teodor-new-chat-ui 4.3.559 → 4.3.561
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/features/chat/components/Message/modals/FileViewerModal.d.ts +1 -1
- package/dist/index.esm.js +4739 -4923
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +36 -36
- package/dist/index.umd.js.map +1 -1
- package/dist/shared/core/api/clients/fileClient.d.ts +1 -0
- package/package.json +1 -1
- package/dist/shared/ui/components/file-preview.d.ts +0 -13
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(z,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("lucide-react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","lucide-react","react-dom"],b):(z=typeof globalThis<"u"?globalThis:z||self,b(z.NewChatUI={},z.React,z.reactSlot,z.classVarianceAuthority,z.clsx,z.tailwindMerge,z.LucideReact,z.ReactDOM))})(this,function(z,b,Jt,Kr,hv,mv,de,Oo){"use strict";var f1=Object.defineProperty;var p1=(z,b,Jt)=>b in z?f1(z,b,{enumerable:!0,configurable:!0,writable:!0,value:Jt}):z[b]=Jt;var sc=(z,b,Jt)=>p1(z,typeof b!="symbol"?b+"":b,Jt);function ic(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=ic(b),qr=ic(Oo),ac=120;function gv(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>ac?`${n.slice(0,ac-3)}…`:n:""}function gi(e){return gv(e.content)||""}function vv(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=gi(o);s&&t.set(r.checkpointId,s)}}return t}function lc(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],p=d.checkpointId,m=p??`cp-${c}`,f=d.metadata??{},x=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let v=null,y=null;const w=Array.isArray(d.messages)?d.messages:[];for(const S of w)S.role==="user"&&(y||(y=S),S.id&&(v=S.id));const C=d.next&&d.next.length>0?String(d.next[0]):null,E=d.parentConfig??null,T={id:m,step:x,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:C,parentConfig:E,userMessageId:v};if(o.push(T),p&&t.set(p,T),p&&y){const S=gi(y);S&&r.set(p,S)}n.push({id:m,messageId:v,step:x,source:g,createdAt:d.createdAt??null,next:C,parentConfig:E})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((p,m)=>{const f=p.createdAt?Date.parse(p.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let p=0;p<c.length;p++){const m=c[p];m.attemptCount=d,m.attemptIndex=p,m.isLatestAttempt=p===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const p of t.values())p.userMessageId===c&&d.push(p);return d.length?(d.sort((p,m)=>{const f=typeof p.attemptIndex=="number"?p.attemptIndex:Number.MAX_SAFE_INTEGER,x=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-x}),d):[]}}}function cc(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function xv(e,t){return e?t.getCheckpoint(e)??null:null}function uc(e){return b.useMemo(()=>lc(e),[e])}function jn(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function _n(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function dc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function vi(e){const t=jn(e);if(t)return jn(t.configurable)??t}function Xn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>bv(s,i)).filter(s=>!!s)].sort((s,i)=>fc(i.createdAt)-fc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function bv(e,t){var T,S;if(!e)return null;const r=(Array.isArray((T=e.values)==null?void 0:T.messages)?e.values.messages:[]).map(k=>wv(k)).filter(k=>!!k),o=jn(e.metadata)??{},s=vi(e.config),i=jn(e.parent_config??e.parentConfig),a=vi(i),l=_n(s,["checkpoint_id","checkpointId"]),c=_n(s,["checkpoint_ns","checkpointNs"]),d=_n(a,["checkpoint_id","checkpointId"]),p=_n(a,["checkpoint_id","checkpointId"])??null,m=_n(a,["checkpoint_ns","checkpointNs"])??null,f=jn(e.config),x=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,v=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:dc(o,["step"])??0,source:_n(o,["source"])??null},w=r.map(k=>({...k,checkpointId:l??null})),C=(S=e.values)==null?void 0:S.interrupts,E=Array.isArray(e.interrupts)?e.interrupts:Array.isArray(C)?C:[];return{checkpointId:l??null,checkpointNs:c??null,createdAt:v,parentId:d??null,messages:w,nextCursor:p,nextCursorNs:m,interrupt:Tv(r,E,t,l??null),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:x}}function wv(e){var s,i,a;if(!e||typeof e!="object")return null;const t=yv(e);if(!t)return null;const n=Cv(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function yv(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&Sv(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function Sv(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function Cv(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function Tv(e,t,n,r,o){const s=t.length,i=kv(e,n);if(i)return i;for(let a=s-1;a>=0;a-=1){const l=t[a];if(!l||typeof l!="object")continue;const c=l,d=c.value??l;if(d==null)continue;return{id:typeof c.id=="string"&&c.id.trim()?c.id:`interrupt-${r??n}-${a}`,value:d}}return null}function kv(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function fc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var xi={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
|
|
9
|
+
*/var pc;function Ev(){if(pc)return Gr;pc=1;var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return Gr.Fragment=n,Gr.jsx=i,Gr.jsxs=i,Gr}var Yr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,30 +14,30 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+_+N}}var
|
|
17
|
+
*/var hc;function Iv(){return hc||(hc=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),x=Symbol.iterator,g="@@iterator";function v(N){if(N===null||typeof N!="object")return null;var te=x&&N[x]||N[g];return typeof te=="function"?te:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(N){{for(var te=arguments.length,ne=new Array(te>1?te-1:0),ce=1;ce<te;ce++)ne[ce-1]=arguments[ce];C("error",N,ne)}}function C(N,te,ne){{var ce=y.ReactDebugCurrentFrame,ge=ce.getStackAddendum();ge!==""&&(te+="%s",ne=ne.concat([ge]));var we=ne.map(function(je){return String(je)});we.unshift("Warning: "+te),Function.prototype.apply.call(console[N],console,we)}}var E=!1,T=!1,S=!1,k=!1,A=!1,P;P=Symbol.for("react.module.reference");function F(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||A||N===o||N===c||N===d||k||N===f||E||T||S||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===p||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===P||N.getModuleId!==void 0))}function $(N,te,ne){var ce=N.displayName;if(ce)return ce;var ge=te.displayName||te.name||"";return ge!==""?ne+"("+ge+")":ne}function B(N){return N.displayName||"Context"}function K(N){if(N==null)return null;if(typeof N.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof N=="function")return N.displayName||N.name||null;if(typeof N=="string")return N;switch(N){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var te=N;return B(te)+".Consumer";case i:var ne=N;return B(ne._context)+".Provider";case l:return $(N,N.render,"ForwardRef");case p:var ce=N.displayName||null;return ce!==null?ce:K(N.type)||"Memo";case m:{var ge=N,we=ge._payload,je=ge._init;try{return K(je(we))}catch{return null}}}return null}var R=Object.assign,W=0,Y,X,O,I,H,J,M;function q(){}q.__reactDisabledLog=!0;function L(){{if(W===0){Y=console.log,X=console.info,O=console.warn,I=console.error,H=console.group,J=console.groupCollapsed,M=console.groupEnd;var N={configurable:!0,enumerable:!0,value:q,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}W++}}function D(){{if(W--,W===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},N,{value:Y}),info:R({},N,{value:X}),warn:R({},N,{value:O}),error:R({},N,{value:I}),group:R({},N,{value:H}),groupCollapsed:R({},N,{value:J}),groupEnd:R({},N,{value:M})})}W<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var G=y.ReactCurrentDispatcher,_;function j(N,te,ne){{if(_===void 0)try{throw Error()}catch(ge){var ce=ge.stack.trim().match(/\n( *(at )?)/);_=ce&&ce[1]||""}return`
|
|
18
|
+
`+_+N}}var U=!1,Z;{var se=typeof WeakMap=="function"?WeakMap:Map;Z=new se}function ae(N,te){if(!N||U)return"";{var ne=Z.get(N);if(ne!==void 0)return ne}var ce;U=!0;var ge=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var we;we=G.current,G.current=null,L();try{if(te){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(Xt){ce=Xt}Reflect.construct(N,[],je)}else{try{je.call()}catch(Xt){ce=Xt}N.call(je.prototype)}}else{try{throw Error()}catch(Xt){ce=Xt}N()}}catch(Xt){if(Xt&&ce&&typeof Xt.stack=="string"){for(var Ee=Xt.stack.split(`
|
|
19
19
|
`),Ut=ce.stack.split(`
|
|
20
20
|
`),yt=Ee.length-1,Et=Ut.length-1;yt>=1&&Et>=0&&Ee[yt]!==Ut[Et];)Et--;for(;yt>=1&&Et>=0;yt--,Et--)if(Ee[yt]!==Ut[Et]){if(yt!==1||Et!==1)do if(yt--,Et--,Et<0||Ee[yt]!==Ut[Et]){var ln=`
|
|
21
|
-
`+Ee[yt].replace(" at new "," at ");return N.displayName&&ln.includes("<anonymous>")&&(ln=ln.replace("<anonymous>",N.displayName)),typeof N=="function"&&Z.set(N,ln),ln}while(yt>=1&&Et>=0);break}}}finally{
|
|
21
|
+
`+Ee[yt].replace(" at new "," at ");return N.displayName&&ln.includes("<anonymous>")&&(ln=ln.replace("<anonymous>",N.displayName)),typeof N=="function"&&Z.set(N,ln),ln}while(yt>=1&&Et>=0);break}}}finally{U=!1,G.current=we,D(),Error.prepareStackTrace=ge}var Vr=N?N.displayName||N.name:"",vr=Vr?j(Vr):"";return typeof N=="function"&&Z.set(N,vr),vr}function Se(N,te,ne){return ae(N,!1)}function Ce(N){var te=N.prototype;return!!(te&&te.isReactComponent)}function Oe(N,te,ne){if(N==null)return"";if(typeof N=="function")return ae(N,Ce(N));if(typeof N=="string")return j(N);switch(N){case c:return j("Suspense");case d:return j("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return Se(N.render);case p:return Oe(N.type,te,ne);case m:{var ce=N,ge=ce._payload,we=ce._init;try{return Oe(we(ge),te,ne)}catch{}}}return""}var Fe=Object.prototype.hasOwnProperty,Be={},Ke=y.ReactDebugCurrentFrame;function ze(N){if(N){var te=N._owner,ne=Oe(N.type,N._source,te?te.type:null);Ke.setExtraStackFrame(ne)}else Ke.setExtraStackFrame(null)}function dt(N,te,ne,ce,ge){{var we=Function.call.bind(Fe);for(var je in N)if(we(N,je)){var Ee=void 0;try{if(typeof N[je]!="function"){var Ut=Error((ce||"React class")+": "+ne+" type `"+je+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[je]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ut.name="Invariant Violation",Ut}Ee=N[je](te,je,ce,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(yt){Ee=yt}Ee&&!(Ee instanceof Error)&&(ze(ge),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ce||"React class",ne,je,typeof Ee),ze(null)),Ee instanceof Error&&!(Ee.message in Be)&&(Be[Ee.message]=!0,ze(ge),w("Failed %s type: %s",ne,Ee.message),ze(null))}}}var pt=Array.isArray;function Ze(N){return pt(N)}function He(N){{var te=typeof Symbol=="function"&&Symbol.toStringTag,ne=te&&N[Symbol.toStringTag]||N.constructor.name||"Object";return ne}}function Re(N){try{return qe(N),!1}catch{return!0}}function qe(N){return""+N}function Ae(N){if(Re(N))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",He(N)),qe(N)}var Ge=y.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0},Ct,Qe;function Tt(N){if(Fe.call(N,"ref")){var te=Object.getOwnPropertyDescriptor(N,"ref").get;if(te&&te.isReactWarning)return!1}return N.ref!==void 0}function ht(N){if(Fe.call(N,"key")){var te=Object.getOwnPropertyDescriptor(N,"key").get;if(te&&te.isReactWarning)return!1}return N.key!==void 0}function wt(N,te){typeof N.ref=="string"&&Ge.current}function At(N,te){{var ne=function(){Ct||(Ct=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};ne.isReactWarning=!0,Object.defineProperty(N,"key",{get:ne,configurable:!0})}}function jt(N,te){{var ne=function(){Qe||(Qe=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};ne.isReactWarning=!0,Object.defineProperty(N,"ref",{get:ne,configurable:!0})}}var mt=function(N,te,ne,ce,ge,we,je){var Ee={$$typeof:t,type:N,key:te,ref:ne,props:je,_owner:we};return Ee._store={},Object.defineProperty(Ee._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ee,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ce}),Object.defineProperty(Ee,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ge}),Object.freeze&&(Object.freeze(Ee.props),Object.freeze(Ee)),Ee};function gt(N,te,ne,ce,ge){{var we,je={},Ee=null,Ut=null;ne!==void 0&&(Ae(ne),Ee=""+ne),ht(te)&&(Ae(te.key),Ee=""+te.key),Tt(te)&&(Ut=te.ref,wt(te,ge));for(we in te)Fe.call(te,we)&&!Xe.hasOwnProperty(we)&&(je[we]=te[we]);if(N&&N.defaultProps){var yt=N.defaultProps;for(we in yt)je[we]===void 0&&(je[we]=yt[we])}if(Ee||Ut){var Et=typeof N=="function"?N.displayName||N.name||"Unknown":N;Ee&&At(je,Et),Ut&&jt(je,Et)}return mt(N,Ee,Ut,ge,ce,Ge.current,je)}}var Ht=y.ReactCurrentOwner,Ve=y.ReactDebugCurrentFrame;function $e(N){if(N){var te=N._owner,ne=Oe(N.type,N._source,te?te.type:null);Ve.setExtraStackFrame(ne)}else Ve.setExtraStackFrame(null)}var ft;ft=!1;function kt(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function ct(){{if(Ht.current){var N=K(Ht.current.type);if(N)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+N+"`."}return""}}function _t(N){return""}var xe={};function Le(N){{var te=ct();if(!te){var ne=typeof N=="string"?N:N.displayName||N.name;ne&&(te=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+ne+">.")}return te}}function Ue(N,te){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ne=Le(te);if(xe[ne])return;xe[ne]=!0;var ce="";N&&N._owner&&N._owner!==Ht.current&&(ce=" It was passed a child from "+
|
|
25
|
+
Check the top-level render call using <`+ne+">.")}return te}}function Ue(N,te){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ne=Le(te);if(xe[ne])return;xe[ne]=!0;var ce="";N&&N._owner&&N._owner!==Ht.current&&(ce=" It was passed a child from "+K(N._owner.type)+"."),$e(N),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,ce),$e(null)}}function st(N,te){{if(typeof N!="object")return;if(Ze(N))for(var ne=0;ne<N.length;ne++){var ce=N[ne];kt(ce)&&Ue(ce,te)}else if(kt(N))N._store&&(N._store.validated=!0);else if(N){var ge=v(N);if(typeof ge=="function"&&ge!==N.entries)for(var we=ge.call(N),je;!(je=we.next()).done;)kt(je.value)&&Ue(je.value,te)}}}function tt(N){{var te=N.type;if(te==null||typeof te=="string")return;var ne;if(typeof te=="function")ne=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===p))ne=te.propTypes;else return;if(ne){var ce=K(te);dt(ne,N.props,"prop",ce,N)}else if(te.PropTypes!==void 0&&!ft){ft=!0;var ge=K(te);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ge||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ut(N){{for(var te=Object.keys(N.props),ne=0;ne<te.length;ne++){var ce=te[ne];if(ce!=="children"&&ce!=="key"){$e(N),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ce),$e(null);break}}N.ref!==null&&($e(N),w("Invalid attribute `ref` supplied to `React.Fragment`."),$e(null))}}var et={};function Q(N,te,ne,ce,ge,we){{var je=F(N);if(!je){var Ee="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Ee+=" 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 Ut=_t();Ut?Ee+=Ut:Ee+=ct();var yt;N===null?yt="null":Ze(N)?yt="array":N!==void 0&&N.$$typeof===t?(yt="<"+(K(N.type)||"Unknown")+" />",Ee=" Did you accidentally export a JSX literal instead of a component?"):yt=typeof N,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",yt,Ee)}var Et=gt(N,te,ne,ge,we);if(Et==null)return Et;if(je){var ln=te.children;if(ln!==void 0)if(ce)if(Ze(ln)){for(var Vr=0;Vr<ln.length;Vr++)st(ln[Vr],N);Object.freeze&&Object.freeze(ln)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else st(ln,N)}if(Fe.call(te,"key")){var vr=K(N),Xt=Object.keys(te).filter(function(d1){return d1!=="key"}),oc=Xt.length>0?"{key: someKey, "+Xt.join(": ..., ")+": ...}":"{key: someKey}";if(!et[vr+oc]){var u1=Xt.length>0?"{"+Xt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,ic,vr,hN,vr),tt[vr+ic]=!0}}return N===r?ut(Et):nt(Et),Et}}function ee(N,te,ne){return Q(N,te,ne,!0)}function he(N,te,ne){return Q(N,te,ne,!1)}var de=he,Ie=ee;Yr.Fragment=r,Yr.jsx=de,Yr.jsxs=Ie}()),Yr}process.env.NODE_ENV==="production"?wi.exports=Iv():wi.exports=Nv();var u=wi.exports;const Av=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=x.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const b=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${b?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${b?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${b?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function vc(e,t){return function(){return e.apply(t,arguments)}}const{toString:jv}=Object.prototype,{getPrototypeOf:yi}=Object,{iterator:Do,toStringTag:xc}=Symbol,Lo=(e=>t=>{const n=jv.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>Lo(t)===e),$o=e=>t=>typeof t===e,{isArray:xr}=Array,br=$o("undefined");function Xr(e){return e!==null&&!br(e)&&e.constructor!==null&&!br(e.constructor)&&Wt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const bc=cn("ArrayBuffer");function Pv(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&bc(e.buffer),t}const _v=$o("string"),Wt=$o("function"),wc=$o("number"),Jr=e=>e!==null&&typeof e=="object",Mv=e=>e===!0||e===!1,Fo=e=>{if(Lo(e)!=="object")return!1;const t=yi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(xc in e)&&!(Do in e)},Rv=e=>{if(!Jr(e)||Xr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ov=cn("Date"),Dv=cn("File"),Lv=cn("Blob"),$v=cn("FileList"),Fv=e=>Jr(e)&&Wt(e.pipe),Bv=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Wt(e.append)&&((t=Lo(e))==="formdata"||t==="object"&&Wt(e.toString)&&e.toString()==="[object FormData]"))},zv=cn("URLSearchParams"),[Hv,Uv,Wv,Vv]=["ReadableStream","Request","Response","Headers"].map(cn),Kv=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),xr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Xr(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 yc(e,t){if(Xr(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 Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Sc=e=>!br(e)&&e!==Jn;function Si(){const{caseless:e,skipUndefined:t}=Sc(this)&&this||{},n={},r=(o,s)=>{const i=e&&yc(n,s)||s;Fo(n[i])&&Fo(o)?n[i]=Si(n[i],o):Fo(o)?n[i]=Si({},o):xr(o)?n[i]=o.slice():(!t||!br(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Zr(arguments[o],r);return n}const qv=(e,t,n,{allOwnKeys:r}={})=>(Zr(t,(o,s)=>{n&&Wt(o)?e[s]=vc(o,n):e[s]=o},{allOwnKeys:r}),e),Gv=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Yv=(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)},Xv=(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&&yi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Jv=(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},Zv=e=>{if(!e)return null;if(xr(e))return e;let t=e.length;if(!wc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qv=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yi(Uint8Array)),ex=(e,t)=>{const r=(e&&e[Do]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},tx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nx=cn("HTMLFormElement"),rx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Cc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ox=cn("RegExp"),Tc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},sx=e=>{Tc(e,(t,n)=>{if(Wt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Wt(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+"'")})}})},ix=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return xr(e)?r(e):r(String(e).split(t)),n},ax=()=>{},lx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function cx(e){return!!(e&&Wt(e.append)&&e[xc]==="FormData"&&e[Do])}const ux=e=>{const t=new Array(10),n=(r,o)=>{if(Jr(r)){if(t.indexOf(r)>=0)return;if(Xr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=xr(r)?[]:{};return Zr(r,(i,a)=>{const l=n(i,o+1);!br(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},dx=cn("AsyncFunction"),fx=e=>e&&(Jr(e)||Wt(e))&&Wt(e.then)&&Wt(e.catch),kc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Wt(Jn.postMessage)),px=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||kc,q={isArray:xr,isArrayBuffer:bc,isBuffer:Xr,isFormData:Bv,isArrayBufferView:Pv,isString:_v,isNumber:wc,isBoolean:Mv,isObject:Jr,isPlainObject:Fo,isEmptyObject:Rv,isReadableStream:Hv,isRequest:Uv,isResponse:Wv,isHeaders:Vv,isUndefined:br,isDate:Ov,isFile:Dv,isBlob:Lv,isRegExp:ox,isFunction:Wt,isStream:Fv,isURLSearchParams:zv,isTypedArray:Qv,isFileList:$v,forEach:Zr,merge:Si,extend:qv,trim:Kv,stripBOM:Gv,inherits:Yv,toFlatObject:Xv,kindOf:Lo,kindOfTest:cn,endsWith:Jv,toArray:Zv,forEachEntry:ex,matchAll:tx,isHTMLForm:nx,hasOwnProperty:Cc,hasOwnProp:Cc,reduceDescriptors:Tc,freezeMethods:sx,toObjectSet:ix,toCamelCase:rx,noop:ax,toFiniteNumber:lx,findKey:yc,global:Jn,isContextDefined:Sc,isSpecCompliantForm:cx,toJSONObject:ux,isAsyncFn:dx,isThenable:fx,setImmediate:kc,asap:px,isIterable:e=>e!=null&&Wt(e[Do])};function je(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)}q.inherits(je,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:q.toJSONObject(this.config),code:this.code,status:this.status}}});const Ec=je.prototype,Ic={};["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=>{Ic[e]={value:e}}),Object.defineProperties(je,Ic),Object.defineProperty(Ec,"isAxiosError",{value:!0}),je.from=(e,t,n,r,o,s)=>{const i=Object.create(Ec);q.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return je.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const hx=null;function Ci(e){return q.isPlainObject(e)||q.isArray(e)}function Nc(e){return q.endsWith(e,"[]")?e.slice(0,-2):e}function Ac(e,t,n){return e?e.concat(t).map(function(o,s){return o=Nc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function mx(e){return q.isArray(e)&&!e.some(Ci)}const gx=q.toFlatObject(q,{},null,function(t){return/^is[A-Z]/.test(t)});function Bo(e,t,n){if(!q.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=q.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,v){return!q.isUndefined(v[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&q.isSpecCompliantForm(t);if(!q.isFunction(o))throw new TypeError("visitor must be a function");function c(b){if(b===null)return"";if(q.isDate(b))return b.toISOString();if(q.isBoolean(b))return b.toString();if(!l&&q.isBlob(b))throw new je("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(b)||q.isTypedArray(b)?l&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function d(b,g,v){let y=b;if(b&&!v&&typeof b=="object"){if(q.endsWith(g,"{}"))g=r?g:g.slice(0,-2),b=JSON.stringify(b);else if(q.isArray(b)&&mx(b)||(q.isFileList(b)||q.endsWith(g,"[]"))&&(y=q.toArray(b)))return g=Nc(g),y.forEach(function(C,E){!(q.isUndefined(C)||C===null)&&t.append(i===!0?Ac([g],E,s):i===null?g:g+"[]",c(C))}),!1}return Ci(b)?!0:(t.append(Ac(v,g,s),c(b)),!1)}const p=[],m=Object.assign(gx,{defaultVisitor:d,convertValue:c,isVisitable:Ci});function f(b,g){if(!q.isUndefined(b)){if(p.indexOf(b)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(b),q.forEach(b,function(y,w){(!(q.isUndefined(y)||y===null)&&o.call(t,y,q.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),p.pop()}}if(!q.isObject(e))throw new TypeError("data must be an object");return f(e),t}function jc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ti(e,t){this._pairs=[],e&&Bo(e,this,t)}const Pc=Ti.prototype;Pc.append=function(t,n){this._pairs.push([t,n])},Pc.toString=function(t){const n=t?function(r){return t.call(this,r,jc)}:jc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function vx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function _c(e,t,n){if(!t)return e;const r=n&&n.encode||vx;q.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=q.isURLSearchParams(t)?t.toString():new Ti(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Mc{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){q.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Rc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ti,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ki=typeof window<"u"&&typeof document<"u",Ei=typeof navigator=="object"&&navigator||void 0,bx=ki&&(!Ei||["ReactNative","NativeScript","NS"].indexOf(Ei.product)<0),wx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yx=ki&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ki,hasStandardBrowserEnv:bx,hasStandardBrowserWebWorkerEnv:wx,navigator:Ei,origin:yx},Symbol.toStringTag,{value:"Module"})),...xx};function Sx(e,t){return Bo(e,new Mt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Mt.isNode&&q.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Cx(e){return q.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Tx(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 Oc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&q.isArray(o)?o.length:i,l?(q.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!q.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&q.isArray(o[i])&&(o[i]=Tx(o[i])),!a)}if(q.isFormData(e)&&q.isFunction(e.entries)){const n={};return q.forEachEntry(e,(r,o)=>{t(Cx(r),o,n,0)}),n}return null}function kx(e,t,n){if(q.isString(e))try{return(t||JSON.parse)(e),q.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Qr={transitional:Rc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=q.isObject(t);if(s&&q.isHTMLForm(t)&&(t=new FormData(t)),q.isFormData(t))return o?JSON.stringify(Oc(t)):t;if(q.isArrayBuffer(t)||q.isBuffer(t)||q.isStream(t)||q.isFile(t)||q.isBlob(t)||q.isReadableStream(t))return t;if(q.isArrayBufferView(t))return t.buffer;if(q.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 Sx(t,this.formSerializer).toString();if((a=q.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Bo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),kx(t)):t}],transformResponse:[function(t){const n=this.transitional||Qr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(q.isResponse(t)||q.isReadableStream(t))return t;if(t&&q.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"?je.from(a,je.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Mt.classes.FormData,Blob:Mt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};q.forEach(["delete","get","head","post","put","patch"],e=>{Qr.headers[e]={}});const Ex=q.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"]),Ix=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[Dc]=this[Dc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=eo(i);r[a]||(Px(o,i),r[a]=!0)}return q.isArray(t)?t.forEach(s):s(t),this}};Vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),q.reduceDescriptors(Vt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),q.freezeMethods(Vt);function Ni(e,t){const n=this||Qr,r=t||n,o=Vt.from(r.headers);let s=r.data;return q.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Lc(e){return!!(e&&e.__CANCEL__)}function wr(e,t,n){je.call(this,e??"canceled",je.ERR_CANCELED,t,n),this.name="CanceledError"}q.inherits(wr,je,{__CANCEL__:!0});function $c(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new je("Request failed with status code "+n.status,[je.ERR_BAD_REQUEST,je.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function _x(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Mx(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function Rx(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Ho=(e,t,n=3)=>{let r=0;const o=Mx(50,250);return Rx(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Fc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Bc=e=>(...t)=>q.asap(()=>e(...t)),Ox=Mt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Mt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Mt.origin),Mt.navigator&&/(msie|trident)/i.test(Mt.navigator.userAgent)):()=>!0,Dx=Mt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];q.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),q.isString(r)&&i.push("path="+r),q.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 Lx(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function $x(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function zc(e,t,n){let r=!Lx(t);return e&&(r||n==!1)?$x(e,t):t}const Hc=e=>e instanceof Vt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,p,m){return q.isPlainObject(c)&&q.isPlainObject(d)?q.merge.call({caseless:m},c,d):q.isPlainObject(d)?q.merge({},d):q.isArray(d)?d.slice():d}function o(c,d,p,m){if(q.isUndefined(d)){if(!q.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!q.isUndefined(d))return r(void 0,d)}function i(c,d){if(q.isUndefined(d)){if(!q.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(Hc(c),Hc(d),p,!0)};return q.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);q.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Uc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Vt.from(i),t.url=_c(zc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),q.isFormData(n)){if(Mt.hasStandardBrowserEnv||Mt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(q.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(Mt.hasStandardBrowserEnv&&(r&&q.isFunction(r)&&(r=r(t)),r||r!==!1&&Ox(t.url))){const l=o&&s&&Dx.read(s);l&&i.set(o,l)}return t},Fx=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Uc(e);let s=o.data;const i=Vt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,b;function g(){f&&f(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let v=new XMLHttpRequest;v.open(o.method.toUpperCase(),o.url,!0),v.timeout=o.timeout;function y(){if(!v)return;const C=Vt.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:C,config:e,request:v};$c(function(k){n(k),g()},function(k){r(k),g()},T),v=null}"onloadend"in v?v.onloadend=y:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(y)},v.onabort=function(){v&&(r(new je("Request aborted",je.ECONNABORTED,e,v)),v=null)},v.onerror=function(E){const T=E&&E.message?E.message:"Network Error",S=new je(T,je.ERR_NETWORK,e,v);S.event=E||null,r(S),v=null},v.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||Rc;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new je(E,T.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,e,v)),v=null},s===void 0&&i.setContentType(null),"setRequestHeader"in v&&q.forEach(i.toJSON(),function(E,T){v.setRequestHeader(T,E)}),q.isUndefined(o.withCredentials)||(v.withCredentials=!!o.withCredentials),a&&a!=="json"&&(v.responseType=o.responseType),c&&([m,b]=Ho(c,!0),v.addEventListener("progress",m)),l&&v.upload&&([p,f]=Ho(l),v.upload.addEventListener("progress",p),v.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=C=>{v&&(r(!C||C.type?new wr(null,e,v):C),v.abort(),v=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=_x(o.url);if(w&&Mt.protocols.indexOf(w)===-1){r(new je("Unsupported protocol "+w+":",je.ERR_BAD_REQUEST,e));return}v.send(s||null)})},Bx=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof je?d:new wr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new je(`timeout ${t} of ms exceeded`,je.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>q.asap(a),l}},zx=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},Hx=async function*(e,t){for await(const n of Ux(e))yield*zx(n,t)},Ux=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()}},Wc=(e,t,n,r)=>{const o=Hx(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Vc=64*1024,{isFunction:Uo}=q,Wx=(({Request:e,Response:t})=>({Request:e,Response:t}))(q.global),{ReadableStream:Kc,TextEncoder:qc}=q.global,Gc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Vx=e=>{e=q.merge.call({skipUndefined:!0},Wx,e);const{fetch:t,Request:n,Response:r}=e,o=t?Uo(t):typeof fetch=="function",s=Uo(n),i=Uo(r);if(!o)return!1;const a=o&&Uo(Kc),l=o&&(typeof qc=="function"?(b=>g=>b.encode(g))(new qc):async b=>new Uint8Array(await new n(b).arrayBuffer())),c=s&&a&&Gc(()=>{let b=!1;const g=new n(Mt.origin,{body:new Kc,method:"POST",get duplex(){return b=!0,"half"}}).headers.has("Content-Type");return b&&!g}),d=i&&a&&Gc(()=>q.isReadableStream(new r("").body)),p={stream:d&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!p[b]&&(p[b]=(g,v)=>{let y=g&&g[b];if(y)return y.call(g);throw new je(`Response type '${b}' is not supported`,je.ERR_NOT_SUPPORT,v)})});const m=async b=>{if(b==null)return 0;if(q.isBlob(b))return b.size;if(q.isSpecCompliantForm(b))return(await new n(Mt.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(q.isArrayBufferView(b)||q.isArrayBuffer(b))return b.byteLength;if(q.isURLSearchParams(b)&&(b=b+""),q.isString(b))return(await l(b)).byteLength},f=async(b,g)=>{const v=q.toFiniteNumber(b.getContentLength());return v??m(g)};return async b=>{let{url:g,method:v,data:y,signal:w,cancelToken:C,timeout:E,onDownloadProgress:T,onUploadProgress:S,responseType:k,headers:A,withCredentials:j="same-origin",fetchOptions:B}=Uc(b),$=t||fetch;k=k?(k+"").toLowerCase():"text";let z=Bx([w,C&&C.toAbortSignal()],E),G=null;const M=z&&z.unsubscribe&&(()=>{z.unsubscribe()});let F;try{if(S&&c&&v!=="get"&&v!=="head"&&(F=await f(A,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),O;if(q.isFormData(y)&&(O=J.headers.get("content-type"))&&A.setContentType(O),J.body){const[Y,L]=Fc(F,Ho(Bc(S)));y=Wc(J.body,Vc,Y,L)}}q.isString(j)||(j=j?"include":"omit");const V=s&&"credentials"in n.prototype,K={...B,signal:z,method:v.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:V?j:void 0};G=s&&new n(g,K);let R=await(s?$(G,B):$(g,K));const I=d&&(k==="stream"||k==="response");if(d&&(T||I&&M)){const J={};["status","statusText","headers"].forEach(D=>{J[D]=R[D]});const O=q.toFiniteNumber(R.headers.get("content-length")),[Y,L]=T&&Fc(O,Ho(Bc(T),!0))||[];R=new r(Wc(R.body,Vc,Y,()=>{L&&L(),M&&M()}),J)}k=k||"text";let U=await p[q.findKey(p,k)||"text"](R,b);return!I&&M&&M(),await new Promise((J,O)=>{$c(J,O,{data:U,headers:Vt.from(R.headers),status:R.status,statusText:R.statusText,config:b,request:G})})}catch(V){throw M&&M(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,b,G),{cause:V.cause||V}):je.from(V,V&&V.code,b,G)}}},Kx=new Map,Yc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Kx;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Vx(t)),d=c;return c};Yc();const Ai={http:hx,xhr:Fx,fetch:{get:Yc}};q.forEach(Ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Xc=e=>`- ${e}`,qx=e=>q.isFunction(e)||e===null||e===!1,Jc={getAdapter:(e,t)=>{e=q.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,!qx(r)&&(o=Ai[(a=String(r)).toLowerCase()],o===void 0))throw new je(`Unknown adapter '${a}'`);if(o&&(q.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
-
`+i.map(
|
|
34
|
-
`):" "+
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Vo.assertOptions(r,{silentJSONParsing:vn.transitional(vn.boolean),forcedJSONParsing:vn.transitional(vn.boolean),clarifyTimeoutError:vn.transitional(vn.boolean)},!1),o!=null&&(q.isFunction(o)?n.paramsSerializer={serialize:o}:Vo.assertOptions(o,{encode:vn.function,serialize:vn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Vo.assertOptions(n,{baseUrl:vn.spelling("baseURL"),withXsrfToken:vn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&q.merge(s.common,s[n.method]);s&&q.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),n.headers=Vt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const b=[Zc.bind(this),void 0];for(b.unshift(...a),b.push(...c),m=b.length,d=Promise.resolve(n);p<m;)d=d.then(b[p++],b[p++]);return d}m=a.length;let f=n;for(;p<m;){const b=a[p++],g=a[p++];try{f=b(f)}catch(v){g.call(this,v);break}}try{d=Zc.call(this,f)}catch(b){return Promise.reject(b)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Zn(this.defaults,t);const n=zc(t.baseURL,t.url,t.allowAbsoluteUrls);return _c(n,t.params,t.paramsSerializer)}};q.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),q.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let Yx=class hv{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 wr(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 hv(function(o){t=o}),cancel:t}}};function Xx(e){return function(n){return e.apply(null,n)}}function Jx(e){return q.isObject(e)&&e.isAxiosError===!0}const Pi={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(Pi).forEach(([e,t])=>{Pi[t]=e});function tu(e){const t=new Qn(e),n=vc(Qn.prototype.request,t);return q.extend(n,Qn.prototype,t,{allOwnKeys:!0}),q.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return tu(Zn(e,o))},n}const vt=tu(Qr);vt.Axios=Qn,vt.CanceledError=wr,vt.CancelToken=Yx,vt.isCancel=Lc,vt.VERSION=Qc,vt.toFormData=Bo,vt.AxiosError=je,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=Xx,vt.isAxiosError=Jx,vt.mergeConfig=Zn,vt.AxiosHeaders=Vt,vt.formToJSON=e=>Oc(q.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Jc.getAdapter,vt.HttpStatusCode=Pi,vt.default=vt;const{Axios:TN,AxiosError:kN,CanceledError:EN,isCancel:nu,CancelToken:IN,VERSION:NN,all:AN,Cancel:jN,isAxiosError:PN,spread:_N,toFormData:MN,AxiosHeaders:RN,HttpStatusCode:ON,formToJSON:DN,getAdapter:LN,mergeConfig:$N}=vt;let Ko=null;const _i=new Set;function Mi(){return Ko}function Mn(e){Ko=e,_i.forEach(t=>t(e))}function Ri(e){return _i.add(e),()=>_i.delete(e)}const ru=3e4,ou=9e4,Lt=vt.create({timeout:ru,withCredentials:!0});Lt.interceptors.request.use(e=>(Ko&&(e.headers.Authorization=`Bearer ${Ko}`),e)),Lt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Mn(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Kt(e,t){return Lt.defaults.baseURL?(await Lt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function to(e,t,n){return Lt.defaults.baseURL?(await Lt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function su(e,t,n){return Lt.defaults.baseURL?(await Lt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Lt.defaults.baseURL?(await Lt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class iu{get baseUrl(){return Lt.defaults.baseURL||""}updateConfig(t){if(t.chatBaseUrl)Lt.defaults.baseURL=t.chatBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");n.endsWith("/chat")?Lt.defaults.baseURL=n:Lt.defaults.baseURL=`${n}/chat`}t.apiKey!==void 0?Mn(t.apiKey):t.getToken&&Mn(t.getToken())}getAuthToken(){return Mi()}setAuthToken(t){Mn(t)}onTokenChange(t){return Ri(t)}async listThreads(){const t=await Kt("/threads"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Kt("/threads/shared"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t,n){const r={};t&&(r.title=t),n&&(r.project=n);const o=await to("/threads",Object.keys(r).length?r:void 0);return $t(o)}async updateThread(t,n){const r=await su(`/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return $t(n)}async shareThread(t,n){const r=await to(`/threads/${t}/share`,{shared_with_user_id:n});return $t(r)}async threadInfo(t){const n=await Kt(`/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Kt("/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Kt(`/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Kt(`/agents/${t}/schema`);return $t(n)}async getState(t){const n=await Kt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return $t(n)}async getStateHistory(t){const n=await Kt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:ou,signal:t.signal});return $t(n)}async cancelRun(t){const n=await to("/runs/cancel",{threadId:t});return $t(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return $t(r)}}const Rn=new iu;class au{async fetchFileBlob(t,n){return await Kt(t,{responseType:"blob",onDownloadProgress:o=>{try{if(n&&o.lengthComputable){const s=o.loaded/o.total;n(s)}}catch{}},maxBodyLength:1/0})}async viewFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/view`,n),o=URL.createObjectURL(r);window.open(o,"_blank"),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileContent(t,n){return await(await this.fetchFileBlob(`/files/${t}/view`,n)).text()}async downloadFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/download`,n),o=URL.createObjectURL(r);let s=`file_${t}`;try{const a=await Kt(`/files/${t}`);s=(a==null?void 0:a.filename)??s}catch{}const i=document.createElement("a");i.href=o,i.download=s,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileInfo(t){return await Kt(`/files/${t}`)}async listFiles(t,n=50,r=0){const o={limit:n,offset:r};return t&&(o.thread_id=t),await Kt("/files",{params:o})}async uploadFile(t,n,r){const o=new FormData;return o.append("file",t),n&&o.append("thread_id",n),await to("/files/upload-form",o,{onUploadProgress:s=>{try{if(r&&s.lengthComputable){const i=s.loaded/s.total;r(i)}}catch{}}})}}const lu=new au;class Zx{constructor(){ac(this,"_authBaseUrl","")}get baseUrl(){return this._authBaseUrl}updateConfig(t){if(t.authBaseUrl)this._authBaseUrl=t.authBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");this._authBaseUrl=`${n}/auth`}t.apiKey!==void 0?Mn(t.apiKey):t.getToken&&Mn(t.getToken())}getAuthToken(){return Mi()}setAuthToken(t){Mn(t)}onTokenChange(t){return Ri(t)}async listUsers(){const t=await Kt("/users",{baseURL:this.baseUrl});return(t==null?void 0:t.users)??[]}}const Qx=new Zx,cu=x.createContext(null);function uu({children:e,apiConfig:t}){const n=Rn,r=Qx;if(t){const s=n.baseUrl,i=r.baseUrl,a=n.getAuthToken();(t.baseUrl||t.chatBaseUrl)&&(t.chatBaseUrl&&t.chatBaseUrl!==s||t.baseUrl&&!s.startsWith(t.baseUrl))&&n.updateConfig(t),(t.baseUrl||t.authBaseUrl)&&(t.authBaseUrl&&t.authBaseUrl!==i||t.baseUrl&&!i.startsWith(t.baseUrl))&&r.updateConfig(t),t.apiKey!==void 0&&t.apiKey!==a&&(n.updateConfig({apiKey:t.apiKey}),r.updateConfig({apiKey:t.apiKey}))}const o={token:n.getAuthToken(),setToken:s=>{n.setAuthToken(s),r.setAuthToken(s)},chatApi:n,authApi:r,fileApi:lu,baseUrl:n.baseUrl};return u.jsx(cu.Provider,{value:o,children:e})}async function du(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function fu(e=[]){const t=[],n=[];for(const r of e)try{const o=await du(r),s=r.type||"application/octet-stream";n.push({filename:r.name,data:o,mime_type:s}),s.startsWith("image/")?t.push({type:"image_url",url:`data:${s};base64,${o}`,mimeType:s,alt:r.name}):t.push({type:"file",url:`data:${s};base64,${o}`,mimeType:s,name:r.name,size:r.size,sourceType:"base64"})}catch{}return{contentParts:t,filesInfo:n}}function On(){const e=x.useContext(cu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function pu(e){return!!e&&typeof e=="object"&&"data"in e}function eb(e={}){const t=e.baseUrl||"",n=e.streamPath??"/runs/stream",[r,o]=x.useState(e.token??null),s=x.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=x.useState(!1),[c,d]=x.useState(null),[p,m]=x.useState(""),[f,b]=x.useState(null),[g,v]=x.useState(0),[y,w]=x.useState(!1),[C,E]=x.useState(null),T=x.useRef(null),S=x.useRef(!0),k=x.useRef(0),A=x.useRef(null),j=x.useRef(null),B=x.useRef(null),$=x.useRef(null),z=x.useRef({messageId:null,lastSeq:null,lastText:""}),G=x.useCallback(K=>{o(K)},[]),M=x.useCallback(()=>{m(""),b(null),d(null),j.current=null,B.current=null,$.current=null,E(null),z.current={messageId:null,lastSeq:null,lastText:""}},[]),F=x.useCallback(()=>{var U;console.debug("[use-chat] stop() invoked - aborting stream");const K=(U=A.current)==null?void 0:U.threadId,R=()=>{var J;(J=T.current)==null||J.abort(),T.current=null,A.current=null,l(!1),w(!1),k.current=0,v(0)};(K?Rn.cancelRun(K).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(R)},[]),V=x.useCallback((K,R,I)=>{T.current&&(T.current.abort(),T.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),b(null),j.current=null,B.current=null,$.current=null,E(null),z.current={messageId:null,lastSeq:null,lastText:""};const U=new AbortController;T.current=U;let J=null,O=null,Y=!1;return A.current={threadId:K.threadId??null,headers:{}},(async()=>{var D,X,_,P,W,Z,se,ae,Se,Ce,Oe,Fe,Be,Ke,ze,dt,pt,Ze;const L=He=>{var Me;try{const qe=JSON.parse(JSON.stringify(He));return(Me=qe==null?void 0:qe.payload)!=null&&Me.files_info&&Array.isArray(qe.payload.files_info)&&(qe.payload.files_info=qe.payload.files_info.map(Ae=>({...Ae,data:Ae!=null&&Ae.data?`<base64 ${String(Ae.data).length} chars>`:Ae==null?void 0:Ae.data}))),qe}catch{return He}};try{let He={};try{if(r)He={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const $e=window.__AUTH_TOKEN__,ft=((D=window.localStorage)==null?void 0:D.getItem("authToken"))||null;let kt=null;try{const _t=(X=window.localStorage)==null?void 0:X.getItem("chat-settings");_t&&(kt=((_=JSON.parse(_t))==null?void 0:_.apiKey)||null)}catch{}const ct=$e||ft||kt||null;ct&&(He={Authorization:`Bearer ${ct}`})}}catch{}console.debug("[use-chat] POST",t+n,L(K));let Me={};if(typeof window<"u")try{const Ve=(P=window.localStorage)==null?void 0:P.getItem("authSessionId");Ve&&(Me={"X-Session-Id":Ve})}catch{}const qe={...He,...Me,...s.current},Ae={"Content-Type":"application/json",Accept:"text/event-stream",...qe},Ge=await fetch(t+n,{method:"POST",headers:Ae,body:JSON.stringify(K),signal:U.signal,credentials:i});if(A.current&&(A.current.headers=qe),!Ge.ok||!Ge.body){const Ve=await Ge.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ge.status,Ve==null?void 0:Ve.slice(0,500));const $e=`stream ${Ge.status}${Ve?": "+Ve:""}`;throw(W=I==null?void 0:I.onConnectionError)==null||W.call(I,$e),Y=!0,J="error",O=$e,new Error($e)}w(!0);const Xe=Ge.body.getReader(),Ct=new TextDecoder;let Qe="",Tt=[];k.current=0,v(0);let ht=0,wt=null;const At=()=>{if(Tt.length){const Ve=Tt.join("");Tt=[],S.current&&m($e=>$e+Ve)}wt=null},Pt=()=>{typeof window<"u"&&wt==null&&(wt=requestAnimationFrame(At))};let mt=Date.now();const gt=setInterval(()=>{var Ve;if(Date.now()-mt>18e5){const $e="Stream idle timeout";d($e),J="error",O=$e,U.abort(),(Ve=I==null?void 0:I.onError)==null||Ve.call(I,$e)}},5e3),Ht=1024*1024;try{const Ve=Ge.headers.get("X-Thread-Id")||Ge.headers.get("x-thread-id"),$e=Ge.headers.get("X-Thread-Created")||Ge.headers.get("x-thread-created"),ft=Ve??null,kt=String($e??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:ft}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:ft,created:kt});;){const{value:ct,done:_t}=await Xe.read();if(_t)break;Qe+=Ct.decode(ct,{stream:!0}),Qe.length>Ht&&(Qe="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=Qe.indexOf(`
|
|
30
|
+
<%s key={someKey} {...props} />`,oc,vr,u1,vr),et[vr+oc]=!0}}return N===r?ut(Et):tt(Et),Et}}function ee(N,te,ne){return Q(N,te,ne,!0)}function he(N,te,ne){return Q(N,te,ne,!1)}var ue=he,Ie=ee;Yr.Fragment=r,Yr.jsx=ue,Yr.jsxs=Ie}()),Yr}process.env.NODE_ENV==="production"?xi.exports=Ev():xi.exports=Iv();var u=xi.exports;const Nv=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const x=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${x?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${x?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${x?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function mc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Av}=Object.prototype,{getPrototypeOf:bi}=Object,{iterator:Do,toStringTag:gc}=Symbol,Lo=(e=>t=>{const n=Av.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>Lo(t)===e),$o=e=>t=>typeof t===e,{isArray:xr}=Array,br=$o("undefined");function Xr(e){return e!==null&&!br(e)&&e.constructor!==null&&!br(e.constructor)&&Wt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const vc=cn("ArrayBuffer");function Pv(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&vc(e.buffer),t}const jv=$o("string"),Wt=$o("function"),xc=$o("number"),Jr=e=>e!==null&&typeof e=="object",_v=e=>e===!0||e===!1,Fo=e=>{if(Lo(e)!=="object")return!1;const t=bi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(gc in e)&&!(Do in e)},Rv=e=>{if(!Jr(e)||Xr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Mv=cn("Date"),Ov=cn("File"),Dv=cn("Blob"),Lv=cn("FileList"),$v=e=>Jr(e)&&Wt(e.pipe),Fv=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Wt(e.append)&&((t=Lo(e))==="formdata"||t==="object"&&Wt(e.toString)&&e.toString()==="[object FormData]"))},Bv=cn("URLSearchParams"),[zv,Hv,Uv,Wv]=["ReadableStream","Request","Response","Headers"].map(cn),Vv=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),xr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Xr(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 bc(e,t){if(Xr(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 Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,wc=e=>!br(e)&&e!==Jn;function wi(){const{caseless:e,skipUndefined:t}=wc(this)&&this||{},n={},r=(o,s)=>{const i=e&&bc(n,s)||s;Fo(n[i])&&Fo(o)?n[i]=wi(n[i],o):Fo(o)?n[i]=wi({},o):xr(o)?n[i]=o.slice():(!t||!br(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Zr(arguments[o],r);return n}const Kv=(e,t,n,{allOwnKeys:r}={})=>(Zr(t,(o,s)=>{n&&Wt(o)?e[s]=mc(o,n):e[s]=o},{allOwnKeys:r}),e),qv=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Gv=(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)},Yv=(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&&bi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xv=(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},Jv=e=>{if(!e)return null;if(xr(e))return e;let t=e.length;if(!xc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zv=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&bi(Uint8Array)),Qv=(e,t)=>{const r=(e&&e[Do]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},ex=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},tx=cn("HTMLFormElement"),nx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),yc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),rx=cn("RegExp"),Sc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},ox=e=>{Sc(e,(t,n)=>{if(Wt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Wt(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+"'")})}})},sx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return xr(e)?r(e):r(String(e).split(t)),n},ix=()=>{},ax=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lx(e){return!!(e&&Wt(e.append)&&e[gc]==="FormData"&&e[Do])}const cx=e=>{const t=new Array(10),n=(r,o)=>{if(Jr(r)){if(t.indexOf(r)>=0)return;if(Xr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=xr(r)?[]:{};return Zr(r,(i,a)=>{const l=n(i,o+1);!br(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ux=cn("AsyncFunction"),dx=e=>e&&(Jr(e)||Wt(e))&&Wt(e.then)&&Wt(e.catch),Cc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Wt(Jn.postMessage)),fx=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||Cc,V={isArray:xr,isArrayBuffer:vc,isBuffer:Xr,isFormData:Fv,isArrayBufferView:Pv,isString:jv,isNumber:xc,isBoolean:_v,isObject:Jr,isPlainObject:Fo,isEmptyObject:Rv,isReadableStream:zv,isRequest:Hv,isResponse:Uv,isHeaders:Wv,isUndefined:br,isDate:Mv,isFile:Ov,isBlob:Dv,isRegExp:rx,isFunction:Wt,isStream:$v,isURLSearchParams:Bv,isTypedArray:Zv,isFileList:Lv,forEach:Zr,merge:wi,extend:Kv,trim:Vv,stripBOM:qv,inherits:Gv,toFlatObject:Yv,kindOf:Lo,kindOfTest:cn,endsWith:Xv,toArray:Jv,forEachEntry:Qv,matchAll:ex,isHTMLForm:tx,hasOwnProperty:yc,hasOwnProp:yc,reduceDescriptors:Sc,freezeMethods:ox,toObjectSet:sx,toCamelCase:nx,noop:ix,toFiniteNumber:ax,findKey:bc,global:Jn,isContextDefined:wc,isSpecCompliantForm:lx,toJSONObject:cx,isAsyncFn:ux,isThenable:dx,setImmediate:Cc,asap:fx,isIterable:e=>e!=null&&Wt(e[Do])};function Pe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}V.inherits(Pe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const Tc=Pe.prototype,kc={};["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=>{kc[e]={value:e}}),Object.defineProperties(Pe,kc),Object.defineProperty(Tc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(Tc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const px=null;function yi(e){return V.isPlainObject(e)||V.isArray(e)}function Ec(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function Ic(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ec(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function hx(e){return V.isArray(e)&&!e.some(yi)}const mx=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Bo(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,v){return!V.isUndefined(v[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function c(x){if(x===null)return"";if(V.isDate(x))return x.toISOString();if(V.isBoolean(x))return x.toString();if(!l&&V.isBlob(x))throw new Pe("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(x)||V.isTypedArray(x)?l&&typeof Blob=="function"?new Blob([x]):Buffer.from(x):x}function d(x,g,v){let y=x;if(x&&!v&&typeof x=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),x=JSON.stringify(x);else if(V.isArray(x)&&hx(x)||(V.isFileList(x)||V.endsWith(g,"[]"))&&(y=V.toArray(x)))return g=Ec(g),y.forEach(function(C,E){!(V.isUndefined(C)||C===null)&&t.append(i===!0?Ic([g],E,s):i===null?g:g+"[]",c(C))}),!1}return yi(x)?!0:(t.append(Ic(v,g,s),c(x)),!1)}const p=[],m=Object.assign(mx,{defaultVisitor:d,convertValue:c,isVisitable:yi});function f(x,g){if(!V.isUndefined(x)){if(p.indexOf(x)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(x),V.forEach(x,function(y,w){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),p.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return f(e),t}function Nc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Si(e,t){this._pairs=[],e&&Bo(e,this,t)}const Ac=Si.prototype;Ac.append=function(t,n){this._pairs.push([t,n])},Ac.toString=function(t){const n=t?function(r){return t.call(this,r,Nc)}:Nc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function gx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pc(e,t,n){if(!t)return e;const r=n&&n.encode||gx;V.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=V.isURLSearchParams(t)?t.toString():new Si(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class jc{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){V.forEach(this.handlers,function(r){r!==null&&t(r)})}}const _c={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},vx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Si,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ci=typeof window<"u"&&typeof document<"u",Ti=typeof navigator=="object"&&navigator||void 0,xx=Ci&&(!Ti||["ReactNative","NativeScript","NS"].indexOf(Ti.product)<0),bx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wx=Ci&&window.location.href||"http://localhost",Rt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ci,hasStandardBrowserEnv:xx,hasStandardBrowserWebWorkerEnv:bx,navigator:Ti,origin:wx},Symbol.toStringTag,{value:"Module"})),...vx};function yx(e,t){return Bo(e,new Rt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Rt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Sx(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Cx(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 Rc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&V.isArray(o)?o.length:i,l?(V.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!V.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&V.isArray(o[i])&&(o[i]=Cx(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(Sx(r),o,n,0)}),n}return null}function Tx(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Qr={transitional:_c,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=V.isObject(t);if(s&&V.isHTMLForm(t)&&(t=new FormData(t)),V.isFormData(t))return o?JSON.stringify(Rc(t)):t;if(V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)||V.isReadableStream(t))return t;if(V.isArrayBufferView(t))return t.buffer;if(V.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 yx(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Bo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Tx(t)):t}],transformResponse:[function(t){const n=this.transitional||Qr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(V.isResponse(t)||V.isReadableStream(t))return t;if(t&&V.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Rt.classes.FormData,Blob:Rt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Qr.headers[e]={}});const kx=V.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"]),Ex=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]&&kx[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Mc=Symbol("internals");function eo(e){return e&&String(e).trim().toLowerCase()}function zo(e){return e===!1||e==null?e:V.isArray(e)?e.map(zo):String(e)}function Ix(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 Nx=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ki(e,t,n,r,o){if(V.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!V.isString(t)){if(V.isString(r))return t.indexOf(r)!==-1;if(V.isRegExp(r))return r.test(t)}}function Ax(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Px(e,t){const n=V.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 Vt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=eo(l);if(!d)throw new Error("header name must be a non-empty string");const p=V.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=zo(a))}const i=(a,l)=>V.forEach(a,(c,d)=>s(c,d,l));if(V.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(V.isString(t)&&(t=t.trim())&&!Nx(t))i(Ex(t),n);else if(V.isObject(t)&&V.isIterable(t)){let a={},l,c;for(const d of t){if(!V.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?V.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=eo(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Ix(o);if(V.isFunction(n))return n.call(this,o,r);if(V.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=eo(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ki(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=eo(i),i){const a=V.findKey(r,i);a&&(!n||ki(r,r[a],a,n))&&(delete r[a],o=!0)}}return V.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||ki(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return V.forEach(this,(o,s)=>{const i=V.findKey(r,s);if(i){n[i]=zo(o),delete n[s];return}const a=t?Ax(s):String(s).trim();a!==s&&delete n[s],n[a]=zo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return V.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&V.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[Mc]=this[Mc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=eo(i);r[a]||(Px(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Vt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Vt);function Ei(e,t){const n=this||Qr,r=t||n,o=Vt.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Oc(e){return!!(e&&e.__CANCEL__)}function wr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(wr,Pe,{__CANCEL__:!0});function Dc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function jx(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function _x(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function Rx(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Ho=(e,t,n=3)=>{let r=0;const o=_x(50,250);return Rx(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Lc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},$c=e=>(...t)=>V.asap(()=>e(...t)),Mx=Rt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Rt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Rt.origin),Rt.navigator&&/(msie|trident)/i.test(Rt.navigator.userAgent)):()=>!0,Ox=Rt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];V.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),V.isString(r)&&i.push("path="+r),V.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 Dx(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Lx(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Fc(e,t,n){let r=!Dx(t);return e&&(r||n==!1)?Lx(e,t):t}const Bc=e=>e instanceof Vt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,p,m){return V.isPlainObject(c)&&V.isPlainObject(d)?V.merge.call({caseless:m},c,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(c,d,p,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!V.isUndefined(d))return r(void 0,d)}function i(c,d){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(Bc(c),Bc(d),p,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);V.isUndefined(m)&&p!==a||(n[d]=m)}),n}const zc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Vt.from(i),t.url=Pc(Fc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(n)){if(Rt.hasStandardBrowserEnv||Rt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(Rt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Mx(t.url))){const l=o&&s&&Ox.read(s);l&&i.set(o,l)}return t},$x=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=zc(e);let s=o.data;const i=Vt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,x;function g(){f&&f(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let v=new XMLHttpRequest;v.open(o.method.toUpperCase(),o.url,!0),v.timeout=o.timeout;function y(){if(!v)return;const C=Vt.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:C,config:e,request:v};Dc(function(k){n(k),g()},function(k){r(k),g()},T),v=null}"onloadend"in v?v.onloadend=y:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(y)},v.onabort=function(){v&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,v)),v=null)},v.onerror=function(E){const T=E&&E.message?E.message:"Network Error",S=new Pe(T,Pe.ERR_NETWORK,e,v);S.event=E||null,r(S),v=null},v.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||_c;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Pe(E,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,v)),v=null},s===void 0&&i.setContentType(null),"setRequestHeader"in v&&V.forEach(i.toJSON(),function(E,T){v.setRequestHeader(T,E)}),V.isUndefined(o.withCredentials)||(v.withCredentials=!!o.withCredentials),a&&a!=="json"&&(v.responseType=o.responseType),c&&([m,x]=Ho(c,!0),v.addEventListener("progress",m)),l&&v.upload&&([p,f]=Ho(l),v.upload.addEventListener("progress",p),v.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=C=>{v&&(r(!C||C.type?new wr(null,e,v):C),v.abort(),v=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=jx(o.url);if(w&&Rt.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}v.send(s||null)})},Fx=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new wr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>V.asap(a),l}},Bx=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},zx=async function*(e,t){for await(const n of Hx(e))yield*Bx(n,t)},Hx=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()}},Hc=(e,t,n,r)=>{const o=zx(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Uc=64*1024,{isFunction:Uo}=V,Ux=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Wc,TextEncoder:Vc}=V.global,Kc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Wx=e=>{e=V.merge.call({skipUndefined:!0},Ux,e);const{fetch:t,Request:n,Response:r}=e,o=t?Uo(t):typeof fetch=="function",s=Uo(n),i=Uo(r);if(!o)return!1;const a=o&&Uo(Wc),l=o&&(typeof Vc=="function"?(x=>g=>x.encode(g))(new Vc):async x=>new Uint8Array(await new n(x).arrayBuffer())),c=s&&a&&Kc(()=>{let x=!1;const g=new n(Rt.origin,{body:new Wc,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!g}),d=i&&a&&Kc(()=>V.isReadableStream(new r("").body)),p={stream:d&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!p[x]&&(p[x]=(g,v)=>{let y=g&&g[x];if(y)return y.call(g);throw new Pe(`Response type '${x}' is not supported`,Pe.ERR_NOT_SUPPORT,v)})});const m=async x=>{if(x==null)return 0;if(V.isBlob(x))return x.size;if(V.isSpecCompliantForm(x))return(await new n(Rt.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(V.isArrayBufferView(x)||V.isArrayBuffer(x))return x.byteLength;if(V.isURLSearchParams(x)&&(x=x+""),V.isString(x))return(await l(x)).byteLength},f=async(x,g)=>{const v=V.toFiniteNumber(x.getContentLength());return v??m(g)};return async x=>{let{url:g,method:v,data:y,signal:w,cancelToken:C,timeout:E,onDownloadProgress:T,onUploadProgress:S,responseType:k,headers:A,withCredentials:P="same-origin",fetchOptions:F}=zc(x),$=t||fetch;k=k?(k+"").toLowerCase():"text";let B=Fx([w,C&&C.toAbortSignal()],E),K=null;const R=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let W;try{if(S&&c&&v!=="get"&&v!=="head"&&(W=await f(A,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),M;if(V.isFormData(y)&&(M=J.headers.get("content-type"))&&A.setContentType(M),J.body){const[q,L]=Lc(W,Ho($c(S)));y=Hc(J.body,Uc,q,L)}}V.isString(P)||(P=P?"include":"omit");const Y=s&&"credentials"in n.prototype,X={...F,signal:B,method:v.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:Y?P:void 0};K=s&&new n(g,X);let O=await(s?$(K,F):$(g,X));const I=d&&(k==="stream"||k==="response");if(d&&(T||I&&R)){const J={};["status","statusText","headers"].forEach(D=>{J[D]=O[D]});const M=V.toFiniteNumber(O.headers.get("content-length")),[q,L]=T&&Lc(M,Ho($c(T),!0))||[];O=new r(Hc(O.body,Uc,q,()=>{L&&L(),R&&R()}),J)}k=k||"text";let H=await p[V.findKey(p,k)||"text"](O,x);return!I&&R&&R(),await new Promise((J,M)=>{Dc(J,M,{data:H,headers:Vt.from(O.headers),status:O.status,statusText:O.statusText,config:x,request:K})})}catch(Y){throw R&&R(),Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,x,K),{cause:Y.cause||Y}):Pe.from(Y,Y&&Y.code,x,K)}}},Vx=new Map,qc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Vx;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Wx(t)),d=c;return c};qc();const Ii={http:px,xhr:$x,fetch:{get:qc}};V.forEach(Ii,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Gc=e=>`- ${e}`,Kx=e=>V.isFunction(e)||e===null||e===!1,Yc={getAdapter:(e,t)=>{e=V.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,!Kx(r)&&(o=Ii[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
+
`+i.map(Gc).join(`
|
|
34
|
+
`):" "+Gc(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ii};function Ni(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new wr(null,e)}function Xc(e){return Ni(e),e.headers=Vt.from(e.headers),e.data=Ei.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Yc.getAdapter(e.adapter||Qr.adapter,e)(e).then(function(r){return Ni(e),r.data=Ei.call(e,e.transformResponse,r),r.headers=Vt.from(r.headers),r},function(r){return Oc(r)||(Ni(e),r&&r.response&&(r.response.data=Ei.call(e,e.transformResponse,r.response),r.response.headers=Vt.from(r.response.headers))),Promise.reject(r)})}const Jc="1.12.2",Wo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Wo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Zc={};Wo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Jc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!Zc[i]&&(Zc[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}},Wo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function qx(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const Vo={assertOptions:qx,validators:Wo},vn=Vo.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new jc,response:new jc}}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=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Vo.assertOptions(r,{silentJSONParsing:vn.transitional(vn.boolean),forcedJSONParsing:vn.transitional(vn.boolean),clarifyTimeoutError:vn.transitional(vn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Vo.assertOptions(o,{encode:vn.function,serialize:vn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Vo.assertOptions(n,{baseUrl:vn.spelling("baseURL"),withXsrfToken:vn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],x=>{delete s[x]}),n.headers=Vt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const x=[Xc.bind(this),void 0];for(x.unshift(...a),x.push(...c),m=x.length,d=Promise.resolve(n);p<m;)d=d.then(x[p++],x[p++]);return d}m=a.length;let f=n;for(;p<m;){const x=a[p++],g=a[p++];try{f=x(f)}catch(v){g.call(this,v);break}}try{d=Xc.call(this,f)}catch(x){return Promise.reject(x)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Fc(t.baseURL,t.url,t.allowAbsoluteUrls);return Pc(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let Gx=class pv{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 wr(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 pv(function(o){t=o}),cancel:t}}};function Yx(e){return function(n){return e.apply(null,n)}}function Xx(e){return V.isObject(e)&&e.isAxiosError===!0}const Ai={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(Ai).forEach(([e,t])=>{Ai[t]=e});function Qc(e){const t=new Qn(e),n=mc(Qn.prototype.request,t);return V.extend(n,Qn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Qc(Zn(e,o))},n}const vt=Qc(Qr);vt.Axios=Qn,vt.CanceledError=wr,vt.CancelToken=Gx,vt.isCancel=Oc,vt.VERSION=Jc,vt.toFormData=Bo,vt.AxiosError=Pe,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=Yx,vt.isAxiosError=Xx,vt.mergeConfig=Zn,vt.AxiosHeaders=Vt,vt.formToJSON=e=>Rc(V.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Yc.getAdapter,vt.HttpStatusCode=Ai,vt.default=vt;const{Axios:w1,AxiosError:y1,CanceledError:S1,isCancel:eu,CancelToken:C1,VERSION:T1,all:k1,Cancel:E1,isAxiosError:I1,spread:N1,toFormData:A1,AxiosHeaders:P1,HttpStatusCode:j1,formToJSON:_1,getAdapter:R1,mergeConfig:M1}=vt;let Ko=null;const Pi=new Set;function ji(){return Ko}function Rn(e){Ko=e,Pi.forEach(t=>t(e))}function _i(e){return Pi.add(e),()=>Pi.delete(e)}const tu=3e4,nu=9e4,Lt=vt.create({timeout:tu,withCredentials:!0});Lt.interceptors.request.use(e=>(Ko&&(e.headers.Authorization=`Bearer ${Ko}`),e)),Lt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Rn(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Kt(e,t){return Lt.defaults.baseURL?(await Lt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function to(e,t,n){return Lt.defaults.baseURL?(await Lt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ru(e,t,n){return Lt.defaults.baseURL?(await Lt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ri(e,t){return Lt.defaults.baseURL?(await Lt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class ou{get baseUrl(){return Lt.defaults.baseURL||""}updateConfig(t){if(t.chatBaseUrl)Lt.defaults.baseURL=t.chatBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");n.endsWith("/chat")?Lt.defaults.baseURL=n:Lt.defaults.baseURL=`${n}/chat`}t.apiKey!==void 0?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return ji()}setAuthToken(t){Rn(t)}onTokenChange(t){return _i(t)}async listThreads(){const t=await Kt("/threads"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Kt("/threads/shared"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t,n){const r={};t&&(r.title=t),n&&(r.project=n);const o=await to("/threads",Object.keys(r).length?r:void 0);return $t(o)}async updateThread(t,n){const r=await ru(`/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Ri(`/threads/${t}`);return $t(n)}async shareThread(t,n){const r=await to(`/threads/${t}/share`,{shared_with_user_id:n});return $t(r)}async threadInfo(t){const n=await Kt(`/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Kt("/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Kt(`/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Kt(`/agents/${t}/schema`);return $t(n)}async getState(t){const n=await Kt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return $t(n)}async getStateHistory(t){const n=await Kt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:nu,signal:t.signal});return $t(n)}async cancelRun(t){const n=await to("/runs/cancel",{threadId:t});return $t(n)}async unshareThread(t,n){const r=await Ri(`/threads/${t}/share/${n}`);return $t(r)}}const Mn=new ou;class su{async fetchFileBlob(t,n){return await Kt(t,{responseType:"blob",onDownloadProgress:o=>{try{if(n&&o.lengthComputable){const s=o.loaded/o.total;n(s)}}catch{}},maxBodyLength:1/0})}async viewFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/view`,n),o=URL.createObjectURL(r);window.open(o,"_blank"),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileBlob(t,n){return await this.fetchFileBlob(`/files/${t}/view`,n)}async getFileContent(t,n){return await(await this.fetchFileBlob(`/files/${t}/view`,n)).text()}async downloadFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/download`,n),o=URL.createObjectURL(r);let s=`file_${t}`;try{const a=await Kt(`/files/${t}`);s=(a==null?void 0:a.filename)??s}catch{}const i=document.createElement("a");i.href=o,i.download=s,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileInfo(t){return await Kt(`/files/${t}`)}async listFiles(t,n=50,r=0){const o={limit:n,offset:r};return t&&(o.thread_id=t),await Kt("/files",{params:o})}async uploadFile(t,n,r){const o=new FormData;return o.append("file",t),n&&o.append("thread_id",n),await to("/files/upload-form",o,{onUploadProgress:s=>{try{if(r&&s.lengthComputable){const i=s.loaded/s.total;r(i)}}catch{}}})}}const iu=new su;class Jx{constructor(){sc(this,"_authBaseUrl","")}get baseUrl(){return this._authBaseUrl}updateConfig(t){if(t.authBaseUrl)this._authBaseUrl=t.authBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");this._authBaseUrl=`${n}/auth`}t.apiKey!==void 0?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return ji()}setAuthToken(t){Rn(t)}onTokenChange(t){return _i(t)}async listUsers(){const t=await Kt("/users",{baseURL:this.baseUrl});return(t==null?void 0:t.users)??[]}}const Zx=new Jx,au=b.createContext(null);function lu({children:e,apiConfig:t}){const n=Mn,r=Zx;if(t){const s=n.baseUrl,i=r.baseUrl,a=n.getAuthToken();(t.baseUrl||t.chatBaseUrl)&&(t.chatBaseUrl&&t.chatBaseUrl!==s||t.baseUrl&&!s.startsWith(t.baseUrl))&&n.updateConfig(t),(t.baseUrl||t.authBaseUrl)&&(t.authBaseUrl&&t.authBaseUrl!==i||t.baseUrl&&!i.startsWith(t.baseUrl))&&r.updateConfig(t),t.apiKey!==void 0&&t.apiKey!==a&&(n.updateConfig({apiKey:t.apiKey}),r.updateConfig({apiKey:t.apiKey}))}const o={token:n.getAuthToken(),setToken:s=>{n.setAuthToken(s),r.setAuthToken(s)},chatApi:n,authApi:r,fileApi:iu,baseUrl:n.baseUrl};return u.jsx(au.Provider,{value:o,children:e})}async function cu(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function uu(e=[]){const t=[],n=[];for(const r of e)try{const o=await cu(r),s=r.type||"application/octet-stream";n.push({filename:r.name,data:o,mime_type:s}),s.startsWith("image/")?t.push({type:"image_url",url:`data:${s};base64,${o}`,mimeType:s,alt:r.name}):t.push({type:"file",url:`data:${s};base64,${o}`,mimeType:s,name:r.name,size:r.size,sourceType:"base64"})}catch{}return{contentParts:t,filesInfo:n}}function On(){const e=b.useContext(au);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function du(e){return!!e&&typeof e=="object"&&"data"in e}function Qx(e={}){const t=e.baseUrl||"",n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[p,m]=b.useState(""),[f,x]=b.useState(null),[g,v]=b.useState(0),[y,w]=b.useState(!1),[C,E]=b.useState(null),T=b.useRef(null),S=b.useRef(!0),k=b.useRef(0),A=b.useRef(null),P=b.useRef(null),F=b.useRef(null),$=b.useRef(null),B=b.useRef({messageId:null,lastSeq:null,lastText:""}),K=b.useCallback(X=>{o(X)},[]),R=b.useCallback(()=>{m(""),x(null),d(null),P.current=null,F.current=null,$.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),W=b.useCallback(()=>{var H;console.debug("[use-chat] stop() invoked - aborting stream");const X=(H=A.current)==null?void 0:H.threadId,O=()=>{var J;(J=T.current)==null||J.abort(),T.current=null,A.current=null,l(!1),w(!1),k.current=0,v(0)};(X?Mn.cancelRun(X).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(O)},[]),Y=b.useCallback((X,O,I)=>{T.current&&(T.current.abort(),T.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),x(null),P.current=null,F.current=null,$.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""};const H=new AbortController;T.current=H;let J=null,M=null,q=!1;return A.current={threadId:X.threadId??null,headers:{}},(async()=>{var D,G,_,j,U,Z,se,ae,Se,Ce,Oe,Fe,Be,Ke,ze,dt,pt,Ze;const L=He=>{var Re;try{const qe=JSON.parse(JSON.stringify(He));return(Re=qe==null?void 0:qe.payload)!=null&&Re.files_info&&Array.isArray(qe.payload.files_info)&&(qe.payload.files_info=qe.payload.files_info.map(Ae=>({...Ae,data:Ae!=null&&Ae.data?`<base64 ${String(Ae.data).length} chars>`:Ae==null?void 0:Ae.data}))),qe}catch{return He}};try{let He={};try{if(r)He={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const $e=window.__AUTH_TOKEN__,ft=((D=window.localStorage)==null?void 0:D.getItem("authToken"))||null;let kt=null;try{const _t=(G=window.localStorage)==null?void 0:G.getItem("chat-settings");_t&&(kt=((_=JSON.parse(_t))==null?void 0:_.apiKey)||null)}catch{}const ct=$e||ft||kt||null;ct&&(He={Authorization:`Bearer ${ct}`})}}catch{}console.debug("[use-chat] POST",t+n,L(X));let Re={};if(typeof window<"u")try{const Ve=(j=window.localStorage)==null?void 0:j.getItem("authSessionId");Ve&&(Re={"X-Session-Id":Ve})}catch{}const qe={...He,...Re,...s.current},Ae={"Content-Type":"application/json",Accept:"text/event-stream",...qe},Ge=await fetch(t+n,{method:"POST",headers:Ae,body:JSON.stringify(X),signal:H.signal,credentials:i});if(A.current&&(A.current.headers=qe),!Ge.ok||!Ge.body){const Ve=await Ge.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ge.status,Ve==null?void 0:Ve.slice(0,500));const $e=`stream ${Ge.status}${Ve?": "+Ve:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,$e),q=!0,J="error",M=$e,new Error($e)}w(!0);const Xe=Ge.body.getReader(),Ct=new TextDecoder;let Qe="",Tt=[];k.current=0,v(0);let ht=0,wt=null;const At=()=>{if(Tt.length){const Ve=Tt.join("");Tt=[],S.current&&m($e=>$e+Ve)}wt=null},jt=()=>{typeof window<"u"&&wt==null&&(wt=requestAnimationFrame(At))};let mt=Date.now();const gt=setInterval(()=>{var Ve;if(Date.now()-mt>18e5){const $e="Stream idle timeout";d($e),J="error",M=$e,H.abort(),(Ve=I==null?void 0:I.onError)==null||Ve.call(I,$e)}},5e3),Ht=1024*1024;try{const Ve=Ge.headers.get("X-Thread-Id")||Ge.headers.get("x-thread-id"),$e=Ge.headers.get("X-Thread-Created")||Ge.headers.get("x-thread-created"),ft=Ve??null,kt=String($e??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:ft}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:ft,created:kt});;){const{value:ct,done:_t}=await Xe.read();if(_t)break;Qe+=Ct.decode(ct,{stream:!0}),Qe.length>Ht&&(Qe="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=Qe.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const Le=Qe.slice(0,xe);Qe=Qe.slice(xe+2);const Ue=Le.split(/\r?\n/),st=[];let
|
|
38
|
-
`);if(!ut)continue;let tt;try{tt=JSON.parse(ut)}catch{console.debug("[use-chat] malformed SSE:",ut.slice(0,200));continue}nt&&typeof tt=="object"&&tt!==null&&!("type"in tt)&&(tt.type=nt);const Q=pu(tt)?tt.data:tt;if(!Q){console.warn("[use-chat] dropped envelope event without payload",tt);continue}const ee=Q;mt=Date.now(),ee.type==="values"&&(ee.type="state_history"),ee.type==="metadata"&&(ee.title||ee.createdAt)&&(ee.type="thread_info");const he=ee.seq;if(he!==void 0){if(he<=ht){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:he,lastProcessedSeq:ht,type:ee.type});continue}ht>0&&he>ht+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:ht,to:he})),ht=he,k.current=he,v(he)}if(ee.type==="checkpoint")j.current=ee.checkpointId??null,B.current=ee.checkpointNs??null,b(ee.checkpointId??null);else if(ee.type==="state_history"){$.current=ee;try{const Ie=Xn(ee).latest;Ie&&(j.current=Ie.checkpointId??null,B.current=Ie.checkpointNs??null,b(Ie.checkpointId??null))}catch(de){console.warn("[use-chat] Failed to hydrate state_history payload",de)}}try{R==null||R(ee)}catch(de){console.error("[use-chat] Error in onEvent callback:",de,"for event:",ee.type)}if(ee.type==="messages/partial"){const Ie=ee.messages;if(Array.isArray(Ie)&&Ie.length>0){const N=Ie.find(te=>te.type==="ai");if(N){const te=N.id,ne=N.content??"",ce=N.response_metadata??{};if(z.current.messageId!==te){const we=ce.model_name??ce.model_provider??"assistant";z.current={messageId:te,lastSeq:null,lastText:""},E({id:te,role:"assistant",name:we,model:we,createdAt:new Date().toISOString(),content:[{type:"text",text:ne}]})}else E(we=>!we||we.id!==te?we:{...we,content:[{type:"text",text:ne}]});const ge=z.current.lastText||"";if(ne.length>ge.length){const we=ne.slice(ge.length);z.current.lastText=ne,e.autoAppendAssistant!==!1&&(Tt.push(we),Pt())}}}}else if(ee.type==="updates"){const de=ee;if(de.tools){const Ie=de.tools;if(Ie.status==="start"){const N={type:"tool.start",id:Ie.id,name:Ie.name,args:Ie.args,seq:de.seq,call_id:Ie.id};try{R==null||R(N)}catch(te){console.error("[use-chat] Error in onEvent (tool.start polyfill):",te)}}else if(Ie.status==="end"){const N={type:"tool.end",id:Ie.id,name:Ie.name,output:Ie.output,artifact:Ie.artifact,seq:de.seq,call_id:Ie.id};try{R==null||R(N)}catch(te){console.error("[use-chat] Error in onEvent (tool.end polyfill):",te)}}}continue}else if(ee.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ae=I==null?void 0:I.onHeartbeat)==null||ae.call(I,ee)}catch(de){console.warn("[use-chat] heartbeat callback failed",de)}}else if(wt!==null&&cancelAnimationFrame(wt),At(),ee.type==="checkpoint")b(ee.checkpointId);else if(ee.type==="error"){const de=ee;if(d(de.message),J="error",O=de.message,de.error_type==="auth_error"||de.code==="TOKEN_EXPIRED"||((Se=de.message)==null?void 0:Se.includes("token"))||((Ce=de.message)==null?void 0:Ce.includes("401"))||((Oe=de.message)==null?void 0:Oe.includes("unauthorized"))||((Fe=de.message)==null?void 0:Fe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",de.message);try{(Be=I==null?void 0:I.onAuthError)==null||Be.call(I,de.message)}catch(N){console.warn("[use-chat] onAuthError handler failed",N)}U.abort()}}}}At(),J===null&&!U.signal.aborted&&(J="complete")}catch(Ve){if(Ve.name==="AbortError")J=J??"aborted";else{const $e=Ve.message||String(Ve);J="error",O=$e,d($e),(Ke=I==null?void 0:I.onError)==null||Ke.call(I,$e)}}finally{try{await Xe.cancel()}catch{}finally{(ze=Xe.releaseLock)==null||ze.call(Xe)}wt!==null&&typeof window<"u"&&window.cancelAnimationFrame(wt),clearInterval(gt)}}catch(He){if(He.name==="AbortError")J=J??"aborted";else{const Me=He.message||String(He);J="error",O=Me,d(Me),(dt=I==null?void 0:I.onError)==null||dt.call(I,Me),Y||((pt=I==null?void 0:I.onConnectionError)==null||pt.call(I,Me),Y=!0)}}finally{const He=k.current,Me=j.current,qe=B.current,Ae=$.current,Ge=J??(U.signal.aborted?"aborted":O?"error":"complete");try{(Ze=I==null?void 0:I.onClosed)==null||Ze.call(I,{reason:Ge,lastSeq:He,lastCheckpointId:Me,lastCheckpointNs:qe,lastStateHistory:Ae,error:O})}catch(Xe){console.warn("[use-chat] onClosed callback failed",Xe)}l(!1),w(!1),T.current=null,k.current=0,v(0),A.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return x.useEffect(()=>()=>{var K;S.current=!1,(K=T.current)==null||K.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:V,stop:F,clear:M,setToken:G}}const tb=["detail","message","error","description","title"];function qo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of tb){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function nb(e){if(!e)return"Request failed";const t=e.response,n=qo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function hu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=x.useState([]),[a,l]=x.useState(t),[c,d]=x.useState(!1),[p,m]=x.useState(null),[f,b]=x.useState([]),[g,v]=x.useState(!1),[,y]=x.useState(null),[w,C]=x.useState(null),[E,T]=x.useState(!1),S=x.useRef(a),k=x.useRef(new Map);x.useEffect(()=>{S.current=a},[a]),x.useEffect(()=>{t!==void 0&&t!==S.current&&l(t)},[t]);const A=x.useCallback(async()=>{d(!0),m(null);try{const R=await e.listThreads();i(R??[])}catch(R){const I=String(R);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),j=x.useCallback(async()=>{v(!0),y(null);try{const R=await e.listSharedThreads();b(R??[])}catch(R){const I=String(R);y(I),n==null||n(I)}finally{v(!1)}},[e,n]);x.useEffect(()=>{A()},[A]),x.useEffect(()=>{j()},[j]),x.useEffect(()=>{r==null||r(a)},[a,r]);const B=x.useCallback(async(R,I)=>{try{const U=await e.createThread(R,I);return l(U.threadId),await A(),U.threadId}catch(U){const J=String(U);return n==null||n(J),null}},[e,n,A]),$=x.useCallback(async R=>{const I=s;i(J=>J.filter(O=>O.threadId!==R));const U=new AbortController;k.current.set(R,U);try{await e.deleteThread(R),S.current===R&&(l(null),o==null||o())}catch(J){i(I);const O=String(J);n==null||n(O)}finally{k.current.delete(R)}},[e,o,n,s]),z=x.useCallback(async(R,I)=>{try{await e.updateThread(R,I),await A()}catch(U){n==null||n(String(U))}},[e,n,A]),G=x.useCallback(async(R,I)=>{T(!0),C("Sharing thread…");try{await e.shareThread(R,I),await j(),C("Shared successfully")}catch(U){const J=nb(U);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{T(!1)}},[e,n,j]),M=x.useCallback(async(R,I)=>{try{await e.unshareThread(R,I),await j()}catch(U){const J=String(U);throw n==null||n(J),U}},[e,n,j]),F=x.useMemo(()=>({createThread:B,deleteThread:$,renameThread:z,refreshThreads:A,refreshSharedThreads:j,shareThread:G,unshareThread:M}),[B,$,z,A,j,G,M]),V=x.useCallback(R=>{if(!(R!=null&&R.threadId))return;const I={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,project:R.project,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(U=>{let J=!1;const O=U.map(Y=>Y.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...Y,title:I.title??Y.title,project:I.project??Y.project,updatedAt:I.updatedAt??Y.updatedAt,messageCount:I.messageCount??Y.messageCount}):Y);return J?O:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...U])})},[]),K=x.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:S,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:F,addThreadFromEvent:V,shareInFlight:E,shareStatus:w,clearShareStatus:K}}const mu=x.createContext(null);function gu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{chatApi:o}=On(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:b,shareInFlight:g,shareStatus:v,clearShareStatus:y}=hu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=x.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:v,clearShareStatus:y,addThreadFromEvent:b}),[s,i,a,l,c,d,p,m,f,g,v,y,b]);return u.jsx(mu.Provider,{value:w,children:e})}function yr(){const e=x.useContext(mu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function er(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=rb(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function rb(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function Di(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Sr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Sr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Di(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Sr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function tr(e){if(typeof e=="string")return e;if(Di(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function vu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function xu(e){const t=tr(e);return typeof e=="string"&&vu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function nr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=er(t);if(n!==null)return nr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?nr(e.content):e}function bu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Go(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Li(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function wu(e){const t=r=>{try{const o=Sr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function yu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function $i(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Su(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Cu(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Tu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Su(n),i=o?`data:${s};base64,${e}`:t,a=Cu(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function ku(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return Tu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Fi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Cr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=er(t);return n!==null?Cr(n):t}if(Array.isArray(e))return e.map(t=>Cr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Cr(t)}return e}function Eu(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}function Bi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Yo(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function ob(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function sb(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 Yo(e,r,s)}return e}const ib={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ab(e,t){var n;switch(t.type){case"reset":return{messages:Bi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r],assemblingId:null}}}return{...e,messages:[...e.messages,r],assemblingId:null}}case"seed":{const r=Bi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Bi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Iu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Iu(o,s),e):e}default:return e}}function lb(e=[]){const[t,n]=x.useReducer(ab,{...ib,messages:e}),r=x.useRef([]),o=x.useRef(null),s=x.useRef(null),i=x.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=x.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=x.useCallback(d=>{r.current.push(d),a()},[a]);x.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=x.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function Iu(e,t){if(t.type==="tool.start")return ub(e,t);if(t.type==="tool.progress")return db(e,t);if(t.type==="tool.end")return fb(e,t);if(t.type==="checkpoint"){const n=t.checkpointNs??e.lastCheckpointNs??null,r=sb(e.messages,t.checkpointId,n);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:n,messages:r}}if(t.type==="error"){const n={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,n]}}if(t.type==="state_history"){const n=Xn(t),r=n.interrupt,o=n.latest,s=r===null?ob(e.messages):e.messages;return{...e,messages:s,pendingInterrupt:r,lastCheckpointId:(o==null?void 0:o.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(o==null?void 0:o.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function zi(e){return e.call_id??e.id??null}function Nu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Au(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Hi(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Go(r).toolCallId===t)return n}return-1}function cb(e){if(e==null)return[];const t=nr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=tr(t??e);return n?[{type:"text",text:n}]:[]}function ju(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function ub(e,t){const n=zi(t),r=Hi(e.messages,n),o=t.name??t.tool??void 0,s=Nu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Yo(e.messages,r,d)}}const i=Au(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function db(e,t){const n=zi(t);if(!n)return e;const r=Hi(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=ju(e.messages[r],o);return{...e,messages:Yo(e.messages,r,a)}}function fb(e,t){const n=zi(t),r=Nu(t);let o=e.messages,s=Hi(o,n);if(s===-1){const b=t.name??t.tool??void 0;o=[...o,Au(r,n,b,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=cb(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=ju(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Yo(o,s,f)}}function Pu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,p]=x.useState(null),f=x.useMemo(()=>Xn(d),[d]).checkpoints,b=fc(f),g=b.timeline,[v,y]=x.useState(!1),[w,C]=x.useState(!1),[E,T]=x.useState(null),S=x.useRef(r),k=x.useRef(null),A=x.useRef(null),j=x.useRef(null),B=x.useRef(null),$=x.useRef(null),z=x.useRef(new Map),G=x.useRef(null);x.useEffect(()=>{S.current=r},[r]);const M=x.useCallback(async L=>{var X,_;if(!L.threadId)return;const D=L.threadId;(X=L.onStart)==null||X.call(L),L.setLoading(!0);try{await L.action(D)}catch(P){if(!nu(P)&&S.current===D){const Z=String(P);(_=L.handleError)==null||_.call(L,Z),n==null||n(Z)}throw P}finally{L.setLoading(!1)}},[n]),F=x.useCallback(async(L,D)=>{var Z;if(!L)return;const X=`${L}:${D??"latest"}`,_=z.current.get(X);if(_)return _;(Z=G.current)==null||Z.abort();const P=new AbortController;G.current=P;const W=M({threadId:L,setLoading:y,onStart:()=>T(null),handleError:se=>T(se),action:async se=>{const ae=await e.getStateHistory({threadId:se,checkpointId:D??void 0,signal:P.signal});if(S.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${S.current}), discarding stale data`);return}const{checkpoints:Se}=Xn(ae),Ce=Se.find(Oe=>Oe.messages&&Oe.messages.length>0)??(D?Se.find(Oe=>Oe.checkpointId===D):null)??Se[0];t((Ce==null?void 0:Ce.messages)??[],{checkpointId:(Ce==null?void 0:Ce.checkpointId)??null,checkpointNs:(Ce==null?void 0:Ce.checkpointNs)??null,pendingInterrupt:(Ce==null?void 0:Ce.interrupt)??null}),p(ae)}});z.current.set(X,W);try{await W}finally{z.current.delete(X),G.current===P&&(G.current=null)}return S.current===L&&($.current=X),W},[e,t,M]),V=x.useCallback(async(L,D)=>{B.current=L;try{await F(L,D)}catch(X){if(!nu(X))throw X}finally{B.current===L&&(B.current=null)}},[F]),K=x.useCallback(L=>{A.current=L},[]),R=x.useCallback(L=>{j.current=L},[]),I=x.useCallback(L=>{const D=L.threadId??S.current;if(!D||S.current&&S.current!==D)return;const{checkpoints:X}=Xn(L);if(!X.length)return;const _=X.find(W=>W.messages&&W.messages.length>0)??X.find(W=>!!W.checkpointId)??X[0],P=j.current===D;!l&&!P&&t((_==null?void 0:_.messages)??[],{checkpointId:(_==null?void 0:_.checkpointId)??null,checkpointNs:(_==null?void 0:_.checkpointNs)??null,pendingInterrupt:(_==null?void 0:_.interrupt)??null}),p(L),$.current=`${D}:latest`,A.current=null,j.current===D&&(j.current=null)},[t,l]),U=x.useCallback(async(L,D)=>{const X=S.current;await M({threadId:X,setLoading:C,action:async _=>{const P=await e.getStateHistory({threadId:_,checkpointId:L,checkpointNs:D??void 0});if(S.current!==_)return;const{checkpoints:W}=Xn(P),Z=W.find(se=>se.checkpointId===L&&(D?se.checkpointNs===D:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:D});return}p(P),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,M]),J=x.useCallback((L,D)=>{t(c(),{checkpointId:L??null,checkpointNs:D??null})},[c,t]),O=x.useCallback(async()=>{S.current&&await V(S.current)},[V]);x.useEffect(()=>{if(!a||!r||v||l)return;if(A.current===r){A.current=null,k.current=r;return}if(j.current===r){k.current=r;return}if(B.current===r){B.current=null,k.current=r;return}if(k.current===r)return;k.current=r;let L;const D=`${r}:latest`;$.current!==D&&V(r,L)},[a,r,s,i,o,v,l,V]);const Y=x.useCallback(()=>{p(null),y(!1),C(!1),T(null),A.current=null,j.current=null,k.current=null,$.current=null,B.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:b,isLoadingThread:v,isLoadingCheckpoint:w,threadStateError:E,loadThread:V,navigateToCheckpoint:U,setCurrentCheckpointId:J,returnToLatest:O,handleStateHistoryEvent:I,markSkipNextLoad:K,markStreamPendingThread:R,resetHistoryState:Y}}const _u=x.createContext(null),Mu=x.createContext(null);function no(){const e=x.useContext(_u);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Ru(){const e=x.useContext(Mu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Ou({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{chatApi:a}=On(),{currentThreadId:l}=yr(),{state:c,seed:d,pushUser:p,onEvent:m}=lb(),{threadCheckpoints:f,threadTimeline:b,checkpointIndex:g,isLoadingThread:v,isLoadingCheckpoint:y,threadStateError:w,loadThread:C,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:B}=Pu({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:x.useCallback(()=>c.messages,[c.messages])}),[$,z]=x.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[G,M]=x.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});x.useEffect(()=>{l||(d([],{}),B())},[l,d,B]);const F=x.useCallback(U=>z(()=>U),[]),V=x.useCallback(U=>M(()=>U),[]),K=x.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),R=x.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:b,metadata:K,isLoading:v,isLoadingCheckpoint:y,error:w,clearState:$,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,loadThread:C,clearThread:$,respondToInterrupt:G,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:B,pushUser:p,onEvent:m}),[l,c,f,b,g,K,v,y,w,$,E,T,S,C,G,g.messagePreviews,k,A,j,B,p,m]),I=x.useMemo(()=>({registerClearThread:F,registerRespondToInterrupt:V}),[F,V]);return u.jsx(Mu.Provider,{value:I,children:u.jsx(_u.Provider,{value:R,children:e})})}function Du(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return _n(r,t)??null}function pb(e){const t=Du(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Du(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function hb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function mb(e,t){const n=[...e].sort(hb);for(const r of n){if(r.messageId!==t)continue;const o=pb(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Lu=x.createContext(null),$u=x.createContext(!1);function gb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{chatApi:d,baseUrl:p}=On(),m=p,{stream:f,stop:b,clear:g,isStreaming:v,assistantMessage:y,error:w,setToken:C}=eb({baseUrl:m}),[E,T]=x.useState(!1);return x.useEffect(()=>{T(v)},[v]),u.jsx(gu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Ou,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:E,children:u.jsx($u.Provider,{value:!0,children:u.jsx(vb,{api:d,streamApi:{stream:f,stop:b,clear:g,isStreaming:v,assistantMessage:y,error:w,setToken:C},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function vb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,clear:c,isStreaming:d,assistantMessage:p,error:m,setToken:f}=n,{setCurrentThreadId:b,currentThreadIdRef:g,addThreadFromEvent:v}=yr(),{checkpoint:y,timelineCheckpoints:w,handleStateHistoryEvent:C,markSkipNextLoad:E,markStreamPendingThread:T,resetHistoryState:S,pushUser:k,onEvent:A}=no(),{registerClearThread:j,registerRespondToInterrupt:B}=Ru(),$=x.useCallback(I=>{v(I),g.current!==I.threadId&&((I.created??!g.current)&&E(I.threadId),T(I.threadId),b(I.threadId))},[v,E,T,b,g]),z=x.useCallback(I=>{I.type==="thread_info"?$(I):I.type==="state_history"?C(I):I.type==="tool.end"?(A(I),i==null||i(I)):A(I)},[$,C,A,i]),G=x.useCallback(I=>{a(I,z,{onError:U=>{console.error("[StreamingProvider] Stream error:",U),r==null||r(U)},onAuthError:U=>{console.error("[StreamingProvider] Auth error:",U),o==null||o(U)},onConnectionError:U=>{console.error("[StreamingProvider] Connection error:",U),s==null||s(U)}})},[a,z,r,o,s]),M=x.useRef(y);x.useEffect(()=>{M.current=y},[y]);const F=x.useCallback(async(I,U,J)=>{const O=g.current;if(!O)throw new Error("No active thread to handle interrupt");const Y=I?U??!0:!1,L=M.current,D={threadId:O,checkpointId:L.id??void 0,checkpointNs:L.namespace??void 0,command:{kind:"resume",value:Y},payload:J==null?void 0:J.payload,config:J==null?void 0:J.config,nodeFilter:J==null?void 0:J.nodeFilter,branchLabel:J==null?void 0:J.branchLabel,timelineCheckpoints:J==null?void 0:J.timelineCheckpoints};G(D)},[g,G]);x.useEffect(()=>{B(F)},[F,B]);const V=x.useCallback(async()=>{l(),c(),S(),b(null)},[c,S,b,l]);x.useEffect(()=>{j(V)},[V,j]);const K=x.useCallback(async(I,U)=>{d&&l();let J=g.current;const O=(I==null?void 0:I.text)??"",Y=(I==null?void 0:I.attachments)??[],L=(O==null?void 0:O.trim())??"",D={...(I==null?void 0:I.payload)??{}},X=Array.isArray(D.messages)?D.messages:void 0;X&&delete D.messages;const _=!!(X&&X.length),P=!!(I.contentParts&&I.contentParts.length>0);if(!J&&!L&&Y.length===0&&!_&&!P)return;if(!J){const Ze=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),He=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);J=`${Ze}${He}`,E(J),b(J)}let W=null;I.contentParts&&I.contentParts.length>0&&(W=I.contentParts);const{contentParts:Z,filesInfo:se}=W?{contentParts:W,filesInfo:[]}:await fu(Y),ae=[...Z];L&&ae.push({type:"text",text:O});const Se=U==null?void 0:U.originalMessageId,Ce=!!(U!=null&&U.edit&&Se),Oe=!_&&ae.length>0;let Fe=null;Oe&&(Fe={id:Ce?Se:`msg-${Date.now()}`,role:"user",content:ae,createdAt:new Date().toISOString()},Ce?k(Fe,Se):k(Fe));const Be=_?X:Fe?[Fe]:[],Ke={...D,...se.length?{files_info:se}:{}};Be.length?Ke.messages=Be:"messages"in Ke||(Ke.messages=[]);let ze=(U==null?void 0:U.checkpointId)??y.id??void 0,dt=(U==null?void 0:U.checkpointNs)??y.namespace??void 0;if(Ce&&Se){const Ze=mb(w,Se);ze=Ze.checkpointId,dt=Ze.checkpointNs??void 0}const pt={threadId:J,payload:Ke,checkpointId:ze,checkpointNs:dt,config:U==null?void 0:U.config,edit:!!(U!=null&&U.edit)};G(pt)},[y,g,d,E,k,G,l,w]),R=x.useMemo(()=>({isStreaming:d,error:m,connectionState:d?"connected":"idle",submit:K,send:K,stop:l,clear:c,setAuthToken:f,assistantMessage:p}),[d,p,m,K,l,c,f]);return u.jsx(Lu.Provider,{value:R,children:e})}function Ui(){const e=x.useContext(Lu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function xb(){return x.useContext($u)}function Fu(e){return typeof e=="object"&&e!==null}function bb(e,t){if(Object.is(e,t))return!0;if(!Fu(e)||!Fu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Bu(e){const t=x.useRef(e),n=x.useRef(e);return bb(t.current,e)||(t.current=e,n.current=e),n.current}function Tr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=Bu(t),m=ro(a),f=ro(l),b=ro(i),g=ro(c),v=ro(d),y=x.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:b,onThreadChange:g,onToolEnd:v}),[n,r,o,s,m,f,b,g,v]);return u.jsx(uu,{apiConfig:p,children:u.jsx(gb,{...y,children:e})})}function ro(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e},[e]),x.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function zu(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"")}function Hu(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Uu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"");return""}function Wu(){const e={},t=zu(),n=Hu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Vu(){const e=Wu(),t=Rn.getAuthToken(),n=zu();return{apiBaseUrl:Uu(e.baseUrl,n),apiKey:t||e.apiKey||Hu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Wi="chat-settings";function Ku(){try{const e=localStorage.getItem(Wi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function qu(e){try{const t={...e,apiBaseUrl:e.apiBaseUrl.trim().replace(/\/+$/,"")};localStorage.setItem(Wi,JSON.stringify(t)),t.apiKey&&Rn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function wb(){const e=Vu(),t=Ku(),n=Rn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Uu(Rn.baseUrl,r,e.apiBaseUrl)}}function yb(e){Rn.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),qu(e)}function oe(...e){return gv.twMerge(mv.clsx(e))}const Sb=Kr.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"}}),et=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Jt.Slot:"button";return u.jsx(i,{className:oe(Sb({variant:t,size:n,className:e})),ref:s,...o})});et.displayName="Button";function le(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 Gu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Gu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Gu(e[o],null)}}}}function Re(...e){return h.useCallback(Dn(...e),e)}function Cb(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,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 nn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...b}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,v=h.useMemo(()=>b,Object.values(b));return u.jsx(g.Provider,{value:v,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,b=h.useContext(f);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Tb(o,...t)]}function Tb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},kb=h[" useId ".trim().toString()]||(()=>{}),Eb=0;function jt(e){const[t,n]=h.useState(kb());return It(()=>{n(r=>r??String(Eb++))},[e]),e||(t?`radix-${t}`:"")}var Ib=h[" useInsertionEffect ".trim().toString()]||It;function In({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Nb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=Ab(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Nb({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Ib(()=>{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 Ab(e){return typeof e=="function"}var jb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=jb.reduce((e,t)=>{const n=Jt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Vi(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function xt(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 Pb(e,t=globalThis==null?void 0:globalThis.document){const n=xt(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 _b="DismissableLayer",Ki="dismissableLayer.update",Mb="dismissableLayer.pointerDownOutside",Rb="dismissableLayer.focusOutside",Yu,Xu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Xu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),b=Re(t,k=>p(k)),g=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),w=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,E=w>=y,T=Db(k=>{const A=k.target,j=[...c.branches].some(B=>B.contains(A));!E||j||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),S=Lb(k=>{const A=k.target;[...c.branches].some(B=>B.contains(A))||(s==null||s(k),i==null||i(k),k.defaultPrevented||a==null||a())},m);return Pb(k=>{w===c.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Yu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Yu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Zu())},[d,c]),h.useEffect(()=>{const k=()=>f({});return document.addEventListener(Ki,k),()=>document.removeEventListener(Ki,k)},[]),u.jsx(me.div,{...l,ref:b,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:le(e.onFocusCapture,S.onFocusCapture),onBlurCapture:le(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:le(e.onPointerDownCapture,T.onPointerDownCapture)})});Er.displayName=_b;var Ob="DismissableLayerBranch",Ju=h.forwardRef((e,t)=>{const n=h.useContext(Xu),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]),u.jsx(me.div,{...e,ref:o})});Ju.displayName=Ob;function Db(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Qu(Mb,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Lb(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Qu(Rb,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 Zu(){const e=new CustomEvent(Ki);document.dispatchEvent(e)}function Qu(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?Vi(o,s):o.dispatchEvent(s)}var $b=Er,Fb=Ju,qi="focusScope.autoFocusOnMount",Gi="focusScope.autoFocusOnUnmount",ed={bubbles:!1,cancelable:!0},Bb="FocusScope",Xo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=xt(o),d=xt(s),p=h.useRef(null),m=Re(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(f.paused||!a)return;const E=C.target;a.contains(E)?p.current=E:Ln(p.current,{select:!0})},v=function(C){if(f.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Ln(p.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const T of C)T.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),w.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){rd.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(qi,ed);a.addEventListener(qi,c),a.dispatchEvent(y),y.defaultPrevented||(zb(Kb(td(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(qi,c),setTimeout(()=>{const y=new CustomEvent(Gi,ed);a.addEventListener(Gi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Gi,d),rd.remove(f)},0)}}},[a,c,d,f]);const b=h.useCallback(g=>{if(!n&&!r||f.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(v&&y){const w=g.currentTarget,[C,E]=Hb(w);C&&E?!g.shiftKey&&y===E?(g.preventDefault(),n&&Ln(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Ln(E,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:b})});Xo.displayName=Bb;function zb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Hb(e){const t=td(e),n=nd(t,e),r=nd(t.reverse(),e);return[n,r]}function td(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 nd(e,t){for(const n of e)if(!Ub(n,{upTo:t}))return n}function Ub(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 Wb(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wb(e)&&t&&e.select()}}var rd=Vb();function Vb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=od(e,t),e.unshift(t)},remove(t){var n;e=od(e,t),(n=e[0])==null||n.resume()}}}function od(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Kb(e){return e.filter(t=>t.tagName!=="A")}var qb="Portal",oo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Oo.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});oo.displayName=qb;function Gb(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=Yb(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Re(r.ref,Xb(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function Yb(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Gb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=Jo(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=Jo(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=Jo(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=f=>{f.target===t&&(s.current=Jo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Jo(e){return(e==null?void 0:e.animationName)||"none"}function Xb(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 Yi=0;function Xi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sd()),document.body.insertAdjacentElement("beforeend",e[1]??sd()),Yi++,()=>{Yi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Yi--}},[])}function sd(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var xn=function(){return xn=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},xn.apply(this,arguments)};function id(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 Jb(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 Zo="right-scroll-bar-position",Qo="width-before-scroll-bar",Zb="with-scroll-bars-hidden",Qb="--removed-body-scroll-bar-size";function Ji(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ew(e,t){var n=x.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 tw=typeof window<"u"?h.useLayoutEffect:h.useEffect,ad=new WeakMap;function nw(e,t){var n=ew(null,function(r){return e.forEach(function(o){return Ji(o,r)})});return tw(function(){var r=ad.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ji(a,null)}),s.forEach(function(a){o.has(a)||Ji(a,i)})}ad.set(n,e)},[e]),n}function rw(e){return e}function ow(e,t){t===void 0&&(t=rw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function sw(e){e===void 0&&(e={});var t=ow(null);return t.options=xn({async:!0,ssr:!1},e),t}var ld=function(e){var t=e.sideCar,n=id(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,xn({},n))};ld.isSideCarExport=!0;function iw(e,t){return e.useMedium(t),ld}var cd=sw(),Zi=function(){},es=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Zi,onWheelCapture:Zi,onTouchMoveCapture:Zi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,b=e.noIsolation,g=e.inert,v=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,C=e.gapMode,E=id(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,S=nw([n,t]),k=xn(xn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(T,{sideCar:cd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:b,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),xn(xn({},k),{ref:S})):h.createElement(w,xn({},k,{className:l,ref:S}),a))});es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},es.classNames={fullWidth:Qo,zeroRight:Zo};var aw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function lw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=aw();return t&&e.setAttribute("nonce",t),e}function cw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function uw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var dw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=lw())&&(cw(t,n),uw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},fw=function(){var e=dw();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ud=function(){var e=fw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},pw={left:0,top:0,right:0,gap:0},Qi=function(e){return parseInt(e||"",10)||0},hw=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[Qi(n),Qi(r),Qi(o)]},mw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return pw;var t=hw(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])}},gw=ud(),Ir="data-scroll-locked",vw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
-
.`.concat(
|
|
37
|
+
`))>=0;){const Le=Qe.slice(0,xe);Qe=Qe.slice(xe+2);const Ue=Le.split(/\r?\n/),st=[];let tt=null;for(const ue of Ue){if(ue.startsWith(":")){ue.startsWith(": heartbeat")&&console.debug("[use-chat] SSE heartbeat comment received");continue}if(ue){if(ue.startsWith("event:")){const Ie=ue.slice(6).trim();Ie&&(tt=Ie);continue}if(ue.startsWith("data:")){const Ie=ue.slice(5);st.push(Ie.startsWith(" ")?Ie.slice(1):Ie)}}}const ut=st.join(`
|
|
38
|
+
`);if(!ut)continue;let et;try{et=JSON.parse(ut)}catch{console.debug("[use-chat] malformed SSE:",ut.slice(0,200));continue}tt&&typeof et=="object"&&et!==null&&!("type"in et)&&(et.type=tt);const Q=du(et)?et.data:et;if(!Q){console.warn("[use-chat] dropped envelope event without payload",et);continue}const ee=Q;mt=Date.now(),ee.type==="values"&&(ee.type="state_history"),ee.type==="metadata"&&(ee.title||ee.createdAt)&&(ee.type="thread_info");const he=ee.seq;if(he!==void 0){if(he<=ht){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:he,lastProcessedSeq:ht,type:ee.type});continue}ht>0&&he>ht+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:ht,to:he})),ht=he,k.current=he,v(he)}if(ee.type==="checkpoint")P.current=ee.checkpointId??null,F.current=ee.checkpointNs??null,x(ee.checkpointId??null);else if(ee.type==="state_history"){$.current=ee;try{const Ie=Xn(ee).latest;Ie&&(P.current=Ie.checkpointId??null,F.current=Ie.checkpointNs??null,x(Ie.checkpointId??null))}catch(ue){console.warn("[use-chat] Failed to hydrate state_history payload",ue)}}try{O==null||O(ee)}catch(ue){console.error("[use-chat] Error in onEvent callback:",ue,"for event:",ee.type)}if(ee.type==="messages/partial"){const Ie=ee.messages;if(Array.isArray(Ie)&&Ie.length>0){const N=Ie.find(te=>te.type==="ai");if(N){const te=N.id,ne=N.content??"",ce=N.response_metadata??{};if(B.current.messageId!==te){const we=ce.model_name??ce.model_provider??"assistant";B.current={messageId:te,lastSeq:null,lastText:""},E({id:te,role:"assistant",name:we,model:we,createdAt:new Date().toISOString(),content:[{type:"text",text:ne}]})}else E(we=>!we||we.id!==te?we:{...we,content:[{type:"text",text:ne}]});const ge=B.current.lastText||"";if(ne.length>ge.length){const we=ne.slice(ge.length);B.current.lastText=ne,e.autoAppendAssistant!==!1&&(Tt.push(we),jt())}}}}else if(ee.type==="updates"){const ue=ee;if(ue.tools){const Ie=ue.tools;if(Ie.status==="start"){const N={type:"tool.start",id:Ie.id,name:Ie.name,args:Ie.args,seq:ue.seq,call_id:Ie.id};try{O==null||O(N)}catch(te){console.error("[use-chat] Error in onEvent (tool.start polyfill):",te)}}else if(Ie.status==="end"){const N={type:"tool.end",id:Ie.id,name:Ie.name,output:Ie.output,artifact:Ie.artifact,seq:ue.seq,call_id:Ie.id};try{O==null||O(N)}catch(te){console.error("[use-chat] Error in onEvent (tool.end polyfill):",te)}}}continue}else if(ee.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ae=I==null?void 0:I.onHeartbeat)==null||ae.call(I,ee)}catch(ue){console.warn("[use-chat] heartbeat callback failed",ue)}}else if(wt!==null&&cancelAnimationFrame(wt),At(),ee.type==="checkpoint")x(ee.checkpointId);else if(ee.type==="error"){const ue=ee;if(d(ue.message),J="error",M=ue.message,ue.error_type==="auth_error"||ue.code==="TOKEN_EXPIRED"||((Se=ue.message)==null?void 0:Se.includes("token"))||((Ce=ue.message)==null?void 0:Ce.includes("401"))||((Oe=ue.message)==null?void 0:Oe.includes("unauthorized"))||((Fe=ue.message)==null?void 0:Fe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",ue.message);try{(Be=I==null?void 0:I.onAuthError)==null||Be.call(I,ue.message)}catch(N){console.warn("[use-chat] onAuthError handler failed",N)}H.abort()}}}}At(),J===null&&!H.signal.aborted&&(J="complete")}catch(Ve){if(Ve.name==="AbortError")J=J??"aborted";else{const $e=Ve.message||String(Ve);J="error",M=$e,d($e),(Ke=I==null?void 0:I.onError)==null||Ke.call(I,$e)}}finally{try{await Xe.cancel()}catch{}finally{(ze=Xe.releaseLock)==null||ze.call(Xe)}wt!==null&&typeof window<"u"&&window.cancelAnimationFrame(wt),clearInterval(gt)}}catch(He){if(He.name==="AbortError")J=J??"aborted";else{const Re=He.message||String(He);J="error",M=Re,d(Re),(dt=I==null?void 0:I.onError)==null||dt.call(I,Re),q||((pt=I==null?void 0:I.onConnectionError)==null||pt.call(I,Re),q=!0)}}finally{const He=k.current,Re=P.current,qe=F.current,Ae=$.current,Ge=J??(H.signal.aborted?"aborted":M?"error":"complete");try{(Ze=I==null?void 0:I.onClosed)==null||Ze.call(I,{reason:Ge,lastSeq:He,lastCheckpointId:Re,lastCheckpointNs:qe,lastStateHistory:Ae,error:M})}catch(Xe){console.warn("[use-chat] onClosed callback failed",Xe)}l(!1),w(!1),T.current=null,k.current=0,v(0),A.current=null}})(),{close:()=>H.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var X;S.current=!1,(X=T.current)==null||X.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:Y,stop:W,clear:R,setToken:K}}const eb=["detail","message","error","description","title"];function qo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of eb){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function tb(e){if(!e)return"Request failed";const t=e.response,n=qo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function fu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[p,m]=b.useState(null),[f,x]=b.useState([]),[g,v]=b.useState(!1),[,y]=b.useState(null),[w,C]=b.useState(null),[E,T]=b.useState(!1),S=b.useRef(a),k=b.useRef(new Map);b.useEffect(()=>{S.current=a},[a]),b.useEffect(()=>{t!==void 0&&t!==S.current&&l(t)},[t]);const A=b.useCallback(async()=>{d(!0),m(null);try{const O=await e.listThreads();i(O??[])}catch(O){const I=String(O);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),P=b.useCallback(async()=>{v(!0),y(null);try{const O=await e.listSharedThreads();x(O??[])}catch(O){const I=String(O);y(I),n==null||n(I)}finally{v(!1)}},[e,n]);b.useEffect(()=>{A()},[A]),b.useEffect(()=>{P()},[P]),b.useEffect(()=>{r==null||r(a)},[a,r]);const F=b.useCallback(async(O,I)=>{try{const H=await e.createThread(O,I);return l(H.threadId),await A(),H.threadId}catch(H){const J=String(H);return n==null||n(J),null}},[e,n,A]),$=b.useCallback(async O=>{const I=s;i(J=>J.filter(M=>M.threadId!==O));const H=new AbortController;k.current.set(O,H);try{await e.deleteThread(O),S.current===O&&(l(null),o==null||o())}catch(J){i(I);const M=String(J);n==null||n(M)}finally{k.current.delete(O)}},[e,o,n,s]),B=b.useCallback(async(O,I)=>{try{await e.updateThread(O,I),await A()}catch(H){n==null||n(String(H))}},[e,n,A]),K=b.useCallback(async(O,I)=>{T(!0),C("Sharing thread…");try{await e.shareThread(O,I),await P(),C("Shared successfully")}catch(H){const J=tb(H);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{T(!1)}},[e,n,P]),R=b.useCallback(async(O,I)=>{try{await e.unshareThread(O,I),await P()}catch(H){const J=String(H);throw n==null||n(J),H}},[e,n,P]),W=b.useMemo(()=>({createThread:F,deleteThread:$,renameThread:B,refreshThreads:A,refreshSharedThreads:P,shareThread:K,unshareThread:R}),[F,$,B,A,P,K,R]),Y=b.useCallback(O=>{if(!(O!=null&&O.threadId))return;const I={threadId:O.threadId,title:O.title||`Thread ${O.threadId.slice(0,8)}`,project:O.project,createdAt:O.createdAt||new Date().toISOString(),updatedAt:O.updatedAt||new Date().toISOString(),messageCount:O.messageCount??1};i(H=>{let J=!1;const M=H.map(q=>q.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...q,title:I.title??q.title,project:I.project??q.project,updatedAt:I.updatedAt??q.updatedAt,messageCount:I.messageCount??q.messageCount}):q);return J?M:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...H])})},[]),X=b.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:S,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:Y,shareInFlight:E,shareStatus:w,clearShareStatus:X}}const pu=b.createContext(null);function hu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{chatApi:o}=On(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:x,shareInFlight:g,shareStatus:v,clearShareStatus:y}=fu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:v,clearShareStatus:y,addThreadFromEvent:x}),[s,i,a,l,c,d,p,m,f,g,v,y,x]);return u.jsx(pu.Provider,{value:w,children:e})}function yr(){const e=b.useContext(pu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function er(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=nb(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function nb(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function Mi(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Sr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Sr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Mi(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Sr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function tr(e){if(typeof e=="string")return e;if(Mi(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function mu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function gu(e){const t=tr(e);return typeof e=="string"&&mu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function nr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=er(t);if(n!==null)return nr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?nr(e.content):e}function vu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Go(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Oi(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function xu(e){const t=r=>{try{const o=Sr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
+
`)):t(e)}function bu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Di(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function wu(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function yu(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Su({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=wu(n),i=o?`data:${s};base64,${e}`:t,a=yu(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Cu(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return Su({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Li(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Cr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=er(t);return n!==null?Cr(n):t}if(Array.isArray(e))return e.map(t=>Cr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Cr(t)}return e}function Tu(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}function $i(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Yo(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function rb(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function ob(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 Yo(e,r,s)}return e}const sb={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ib(e,t){var n;switch(t.type){case"reset":return{messages:$i(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r],assemblingId:null}}}return{...e,messages:[...e.messages,r],assemblingId:null}}case"seed":{const r=$i(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=$i(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return ku(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>ku(o,s),e):e}default:return e}}function ab(e=[]){const[t,n]=b.useReducer(ib,{...sb,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function ku(e,t){if(t.type==="tool.start")return cb(e,t);if(t.type==="tool.progress")return ub(e,t);if(t.type==="tool.end")return db(e,t);if(t.type==="checkpoint"){const n=t.checkpointNs??e.lastCheckpointNs??null,r=ob(e.messages,t.checkpointId,n);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:n,messages:r}}if(t.type==="error"){const n={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,n]}}if(t.type==="state_history"){const n=Xn(t),r=n.interrupt,o=n.latest,s=r===null?rb(e.messages):e.messages;return{...e,messages:s,pendingInterrupt:r,lastCheckpointId:(o==null?void 0:o.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(o==null?void 0:o.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Fi(e){return e.call_id??e.id??null}function Eu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Iu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Bi(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Go(r).toolCallId===t)return n}return-1}function lb(e){if(e==null)return[];const t=nr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=tr(t??e);return n?[{type:"text",text:n}]:[]}function Nu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function cb(e,t){const n=Fi(t),r=Bi(e.messages,n),o=t.name??t.tool??void 0,s=Eu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Yo(e.messages,r,d)}}const i=Iu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function ub(e,t){const n=Fi(t);if(!n)return e;const r=Bi(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=Nu(e.messages[r],o);return{...e,messages:Yo(e.messages,r,a)}}function db(e,t){const n=Fi(t),r=Eu(t);let o=e.messages,s=Bi(o,n);if(s===-1){const x=t.name??t.tool??void 0;o=[...o,Iu(r,n,x,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=lb(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=Nu(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Yo(o,s,f)}}function Au({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,p]=b.useState(null),f=b.useMemo(()=>Xn(d),[d]).checkpoints,x=uc(f),g=x.timeline,[v,y]=b.useState(!1),[w,C]=b.useState(!1),[E,T]=b.useState(null),S=b.useRef(r),k=b.useRef(null),A=b.useRef(null),P=b.useRef(null),F=b.useRef(null),$=b.useRef(null),B=b.useRef(new Map),K=b.useRef(null);b.useEffect(()=>{S.current=r},[r]);const R=b.useCallback(async L=>{var G,_;if(!L.threadId)return;const D=L.threadId;(G=L.onStart)==null||G.call(L),L.setLoading(!0);try{await L.action(D)}catch(j){if(!eu(j)&&S.current===D){const Z=String(j);(_=L.handleError)==null||_.call(L,Z),n==null||n(Z)}throw j}finally{L.setLoading(!1)}},[n]),W=b.useCallback(async(L,D)=>{var Z;if(!L)return;const G=`${L}:${D??"latest"}`,_=B.current.get(G);if(_)return _;(Z=K.current)==null||Z.abort();const j=new AbortController;K.current=j;const U=R({threadId:L,setLoading:y,onStart:()=>T(null),handleError:se=>T(se),action:async se=>{const ae=await e.getStateHistory({threadId:se,checkpointId:D??void 0,signal:j.signal});if(S.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${S.current}), discarding stale data`);return}const{checkpoints:Se}=Xn(ae),Ce=Se.find(Oe=>Oe.messages&&Oe.messages.length>0)??(D?Se.find(Oe=>Oe.checkpointId===D):null)??Se[0];t((Ce==null?void 0:Ce.messages)??[],{checkpointId:(Ce==null?void 0:Ce.checkpointId)??null,checkpointNs:(Ce==null?void 0:Ce.checkpointNs)??null,pendingInterrupt:(Ce==null?void 0:Ce.interrupt)??null}),p(ae)}});B.current.set(G,U);try{await U}finally{B.current.delete(G),K.current===j&&(K.current=null)}return S.current===L&&($.current=G),U},[e,t,R]),Y=b.useCallback(async(L,D)=>{F.current=L;try{await W(L,D)}catch(G){if(!eu(G))throw G}finally{F.current===L&&(F.current=null)}},[W]),X=b.useCallback(L=>{A.current=L},[]),O=b.useCallback(L=>{P.current=L},[]),I=b.useCallback(L=>{const D=L.threadId??S.current;if(!D||S.current&&S.current!==D)return;const{checkpoints:G}=Xn(L);if(!G.length)return;const _=G.find(U=>U.messages&&U.messages.length>0)??G.find(U=>!!U.checkpointId)??G[0],j=P.current===D;!l&&!j&&t((_==null?void 0:_.messages)??[],{checkpointId:(_==null?void 0:_.checkpointId)??null,checkpointNs:(_==null?void 0:_.checkpointNs)??null,pendingInterrupt:(_==null?void 0:_.interrupt)??null}),p(L),$.current=`${D}:latest`,A.current=null,P.current===D&&(P.current=null)},[t,l]),H=b.useCallback(async(L,D)=>{const G=S.current;await R({threadId:G,setLoading:C,action:async _=>{const j=await e.getStateHistory({threadId:_,checkpointId:L,checkpointNs:D??void 0});if(S.current!==_)return;const{checkpoints:U}=Xn(j),Z=U.find(se=>se.checkpointId===L&&(D?se.checkpointNs===D:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:D});return}p(j),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,R]),J=b.useCallback((L,D)=>{t(c(),{checkpointId:L??null,checkpointNs:D??null})},[c,t]),M=b.useCallback(async()=>{S.current&&await Y(S.current)},[Y]);b.useEffect(()=>{if(!a||!r||v||l)return;if(A.current===r){A.current=null,k.current=r;return}if(P.current===r){k.current=r;return}if(F.current===r){F.current=null,k.current=r;return}if(k.current===r)return;k.current=r;let L;const D=`${r}:latest`;$.current!==D&&Y(r,L)},[a,r,s,i,o,v,l,Y]);const q=b.useCallback(()=>{p(null),y(!1),C(!1),T(null),A.current=null,P.current=null,k.current=null,$.current=null,F.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:x,isLoadingThread:v,isLoadingCheckpoint:w,threadStateError:E,loadThread:Y,navigateToCheckpoint:H,setCurrentCheckpointId:J,returnToLatest:M,handleStateHistoryEvent:I,markSkipNextLoad:X,markStreamPendingThread:O,resetHistoryState:q}}const Pu=b.createContext(null),ju=b.createContext(null);function no(){const e=b.useContext(Pu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function _u(){const e=b.useContext(ju);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Ru({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{chatApi:a}=On(),{currentThreadId:l}=yr(),{state:c,seed:d,pushUser:p,onEvent:m}=ab(),{threadCheckpoints:f,threadTimeline:x,checkpointIndex:g,isLoadingThread:v,isLoadingCheckpoint:y,threadStateError:w,loadThread:C,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:P,resetHistoryState:F}=Au({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[$,B]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[K,R]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),F())},[l,d,F]);const W=b.useCallback(H=>B(()=>H),[]),Y=b.useCallback(H=>R(()=>H),[]),X=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),O=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:x,metadata:X,isLoading:v,isLoadingCheckpoint:y,error:w,clearState:$,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,loadThread:C,clearThread:$,respondToInterrupt:K,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:P,resetHistoryState:F,pushUser:p,onEvent:m}),[l,c,f,x,g,X,v,y,w,$,E,T,S,C,K,g.messagePreviews,k,A,P,F,p,m]),I=b.useMemo(()=>({registerClearThread:W,registerRespondToInterrupt:Y}),[W,Y]);return u.jsx(ju.Provider,{value:I,children:u.jsx(Pu.Provider,{value:O,children:e})})}function Mu(e,t){if(!e)return null;const n=jn(e);if(!n)return null;const r=jn(n.configurable)??n;return _n(r,t)??null}function fb(e){const t=Mu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Mu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function pb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function hb(e,t){const n=[...e].sort(pb);for(const r of n){if(r.messageId!==t)continue;const o=fb(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Ou=b.createContext(null),Du=b.createContext(!1);function mb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{chatApi:d,baseUrl:p}=On(),m=p,{stream:f,stop:x,clear:g,isStreaming:v,assistantMessage:y,error:w,setToken:C}=Qx({baseUrl:m}),[E,T]=b.useState(!1);return b.useEffect(()=>{T(v)},[v]),u.jsx(hu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Ru,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:E,children:u.jsx(Du.Provider,{value:!0,children:u.jsx(gb,{api:d,streamApi:{stream:f,stop:x,clear:g,isStreaming:v,assistantMessage:y,error:w,setToken:C},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function gb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,clear:c,isStreaming:d,assistantMessage:p,error:m,setToken:f}=n,{setCurrentThreadId:x,currentThreadIdRef:g,addThreadFromEvent:v}=yr(),{checkpoint:y,timelineCheckpoints:w,handleStateHistoryEvent:C,markSkipNextLoad:E,markStreamPendingThread:T,resetHistoryState:S,pushUser:k,onEvent:A}=no(),{registerClearThread:P,registerRespondToInterrupt:F}=_u(),$=b.useCallback(I=>{v(I),g.current!==I.threadId&&((I.created??!g.current)&&E(I.threadId),T(I.threadId),x(I.threadId))},[v,E,T,x,g]),B=b.useCallback(I=>{I.type==="thread_info"?$(I):I.type==="state_history"?C(I):I.type==="tool.end"?(A(I),i==null||i(I)):A(I)},[$,C,A,i]),K=b.useCallback(I=>{a(I,B,{onError:H=>{console.error("[StreamingProvider] Stream error:",H),r==null||r(H)},onAuthError:H=>{console.error("[StreamingProvider] Auth error:",H),o==null||o(H)},onConnectionError:H=>{console.error("[StreamingProvider] Connection error:",H),s==null||s(H)}})},[a,B,r,o,s]),R=b.useRef(y);b.useEffect(()=>{R.current=y},[y]);const W=b.useCallback(async(I,H,J)=>{const M=g.current;if(!M)throw new Error("No active thread to handle interrupt");const q=I?H??!0:!1,L=R.current,D={threadId:M,checkpointId:L.id??void 0,checkpointNs:L.namespace??void 0,command:{kind:"resume",value:q},payload:J==null?void 0:J.payload,config:J==null?void 0:J.config,nodeFilter:J==null?void 0:J.nodeFilter,branchLabel:J==null?void 0:J.branchLabel,timelineCheckpoints:J==null?void 0:J.timelineCheckpoints};K(D)},[g,K]);b.useEffect(()=>{F(W)},[W,F]);const Y=b.useCallback(async()=>{l(),c(),S(),x(null)},[c,S,x,l]);b.useEffect(()=>{P(Y)},[Y,P]);const X=b.useCallback(async(I,H)=>{d&&l();let J=g.current;const M=(I==null?void 0:I.text)??"",q=(I==null?void 0:I.attachments)??[],L=(M==null?void 0:M.trim())??"",D={...(I==null?void 0:I.payload)??{}},G=Array.isArray(D.messages)?D.messages:void 0;G&&delete D.messages;const _=!!(G&&G.length),j=!!(I.contentParts&&I.contentParts.length>0);if(!J&&!L&&q.length===0&&!_&&!j)return;if(!J){const Ze=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),He=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);J=`${Ze}${He}`,E(J),x(J)}let U=null;I.contentParts&&I.contentParts.length>0&&(U=I.contentParts);const{contentParts:Z,filesInfo:se}=U?{contentParts:U,filesInfo:[]}:await uu(q),ae=[...Z];L&&ae.push({type:"text",text:M});const Se=H==null?void 0:H.originalMessageId,Ce=!!(H!=null&&H.edit&&Se),Oe=!_&&ae.length>0;let Fe=null;Oe&&(Fe={id:Ce?Se:`msg-${Date.now()}`,role:"user",content:ae,createdAt:new Date().toISOString()},Ce?k(Fe,Se):k(Fe));const Be=_?G:Fe?[Fe]:[],Ke={...D,...se.length?{files_info:se}:{}};Be.length?Ke.messages=Be:"messages"in Ke||(Ke.messages=[]);let ze=(H==null?void 0:H.checkpointId)??y.id??void 0,dt=(H==null?void 0:H.checkpointNs)??y.namespace??void 0;if(Ce&&Se){const Ze=hb(w,Se);ze=Ze.checkpointId,dt=Ze.checkpointNs??void 0}const pt={threadId:J,payload:Ke,checkpointId:ze,checkpointNs:dt,config:H==null?void 0:H.config,edit:!!(H!=null&&H.edit)};K(pt)},[y,g,d,E,k,K,l,w]),O=b.useMemo(()=>({isStreaming:d,error:m,connectionState:d?"connected":"idle",submit:X,send:X,stop:l,clear:c,setAuthToken:f,assistantMessage:p}),[d,p,m,X,l,c,f]);return u.jsx(Ou.Provider,{value:O,children:e})}function zi(){const e=b.useContext(Ou);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function vb(){return b.useContext(Du)}function Lu(e){return typeof e=="object"&&e!==null}function xb(e,t){if(Object.is(e,t))return!0;if(!Lu(e)||!Lu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function $u(e){const t=b.useRef(e),n=b.useRef(e);return xb(t.current,e)||(t.current=e,n.current=e),n.current}function Tr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=$u(t),m=ro(a),f=ro(l),x=ro(i),g=ro(c),v=ro(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:x,onThreadChange:g,onToolEnd:v}),[n,r,o,s,m,f,x,g,v]);return u.jsx(lu,{apiConfig:p,children:u.jsx(mb,{...y,children:e})})}function ro(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Fu(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"")}function Bu(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function zu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"");return""}function Hu(){const e={},t=Fu(),n=Bu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Uu(){const e=Hu(),t=Mn.getAuthToken(),n=Fu();return{apiBaseUrl:zu(e.baseUrl,n),apiKey:t||e.apiKey||Bu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Hi="chat-settings";function Wu(){try{const e=localStorage.getItem(Hi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Vu(e){try{const t={...e,apiBaseUrl:e.apiBaseUrl.trim().replace(/\/+$/,"")};localStorage.setItem(Hi,JSON.stringify(t)),t.apiKey&&Mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function bb(){const e=Uu(),t=Wu(),n=Mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:zu(Mn.baseUrl,r,e.apiBaseUrl)}}function wb(e){Mn.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),Vu(e)}function oe(...e){return mv.twMerge(hv.clsx(e))}const yb=Kr.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"}}),nt=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Jt.Slot:"button";return u.jsx(i,{className:oe(yb({variant:t,size:n,className:e})),ref:s,...o})});nt.displayName="Button";function le(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 Ku(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ku(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():Ku(e[o],null)}}}}function Me(...e){return h.useCallback(Dn(...e),e)}function Sb(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,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 nn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...x}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,v=h.useMemo(()=>x,Object.values(x));return u.jsx(g.Provider,{value:v,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,x=h.useContext(f);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Cb(o,...t)]}function Cb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Tb=h[" useId ".trim().toString()]||(()=>{}),kb=0;function Pt(e){const[t,n]=h.useState(Tb());return It(()=>{n(r=>r??String(kb++))},[e]),e||(t?`radix-${t}`:"")}var Eb=h[" useInsertionEffect ".trim().toString()]||It;function In({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ib({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=Nb(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Ib({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Eb(()=>{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 Nb(e){return typeof e=="function"}var Ab=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=Ab.reduce((e,t)=>{const n=Jt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ui(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function xt(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 Pb(e,t=globalThis==null?void 0:globalThis.document){const n=xt(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 jb="DismissableLayer",Wi="dismissableLayer.update",_b="dismissableLayer.pointerDownOutside",Rb="dismissableLayer.focusOutside",qu,Gu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Gu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),x=Me(t,k=>p(k)),g=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),w=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,E=w>=y,T=Ob(k=>{const A=k.target,P=[...c.branches].some(F=>F.contains(A));!E||P||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),S=Db(k=>{const A=k.target;[...c.branches].some(F=>F.contains(A))||(s==null||s(k),i==null||i(k),k.defaultPrevented||a==null||a())},m);return Pb(k=>{w===c.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(qu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Xu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=qu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Xu())},[d,c]),h.useEffect(()=>{const k=()=>f({});return document.addEventListener(Wi,k),()=>document.removeEventListener(Wi,k)},[]),u.jsx(me.div,{...l,ref:x,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:le(e.onFocusCapture,S.onFocusCapture),onBlurCapture:le(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:le(e.onPointerDownCapture,T.onPointerDownCapture)})});Er.displayName=jb;var Mb="DismissableLayerBranch",Yu=h.forwardRef((e,t)=>{const n=h.useContext(Gu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(me.div,{...e,ref:o})});Yu.displayName=Mb;function Ob(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Ju(_b,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Db(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Ju(Rb,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 Xu(){const e=new CustomEvent(Wi);document.dispatchEvent(e)}function Ju(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?Ui(o,s):o.dispatchEvent(s)}var Lb=Er,$b=Yu,Vi="focusScope.autoFocusOnMount",Ki="focusScope.autoFocusOnUnmount",Zu={bubbles:!1,cancelable:!0},Fb="FocusScope",Xo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=xt(o),d=xt(s),p=h.useRef(null),m=Me(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(f.paused||!a)return;const E=C.target;a.contains(E)?p.current=E:Ln(p.current,{select:!0})},v=function(C){if(f.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Ln(p.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const T of C)T.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),w.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){td.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Vi,Zu);a.addEventListener(Vi,c),a.dispatchEvent(y),y.defaultPrevented||(Bb(Vb(Qu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Vi,c),setTimeout(()=>{const y=new CustomEvent(Ki,Zu);a.addEventListener(Ki,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Ki,d),td.remove(f)},0)}}},[a,c,d,f]);const x=h.useCallback(g=>{if(!n&&!r||f.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(v&&y){const w=g.currentTarget,[C,E]=zb(w);C&&E?!g.shiftKey&&y===E?(g.preventDefault(),n&&Ln(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Ln(E,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:x})});Xo.displayName=Fb;function Bb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function zb(e){const t=Qu(e),n=ed(t,e),r=ed(t.reverse(),e);return[n,r]}function Qu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ed(e,t){for(const n of e)if(!Hb(n,{upTo:t}))return n}function Hb(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 Ub(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ub(e)&&t&&e.select()}}var td=Wb();function Wb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=nd(e,t),e.unshift(t)},remove(t){var n;e=nd(e,t),(n=e[0])==null||n.resume()}}}function nd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Vb(e){return e.filter(t=>t.tagName!=="A")}var Kb="Portal",oo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Oo.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});oo.displayName=Kb;function qb(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=Gb(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Me(r.ref,Yb(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function Gb(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=qb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=Jo(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=Jo(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=Jo(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=f=>{f.target===t&&(s.current=Jo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Jo(e){return(e==null?void 0:e.animationName)||"none"}function Yb(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 qi=0;function Gi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??rd()),document.body.insertAdjacentElement("beforeend",e[1]??rd()),qi++,()=>{qi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qi--}},[])}function rd(){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 xn=function(){return xn=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},xn.apply(this,arguments)};function od(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 Xb(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 Zo="right-scroll-bar-position",Qo="width-before-scroll-bar",Jb="with-scroll-bars-hidden",Zb="--removed-body-scroll-bar-size";function Yi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Qb(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var ew=typeof window<"u"?h.useLayoutEffect:h.useEffect,sd=new WeakMap;function tw(e,t){var n=Qb(null,function(r){return e.forEach(function(o){return Yi(o,r)})});return ew(function(){var r=sd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Yi(a,null)}),s.forEach(function(a){o.has(a)||Yi(a,i)})}sd.set(n,e)},[e]),n}function nw(e){return e}function rw(e,t){t===void 0&&(t=nw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function ow(e){e===void 0&&(e={});var t=rw(null);return t.options=xn({async:!0,ssr:!1},e),t}var id=function(e){var t=e.sideCar,n=od(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,xn({},n))};id.isSideCarExport=!0;function sw(e,t){return e.useMedium(t),id}var ad=ow(),Xi=function(){},es=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Xi,onWheelCapture:Xi,onTouchMoveCapture:Xi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,x=e.noIsolation,g=e.inert,v=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,C=e.gapMode,E=od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,S=tw([n,t]),k=xn(xn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(T,{sideCar:ad,removeScrollBar:c,shards:p,noRelative:f,noIsolation:x,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),xn(xn({},k),{ref:S})):h.createElement(w,xn({},k,{className:l,ref:S}),a))});es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},es.classNames={fullWidth:Qo,zeroRight:Zo};var iw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function aw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=iw();return t&&e.setAttribute("nonce",t),e}function lw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function cw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var uw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=aw())&&(lw(t,n),cw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},dw=function(){var e=uw();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ld=function(){var e=dw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},fw={left:0,top:0,right:0,gap:0},Ji=function(e){return parseInt(e||"",10)||0},pw=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[Ji(n),Ji(r),Ji(o)]},hw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return fw;var t=pw(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])}},mw=ld(),Ir="data-scroll-locked",gw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
+
.`.concat(Jb,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
43
43
|
}
|
|
@@ -71,29 +71,29 @@ React keys must be passed directly to JSX without using spread:
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
body[`).concat(Ir,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(Zb,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},
|
|
76
|
+
`)},cd=function(){var e=parseInt(document.body.getAttribute(Ir)||"0",10);return isFinite(e)?e:0},vw=function(){h.useEffect(function(){return document.body.setAttribute(Ir,(cd()+1).toString()),function(){var e=cd()-1;e<=0?document.body.removeAttribute(Ir):document.body.setAttribute(Ir,e.toString())}},[])},xw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;vw();var s=h.useMemo(function(){return hw(o)},[o]);return h.createElement(mw,{styles:gw(s,!t,o,n?"":"!important")})},Zi=!1;if(typeof window<"u")try{var ts=Object.defineProperty({},"passive",{get:function(){return Zi=!0,!0}});window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{Zi=!1}var Nr=Zi?{passive:!1}:!1,bw=function(e){return e.tagName==="TEXTAREA"},ud=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!bw(e)&&n[t]==="visible")},ww=function(e){return ud(e,"overflowY")},yw=function(e){return ud(e,"overflowX")},dd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=fd(e,r);if(o){var s=pd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Sw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Cw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},fd=function(e,t){return e==="v"?ww(t):yw(t)},pd=function(e,t){return e==="v"?Sw(t):Cw(t)},Tw=function(e,t){return e==="h"&&t==="rtl"?-1:1},kw=function(e,t,n,r,o){var s=Tw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=pd(e,a),x=f[0],g=f[1],v=f[2],y=g-v-s*x;(x||y)&&fd(e,a)&&(p+=y,m+=x);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(p)<1||!d&&Math.abs(m)<1)&&(c=!0),c},ns=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},hd=function(e){return[e.deltaX,e.deltaY]},md=function(e){return e&&"current"in e?e.current:e},Ew=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Iw=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},
|
|
79
|
+
`)},Nw=0,Ar=[];function Aw(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Nw++)[0],s=h.useState(ld)[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 g=Xb([e.lockRef.current],(e.shards||[]).map(md),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,v){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ns(g),w=n.current,C="deltaX"in g?g.deltaX:w[0]-y[0],E="deltaY"in g?g.deltaY:w[1]-y[1],T,S=g.target,k=Math.abs(C)>Math.abs(E)?"h":"v";if("touches"in g&&k==="h"&&S.type==="range")return!1;var A=dd(k,S);if(!A)return!0;if(A?T=k:(T=k==="v"?"h":"v",A=dd(k,S)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||E)&&(r.current=T),!T)return!0;var P=r.current||T;return kw(P,v,g,P==="h"?C:E)},[]),l=h.useCallback(function(g){var v=g;if(!(!Ar.length||Ar[Ar.length-1]!==s)){var y="deltaY"in v?hd(v):ns(v),w=t.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&Ew(T.delta,y)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var C=(i.current.shards||[]).map(md).filter(Boolean).filter(function(T){return T.contains(v.target)}),E=C.length>0?a(v,C[0]):!i.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),c=h.useCallback(function(g,v,y,w){var C={name:g,delta:v,target:y,should:w,shadowParent:Pw(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(E){return E!==C})},1)},[]),d=h.useCallback(function(g){n.current=ns(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,hd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,ns(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Ar.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",d,Nr),function(){Ar=Ar.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",d,Nr)}},[]);var f=e.removeScrollBar,x=e.inert;return h.createElement(h.Fragment,null,x?h.createElement(s,{styles:Iw(o)}):null,f?h.createElement(xw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Pw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const jw=sw(ad,Aw);var rs=h.forwardRef(function(e,t){return h.createElement(es,xn({},e,{ref:t,sideCar:jw}))});rs.classNames=es.classNames;var _w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Pr=new WeakMap,os=new WeakMap,ss={},Qi=0,gd=function(e){return e&&(e.host||gd(e.parentNode))},Rw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=gd(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})},Mw=function(e,t,n,r){var o=Rw(t,Array.isArray(e)?e:[e]);ss[n]||(ss[n]=new WeakMap);var s=ss[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),x=f!==null&&f!=="false",g=(Pr.get(m)||0)+1,v=(s.get(m)||0)+1;Pr.set(m,g),s.set(m,v),i.push(m),g===1&&x&&os.set(m,!0),v===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),Qi++,function(){i.forEach(function(p){var m=Pr.get(p)-1,f=s.get(p)-1;Pr.set(p,m),s.set(p,f),m||(os.has(p)||p.removeAttribute(r),os.delete(p)),f||p.removeAttribute(n)}),Qi--,Qi||(Pr=new WeakMap,Pr=new WeakMap,os=new WeakMap,ss={})}},ea=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=_w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Mw(r,o,n,"aria-hidden")):function(){return null}},is="Dialog",[vd,O1]=nn(is),[Ow,un]=vd(is),xd=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=In({prop:r,defaultProp:o??!1,onChange:s,caller:is});return u.jsx(Ow,{scope:t,triggerRef:a,contentRef:l,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};xd.displayName=is;var bd="DialogTrigger",wd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(bd,n),s=Me(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ra(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});wd.displayName=bd;var ta="DialogPortal",[Dw,yd]=vd(ta,{forceMount:void 0}),Sd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=un(ta,t);return u.jsx(Dw,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ft,{present:n||s.open,children:u.jsx(oo,{asChild:!0,container:o,children:i})}))})};Sd.displayName=ta;var as="DialogOverlay",Cd=h.forwardRef((e,t)=>{const n=yd(as,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(as,e.__scopeDialog);return s.modal?u.jsx(Ft,{present:r||s.open,children:u.jsx($w,{...o,ref:t})}):null});Cd.displayName=as;var Lw=Jt.createSlot("DialogOverlay.RemoveScroll"),$w=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(as,n);return u.jsx(rs,{as:Lw,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":ra(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),rr="DialogContent",Td=h.forwardRef((e,t)=>{const n=yd(rr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(rr,e.__scopeDialog);return u.jsx(Ft,{present:r||s.open,children:s.modal?u.jsx(Fw,{...o,ref:t}):u.jsx(Bw,{...o,ref:t})})});Td.displayName=rr;var Fw=h.forwardRef((e,t)=>{const n=un(rr,e.__scopeDialog),r=h.useRef(null),o=Me(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return ea(s)},[]),u.jsx(kd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:le(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:le(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault())})}),Bw=h.forwardRef((e,t)=>{const n=un(rr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(kd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),kd=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=un(rr,n),l=h.useRef(null),c=Me(t,l);return Gi(),u.jsxs(u.Fragment,{children:[u.jsx(Xo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Er,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ra(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(zw,{titleId:a.titleId}),u.jsx(Uw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),na="DialogTitle",Ed=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(na,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Ed.displayName=na;var Id="DialogDescription",Nd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Id,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});Nd.displayName=Id;var Ad="DialogClose",Pd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Ad,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});Pd.displayName=Ad;function ra(e){return e?"open":"closed"}var jd="DialogTitleWarning",[D1,_d]=Sb(jd,{contentName:rr,titleName:na,docsSlug:"dialog"}),zw=({titleId:e})=>{const t=_d(jd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
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},Uw="DialogDescriptionWarning",Ww=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Rd(Uw).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},ia=wd,Vw=Sd,aa=Td,so=kd,io=Ed,or=Nd,ls=jd,Od=_d;const la=ia,Kw=aa,Dd=h.forwardRef(({className:e,...t},n)=>u.jsx(so,{ref:n,className:oe("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}));Dd.displayName=so.displayName;const cs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===or||(c==null?void 0:c.displayName)===or.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(Kw,{children:[u.jsx(Dd,{}),u.jsxs(io,{ref:r,className:oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(or,{className:"sr-only",children:"Dialog"}),t,u.jsxs(Od,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});cs.displayName=io.displayName;const us=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});us.displayName="DialogHeader";const ds=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));ds.displayName=or.displayName;const qw=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));qw.displayName=ls.displayName;const Gw=1,Yw=1e6;let ca=0;function Xw(){return ca=(ca+1)%Number.MAX_SAFE_INTEGER,ca.toString()}const ua=new Map,Ld=e=>{if(ua.has(e))return;const t=setTimeout(()=>{ua.delete(e),ao({type:"REMOVE_TOAST",toastId:e})},Yw);ua.set(e,t)},Jw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Gw)};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?Ld(n):e.toasts.forEach(r=>{Ld(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},fs=[];let ps={toasts:[]};function ao(e){ps=Jw(ps,e),fs.forEach(t=>{t(ps)})}function Zw({...e}){const t=Xw(),n=o=>ao({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>ao({type:"DISMISS_TOAST",toastId:t});return ao({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function da(){const[e,t]=h.useState(ps);return h.useEffect(()=>(fs.push(t),()=>{const n=fs.indexOf(t);n>-1&&fs.splice(n,1)}),[e]),{...e,toast:Zw,dismiss:n=>ao({type:"DISMISS_TOAST",toastId:n})}}const Qw=.5,ey=3,ty=.1;function ny({url:e,mimeType:t,loading:n=!1,error:r=null,className:o,initialZoom:s=1,minZoom:i=Qw,maxZoom:a=ey,zoomStep:l=ty}){const[c,d]=x.useState(s),[p,m]=x.useState(0),[f,b]=x.useState(0),[g,v]=x.useState(!1),[y,w]=x.useState(null),C=x.useRef(null),E=t==null?void 0:t.startsWith("image/");x.useEffect(()=>{d(s),m(0),b(0)},[e,s]);const T=x.useCallback(F=>{if(!e||!E)return;F.preventDefault(),F.stopPropagation();const V=F.deltaY>0?-l:l;d(K=>{const R=K+V;return Math.min(a,Math.max(i,R))})},[e,l,a,i,E]),S=x.useCallback(()=>{!e||!E||(d(F=>F===1?Math.min(2,a):1),c!==1&&(m(0),b(0)))},[e,a,c,E]),k=(F,V)=>{const K=F.clientX-V.clientX,R=F.clientY-V.clientY;return Math.sqrt(K*K+R*R)},A=x.useCallback(F=>{if(E&&F.touches.length===2){F.preventDefault();const V=k(F.touches[0],F.touches[1]);C.current=V}},[E]),j=x.useCallback(F=>{if(F.touches.length===2&&C.current!==null){F.preventDefault();const V=k(F.touches[0],F.touches[1]),K=V/C.current;if(!Number.isFinite(K)||K===0)return;d(R=>{const I=R*K;return Math.min(a,Math.max(i,I))}),C.current=V}},[a,i]),B=x.useCallback(()=>{C.current=null},[]),$=x.useCallback(F=>{!e||!E||F.button===0&&(v(!0),w({x:F.clientX,y:F.clientY}))},[e,E]),z=x.useCallback(F=>{if(!g||!y)return;F.preventDefault();const V=(F.clientX-y.x)/c,K=(F.clientY-y.y)/c;m(R=>R+V),b(R=>R+K),w({x:F.clientX,y:F.clientY})},[g,y,c]),G=x.useCallback(()=>{v(!1),w(null)},[]),M=x.useCallback(()=>{v(!1),w(null)},[]);return u.jsxs("div",{className:oe("relative flex items-center justify-center overflow-hidden bg-card rounded-xl border border-border select-none",o),onWheel:T,onDoubleClick:S,onTouchStart:A,onTouchMove:j,onTouchEnd:B,onMouseDown:$,onMouseMove:z,onMouseUp:G,onMouseLeave:M,style:{touchAction:"none"},children:[n&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10 bg-background/50",children:u.jsxs("div",{className:"flex flex-col items-center gap-2",children:[u.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading preview..."})]})}),!n&&r?u.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-4",children:[u.jsx("p",{className:"text-destructive text-sm font-medium mb-1",children:"Preview Error"}),u.jsx("p",{className:"text-muted-foreground text-xs",children:r})]}):!n&&!e?u.jsx("div",{className:"text-muted-foreground text-sm",children:"No preview available"}):u.jsx("div",{className:"flex h-full w-full items-center justify-center",style:E?{transform:`scale(${c}) translate(${p}px, ${f}px)`,cursor:g?"grabbing":c>1?"grab":"default",transition:g?"none":"transform 0.1s ease-out"}:void 0,children:E?u.jsx("img",{src:e,alt:"File Preview",className:"h-full w-full object-contain pointer-events-none",draggable:!1}):u.jsx("object",{data:e,type:t||"application/pdf",className:"h-full w-full",children:u.jsx("div",{className:"flex bg-muted text-muted-foreground items-center justify-center h-full",children:"Preview not supported for this file type"})})})]})}function fa(e,t){return t==="application/octet-stream"&&e.toLowerCase().endsWith(".pdf")?"application/pdf":t}function ry({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=x.useState(!1),[a,l]=x.useState(null),[c,d]=x.useState(null),{toast:p}=da(),{fileApi:m}=On(),f=x.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const w=await m.getFileContent(n);l(w)}catch(w){console.error("Failed to load file:",w),d(w instanceof Error?w.message:"Failed to load file")}finally{i(!1)}}},[n,m]);x.useEffect(()=>{e&&n&&f()},[e,n,f]);const b=async()=>{if(n)try{await m.downloadFileById(n),p({title:"Download started",description:`Downloading ${r}`})}catch(w){console.error("Failed to download file:",w),p({title:"Download failed",description:String(w),variant:"destructive"})}},g=x.useMemo(()=>{if(!a)return null;try{const w=fa(r,o);if(w.startsWith("image/")||w==="application/pdf"){const E=atob(a),T=new Array(E.length);for(let A=0;A<E.length;A++)T[A]=E.charCodeAt(A);const S=new Uint8Array(T),k=new Blob([S],{type:w});return URL.createObjectURL(k)}else{const E=new Blob([a],{type:w});return URL.createObjectURL(E)}}catch(w){return console.error("Error creating object URL:",w),null}},[a,r,o]);x.useEffect(()=>()=>{g&&URL.revokeObjectURL(g)},[g]);const v=()=>{if(s)return u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]});if(c)return u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(et,{onClick:f,variant:"outline",children:"Try Again"})]});if(!a)return u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})});const w=fa(r,o);return w.startsWith("text/")||w.includes("json")||w.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsx(ny,{url:g,mimeType:w,className:"w-full h-[70vh] border-0",error:c})},y=()=>fa(r,o).startsWith("image/")?u.jsx(ue.Image,{className:"h-5 w-5"}):u.jsx(ue.FileText,{className:"h-5 w-5"});return u.jsx(la,{open:e,onOpenChange:t,children:u.jsxs(cs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(us,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[y(),u.jsxs("div",{children:[u.jsx(ds,{className:"text-left",children:r}),u.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:o})]})]}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs(et,{variant:"outline",size:"sm",onClick:b,className:"flex items-center gap-2",children:[u.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function $d(){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 sr=$d();function oy(e){sr=e}const Fd=/[&<>"']/,sy=new RegExp(Fd.source,"g"),Bd=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,iy=new RegExp(Bd.source,"g"),ay={"&":"&","<":"<",">":">",'"':""","'":"'"},zd=e=>ay[e];function Rt(e,t){if(t){if(Fd.test(e))return e.replace(sy,zd)}else if(Bd.test(e))return e.replace(iy,zd);return e}const ly=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Hd(e){return e.replace(ly,(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 cy=/(^|[^\[])\^/g;function rt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(cy,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const uy=/[^\w:]/g,dy=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ud(e,t,n){if(e){let r;try{r=decodeURIComponent(Hd(n)).replace(uy,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!dy.test(n)&&(n=my(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const hs={},fy=/^[^:]+:\/*[^/]*$/,py=/^([^:]+:)[\s\S]*$/,hy=/^([^:]+:\/*[^/]*)[\s\S]*$/;function my(e,t){hs[" "+e]||(fy.test(e)?hs[" "+e]=e+"/":hs[" "+e]=gs(e,"/",!0)),e=hs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(py,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(hy,"$1")+t:e+t}const ms={exec:function(){}};function Wd(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function gs(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 gy(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 vy(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 Vd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Kd(e,t,n,r){const o=t.href,s=t.title?Rt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Rt(i)}}function xy(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
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},Hw="DialogDescriptionWarning",Uw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${_d(Hw).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},oa=xd,Ww=wd,sa=Sd,so=Cd,io=Td,or=Ed,ls=Nd,Rd=Pd;const ia=oa,Vw=sa,Md=h.forwardRef(({className:e,...t},n)=>u.jsx(so,{ref:n,className:oe("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}));Md.displayName=so.displayName;const cs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===or||(c==null?void 0:c.displayName)===or.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(Vw,{children:[u.jsx(Md,{}),u.jsxs(io,{ref:r,className:oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(or,{className:"sr-only",children:"Dialog"}),t,u.jsxs(Rd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});cs.displayName=io.displayName;const aa=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});aa.displayName="DialogHeader";const la=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));la.displayName=or.displayName;const Kw=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Kw.displayName=ls.displayName;function qw(e,t){return t==="application/octet-stream"&&e.toLowerCase().endsWith(".pdf")?"application/pdf":t}function Gw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const{chatApi:s}=On(),i=s.getAuthToken();if(!e||!n)return null;const a=`${s.baseUrl}/files/${n}/view?token=${i}`,c=qw(r,o).startsWith("image/");return u.jsx(ia,{open:e,onOpenChange:t,children:u.jsx(cs,{className:"max-w-6xl w-[95vw] h-[90vh] p-0 overflow-hidden border-none bg-background/95 backdrop-blur-md shadow-2xl",children:u.jsxs("div",{className:"w-full h-full flex flex-col relative group",children:[u.jsx("div",{className:"flex-1 min-h-0 w-full h-full bg-background/50 overflow-hidden",children:c?u.jsx("div",{className:"w-full h-full flex items-center justify-center p-8",children:u.jsx("img",{src:a,alt:r,className:"max-w-full max-h-full object-contain drop-shadow-2xl rounded-sm",loading:"lazy"})}):u.jsx("iframe",{src:a,className:"w-full h-full border-none",title:r,loading:"lazy"})}),u.jsx("div",{className:"absolute top-4 left-4 bg-background/80 backdrop-blur-md px-3 py-1.5 rounded-full border border-border text-xs font-medium text-muted-foreground opacity-100 group-hover:opacity-0 transition-opacity pointer-events-none shadow-sm",children:r})]})})})}function Od(){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 sr=Od();function Yw(e){sr=e}const Dd=/[&<>"']/,Xw=new RegExp(Dd.source,"g"),Ld=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Jw=new RegExp(Ld.source,"g"),Zw={"&":"&","<":"<",">":">",'"':""","'":"'"},$d=e=>Zw[e];function Mt(e,t){if(t){if(Dd.test(e))return e.replace(Xw,$d)}else if(Ld.test(e))return e.replace(Jw,$d);return e}const Qw=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Fd(e){return e.replace(Qw,(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 ey=/(^|[^\[])\^/g;function rt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(ey,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const ty=/[^\w:]/g,ny=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Bd(e,t,n){if(e){let r;try{r=decodeURIComponent(Fd(n)).replace(ty,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!ny.test(n)&&(n=iy(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const us={},ry=/^[^:]+:\/*[^/]*$/,oy=/^([^:]+:)[\s\S]*$/,sy=/^([^:]+:\/*[^/]*)[\s\S]*$/;function iy(e,t){us[" "+e]||(ry.test(e)?us[" "+e]=e+"/":us[" "+e]=fs(e,"/",!0)),e=us[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(oy,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(sy,"$1")+t:e+t}const ds={exec:function(){}};function zd(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function fs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function ay(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 ly(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 Hd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Ud(e,t,n,r){const o=t.href,s=t.title?Mt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Mt(i)}}function cy(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).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(`
|
|
85
|
-
`)}class
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
85
|
+
`)}class ca{constructor(t){this.options=t||sr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:fs(r,`
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=cy(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=fs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,p,m,f,x,g=n[1].trim();const v=g.length>1,y={type:"list",raw:"",ordered:v,start:v?+g.slice(0,-1):"",loose:!1,items:[]};g=v?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=v?g:"[*+-]");const w=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(x=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
87
87
|
`,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),p=t.split(`
|
|
88
88
|
`,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(p)&&(r+=p+`
|
|
89
|
-
`,t=t.substring(p.length+1),
|
|
89
|
+
`,t=t.substring(p.length+1),x=!0),!x){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),S=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
90
90
|
`,1)[0],p=m,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(S.test(p)||k.test(p)||E.test(p)||T.test(t)));){if(p.search(/[^ ]/)>=i||!p.trim())f+=`
|
|
91
91
|
`+p.slice(i);else{if(l||d.search(/[^ ]/)>=4||S.test(d)||k.test(d)||T.test(d))break;f+=`
|
|
92
92
|
`+p}!l&&!p.trim()&&(l=!0),r+=m+`
|
|
93
|
-
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(S=>S.type==="space"),T=E.length>0&&E.some(S=>/\n.*\n/.test(S.raw));y.loose=T}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):
|
|
94
|
-
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=
|
|
95
|
-
`?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:
|
|
96
|
-
]`).replace("lheading",ye.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:
|
|
93
|
+
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(S=>S.type==="space"),T=E.length>0&&E.some(S=>/\n.*\n/.test(S.raw));y.loose=T}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Mt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:zd(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
94
|
+
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=zd(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
95
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Mt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Mt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=fs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=ay(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),Ud(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 Ud(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const x=m.slice(1,-1);return{type:"em",raw:m,text:x,tokens:this.lexer.inlineTokens(x)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Mt(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Mt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Mt(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Mt(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Mt(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Mt(r[0]):r[0]:o=Mt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ye={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:ds,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ye._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ye._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ye.def=rt(ye.def).replace("label",ye._label).replace("title",ye._title).getRegex(),ye.bullet=/(?:[*+-]|\d{1,9}[.)])/,ye.listItemStart=rt(/^( *)(bull) */).replace("bull",ye.bullet).getRegex(),ye.list=rt(ye.list).replace(/bull/g,ye.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ye.def.source+")").getRegex(),ye._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",ye._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ye.html=rt(ye.html,"i").replace("comment",ye._comment).replace("tag",ye._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ye.paragraph=rt(ye._paragraph).replace("hr",ye.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",ye._tag).getRegex(),ye.blockquote=rt(ye.blockquote).replace("paragraph",ye.paragraph).getRegex(),ye.normal={...ye},ye.gfm={...ye.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ye.gfm.table=rt(ye.gfm.table).replace("hr",ye.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",ye._tag).getRegex(),ye.gfm.paragraph=rt(ye._paragraph).replace("hr",ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ye.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",ye._tag).getRegex(),ye.pedantic={...ye.normal,html:rt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ye._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ds,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rt(ye.normal._paragraph).replace("hr",ye.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",ye.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ds,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ds,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=rt(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=rt(ye._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=rt(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=rt(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=rt(pe.emStrong.rDelimUnd,"g").replace(/punct/g,pe._punctuation).getRegex(),pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,pe._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])?)+(?![-_])/,pe.autolink=rt(pe.autolink).replace("scheme",pe._scheme).replace("email",pe._email).getRegex(),pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,pe.tag=rt(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=rt(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=rt(pe.reflink).replace("label",pe._label).replace("ref",ye._label).getRegex(),pe.nolink=rt(pe.nolink).replace("ref",ye._label).getRegex(),pe.reflinkSearch=rt(pe.reflinkSearch,"g").replace("reflink",pe.reflink).replace("nolink",pe.nolink).getRegex(),pe.normal={...pe},pe.pedantic={...pe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:rt(pe.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},pe.gfm.url=rt(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:rt(pe.br).replace("{2,}","*").getRegex(),text:rt(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function uy(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 Wd(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 $n{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||sr,this.options.tokenizer=this.options.tokenizer||new ca,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:ye.normal,inline:pe.normal};this.options.pedantic?(n.block=ye.pedantic,n.inline=pe.pedantic):this.options.gfm&&(n.block=ye.gfm,this.options.breaks?n.inline=pe.breaks:n.inline=pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:ye,inline:pe}}static lex(t,n){return new $n(n).lex(t)}static lexInline(t,n){return new $n(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
97
97
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`: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+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
@@ -103,9 +103,9 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
103
103
|
`+r.raw,o.text+=`
|
|
104
104
|
`+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+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+
|
|
107
|
-
`,o?'<pre><code class="'+this.options.langPrefix+
|
|
108
|
-
`:"<pre><code>"+(r?t:
|
|
106
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+Hd("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)+"["+Hd("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,Wd)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Wd))){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 p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,uy)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class ua{constructor(t){this.options=t||sr}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$/,"")+`
|
|
107
|
+
`,o?'<pre><code class="'+this.options.langPrefix+Mt(o)+'">'+(r?t:Mt(t,!0))+`</code></pre>
|
|
108
|
+
`:"<pre><code>"+(r?t:Mt(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
110
110
|
${t}</blockquote>
|
|
111
111
|
`}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
|
|
@@ -123,10 +123,10 @@ ${t}</blockquote>
|
|
|
123
123
|
`}tablerow(t){return`<tr>
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
|
-
`}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=
|
|
127
|
-
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Rt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Xd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=wy(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(vy(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&be.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;be.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(be.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&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return Xd($n.lex,Fn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},oy(be.defaults),be},be.getDefaults=$d,be.defaults=sr,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.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=be.defaults.renderer||new ha;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=be.defaults.tokenizer||new pa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=be.defaults.hooks||new vs;for(const s in n.hooks){const i=o[s];vs.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=be.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}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=Xd($n.lexInline,Fn.parseInline),be.Parser=Fn,be.parser=Fn.parse,be.Renderer=ha,be.TextRenderer=Gd,be.Lexer=$n,be.lexer=$n.lex,be.Tokenizer=pa,be.Slugger=Yd,be.Hooks=vs,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,Fn.parse,$n.lex;function ir({content:e,className:t="",allowHtml:n=!1,style:r}){const o=x.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=x.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:oe("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Jd({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Zd({artifact:e,idx:t=0}){const n=x.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>ku(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Jd,{preview:r,idx:o},`${t}-plot-${o}`))}):null}const yy="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function xs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:yy,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:tr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:tr(e)})}function Qd({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=x.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const ma=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ma.displayName="Card";const ga=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));ga.displayName="CardHeader";const va=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));va.displayName="CardTitle";const xa=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));xa.displayName="CardDescription";const bs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));bs.displayName="CardContent";const ef=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));ef.displayName="CardFooter";const Sy=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function ba({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=Sy(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const p=tr(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:p})}return u.jsxs(ma,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ga,{className:"pb-3",children:[u.jsx(va,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(xa,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(bs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(p=>u.jsx(et,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,p),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:p.label}),p.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:p.description}):null]})},p.id))})}):d&&u.jsx(bs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(ef,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(et,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(et,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function tf({className:e}){const t=x.useRef(null);return x.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function nf({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(ir,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(et,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Cy(e,t,n){const[r,o]=x.useState(e),s=x.useRef(e),i=x.useRef(null);return x.useEffect(()=>{s.current=e;const a=()=>{o(s.current),i.current&&(clearTimeout(i.current),i.current=null)};if(!t||n<=0){a();return}return i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a()},n),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[e,t,n]),r}function rf({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,toolExpandable:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptPart:d,isStreamingMessage:p,streamingDebounceMs:m,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:b,defaultMessage:g,handleFileClick:v,uploadingFiles:y,messageRole:w,truncateUserMessages:C,userMessagePreviewLength:E,isUserExpanded:T,setIsUserExpanded:S,isCompactLayout:k,iconForeground:A,toolConfig:j,handleInterruptApprove:B,handleInterruptReject:$,handleInterruptAlternative:z,disableInterruptActions:G,isInterruptMessage:M}){const F=x.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),K=Cy(i,(f??!0)&&p,m??0),R=x.useMemo(()=>K.filter(P=>P.type==="text"),[K]),I=x.useMemo(()=>R.map(P=>P.text??"").join(""),[R]),U=x.useMemo(()=>{if(!b)return null;const P=ky(I);return{stablePart:I.slice(0,P),tailPart:I.slice(P)}},[I,b]),J=x.useMemo(()=>{if(!U)return null;const{stablePart:P,tailPart:W}=U;return!P&&!W?null:u.jsxs("div",{className:"space-y-2",children:[P?u.jsx(ir,{content:P,allowHtml:!1}):null,W?u.jsx(ir,{content:W,allowHtml:!1}):null]})},[U]),O=x.useMemo(()=>{if(!b)return K;const P=[];let W=!1;for(const Z of K){if(Z.type==="text"){W||(P.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),W=!0);continue}P.push(Z)}return P},[K,b]),L=(b?O:K).filter(P=>P.type!=="interrupt"&&P.type!=="image_url"),D=()=>!l||l.length===0?null:u.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.map((P,W)=>{const Z=P;return u.jsx("div",{className:"relative group",children:u.jsx("img",{src:Z.url,alt:Z.alt??"Image",loading:"lazy",onClick:()=>window.open(Z.url,"_blank"),className:"h-20 w-20 object-cover rounded-md border border-border/50 cursor-pointer hover:opacity-90 transition-opacity"})},W)})}),X=x.useCallback(({part:P,i:W})=>{if(P.type==="text"){if(b)return null;const Z=P.text??"",se=Z.trim(),ae=er(se);return ae&&w!=="tool"?u.jsx(xs,{data:ae},W):w==="user"&&C&&se.length>E?u.jsx(nf,{text:se,expanded:T,onExpandedChange:S,previewLength:E,isCompact:k},W):u.jsx(ir,{content:Z,allowHtml:!1},W)}if(P.type==="image_url")return null;if(P.type==="file"){const Z=P,se=Z.name||"file";return u.jsxs("a",{href:Z.url,onClick:ae=>v(ae,Z,W),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[y[
|
|
130
|
-
`),d=er(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=Ay(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=Cr(i),l=nr(a);return l&&typeof l=="object"&&!Array.isArray(l)?{kind:"dict",value:l,data:l,event:s}:{kind:"generic",value:l,event:s}},[e])}const ws=x.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,toolConfig:m,customStyles:f={},streamingDebounceMs:b=300,renderStreamingMarkdown:g=!0,enableStreamingMarkdownBuffer:v,onEdit:y,onRegenerate:w,onCopy:C,getInterruptOptions:E,attemptCount:T=1,attemptIndex:S=0,onSelectCheckpoint:k,attemptMetas:A=[]}){const[j,B]=x.useState(!1),[$,z]=x.useState(!1),{currentThreadId:G}=yr(),{respondToInterrupt:M}=no(),[F,V]=x.useState(!1),K=l==="phone"||l==="half-screen",R=t.role,I=R==="interrupt",U=R==="tool"||I,O=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:Y,toolArtifactRenderers:L,getToolExpandable:D}=m??{},X=x.useMemo(()=>!D||t.role!=="tool"?!1:D(t),[D,t.id,t.role]),[_,P]=x.useState(X?"preview":"expanded");x.useEffect(()=>{P(X?"preview":"expanded")},[X,t.id]);const W=x.useMemo(()=>t.role==="default_message"?t:null,[t]),Z=!!W,se=!(r&&R!=="user"),{uploadingFiles:ae,handleFileClick:Se,fileViewerOpen:Ce,currentFileInfo:Oe,closeFileViewer:Fe}=af({allowFileOpen:se,currentThreadId:G}),Be=x.useMemo(()=>{switch(R){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[R]),Ke=lf(t,W),{contentParts:ze,imageParts:dt,fileParts:pt,textContent:Ze,toolMeta:He,toolRaw:Me,isToolStreaming:qe,interruptParts:Ae}=Ke,Ge=v??b!==0,Xe=x.useMemo(()=>Ae.length?Ae[0]:null,[Ae]),Ct=x.useCallback(async()=>{const ee=U?Me:Ze;async function he(de){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(de);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ie=new Blob([de],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ie})]);return}throw new Error("Clipboard API not supported in this context.")}try{await he(ee),B(!0),setTimeout(()=>B(!1),2e3),C==null||C(ee)}catch(de){console.error("Failed to copy:",de)}},[U,Me,Ze,C]),Qe=x.useCallback(async(ee,he)=>{if(!Xe)return;if(!Li(Xe.id)){console.warn("Interrupt part missing id",Xe);return}V(!0);try{const Ie=E==null?void 0:E(t);await M(ee,he,Ie)}catch(Ie){console.error("Failed to respond to interrupt:",Ie)}finally{V(!1)}},[Xe,M]),Tt=x.useCallback(()=>Qe(!0),[Qe]),ht=x.useCallback(()=>Qe(!1),[Qe]),wt=x.useCallback((ee,he)=>{if(!he)return;const de={alternativeId:he.id??he.label??void 0,alternativeLabel:he.label};Qe(!0,de)},[Qe]),At=x.useCallback(()=>{if(!y||!t.id)return;const ee=(U?Me:Ze)??"",he="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,ee,he)},[y,U,Me,Ze,t]),Pt=x.useCallback(()=>{w==null||w(n)},[w,n]),mt=x.useCallback(()=>{const he=oe(K?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Be);switch(R){case"user":return u.jsx(ue.User,{className:he});case"assistant":return u.jsx(ue.Bot,{className:he});case"tool":return u.jsx(ue.Wrench,{className:he});case"interrupt":return u.jsx(ue.Bot,{className:he});default:return u.jsx(ue.Bot,{className:he})}},[K,Be,R]),gt=x.useCallback(()=>{const ee="group relative mb-4 flex w-full";switch(R){case"user":return oe(ee,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return oe(ee,"justify-start");default:return ee}},[R]),Ht=x.useCallback(()=>{const ee=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",K&&"px-3 py-2 text-sm");if(Z)return oe(ee,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(R){case"user":return oe(ee,"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 oe(ee,"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":case"interrupt":return oe(ee,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(ee,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(ee,"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")}},[K,Z,R]),Ve=X&&!I&&O,$e=x.useCallback(()=>{Ve&&P(ee=>ee==="expanded"?"preview":"expanded")},[Ve]),kt=I?"expanded":_,ct=(p||I)&&O,_t=u.jsx(rf,{message:t,isToolMessage:U,showToolMessages:ct,toolViewMode:kt,toolExpandable:X,toolConfig:{toolRenderers:Y,toolArtifactRenderers:L,getToolExpandable:D},isToolStreaming:qe,contentParts:ze,textContent:Ze,imageParts:dt,fileParts:pt,isStreamingMessage:r,defaultMessage:W,enableStreamingMarkdownBuffer:Ge,renderStreamingMarkdown:g,streamingDebounceMs:b,handleFileClick:Se,uploadingFiles:ae,messageRole:R,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:$,setIsUserExpanded:z,isCompactLayout:K,iconForeground:Be,interruptPart:Xe,handleInterruptApprove:Tt,handleInterruptReject:ht,handleInterruptAlternative:wt,disableInterruptActions:F,isInterruptMessage:I}),xe=x.useMemo(()=>W?"Assistant":yu(t),[W,t]),Le=mt(),Ue=R==="user"&&(T??1)>1&&typeof k=="function",st=(A==null?void 0:A.length)??0,nt=st>0&&S<st-1?A[S+1]:void 0,ut=st>0&&S>0?A[S-1]:void 0,tt=x.useCallback(()=>{!nt||!k||k(nt.id,void 0,!!nt.isLatestAttempt)},[nt,k]),Q=x.useCallback(()=>{!ut||!k||k(ut.id,void 0,!!ut.isLatestAttempt)},[ut,k]);return U&&!p?null:Z&&W?u.jsx("div",{className:oe(gt(),f.container),children:u.jsxs("div",{className:oe(Ht(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:oe("h-4 w-4",Be)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(ir,{content:W.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(gt(),f.container),children:u.jsxs("div",{className:oe(Ht(),f.content),children:[u.jsx(sf,{showTimestamp:i,showAgentName:a,isToolMessage:U,iconForeground:Be,agentName:xe,messageIcon:Le,customHeaderClass:f.header,customActionsClass:f.actions,isCompactLayout:K,showActions:s,isEditing:o,messageRole:R,toolViewMode:kt,toolExpandable:X,isInterruptMessage:I,toolMeta:He,onToggleToolView:$e,onCopy:Ct,onEdit:At,onRegenerate:Pt,showCheckpointControls:Ue,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:tt,handleNewerAttemptSelect:Q,messageCreatedAt:t.createdAt,copied:j}),u.jsx("div",{className:"relative",children:_t}),!(i||a||U)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",K&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:oe(j?"text-success":"text-current",K?"h-3 w-3":"h-4 w-4")})}),R==="user"&&y&&u.jsx(et,{variant:"ghost",size:"sm",onClick:At,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",K&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:oe("text-current",K?"h-3 w-3":"h-4 w-4")})}),R==="assistant"&&w&&u.jsx(et,{variant:"ghost",size:"sm",onClick:Pt,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",K&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:oe("text-current",K?"h-3 w-3":"h-4 w-4")})})]})]})}),Oe&&u.jsx(ry,{isOpen:Ce,onClose:Fe,fileId:Oe.id,fileName:Oe.name,mimeType:Oe.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,b,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&$i(e.message)===$i(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolConfig"].every(v=>e[v]===t[v]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((b=e.customStyles)==null?void 0:b.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Fi(e.message),a=Fi(t.message);return i.length===a.length});ws.displayName="MessageComponent";const ys=0,Bn=1,Pr=2,df=4;function ff(e){return()=>e}function jy(e){e()}function pf(e,t){return n=>e(t(n))}function hf(e,t){return()=>e(t)}function Py(e,t){return n=>e(t,n)}function wa(e){return e!==void 0}function _y(...e){return()=>{e.map(jy)}}function _r(){}function Ss(e,t){return t(e),e}function My(e,t){return t(e)}function it(...e){return e}function Je(e,t){return e(Bn,t)}function _e(e,t){e(ys,t)}function ya(e){e(Pr)}function bt(e){return e(df)}function ve(e,t){return Je(e,Py(t,ys))}function dn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function mf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function gf(e,t){return e===t}function at(e=gf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>pf(t,e)}function bn(e){return t=>()=>{t(e)}}function re(e,...t){const n=Ry(...t);return(r,o)=>{switch(r){case Pr:ya(e);return;case Bn:return Je(e,n(o))}}}function wn(e,t){return n=>r=>{n(t=e(t,r))}}function ar(e){return t=>n=>{e>0?e--:t(n)}}function Nn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Ry(...e){return t=>e.reduceRight(My,t)}function Oy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),_r);case Pr:r(),n=null;return}}}function ie(e){let t=e;const n=We();return(r,o)=>{switch(r){case ys:t=o;break;case Bn:{o(t);break}case df:return t}return n(r,o)}}function Ot(e,t){return Ss(ie(t),n=>ve(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case ys:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ss(We(),t=>ve(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Dy(),singleton:n}}const Dy=()=>Symbol();function Ly(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function St(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{n[i]=l,r=r|a,r===o&&_e(t,n)})}),function(s,i){switch(s){case Pr:{ya(t);return}case Bn:return r===o&&i(n),Je(t,i)}}}function Te(e,t=gf){return re(e,at(t))}function Sa(...e){return function(t,n){switch(t){case Pr:return;case Bn:return _y(...e.map(r=>Je(r,n)))}}}var qt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(qt||{});const $y={0:"debug",3:"error",1:"log",2:"warn"},Fy=()=>typeof globalThis>"u"?window:globalThis,zn=Ye(()=>{const e=ie(3);return{log:ie((t,n,r=1)=>{var o;const s=(o=Fy().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[$y[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function lr(e,t,n){return Ca(e,t,n).callbackRef}function Ca(e,t,n){const r=x.useRef(null);let o=i=>{};const s=x.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function By(e,t,n,r,o,s,i,a,l){const c=x.useCallback(d=>{const p=zy(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let b;f&&(b=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,v=i?a?i.scrollWidth:i.scrollHeight:f?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?b.innerWidth:b.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:v,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?vf("column-gap",getComputedStyle(d).columnGap,o):vf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Ca(c,n,l)}function zy(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},qt.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function vf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}function xf(e,t,n){const r=x.useRef(null),o=x.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),b=c.top-f.top;m=f.height-Math.max(0,b),p=b+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ca(o,!0,n),a=x.useCallback(()=>{o(i.current)},[o,i]);return x.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Bt=Ye(()=>{const e=We(),t=We(),n=ie(0),r=We(),o=ie(0),s=We(),i=We(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),p=We(),m=We(),f=ie(!1),b=ie(!1),g=ie(!1);return ve(re(e,fe(({scrollTop:v})=>v)),t),ve(re(e,fe(({scrollHeight:v})=>v)),i),ve(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),co={lvl:0};function bf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===co}function uo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?uo(e.l,t):uo(e.r,t)}function fn(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=fn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return fn(e.l,t,n)}function Qt(e,t,n){return ot(e)?Sf(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?Cf(Nt(e,{l:Qt(e.l,t,n)})):Cf(Nt(e,{r:Qt(e.r,t,n)}))}function Mr(){return co}function Cs(e,t,n){if(ot(e))return[];const r=fn(e,t)[0];return Hy(ka(e,r,n))}function Ta(e,t){if(ot(e))return co;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=yf(r);return Ts(Nt(e,{k:s,l:wf(r),v:i}))}}else return t<n?Ts(Nt(e,{l:Ta(r,t)})):Ts(Nt(e,{r:Ta(o,t)}))}function cr(e){return ot(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function ka(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ka(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ka(s,t,n))),a}function Ts(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(Ea(t))return Tf(Nt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return Nt(t.r,{l:Nt(t,{r:t.r.l}),lvl:n,r:Nt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ea(e))return Ia(Nt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=Ea(o)?r.lvl-1:r.lvl;return Nt(o,{l:Nt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ia(Nt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Nt(e,t){return Sf(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 wf(e){return ot(e.r)?e.l:Ts(Nt(e,{r:wf(e.r)}))}function Ea(e){return ot(e)||e.lvl>e.r.lvl}function yf(e){return ot(e.r)?[e.k,e.v]:yf(e.r)}function Sf(e,t,n,r=co,o=co){return{k:e,l:r,lvl:n,r:o,v:t}}function Cf(e){return Ia(Tf(e))}function Tf(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function Ia(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function Hy(e){return bf(e,({k:t,v:n})=>({index:t,value:n}))}function kf(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function fo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Na=Ye(()=>({recalcInProgress:ie(!1)}),[],{singleton:!0});function Ef(e,t,n){return e[ks(e,t,n)]}function ks(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 Uy(e,t,n,r){const o=ks(e,t,r),s=ks(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Es(e){return!ot(e.groupOffsetTree)}function Aa({index:e},t){return t===e?0:t<e?-1:1}function Wy(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function Vy(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=Qt(e,0,s);continue}const a=Cs(e,i-1,o+1);if(a.some(Zy(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Ta(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function Ky(e){return typeof e.groupIndex<"u"}function qy({offset:e},t){return t===e?0:t<e?-1:1}function po(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Ef(t,e,Aa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function If(e,t){if(!Es(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Nf(e,t,n){if(Ky(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=If(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Gy(e,t,n,r=0){return r>0&&(t=Math.max(t,Ef(e,r,Aa).offset)),bf(Uy(e,t,n,qy),Jy)}function Yy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,qt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((b,g)=>Qt(Qt(b,g,m),g+1,f),i)}else[i,a]=Vy(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=ja(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Qt(m,f,po(f,p,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function Xy(e){return cr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Af(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 ja(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ks(o,t-1,Aa),a=o[l].offset;const c=fn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===fn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Cs(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Jy(e){return{index:e.index,value:e}}function Zy(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 Qy={offsetHeight:"height",offsetWidth:"width"},yn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Ot(r,0),s=We(),i=We(),a=ie(0),l=ie([]),c=ie(void 0),d=ie(void 0),p=ie((T,S)=>Hn(T,Qy[S])),m=ie(void 0),f=ie(0),b=Wy(),g=Ot(re(n,De(l,e,f),wn(Yy,b),at()),b),v=Ot(re(l,at(),wn((T,S)=>({current:S,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);ve(re(l,ke(T=>T.length>0),De(g,f),fe(([T,S,k])=>{const A=T.reduce((j,B,$)=>Qt(j,B,po(B,S.offsetTree,k)||$),Mr());return{...S,groupIndices:T,groupOffsetTree:A}})),g),ve(re(r,De(g),ke(([T,{lastIndex:S}])=>T<S),fe(([T,{lastIndex:S,lastSize:k}])=>[{endIndex:S,size:k,startIndex:T}])),n),ve(c,d);const y=Ot(re(c,fe(T=>T===void 0)),!0);ve(re(d,ke(T=>T!==void 0&&ot(bt(g).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Zt(re(n,De(g),wn(({sizes:T},[S,k])=>({changed:k!==T,sizes:k}),{changed:!1,sizes:b}),fe(T=>T.changed)));Je(re(a,wn((T,S)=>({diff:T.prev-S,prev:S}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:S}=bt(g);if(T>0)_e(t,!0),_e(s,T+Af(T,S));else if(T<0){const k=bt(v);k.length>0&&(T-=Af(-T,k)),_e(i,T)}}),Je(re(a,De(e)),([T,S])=>{T<0&&S("`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},qt.ERROR)});const C=Zt(s);ve(re(s,De(g),fe(([T,S])=>{const k=S.groupIndices.length>0,A=[],j=S.lastSize;if(k){const B=uo(S.sizeTree,0);let $=0,z=0;for(;$<T;){const M=S.groupIndices[z],F=S.groupIndices.length===z+1?1/0:S.groupIndices[z+1]-M-1;A.push({endIndex:M,size:B,startIndex:M}),A.push({endIndex:M+1+F-1,size:j,startIndex:M+1}),z++,$+=F+1}const G=cr(S.sizeTree);return $!==T&&G.shift(),G.reduce((M,{k:F,v:V})=>{let K=M.ranges;return M.prevSize!==0&&(K=[...M.ranges,{endIndex:F+T-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:F+T,prevSize:V,ranges:K}},{prevIndex:T,prevSize:0,ranges:A}).ranges}return cr(S.sizeTree).reduce((B,{k:$,v:z})=>({prevIndex:$+T,prevSize:z,ranges:[...B.ranges,{endIndex:$+T-1,size:B.prevSize,startIndex:B.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=Zt(re(i,De(g,f),fe(([T,{offsetTree:S},k])=>{const A=-T;return po(A,S,k)})));return ve(re(i,De(g,f),fe(([T,S,k])=>{if(S.groupIndices.length>0){if(ot(S.sizeTree))return S;let A=Mr();const j=bt(v);let B=0,$=0,z=0;for(;B<-T;){z=j[$];const G=j[$+1]-z-1;$++,B+=G+1}if(A=cr(S.sizeTree).reduce((G,{k:M,v:F})=>Qt(G,Math.max(0,M+T),F),A),B!==-T){const G=uo(S.sizeTree,z);A=Qt(A,0,G);const M=fn(S.sizeTree,-T+1)[1];A=Qt(A,1,M)}return{...S,sizeTree:A,...ja(S.offsetTree,0,A,k)}}else{const A=cr(S.sizeTree).reduce((j,{k:B,v:$})=>Qt(j,Math.max(0,B+T),$),Mr());return{...S,sizeTree:A,...ja(S.offsetTree,0,A,k)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:w,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(zn,Na),{singleton:!0});function e0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const jf=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Zt(re(s,fe(e0)));return ve(re(a,fe(l=>l.totalCount)),n),ve(re(a,fe(l=>l.groupIndices)),e),ve(re(St(o,t,r),ke(([l,c])=>Es(c)),fe(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(yn,Bt)),Un=Ye(([{log:e}])=>{const t=ie(!1),n=Zt(re(t,ke(r=>r),at()));return Je(t,r=>{r&&bt(e)("props updated",{},qt.DEBUG)}),{didMount:n,propsReady:t}},it(zn),{singleton:!0}),t0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Pf(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!t0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ho=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=We(),b=We(),g=ie(0);let v=null,y=null,w=null;function C(){v&&(v(),v=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),_e(l,!1)}return ve(re(f,De(n,p,r,g,a,i,m),De(e,s,o),fe(([[E,T,S,k,A,j,B,$],z,G,M])=>{const F=Pf(E),{align:V,behavior:K,offset:R}=F,I=k-1,U=Nf(F,T,I);let J=po(U,T.offsetTree,z)+j;V==="end"?(J+=G+fn(T.sizeTree,U)[1]-S+M,U===I&&(J+=B)):V==="center"?J+=(G+fn(T.sizeTree,U)[1]-S+M)/2:J-=A,R&&(J+=R);const O=Y=>{C(),Y?($("retrying to scroll to",{location:E},qt.DEBUG),_e(f,E)):(_e(b,!0),$("list did not change, scroll successful",{},qt.DEBUG))};if(C(),K==="smooth"){let Y=!1;w=Je(t,L=>{Y=Y||L}),v=dn(d,()=>{O(Y)})}else v=dn(re(t,n0(150)),O);return y=setTimeout(()=>{C()},1200),_e(l,!0),$("scrolling from index to",{behavior:K,index:U,top:J},qt.DEBUG),{behavior:K,top:J}})),c),{scrollTargetReached:b,scrollToIndex:f,topListHeight:g}},it(yn,Bt,zn),{singleton:!0});function n0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Pa(e,t){e==0?t():requestAnimationFrame(()=>{Pa(e-1,t)})}function _a(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const mo=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=ie(!0),l=ie(0),c=ie(!0);return ve(re(i,De(l),ke(([d,p])=>!!p),bn(!1)),a),ve(re(i,De(l),ke(([d,p])=>!!p),bn(!1)),c),Je(re(St(t,i),De(a,n,e,c),ke(([[,d],p,{sizeTree:m},f,b])=>d&&(!ot(m)||wa(f))&&!p&&!b),De(l)),([,d])=>{dn(o,()=>{_e(c,!0)}),Pa(4,()=>{dn(r,()=>{_e(a,!0)}),_e(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(yn,Bt,ho,Un),{singleton:!0});function _f(e,t){return Math.abs(e-t)<1.01}const go="up",vo="down",r0="none",o0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},s0=0,xo=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=We(),c=We(),d=ie(4),p=ie(s0),m=Ot(re(Sa(re(Te(o),ar(1),bn(!0)),re(Te(o),ar(1),bn(!1),mf(100))),at()),!1),f=Ot(re(Sa(re(n,bn(!0)),re(n,bn(!1),mf(200))),at()),!1);ve(re(St(Te(o),Te(p)),fe(([w,C])=>w<=C),at()),a),ve(re(a,Nn(50)),c);const b=Zt(re(St(r,Te(s),Te(t),Te(e),Te(d)),wn((w,[{scrollHeight:C,scrollTop:E},T,S,k,A])=>{const j=E+T-C>-A,B={scrollHeight:C,scrollTop:E,viewportHeight:T};if(j){let z,G;return E>w.state.scrollTop?(z="SCROLLED_DOWN",G=w.state.scrollTop-E):(z="SIZE_DECREASED",G=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:G,state:B}}let $;return B.scrollHeight>w.state.scrollHeight?$="SIZE_INCREASED":T<w.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:B}},o0),at((w,C)=>w&&w.atBottom===C.atBottom))),g=Ot(re(r,wn((w,{scrollHeight:C,scrollTop:E,viewportHeight:T})=>{if(_f(w.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:E};{const S=C-(E+T)<1;return w.scrollTop!==E&&S?{changed:!0,jump:w.scrollTop-E,scrollHeight:C,scrollTop:E}:{changed:!0,jump:0,scrollHeight:C,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(w=>w.changed),fe(w=>w.jump)),0);ve(re(b,fe(w=>w.atBottom)),i),ve(re(i,Nn(50)),l);const v=ie(vo);ve(re(r,fe(({scrollTop:w})=>w),at(),wn((w,C)=>bt(f)?{direction:w.direction,prevScrollTop:C}:{direction:C<w.prevScrollTop?go:vo,prevScrollTop:C},{direction:vo,prevScrollTop:0}),fe(w=>w.direction)),v),ve(re(r,Nn(50),bn(r0)),v);const y=ie(0);return ve(re(m,ke(w=>!w),bn(0)),y),ve(re(o,Nn(100),De(m),ke(([w,C])=>!!C),wn(([w,C],[E])=>[C,E],[0,0]),fe(([w,C])=>C-w)),y),{atBottomState:b,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:v,scrollVelocity:y}},it(Bt)),Is="top",Ns="bottom",Mf="none";function Rf(e,t,n){return typeof e=="number"?n===go&&t===Is||n===vo&&t===Ns?e:0:n===go?t===Is?e.main:e.reverse:t===Ns?e.main:e.reverse}function Of(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ma=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=ie(0),a=ie(0),l=ie(0),c=Ot(re(St(Te(r),Te(o),Te(n),Te(s,fo),Te(l),Te(i),Te(t),Te(e),Te(a)),fe(([d,p,m,[f,b],g,v,y,w,C])=>{const E=d-w,T=v+y,S=Math.max(m-E,0);let k=Mf;const A=Of(C,Is),j=Of(C,Ns);return f-=w,f+=m+y,b+=m+y,b-=w,f>d+T-A&&(k=go),b<d-S+p+j&&(k=vo),k!==Mf?[Math.max(E-m-Rf(g,Is,k)-A,0),E-S-y+p+Rf(g,Ns,k)+j]:null}),ke(d=>d!=null),at(fo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Bt),{singleton:!0});function i0(e,t,n){if(Es(t)){const r=If(e,t);return[{index:fn(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 Ra={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function As(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,b=m-d;return{bottom:d,firstItemIndex:s,items:Lf(e,o,s),offsetBottom:b,offsetTop:c,top:f,topItems:Lf(t,o,s),topListHeight:t.reduce((g,v)=>v.size+g,0),totalCount:n}}function Df(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=_a(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return As(c,[],a,o,n,r)}function Lf(e,t,n){if(e.length===0)return[];if(!Es(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Cs(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ur=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:b}])=>{const g=ie([]),v=ie(0),y=We();ve(s.topItemsIndexes,g);const w=Ot(re(St(f,b,Te(l,fo),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),ke(([S,k,,A,,,,,,,j])=>{const B=j&&j.length!==A;return S&&!k&&!B}),fe(([,,[S,k],A,j,B,$,z,G,M,F])=>{const V=j,{offsetTree:K,sizeTree:R}=V,I=bt(v);if(A===0)return{...Ra,totalCount:A};if(S===0&&k===0)return I===0?{...Ra,totalCount:A}:Df(I,B,j,G,M,F||[]);if(ot(R))return I>0?null:As(i0(_a(B,A),V,F),[],A,M,V,G);const U=[];if(z.length>0){const D=z[0],X=z[z.length-1];let _=0;for(const P of Cs(R,D,X)){const W=P.value,Z=Math.max(P.start,D),se=Math.min(P.end,X);for(let ae=Z;ae<=se;ae++)U.push({data:F==null?void 0:F[ae],index:ae,offset:_,size:W}),_+=W}}if(!$)return As([],U,A,M,V,G);const J=z.length>0?z[z.length-1]+1:0,O=Gy(K,S,k,J);if(O.length===0)return null;const Y=A-1,L=Ss([],D=>{for(const X of O){const _=X.value;let P=_.offset,W=X.start;const Z=_.size;if(_.offset<S){W+=Math.floor((S-_.offset+M)/(Z+M));const ae=W-X.start;P+=ae*Z+ae*M}W<J&&(P+=(J-W)*Z,W=J);const se=Math.min(X.end,Y);for(let ae=W;ae<=se&&!(P>=k);ae++)D.push({data:F==null?void 0:F[ae],index:ae,offset:P,size:Z}),P+=Z+M}});return As(L,U,A,M,V,G)}),ke(S=>S!==null),at()),Ra);ve(re(e,ke(wa),fe(S=>S==null?void 0:S.length)),o),ve(re(w,fe(S=>S.topListHeight)),p),ve(p,a),ve(re(w,fe(S=>[S.top,S.bottom])),i),ve(re(w,fe(S=>S.items)),y);const C=Zt(re(w,ke(({items:S})=>S.length>0),De(o,e),ke(([{items:S},k])=>S[S.length-1].originalIndex===k-1),fe(([,S,k])=>[S-1,k]),at(fo),fe(([S])=>S))),E=Zt(re(w,Nn(200),ke(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),fe(({items:S})=>S[0].index),at())),T=Zt(re(w,ke(({items:S})=>S.length>0),fe(({items:S})=>{let k=0,A=S.length-1;for(;S[k].type==="group"&&k<A;)k++;for(;S[A].type==="group"&&A>k;)A--;return{endIndex:S[A].index,startIndex:S[k].index}}),at(kf)));return{endReached:C,initialItemCount:v,itemsRendered:y,listState:w,rangeChanged:T,startReached:E,topItemsIndexes:g,...m}},it(yn,jf,Ma,mo,ho,xo,Un,Na),{singleton:!0}),$f=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Ot(re(St(n,e,r,t,o),fe(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return ve(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Bt,ur),{singleton:!0}),a0=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=Ot(re(St(n,e,t),ke(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Nn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Bt,$f),{singleton:!0}),Ff=Ye(()=>({context:ie(null)})),l0=({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,Bf=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return ve(re(d,De(t,l,n,s,o,r,a),De(e),fe(([[p,m,f,b,g,v,y,w],C])=>{const{align:E,behavior:T,calculateViewLocation:S=l0,done:k,...A}=p,j=Nf(p,m,b-1),B=po(j,m.offsetTree,C)+g+v,$=B+fn(m.sizeTree,j)[1],z=w+v,G=w+f-y,M=S({itemBottom:$,itemTop:B,locationParams:{align:E,behavior:T,...A},viewportBottom:G,viewportTop:z});return M?k&&dn(re(i,ke(F=>!F),ar(bt(i)?1:2)),k):k&&k(),M}),ke(p=>p!==null)),c),{scrollIntoView:d}},it(yn,Bt,ho,ur,zn),{singleton:!0});function zf(e){return e?e==="smooth"?"smooth":"auto":!1}const c0=(e,t)=>typeof e=="function"?zf(e(t)):t&&zf(e),u0=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const b=ie(!1),g=We();let v=null;function y(T){_e(i,{align:"end",behavior:T,index:"LAST"})}Je(re(St(re(Te(t),ar(1)),l),De(Te(b),s,a,p),fe(([[T,S],k,A,j,B])=>{let $=S&&j,z="auto";return $&&(z=c0(k,A||B),$=$&&!!z),{followOutputBehavior:z,shouldFollow:$,totalCount:T}}),ke(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:S})=>{v&&(v(),v=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T)}):v=dn(e,()=>{bt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T),v=null})});function w(T){const S=dn(o,k=>{T&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!v&&(bt(d)("scrolling to bottom due to increased size",{},qt.DEBUG),y("auto"))});setTimeout(S,100)}Je(re(St(Te(b),t,c),ke(([T,,S])=>T&&S),wn(({value:T},[,S])=>({refreshed:T===S,value:S}),{refreshed:!1,value:0}),ke(({refreshed:T})=>T),De(b,t)),([,T])=>{bt(a)&&w(T!==!1)}),Je(g,()=>{w(bt(b)!==!1)}),Je(St(Te(b),o),([T,S])=>{T&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=ie(null),E=We();return ve(Sa(re(Te(r),fe(T=>{var S;return(S=T==null?void 0:T.length)!=null?S:0})),re(Te(t))),E),Je(re(St(re(E,ar(1)),l),De(Te(C),a,p,m),fe(([[T,S],k,A,j,B])=>S&&A&&(k==null?void 0:k({context:B,totalCount:T,scrollingInProgress:j}))),ke(T=>!!T),Nn(0)),T=>{v&&(v(),v=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),_e(f,T)}):v=dn(e,()=>{bt(d)("scrolling into view",{}),_e(f,T),v=null})}),{autoscrollToBottom:g,followOutput:b,scrollIntoViewOnChange:C}},it(yn,xo,ho,mo,Un,zn,Bt,Ff,Bf)),d0=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(re(a,De(s),ke(([,l])=>l!==0),De(o,r,t,n,e),fe(([[,l],c,d,p,m,f=[]])=>Df(l,c,d,p,m,f))),i),{}),it(yn,mo,ur,Un),{singleton:!0}),f0=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return Je(re(e,De(r),ke(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(re(n,ar(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{_e(t,o)})})}),{initialScrollTop:r}},it(Un,Bt,ur),{singleton:!0}),Hf=Ye(([{scrollVelocity:e}])=>{const t=ie(!1),n=We(),r=ie(!1);return ve(re(e,De(r,t,n),ke(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Je(re(St(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(xo),{singleton:!0}),Oa=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=ie(!1),i=ie(void 0);return ve(re(St(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ve(re(t,De(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Bt)),p0=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=ie(void 0),p=ie(null),m=ie(null);return ve(a,p),ve(l,m),Je(re(c,De(t,r,i,p,m,n)),([f,b,g,v,y,w,C])=>{const E=Xy(b.sizeTree);v&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=C,f({ranges:E,scrollTop:g})}),ve(re(d,ke(wa),fe(h0)),o),ve(re(s,De(d),ke(([,f])=>f!==void 0),at(),fe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(yn,Bt,mo,Un,Oa));function h0(e){return{align:"start",index:0,offset:e.scrollTop}}const m0=Ye(([{topItemsIndexes:e}])=>{const t=ie(0);return ve(re(t,ke(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ur));function Uf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const g0=Uf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),v0=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:b}])=>{const g=Zt(re(l,De(i),wn(([,y,w,C],[{bottom:E,items:T,offsetBottom:S,totalCount:k},A])=>{const j=E+S;let B=0;return w===k&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||(B=j-C,B!==0&&(B+=A))),[B,T,k,j]},[0,[],0,0]),ke(([y])=>y!==0),De(r,a,n,o,f,b),ke(([,y,w,C,,,E])=>!E&&!C&&y!==0&&w===go),fe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},qt.DEBUG),y))));function v(y){y>0?(_e(t,{behavior:"auto",top:-y}),_e(e,0)):(_e(e,0),_e(t,{behavior:"auto",top:-y}))}return Je(re(g,De(e,s)),([y,w,C])=>{C&&g0()?_e(e,w-y):v(-y)}),Je(re(St(Ot(s,!1),e,b),ke(([y,w,C])=>!y&&!C&&w!==0),fe(([y,w])=>w),Nn(1)),v),ve(re(p,fe(y=>({top:-y}))),t),Je(re(c,De(m,d),fe(([y,{groupIndices:w,lastSize:C,sizeTree:E},T])=>{function S(k){return k*(C+T)}if(w.length===0)return S(y);{let k=0;const A=uo(E,0);let j=0,B=0;for(;j<y;){j++,k+=A;let $=w.length===B+1?1/0:w[B+1]-w[B]-1;j+$>y&&(k-=A,$=y-j+1),j+=$,k+=S($),B++}return k}})),y=>{_e(e,y),requestAnimationFrame(()=>{_e(t,{top:y}),requestAnimationFrame(()=>{_e(e,0),_e(b,!1)})})}),{deviation:e}},it(Bt,xo,ur,yn,zn,Na)),x0=Ye(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it(Ma,d0,Un,Hf,$f,f0,a0,Oa,Bf,zn,Ff)),Wf=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:b},g,v,y,{listState:w,topItemsIndexes:C,...E},{scrollToIndex:T},S,{topItemCount:k},{groupCounts:A},j])=>(ve(E.rangeChanged,j.scrollSeekRangeChanged),ve(re(j.windowViewportRect,fe(B=>B.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:b,sizeRanges:a,topItemCount:k,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:p,...E,...j,...g,sizes:l,...v}),it(yn,mo,Bt,p0,u0,ur,ho,v0,m0,jf,x0));function b0(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 js=typeof document<"u"?x.useLayoutEffect:x.useEffect;function Vf(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=x.createContext({});function l(v,y){v.propsReady&&_e(v.propsReady,!1);for(const w of r){const C=v[t.required[w]];_e(C,y[w])}for(const w of o)if(w in y){const C=v[t.optional[w]];_e(C,y[w])}v.propsReady&&_e(v.propsReady,!0)}function c(v){return s.reduce((y,w)=>(y[w]=C=>{const E=v[t.methods[w]];_e(E,C)},y),{})}function d(v){return i.reduce((y,w)=>(y[w]=Oy(v[t.events[w]]),y),{})}const p=x.forwardRef((v,y)=>{const{children:w,...C}=v,[E]=x.useState(()=>Ss(Ly(e),k=>{l(k,C)})),[T]=x.useState(hf(d,E));js(()=>{for(const k of i)k in C&&Je(T[k],C[k]);return()=>{Object.values(T).map(ya)}},[C,T,E]),js(()=>{l(E,C)}),x.useImperativeHandle(y,ff(c(E)));const S=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(S,{...b0([...r,...o,...i],C),children:w}):w})}),m=v=>{const y=x.useContext(a);return x.useCallback(w=>{_e(y[v],w)},[y,v])},f=v=>{const y=x.useContext(a)[v],w=x.useCallback(C=>Je(y,C),[y]);return x.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},b=v=>{const y=x.useContext(a)[v],[w,C]=x.useState(hf(bt,y));return js(()=>Je(y,E=>{E!==w&&C(ff(E))}),[y,w]),w},g=x.version.startsWith("18")?f:b;return{Component:p,useEmitter:(v,y)=>{const w=x.useContext(a)[v];js(()=>Je(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Kf=x.createContext(void 0),qf=x.createContext(void 0),Gf=typeof document<"u"?x.useLayoutEffect:x.useEffect;function Da(e){return"self"in e}function w0(e){return"body"in e}function Yf(e,t,n,r=_r,o,s){const i=x.useRef(null),a=x.useRef(null),l=x.useRef(null),c=x.useCallback(m=>{let f,b,g;const v=m.target;if(w0(v)||Da(v)){const w=Da(v)?v:v.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=s?w.innerWidth:w.innerHeight}else g=s?v.scrollLeft:v.scrollTop,f=s?v.scrollWidth:v.scrollHeight,b=s?v.offsetWidth:v.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:b})};m.suppressFlushSync?y():Oo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-b)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);x.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const b=m.behavior==="smooth";let g,v,y;Da(f)?(v=Math.max(Hn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(v=f[s?"scrollWidth":"scrollHeight"],g=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=v-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),_f(g,v)||m.top===y){e({scrollHeight:v,scrollTop:y,viewportHeight:g}),b&&t(!0);return}b?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const La="-webkit-sticky",Xf="sticky",$a=Uf(()=>{if(typeof document>"u")return Xf;const e=document.createElement("div");return e.style.position=La,e.style.position===La?La:Xf});function Fa(e){return e}const y0=Ye(()=>{const e=ie(a=>`Item ${a}`),t=ie(a=>`Group ${a}`),n=ie({}),r=ie(Fa),o=ie("div"),s=ie(_r),i=(a,l=null)=>Ot(re(n,fe(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),S0=Ye(([e,t])=>({...e,...t}),it(Wf,y0)),C0=({height:e})=>u.jsx("div",{style:{height:e}}),T0={overflowAnchor:"none",position:$a(),zIndex:1},Jf={overflowAnchor:"none"},k0={...Jf,display:"inline-block",height:"100%"},Zf=x.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=rn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),p=Ne("trackItemSizes"),m=Ne("itemSize"),f=Ne("log"),b=rn("gap"),g=Ne("horizontalDirection"),{callbackRef:v}=By(n,m,p,e?_r:a,f,b,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,w]=x.useState(0);Ba("deviation",M=>{y!==M&&w(M)});const C=Ne("EmptyPlaceholder"),E=Ne("ScrollSeekPlaceholder")||C0,T=Ne("ListComponent"),S=Ne("ItemComponent"),k=Ne("GroupComponent"),A=Ne("computeItemKey"),j=Ne("isSeeking"),B=Ne("groupIndices").length>0,$=Ne("alignToBottom"),z=Ne("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:$?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:$?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Dt(C,c)}):u.jsx(T,{...Dt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:v,style:G,children:(e?t.topItems:t.items).map(M=>{const F=M.originalIndex,V=A(F+t.firstItemIndex,M.data,c);return j?x.createElement(E,{...Dt(E,c),height:M.size,index:M.index,key:V,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?x.createElement(k,{...Dt(k,c),"data-index":F,"data-item-index":M.index,"data-known-size":M.size,key:V,style:T0},d(M.index,c)):x.createElement(S,{...Dt(S,c),...A0(S,M.data),"data-index":F,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:V,style:g?k0:Jf},B?l(M.index,M.groupIndex,M.data,c):l(M.index,M.data,c))})})}),E0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},I0={outline:"none",overflowX:"auto",position:"relative"},Ps=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),N0={position:$a(),top:0,width:"100%",zIndex:1};function Dt(e,t){if(typeof e!="string")return{context:t}}function A0(e,t){return{item:typeof e=="string"?void 0:t}}const j0=x.memo(function(){const e=Ne("HeaderComponent"),t=rn("headerHeight"),n=Ne("HeaderFooterTag"),r=lr(x.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),P0=x.memo(function(){const e=Ne("FooterComponent"),t=rn("footerHeight"),n=Ne("HeaderFooterTag"),r=lr(x.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null});function Qf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:b}=Yf(a,c,l,d,void 0,p);return e("scrollTo",b),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?I0:E0,...o},tabIndex:0,...i,...Dt(l,s),children:r})})}function ep({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=x.useRef(null),b=t("scrollerRef"),{scrollByCallback:g,scrollerRef:v,scrollToCallback:y}=Yf(a,c,l,b,m);return Gf(()=>{var w;return v.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{v.current=null}},[v,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...Dt(l,s),children:r})})}const _0=({children:e})=>{const t=x.useContext(Kf),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=x.useMemo(()=>pf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=lr(i,!0,Ne("skipAnimationFrameInResizeObserver"));return x.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ps(o),children:e})},M0=({children:e})=>{const t=x.useContext(Kf),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ne("customScrollParent"),s=xf(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("alignToBottom");return x.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Ps(i),children:e})},R0=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...N0,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...Dt(t,o),children:e})},O0=x.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?$0:L0,{...e,context:o,children:[n&&u.jsx(R0,{children:u.jsx(Zf,{showTopList:!0})}),u.jsxs(r||t?M0:_0,{children:[u.jsx(j0,{}),u.jsx(Zf,{}),u.jsx(P0,{})]})]})}),{Component:D0,useEmitter:Ba,useEmitterValue:Ne,usePublisher:rn}=Vf(S0,{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"}},O0),L0=Qf({useEmitter:Ba,useEmitterValue:Ne,usePublisher:rn}),$0=ep({useEmitter:Ba,useEmitterValue:Ne,usePublisher:rn}),F0=D0;it(Wf,Ye(()=>{const e=ie(c=>u.jsxs("td",{children:["Item $",c]})),t=ie(null),n=ie(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ie(null),o=ie(null),s=ie({}),i=ie(Fa),a=ie(_r),l=(c,d=null)=>Ot(re(s,fe(p=>p[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),$a();const tp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},B0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:np,floor:_s,max:bo,min:za,round:rp}=Math;function op(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function z0(e){return{...B0,items:e}}function Ms(e,t){return e&&e.width===t.width&&e.height===t.height}function H0(e,t){return e&&e.column===t.column&&e.row===t.row}const U0=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:b,propsReady:g},{customScrollParent:v,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E},T])=>{const S=ie(0),k=ie(0),A=ie(tp),j=ie({height:0,width:0}),B=ie({height:0,width:0}),$=We(),z=We(),G=ie(0),M=ie(null),F=ie({column:0,row:0}),V=We(),K=We(),R=ie(!1),I=ie(0),U=ie(!0),J=ie(!1),O=ie(!1);Je(re(b,De(I),ke(([P,W])=>!!W)),()=>{_e(U,!1)}),Je(re(St(b,U,B,j,I,J),ke(([P,W,Z,se,,ae])=>P&&!W&&Z.height!==0&&se.height!==0&&!ae)),([,,,,P])=>{_e(J,!0),Pa(1,()=>{_e($,P)}),dn(re(c),()=>{_e(t,[0,0]),_e(U,!0)})}),ve(re(K,ke(P=>P!=null&&P.scrollTop>0),bn(0)),k),Je(re(b,De(K),ke(([,P])=>P!=null)),([,P])=>{P&&(_e(j,P.viewport),_e(B,P.item),_e(F,P.gap),P.scrollTop>0&&(_e(R,!0),dn(re(c,ar(1)),W=>{_e(R,!1)}),_e(l,{top:P.scrollTop})))}),ve(re(j,fe(({height:P})=>P)),p),ve(re(St(Te(j,Ms),Te(B,Ms),Te(F,(P,W)=>P&&P.column===W.column&&P.row===W.row),Te(c)),fe(([P,W,Z,se])=>({gap:Z,item:W,scrollTop:se,viewport:P}))),V),ve(re(St(Te(S),r,Te(F,H0),Te(B,Ms),Te(j,Ms),Te(M),Te(k),Te(R),Te(U),Te(I)),ke(([,,,,,,,P])=>!P),fe(([P,[W,Z],se,ae,Se,Ce,Oe,,Fe,Be])=>{const{column:Ke,row:ze}=se,{height:dt,width:pt}=ae,{width:Ze}=Se;if(Oe===0&&(P===0||Ze===0))return tp;if(pt===0){const Tt=_a(Be,P),ht=Tt+Math.max(Oe-1,0);return z0(op(Tt,ht,Ce))}const He=sp(Ze,pt,Ke);let Me,qe;Fe?W===0&&Z===0&&Oe>0?(Me=0,qe=Oe-1):(Me=He*_s((W+ze)/(dt+ze)),qe=He*np((Z+ze)/(dt+ze))-1,qe=za(P-1,bo(qe,He-1)),Me=za(qe,bo(0,Me))):(Me=0,qe=-1);const Ae=op(Me,qe,Ce),{bottom:Ge,top:Xe}=ip(Se,se,ae,Ae),Ct=np(P/He),Qe=Ct*dt+(Ct-1)*ze-Ge;return{bottom:Ge,itemHeight:dt,items:Ae,itemWidth:pt,offsetBottom:Qe,offsetTop:Xe,top:Xe}})),A),ve(re(M,ke(P=>P!==null),fe(P=>P.length)),S),ve(re(St(j,B,A,F),ke(([P,W,{items:Z}])=>Z.length>0&&W.height!==0&&P.height!==0),fe(([P,W,{items:Z},se])=>{const{bottom:ae,top:Se}=ip(P,se,W,Z);return[Se,ae]}),at(fo)),t);const Y=ie(!1);ve(re(c,De(Y),fe(([P,W])=>W||P!==0)),Y);const L=Zt(re(St(A,S),ke(([{items:P}])=>P.length>0),De(Y),ke(([[P,W],Z])=>{const se=P.items[P.items.length-1].index===W-1;return(Z||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===W)&&se}),fe(([[,P]])=>P-1),at())),D=Zt(re(Te(A),ke(({items:P})=>P.length>0&&P[0].index===0),bn(0),at())),X=Zt(re(Te(A),De(R),ke(([{items:P},W])=>P.length>0&&!W),fe(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),at(kf),Nn(0)));ve(X,f.scrollSeekRangeChanged),ve(re($,De(j,B,S,F),fe(([P,W,Z,se,ae])=>{const Se=Pf(P),{align:Ce,behavior:Oe,offset:Fe}=Se;let Be=Se.index;Be==="LAST"&&(Be=se-1),Be=bo(0,Be,za(se-1,Be));let Ke=Ha(W,ae,Z,Be);return Ce==="end"?Ke=rp(Ke-W.height+Z.height):Ce==="center"&&(Ke=rp(Ke-W.height/2+Z.height/2)),Fe&&(Ke+=Fe),{behavior:Oe,top:Ke}})),l);const _=Ot(re(A,fe(P=>P.offsetBottom+P.bottom)),0);return ve(re(E,fe(P=>({height:P.visibleHeight,width:P.visibleWidth}))),j),{customScrollParent:v,data:M,deviation:G,footerHeight:o,gap:F,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:B,overscan:n,restoreStateFrom:K,scrollBy:i,scrollContainerState:a,scrollHeight:z,scrollTo:l,scrollToIndex:$,scrollTop:c,smoothScrollTargetReached:d,totalCount:S,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E,...f,gridState:A,horizontalDirection:O,initialTopMostItemIndex:I,totalListHeight:_,...m,endReached:L,propsReady:g,rangeChanged:X,startReached:D,stateChanged:V,stateRestoreInProgress:R,...T}},it(Ma,Bt,xo,Hf,Un,Oa,zn));function sp(e,t,n){return bo(1,_s((e+n)/(_s(t)+n)))}function ip(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ha(e,t,n,r[0].index);return{bottom:Ha(e,t,n,r[r.length-1].index)+o,top:s}}function Ha(e,t,n,r){const o=sp(e.width,n.width,t.column),s=_s(r/o),i=s*n.height+bo(0,s-1)*t.row;return i>0?i+t.row:i}const W0=Ye(()=>{const e=ie(p=>`Item ${p}`),t=ie({}),n=ie(null),r=ie("virtuoso-grid-item"),o=ie("virtuoso-grid-list"),s=ie(Fa),i=ie("div"),a=ie(_r),l=(p,m=null)=>Ot(re(t,fe(f=>f[p]),at()),m),c=ie(!1),d=ie(!1);return ve(Te(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),V0=Ye(([e,t])=>({...e,...t}),it(U0,W0)),K0=x.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=on("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),c=lt("ScrollSeekPlaceholder"),d=lt("context"),p=on("itemDimensions"),m=on("gap"),f=lt("log"),b=lt("stateRestoreInProgress"),g=on("reportReadyState"),v=lr(x.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const C=y.firstChild;if(C){const{height:E,width:T}=C.getBoundingClientRect();p({height:E,width:T})}m({column:lp("column-gap",getComputedStyle(y).columnGap,f),row:lp("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Gf(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),b?null:u.jsx(l,{className:t,ref:v,...Dt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...Dt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):x.createElement(a,{...Dt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),q0=x.memo(function(){const e=lt("HeaderComponent"),t=on("headerHeight"),n=lt("headerFooterTag"),r=lr(x.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),G0=x.memo(function(){const e=lt("FooterComponent"),t=on("footerHeight"),n=lt("headerFooterTag"),r=lr(x.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),Y0=({children:e})=>{const t=x.useContext(qf),n=on("itemDimensions"),r=on("viewportDimensions"),o=lr(x.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return x.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Ps(!1),children:e})},X0=({children:e})=>{const t=x.useContext(qf),n=on("windowViewportRect"),r=on("itemDimensions"),o=lt("customScrollParent"),s=xf(n,o,!1);return x.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Ps(!1),children:e})},J0=x.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?Q0:Z0,o=n||t?X0:Y0,s=lt("context");return u.jsx(r,{...e,...Dt(r,s),children:u.jsxs(o,{children:[u.jsx(q0,{}),u.jsx(K0,{}),u.jsx(G0,{})]})})}),{useEmitter:ap,useEmitterValue:lt,usePublisher:on}=Vf(V0,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},J0),Z0=Qf({useEmitter:ap,useEmitterValue:lt,usePublisher:on}),Q0=ep({useEmitter:ap,useEmitterValue:lt,usePublisher:on});function lp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}const eS={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},Ua=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Wa=x.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s=0,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,showToolMessages:m,checkpointIndex:f,onSelectCheckpoint:b,getMessageCustomStyles:g,getInterruptOptions:v,toolConfig:y}){const w=Ua(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming||o===t.id&&t.role==="assistant",k=f??eS,A=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:j,attemptIndex:B,attempts:$}=x.useMemo(()=>dc(t.id,A,k),[t.id,A,k]),z=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":w,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ws,{message:t,messageIndex:n,isStreamingMessage:S,renderStreamingMarkdown:S,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,getInterruptOptions:v,showToolMessages:m,attemptCount:j,attemptIndex:B,attemptMetas:$,onSelectCheckpoint:b,customStyles:z,toolConfig:y})})});Wa.displayName="MessageRow";const Va=x.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r=0,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:b=!0,isNavigatingCheckpoint:g=!1,onScrollAway:v,onAtBottom:y,showToolMessages:w=!0,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,createSyntheticThinkingMessage:k=!0,forceSyntheticThinking:A=!1,getMessageCustomStyles:j,getInterruptOptions:B},$)=>{const z=x.useRef(null),G=x.useRef(null),M=x.useRef(!1),F=x.useRef(!1),V=e,K=x.useMemo(()=>{const _=n&&V.some(W=>W.id===n);return k&&(t||A)&&!_&&V.length>0?[...V,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:V},[V,t,n,k,A]),R=x.useMemo(()=>w?K:K.filter(_=>(_==null?void 0:_.role)!=="tool"),[K,w]),I=x.useCallback(_=>{v&&v(!_),y&&y(_)},[v,y]),U=x.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),J=x.useMemo(()=>!b||g?!1:"auto",[b,g]),O=x.useMemo(()=>{if(typeof f!="string")return null;const _=f.trim();return!_||R&&R.length>0?null:{id:"default-message",role:"default_message",content:_,createdAt:new Date().toISOString()}},[f,R]),Y=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),L=()=>{if(O){const _=j==null?void 0:j(O);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ws,{message:O,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:_,getInterruptOptions:B})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"})},D=R.length,X=D>0;return x.useEffect(()=>{var _,P;if(D===0){F.current=!1;return}if(!F.current)if(F.current=!0,z.current&&R.length>0){const W=R.length-1;(P=(_=z.current).scrollToIndex)==null||P.call(_,{index:W,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},[D,R.length]),x.useImperativeHandle($,()=>({scrollToLatest:()=>{var _,P;if(z.current&&R.length>0){const W=R.length-1;(P=(_=z.current).scrollToIndex)==null||P.call(_,{index:W,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},scrollToTop:()=>{var _,P;z.current&&R.length>0?(P=(_=z.current).scrollToIndex)==null||P.call(_,{index:0,align:"start",behavior:"auto"}):G.current&&(G.current.scrollTop=0)}}),[R]),u.jsx("div",{className:Y,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:X?u.jsx(F0,{ref:_=>{z.current=_},scrollerRef:_=>{G.current=_ instanceof HTMLDivElement?_:null},data:R,followOutput:J,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{U&&U()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(_,P)=>Ua(P,_),itemContent:(_,P)=>u.jsx(Wa,{message:P,index:_,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:w,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,getMessageCustomStyles:j,getInterruptOptions:B})}):L()})})});Va.displayName="MessageList";function cp({message:e,viewMode:t,isStreaming:n=!1,toolConfig:r,expandable:o=!1}){var B;const s=Go(e),i=e.artifact??null,a=uf(e),c=(a?Eu(a):null)??a,d=e.content.find($=>$.type!=="tool_call"),p=$=>{if($==null)return null;const z=typeof $=="string"?er($)??$:$;if(z&&typeof z=="object")return u.jsx(xs,{data:z});const G=typeof z=="string"?z:(()=>{try{return tr(z)}catch{return String(z??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:G})},m=$=>{if($==null)return null;const{content:z,isMarkdown:G}=xu($);return G?u.jsx(ir,{content:z,className:"text-current"}):p($)},f=$=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(xs,{data:$})]}),b=()=>{if((c==null?void 0:c.kind)==="generic")return m(c.value);if(!d)return null;if(d.type==="text"){const M=(d.text??"").trim();if(!M)return null;const F=nr(M);return m(F)}const $=Sr(d),z=nr($);return m(z)},g=()=>(c==null?void 0:c.kind)==="dict"?f(c.data):b(),v=()=>{if(!y)return;if(s.name){const z=y[s.name];if(z)return z}const $=(c==null?void 0:c.kind)??(a==null?void 0:a.kind);if($){const z=y[$];if(z)return z}return y.default},{toolRenderers:y,toolArtifactRenderers:w}=r??{},C=v(),E=g(),T=!o||t==="expanded",S=(T?C==null?void 0:C({message:e,toolMeta:s,toolPayload:c,viewMode:t,isStreaming:n}):null)??null,A=((B=(()=>{if(!w)return;const $=i==null?void 0:i.type;if(typeof $=="string"){const z=w[$];if(z)return z}return w.default})())==null?void 0:B({artifact:i,message:e,toolPayload:c,isStreaming:n}))??null,j=S??E;return u.jsxs("div",{className:"space-y-2",children:[i&&(A??u.jsx(Zd,{artifact:i,idx:0})),u.jsx(Qd,{message:e,isStreaming:n}),T?j:null]})}function Rs(e){const t=e+"CollectionProvider",[n,r]=nn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:v,children:y}=g,w=x.useRef(null),C=x.useRef(new Map).current;return u.jsx(o,{scope:v,itemMap:C,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Jt.createSlot(a),c=x.forwardRef((g,v)=>{const{scope:y,children:w}=g,C=s(a,y),E=Re(v,C.collectionRef);return u.jsx(l,{ref:E,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Jt.createSlot(d),f=x.forwardRef((g,v)=>{const{scope:y,children:w,...C}=g,E=x.useRef(null),T=Re(v,E),S=s(d,y);return x.useEffect(()=>(S.itemMap.set(E,{ref:E,...C}),()=>void S.itemMap.delete(E))),u.jsx(m,{[p]:"",ref:T,children:w})});f.displayName=d;function b(g){const v=s(e+"CollectionConsumer",g);return x.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((S,k)=>C.indexOf(S.ref.current)-C.indexOf(k.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},b,r]}var tS=h.createContext(void 0);function Os(e){const t=h.useContext(tS);return e||t||"ltr"}const nS=["top","right","bottom","left"],Wn=Math.min,en=Math.max,Ds=Math.round,Ls=Math.floor,Sn=e=>({x:e,y:e}),rS={left:"right",right:"left",bottom:"top",top:"bottom"},oS={start:"end",end:"start"};function Ka(e,t,n){return en(e,Wn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Rr(e){return e.split("-")[1]}function qa(e){return e==="x"?"y":"x"}function Ga(e){return e==="y"?"height":"width"}const sS=new Set(["top","bottom"]);function Cn(e){return sS.has(jn(e))?"y":"x"}function Ya(e){return qa(Cn(e))}function iS(e,t,n){n===void 0&&(n=!1);const r=Rr(e),o=Ya(e),s=Ga(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=$s(i)),[i,$s(i)]}function aS(e){const t=$s(e);return[Xa(e),t,Xa(t)]}function Xa(e){return e.replace(/start|end/g,t=>oS[t])}const up=["left","right"],dp=["right","left"],lS=["top","bottom"],cS=["bottom","top"];function uS(e,t,n){switch(e){case"top":case"bottom":return n?t?dp:up:t?up:dp;case"left":case"right":return t?lS:cS;default:return[]}}function dS(e,t,n,r){const o=Rr(e);let s=uS(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Xa)))),s}function $s(e){return e.replace(/left|right|bottom|top/g,t=>rS[t])}function fS(e){return{top:0,right:0,bottom:0,left:0,...e}}function fp(e){return typeof e!="number"?fS(e):{top:e,right:e,bottom:e,left:e}}function Fs(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 pp(e,t,n){let{reference:r,floating:o}=e;const s=Cn(t),i=Ya(t),a=Ga(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(Rr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const pS=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=pp(c,r,l),m=r,f={},b=0;for(let g=0;g<a.length;g++){const{name:v,fn:y}=a[g],{x:w,y:C,data:E,reset:T}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,p=C??p,f={...f,[v]:{...f[v],...E}},T&&b<=50&&(b++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:p}=pp(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function wo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),b=fp(f),v=a[m?p==="floating"?"reference":"floating":p],y=Fs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},T=Fs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:l}):w);return{top:(y.top-T.top+b.top)/E.y,bottom:(T.bottom-y.bottom+b.bottom)/E.y,left:(y.left-T.left+b.left)/E.x,right:(T.right-y.right+b.right)/E.x}}const hS=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const p=fp(d),m={x:n,y:r},f=Ya(o),b=Ga(f),g=await i.getDimensions(c),v=f==="y",y=v?"top":"left",w=v?"bottom":"right",C=v?"clientHeight":"clientWidth",E=s.reference[b]+s.reference[f]-m[f]-s.floating[b],T=m[f]-s.reference[f],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let k=S?S[C]:0;(!k||!await(i.isElement==null?void 0:i.isElement(S)))&&(k=a.floating[C]||s.floating[b]);const A=E/2-T/2,j=k/2-g[b]/2-1,B=Wn(p[y],j),$=Wn(p[w],j),z=B,G=k-g[b]-$,M=k/2-g[b]/2+A,F=Ka(z,M,G),V=!l.arrow&&Rr(o)!=null&&M!==F&&s.reference[b]/2-(M<z?B:$)-g[b]/2<0,K=V?M<z?M-z:M-G:0;return{[f]:m[f]+K,data:{[f]:F,centerOffset:M-F-K,...V&&{alignmentOffset:K}},reset:V}}}),mS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:g=!0,...v}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=Cn(a),C=jn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=m||(C||!g?[$s(a)]:aS(a)),S=b!=="none";!m&&S&&T.push(...dS(a,g,b,E));const k=[a,...T],A=await wo(t,v),j=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),p){const M=iS(o,i,E);j.push(A[M[0]],A[M[1]])}if(B=[...B,{placement:o,overflows:j}],!j.every(M=>M<=0)){var $,z;const M=((($=s.flip)==null?void 0:$.index)||0)+1,F=k[M];if(F&&(!(p==="alignment"?w!==Cn(F):!1)||B.every(R=>Cn(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:M,overflows:B},reset:{placement:F}};let V=(z=B.filter(K=>K.overflows[0]<=0).sort((K,R)=>K.overflows[1]-R.overflows[1])[0])==null?void 0:z.placement;if(!V)switch(f){case"bestFit":{var G;const K=(G=B.filter(R=>{if(S){const I=Cn(R.placement);return I===w||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,U)=>I+U,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:G[0];K&&(V=K);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function hp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function mp(e){return nS.some(t=>e[t]>=0)}const gS=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await wo(t,{...o,elementContext:"reference"}),i=hp(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:mp(i)}}}case"escaped":{const s=await wo(t,{...o,altBoundary:!0}),i=hp(s,n.floating);return{data:{escapedOffsets:i,escaped:mp(i)}}}default:return{}}}}},gp=new Set(["left","top"]);async function vS(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=Rr(n),l=Cn(n)==="y",c=gp.has(i)?-1:1,d=s&&l?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:b}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof b=="number"&&(f=a==="end"?b*-1:b),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const xS=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await vS(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},bS=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:v=>{let{x:y,y:w}=v;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await wo(t,l),p=Cn(jn(o)),m=qa(p);let f=c[m],b=c[p];if(s){const v=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[v],C=f-d[y];f=Ka(w,f,C)}if(i){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",w=b+d[v],C=b-d[y];b=Ka(w,b,C)}const g=a.fn({...t,[m]:f,[p]:b});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},wS=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},p=Cn(o),m=qa(p);let f=d[m],b=d[p];const g=An(a,t),v=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",E=s.reference[m]-s.floating[C]+v.mainAxis,T=s.reference[m]+s.reference[C]-v.mainAxis;f<E?f=E:f>T&&(f=T)}if(c){var y,w;const C=m==="y"?"width":"height",E=gp.has(jn(o)),T=s.reference[p]-s.floating[C]+(E&&((y=i.offset)==null?void 0:y[p])||0)+(E?0:v.crossAxis),S=s.reference[p]+s.reference[C]+(E?0:((w=i.offset)==null?void 0:w[p])||0)-(E?v.crossAxis:0);b<T?b=T:b>S&&(b=S)}return{[m]:f,[p]:b}}}},yS=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await wo(t,c),p=jn(o),m=Rr(o),f=Cn(o)==="y",{width:b,height:g}=s.floating;let v,y;p==="top"||p==="bottom"?(v=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,v=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,C=b-d.left-d.right,E=Wn(g-d[v],w),T=Wn(b-d[y],C),S=!t.middlewareData.shift;let k=E,A=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),S&&!m){const B=en(d.left,0),$=en(d.right,0),z=en(d.top,0),G=en(d.bottom,0);f?A=b-2*(B!==0||$!==0?B+$:en(d.left,d.right)):k=g-2*(z!==0||G!==0?z+G:en(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:k});const j=await i.getDimensions(a.floating);return b!==j.width||g!==j.height?{reset:{rects:!0}}:{}}}};function Bs(){return typeof window<"u"}function Or(e){return vp(e)?(e.nodeName||"").toLowerCase():"#document"}function tn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Tn(e){var t;return(t=(vp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vp(e){return Bs()?e instanceof Node||e instanceof tn(e).Node:!1}function pn(e){return Bs()?e instanceof Element||e instanceof tn(e).Element:!1}function kn(e){return Bs()?e instanceof HTMLElement||e instanceof tn(e).HTMLElement:!1}function xp(e){return!Bs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof tn(e).ShadowRoot}const SS=new Set(["inline","contents"]);function yo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=hn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!SS.has(o)}const CS=new Set(["table","td","th"]);function TS(e){return CS.has(Or(e))}const kS=[":popover-open",":modal"];function zs(e){return kS.some(t=>{try{return e.matches(t)}catch{return!1}})}const ES=["transform","translate","scale","rotate","perspective"],IS=["transform","translate","scale","rotate","perspective","filter"],NS=["paint","layout","strict","content"];function Ja(e){const t=Za(),n=pn(e)?hn(e):e;return ES.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)||IS.some(r=>(n.willChange||"").includes(r))||NS.some(r=>(n.contain||"").includes(r))}function AS(e){let t=Vn(e);for(;kn(t)&&!Dr(t);){if(Ja(t))return t;if(zs(t))return null;t=Vn(t)}return null}function Za(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jS=new Set(["html","body","#document"]);function Dr(e){return jS.has(Or(e))}function hn(e){return tn(e).getComputedStyle(e)}function Hs(e){return pn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vn(e){if(Or(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xp(e)&&e.host||Tn(e);return xp(t)?t.host:t}function bp(e){const t=Vn(e);return Dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:kn(t)&&yo(t)?t:bp(t)}function So(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=bp(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=tn(o);if(s){const a=Qa(i);return t.concat(i,i.visualViewport||[],yo(o)?o:[],a&&n?So(a):[])}return t.concat(o,So(o,[],n))}function Qa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wp(e){const t=hn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=kn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ds(n)!==s||Ds(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function el(e){return pn(e)?e:e.contextElement}function Lr(e){const t=el(e);if(!kn(t))return Sn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=wp(t);let i=(s?Ds(n.width):n.width)/r,a=(s?Ds(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const PS=Sn(0);function yp(e){const t=tn(e);return!Za()||!t.visualViewport?PS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _S(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==tn(e)?!1:t}function dr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=el(e);let i=Sn(1);t&&(r?pn(r)&&(i=Lr(r)):i=Lr(e));const a=_S(s,n,r)?yp(s):Sn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=tn(s),f=r&&pn(r)?tn(r):r;let b=m,g=Qa(b);for(;g&&r&&f!==b;){const v=Lr(g),y=g.getBoundingClientRect(),w=hn(g),C=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*v.x,E=y.top+(g.clientTop+parseFloat(w.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,p*=v.y,l+=C,c+=E,b=tn(g),g=Qa(b)}}return Fs({width:d,height:p,x:l,y:c})}function Us(e,t){const n=Hs(e).scrollLeft;return t?t.left+n:dr(Tn(e)).left+n}function Sp(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function MS(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Tn(r),a=t?zs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Sn(1);const d=Sn(0),p=kn(r);if((p||!p&&!s)&&((Or(r)!=="body"||yo(i))&&(l=Hs(r)),kn(r))){const f=dr(r);c=Lr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?Sp(i,l):Sn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function RS(e){return Array.from(e.getClientRects())}function OS(e){const t=Tn(e),n=Hs(e),r=e.ownerDocument.body,o=en(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=en(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Us(e);const a=-n.scrollTop;return hn(r).direction==="rtl"&&(i+=en(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Cp=25;function DS(e,t){const n=tn(e),r=Tn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Za();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Us(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,b=Math.abs(r.clientWidth-p.clientWidth-f);b<=Cp&&(s-=b)}else c<=Cp&&(s+=c);return{width:s,height:i,x:a,y:l}}const LS=new Set(["absolute","fixed"]);function $S(e,t){const n=dr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=kn(e)?Lr(e):Sn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Tp(e,t,n){let r;if(t==="viewport")r=DS(e,n);else if(t==="document")r=OS(Tn(e));else if(pn(t))r=$S(t,n);else{const o=yp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Fs(r)}function kp(e,t){const n=Vn(e);return n===t||!pn(n)||Dr(n)?!1:hn(n).position==="fixed"||kp(n,t)}function FS(e,t){const n=t.get(e);if(n)return n;let r=So(e,[],!1).filter(a=>pn(a)&&Or(a)!=="body"),o=null;const s=hn(e).position==="fixed";let i=s?Vn(e):e;for(;pn(i)&&!Dr(i);){const a=hn(i),l=Ja(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&LS.has(o.position)||yo(i)&&!l&&kp(e,i))?r=r.filter(d=>d!==i):o=a,i=Vn(i)}return t.set(e,r),r}function BS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zs(t)?[]:FS(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=Tp(t,d,o);return c.top=en(p.top,c.top),c.right=Wn(p.right,c.right),c.bottom=Wn(p.bottom,c.bottom),c.left=en(p.left,c.left),c},Tp(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function zS(e){const{width:t,height:n}=wp(e);return{width:t,height:n}}function HS(e,t,n){const r=kn(t),o=Tn(t),s=n==="fixed",i=dr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Sn(0);function c(){l.x=Us(o)}if(r||!r&&!s)if((Or(t)!=="body"||yo(o))&&(a=Hs(t)),r){const f=dr(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?Sp(o,a):Sn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function tl(e){return hn(e).position==="static"}function Ep(e,t){if(!kn(e)||hn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Tn(e)===n&&(n=n.ownerDocument.body),n}function Ip(e,t){const n=tn(e);if(zs(e))return n;if(!kn(e)){let o=Vn(e);for(;o&&!Dr(o);){if(pn(o)&&!tl(o))return o;o=Vn(o)}return n}let r=Ep(e,t);for(;r&&TS(r)&&tl(r);)r=Ep(r,t);return r&&Dr(r)&&tl(r)&&!Ja(r)?n:r||AS(e)||n}const US=async function(e){const t=this.getOffsetParent||Ip,n=this.getDimensions,r=await n(e.floating);return{reference:HS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function WS(e){return hn(e).direction==="rtl"}const VS={convertOffsetParentRelativeRectToViewportRelativeRect:MS,getDocumentElement:Tn,getClippingRect:BS,getOffsetParent:Ip,getElementRects:US,getClientRects:RS,getDimensions:zS,getScale:Lr,isElement:pn,isRTL:WS};function Np(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function KS(e,t){let n=null,r;const o=Tn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const b=Ls(p),g=Ls(o.clientWidth-(d+m)),v=Ls(o.clientHeight-(p+f)),y=Ls(d),C={rootMargin:-b+"px "+-g+"px "+-v+"px "+-y+"px",threshold:en(0,Wn(1,l))||1};let E=!0;function T(S){const k=S[0].intersectionRatio;if(k!==l){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Np(c,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(T,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,C)}n.observe(e)}return i(!0),s}function qS(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=el(e),d=o||s?[...c?So(c):[],...So(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?KS(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let b,g=l?dr(e):null;l&&v();function v(){const y=dr(e);g&&!Np(g,y)&&n(),g=y,b=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(b)}}const GS=xS,YS=bS,XS=mS,JS=yS,ZS=gS,Ap=hS,QS=wS,eC=(e,t,n)=>{const r=new Map,o={platform:VS,...n},s={...o.platform,_c:r};return pS(e,t,{...o,platform:s})};var tC=typeof document<"u",nC=function(){},Ws=tC?x.useLayoutEffect:nC;function Vs(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(!Vs(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)&&!Vs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function jp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pp(e,t){const n=jp(e);return Math.round(t*n)/n}function nl(e){const t=h.useRef(e);return Ws(()=>{t.current=e}),t}function rC(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);Vs(m,r)||f(r);const[b,g]=h.useState(null),[v,y]=h.useState(null),w=h.useCallback(R=>{R!==S.current&&(S.current=R,g(R))},[]),C=h.useCallback(R=>{R!==k.current&&(k.current=R,y(R))},[]),E=s||b,T=i||v,S=h.useRef(null),k=h.useRef(null),A=h.useRef(d),j=l!=null,B=nl(l),$=nl(o),z=nl(c),G=h.useCallback(()=>{if(!S.current||!k.current)return;const R={placement:t,strategy:n,middleware:m};$.current&&(R.platform=$.current),eC(S.current,k.current,R).then(I=>{const U={...I,isPositioned:z.current!==!1};M.current&&!Vs(A.current,U)&&(A.current=U,qr.flushSync(()=>{p(U)}))})},[m,t,n,$,z]);Ws(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p(R=>({...R,isPositioned:!1})))},[c]);const M=h.useRef(!1);Ws(()=>(M.current=!0,()=>{M.current=!1}),[]),Ws(()=>{if(E&&(S.current=E),T&&(k.current=T),E&&T){if(B.current)return B.current(E,T,G);G()}},[E,T,G,B,j]);const F=h.useMemo(()=>({reference:S,floating:k,setReference:w,setFloating:C}),[w,C]),V=h.useMemo(()=>({reference:E,floating:T}),[E,T]),K=h.useMemo(()=>{const R={position:n,left:0,top:0};if(!V.floating)return R;const I=Pp(V.floating,d.x),U=Pp(V.floating,d.y);return a?{...R,transform:"translate("+I+"px, "+U+"px)",...jp(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:U}},[n,a,V.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:G,refs:F,elements:V,floatingStyles:K}),[d,G,F,V,K])}const oC=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?Ap({element:r.current,padding:o}).fn(n):{}:r?Ap({element:r,padding:o}).fn(n):{}}}},sC=(e,t)=>({...GS(e),options:[e,t]}),iC=(e,t)=>({...YS(e),options:[e,t]}),aC=(e,t)=>({...QS(e),options:[e,t]}),lC=(e,t)=>({...XS(e),options:[e,t]}),cC=(e,t)=>({...JS(e),options:[e,t]}),uC=(e,t)=>({...ZS(e),options:[e,t]}),dC=(e,t)=>({...oC(e),options:[e,t]});var fC="Arrow",_p=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});_p.displayName=fC;var pC=_p;function Mp(e){const[t,n]=h.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var rl="Popper",[Rp,$r]=nn(rl),[hC,Op]=Rp(rl),Dp=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(hC,{scope:t,anchor:r,onAnchorChange:o,children:n})};Dp.displayName=rl;var Lp="PopperAnchor",$p=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Op(Lp,n),i=h.useRef(null),a=Re(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});$p.displayName=Lp;var ol="PopperContent",[mC,gC]=Rp(ol),Fp=h.forwardRef((e,t)=>{var _,P,W,Z,se,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:b,...g}=e,v=Op(ol,n),[y,w]=h.useState(null),C=Re(t,Se=>w(Se)),[E,T]=h.useState(null),S=Mp(E),k=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,j=r+(s!=="center"?"-"+s:""),B=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(c)?c:[c],z=$.length>0,G={padding:B,boundary:$.filter(xC),altBoundary:z},{refs:M,floatingStyles:F,placement:V,isPositioned:K,middlewareData:R}=rC({strategy:"fixed",placement:j,whileElementsMounted:(...Se)=>qS(...Se,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[sC({mainAxis:o+A,alignmentAxis:i}),l&&iC({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?aC():void 0,...G}),l&&lC({...G}),cC({...G,apply:({elements:Se,rects:Ce,availableWidth:Oe,availableHeight:Fe})=>{const{width:Be,height:Ke}=Ce.reference,ze=Se.floating.style;ze.setProperty("--radix-popper-available-width",`${Oe}px`),ze.setProperty("--radix-popper-available-height",`${Fe}px`),ze.setProperty("--radix-popper-anchor-width",`${Be}px`),ze.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),E&&dC({element:E,padding:a}),bC({arrowWidth:k,arrowHeight:A}),m&&uC({strategy:"referenceHidden",...G})]}),[I,U]=Hp(V),J=xt(b);It(()=>{K&&(J==null||J())},[K,J]);const O=(_=R.arrow)==null?void 0:_.x,Y=(P=R.arrow)==null?void 0:P.y,L=((W=R.arrow)==null?void 0:W.centerOffset)!==0,[D,X]=h.useState();return It(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:K?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:D,"--radix-popper-transform-origin":[(Z=R.transformOrigin)==null?void 0:Z.x,(se=R.transformOrigin)==null?void 0:se.y].join(" "),...((ae=R.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(mC,{scope:n,placedSide:I,onArrowChange:T,arrowX:O,arrowY:Y,shouldHideArrow:L,children:u.jsx(me.div,{"data-side":I,"data-align":U,...g,ref:C,style:{...g.style,animation:K?void 0:"none"}})})})});Fp.displayName=ol;var Bp="PopperArrow",vC={top:"bottom",right:"left",bottom:"top",left:"right"},zp=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=gC(Bp,r),i=vC[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(pC,{...o,ref:n,style:{...o.style,display:"block"}})})});zp.displayName=Bp;function xC(e){return e!==null}var bC=e=>({name:"transformOrigin",options:e,fn(t){var v,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Hp(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let b="",g="";return c==="bottom"?(b=i?p:`${m}px`,g=`${-l}px`):c==="top"?(b=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(b=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(b=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:b,y:g}}}});function Hp(e){const[t,n="center"]=e.split("-");return[t,n]}var sl=Dp,il=$p,al=Fp,ll=zp,cl="rovingFocusGroup.onEntryFocus",wC={bubbles:!1,cancelable:!0},Co="RovingFocusGroup",[ul,Up,yC]=Rs(Co),[SC,Wp]=nn(Co,[yC]),[CC,TC]=SC(Co),Vp=h.forwardRef((e,t)=>u.jsx(ul.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ul.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(kC,{...e,ref:t})})}));Vp.displayName=Co;var kC=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=Re(t,m),b=Os(s),[g,v]=In({prop:i,defaultProp:a??null,onChange:l,caller:Co}),[y,w]=h.useState(!1),C=xt(c),E=Up(n),T=h.useRef(!1),[S,k]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(cl,C),()=>A.removeEventListener(cl,C)},[C]),u.jsx(CC,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>v(A),[v]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>k(A=>A-1),[]),children:u.jsx(me.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{T.current=!0}),onFocus:le(e.onFocus,A=>{const j=!T.current;if(A.target===A.currentTarget&&j&&!y){const B=new CustomEvent(cl,wC);if(A.currentTarget.dispatchEvent(B),!B.defaultPrevented){const $=E().filter(V=>V.focusable),z=$.find(V=>V.active),G=$.find(V=>V.id===g),F=[z,G,...$].filter(Boolean).map(V=>V.ref.current);Gp(F,d)}}T.current=!1}),onBlur:le(e.onBlur,()=>w(!1))})})}),Kp="RovingFocusGroupItem",qp=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=jt(),c=s||l,d=TC(Kp,n),p=d.currentTabStopId===c,m=Up(n),{onFocusableItemAdd:f,onFocusableItemRemove:b,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>b()},[r,f,b]),u.jsx(ul.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:le(e.onMouseDown,v=>{r?d.onItemFocus(c):v.preventDefault()}),onFocus:le(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:le(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=NC(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const E=C.indexOf(v.currentTarget);C=d.loop?AC(C,E+1):C.slice(E+1)}setTimeout(()=>Gp(C))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});qp.displayName=Kp;var EC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function IC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function NC(e,t,n){const r=IC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return EC[r]}function Gp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function AC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var jC=Vp,PC=qp,dl=["Enter"," "],_C=["ArrowDown","PageUp","Home"],Yp=["ArrowUp","PageDown","End"],MC=[..._C,...Yp],RC={ltr:[...dl,"ArrowRight"],rtl:[...dl,"ArrowLeft"]},OC={ltr:["ArrowLeft"],rtl:["ArrowRight"]},To="Menu",[ko,DC,LC]=Rs(To),[fr,Xp]=nn(To,[LC,$r,Wp]),Ks=$r(),Jp=Wp(),[$C,pr]=fr(To),[FC,Eo]=fr(To),Zp=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ks(t),[l,c]=h.useState(null),d=h.useRef(!1),p=xt(s),m=Os(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),u.jsx(sl,{...a,children:u.jsx($C,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(FC,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Zp.displayName=To;var BC="MenuAnchor",fl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(il,{...o,...r,ref:t})});fl.displayName=BC;var pl="MenuPortal",[zC,Qp]=fr(pl,{forceMount:void 0}),eh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=pr(pl,t);return u.jsx(zC,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(oo,{asChild:!0,container:o,children:r})})})};eh.displayName=pl;var sn="MenuContent",[HC,hl]=fr(sn),th=h.forwardRef((e,t)=>{const n=Qp(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu);return u.jsx(ko.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ko.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(UC,{...o,ref:t}):u.jsx(WC,{...o,ref:t})})})})}),UC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return na(s)},[]),u.jsx(ml,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),WC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu);return u.jsx(ml,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),VC=Jt.createSlot("MenuContent.ScrollLock"),ml=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:b,...g}=e,v=pr(sn,n),y=Eo(sn,n),w=Ks(n),C=Jp(n),E=DC(n),[T,S]=h.useState(null),k=h.useRef(null),A=Re(t,k,v.onContentChange),j=h.useRef(0),B=h.useRef(""),$=h.useRef(0),z=h.useRef(null),G=h.useRef("right"),M=h.useRef(0),F=b?rs:h.Fragment,V=b?{as:VC,allowPinchZoom:!0}:void 0,K=I=>{var _,P;const U=B.current+I,J=E().filter(W=>!W.disabled),O=document.activeElement,Y=(_=J.find(W=>W.ref.current===O))==null?void 0:_.textValue,L=J.map(W=>W.textValue),D=rT(L,U,Y),X=(P=J.find(W=>W.textValue===D))==null?void 0:P.ref.current;(function W(Z){B.current=Z,window.clearTimeout(j.current),Z!==""&&(j.current=window.setTimeout(()=>W(""),1e3))})(U),X&&setTimeout(()=>X.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Xi();const R=h.useCallback(I=>{var J,O;return G.current===((J=z.current)==null?void 0:J.side)&&sT(I,(O=z.current)==null?void 0:O.area)},[]);return u.jsx(HC,{scope:n,searchRef:B,onItemEnter:h.useCallback(I=>{R(I)&&I.preventDefault()},[R]),onItemLeave:h.useCallback(I=>{var U;R(I)||((U=k.current)==null||U.focus(),S(null))},[R]),onTriggerLeave:h.useCallback(I=>{R(I)&&I.preventDefault()},[R]),pointerGraceTimerRef:$,onPointerGraceIntentChange:h.useCallback(I=>{z.current=I},[]),children:u.jsx(F,{...V,children:u.jsx(Xo,{asChild:!0,trapped:o,onMountAutoFocus:le(s,I=>{var U;I.preventDefault(),(U=k.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(jC,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:S,onEntryFocus:le(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(al,{role:"menu","aria-orientation":"vertical","data-state":xh(v.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:le(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,O=I.ctrlKey||I.altKey||I.metaKey,Y=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!O&&Y&&K(I.key));const L=k.current;if(I.target!==L||!MC.includes(I.key))return;I.preventDefault();const X=E().filter(_=>!_.disabled).map(_=>_.ref.current);Yp.includes(I.key)&&X.reverse(),tT(X)}),onBlur:le(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(j.current),B.current="")}),onPointerMove:le(e.onPointerMove,No(I=>{const U=I.target,J=M.current!==I.clientX;if(I.currentTarget.contains(U)&&J){const O=I.clientX>M.current?"right":"left";G.current=O,M.current=I.clientX}}))})})})})})})});th.displayName=sn;var KC="MenuGroup",gl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});gl.displayName=KC;var qC="MenuLabel",nh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});nh.displayName=qC;var qs="MenuItem",rh="menu.itemSelect",Gs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Eo(qs,e.__scopeMenu),a=hl(qs,e.__scopeMenu),l=Re(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(rh,{bubbles:!0,cancelable:!0});p.addEventListener(rh,f=>r==null?void 0:r(f),{once:!0}),Vi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(oh,{...o,ref:l,disabled:n,onClick:le(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:le(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:le(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||dl.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Gs.displayName=qs;var oh=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=hl(qs,n),a=Jp(n),l=h.useRef(null),c=Re(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const b=l.current;b&&f((b.textContent??"").trim())},[s.children]),u.jsx(ko.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(PC,{asChild:!0,...a,focusable:!r,children:u.jsx(me.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:le(e.onPointerMove,No(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,No(b=>i.onItemLeave(b))),onFocus:le(e.onFocus,()=>p(!0)),onBlur:le(e.onBlur,()=>p(!1))})})})}),GC="MenuCheckboxItem",sh=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(uh,{scope:e.__scopeMenu,checked:n,children:u.jsx(Gs,{role:"menuitemcheckbox","aria-checked":Ys(n)?"mixed":n,...o,ref:t,"data-state":xl(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(Ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sh.displayName=GC;var ih="MenuRadioGroup",[YC,XC]=fr(ih,{value:void 0,onValueChange:()=>{}}),ah=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=xt(r);return u.jsx(YC,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(gl,{...o,ref:t})})});ah.displayName=ih;var lh="MenuRadioItem",ch=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=XC(lh,e.__scopeMenu),s=n===o.value;return u.jsx(uh,{scope:e.__scopeMenu,checked:s,children:u.jsx(Gs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":xl(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});ch.displayName=lh;var vl="MenuItemIndicator",[uh,JC]=fr(vl,{checked:!1}),dh=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=JC(vl,n);return u.jsx(Ft,{present:r||Ys(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":xl(s.checked)})})});dh.displayName=vl;var ZC="MenuSeparator",fh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});fh.displayName=ZC;var QC="MenuArrow",ph=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(ll,{...o,...r,ref:t})});ph.displayName=QC;var eT="MenuSub",[HN,hh]=fr(eT),Io="MenuSubTrigger",mh=h.forwardRef((e,t)=>{const n=pr(Io,e.__scopeMenu),r=Eo(Io,e.__scopeMenu),o=hh(Io,e.__scopeMenu),s=hl(Io,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(fl,{asChild:!0,...c,children:u.jsx(oh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xh(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:le(e.onPointerMove,No(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:le(e.onPointerLeave,No(p=>{var f,b;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(b=n.content)==null?void 0:b.dataset.side,v=g==="right",y=v?-5:5,w=m[v?"left":"right"],C=m[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:w,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:le(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||RC[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});mh.displayName=Io;var gh="MenuSubContent",vh=h.forwardRef((e,t)=>{const n=Qp(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu),a=hh(gh,e.__scopeMenu),l=h.useRef(null),c=Re(t,l);return u.jsx(ko.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ko.Slot,{scope:e.__scopeMenu,children:u.jsx(ml,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:le(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:le(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=OC[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});vh.displayName=gh;function xh(e){return e?"open":"closed"}function Ys(e){return e==="indeterminate"}function xl(e){return Ys(e)?"indeterminate":e?"checked":"unchecked"}function tT(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function nT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function rT(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=nT(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function oT(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function sT(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return oT(n,t)}function No(e){return t=>t.pointerType==="mouse"?e(t):void 0}var iT=Zp,aT=fl,lT=eh,cT=th,uT=gl,dT=nh,fT=Gs,pT=sh,hT=ah,mT=ch,gT=dh,vT=fh,xT=ph,bT=mh,wT=vh,Xs="DropdownMenu",[yT,UN]=nn(Xs,[Xp]),zt=Xp(),[ST,bh]=yT(Xs),wh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),c=h.useRef(null),[d,p]=In({prop:o,defaultProp:s??!1,onChange:i,caller:Xs});return u.jsx(ST,{scope:t,triggerId:jt(),triggerRef:c,contentId:jt(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(iT,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};wh.displayName=Xs;var yh="DropdownMenuTrigger",Sh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bh(yh,n),i=zt(n);return u.jsx(aT,{asChild:!0,...i,children:u.jsx(me.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:Dn(t,s.triggerRef),onPointerDown:le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Sh.displayName=yh;var CT="DropdownMenuPortal",Ch=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(lT,{...r,...n})};Ch.displayName=CT;var Th="DropdownMenuContent",kh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bh(Th,n),s=zt(n),i=h.useRef(!1);return u.jsx(cT,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kh.displayName=Th;var TT="DropdownMenuGroup",kT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(uT,{...o,...r,ref:t})});kT.displayName=TT;var ET="DropdownMenuLabel",Eh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(dT,{...o,...r,ref:t})});Eh.displayName=ET;var IT="DropdownMenuItem",Ih=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(fT,{...o,...r,ref:t})});Ih.displayName=IT;var NT="DropdownMenuCheckboxItem",Nh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(pT,{...o,...r,ref:t})});Nh.displayName=NT;var AT="DropdownMenuRadioGroup",jT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(hT,{...o,...r,ref:t})});jT.displayName=AT;var PT="DropdownMenuRadioItem",Ah=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(mT,{...o,...r,ref:t})});Ah.displayName=PT;var _T="DropdownMenuItemIndicator",jh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(gT,{...o,...r,ref:t})});jh.displayName=_T;var MT="DropdownMenuSeparator",Ph=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(vT,{...o,...r,ref:t})});Ph.displayName=MT;var RT="DropdownMenuArrow",OT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(xT,{...o,...r,ref:t})});OT.displayName=RT;var DT="DropdownMenuSubTrigger",_h=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(bT,{...o,...r,ref:t})});_h.displayName=DT;var LT="DropdownMenuSubContent",Mh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(wT,{...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)"}})});Mh.displayName=LT;var $T=wh,FT=Sh,BT=Ch,Rh=kh,Oh=Eh,Dh=Ih,Lh=Nh,$h=Ah,Fh=jh,Bh=Ph,zh=_h,Hh=Mh;const Js=$T,Zs=FT,zT=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(zh,{ref:o,className:oe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));zT.displayName=zh.displayName;const HT=h.forwardRef(({className:e,...t},n)=>u.jsx(Hh,{ref:n,className:oe("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}));HT.displayName=Hh.displayName;const Ao=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(BT,{children:u.jsx(Rh,{ref:r,sideOffset:t,className:oe("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})}));Ao.displayName=Rh.displayName;const Kn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Dh,{ref:r,className:oe("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}));Kn.displayName=Dh.displayName;const UT=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Lh,{ref:o,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Fh,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));UT.displayName=Lh.displayName;const WT=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($h,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Fh,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));WT.displayName=$h.displayName;const VT=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Oh,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));VT.displayName=Oh.displayName;const KT=h.forwardRef(({className:e,...t},n)=>u.jsx(Bh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));KT.displayName=Bh.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[40px] 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";const qT=1e4;function Uh({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=qT,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:b,validate:g,onValidationError:v}){const y=i!==void 0,[w,C]=x.useState(e),E=(y?i:w)??"",[T,S]=x.useTransition(),k=x.useRef(null),A=x.useRef(0),j=x.useRef(null),B=x.useRef("");x.useEffect(()=>{if(!y&&(C(e??""),j.current=null,k.current)){const L=!e||e.trim()==="",D=44;L?k.current.style.height=`${D}px`:(k.current.style.height="auto",k.current.style.height=`${Math.max(k.current.scrollHeight,D)}px`)}},[e,t,y]);const[$,z]=x.useState(null),G=x.useCallback(L=>L.length>s?`Message too long (${L.length}/${s} characters)`:null,[s]),M=x.useMemo(()=>g??G,[g,G]),F=x.useCallback(L=>{const D=M(L);return z(D),v==null||v(D),B.current=L,D},[M,v]),V=x.useCallback(()=>{const L=k.current;if(!L)return;const D=!L.value||L.value.trim()==="",X=44;if(D){L.style.height=`${X}px`;return}L.style.height="auto";const _=Math.max(L.scrollHeight,X);L.style.height=`${_}px`},[]);x.useEffect(()=>{V()},[V,E]),x.useEffect(()=>{if(!$)return;const L=(E??"").trim();B.current!==L&&F(L)},[E,$,F]);const K=x.useCallback((L,{fromUser:D})=>{y||C(L),D&&(a==null||a(L))},[y,a]),R=x.useCallback(async L=>{L&&L.preventDefault();const D=(E??"").trim();if(!D&&!f||F(D))return;const X=++A.current;j.current={id:X,shouldClear:!0},S(()=>{var _,P,W;try{const Z=l(D);Z&&typeof Z.then=="function"?Z.then(()=>{var se,ae;((se=j.current)==null?void 0:se.id)===X&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ae=j.current)==null?void 0:ae.id)===X&&(j.current=null)}).catch(()=>{var se;((se=j.current)==null?void 0:se.id)===X&&(j.current=null)}):(((_=j.current)==null?void 0:_.id)===X&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((P=j.current)==null?void 0:P.id)===X&&(j.current=null))}catch{((W=j.current)==null?void 0:W.id)===X&&(j.current=null)}})},[E,l,f,y,a,F]),I=x.useCallback(L=>{const D=L.target.value;K(D,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),$&&F(D.trim())},[K,F,$]),U=x.useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),R()):L.key==="Escape"&&t&&(L.preventDefault(),c==null||c())},[R,t,c]),Y=`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))]":""} ${m}`;return u.jsx("div",{className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(bl,{ref:k,value:E,onChange:I,onKeyDown:U,placeholder:t?"Edit your message...":n,className:Y,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),u.jsx("div",{children:r?u.jsx(et,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(et,{type:"button",onClick:L=>void R(L),size:"icon",className:`shrink-0 ${b??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!f||T||r,children:u.jsx(ue.Send,{size:16})})})]})})}const GT=x.memo(Uh);function Wh({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:p={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:b,onFilesChange:g,onError:v,allowEmptySend:y=!1,inputError:w=null}){const[C,E]=x.useState([]),T=x.useRef(null),S=x.useRef(null),[k,A]=x.useState(0),[j,B]=x.useState(0),[$,z]=x.useState(!1),[G,M]=x.useState(null),[F,V]=x.useState(null),K=x.useCallback(()=>{T.current&&(T.current.value=""),S.current&&(S.current.value=""),A(D=>D+1),B(D=>D+1)},[]),R=x.useCallback(D=>{E(X=>{const _=[...X,...D];return g==null||g(_),_})},[g]),I=x.useCallback(D=>{const X=Array.from(D.target.files||[]);R(X),D.target.value=""},[R]),U=x.useCallback(D=>{E(X=>{const _=X.filter((P,W)=>W!==D);return _.length===0&&K(),g==null||g(_),_})},[g,K]),J=x.useCallback(async D=>{const X=(D.target.files||[])[0];if(X&&(M(null),V(null),!!b)){z(!0);try{await b(X),M(`Uploaded ${X.name} - processing through chat stream`)}catch(_){const P=_ instanceof Error?_.message:"Failed to upload Excel file";V(P),v==null||v(P)}finally{z(!1),D.target.value="",K()}}},[b,v,K]),O=x.useMemo(()=>y||C.length>0,[y,C]),Y=x.useCallback(async D=>{const _=await n(D,C);return C.length>0&&(E([]),g==null||g([]),K()),_},[n,K,C]),L=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"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":""} ${p.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:T,type:"file",multiple:!0,onChange:I,className:"hidden"},k),C.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:C.map((D,X)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:D.name}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>U(X),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 ${D.name}`,children:u.jsx(ue.X,{size:12})})]},X))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:J,className:"hidden"},j),$&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),G&&!$&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:G}),F&&!$&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:F})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(et,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:p.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(Ao,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Kn,{onClick:()=>{var D;return(D=T.current)==null?void 0:D.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Kn,{onClick:()=>{var D;$||(D=S.current)==null||D.click()},className:`cursor-pointer ${$?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(GT,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:Y,onCancelEdit:r,onStop:o,allowEmptySend:O,textareaClassName:L,sendButtonClassName:p.sendButton})})]})]})}const YT=x.memo(Wh),Vh={value:""};function Fr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,followNewMessages:s=!0,enableFileUpload:i=!0,enableExcelUpload:a=!1,enableMessageEditing:l=!0,showToolMessages:c=!0,toolConfig:d,toolRenderers:p,toolArtifactRenderers:m,payloadExtras:f={},customStyles:b={},messageCustomStyles:g,onMessageSent:v,onExcelUploadSuccess:y,onError:w,defaultMessage:C}){const{chatApi:E}=On(),T=E.baseUrl,{currentThreadId:S}=yr(),{threadId:k,messages:A,isLoading:j,navigateToCheckpoint:B,returnToLatest:$,checkpoint:z,checkpoints:G,interrupt:M,metadata:F,checkpointIndex:V,respondToInterrupt:K}=no(),{isStreaming:R,error:I,connectionState:U,submit:J,stop:O}=Ui(),Y=k??S??null,L=(z==null?void 0:z.id)??null,D=(z==null?void 0:z.namespace)??null,X=(F==null?void 0:F.assemblingMessageId)??null;x.useEffect(()=>{console.log("[ChatInterface] streamingAssistantId changed:",{streamingAssistantId:X,isStreaming:R,assemblingMessageId:F==null?void 0:F.assemblingMessageId})},[X,R,F==null?void 0:F.assemblingMessageId]);const _=M,P=_?Li(_.id):null,W=P!==null?{type:"interrupt",id:P}:null,[Z,se]=x.useState(!1),[ae,Se]=x.useState(!1);x.useEffect(()=>{_||se(!1)},[_]);const Ce=x.useCallback(()=>{se(!0)},[]),Oe=x.useCallback(()=>{se(!1)},[]),Fe=x.useCallback(ne=>{},[]),Be=x.useCallback(ne=>ne.name!=="ask_user_choice",[]),Ke=d??{toolRenderers:p,toolArtifactRenderers:m,getToolExpandable:Be},ze=x.useCallback(async(ne,ce,ge)=>{try{Ce(),await K(ne,ce,ge)}catch(we){console.error("Failed to respond to interrupt:",we)}finally{Oe()}},[Oe,Ce,K]),dt=x.useCallback(()=>ze(!0),[ze]),pt=x.useCallback(()=>ze(!1),[ze]),Ze=x.useCallback((ne,ce)=>ze(!0,ce),[ze]),He=!!_||Z,[Me,qe]=x.useState(null),[Ae,Ge]=x.useState(""),[Xe,Ct]=x.useState(null),[Qe,Tt]=x.useState(null),[ht,wt]=x.useState(!1),[At,Pt]=x.useState(null),mt=x.useRef(!1),[gt,Ht]=x.useState(()=>Vh.value),Ve=x.useRef(gt),$e=x.useRef(null),ft=x.useCallback(ne=>{Vh.value=ne,Ht(ne)},[]),[kt,ct]=x.useState(!1),_t=x.useRef(null),xe=x.useCallback(ne=>{ft(ne)},[ft]);x.useEffect(()=>{R||Se(!1)},[R]),x.useEffect(()=>{F!=null&&F.assemblingMessageId&&Se(!1)},[F==null?void 0:F.assemblingMessageId]);const[Le,Ue]=x.useState("desktop");x.useEffect(()=>{const ne=()=>{const ce=window.innerWidth;Ue(ce<640?"phone":ce<1024?"tablet":"desktop")};return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[]),x.useEffect(()=>{mt.current=!1},[Y]),x.useEffect(()=>{Ve.current=gt},[gt]),x.useEffect(()=>{if(!Me){$e.current=null;return}$e.current===null&&($e.current=Ve.current),ft(Ae??"")},[Ae,Me,ft]),x.useEffect(()=>{if(C!==void 0){Pt(C);return}(async()=>{if(!T){Pt(null);return}try{const ge=(await E.getAgent("default")).uiDefaultMessage||"";Pt(ge||null)}catch(ce){console.warn("Failed to fetch default message:",ce),Pt(null)}})()},[E,T,C]),x.useEffect(()=>{I&&!ht&&(w==null||w(I))},[I,ht,w]);const st=async(ne,ce)=>{const ge=ne.trim();if(!(!ge&&ce.length===0))try{const we=Me?(Xe==null?void 0:Xe.checkpointId)??L??void 0:L??void 0,Pe=Me?(Xe==null?void 0:Xe.checkpointNs)??D??void 0:D??void 0;await J({text:ge||"",attachments:ce,payload:f},{checkpointId:we,checkpointNs:Pe,edit:!!Me,originalMessageId:Me??void 0}),v==null||v(ge),Se(!0),ft(""),Tt(null),qe(null),Ge(""),Ct(null)}catch(we){const Pe=(we==null?void 0:we.message)||"Failed to send message";Tt(Pe),w==null||w(Pe),Se(!1)}},nt=x.useCallback(async ne=>{await J({attachments:[ne],payload:f},{checkpointId:L??void 0,checkpointNs:D??void 0}),y==null||y({file:ne})},[L,D,f,y,J]),ut=x.useCallback((ne,ce,ge)=>{l&&($e.current=gt,qe(ne),Ge(ce),ft(ce),Tt(null),Ct({checkpointId:(ge==null?void 0:ge.checkpointId)??null,checkpointNs:(ge==null?void 0:ge.checkpointNs)??null}))},[gt,l,ft]),tt=x.useCallback(()=>{qe(null),Ge(""),Ct(null),Tt(null),ft($e.current??gt),$e.current=null},[gt,ft]),Q=x.useCallback((ne,ce,ge)=>{ut(ne,ce,ge)},[ut]),ee=x.useCallback(ne=>{let ce=null;for(let Ee=ne-1;Ee>=0;Ee--)if(A[Ee].role==="user"){ce=A[Ee];break}if(!ce)return;const ge=Array.isArray(ce.content)?ce.content:[],Pe=ge.filter(Ee=>(Ee==null?void 0:Ee.type)==="text").map(Ee=>Ee.text).join("")||(()=>{try{return JSON.stringify(ge,null,2)}catch{return String(ge)}})();Pe&&J({text:Pe,payload:f},{checkpointId:L??void 0,checkpointNs:D??void 0,edit:!0,originalMessageId:ce.id})},[A,J,L,D,f]),he=x.useCallback(async ne=>{if(S){ct(!0);try{if(!ne){await $(),requestAnimationFrame(()=>{var we;(we=_t.current)==null||we.scrollToLatest()});return}const ce=G.find(we=>we.checkpointId===ne),ge=(ce==null?void 0:ce.checkpointNs)??null;await B(ne,ge),requestAnimationFrame(()=>{var we;(we=_t.current)==null||we.scrollToTop()})}finally{ct(!1)}}},[G,S,_t,B,$]),de=x.useCallback(async(ne,ce,ge)=>{await he(ge?null:ne)},[he]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${b.container||""}`,N=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${_?"pb-32":""} bg-transparent ${b.messagesArea||""}`,te=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${b.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!I&&!ht&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${N}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Va,{ref:_t,className:"h-full",style:{height:"100%"},messages:A,isStreaming:R,streamingAssistantId:X,streamingDebounceMs:o,followNewMessages:s,layoutSize:Le,enableMessageEditing:l,editingMessageId:Me,onEdit:Q,onRegenerate:ee,onCancelEdit:tt,emptyMessage:At??void 0,isNavigatingCheckpoint:kt,showToolMessages:c,toolConfig:Ke,checkpointIndex:V,activeCheckpointId:L,onSelectCheckpoint:de,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae,getMessageCustomStyles:g,getInterruptOptions:Fe}),(U==="reconnecting"||U==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),U==="reconnecting"?"Reconnecting…":"Connecting…"]})}),U==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),j&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),kt&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),_&&W&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(ba,{interruptPart:W,onApprove:dt,onReject:pt,onSelectAlternative:Ze,disabled:Z,isActive:!0,payload:_.value})})})]}),u.jsxs("div",{className:te,children:[Me&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(et,{variant:"ghost",size:"sm",onClick:tt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),Qe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Qe}),u.jsx(YT,{composerValue:gt,onComposerChange:xe,onSend:st,onCancelEdit:tt,onStop:O,editingMessageId:Me,editingInitialValue:Ae,placeholder:Me?"Edit your message...":t,isStreaming:R,disabled:He,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:nt,onError:w,customStyles:b,textareaClassName:b.textarea||"",allowEmptySend:!1,inputError:Qe})]})]})}var Kh=1,XT=.9,JT=.8,ZT=.17,wl=.1,yl=.999,QT=.9999,ek=.99,tk=/[\\\/_+.#"@\[\(\{&]/,nk=/[\\\/_+.#"@\[\(\{&]/g,rk=/[\s-]/,qh=/[\s-]/g;function Sl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Kh:ek;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,b;c>=0;)p=Sl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Kh:tk.test(e.charAt(c-1))?(p*=JT,f=e.slice(o,c-1).match(nk),f&&o>0&&(p*=Math.pow(yl,f.length))):rk.test(e.charAt(c-1))?(p*=XT,b=e.slice(o,c-1).match(qh),b&&o>0&&(p*=Math.pow(yl,b.length))):(p*=ZT,o>0&&(p*=Math.pow(yl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=QT)),(p<wl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=Sl(e,t,n,r,c+1,s+2,i),m*wl>p&&(p=m*wl)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Gh(e){return e.toLowerCase().replace(qh," ")}function ok(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Sl(e,t,Gh(e),Gh(t),0,0,{})}var jo='[cmdk-group=""]',Cl='[cmdk-group-items=""]',sk='[cmdk-group-heading=""]',Yh='[cmdk-item=""]',Xh=`${Yh}:not([aria-disabled="true"])`,Tl="cmdk-item-select",Br="data-value",ik=(e,t,n)=>ok(e,t,n),Jh=h.createContext(void 0),Po=()=>h.useContext(Jh),Zh=h.createContext(void 0),kl=()=>h.useContext(Zh),Qh=h.createContext(void 0),em=h.forwardRef((e,t)=>{let n=zr(()=>{var O,Y;return{search:"",value:(Y=(O=e.value)!=null?O:e.defaultValue)!=null?Y:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=zr(()=>new Set),o=zr(()=>new Map),s=zr(()=>new Map),i=zr(()=>new Set),a=tm(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:b,disablePointerSelection:g=!1,vimBindings:v=!0,...y}=e,w=jt(),C=jt(),E=jt(),T=h.useRef(null),S=vk();hr(()=>{if(d!==void 0){let O=d.trim();n.current.value=O,k.emit()}},[d]),hr(()=>{S(6,G)},[]);let k=h.useMemo(()=>({subscribe:O=>(i.current.add(O),()=>i.current.delete(O)),snapshot:()=>n.current,setState:(O,Y,L)=>{var D,X,_,P;if(!Object.is(n.current[O],Y)){if(n.current[O]=Y,O==="search")z(),B(),S(1,$);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let W=document.getElementById(E);W?W.focus():(D=document.getElementById(w))==null||D.focus()}if(S(7,()=>{var W;n.current.selectedItemId=(W=M())==null?void 0:W.id,k.emit()}),L||S(5,G),((X=a.current)==null?void 0:X.value)!==void 0){let W=Y??"";(P=(_=a.current).onValueChange)==null||P.call(_,W);return}}k.emit()}},emit:()=>{i.current.forEach(O=>O())}}),[]),A=h.useMemo(()=>({value:(O,Y,L)=>{var D;Y!==((D=s.current.get(O))==null?void 0:D.value)&&(s.current.set(O,{value:Y,keywords:L}),n.current.filtered.items.set(O,j(Y,L)),S(2,()=>{B(),k.emit()}))},item:(O,Y)=>(r.current.add(O),Y&&(o.current.has(Y)?o.current.get(Y).add(O):o.current.set(Y,new Set([O]))),S(3,()=>{z(),B(),n.current.value||$(),k.emit()}),()=>{s.current.delete(O),r.current.delete(O),n.current.filtered.items.delete(O);let L=M();S(4,()=>{z(),(L==null?void 0:L.getAttribute("id"))===O&&$(),k.emit()})}),group:O=>(o.current.has(O)||o.current.set(O,new Set),()=>{s.current.delete(O),o.current.delete(O)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:E,labelId:C,listInnerRef:T}),[]);function j(O,Y){var L,D;let X=(D=(L=a.current)==null?void 0:L.filter)!=null?D:ik;return O?X(O,n.current.search,Y):0}function B(){if(!n.current.search||a.current.shouldFilter===!1)return;let O=n.current.filtered.items,Y=[];n.current.filtered.groups.forEach(D=>{let X=o.current.get(D),_=0;X.forEach(P=>{let W=O.get(P);_=Math.max(W,_)}),Y.push([D,_])});let L=T.current;F().sort((D,X)=>{var _,P;let W=D.getAttribute("id"),Z=X.getAttribute("id");return((_=O.get(Z))!=null?_:0)-((P=O.get(W))!=null?P:0)}).forEach(D=>{let X=D.closest(Cl);X?X.appendChild(D.parentElement===X?D:D.closest(`${Cl} > *`)):L.appendChild(D.parentElement===L?D:D.closest(`${Cl} > *`))}),Y.sort((D,X)=>X[1]-D[1]).forEach(D=>{var X;let _=(X=T.current)==null?void 0:X.querySelector(`${jo}[${Br}="${encodeURIComponent(D[0])}"]`);_==null||_.parentElement.appendChild(_)})}function $(){let O=F().find(L=>L.getAttribute("aria-disabled")!=="true"),Y=O==null?void 0:O.getAttribute(Br);k.setState("value",Y||void 0)}function z(){var O,Y,L,D;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let _ of r.current){let P=(Y=(O=s.current.get(_))==null?void 0:O.value)!=null?Y:"",W=(D=(L=s.current.get(_))==null?void 0:L.keywords)!=null?D:[],Z=j(P,W);n.current.filtered.items.set(_,Z),Z>0&&X++}for(let[_,P]of o.current)for(let W of P)if(n.current.filtered.items.get(W)>0){n.current.filtered.groups.add(_);break}n.current.filtered.count=X}function G(){var O,Y,L;let D=M();D&&(((O=D.parentElement)==null?void 0:O.firstChild)===D&&((L=(Y=D.closest(jo))==null?void 0:Y.querySelector(sk))==null||L.scrollIntoView({block:"nearest"})),D.scrollIntoView({block:"nearest"}))}function M(){var O;return(O=T.current)==null?void 0:O.querySelector(`${Yh}[aria-selected="true"]`)}function F(){var O;return Array.from(((O=T.current)==null?void 0:O.querySelectorAll(Xh))||[])}function V(O){let Y=F()[O];Y&&k.setState("value",Y.getAttribute(Br))}function K(O){var Y;let L=M(),D=F(),X=D.findIndex(P=>P===L),_=D[X+O];(Y=a.current)!=null&&Y.loop&&(_=X+O<0?D[D.length-1]:X+O===D.length?D[0]:D[X+O]),_&&k.setState("value",_.getAttribute(Br))}function R(O){let Y=M(),L=Y==null?void 0:Y.closest(jo),D;for(;L&&!D;)L=O>0?mk(L,jo):gk(L,jo),D=L==null?void 0:L.querySelector(Xh);D?k.setState("value",D.getAttribute(Br)):K(O)}let I=()=>V(F().length-1),U=O=>{O.preventDefault(),O.metaKey?I():O.altKey?R(1):K(1)},J=O=>{O.preventDefault(),O.metaKey?V(0):O.altKey?R(-1):K(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:O=>{var Y;(Y=y.onKeyDown)==null||Y.call(y,O);let L=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||L))switch(O.key){case"n":case"j":{v&&O.ctrlKey&&U(O);break}case"ArrowDown":{U(O);break}case"p":case"k":{v&&O.ctrlKey&&J(O);break}case"ArrowUp":{J(O);break}case"Home":{O.preventDefault(),V(0);break}case"End":{O.preventDefault(),I();break}case"Enter":{O.preventDefault();let D=M();if(D){let X=new Event(Tl);D.dispatchEvent(X)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:bk},l),Qs(e,O=>h.createElement(Zh.Provider,{value:k},h.createElement(Jh.Provider,{value:A},O))))}),ak=h.forwardRef((e,t)=>{var n,r;let o=jt(),s=h.useRef(null),i=h.useContext(Qh),a=Po(),l=tm(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;hr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=nm(o,s,[e.value,e.children,s],e.keywords),p=kl(),m=qn(S=>S.value&&S.value===d.current),f=qn(S=>c||a.filter()===!1?!0:S.search?S.filtered.items.get(o)>0:!0);h.useEffect(()=>{let S=s.current;if(!(!S||e.disabled))return S.addEventListener(Tl,b),()=>S.removeEventListener(Tl,b)},[f,e.onSelect,e.disabled]);function b(){var S,k;g(),(k=(S=l.current).onSelect)==null||k.call(S,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:v,value:y,onSelect:w,forceMount:C,keywords:E,...T}=e;return h.createElement(me.div,{ref:Dn(s,t),...T,id:o,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!m,"data-disabled":!!v,"data-selected":!!m,onPointerMove:v||a.getDisablePointerSelection()?void 0:g,onClick:v?void 0:b},e.children)}),lk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=jt(),a=h.useRef(null),l=h.useRef(null),c=jt(),d=Po(),p=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);hr(()=>d.group(i),[]),nm(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(me.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Qs(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Qh.Provider,{value:m},f))))}),ck=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:h.createElement(me.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),uk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=kl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=Po();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(me.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),dk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=qn(c=>c.selectedItemId),l=Po();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(me.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Qs(e,c=>h.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),fk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(ia,{open:n,onOpenChange:r},h.createElement(aa,{container:i},h.createElement(so,{"cmdk-overlay":"",className:o}),h.createElement(io,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(em,{ref:t,...a}))))}),pk=h.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?h.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),hk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Gt=Object.assign(em,{List:dk,Item:ak,Input:uk,Group:lk,Separator:ck,Dialog:fk,Empty:pk,Loading:hk});function mk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function gk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function tm(e){let t=h.useRef(e);return hr(()=>{t.current=e}),t}var hr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function zr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=kl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function nm(e,t,n,r=[]){let o=h.useRef(),s=Po();return hr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Br,a),o.current=a}),o}var vk=()=>{let[e,t]=h.useState(),n=zr(()=>new Map);return hr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function xk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(xk(t),{ref:t.ref},n(t.props.children)):n(t)}var bk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));El.displayName=Gt.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Gt.Input,{ref:n,className:oe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Il.displayName=Gt.Input.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Nl.displayName=Gt.List.displayName;const Al=h.forwardRef((e,t)=>u.jsx(Gt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Al.displayName=Gt.Empty.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Group,{ref:n,className:oe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));jl.displayName=Gt.Group.displayName;const wk=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));wk.displayName=Gt.Separator.displayName;const Pl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Item,{ref:n,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Pl.displayName=Gt.Item.displayName;function _l(e,[t,n]){return Math.min(n,Math.max(t,e))}function yk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ml="ScrollArea",[rm,WN]=nn(Ml),[Sk,an]=rm(Ml),om=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,b]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState(0),[C,E]=h.useState(0),[T,S]=h.useState(!1),[k,A]=h.useState(!1),j=Re(t,$=>l($)),B=Os(o);return u.jsx(Sk,{scope:n,type:r,dir:B,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:b,scrollbarXEnabled:T,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:E,children:u.jsx(me.div,{dir:B,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});om.displayName=Ml;var sm="ScrollAreaViewport",im=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=an(sm,n),a=h.useRef(null),l=Re(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(me.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});im.displayName=sm;var En="ScrollAreaScrollbar",Rl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,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"?u.jsx(Ck,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Tk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(am,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ol,{...r,ref:t}):null});Rl.displayName=En;var Ck=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ft,{present:n||s,children:u.jsx(am,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Tk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=yk("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 c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ft,{present:n||a!=="hidden",children:u.jsx(Ol,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),am=h.forwardRef((e,t)=>{const n=an(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Hr(n.viewport,l),Hr(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(Ol,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ol=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=an(En,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=fm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return jk(m,i.current,a,f)}return n==="horizontal"?u.jsx(kk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=pm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(Ek,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=pm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),kk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Re(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cm,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),mm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),Ek=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Re(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cm,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),mm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[Ik,lm]=rm(En),cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=an(En,n),[b,g]=h.useState(null),v=Re(t,j=>g(j)),y=h.useRef(null),w=h.useRef(""),C=f.viewport,E=r.content-r.viewport,T=xt(d),S=xt(l),k=ri(p,10);function A(j){if(y.current){const B=j.clientX-y.current.left,$=j.clientY-y.current.top;c({x:B,y:$})}}return h.useEffect(()=>{const j=B=>{const $=B.target;(b==null?void 0:b.contains($))&&T(B,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[C,b,E,T]),h.useEffect(S,[r,S]),Hr(b,k),Hr(f.content,k),u.jsx(Ik,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:xt(s),onThumbPointerUp:xt(i),onThumbPositionChange:S,onThumbPointerDown:xt(a),children:u.jsx(me.div,{...m,ref:v,style:{position:"absolute",...m.style},onPointerDown:le(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=b.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:le(e.onPointerMove,A),onPointerUp:le(e.onPointerUp,j=>{const B=j.target;B.hasPointerCapture(j.pointerId)&&B.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",um=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=lm(ei,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(Nk,{ref:t,...r})})}),Nk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(ei,n),i=lm(ei,n),{onThumbPositionChange:a}=i,l=Re(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=ri(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=Pk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:le(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),b=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:b,y:g})}),onPointerUp:le(e.onPointerUp,i.onThumbPointerUp)})});um.displayName=ei;var Dl="ScrollAreaCorner",dm=h.forwardRef((e,t)=>{const n=an(Dl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Ak,{...e,ref:t}):null});dm.displayName=Dl;var Ak=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=an(Dl,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Hr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Hr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.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 ti(e){return e?parseInt(e,10):0}function fm(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=fm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function jk(e,t,n,r="ltr"){const o=ni(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return hm([l,c],p)(e)}function pm(e,t,n="ltr"){const r=ni(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=_l(e,l);return hm([0,i],[0,a])(c)}function hm(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 mm(e,t){return e>0&&e<t}var Pk=(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 ri(e,t){const n=xt(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 Hr(e,t){const n=xt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var gm=om,_k=im,Mk=dm;const Ll=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(_k,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(vm,{}),u.jsx(Mk,{})]}));Ll.displayName=gm.displayName;const vm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Rl,{ref:r,orientation:t,className:oe("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(um,{className:"relative flex-1 rounded-full bg-border"})}));vm.displayName=Rl.displayName;const $l=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:oe("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}));$l.displayName="Input";const Rk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Ok="bg-slate-700 border-slate-600 hover:bg-slate-600",Dk="bg-slate-600 border-slate-500";function Fl({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:b,secondaryLine:g,itemClassName:v,activeItemClassName:y}){var T;const w=n===e.threadId,C=t?`${y??Dk}`:`${v??Ok}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${Rk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx($l,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(et,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:b(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)}),((T=e.project)==null?void 0:T.name)&&u.jsx("span",{className:"flex items-center gap-1.5 before:content-['•'] before:text-gray-300 dark:before:text-slate-600",children:u.jsx("span",{className:"truncate max-w-[100px]",children:e.project.name})})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(et,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(Ao,{align:"end",sideOffset:6,className:"w-44",style:{zIndex:9999},children:[u.jsxs(Kn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Kn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Kn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}var oi="Collapsible",[Lk,VN]=nn(oi),[$k,Bl]=Lk(oi),xm=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,c]=In({prop:r,defaultProp:o??!1,onChange:i,caller:oi});return u.jsx($k,{scope:n,disabled:s,contentId:jt(),open:l,onOpenToggle:h.useCallback(()=>c(d=>!d),[c]),children:u.jsx(me.div,{"data-state":Hl(l),"data-disabled":s?"":void 0,...a,ref:t})})});xm.displayName=oi;var bm="CollapsibleTrigger",wm=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Bl(bm,n);return u.jsx(me.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Hl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:le(e.onClick,o.onOpenToggle)})});wm.displayName=bm;var zl="CollapsibleContent",ym=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bl(zl,e.__scopeCollapsible);return u.jsx(Ft,{present:n||o.open,children:({present:s})=>u.jsx(Fk,{...r,ref:t,present:s})})});ym.displayName=zl;var Fk=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Bl(zl,n),[a,l]=h.useState(r),c=h.useRef(null),d=Re(t,c),p=h.useRef(0),m=p.current,f=h.useRef(0),b=f.current,g=i.open||a,v=h.useRef(g),y=h.useRef(void 0);return h.useEffect(()=>{const w=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(w)},[]),It(()=>{const w=c.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();p.current=C.height,f.current=C.width,v.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(me.div,{"data-state":Hl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...s,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:g&&o})});function Hl(e){return e?"open":"closed"}var Bk=xm;const zk=Bk,Hk=wm,Uk=ym,Sm=25,Cm="thread-manager-view",Wk=e=>e==="default"||e==="shared",Vk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Cm);if(Wk(e))return e}catch{}return null};function Tm({defaultView:e}={}){const[t,n]=x.useState(()=>Vk()??e??"default");x.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Cm,t)}catch{}},[t]);const r=x.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Kk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function si({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:b,viewState:g,showHeader:v=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:C,groupBy:E}){const{chatApi:T,authApi:S}=On(),{threads:k,sharedThreads:A,currentThreadId:j,setCurrentThreadId:B,isLoading:$,isLoadingSharedThreads:z,actions:G,shareInFlight:M,shareStatus:F,clearShareStatus:V}=yr(),{createThread:K,deleteThread:R,renameThread:I,shareThread:U}=G,{loadThread:J}=no(),O=i??j,[Y,L]=x.useState(Array.isArray(k)?k:[]),D=x.useRef(Y.length>0),X=x.useRef(null),_=x.useRef(0),[P,W]=x.useState(null),[Z,se]=x.useState(""),[ae,Se]=x.useState(!1),[Ce,Oe]=x.useState(!1),[Fe,Be]=x.useState(null),[Ke,ze]=x.useState(""),[dt,pt]=x.useState([]),[Ze,He]=x.useState(!1);x.useEffect(()=>{Ce&&!y&&dt.length===0&&!Ze&&(async()=>{He(!0);try{const he=(await S.listUsers()).filter(de=>de.id||de.user_id).map(de=>({type:"user",value:de.user_id||de.id||"",id:de.user_id||de.id||"",label:de.name||de.username||de.email||"Unknown User",secondaryLabel:de.name||de.username?de.email:void 0}));pt(he)}catch(ee){console.error("Failed to load users for sharing:",ee)}finally{He(!1)}})()},[Ce,y,dt.length,Ze,T]);const Me=y??dt,qe=w??Ze,Ae=b&&b.length>0?b:Kk,Ge=Tm({defaultView:m}),Xe=g??Ge,Ct=p??Xe.view,Qe=x.useCallback(Q=>{p||Xe.setView(Q),f==null||f(Q)},[p,f,Xe]),Tt=Ae.find(Q=>Q.key===Ct)??Ae[0],ht=Q=>{Be(Q),ze(""),Oe(!0)},wt=()=>{Oe(!1),Be(null),ze(""),V()},At=x.useCallback(async Q=>{if(!(!Fe||M)&&Q.id)try{await U(Fe,Q.id),setTimeout(()=>wt(),600)}catch(ee){console.error("Failed to share thread:",ee)}},[wt,M,Fe,U]),Pt=x.useMemo(()=>{const Q=Me,ee=Ke.trim().toLowerCase();return ee?C?Q.filter(he=>C(he,ee)):Q.filter(he=>`${he.label} ${he.secondaryLabel??""}`.toLowerCase().includes(ee)):Q},[y,Ke,C]),mt=Ct==="shared",gt=mt?A:Y,Ht=x.useMemo(()=>{if(!E||mt)return null;const Q={},ee="Default";return gt.forEach(he=>{var Ie,N;let de=ee;E==="project"?de=((Ie=he.project)==null?void 0:Ie.name)||((N=he.project)==null?void 0:N.id)||ee:de=he[E]||ee,Q[de]||(Q[de]=[]),Q[de].push(he)}),Object.keys(Q).forEach(he=>{Q[he].sort((de,Ie)=>new Date(Ie.updatedAt||Ie.createdAt||"").getTime()-new Date(de.updatedAt||de.createdAt||"").getTime())}),Q},[gt,E,mt]),Ve=mt?z:$,$e=mt?"No shared conversations yet":"No conversations yet",ft=Q=>{const ee=Q.sharedAt?` • ${nt(Q.sharedAt)}`:"";return`Shared by ${Q.sharedByUserId}${ee}`},kt=Q=>"sharedByUserId"in Q;x.useEffect(()=>{const Q=Array.isArray(k)?k:[];if(Q.length>0){D.current=!0,L(Q);return}$||(D.current=!1,L(Q))},[k,$]),x.useEffect(()=>{if(!X.current)return;const Q=X.current.querySelector("[data-radix-scroll-area-viewport]");if(!Q)return;let ee=null,he=null;return ee=requestAnimationFrame(()=>{he=requestAnimationFrame(()=>{Q.scrollTop=_.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),he!==null&&cancelAnimationFrame(he)}},[Y]);const ct=async Q=>{try{B(Q),await J(Q),a==null||a(Q),l==null||l(Q)}catch(ee){console.error("Failed to select thread:",ee)}},_t=async()=>{try{Se(!0);const Q=await K();Q&&(c==null||c(Q),a==null||a(Q))}catch(Q){console.error("Failed to create thread:",Q)}finally{Se(!1)}},xe=async(Q,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(X.current){const he=X.current.querySelector("[data-radix-scroll-area-viewport]");he&&(_.current=he.scrollTop)}try{await R(Q),d==null||d(Q)}catch(he){console.error("Failed to delete thread:",he)}}},Le=(Q,ee)=>{ee.stopPropagation(),W(Q.threadId),se(Q.title||`Thread ${Q.threadId.slice(0,8)}`)},Ue=async Q=>{if(Z.trim())try{await I(Q,Z.trim()),W(null),se("")}catch(ee){console.error("Failed to update title:",ee)}},st=()=>{W(null),se("")},nt=Q=>{if(!Q)return"";try{const ee=Q.endsWith("Z")||Q.includes("+")?Q:`${Q}Z`,he=new Date(ee),Ie=new Date().getTime()-he.getTime(),N=Math.floor(Ie/(1e3*60*60*24));return N===0?he.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):N===1?"Yesterday":N<7?`${N} days ago`:he.toLocaleDateString()}catch{return""}},ut=Q=>Q.title||`Thread ${Q.threadId.slice(0,8)}`,tt=Q=>{const ee=ut(Q);return ee.length<=Sm?ee:`${ee.slice(0,Sm)}...`};return u.jsxs("div",{className:`thread-manager-root flex flex-col h-full ${e} ${s.container||""}`,children:[v&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(et,{onClick:_t,disabled:ae||$,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:ae?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(et,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:Tt.label})}),u.jsx(Ao,{align:"start",sideOffset:6,className:"w-40",children:Ae.map(Q=>u.jsxs(Kn,{className:"justify-between text-[12px]",onClick:ee=>{ee.preventDefault(),Qe(Q.key)},children:[u.jsx("span",{children:Q.label}),Ct===Q.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Q.key))})]})]})]}),u.jsx(Ll,{ref:X,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Ve?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):gt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:$e})]}):Ht?Object.entries(Ht).sort(([Q],[ee])=>{const he="Default";return Q===he?1:ee===he?-1:Q.localeCompare(ee)}).map(([Q,ee])=>u.jsxs(zk,{defaultOpen:!0,className:"group/collapsible",children:[u.jsxs(Hk,{className:"flex items-center w-full px-2 py-1 text-xs font-medium text-slate-500 hover:text-slate-800 dark:hover:text-slate-200",children:[u.jsx(ue.ChevronRight,{className:"w-3 h-3 mr-1 transition-transform group-data-[state=open]/collapsible:rotate-90"}),Q,u.jsx("span",{className:"ml-auto text-[10px] text-slate-400",children:ee.length})]}),u.jsx(Uk,{children:u.jsx("div",{className:"pl-2 border-l border-slate-100 dark:border-slate-800 ml-1.5 my-1 space-y-1",children:ee.map(he=>u.jsx(Fl,{thread:he,isActive:O===he.threadId,editingThreadId:P,editingTitle:Z,onSelect:ct,onStartEditing:Le,onEditingTitleChange:de=>se(de),onSaveEditing:Ue,onCancelEditing:st,onShare:()=>ht(he.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:nt,getDisplayThreadTitle:tt,itemClassName:s.threadItem,activeItemClassName:s.activeThread},he.threadId))})})]},Q)):gt.slice().sort((Q,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(Q.updatedAt||Q.createdAt||"").getTime()).map(Q=>u.jsx(Fl,{thread:Q,isActive:O===Q.threadId,editingThreadId:P,editingTitle:Z,onSelect:ct,onStartEditing:Le,onEditingTitleChange:ee=>se(ee),onSaveEditing:Ue,onCancelEditing:st,onShare:()=>ht(Q.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:nt,getDisplayThreadTitle:tt,secondaryLine:mt&&kt(Q)?ft(Q):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Q.threadId))})}),u.jsx(la,{open:Ce,onOpenChange:Q=>!Q&&wt(),children:u.jsxs(cs,{className:"max-w-md p-0",children:[u.jsx(us,{children:u.jsx(ds,{children:"Share thread"})}),u.jsxs(El,{children:[u.jsx(Il,{autoFocus:!0,value:Ke,onValueChange:Q=>ze(Q),placeholder:"Search for recipients..."}),u.jsxs(Nl,{children:[F&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[M&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:F.startsWith("Failed")?"text-red-500":F.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:F})]}),u.jsx(Al,{children:qe?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Pt.length>0&&u.jsx(jl,{heading:"Recipients",children:Pt.map(Q=>u.jsx(Pl,{onSelect:()=>At(Q),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Q.label}),Q.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Q.secondaryLabel})]})},Q.id))})]})]})]})})]})}function qk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},payloadExtras:s={},...i}){const a=d=>{const p="h-full";switch(d){case"phone":return`${p} max-w-none`;case"tablet":return`${p} max-w-4xl mx-auto`;case"half-screen":return`${p} max-w-2xl`;case"desktop":default:return`${p} max-w-7xl mx-auto`}},l=d=>({"--chat-sidebar-width":d==="phone"?"100%":d==="tablet"?"280px":d==="half-screen"?"240px":"320px","--chat-message-max-width":d==="phone"?"95%":d==="tablet"?"90%":d==="half-screen"?"85%":"80%","--chat-input-height":d==="phone"?"120px":"100px"}),c=x.useCallback(d=>{var p;(p=i.onThreadChange)==null||p.call(i,d)},[i]);return e==="fullscreen"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(t),children:u.jsx(Fr,{className:"flex-1",onError:i.onError,enableFileUpload:!0,payloadExtras:s})})}):e==="tabs"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(si,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}):u.jsx(Tr,{...i,onThreadChange:c,children:u.jsxs("div",{className:`${a(t)} flex overflow-hidden ${r} ${o.container||""}`,style:l(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(si,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}function Gk({apiConfig:e,className:t="",onError:n}){return u.jsx(Tr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Fr,{})})})}function Yk({placeholder:e,onMessageSent:t}){const[n,r]=x.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Fr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(si,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Xk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=x.useState(!1);return n?u.jsx(Tr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(et,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(et,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(et,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Yk,{placeholder:t,onMessageSent:r})})]})})}):null}function Jk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(et,{variant:r,size:o,className:oe("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var Zk="Label",km=h.forwardRef((e,t)=>u.jsx(me.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())}}));km.displayName=Zk;var Em=km;const Qk=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Im=h.forwardRef(({className:e,...t},n)=>u.jsx(Em,{ref:n,className:oe(Qk(),e),...t}));Im.displayName=Em.displayName;function Nm(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 Am=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"}),eE="VisuallyHidden",ii=h.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...Am,...e.style}}));ii.displayName=eE;var tE=ii,nE=[" ","Enter","ArrowUp","ArrowDown"],rE=[" ","Enter"],mr="Select",[ai,li,oE]=Rs(mr),[Ur,KN]=nn(mr,[oE,$r]),ci=$r(),[sE,Gn]=Ur(mr),[iE,aE]=Ur(mr),jm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:b}=e,g=ci(t),[v,y]=h.useState(null),[w,C]=h.useState(null),[E,T]=h.useState(!1),S=Os(c),[k,A]=In({prop:r,defaultProp:o??!1,onChange:s,caller:mr}),[j,B]=In({prop:i,defaultProp:a,onChange:l,caller:mr}),$=h.useRef(null),z=v?b||!!v.closest("form"):!0,[G,M]=h.useState(new Set),F=Array.from(G).map(V=>V.props.value).join(";");return u.jsx(sl,{...g,children:u.jsxs(sE,{required:f,scope:t,trigger:v,onTriggerChange:y,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:jt(),value:j,onValueChange:B,open:k,onOpenChange:A,dir:S,triggerPointerDownPosRef:$,disabled:m,children:[u.jsx(ai.Provider,{scope:t,children:u.jsx(iE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(V=>{M(K=>new Set(K).add(V))},[]),onNativeOptionRemove:h.useCallback(V=>{M(K=>{const R=new Set(K);return R.delete(V),R})},[]),children:n})}),z?u.jsxs(eg,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:j,onChange:V=>B(V.target.value),disabled:m,form:b,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},F):null]})})};jm.displayName=mr;var Pm="SelectTrigger",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ci(n),i=Gn(Pm,n),a=i.disabled||r,l=Re(t,i.onTriggerChange),c=li(n),d=h.useRef("touch"),[p,m,f]=ng(g=>{const v=c().filter(C=>!C.disabled),y=v.find(C=>C.value===i.value),w=rg(v,g,y);w!==void 0&&i.onValueChange(w.value)}),b=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(il,{asChild:!0,...s,children:u.jsx(me.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":tg(i.value)?"":void 0,...o,ref:l,onClick:le(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&b(g)}),onPointerDown:le(o.onPointerDown,g=>{d.current=g.pointerType;const v=g.target;v.hasPointerCapture(g.pointerId)&&v.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(b(g),g.preventDefault())}),onKeyDown:le(o.onKeyDown,g=>{const v=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(v&&g.key===" ")&&nE.includes(g.key)&&(b(),g.preventDefault())})})})});_m.displayName=Pm;var Mm="SelectValue",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(Mm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Re(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:p,style:{pointerEvents:"none"},children:tg(l.value)?u.jsx(u.Fragment,{children:i}):s})});Rm.displayName=Mm;var lE="SelectIcon",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Om.displayName=lE;var cE="SelectPortal",Dm=e=>u.jsx(oo,{asChild:!0,...e});Dm.displayName=cE;var gr="SelectContent",Lm=h.forwardRef((e,t)=>{const n=Gn(gr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(u.jsx($m,{scope:e.__scopeSelect,children:u.jsx(ai.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Fm,{...e,ref:t})});Lm.displayName=gr;var mn=10,[$m,Yn]=Ur(gr),uE="SelectContentImpl",dE=Jt.createSlot("SelectContent.RemoveScroll"),Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:b,hideWhenDetached:g,avoidCollisions:v,...y}=e,w=Gn(gr,n),[C,E]=h.useState(null),[T,S]=h.useState(null),k=Re(t,_=>E(_)),[A,j]=h.useState(null),[B,$]=h.useState(null),z=li(n),[G,M]=h.useState(!1),F=h.useRef(!1);h.useEffect(()=>{if(C)return na(C)},[C]),Xi();const V=h.useCallback(_=>{const[P,...W]=z().map(ae=>ae.ref.current),[Z]=W.slice(-1),se=document.activeElement;for(const ae of _)if(ae===se||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===P&&T&&(T.scrollTop=0),ae===Z&&T&&(T.scrollTop=T.scrollHeight),ae==null||ae.focus(),document.activeElement!==se))return},[z,T]),K=h.useCallback(()=>V([A,C]),[V,A,C]);h.useEffect(()=>{G&&K()},[G,K]);const{onOpenChange:R,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(C){let _={x:0,y:0};const P=Z=>{var se,ae;_={x:Math.abs(Math.round(Z.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ae=I.current)==null?void 0:ae.y)??0))}},W=Z=>{_.x<=10&&_.y<=10?Z.preventDefault():C.contains(Z.target)||R(!1),document.removeEventListener("pointermove",P),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",P),document.addEventListener("pointerup",W,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",W,{capture:!0})}}},[C,R,I]),h.useEffect(()=>{const _=()=>R(!1);return window.addEventListener("blur",_),window.addEventListener("resize",_),()=>{window.removeEventListener("blur",_),window.removeEventListener("resize",_)}},[R]);const[U,J]=ng(_=>{const P=z().filter(se=>!se.disabled),W=P.find(se=>se.ref.current===document.activeElement),Z=rg(P,_,W);Z&&setTimeout(()=>Z.ref.current.focus())}),O=h.useCallback((_,P,W)=>{const Z=!F.current&&!W;(w.value!==void 0&&w.value===P||Z)&&(j(_),Z&&(F.current=!0))},[w.value]),Y=h.useCallback(()=>C==null?void 0:C.focus(),[C]),L=h.useCallback((_,P,W)=>{const Z=!F.current&&!W;(w.value!==void 0&&w.value===P||Z)&&$(_)},[w.value]),D=r==="popper"?Ul:Bm,X=D===Ul?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:b,hideWhenDetached:g,avoidCollisions:v}:{};return u.jsx($m,{scope:n,content:C,viewport:T,onViewportChange:S,itemRefCallback:O,selectedItem:A,onItemLeave:Y,itemTextRefCallback:L,focusSelectedItem:K,selectedItemText:B,position:r,isPositioned:G,searchRef:U,children:u.jsx(rs,{as:dE,allowPinchZoom:!0,children:u.jsx(Xo,{asChild:!0,trapped:w.open,onMountAutoFocus:_=>{_.preventDefault()},onUnmountAutoFocus:le(o,_=>{var P;(P=w.trigger)==null||P.focus({preventScroll:!0}),_.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:_=>_.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(D,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:_=>_.preventDefault(),...y,...X,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:le(y.onKeyDown,_=>{const P=_.ctrlKey||_.altKey||_.metaKey;if(_.key==="Tab"&&_.preventDefault(),!P&&_.key.length===1&&J(_.key),["ArrowUp","ArrowDown","Home","End"].includes(_.key)){let Z=z().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(_.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(_.key)){const se=_.target,ae=Z.indexOf(se);Z=Z.slice(ae+1)}setTimeout(()=>V(Z)),_.preventDefault()}})})})})})})});Fm.displayName=uE;var fE="SelectItemAlignedPosition",Bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(gr,n),i=Yn(gr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=Re(t,k=>d(k)),m=li(n),f=h.useRef(!1),b=h.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:y,focusSelectedItem:w}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&v&&y){const k=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),B=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=B.left-A.left,ae=j.left-se,Se=k.left-ae,Ce=k.width+Se,Oe=Math.max(Ce,A.width),Fe=window.innerWidth-mn,Be=_l(ae,[mn,Math.max(mn,Fe-Oe)]);a.style.minWidth=Ce+"px",a.style.left=Be+"px"}else{const se=A.right-B.right,ae=window.innerWidth-j.right-se,Se=window.innerWidth-k.right-ae,Ce=k.width+Se,Oe=Math.max(Ce,A.width),Fe=window.innerWidth-mn,Be=_l(ae,[mn,Math.max(mn,Fe-Oe)]);a.style.minWidth=Ce+"px",a.style.right=Be+"px"}const $=m(),z=window.innerHeight-mn*2,G=g.scrollHeight,M=window.getComputedStyle(c),F=parseInt(M.borderTopWidth,10),V=parseInt(M.paddingTop,10),K=parseInt(M.borderBottomWidth,10),R=parseInt(M.paddingBottom,10),I=F+V+G+R+K,U=Math.min(v.offsetHeight*5,I),J=window.getComputedStyle(g),O=parseInt(J.paddingTop,10),Y=parseInt(J.paddingBottom,10),L=k.top+k.height/2-mn,D=z-L,X=v.offsetHeight/2,_=v.offsetTop+X,P=F+V+_,W=I-P;if(P<=L){const se=$.length>0&&v===$[$.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max(D,X+(se?Y:0)+ae+K),Ce=P+Se;a.style.height=Ce+"px"}else{const se=$.length>0&&v===$[0].ref.current;a.style.top="0px";const Se=Math.max(L,F+g.offsetTop+(se?O:0)+X)+W;a.style.height=Se+"px",g.scrollTop=P-L+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,v,y,s.dir,r]);It(()=>C(),[C]);const[E,T]=h.useState();It(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const S=h.useCallback(k=>{k&&b.current===!0&&(C(),w==null||w(),b.current=!1)},[C,w]);return u.jsx(hE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:S,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:u.jsx(me.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Bm.displayName=fE;var pE="SelectPopperPosition",Ul=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ci(n);return u.jsx(al,{...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)"}})});Ul.displayName=pE;var[hE,Wl]=Ur(gr,{}),Vl="SelectViewport",zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Vl,n),i=Wl(Vl,n),a=Re(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ai.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:le(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const b=window.innerHeight-mn*2,g=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),y=Math.max(g,v);if(y<b){const w=y+f,C=Math.min(b,w),E=w-C;p.style.height=C+"px",p.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});zm.displayName=Vl;var Hm="SelectGroup",[mE,gE]=Ur(Hm),vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jt();return u.jsx(mE,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vE.displayName=Hm;var Um="SelectLabel",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=gE(Um,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});Wm.displayName=Um;var ui="SelectItem",[xE,Vm]=Ur(ui),Km=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ui,n),l=Yn(ui,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),b=Re(t,w=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,w,r,o)}),g=jt(),v=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(xE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{p(C=>C||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ai.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:le(i.onFocus,()=>f(!0)),onBlur:le(i.onBlur,()=>f(!1)),onClick:le(i.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:le(i.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:le(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:le(i.onPointerMove,w=>{var C;v.current=w.pointerType,o?(C=l.onItemLeave)==null||C.call(l):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:le(i.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:le(i.onKeyDown,w=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(rE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Km.displayName=ui;var _o="SelectItemText",qm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(_o,n),a=Yn(_o,n),l=Vm(_o,n),c=aE(_o,n),[d,p]=h.useState(null),m=Re(t,y=>p(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,b=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=c;return It(()=>(g(b),()=>v(b)),[g,v,b]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});qm.displayName=_o;var Gm="SelectItemIndicator",Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Vm(Gm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Ym.displayName=Gm;var Kl="SelectScrollUpButton",Xm=h.forwardRef((e,t)=>{const n=Yn(Kl,e.__scopeSelect),r=Wl(Kl,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Zm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Xm.displayName=Kl;var ql="SelectScrollDownButton",Jm=h.forwardRef((e,t)=>{const n=Yn(ql,e.__scopeSelect),r=Wl(ql,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Zm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Jm.displayName=ql;var Zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=h.useRef(null),a=li(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:le(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:le(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:le(o.onPointerLeave,()=>{l()})})}),bE="SelectSeparator",Qm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Qm.displayName=bE;var Gl="SelectArrow",wE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ci(n),s=Gn(Gl,n),i=Yn(Gl,n);return s.open&&i.position==="popper"?u.jsx(ll,{...o,...r,ref:t}):null});wE.displayName=Gl;var yE="SelectBubbleInput",eg=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Re(r,o),i=Nm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(me.select,{...n,style:{...Am,...n.style},ref:s,defaultValue:t})});eg.displayName=yE;function tg(e){return e===""||e===void 0}function ng(e){const t=xt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function rg(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=SE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function SE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var CE=jm,og=_m,TE=Rm,kE=Om,EE=Dm,sg=Lm,IE=zm,ig=Wm,ag=Km,NE=qm,AE=Ym,lg=Xm,cg=Jm,ug=Qm;const jE=CE,PE=TE,dg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(og,{ref:r,className:oe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(kE,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));dg.displayName=og.displayName;const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(lg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));fg.displayName=lg.displayName;const pg=h.forwardRef(({className:e,...t},n)=>u.jsx(cg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));pg.displayName=cg.displayName;const hg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(EE,{children:u.jsxs(sg,{ref:o,className:oe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(fg,{}),u.jsx(IE,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(pg,{})]})}));hg.displayName=sg.displayName;const _E=h.forwardRef(({className:e,...t},n)=>u.jsx(ig,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));_E.displayName=ig.displayName;const mg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ag,{ref:r,className:oe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(AE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(NE,{children:t})]}));mg.displayName=ag.displayName;const ME=h.forwardRef(({className:e,...t},n)=>u.jsx(ug,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));ME.displayName=ug.displayName;var RE="Separator",gg="horizontal",OE=["horizontal","vertical"],vg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=gg,...o}=e,s=DE(r)?r:gg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});vg.displayName=RE;function DE(e){return OE.includes(e)}var xg=vg;const bg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(xg,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));bg.displayName=xg.displayName;var di="Switch",[LE,qN]=nn(di),[$E,FE]=LE(di),wg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),b=Re(t,C=>f(C)),g=h.useRef(!1),v=m?d||!!m.closest("form"):!0,[y,w]=In({prop:o,defaultProp:s??!1,onChange:c,caller:di});return u.jsxs($E,{scope:n,checked:y,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Tg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:b,onClick:le(e.onClick,C=>{w(E=>!E),v&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),v&&u.jsx(Cg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});wg.displayName=di;var yg="SwitchThumb",Sg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=FE(yg,n);return u.jsx(me.span,{"data-state":Tg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Sg.displayName=yg;var BE="SwitchBubbleInput",Cg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Re(i,s),l=Nm(n),c=Mp(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const b=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(b)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Cg.displayName=BE;function Tg(e){return e?"checked":"unchecked"}var kg=wg,zE=Sg;const Eg=h.forwardRef(({className:e,...t},n)=>u.jsx(kg,{className:oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(zE,{className:oe("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")})}));Eg.displayName=kg.displayName;const HE=ia,UE=Vw,WE=aa,Ig=h.forwardRef(({className:e,...t},n)=>u.jsx(so,{className:oe("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}));Ig.displayName=so.displayName;const VE=Kr.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"}}),Ng=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(WE,{children:[u.jsx(Ig,{}),u.jsxs(io,{ref:o,className:oe(VE({side:e}),t),...r,children:[n,u.jsxs(Od,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ng.displayName=io.displayName;const Ag=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ag.displayName="SheetHeader";const jg=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));jg.displayName=or.displayName;const Pg=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Pg.displayName=ls.displayName;var[fi,GN]=nn("Tooltip",[$r]),pi=$r(),_g="TooltipProvider",KE=700,Yl="tooltip.open",[qE,Xl]=fi(_g),Mg=e=>{const{__scopeTooltip:t,delayDuration:n=KE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(qE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Mg.displayName=_g;var Mo="Tooltip",[GE,hi]=fi(Mo),Rg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Xl(Mo,e.__scopeTooltip),c=pi(t),[d,p]=h.useState(null),m=jt(),f=h.useRef(0),b=i??l.disableHoverableContent,g=a??l.delayDuration,v=h.useRef(!1),[y,w]=In({prop:r,defaultProp:o??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(Yl))):l.onClose(),s==null||s(k)},caller:Mo}),C=h.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,v.current=!1,w(!0)},[w]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),S=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{v.current=!0,w(!0),f.current=0},g)},[g,w]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(sl,{...c,children:u.jsx(GE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?S():E()},[l.isOpenDelayedRef,S,E]),onTriggerLeave:h.useCallback(()=>{b?T():(window.clearTimeout(f.current),f.current=0)},[T,b]),onOpen:E,onClose:T,disableHoverableContent:b,children:n})})};Rg.displayName=Mo;var Jl="TooltipTrigger",Og=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(Jl,n),s=Xl(Jl,n),i=pi(n),a=h.useRef(null),l=Re(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(il,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:le(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:le(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:le(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:le(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:le(e.onBlur,o.onClose),onClick:le(e.onClick,o.onClose)})})});Og.displayName=Jl;var YE="TooltipPortal",[YN,XE]=fi(YE,{forceMount:void 0}),Wr="TooltipContent",Dg=h.forwardRef((e,t)=>{const n=XE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Wr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Lg,{side:o,...s,ref:t}):u.jsx(JE,{side:o,...s,ref:t})})}),JE=h.forwardRef((e,t)=>{const n=hi(Wr,e.__scopeTooltip),r=Xl(Wr,e.__scopeTooltip),o=h.useRef(null),s=Re(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((b,g)=>{const v=b.currentTarget,y={x:b.clientX,y:b.clientY},w=nI(y,v.getBoundingClientRect()),C=rI(y,w),E=oI(g.getBoundingClientRect()),T=iI([...C,...E]);a(T),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const b=v=>f(v,d),g=v=>f(v,l);return l.addEventListener("pointerleave",b),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",b),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const b=g=>{const v=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(v))||(d==null?void 0:d.contains(v)),C=!sI(y,i);w?m():C&&(m(),c())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[l,d,i,c,m]),u.jsx(Lg,{...e,ref:s})}),[ZE,QE]=fi(Mo,{isInside:!1}),eI=Jt.createSlottable("TooltipContent"),Lg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=hi(Wr,n),c=pi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Yl,d),()=>document.removeEventListener(Yl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(al,{"data-state":l.stateAttribute,...c,...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:[u.jsx(eI,{children:r}),u.jsx(ZE,{scope:n,isInside:!0,children:u.jsx(tE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Dg.displayName=Wr;var $g="TooltipArrow",tI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=pi(n);return QE($g,n).isInside?null:u.jsx(ll,{...o,...r,ref:t})});tI.displayName=$g;function nI(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 rI(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 oI(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 sI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function iI(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),aI(t)}function aI(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 lI=Mg,cI=Rg,uI=Og,Fg=Dg;const dI=lI,fI=cI,pI=uI,Bg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Fg,{ref:r,sideOffset:t,className:oe("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}));Bg.displayName=Fg.displayName;var Zl="ToastProvider",[Ql,hI,mI]=Rs("Toast"),[zg,XN]=nn("Toast",[mI]),[gI,mi]=zg(Zl),Hg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Zl}\`. Expected non-empty \`string\`.`),u.jsx(Ql.Provider,{scope:t,children:u.jsx(gI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Hg.displayName=Zl;var Ug="ToastViewport",vI=["F8"],ec="toast.viewportPause",tc="toast.viewportResume",Wg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=vI,label:o="Notifications ({hotkey})",...s}=e,i=mi(Ug,n),a=hI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Re(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=i.toastCount>0;h.useEffect(()=>{const v=y=>{var C;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((C=p.current)==null||C.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r]),h.useEffect(()=>{const v=l.current,y=p.current;if(b&&v&&y){const w=()=>{if(!i.isClosePausedRef.current){const S=new CustomEvent(ec);y.dispatchEvent(S),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const S=new CustomEvent(tc);y.dispatchEvent(S),i.isClosePausedRef.current=!1}},E=S=>{!v.contains(S.relatedTarget)&&C()},T=()=>{v.contains(document.activeElement)||C()};return v.addEventListener("focusin",w),v.addEventListener("focusout",E),v.addEventListener("pointermove",w),v.addEventListener("pointerleave",T),window.addEventListener("blur",w),window.addEventListener("focus",C),()=>{v.removeEventListener("focusin",w),v.removeEventListener("focusout",E),v.removeEventListener("pointermove",w),v.removeEventListener("pointerleave",T),window.removeEventListener("blur",w),window.removeEventListener("focus",C)}}},[b,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:v})=>{const w=a().map(C=>{const E=C.ref.current,T=[E,...jI(E)];return v==="forwards"?T:T.reverse()});return(v==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const v=p.current;if(v){const y=w=>{var T,S,k;const C=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!C){const A=document.activeElement,j=w.shiftKey;if(w.target===v&&j){(T=c.current)==null||T.focus();return}const z=g({tabbingDirection:j?"backwards":"forwards"}),G=z.findIndex(M=>M===A);oc(z.slice(G+1))?w.preventDefault():j?(S=c.current)==null||S.focus():(k=d.current)==null||k.focus()}};return v.addEventListener("keydown",y),()=>v.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Fb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&u.jsx(nc,{ref:c,onFocusFromOutsideViewport:()=>{const v=g({tabbingDirection:"forwards"});oc(v)}}),u.jsx(Ql.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),b&&u.jsx(nc,{ref:d,onFocusFromOutsideViewport:()=>{const v=g({tabbingDirection:"backwards"});oc(v)}})]})});Wg.displayName=Ug;var Vg="ToastFocusProxy",nc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=mi(Vg,n);return u.jsx(ii,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});nc.displayName=Vg;var Ro="Toast",xI="toast.swipeStart",bI="toast.swipeMove",wI="toast.swipeCancel",yI="toast.swipeEnd",Kg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=In({prop:r,defaultProp:o??!0,onChange:s,caller:Ro});return u.jsx(Ft,{present:n||a,children:u.jsx(TI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:xt(e.onPause),onResume:xt(e.onResume),onSwipeStart:le(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:le(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:le(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:le(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Kg.displayName=Ro;var[SI,CI]=zg(Ro,{onClose(){}}),TI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...b}=e,g=mi(Ro,n),[v,y]=h.useState(null),w=Re(t,M=>y(M)),C=h.useRef(null),E=h.useRef(null),T=o||g.duration,S=h.useRef(0),k=h.useRef(T),A=h.useRef(0),{onToastAdd:j,onToastRemove:B}=g,$=xt(()=>{var F;(v==null?void 0:v.contains(document.activeElement))&&((F=g.viewport)==null||F.focus()),i()}),z=h.useCallback(M=>{!M||M===1/0||(window.clearTimeout(A.current),S.current=new Date().getTime(),A.current=window.setTimeout($,M))},[$]);h.useEffect(()=>{const M=g.viewport;if(M){const F=()=>{z(k.current),c==null||c()},V=()=>{const K=new Date().getTime()-S.current;k.current=k.current-K,window.clearTimeout(A.current),l==null||l()};return M.addEventListener(ec,V),M.addEventListener(tc,F),()=>{M.removeEventListener(ec,V),M.removeEventListener(tc,F)}}},[g.viewport,T,l,c,z]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&z(T)},[s,T,g.isClosePausedRef,z]),h.useEffect(()=>(j(),()=>B()),[j,B]);const G=h.useMemo(()=>v?Qg(v):null,[v]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(kI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(SI,{scope:n,onClose:$,children:qr.createPortal(u.jsx(Ql.ItemSlot,{scope:n,children:u.jsx($b,{asChild:!0,onEscapeKeyDown:le(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...b,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:le(e.onKeyDown,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:le(e.onPointerDown,M=>{M.button===0&&(C.current={x:M.clientX,y:M.clientY})}),onPointerMove:le(e.onPointerMove,M=>{if(!C.current)return;const F=M.clientX-C.current.x,V=M.clientY-C.current.y,K=!!E.current,R=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=R?I(0,F):0,J=R?0:I(0,V),O=M.pointerType==="touch"?10:2,Y={x:U,y:J},L={originalEvent:M,delta:Y};K?(E.current=Y,gi(bI,p,L,{discrete:!1})):ev(Y,g.swipeDirection,O)?(E.current=Y,gi(xI,d,L,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(F)>O||Math.abs(V)>O)&&(C.current=null)}),onPointerUp:le(e.onPointerUp,M=>{const F=E.current,V=M.target;if(V.hasPointerCapture(M.pointerId)&&V.releasePointerCapture(M.pointerId),E.current=null,C.current=null,F){const K=M.currentTarget,R={originalEvent:M,delta:F};ev(F,g.swipeDirection,g.swipeThreshold)?gi(yI,f,R,{discrete:!0}):gi(wI,m,R,{discrete:!0}),K.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),kI=e=>{const{__scopeToast:t,children:n,...r}=e,o=mi(Ro,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return NI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(oo,{asChild:!0,children:u.jsx(ii,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},EI="ToastTitle",qg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});qg.displayName=EI;var II="ToastDescription",Gg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Gg.displayName=II;var Yg="ToastAction",Xg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Zg,{altText:n,asChild:!0,children:u.jsx(rc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Yg}\`. Expected non-empty \`string\`.`),null)});Xg.displayName=Yg;var Jg="ToastClose",rc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=CI(Jg,n);return u.jsx(Zg,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:le(e.onClick,o.onClose)})})});rc.displayName=Jg;var Zg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(me.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Qg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),AI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Qg(r))}}),t}function gi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Vi(o,s):o.dispatchEvent(s)}var ev=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function NI(e=()=>{}){const t=xt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function AI(e){return e.nodeType===e.ELEMENT_NODE}function jI(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 oc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var PI=Hg,tv=Wg,nv=Kg,rv=qg,ov=Gg,sv=Xg,iv=rc;const _I=PI,av=h.forwardRef(({className:e,...t},n)=>u.jsx(tv,{ref:n,className:oe("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));av.displayName=tv.displayName;const MI=Kr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),lv=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(nv,{ref:r,className:oe(MI({variant:t}),e),...n}));lv.displayName=nv.displayName;const RI=h.forwardRef(({className:e,...t},n)=>u.jsx(sv,{ref:n,className:oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));RI.displayName=sv.displayName;const cv=h.forwardRef(({className:e,...t},n)=>u.jsx(iv,{ref:n,className:oe("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));cv.displayName=iv.displayName;const uv=h.forwardRef(({className:e,...t},n)=>u.jsx(rv,{ref:n,className:oe("text-sm font-semibold",e),...t}));uv.displayName=rv.displayName;const dv=h.forwardRef(({className:e,...t},n)=>u.jsx(ov,{ref:n,className:oe("text-sm opacity-90",e),...t}));dv.displayName=ov.displayName;function OI(){const{toasts:e}=da();return u.jsxs(_I,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(lv,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(uv,{children:n}),r&&u.jsx(dv,{children:r})]}),o,u.jsx(cv,{})]},t)}),u.jsx(av,{})]})}var DI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(b=>{let g=b==="class",v=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...v),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(b,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,b=i&&f==="system"?m():f;d(b)}catch{}},LI=h.createContext(void 0),$I={setTheme:e=>{},themes:[]},FI=()=>{var e;return(e=h.useContext(LI))!=null?e:$I};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${DI.toString()})(${d})`}})});var BI=e=>{switch(e){case"success":return UI;case"info":return VI;case"warning":return WI;case"error":return KI;default:return null}},zI=Array(12).fill(0),HI=({visible:e,className:t})=>x.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},x.createElement("div",{className:"sonner-spinner"},zI.map((n,r)=>x.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),UI=x.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},x.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),WI=x.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},x.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),VI=x.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},x.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),KI=x.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},x.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),qI=x.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},x.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),x.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),GI=()=>{let[e,t]=x.useState(document.hidden);return x.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},sc=1,YI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:sc++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],x.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(JI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||sc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Yt=new YI,XI=(e,t)=>{let n=(t==null?void 0:t.id)||sc++;return Yt.addToast({title:e,...t,id:n}),n},JI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",ZI=XI,QI=()=>Yt.toasts,eN=()=>Yt.getActiveToasts();Object.assign(ZI,{success:Yt.success,info:Yt.info,warning:Yt.warning,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss,loading:Yt.loading},{getHistory:QI,getToasts:eN});function tN(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}tN(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
131
|
-
`);function vi(e){return e.label!==void 0}var nN=3,rN="32px",oN="16px",fv=4e3,sN=356,iN=14,aN=20,lN=200;function gn(...e){return e.filter(Boolean).join(" ")}function cN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var uN=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:b,interacting:g,setHeights:v,visibleToasts:y,heights:w,index:C,toasts:E,expanded:T,removeToast:S,defaultRichColors:k,closeButton:A,style:j,cancelButtonStyle:B,actionButtonStyle:$,className:z="",descriptionClassName:G="",duration:M,position:F,gap:V,loadingIcon:K,expandByDefault:R,classNames:I,icons:U,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:O}=e,[Y,L]=x.useState(null),[D,X]=x.useState(null),[_,P]=x.useState(!1),[W,Z]=x.useState(!1),[se,ae]=x.useState(!1),[Se,Ce]=x.useState(!1),[Oe,Fe]=x.useState(!1),[Be,Ke]=x.useState(0),[ze,dt]=x.useState(0),pt=x.useRef(f.duration||M||fv),Ze=x.useRef(null),He=x.useRef(null),Me=C===0,qe=C+1<=y,Ae=f.type,Ge=f.dismissible!==!1,Xe=f.className||"",Ct=f.descriptionClassName||"",Qe=x.useMemo(()=>w.findIndex(xe=>xe.toastId===f.id)||0,[w,f.id]),Tt=x.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:A},[f.closeButton,A]),ht=x.useMemo(()=>f.duration||M||fv,[f.duration,M]),wt=x.useRef(0),At=x.useRef(0),Pt=x.useRef(0),mt=x.useRef(null),[gt,Ht]=F.split("-"),Ve=x.useMemo(()=>w.reduce((xe,Le,Ue)=>Ue>=Qe?xe:xe+Le.height,0),[w,Qe]),$e=GI(),ft=f.invert||m,kt=Ae==="loading";At.current=x.useMemo(()=>Qe*V+Ve,[Qe,Ve]),x.useEffect(()=>{pt.current=ht},[ht]),x.useEffect(()=>{P(!0)},[]),x.useEffect(()=>{let xe=He.current;if(xe){let Le=xe.getBoundingClientRect().height;return dt(Le),v(Ue=>[{toastId:f.id,height:Le,position:f.position},...Ue]),()=>v(Ue=>Ue.filter(st=>st.toastId!==f.id))}},[v,f.id]),x.useLayoutEffect(()=>{if(!_)return;let xe=He.current,Le=xe.style.height;xe.style.height="auto";let Ue=xe.getBoundingClientRect().height;xe.style.height=Le,dt(Ue),v(st=>st.find(nt=>nt.toastId===f.id)?st.map(nt=>nt.toastId===f.id?{...nt,height:Ue}:nt):[{toastId:f.id,height:Ue,position:f.position},...st])},[_,f.title,f.description,v,f.id]);let ct=x.useCallback(()=>{Z(!0),Ke(At.current),v(xe=>xe.filter(Le=>Le.toastId!==f.id)),setTimeout(()=>{S(f)},lN)},[f,S,v,At]);x.useEffect(()=>{if(f.promise&&Ae==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return T||g||O&&$e?(()=>{if(Pt.current<wt.current){let Le=new Date().getTime()-wt.current;pt.current=pt.current-Le}Pt.current=new Date().getTime()})():pt.current!==1/0&&(wt.current=new Date().getTime(),xe=setTimeout(()=>{var Le;(Le=f.onAutoClose)==null||Le.call(f,f),ct()},pt.current)),()=>clearTimeout(xe)},[T,g,f,Ae,O,$e,ct]),x.useEffect(()=>{f.delete&&ct()},[ct,f.delete]);function _t(){var xe,Le,Ue;return U!=null&&U.loading?x.createElement("div",{className:gn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Ae==="loading"},U.loading):K?x.createElement("div",{className:gn(I==null?void 0:I.loader,(Le=f==null?void 0:f.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":Ae==="loading"},K):x.createElement(HI,{className:gn(I==null?void 0:I.loader,(Ue=f==null?void 0:f.classNames)==null?void 0:Ue.loader),visible:Ae==="loading"})}return x.createElement("li",{tabIndex:0,ref:He,className:gn(z,Xe,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Ae],(n=f==null?void 0:f.classNames)==null?void 0:n[Ae]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:k,"data-styled":!(f.jsx||f.unstyled||b),"data-mounted":_,"data-promise":!!f.promise,"data-swiped":Oe,"data-removed":W,"data-visible":qe,"data-y-position":gt,"data-x-position":Ht,"data-index":C,"data-front":Me,"data-swiping":se,"data-dismissible":Ge,"data-type":Ae,"data-invert":ft,"data-swipe-out":Se,"data-swipe-direction":D,"data-expanded":!!(T||R&&_),style:{"--index":C,"--toasts-before":C,"--z-index":E.length-C,"--offset":`${W?Be:At.current}px`,"--initial-height":R?"auto":`${ze}px`,...j,...f.style},onDragEnd:()=>{ae(!1),L(null),mt.current=null},onPointerDown:xe=>{kt||!Ge||(Ze.current=new Date,Ke(At.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(ae(!0),mt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Le,Ue,st;if(Se||!Ge)return;mt.current=null;let nt=Number(((xe=He.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ut=Number(((Le=He.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),tt=new Date().getTime()-((Ue=Ze.current)==null?void 0:Ue.getTime()),Q=Y==="x"?nt:ut,ee=Math.abs(Q)/tt;if(Math.abs(Q)>=aN||ee>.11){Ke(At.current),(st=f.onDismiss)==null||st.call(f,f),X(Y==="x"?nt>0?"right":"left":ut>0?"down":"up"),ct(),Ce(!0),Fe(!1);return}ae(!1),L(null)},onPointerMove:xe=>{var Le,Ue,st,nt;if(!mt.current||!Ge||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;let ut=xe.clientY-mt.current.y,tt=xe.clientX-mt.current.x,Q=(Ue=e.swipeDirections)!=null?Ue:cN(F);!Y&&(Math.abs(tt)>1||Math.abs(ut)>1)&&L(Math.abs(tt)>Math.abs(ut)?"x":"y");let ee={x:0,y:0};Y==="y"?(Q.includes("top")||Q.includes("bottom"))&&(Q.includes("top")&&ut<0||Q.includes("bottom")&&ut>0)&&(ee.y=ut):Y==="x"&&(Q.includes("left")||Q.includes("right"))&&(Q.includes("left")&&tt<0||Q.includes("right")&&tt>0)&&(ee.x=tt),(Math.abs(ee.x)>0||Math.abs(ee.y)>0)&&Fe(!0),(st=He.current)==null||st.style.setProperty("--swipe-amount-x",`${ee.x}px`),(nt=He.current)==null||nt.style.setProperty("--swipe-amount-y",`${ee.y}px`)}},Tt&&!f.jsx?x.createElement("button",{"aria-label":J,"data-disabled":kt,"data-close-button":!0,onClick:kt||!Ge?()=>{}:()=>{var xe;ct(),(xe=f.onDismiss)==null||xe.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=U==null?void 0:U.close)!=null?s:qI):null,f.jsx||x.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:x.createElement(x.Fragment,null,Ae||f.icon||f.promise?x.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||_t():null,f.type!=="loading"?f.icon||(U==null?void 0:U[Ae])||BI(Ae):null):null,x.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},x.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?x.createElement("div",{"data-description":"",className:gn(G,Ct,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),x.isValidElement(f.cancel)?f.cancel:f.cancel&&vi(f.cancel)?x.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||B,onClick:xe=>{var Le,Ue;vi(f.cancel)&&Ge&&((Ue=(Le=f.cancel).onClick)==null||Ue.call(Le,xe),ct())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,x.isValidElement(f.action)?f.action:f.action&&vi(f.action)?x.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||$,onClick:xe=>{var Le,Ue;vi(f.action)&&((Ue=(Le=f.action).onClick)==null||Ue.call(Le,xe),!xe.defaultPrevented&&ct())},className:gn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function pv(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function dN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?oN:rN;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var fN=x.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:b=nN,toastOptions:g,dir:v=pv(),gap:y=iN,loadingIcon:w,icons:C,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:T}=e,[S,k]=x.useState([]),A=x.useMemo(()=>Array.from(new Set([r].concat(S.filter(O=>O.position).map(O=>O.position)))),[S,r]),[j,B]=x.useState([]),[$,z]=x.useState(!1),[G,M]=x.useState(!1),[F,V]=x.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),K=x.useRef(null),R=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=x.useRef(null),U=x.useRef(!1),J=x.useCallback(O=>{k(Y=>{var L;return(L=Y.find(D=>D.id===O.id))!=null&&L.delete||Yt.dismiss(O.id),Y.filter(({id:D})=>D!==O.id)})},[]);return x.useEffect(()=>Yt.subscribe(O=>{if(O.dismiss){k(Y=>Y.map(L=>L.id===O.id?{...L,delete:!0}:L));return}setTimeout(()=>{Oo.flushSync(()=>{k(Y=>{let L=Y.findIndex(D=>D.id===O.id);return L!==-1?[...Y.slice(0,L),{...Y[L],...O},...Y.slice(L+1)]:[O,...Y]})})})}),[]),x.useEffect(()=>{if(d!=="system"){V(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?V("dark"):V("light")),typeof window>"u")return;let O=window.matchMedia("(prefers-color-scheme: dark)");try{O.addEventListener("change",({matches:Y})=>{V(Y?"dark":"light")})}catch{O.addListener(({matches:L})=>{try{V(L?"dark":"light")}catch(D){console.error(D)}})}},[d]),x.useEffect(()=>{S.length<=1&&z(!1)},[S]),x.useEffect(()=>{let O=Y=>{var L,D;o.every(X=>Y[X]||Y.code===X)&&(z(!0),(L=K.current)==null||L.focus()),Y.code==="Escape"&&(document.activeElement===K.current||(D=K.current)!=null&&D.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[o]),x.useEffect(()=>{if(K.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,U.current=!1)}},[K.current]),x.createElement("section",{ref:t,"aria-label":`${E} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((O,Y)=>{var L;let[D,X]=O.split("-");return S.length?x.createElement("ol",{key:O,dir:v==="auto"?pv():v,tabIndex:-1,ref:K,className:a,"data-sonner-toaster":!0,"data-theme":F,"data-y-position":D,"data-lifted":$&&S.length>1&&!s,"data-x-position":X,style:{"--front-toast-height":`${((L=j[0])==null?void 0:L.height)||0}px`,"--width":`${sN}px`,"--gap":`${y}px`,...f,...dN(l,c)},onBlur:_=>{U.current&&!_.currentTarget.contains(_.relatedTarget)&&(U.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:_=>{_.target instanceof HTMLElement&&_.target.dataset.dismissible==="false"||U.current||(U.current=!0,I.current=_.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{G||z(!1)},onDragEnd:()=>z(!1),onPointerDown:_=>{_.target instanceof HTMLElement&&_.target.dataset.dismissible==="false"||M(!0)},onPointerUp:()=>M(!1)},S.filter(_=>!_.position&&Y===0||_.position===O).map((_,P)=>{var W,Z;return x.createElement(uN,{key:_.id,icons:C,index:P,toast:_,defaultRichColors:p,duration:(W=g==null?void 0:g.duration)!=null?W:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:b,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:G,position:O,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:S.filter(se=>se.position==_.position),heights:j.filter(se=>se.position==_.position),setHeights:B,expandByDefault:s,gap:y,loadingIcon:w,expanded:$,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const pN=({...e})=>{const{theme:t="system"}=FI();return u.jsx(fN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};H.ApiProvider=uu,H.ArtifactRenderer=Zd,H.Badge=of,H.Button=et,H.Card=ma,H.CardContent=bs,H.CardDescription=xa,H.CardHeader=ga,H.CardTitle=va,H.ChatApi=iu,H.ChatApp=qk,H.ChatInput=Uh,H.ChatInputRow=Wh,H.ChatInterface=Fr,H.ChatProviders=Tr,H.ChatWidget=Xk,H.Command=El,H.CommandEmpty=Al,H.CommandGroup=jl,H.CommandInput=Il,H.CommandItem=Pl,H.CommandList=Nl,H.DEFAULT_TIMEOUT_MS=ru,H.Dialog=la,H.DialogContent=cs,H.DialogHeader=us,H.DialogTitle=ds,H.DropdownMenu=Js,H.DropdownMenuContent=Ao,H.DropdownMenuItem=Kn,H.DropdownMenuTrigger=Zs,H.FileApi=au,H.HISTORY_TIMEOUT_MS=ou,H.Input=$l,H.InterruptPartRenderer=ba,H.Label=Im,H.MarkdownContent=ir,H.MessageComponent=ws,H.MessageContent=rf,H.MessageHeader=sf,H.MessageList=Va,H.MessageRow=Wa,H.NewChatButton=Jk,H.PlotArtifact=Jd,H.SETTINGS_STORAGE_KEY=Wi,H.ScrollArea=Ll,H.Select=jE,H.SelectContent=hg,H.SelectItem=mg,H.SelectTrigger=dg,H.SelectValue=PE,H.Separator=bg,H.Sheet=HE,H.SheetContent=Ng,H.SheetDescription=Pg,H.SheetHeader=Ag,H.SheetTitle=jg,H.SheetTrigger=UE,H.SimpleChat=Gk,H.SimpleJsonView=xs,H.Sonner=pN,H.StreamProgress=Qd,H.Switch=Eg,H.Textarea=bl,H.ThinkingIndicator=tf,H.ThreadListItem=Fl,H.ThreadManager=si,H.ThreadStateProvider=Ou,H.ThreadsProvider=gu,H.TimelineColumn=Av,H.Toaster=OI,H.ToolContent=cp,H.Tooltip=fI,H.TooltipContent=Bg,H.TooltipProvider=dI,H.TooltipTrigger=pI,H.UserTextContent=nf,H.applySettings=yb,H.buildCheckpointIndex=uc,H.buildCheckpointPreviewMap=xv,H.buildLabelParts=Cu,H.chatApiClient=Rn,H.collectText=bu,H.createArtifactPreviewFromPlot=ku,H.createArtifactPreviewFromSource=Tu,H.del=Oi,H.extractConfigFields=bi,H.extractToolContent=nr,H.extractToolMeta=Go,H.fileApiClient=lu,H.fileToBase64=du,H.formatToolOutput=xu,H.get=Kt,H.getAgentNameFromMessage=yu,H.getChatToken=Mi,H.getCheckpointForMessage=bv,H.getCurrentSettings=wb,H.getDefaultApiConfig=Wu,H.getDefaultChatSettings=Vu,H.getMessageAttemptInfo=dc,H.getMessageDomKey=Ua,H.getPreviewForMessage=xi,H.getToolProgress=Fi,H.httpClient=Lt,H.hydrateHistorySnapshots=Xn,H.isEnvelope=pu,H.isFileLike=Di,H.loadStoredSettings=Ku,H.looksLikeMarkdown=vu,H.messageSignature=$i,H.normalizeInterruptId=Li,H.normalizeMimeType=Su,H.normalizeToolPayload=Eu,H.normalizeToolPayloadValue=Cr,H.onChatTokenChanged=Ri,H.parseJsonSafe=er,H.post=to,H.pretty=tr,H.processAttachments=fu,H.put=su,H.readNumber=pc,H.readString=_n,H.sanitizeForDisplay=Sr,H.saveSettings=qu,H.setChatToken=Mn,H.stringifyTool=wu,H.toPlainObject=Pn,H.unwrap=$t,H.useApi=On,H.useCheckpointIndex=fc,H.useFilePreview=af,H.useHasChatSession=xb,H.useParsedMessageContent=lf,H.useShallowStableValue=Bu,H.useStream=Ui,H.useStreamingHook=Ui,H.useThreadHistoryState=Pu,H.useThreadManagerViewState=Tm,H.useThreadState=no,H.useThreadStateUpdater=Ru,H.useThreads=yr,H.useThreadsState=hu,H.useToolPayload=uf,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|
|
126
|
+
`}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=Bd(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=Bd(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 Vd{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 Kd{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 Fn{constructor(t){this.options=t||sr,this.options.renderer=this.options.renderer||new ua,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Vd,this.slugger=new Kd}static parse(t,n){return new Fn(n).parse(t)}static parseInline(t,n){return new Fn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,x,g,v,y,w,C,E,T,S;const k=t.length;for(o=0;o<k;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(S=this.options.extensions.renderers[f.type].call({parser:this},f),S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=S||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,Fd(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(p="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(p+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(x=f.ordered,g=f.start,v=f.loose,a=f.items.length,m="",s=0;s<a;s++)w=f.items[s],C=w.checked,E=w.task,y="",w.task&&(T=this.renderer.checkbox(C),v?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=T+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=T+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:T}):y+=T),y+=this.parse(w.tokens,v),m+=this.renderer.listitem(y,E,C);r+=this.renderer.list(m,x,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<k&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
|
+
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class ps{constructor(t){this.options=t||sr}preprocess(t){return t}postprocess(t){return t}}sc(ps,"passThroughHooks",new Set(["preprocess","postprocess"]));function dy(e,t,n){return r=>{if(r.message+=`
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Mt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function qd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=dy(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(ly(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&be.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;be.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(be.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&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return qd($n.lex,Fn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},Yw(be.defaults),be},be.getDefaults=Od,be.defaults=sr,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.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=be.defaults.renderer||new ua;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=be.defaults.tokenizer||new ca;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=be.defaults.hooks||new ps;for(const s in n.hooks){const i=o[s];ps.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=be.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}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=qd($n.lexInline,Fn.parseInline),be.Parser=Fn,be.parser=Fn.parse,be.Renderer=ua,be.TextRenderer=Vd,be.Lexer=$n,be.lexer=$n.lex,be.Tokenizer=ca,be.Slugger=Kd,be.Hooks=ps,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,Fn.parse,$n.lex;function ir({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:oe("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Gd({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Yd({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Cu(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Gd,{preview:r,idx:o},`${t}-plot-${o}`))}):null}const fy="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function hs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:fy,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:tr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:tr(e)})}function Xd({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(de.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const da=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));da.displayName="Card";const fa=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));fa.displayName="CardHeader";const pa=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));pa.displayName="CardTitle";const ha=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));ha.displayName="CardDescription";const ms=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));ms.displayName="CardContent";const Jd=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));Jd.displayName="CardFooter";const py=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function ma({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=py(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const p=tr(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:p})}return u.jsxs(da,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(fa,{className:"pb-3",children:[u.jsx(pa,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(ha,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(ms,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(p=>u.jsx(nt,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,p),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:p.label}),p.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:p.description}):null]})},p.id))})}):d&&u.jsx(ms,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(Jd,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(nt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(nt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function Zd({className:e}){const t=b.useRef(null);return b.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Qd({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(ir,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(nt,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function hy(e,t,n){const[r,o]=b.useState(e),s=b.useRef(e),i=b.useRef(null);return b.useEffect(()=>{s.current=e;const a=()=>{o(s.current),i.current&&(clearTimeout(i.current),i.current=null)};if(!t||n<=0){a();return}return i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a()},n),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[e,t,n]),r}function ef({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,toolExpandable:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptPart:d,isStreamingMessage:p,streamingDebounceMs:m,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:x,defaultMessage:g,handleFileClick:v,uploadingFiles:y,messageRole:w,truncateUserMessages:C,userMessagePreviewLength:E,isUserExpanded:T,setIsUserExpanded:S,isCompactLayout:k,iconForeground:A,toolConfig:P,handleInterruptApprove:F,handleInterruptReject:$,handleInterruptAlternative:B,disableInterruptActions:K,isInterruptMessage:R}){const W=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(de.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),X=hy(i,(f??!0)&&p,m??0),O=b.useMemo(()=>X.filter(j=>j.type==="text"),[X]),I=b.useMemo(()=>O.map(j=>j.text??"").join(""),[O]),H=b.useMemo(()=>{if(!x)return null;const j=gy(I);return{stablePart:I.slice(0,j),tailPart:I.slice(j)}},[I,x]),J=b.useMemo(()=>{if(!H)return null;const{stablePart:j,tailPart:U}=H;return!j&&!U?null:u.jsxs("div",{className:"space-y-2",children:[j?u.jsx(ir,{content:j,allowHtml:!1}):null,U?u.jsx(ir,{content:U,allowHtml:!1}):null]})},[H]),M=b.useMemo(()=>{if(!x)return X;const j=[];let U=!1;for(const Z of X){if(Z.type==="text"){U||(j.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),U=!0);continue}j.push(Z)}return j},[X,x]),L=(x?M:X).filter(j=>j.type!=="interrupt"&&j.type!=="image_url"),D=()=>!l||l.length===0?null:u.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.map((j,U)=>{const Z=j;return u.jsx("div",{className:"relative group",children:u.jsx("img",{src:Z.url,alt:Z.alt??"Image",loading:"lazy",onClick:()=>window.open(Z.url,"_blank"),className:"h-20 w-20 object-cover rounded-md border border-border/50 cursor-pointer hover:opacity-90 transition-opacity"})},U)})}),G=b.useCallback(({part:j,i:U})=>{if(j.type==="text"){if(x)return null;const Z=j.text??"",se=Z.trim(),ae=er(se);return ae&&w!=="tool"?u.jsx(hs,{data:ae},U):w==="user"&&C&&se.length>E?u.jsx(Qd,{text:se,expanded:T,onExpandedChange:S,previewLength:E,isCompact:k},U):u.jsx(ir,{content:Z,allowHtml:!1},U)}if(j.type==="image_url")return null;if(j.type==="file"){const Z=j,se=Z.name||"file";return u.jsxs("a",{href:Z.url,onClick:ae=>v(ae,Z,U),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[y[U]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[se,y[U]?" (processing)":""]})]},U)}return null},[v,k,T,w,C,y,E,x,S]),_=a.trim().length>0||l.length>0||c.length>0||L.length>0;if(!t&&c.length>0&&!p&&!a&&l.length===0)return W();if(!t&&!_&&!p)return null;if(t){if(!n)return null;if(R&&d){const j=d.value,U=!K,Z=F??(()=>{}),se=$??(()=>{});return u.jsx(ma,{interruptPart:d,payload:j,onApprove:Z,onReject:se,onSelectAlternative:B,disabled:K,isActive:U})}return u.jsx(lp,{message:e,viewMode:r,expandable:o,isStreaming:s,toolConfig:P},e.id)}if(!g){const j=u.jsxs("div",{className:"space-y-2",children:[D(),L.map((U,Z)=>x&&vy(U)?J?u.jsx("div",{className:"space-y-2",children:J},`streaming-md-${Z}`):null:u.jsx(G,{part:U,i:Z},Z))]});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[j,u.jsx(Zd,{className:A})]}):j}return null}function my(e){return e?!(ao(e,/```/g)||ao(e,/`/g)||ao(e,/\*\*/g)||ao(e,/__/g)||ao(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function ao(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function gy(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(my(e.slice(0,t)))return t;return 0}function vy(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const xy=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function tf({className:e,variant:t,...n}){return u.jsx("div",{className:oe(xy({variant:t}),e),...n})}function nf({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:p,messageRole:m,toolViewMode:f,toolExpandable:x=!1,toolMeta:g,onToggleToolView:v,onCopy:y,onEdit:w,onRegenerate:C,showCheckpointControls:E,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:k,handleNewerAttemptSelect:A,messageCreatedAt:P,copied:F}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:oe("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(tf,{variant:"outline",className:oe("text-xs flex items-center gap-1",o,"border border-current/40",c&&"text-xs h-4",x&&"cursor-pointer select-none"),role:x?"button":void 0,tabIndex:x?0:void 0,"aria-expanded":x?f==="expanded":void 0,onClick:x?v:void 0,onKeyDown:$=>{x&&($.key==="Enter"||$.key===" ")&&($.preventDefault(),v())},children:[u.jsx("span",{children:g.name??"Tool Output"}),g.toolCallId&&u.jsx("span",{className:"opacity-70",children:g.toolCallId.slice(0,8)}),x&&(f==="expanded"?u.jsx(de.ChevronUp,{className:"h-3 w-3"}):u.jsx(de.ChevronDown,{className:"h-3 w-3"}))]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[E&&T>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S<T-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=T-1||k()},"aria-label":"Older attempt (back in time)",disabled:S>=T-1,children:u.jsx(de.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[T-S," / ",T]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||A()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(de.ChevronRight,{className:"h-3 w-3"})})]}),e&&P&&u.jsx("time",{className:oe("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(P.endsWith("Z")||P.includes("+")?P:`${P}Z`).toISOString(),title:new Date(P.endsWith("Z")||P.includes("+")?P:`${P}Z`).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(P.endsWith("Z")||P.includes("+")?P:`${P}Z`))}),d&&!p&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(nt,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(de.Copy,{className:oe(F?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&w&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:w,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(de.Edit,{className:oe(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&C&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:C,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(de.RotateCcw,{className:oe(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const by=1,wy=1e6;let ga=0;function yy(){return ga=(ga+1)%Number.MAX_SAFE_INTEGER,ga.toString()}const va=new Map,rf=e=>{if(va.has(e))return;const t=setTimeout(()=>{va.delete(e),lo({type:"REMOVE_TOAST",toastId:e})},wy);va.set(e,t)},Sy=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,by)};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?rf(n):e.toasts.forEach(r=>{rf(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)}}},gs=[];let vs={toasts:[]};function lo(e){vs=Sy(vs,e),gs.forEach(t=>{t(vs)})}function Cy({...e}){const t=yy(),n=o=>lo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>lo({type:"DISMISS_TOAST",toastId:t});return lo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function of(){const[e,t]=h.useState(vs);return h.useEffect(()=>(gs.push(t),()=>{const n=gs.indexOf(t);n>-1&&gs.splice(n,1)}),[e]),{...e,toast:Cy,dismiss:n=>lo({type:"DISMISS_TOAST",toastId:n})}}function sf(e){const{allowFileOpen:t,currentThreadId:n}=e,{fileApi:r}=On(),{toast:o}=of(),[s,i]=b.useState({}),[a,l]=b.useState(null),[c,d]=b.useState(!1),p=b.useCallback(()=>{d(!1),l(null)},[]),m=b.useCallback(x=>{l(x),d(!0)},[]),f=b.useCallback(async(x,g,v)=>{var y,w;if(!t){x.preventDefault();return}if(s[v]){x.preventDefault();return}try{const C=String(g.url??""),E=C.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(E){x.preventDefault();const T=E[1],S=g.name||`file_${T}`,k=g.mimeType||"application/octet-stream";m({id:T,name:S,mimeType:k});return}if(C.startsWith("data:")){x.preventDefault(),i(S=>({...S,[v]:!0}));const T=o({title:"Fetching file...",description:"",open:!0});try{const S=await r.listFiles(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const k=S.find(A=>!A||typeof A!="object"||!((A.filename??"")===(g.name??""))?!1:typeof g.size=="number"&&typeof A.size=="number"?A.size===g.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${g.name}" is not yet available on the server`);if(!k.id||!k.filename)throw new Error("Invalid file data received from server");m({id:k.id,name:g.name||k.filename||`file_${k.id}`,mimeType:g.mimeType||k.mime_type||"application/octet-stream"}),(y=T.update)==null||y.call(T,{id:T.id,title:"Success",description:`Opened ${g.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const k=S instanceof Error?S.message:"Unknown error occurred";(w=T.update)==null||w.call(T,{id:T.id,title:"Failed",description:k}),o({title:"Failed to fetch file",description:k,open:!0})}finally{i(S=>({...S,[v]:!1}))}}}catch(C){console.error("File click error:",C),i(E=>({...E,[v]:!1}))}},[t,s,o,n,m]);return{uploadingFiles:s,handleFileClick:f,fileViewerOpen:c,currentFileInfo:a,closeFileViewer:p}}function af(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:vu(r),toolMeta:Go(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:xu(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const lf="data:";function Ty(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(lf))continue;const s=o.slice(lf.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=er(s);i&&typeof i=="object"&&t.push(i)}return t}function ky(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&typeof n=="object"&&n.type==="tool.end")return n}return null}function cf(e){return b.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>Ty(c.text??""));if(!r.length){const c=t.map(p=>p.text??"").join(`
|
|
130
|
+
`),d=er(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=ky(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=Cr(i),l=nr(a);return l&&typeof l=="object"&&!Array.isArray(l)?{kind:"dict",value:l,data:l,event:s}:{kind:"generic",value:l,event:s}},[e])}const xs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,toolConfig:m,customStyles:f={},streamingDebounceMs:x=300,renderStreamingMarkdown:g=!0,enableStreamingMarkdownBuffer:v,onEdit:y,onRegenerate:w,onCopy:C,getInterruptOptions:E,attemptCount:T=1,attemptIndex:S=0,onSelectCheckpoint:k,attemptMetas:A=[]}){const[P,F]=b.useState(!1),[$,B]=b.useState(!1),{currentThreadId:K}=yr(),{respondToInterrupt:R}=no(),[W,Y]=b.useState(!1),X=l==="phone"||l==="half-screen",O=t.role,I=O==="interrupt",H=O==="tool"||I,M=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:D}=m??{},G=b.useMemo(()=>!D||t.role!=="tool"?!1:D(t),[D,t.id,t.role]),[_,j]=b.useState(G?"preview":"expanded");b.useEffect(()=>{j(G?"preview":"expanded")},[G,t.id]);const U=b.useMemo(()=>t.role==="default_message"?t:null,[t]),Z=!!U,se=!(r&&O!=="user"),{uploadingFiles:ae,handleFileClick:Se,fileViewerOpen:Ce,currentFileInfo:Oe,closeFileViewer:Fe}=sf({allowFileOpen:se,currentThreadId:K}),Be=b.useMemo(()=>{switch(O){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":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))]"}},[O]),Ke=af(t,U),{contentParts:ze,imageParts:dt,fileParts:pt,textContent:Ze,toolMeta:He,toolRaw:Re,isToolStreaming:qe,interruptParts:Ae}=Ke,Ge=v??x!==0,Xe=b.useMemo(()=>Ae.length?Ae[0]:null,[Ae]),Ct=b.useCallback(async()=>{const ee=H?Re:Ze;async function he(ue){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ue);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ie=new Blob([ue],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ie})]);return}throw new Error("Clipboard API not supported in this context.")}try{await he(ee),F(!0),setTimeout(()=>F(!1),2e3),C==null||C(ee)}catch(ue){console.error("Failed to copy:",ue)}},[H,Re,Ze,C]),Qe=b.useCallback(async(ee,he)=>{if(!Xe)return;if(!Oi(Xe.id)){console.warn("Interrupt part missing id",Xe);return}Y(!0);try{const Ie=E==null?void 0:E(t);await R(ee,he,Ie)}catch(Ie){console.error("Failed to respond to interrupt:",Ie)}finally{Y(!1)}},[Xe,R]),Tt=b.useCallback(()=>Qe(!0),[Qe]),ht=b.useCallback(()=>Qe(!1),[Qe]),wt=b.useCallback((ee,he)=>{if(!he)return;const ue={alternativeId:he.id??he.label??void 0,alternativeLabel:he.label};Qe(!0,ue)},[Qe]),At=b.useCallback(()=>{if(!y||!t.id)return;const ee=(H?Re:Ze)??"",he="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,ee,he)},[y,H,Re,Ze,t]),jt=b.useCallback(()=>{w==null||w(n)},[w,n]),mt=b.useCallback(()=>{const he=oe(X?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Be);switch(O){case"user":return u.jsx(de.User,{className:he});case"assistant":return u.jsx(de.Bot,{className:he});case"tool":return u.jsx(de.Wrench,{className:he});case"interrupt":return u.jsx(de.Bot,{className:he});default:return u.jsx(de.Bot,{className:he})}},[X,Be,O]),gt=b.useCallback(()=>{const ee="group relative mb-4 flex w-full";switch(O){case"user":return oe(ee,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return oe(ee,"justify-start");default:return ee}},[O]),Ht=b.useCallback(()=>{const ee=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",X&&"px-3 py-2 text-sm");if(Z)return oe(ee,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(O){case"user":return oe(ee,"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 oe(ee,"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":case"interrupt":return oe(ee,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(ee,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(ee,"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")}},[X,Z,O]),Ve=G&&!I&&M,$e=b.useCallback(()=>{Ve&&j(ee=>ee==="expanded"?"preview":"expanded")},[Ve]),kt=I?"expanded":_,ct=(p||I)&&M,_t=u.jsx(ef,{message:t,isToolMessage:H,showToolMessages:ct,toolViewMode:kt,toolExpandable:G,toolConfig:{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:D},isToolStreaming:qe,contentParts:ze,textContent:Ze,imageParts:dt,fileParts:pt,isStreamingMessage:r,defaultMessage:U,enableStreamingMarkdownBuffer:Ge,renderStreamingMarkdown:g,streamingDebounceMs:x,handleFileClick:Se,uploadingFiles:ae,messageRole:O,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:$,setIsUserExpanded:B,isCompactLayout:X,iconForeground:Be,interruptPart:Xe,handleInterruptApprove:Tt,handleInterruptReject:ht,handleInterruptAlternative:wt,disableInterruptActions:W,isInterruptMessage:I}),xe=b.useMemo(()=>U?"Assistant":bu(t),[U,t]),Le=mt(),Ue=O==="user"&&(T??1)>1&&typeof k=="function",st=(A==null?void 0:A.length)??0,tt=st>0&&S<st-1?A[S+1]:void 0,ut=st>0&&S>0?A[S-1]:void 0,et=b.useCallback(()=>{!tt||!k||k(tt.id,void 0,!!tt.isLatestAttempt)},[tt,k]),Q=b.useCallback(()=>{!ut||!k||k(ut.id,void 0,!!ut.isLatestAttempt)},[ut,k]);return H&&!p?null:Z&&U?u.jsx("div",{className:oe(gt(),f.container),children:u.jsxs("div",{className:oe(Ht(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:oe("h-4 w-4",Be)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(ir,{content:U.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(gt(),f.container),children:u.jsxs("div",{className:oe(Ht(),f.content),children:[u.jsx(nf,{showTimestamp:i,showAgentName:a,isToolMessage:H,iconForeground:Be,agentName:xe,messageIcon:Le,customHeaderClass:f.header,customActionsClass:f.actions,isCompactLayout:X,showActions:s,isEditing:o,messageRole:O,toolViewMode:kt,toolExpandable:G,isInterruptMessage:I,toolMeta:He,onToggleToolView:$e,onCopy:Ct,onEdit:At,onRegenerate:jt,showCheckpointControls:Ue,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:et,handleNewerAttemptSelect:Q,messageCreatedAt:t.createdAt,copied:P}),u.jsx("div",{className:"relative",children:_t}),!(i||a||H)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",X&&"h-5 w-5"),children:u.jsx(de.Copy,{className:oe(P?"text-success":"text-current",X?"h-3 w-3":"h-4 w-4")})}),O==="user"&&y&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:At,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",X&&"h-5 w-5"),children:u.jsx(de.Edit,{className:oe("text-current",X?"h-3 w-3":"h-4 w-4")})}),O==="assistant"&&w&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:jt,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",X&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:oe("text-current",X?"h-3 w-3":"h-4 w-4")})})]})]})}),Oe&&u.jsx(Gw,{isOpen:Ce,onClose:Fe,fileId:Oe.id,fileName:Oe.name,mimeType:Oe.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,x,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Di(e.message)===Di(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolConfig"].every(v=>e[v]===t[v]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((x=e.customStyles)==null?void 0:x.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Li(e.message),a=Li(t.message);return i.length===a.length});xs.displayName="MessageComponent";const bs=0,Bn=1,jr=2,uf=4;function df(e){return()=>e}function Ey(e){e()}function ff(e,t){return n=>e(t(n))}function pf(e,t){return()=>e(t)}function Iy(e,t){return n=>e(t,n)}function xa(e){return e!==void 0}function Ny(...e){return()=>{e.map(Ey)}}function _r(){}function ws(e,t){return t(e),e}function Ay(e,t){return t(e)}function it(...e){return e}function Je(e,t){return e(Bn,t)}function _e(e,t){e(bs,t)}function ba(e){e(jr)}function bt(e){return e(uf)}function ve(e,t){return Je(e,Iy(t,bs))}function dn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function hf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function mf(e,t){return e===t}function at(e=mf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>ff(t,e)}function bn(e){return t=>()=>{t(e)}}function re(e,...t){const n=Py(...t);return(r,o)=>{switch(r){case jr:ba(e);return;case Bn:return Je(e,n(o))}}}function wn(e,t){return n=>r=>{n(t=e(t,r))}}function ar(e){return t=>n=>{e>0?e--:t(n)}}function Nn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Py(...e){return t=>e.reduceRight(Ay,t)}function jy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),_r);case jr:r(),n=null;return}}}function ie(e){let t=e;const n=We();return(r,o)=>{switch(r){case bs:t=o;break;case Bn:{o(t);break}case uf:return t}return n(r,o)}}function Ot(e,t){return ws(ie(t),n=>ve(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case bs:e.slice().forEach(r=>{r(n)});return;case jr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return ws(We(),t=>ve(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:_y(),singleton:n}}const _y=()=>Symbol();function Ry(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function St(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{n[i]=l,r=r|a,r===o&&_e(t,n)})}),function(s,i){switch(s){case jr:{ba(t);return}case Bn:return r===o&&i(n),Je(t,i)}}}function Te(e,t=mf){return re(e,at(t))}function wa(...e){return function(t,n){switch(t){case jr:return;case Bn:return Ny(...e.map(r=>Je(r,n)))}}}var qt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(qt||{});const My={0:"debug",3:"error",1:"log",2:"warn"},Oy=()=>typeof globalThis>"u"?window:globalThis,zn=Ye(()=>{const e=ie(3);return{log:ie((t,n,r=1)=>{var o;const s=(o=Oy().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[My[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function lr(e,t,n){return ya(e,t,n).callbackRef}function ya(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Dy(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const p=Ly(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let x;f&&(x=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?x.scrollX||x.document.documentElement.scrollLeft:x.scrollY||x.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,v=i?a?i.scrollWidth:i.scrollHeight:f?a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?x.innerWidth:x.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:v,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?gf("column-gap",getComputedStyle(d).columnGap,o):gf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return ya(c,n,l)}function Ly(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},qt.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function gf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}function vf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),x=c.top-f.top;m=f.height-Math.max(0,x),p=x+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ya(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Bt=Ye(()=>{const e=We(),t=We(),n=ie(0),r=We(),o=ie(0),s=We(),i=We(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),p=We(),m=We(),f=ie(!1),x=ie(!1),g=ie(!1);return ve(re(e,fe(({scrollTop:v})=>v)),t),ve(re(e,fe(({scrollHeight:v})=>v)),i),ve(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:x,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),co={lvl:0};function xf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===co}function uo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?uo(e.l,t):uo(e.r,t)}function fn(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=fn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return fn(e.l,t,n)}function Qt(e,t,n){return ot(e)?yf(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?Sf(Nt(e,{l:Qt(e.l,t,n)})):Sf(Nt(e,{r:Qt(e.r,t,n)}))}function Rr(){return co}function ys(e,t,n){if(ot(e))return[];const r=fn(e,t)[0];return $y(Ca(e,r,n))}function Sa(e,t){if(ot(e))return co;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=wf(r);return Ss(Nt(e,{k:s,l:bf(r),v:i}))}}else return t<n?Ss(Nt(e,{l:Sa(r,t)})):Ss(Nt(e,{r:Sa(o,t)}))}function cr(e){return ot(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function Ca(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ca(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ca(s,t,n))),a}function Ss(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(Ta(t))return Cf(Nt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return Nt(t.r,{l:Nt(t,{r:t.r.l}),lvl:n,r:Nt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ta(e))return ka(Nt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=Ta(o)?r.lvl-1:r.lvl;return Nt(o,{l:Nt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ka(Nt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Nt(e,t){return yf(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 bf(e){return ot(e.r)?e.l:Ss(Nt(e,{r:bf(e.r)}))}function Ta(e){return ot(e)||e.lvl>e.r.lvl}function wf(e){return ot(e.r)?[e.k,e.v]:wf(e.r)}function yf(e,t,n,r=co,o=co){return{k:e,l:r,lvl:n,r:o,v:t}}function Sf(e){return ka(Cf(e))}function Cf(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function ka(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function $y(e){return xf(e,({k:t,v:n})=>({index:t,value:n}))}function Tf(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function fo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ea=Ye(()=>({recalcInProgress:ie(!1)}),[],{singleton:!0});function kf(e,t,n){return e[Cs(e,t,n)]}function Cs(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 Fy(e,t,n,r){const o=Cs(e,t,r),s=Cs(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ts(e){return!ot(e.groupOffsetTree)}function Ia({index:e},t){return t===e?0:t<e?-1:1}function By(){return{groupIndices:[],groupOffsetTree:Rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rr()}}function zy(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=Qt(e,0,s);continue}const a=ys(e,i-1,o+1);if(a.some(Gy(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Sa(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function Hy(e){return typeof e.groupIndex<"u"}function Uy({offset:e},t){return t===e?0:t<e?-1:1}function po(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=kf(t,e,Ia),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Ef(e,t){if(!Ts(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function If(e,t,n){if(Hy(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Ef(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Wy(e,t,n,r=0){return r>0&&(t=Math.max(t,kf(e,r,Ia).offset)),xf(Fy(e,t,n,Uy),qy)}function Vy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,qt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((x,g)=>Qt(Qt(x,g,m),g+1,f),i)}else[i,a]=zy(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=Na(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Qt(m,f,po(f,p,o)),Rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function Ky(e){return cr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Nf(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 Na(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Cs(o,t-1,Ia),a=o[l].offset;const c=fn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===fn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of ys(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function qy(e){return{index:e.index,value:e}}function Gy(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 Yy={offsetHeight:"height",offsetWidth:"width"},yn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Ot(r,0),s=We(),i=We(),a=ie(0),l=ie([]),c=ie(void 0),d=ie(void 0),p=ie((T,S)=>Hn(T,Yy[S])),m=ie(void 0),f=ie(0),x=By(),g=Ot(re(n,De(l,e,f),wn(Vy,x),at()),x),v=Ot(re(l,at(),wn((T,S)=>({current:S,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);ve(re(l,ke(T=>T.length>0),De(g,f),fe(([T,S,k])=>{const A=T.reduce((P,F,$)=>Qt(P,F,po(F,S.offsetTree,k)||$),Rr());return{...S,groupIndices:T,groupOffsetTree:A}})),g),ve(re(r,De(g),ke(([T,{lastIndex:S}])=>T<S),fe(([T,{lastIndex:S,lastSize:k}])=>[{endIndex:S,size:k,startIndex:T}])),n),ve(c,d);const y=Ot(re(c,fe(T=>T===void 0)),!0);ve(re(d,ke(T=>T!==void 0&&ot(bt(g).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Zt(re(n,De(g),wn(({sizes:T},[S,k])=>({changed:k!==T,sizes:k}),{changed:!1,sizes:x}),fe(T=>T.changed)));Je(re(a,wn((T,S)=>({diff:T.prev-S,prev:S}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:S}=bt(g);if(T>0)_e(t,!0),_e(s,T+Nf(T,S));else if(T<0){const k=bt(v);k.length>0&&(T-=Nf(-T,k)),_e(i,T)}}),Je(re(a,De(e)),([T,S])=>{T<0&&S("`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},qt.ERROR)});const C=Zt(s);ve(re(s,De(g),fe(([T,S])=>{const k=S.groupIndices.length>0,A=[],P=S.lastSize;if(k){const F=uo(S.sizeTree,0);let $=0,B=0;for(;$<T;){const R=S.groupIndices[B],W=S.groupIndices.length===B+1?1/0:S.groupIndices[B+1]-R-1;A.push({endIndex:R,size:F,startIndex:R}),A.push({endIndex:R+1+W-1,size:P,startIndex:R+1}),B++,$+=W+1}const K=cr(S.sizeTree);return $!==T&&K.shift(),K.reduce((R,{k:W,v:Y})=>{let X=R.ranges;return R.prevSize!==0&&(X=[...R.ranges,{endIndex:W+T-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:W+T,prevSize:Y,ranges:X}},{prevIndex:T,prevSize:0,ranges:A}).ranges}return cr(S.sizeTree).reduce((F,{k:$,v:B})=>({prevIndex:$+T,prevSize:B,ranges:[...F.ranges,{endIndex:$+T-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const E=Zt(re(i,De(g,f),fe(([T,{offsetTree:S},k])=>{const A=-T;return po(A,S,k)})));return ve(re(i,De(g,f),fe(([T,S,k])=>{if(S.groupIndices.length>0){if(ot(S.sizeTree))return S;let A=Rr();const P=bt(v);let F=0,$=0,B=0;for(;F<-T;){B=P[$];const K=P[$+1]-B-1;$++,F+=K+1}if(A=cr(S.sizeTree).reduce((K,{k:R,v:W})=>Qt(K,Math.max(0,R+T),W),A),F!==-T){const K=uo(S.sizeTree,B);A=Qt(A,0,K);const R=fn(S.sizeTree,-T+1)[1];A=Qt(A,1,R)}return{...S,sizeTree:A,...Na(S.offsetTree,0,A,k)}}else{const A=cr(S.sizeTree).reduce((P,{k:F,v:$})=>Qt(P,Math.max(0,F+T),$),Rr());return{...S,sizeTree:A,...Na(S.offsetTree,0,A,k)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:w,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(zn,Ea),{singleton:!0});function Xy(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Af=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Zt(re(s,fe(Xy)));return ve(re(a,fe(l=>l.totalCount)),n),ve(re(a,fe(l=>l.groupIndices)),e),ve(re(St(o,t,r),ke(([l,c])=>Ts(c)),fe(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(yn,Bt)),Un=Ye(([{log:e}])=>{const t=ie(!1),n=Zt(re(t,ke(r=>r),at()));return Je(t,r=>{r&&bt(e)("props updated",{},qt.DEBUG)}),{didMount:n,propsReady:t}},it(zn),{singleton:!0}),Jy=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Pf(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Jy)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ho=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=We(),x=We(),g=ie(0);let v=null,y=null,w=null;function C(){v&&(v(),v=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),_e(l,!1)}return ve(re(f,De(n,p,r,g,a,i,m),De(e,s,o),fe(([[E,T,S,k,A,P,F,$],B,K,R])=>{const W=Pf(E),{align:Y,behavior:X,offset:O}=W,I=k-1,H=If(W,T,I);let J=po(H,T.offsetTree,B)+P;Y==="end"?(J+=K+fn(T.sizeTree,H)[1]-S+R,H===I&&(J+=F)):Y==="center"?J+=(K+fn(T.sizeTree,H)[1]-S+R)/2:J-=A,O&&(J+=O);const M=q=>{C(),q?($("retrying to scroll to",{location:E},qt.DEBUG),_e(f,E)):(_e(x,!0),$("list did not change, scroll successful",{},qt.DEBUG))};if(C(),X==="smooth"){let q=!1;w=Je(t,L=>{q=q||L}),v=dn(d,()=>{M(q)})}else v=dn(re(t,Zy(150)),M);return y=setTimeout(()=>{C()},1200),_e(l,!0),$("scrolling from index to",{behavior:X,index:H,top:J},qt.DEBUG),{behavior:X,top:J}})),c),{scrollTargetReached:x,scrollToIndex:f,topListHeight:g}},it(yn,Bt,zn),{singleton:!0});function Zy(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Aa(e,t){e==0?t():requestAnimationFrame(()=>{Aa(e-1,t)})}function Pa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const mo=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=ie(!0),l=ie(0),c=ie(!0);return ve(re(i,De(l),ke(([d,p])=>!!p),bn(!1)),a),ve(re(i,De(l),ke(([d,p])=>!!p),bn(!1)),c),Je(re(St(t,i),De(a,n,e,c),ke(([[,d],p,{sizeTree:m},f,x])=>d&&(!ot(m)||xa(f))&&!p&&!x),De(l)),([,d])=>{dn(o,()=>{_e(c,!0)}),Aa(4,()=>{dn(r,()=>{_e(a,!0)}),_e(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(yn,Bt,ho,Un),{singleton:!0});function jf(e,t){return Math.abs(e-t)<1.01}const go="up",vo="down",Qy="none",e0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},t0=0,xo=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=We(),c=We(),d=ie(4),p=ie(t0),m=Ot(re(wa(re(Te(o),ar(1),bn(!0)),re(Te(o),ar(1),bn(!1),hf(100))),at()),!1),f=Ot(re(wa(re(n,bn(!0)),re(n,bn(!1),hf(200))),at()),!1);ve(re(St(Te(o),Te(p)),fe(([w,C])=>w<=C),at()),a),ve(re(a,Nn(50)),c);const x=Zt(re(St(r,Te(s),Te(t),Te(e),Te(d)),wn((w,[{scrollHeight:C,scrollTop:E},T,S,k,A])=>{const P=E+T-C>-A,F={scrollHeight:C,scrollTop:E,viewportHeight:T};if(P){let B,K;return E>w.state.scrollTop?(B="SCROLLED_DOWN",K=w.state.scrollTop-E):(B="SIZE_DECREASED",K=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:K,state:F}}let $;return F.scrollHeight>w.state.scrollHeight?$="SIZE_INCREASED":T<w.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:F}},e0),at((w,C)=>w&&w.atBottom===C.atBottom))),g=Ot(re(r,wn((w,{scrollHeight:C,scrollTop:E,viewportHeight:T})=>{if(jf(w.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:E};{const S=C-(E+T)<1;return w.scrollTop!==E&&S?{changed:!0,jump:w.scrollTop-E,scrollHeight:C,scrollTop:E}:{changed:!0,jump:0,scrollHeight:C,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(w=>w.changed),fe(w=>w.jump)),0);ve(re(x,fe(w=>w.atBottom)),i),ve(re(i,Nn(50)),l);const v=ie(vo);ve(re(r,fe(({scrollTop:w})=>w),at(),wn((w,C)=>bt(f)?{direction:w.direction,prevScrollTop:C}:{direction:C<w.prevScrollTop?go:vo,prevScrollTop:C},{direction:vo,prevScrollTop:0}),fe(w=>w.direction)),v),ve(re(r,Nn(50),bn(Qy)),v);const y=ie(0);return ve(re(m,ke(w=>!w),bn(0)),y),ve(re(o,Nn(100),De(m),ke(([w,C])=>!!C),wn(([w,C],[E])=>[C,E],[0,0]),fe(([w,C])=>C-w)),y),{atBottomState:x,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:v,scrollVelocity:y}},it(Bt)),ks="top",Es="bottom",_f="none";function Rf(e,t,n){return typeof e=="number"?n===go&&t===ks||n===vo&&t===Es?e:0:n===go?t===ks?e.main:e.reverse:t===Es?e.main:e.reverse}function Mf(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ja=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=ie(0),a=ie(0),l=ie(0),c=Ot(re(St(Te(r),Te(o),Te(n),Te(s,fo),Te(l),Te(i),Te(t),Te(e),Te(a)),fe(([d,p,m,[f,x],g,v,y,w,C])=>{const E=d-w,T=v+y,S=Math.max(m-E,0);let k=_f;const A=Mf(C,ks),P=Mf(C,Es);return f-=w,f+=m+y,x+=m+y,x-=w,f>d+T-A&&(k=go),x<d-S+p+P&&(k=vo),k!==_f?[Math.max(E-m-Rf(g,ks,k)-A,0),E-S-y+p+Rf(g,Es,k)+P]:null}),ke(d=>d!=null),at(fo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Bt),{singleton:!0});function n0(e,t,n){if(Ts(t)){const r=Ef(e,t);return[{index:fn(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 _a={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Is(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,x=m-d;return{bottom:d,firstItemIndex:s,items:Df(e,o,s),offsetBottom:x,offsetTop:c,top:f,topItems:Df(t,o,s),topListHeight:t.reduce((g,v)=>v.size+g,0),totalCount:n}}function Of(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=Pa(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Is(c,[],a,o,n,r)}function Df(e,t,n){if(e.length===0)return[];if(!Ts(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=ys(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ur=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:x}])=>{const g=ie([]),v=ie(0),y=We();ve(s.topItemsIndexes,g);const w=Ot(re(St(f,x,Te(l,fo),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),ke(([S,k,,A,,,,,,,P])=>{const F=P&&P.length!==A;return S&&!k&&!F}),fe(([,,[S,k],A,P,F,$,B,K,R,W])=>{const Y=P,{offsetTree:X,sizeTree:O}=Y,I=bt(v);if(A===0)return{..._a,totalCount:A};if(S===0&&k===0)return I===0?{..._a,totalCount:A}:Of(I,F,P,K,R,W||[]);if(ot(O))return I>0?null:Is(n0(Pa(F,A),Y,W),[],A,R,Y,K);const H=[];if(B.length>0){const D=B[0],G=B[B.length-1];let _=0;for(const j of ys(O,D,G)){const U=j.value,Z=Math.max(j.start,D),se=Math.min(j.end,G);for(let ae=Z;ae<=se;ae++)H.push({data:W==null?void 0:W[ae],index:ae,offset:_,size:U}),_+=U}}if(!$)return Is([],H,A,R,Y,K);const J=B.length>0?B[B.length-1]+1:0,M=Wy(X,S,k,J);if(M.length===0)return null;const q=A-1,L=ws([],D=>{for(const G of M){const _=G.value;let j=_.offset,U=G.start;const Z=_.size;if(_.offset<S){U+=Math.floor((S-_.offset+R)/(Z+R));const ae=U-G.start;j+=ae*Z+ae*R}U<J&&(j+=(J-U)*Z,U=J);const se=Math.min(G.end,q);for(let ae=U;ae<=se&&!(j>=k);ae++)D.push({data:W==null?void 0:W[ae],index:ae,offset:j,size:Z}),j+=Z+R}});return Is(L,H,A,R,Y,K)}),ke(S=>S!==null),at()),_a);ve(re(e,ke(xa),fe(S=>S==null?void 0:S.length)),o),ve(re(w,fe(S=>S.topListHeight)),p),ve(p,a),ve(re(w,fe(S=>[S.top,S.bottom])),i),ve(re(w,fe(S=>S.items)),y);const C=Zt(re(w,ke(({items:S})=>S.length>0),De(o,e),ke(([{items:S},k])=>S[S.length-1].originalIndex===k-1),fe(([,S,k])=>[S-1,k]),at(fo),fe(([S])=>S))),E=Zt(re(w,Nn(200),ke(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),fe(({items:S})=>S[0].index),at())),T=Zt(re(w,ke(({items:S})=>S.length>0),fe(({items:S})=>{let k=0,A=S.length-1;for(;S[k].type==="group"&&k<A;)k++;for(;S[A].type==="group"&&A>k;)A--;return{endIndex:S[A].index,startIndex:S[k].index}}),at(Tf)));return{endReached:C,initialItemCount:v,itemsRendered:y,listState:w,rangeChanged:T,startReached:E,topItemsIndexes:g,...m}},it(yn,Af,ja,mo,ho,xo,Un,Ea),{singleton:!0}),Lf=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Ot(re(St(n,e,r,t,o),fe(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return ve(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Bt,ur),{singleton:!0}),r0=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=Ot(re(St(n,e,t),ke(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Nn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Bt,Lf),{singleton:!0}),$f=Ye(()=>({context:ie(null)})),o0=({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,Ff=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return ve(re(d,De(t,l,n,s,o,r,a),De(e),fe(([[p,m,f,x,g,v,y,w],C])=>{const{align:E,behavior:T,calculateViewLocation:S=o0,done:k,...A}=p,P=If(p,m,x-1),F=po(P,m.offsetTree,C)+g+v,$=F+fn(m.sizeTree,P)[1],B=w+v,K=w+f-y,R=S({itemBottom:$,itemTop:F,locationParams:{align:E,behavior:T,...A},viewportBottom:K,viewportTop:B});return R?k&&dn(re(i,ke(W=>!W),ar(bt(i)?1:2)),k):k&&k(),R}),ke(p=>p!==null)),c),{scrollIntoView:d}},it(yn,Bt,ho,ur,zn),{singleton:!0});function Bf(e){return e?e==="smooth"?"smooth":"auto":!1}const s0=(e,t)=>typeof e=="function"?Bf(e(t)):t&&Bf(e),i0=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const x=ie(!1),g=We();let v=null;function y(T){_e(i,{align:"end",behavior:T,index:"LAST"})}Je(re(St(re(Te(t),ar(1)),l),De(Te(x),s,a,p),fe(([[T,S],k,A,P,F])=>{let $=S&&P,B="auto";return $&&(B=s0(k,A||F),$=$&&!!B),{followOutputBehavior:B,shouldFollow:$,totalCount:T}}),ke(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:S})=>{v&&(v(),v=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T)}):v=dn(e,()=>{bt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T),v=null})});function w(T){const S=dn(o,k=>{T&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!v&&(bt(d)("scrolling to bottom due to increased size",{},qt.DEBUG),y("auto"))});setTimeout(S,100)}Je(re(St(Te(x),t,c),ke(([T,,S])=>T&&S),wn(({value:T},[,S])=>({refreshed:T===S,value:S}),{refreshed:!1,value:0}),ke(({refreshed:T})=>T),De(x,t)),([,T])=>{bt(a)&&w(T!==!1)}),Je(g,()=>{w(bt(x)!==!1)}),Je(St(Te(x),o),([T,S])=>{T&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=ie(null),E=We();return ve(wa(re(Te(r),fe(T=>{var S;return(S=T==null?void 0:T.length)!=null?S:0})),re(Te(t))),E),Je(re(St(re(E,ar(1)),l),De(Te(C),a,p,m),fe(([[T,S],k,A,P,F])=>S&&A&&(k==null?void 0:k({context:F,totalCount:T,scrollingInProgress:P}))),ke(T=>!!T),Nn(0)),T=>{v&&(v(),v=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),_e(f,T)}):v=dn(e,()=>{bt(d)("scrolling into view",{}),_e(f,T),v=null})}),{autoscrollToBottom:g,followOutput:x,scrollIntoViewOnChange:C}},it(yn,xo,ho,mo,Un,zn,Bt,$f,Ff)),a0=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(re(a,De(s),ke(([,l])=>l!==0),De(o,r,t,n,e),fe(([[,l],c,d,p,m,f=[]])=>Of(l,c,d,p,m,f))),i),{}),it(yn,mo,ur,Un),{singleton:!0}),l0=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return Je(re(e,De(r),ke(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(re(n,ar(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{_e(t,o)})})}),{initialScrollTop:r}},it(Un,Bt,ur),{singleton:!0}),zf=Ye(([{scrollVelocity:e}])=>{const t=ie(!1),n=We(),r=ie(!1);return ve(re(e,De(r,t,n),ke(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Je(re(St(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(xo),{singleton:!0}),Ra=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=ie(!1),i=ie(void 0);return ve(re(St(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ve(re(t,De(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Bt)),c0=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=ie(void 0),p=ie(null),m=ie(null);return ve(a,p),ve(l,m),Je(re(c,De(t,r,i,p,m,n)),([f,x,g,v,y,w,C])=>{const E=Ky(x.sizeTree);v&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=C,f({ranges:E,scrollTop:g})}),ve(re(d,ke(xa),fe(u0)),o),ve(re(s,De(d),ke(([,f])=>f!==void 0),at(),fe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(yn,Bt,mo,Un,Ra));function u0(e){return{align:"start",index:0,offset:e.scrollTop}}const d0=Ye(([{topItemsIndexes:e}])=>{const t=ie(0);return ve(re(t,ke(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ur));function Hf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const f0=Hf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),p0=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:x}])=>{const g=Zt(re(l,De(i),wn(([,y,w,C],[{bottom:E,items:T,offsetBottom:S,totalCount:k},A])=>{const P=E+S;let F=0;return w===k&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||(F=P-C,F!==0&&(F+=A))),[F,T,k,P]},[0,[],0,0]),ke(([y])=>y!==0),De(r,a,n,o,f,x),ke(([,y,w,C,,,E])=>!E&&!C&&y!==0&&w===go),fe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},qt.DEBUG),y))));function v(y){y>0?(_e(t,{behavior:"auto",top:-y}),_e(e,0)):(_e(e,0),_e(t,{behavior:"auto",top:-y}))}return Je(re(g,De(e,s)),([y,w,C])=>{C&&f0()?_e(e,w-y):v(-y)}),Je(re(St(Ot(s,!1),e,x),ke(([y,w,C])=>!y&&!C&&w!==0),fe(([y,w])=>w),Nn(1)),v),ve(re(p,fe(y=>({top:-y}))),t),Je(re(c,De(m,d),fe(([y,{groupIndices:w,lastSize:C,sizeTree:E},T])=>{function S(k){return k*(C+T)}if(w.length===0)return S(y);{let k=0;const A=uo(E,0);let P=0,F=0;for(;P<y;){P++,k+=A;let $=w.length===F+1?1/0:w[F+1]-w[F]-1;P+$>y&&(k-=A,$=y-P+1),P+=$,k+=S($),F++}return k}})),y=>{_e(e,y),requestAnimationFrame(()=>{_e(t,{top:y}),requestAnimationFrame(()=>{_e(e,0),_e(x,!1)})})}),{deviation:e}},it(Bt,xo,ur,yn,zn,Ea)),h0=Ye(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it(ja,a0,Un,zf,Lf,l0,r0,Ra,Ff,zn,$f)),Uf=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:x},g,v,y,{listState:w,topItemsIndexes:C,...E},{scrollToIndex:T},S,{topItemCount:k},{groupCounts:A},P])=>(ve(E.rangeChanged,P.scrollSeekRangeChanged),ve(re(P.windowViewportRect,fe(F=>F.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:x,sizeRanges:a,topItemCount:k,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:p,...E,...P,...g,sizes:l,...v}),it(yn,mo,Bt,c0,i0,ur,ho,p0,d0,Af,h0));function m0(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 Ns=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Wf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(v,y){v.propsReady&&_e(v.propsReady,!1);for(const w of r){const C=v[t.required[w]];_e(C,y[w])}for(const w of o)if(w in y){const C=v[t.optional[w]];_e(C,y[w])}v.propsReady&&_e(v.propsReady,!0)}function c(v){return s.reduce((y,w)=>(y[w]=C=>{const E=v[t.methods[w]];_e(E,C)},y),{})}function d(v){return i.reduce((y,w)=>(y[w]=jy(v[t.events[w]]),y),{})}const p=b.forwardRef((v,y)=>{const{children:w,...C}=v,[E]=b.useState(()=>ws(Ry(e),k=>{l(k,C)})),[T]=b.useState(pf(d,E));Ns(()=>{for(const k of i)k in C&&Je(T[k],C[k]);return()=>{Object.values(T).map(ba)}},[C,T,E]),Ns(()=>{l(E,C)}),b.useImperativeHandle(y,df(c(E)));const S=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(S,{...m0([...r,...o,...i],C),children:w}):w})}),m=v=>{const y=b.useContext(a);return b.useCallback(w=>{_e(y[v],w)},[y,v])},f=v=>{const y=b.useContext(a)[v],w=b.useCallback(C=>Je(y,C),[y]);return b.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},x=v=>{const y=b.useContext(a)[v],[w,C]=b.useState(pf(bt,y));return Ns(()=>Je(y,E=>{E!==w&&C(df(E))}),[y,w]),w},g=b.version.startsWith("18")?f:x;return{Component:p,useEmitter:(v,y)=>{const w=b.useContext(a)[v];Ns(()=>Je(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Vf=b.createContext(void 0),Kf=b.createContext(void 0),qf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ma(e){return"self"in e}function g0(e){return"body"in e}function Gf(e,t,n,r=_r,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,x,g;const v=m.target;if(g0(v)||Ma(v)){const w=Ma(v)?v:v.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,x=s?w.innerWidth:w.innerHeight}else g=s?v.scrollLeft:v.scrollTop,f=s?v.scrollWidth:v.scrollHeight,x=s?v.offsetWidth:v.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:x})};m.suppressFlushSync?y():Oo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-x)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const x=m.behavior==="smooth";let g,v,y;Ma(f)?(v=Math.max(Hn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(v=f[s?"scrollWidth":"scrollHeight"],g=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=v-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),jf(g,v)||m.top===y){e({scrollHeight:v,scrollTop:y,viewportHeight:g}),x&&t(!0);return}x?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const Oa="-webkit-sticky",Yf="sticky",Da=Hf(()=>{if(typeof document>"u")return Yf;const e=document.createElement("div");return e.style.position=Oa,e.style.position===Oa?Oa:Yf});function La(e){return e}const v0=Ye(()=>{const e=ie(a=>`Item ${a}`),t=ie(a=>`Group ${a}`),n=ie({}),r=ie(La),o=ie("div"),s=ie(_r),i=(a,l=null)=>Ot(re(n,fe(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),x0=Ye(([e,t])=>({...e,...t}),it(Uf,v0)),b0=({height:e})=>u.jsx("div",{style:{height:e}}),w0={overflowAnchor:"none",position:Da(),zIndex:1},Xf={overflowAnchor:"none"},y0={...Xf,display:"inline-block",height:"100%"},Jf=b.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=rn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),p=Ne("trackItemSizes"),m=Ne("itemSize"),f=Ne("log"),x=rn("gap"),g=Ne("horizontalDirection"),{callbackRef:v}=Dy(n,m,p,e?_r:a,f,x,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);$a("deviation",R=>{y!==R&&w(R)});const C=Ne("EmptyPlaceholder"),E=Ne("ScrollSeekPlaceholder")||b0,T=Ne("ListComponent"),S=Ne("ItemComponent"),k=Ne("GroupComponent"),A=Ne("computeItemKey"),P=Ne("isSeeking"),F=Ne("groupIndices").length>0,$=Ne("alignToBottom"),B=Ne("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:$?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:$?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Dt(C,c)}):u.jsx(T,{...Dt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:v,style:K,children:(e?t.topItems:t.items).map(R=>{const W=R.originalIndex,Y=A(W+t.firstItemIndex,R.data,c);return P?b.createElement(E,{...Dt(E,c),height:R.size,index:R.index,key:Y,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?b.createElement(k,{...Dt(k,c),"data-index":W,"data-item-index":R.index,"data-known-size":R.size,key:Y,style:w0},d(R.index,c)):b.createElement(S,{...Dt(S,c),...k0(S,R.data),"data-index":W,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:Y,style:g?y0:Xf},F?l(R.index,R.groupIndex,R.data,c):l(R.index,R.data,c))})})}),S0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},C0={outline:"none",overflowX:"auto",position:"relative"},As=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),T0={position:Da(),top:0,width:"100%",zIndex:1};function Dt(e,t){if(typeof e!="string")return{context:t}}function k0(e,t){return{item:typeof e=="string"?void 0:t}}const E0=b.memo(function(){const e=Ne("HeaderComponent"),t=rn("headerHeight"),n=Ne("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),I0=b.memo(function(){const e=Ne("FooterComponent"),t=rn("footerHeight"),n=Ne("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null});function Zf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:x}=Gf(a,c,l,d,void 0,p);return e("scrollTo",x),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?C0:S0,...o},tabIndex:0,...i,...Dt(l,s),children:r})})}function Qf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),x=t("scrollerRef"),{scrollByCallback:g,scrollerRef:v,scrollToCallback:y}=Gf(a,c,l,x,m);return qf(()=>{var w;return v.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{v.current=null}},[v,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...Dt(l,s),children:r})})}const N0=({children:e})=>{const t=b.useContext(Vf),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=b.useMemo(()=>ff(n,l=>Hn(l,s?"width":"height")),[n,s]),a=lr(i,!0,Ne("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:As(o),children:e})},A0=({children:e})=>{const t=b.useContext(Vf),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ne("customScrollParent"),s=vf(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:As(i),children:e})},P0=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...T0,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...Dt(t,o),children:e})},j0=b.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?M0:R0,{...e,context:o,children:[n&&u.jsx(P0,{children:u.jsx(Jf,{showTopList:!0})}),u.jsxs(r||t?A0:N0,{children:[u.jsx(E0,{}),u.jsx(Jf,{}),u.jsx(I0,{})]})]})}),{Component:_0,useEmitter:$a,useEmitterValue:Ne,usePublisher:rn}=Wf(x0,{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"}},j0),R0=Zf({useEmitter:$a,useEmitterValue:Ne,usePublisher:rn}),M0=Qf({useEmitter:$a,useEmitterValue:Ne,usePublisher:rn}),O0=_0;it(Uf,Ye(()=>{const e=ie(c=>u.jsxs("td",{children:["Item $",c]})),t=ie(null),n=ie(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ie(null),o=ie(null),s=ie({}),i=ie(La),a=ie(_r),l=(c,d=null)=>Ot(re(s,fe(p=>p[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Da();const ep={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},D0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:tp,floor:Ps,max:bo,min:Fa,round:np}=Math;function rp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function L0(e){return{...D0,items:e}}function js(e,t){return e&&e.width===t.width&&e.height===t.height}function $0(e,t){return e&&e.column===t.column&&e.row===t.row}const F0=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:x,propsReady:g},{customScrollParent:v,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E},T])=>{const S=ie(0),k=ie(0),A=ie(ep),P=ie({height:0,width:0}),F=ie({height:0,width:0}),$=We(),B=We(),K=ie(0),R=ie(null),W=ie({column:0,row:0}),Y=We(),X=We(),O=ie(!1),I=ie(0),H=ie(!0),J=ie(!1),M=ie(!1);Je(re(x,De(I),ke(([j,U])=>!!U)),()=>{_e(H,!1)}),Je(re(St(x,H,F,P,I,J),ke(([j,U,Z,se,,ae])=>j&&!U&&Z.height!==0&&se.height!==0&&!ae)),([,,,,j])=>{_e(J,!0),Aa(1,()=>{_e($,j)}),dn(re(c),()=>{_e(t,[0,0]),_e(H,!0)})}),ve(re(X,ke(j=>j!=null&&j.scrollTop>0),bn(0)),k),Je(re(x,De(X),ke(([,j])=>j!=null)),([,j])=>{j&&(_e(P,j.viewport),_e(F,j.item),_e(W,j.gap),j.scrollTop>0&&(_e(O,!0),dn(re(c,ar(1)),U=>{_e(O,!1)}),_e(l,{top:j.scrollTop})))}),ve(re(P,fe(({height:j})=>j)),p),ve(re(St(Te(P,js),Te(F,js),Te(W,(j,U)=>j&&j.column===U.column&&j.row===U.row),Te(c)),fe(([j,U,Z,se])=>({gap:Z,item:U,scrollTop:se,viewport:j}))),Y),ve(re(St(Te(S),r,Te(W,$0),Te(F,js),Te(P,js),Te(R),Te(k),Te(O),Te(H),Te(I)),ke(([,,,,,,,j])=>!j),fe(([j,[U,Z],se,ae,Se,Ce,Oe,,Fe,Be])=>{const{column:Ke,row:ze}=se,{height:dt,width:pt}=ae,{width:Ze}=Se;if(Oe===0&&(j===0||Ze===0))return ep;if(pt===0){const Tt=Pa(Be,j),ht=Tt+Math.max(Oe-1,0);return L0(rp(Tt,ht,Ce))}const He=op(Ze,pt,Ke);let Re,qe;Fe?U===0&&Z===0&&Oe>0?(Re=0,qe=Oe-1):(Re=He*Ps((U+ze)/(dt+ze)),qe=He*tp((Z+ze)/(dt+ze))-1,qe=Fa(j-1,bo(qe,He-1)),Re=Fa(qe,bo(0,Re))):(Re=0,qe=-1);const Ae=rp(Re,qe,Ce),{bottom:Ge,top:Xe}=sp(Se,se,ae,Ae),Ct=tp(j/He),Qe=Ct*dt+(Ct-1)*ze-Ge;return{bottom:Ge,itemHeight:dt,items:Ae,itemWidth:pt,offsetBottom:Qe,offsetTop:Xe,top:Xe}})),A),ve(re(R,ke(j=>j!==null),fe(j=>j.length)),S),ve(re(St(P,F,A,W),ke(([j,U,{items:Z}])=>Z.length>0&&U.height!==0&&j.height!==0),fe(([j,U,{items:Z},se])=>{const{bottom:ae,top:Se}=sp(j,se,U,Z);return[Se,ae]}),at(fo)),t);const q=ie(!1);ve(re(c,De(q),fe(([j,U])=>U||j!==0)),q);const L=Zt(re(St(A,S),ke(([{items:j}])=>j.length>0),De(q),ke(([[j,U],Z])=>{const se=j.items[j.items.length-1].index===U-1;return(Z||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===U)&&se}),fe(([[,j]])=>j-1),at())),D=Zt(re(Te(A),ke(({items:j})=>j.length>0&&j[0].index===0),bn(0),at())),G=Zt(re(Te(A),De(O),ke(([{items:j},U])=>j.length>0&&!U),fe(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),at(Tf),Nn(0)));ve(G,f.scrollSeekRangeChanged),ve(re($,De(P,F,S,W),fe(([j,U,Z,se,ae])=>{const Se=Pf(j),{align:Ce,behavior:Oe,offset:Fe}=Se;let Be=Se.index;Be==="LAST"&&(Be=se-1),Be=bo(0,Be,Fa(se-1,Be));let Ke=Ba(U,ae,Z,Be);return Ce==="end"?Ke=np(Ke-U.height+Z.height):Ce==="center"&&(Ke=np(Ke-U.height/2+Z.height/2)),Fe&&(Ke+=Fe),{behavior:Oe,top:Ke}})),l);const _=Ot(re(A,fe(j=>j.offsetBottom+j.bottom)),0);return ve(re(E,fe(j=>({height:j.visibleHeight,width:j.visibleWidth}))),P),{customScrollParent:v,data:R,deviation:K,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:F,overscan:n,restoreStateFrom:X,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:$,scrollTop:c,smoothScrollTargetReached:d,totalCount:S,useWindowScroll:y,viewportDimensions:P,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E,...f,gridState:A,horizontalDirection:M,initialTopMostItemIndex:I,totalListHeight:_,...m,endReached:L,propsReady:g,rangeChanged:G,startReached:D,stateChanged:Y,stateRestoreInProgress:O,...T}},it(ja,Bt,xo,zf,Un,Ra,zn));function op(e,t,n){return bo(1,Ps((e+n)/(Ps(t)+n)))}function sp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ba(e,t,n,r[0].index);return{bottom:Ba(e,t,n,r[r.length-1].index)+o,top:s}}function Ba(e,t,n,r){const o=op(e.width,n.width,t.column),s=Ps(r/o),i=s*n.height+bo(0,s-1)*t.row;return i>0?i+t.row:i}const B0=Ye(()=>{const e=ie(p=>`Item ${p}`),t=ie({}),n=ie(null),r=ie("virtuoso-grid-item"),o=ie("virtuoso-grid-list"),s=ie(La),i=ie("div"),a=ie(_r),l=(p,m=null)=>Ot(re(t,fe(f=>f[p]),at()),m),c=ie(!1),d=ie(!1);return ve(Te(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),z0=Ye(([e,t])=>({...e,...t}),it(F0,B0)),H0=b.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=on("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),c=lt("ScrollSeekPlaceholder"),d=lt("context"),p=on("itemDimensions"),m=on("gap"),f=lt("log"),x=lt("stateRestoreInProgress"),g=on("reportReadyState"),v=lr(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const C=y.firstChild;if(C){const{height:E,width:T}=C.getBoundingClientRect();p({height:E,width:T})}m({column:ap("column-gap",getComputedStyle(y).columnGap,f),row:ap("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return qf(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),x?null:u.jsx(l,{className:t,ref:v,...Dt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...Dt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Dt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),U0=b.memo(function(){const e=lt("HeaderComponent"),t=on("headerHeight"),n=lt("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),W0=b.memo(function(){const e=lt("FooterComponent"),t=on("footerHeight"),n=lt("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),V0=({children:e})=>{const t=b.useContext(Kf),n=on("itemDimensions"),r=on("viewportDimensions"),o=lr(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:As(!1),children:e})},K0=({children:e})=>{const t=b.useContext(Kf),n=on("windowViewportRect"),r=on("itemDimensions"),o=lt("customScrollParent"),s=vf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:As(!1),children:e})},q0=b.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?Y0:G0,o=n||t?K0:V0,s=lt("context");return u.jsx(r,{...e,...Dt(r,s),children:u.jsxs(o,{children:[u.jsx(U0,{}),u.jsx(H0,{}),u.jsx(W0,{})]})})}),{useEmitter:ip,useEmitterValue:lt,usePublisher:on}=Wf(z0,{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"}},q0),G0=Zf({useEmitter:ip,useEmitterValue:lt,usePublisher:on}),Y0=Qf({useEmitter:ip,useEmitterValue:lt,usePublisher:on});function ap(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}const X0={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},za=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ha=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s=0,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,showToolMessages:m,checkpointIndex:f,onSelectCheckpoint:x,getMessageCustomStyles:g,getInterruptOptions:v,toolConfig:y}){const w=za(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming||o===t.id&&t.role==="assistant",k=f??X0,A=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:P,attemptIndex:F,attempts:$}=b.useMemo(()=>cc(t.id,A,k),[t.id,A,k]),B=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":w,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(xs,{message:t,messageIndex:n,isStreamingMessage:S,renderStreamingMarkdown:S,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,getInterruptOptions:v,showToolMessages:m,attemptCount:P,attemptIndex:F,attemptMetas:$,onSelectCheckpoint:x,customStyles:B,toolConfig:y})})});Ha.displayName="MessageRow";const Ua=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r=0,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:x=!0,isNavigatingCheckpoint:g=!1,onScrollAway:v,onAtBottom:y,showToolMessages:w=!0,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,createSyntheticThinkingMessage:k=!0,forceSyntheticThinking:A=!1,getMessageCustomStyles:P,getInterruptOptions:F},$)=>{const B=b.useRef(null),K=b.useRef(null),R=b.useRef(!1),W=b.useRef(!1),Y=e,X=b.useMemo(()=>{const _=n&&Y.some(U=>U.id===n);return k&&(t||A)&&!_&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y},[Y,t,n,k,A]),O=b.useMemo(()=>w?X:X.filter(_=>(_==null?void 0:_.role)!=="tool"),[X,w]),I=b.useCallback(_=>{v&&v(!_),y&&y(_)},[v,y]),H=b.useMemo(()=>{if(a)return async()=>{if(!R.current){R.current=!0;try{await a()}finally{R.current=!1}}}},[a]),J=b.useMemo(()=>!x||g?!1:"auto",[x,g]),M=b.useMemo(()=>{if(typeof f!="string")return null;const _=f.trim();return!_||O&&O.length>0?null:{id:"default-message",role:"default_message",content:_,createdAt:new Date().toISOString()}},[f,O]),q=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),L=()=>{if(M){const _=P==null?void 0:P(M);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(xs,{message:M,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:_,getInterruptOptions:F})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"})},D=O.length,G=D>0;return b.useEffect(()=>{var _,j;if(D===0){W.current=!1;return}if(!W.current)if(W.current=!0,B.current&&O.length>0){const U=O.length-1;(j=(_=B.current).scrollToIndex)==null||j.call(_,{index:U,align:"end",behavior:"auto"})}else K.current&&(K.current.scrollTop=K.current.scrollHeight)},[D,O.length]),b.useImperativeHandle($,()=>({scrollToLatest:()=>{var _,j;if(B.current&&O.length>0){const U=O.length-1;(j=(_=B.current).scrollToIndex)==null||j.call(_,{index:U,align:"end",behavior:"auto"})}else K.current&&(K.current.scrollTop=K.current.scrollHeight)},scrollToTop:()=>{var _,j;B.current&&O.length>0?(j=(_=B.current).scrollToIndex)==null||j.call(_,{index:0,align:"start",behavior:"auto"}):K.current&&(K.current.scrollTop=0)}}),[O]),u.jsx("div",{className:q,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:G?u.jsx(O0,{ref:_=>{B.current=_},scrollerRef:_=>{K.current=_ instanceof HTMLDivElement?_:null},data:O,followOutput:J,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{H&&H()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(_,j)=>za(j,_),itemContent:(_,j)=>u.jsx(Ha,{message:j,index:_,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:w,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,getMessageCustomStyles:P,getInterruptOptions:F})}):L()})})});Ua.displayName="MessageList";function lp({message:e,viewMode:t,isStreaming:n=!1,toolConfig:r,expandable:o=!1}){var F;const s=Go(e),i=e.artifact??null,a=cf(e),c=(a?Tu(a):null)??a,d=e.content.find($=>$.type!=="tool_call"),p=$=>{if($==null)return null;const B=typeof $=="string"?er($)??$:$;if(B&&typeof B=="object")return u.jsx(hs,{data:B});const K=typeof B=="string"?B:(()=>{try{return tr(B)}catch{return String(B??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:K})},m=$=>{if($==null)return null;const{content:B,isMarkdown:K}=gu($);return K?u.jsx(ir,{content:B,className:"text-current"}):p($)},f=$=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(hs,{data:$})]}),x=()=>{if((c==null?void 0:c.kind)==="generic")return m(c.value);if(!d)return null;if(d.type==="text"){const R=(d.text??"").trim();if(!R)return null;const W=nr(R);return m(W)}const $=Sr(d),B=nr($);return m(B)},g=()=>(c==null?void 0:c.kind)==="dict"?f(c.data):x(),v=()=>{if(!y)return;if(s.name){const B=y[s.name];if(B)return B}const $=(c==null?void 0:c.kind)??(a==null?void 0:a.kind);if($){const B=y[$];if(B)return B}return y.default},{toolRenderers:y,toolArtifactRenderers:w}=r??{},C=v(),E=g(),T=!o||t==="expanded",S=(T?C==null?void 0:C({message:e,toolMeta:s,toolPayload:c,viewMode:t,isStreaming:n}):null)??null,A=((F=(()=>{if(!w)return;const $=i==null?void 0:i.type;if(typeof $=="string"){const B=w[$];if(B)return B}return w.default})())==null?void 0:F({artifact:i,message:e,toolPayload:c,isStreaming:n}))??null,P=S??E;return u.jsxs("div",{className:"space-y-2",children:[i&&(A??u.jsx(Yd,{artifact:i,idx:0})),u.jsx(Xd,{message:e,isStreaming:n}),T?P:null]})}function _s(e){const t=e+"CollectionProvider",[n,r]=nn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:v,children:y}=g,w=b.useRef(null),C=b.useRef(new Map).current;return u.jsx(o,{scope:v,itemMap:C,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Jt.createSlot(a),c=b.forwardRef((g,v)=>{const{scope:y,children:w}=g,C=s(a,y),E=Me(v,C.collectionRef);return u.jsx(l,{ref:E,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Jt.createSlot(d),f=b.forwardRef((g,v)=>{const{scope:y,children:w,...C}=g,E=b.useRef(null),T=Me(v,E),S=s(d,y);return b.useEffect(()=>(S.itemMap.set(E,{ref:E,...C}),()=>void S.itemMap.delete(E))),u.jsx(m,{[p]:"",ref:T,children:w})});f.displayName=d;function x(g){const v=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((S,k)=>C.indexOf(S.ref.current)-C.indexOf(k.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},x,r]}var J0=h.createContext(void 0);function Rs(e){const t=h.useContext(J0);return e||t||"ltr"}const Z0=["top","right","bottom","left"],Wn=Math.min,en=Math.max,Ms=Math.round,Os=Math.floor,Sn=e=>({x:e,y:e}),Q0={left:"right",right:"left",bottom:"top",top:"bottom"},eS={start:"end",end:"start"};function Wa(e,t,n){return en(e,Wn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Pn(e){return e.split("-")[0]}function Mr(e){return e.split("-")[1]}function Va(e){return e==="x"?"y":"x"}function Ka(e){return e==="y"?"height":"width"}const tS=new Set(["top","bottom"]);function Cn(e){return tS.has(Pn(e))?"y":"x"}function qa(e){return Va(Cn(e))}function nS(e,t,n){n===void 0&&(n=!1);const r=Mr(e),o=qa(e),s=Ka(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ds(i)),[i,Ds(i)]}function rS(e){const t=Ds(e);return[Ga(e),t,Ga(t)]}function Ga(e){return e.replace(/start|end/g,t=>eS[t])}const cp=["left","right"],up=["right","left"],oS=["top","bottom"],sS=["bottom","top"];function iS(e,t,n){switch(e){case"top":case"bottom":return n?t?up:cp:t?cp:up;case"left":case"right":return t?oS:sS;default:return[]}}function aS(e,t,n,r){const o=Mr(e);let s=iS(Pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ga)))),s}function Ds(e){return e.replace(/left|right|bottom|top/g,t=>Q0[t])}function lS(e){return{top:0,right:0,bottom:0,left:0,...e}}function dp(e){return typeof e!="number"?lS(e):{top:e,right:e,bottom:e,left:e}}function Ls(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 fp(e,t,n){let{reference:r,floating:o}=e;const s=Cn(t),i=qa(t),a=Ka(i),l=Pn(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(Mr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const cS=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=fp(c,r,l),m=r,f={},x=0;for(let g=0;g<a.length;g++){const{name:v,fn:y}=a[g],{x:w,y:C,data:E,reset:T}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,p=C??p,f={...f,[v]:{...f[v],...E}},T&&x<=50&&(x++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:p}=fp(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function wo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),x=dp(f),v=a[m?p==="floating"?"reference":"floating":p],y=Ls(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},T=Ls(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:l}):w);return{top:(y.top-T.top+x.top)/E.y,bottom:(T.bottom-y.bottom+x.bottom)/E.y,left:(y.left-T.left+x.left)/E.x,right:(T.right-y.right+x.right)/E.x}}const uS=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const p=dp(d),m={x:n,y:r},f=qa(o),x=Ka(f),g=await i.getDimensions(c),v=f==="y",y=v?"top":"left",w=v?"bottom":"right",C=v?"clientHeight":"clientWidth",E=s.reference[x]+s.reference[f]-m[f]-s.floating[x],T=m[f]-s.reference[f],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let k=S?S[C]:0;(!k||!await(i.isElement==null?void 0:i.isElement(S)))&&(k=a.floating[C]||s.floating[x]);const A=E/2-T/2,P=k/2-g[x]/2-1,F=Wn(p[y],P),$=Wn(p[w],P),B=F,K=k-g[x]-$,R=k/2-g[x]/2+A,W=Wa(B,R,K),Y=!l.arrow&&Mr(o)!=null&&R!==W&&s.reference[x]/2-(R<B?F:$)-g[x]/2<0,X=Y?R<B?R-B:R-K:0;return{[f]:m[f]+X,data:{[f]:W,centerOffset:R-W-X,...Y&&{alignmentOffset:X}},reset:Y}}}),dS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...v}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pn(o),w=Cn(a),C=Pn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=m||(C||!g?[Ds(a)]:rS(a)),S=x!=="none";!m&&S&&T.push(...aS(a,g,x,E));const k=[a,...T],A=await wo(t,v),P=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(A[y]),p){const R=nS(o,i,E);P.push(A[R[0]],A[R[1]])}if(F=[...F,{placement:o,overflows:P}],!P.every(R=>R<=0)){var $,B;const R=((($=s.flip)==null?void 0:$.index)||0)+1,W=k[R];if(W&&(!(p==="alignment"?w!==Cn(W):!1)||F.every(O=>Cn(O.placement)===w?O.overflows[0]>0:!0)))return{data:{index:R,overflows:F},reset:{placement:W}};let Y=(B=F.filter(X=>X.overflows[0]<=0).sort((X,O)=>X.overflows[1]-O.overflows[1])[0])==null?void 0:B.placement;if(!Y)switch(f){case"bestFit":{var K;const X=(K=F.filter(O=>{if(S){const I=Cn(O.placement);return I===w||I==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(I=>I>0).reduce((I,H)=>I+H,0)]).sort((O,I)=>O[1]-I[1])[0])==null?void 0:K[0];X&&(Y=X);break}case"initialPlacement":Y=a;break}if(o!==Y)return{reset:{placement:Y}}}return{}}}};function pp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hp(e){return Z0.some(t=>e[t]>=0)}const fS=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await wo(t,{...o,elementContext:"reference"}),i=pp(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:hp(i)}}}case"escaped":{const s=await wo(t,{...o,altBoundary:!0}),i=pp(s,n.floating);return{data:{escapedOffsets:i,escaped:hp(i)}}}default:return{}}}}},mp=new Set(["left","top"]);async function pS(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pn(n),a=Mr(n),l=Cn(n)==="y",c=mp.has(i)?-1:1,d=s&&l?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof x=="number"&&(f=a==="end"?x*-1:x),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const hS=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await pS(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},mS=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:v=>{let{x:y,y:w}=v;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await wo(t,l),p=Cn(Pn(o)),m=Va(p);let f=c[m],x=c[p];if(s){const v=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[v],C=f-d[y];f=Wa(w,f,C)}if(i){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",w=x+d[v],C=x-d[y];x=Wa(w,x,C)}const g=a.fn({...t,[m]:f,[p]:x});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},gS=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},p=Cn(o),m=Va(p);let f=d[m],x=d[p];const g=An(a,t),v=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",E=s.reference[m]-s.floating[C]+v.mainAxis,T=s.reference[m]+s.reference[C]-v.mainAxis;f<E?f=E:f>T&&(f=T)}if(c){var y,w;const C=m==="y"?"width":"height",E=mp.has(Pn(o)),T=s.reference[p]-s.floating[C]+(E&&((y=i.offset)==null?void 0:y[p])||0)+(E?0:v.crossAxis),S=s.reference[p]+s.reference[C]+(E?0:((w=i.offset)==null?void 0:w[p])||0)-(E?v.crossAxis:0);x<T?x=T:x>S&&(x=S)}return{[m]:f,[p]:x}}}},vS=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await wo(t,c),p=Pn(o),m=Mr(o),f=Cn(o)==="y",{width:x,height:g}=s.floating;let v,y;p==="top"||p==="bottom"?(v=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,v=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,C=x-d.left-d.right,E=Wn(g-d[v],w),T=Wn(x-d[y],C),S=!t.middlewareData.shift;let k=E,A=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),S&&!m){const F=en(d.left,0),$=en(d.right,0),B=en(d.top,0),K=en(d.bottom,0);f?A=x-2*(F!==0||$!==0?F+$:en(d.left,d.right)):k=g-2*(B!==0||K!==0?B+K:en(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:k});const P=await i.getDimensions(a.floating);return x!==P.width||g!==P.height?{reset:{rects:!0}}:{}}}};function $s(){return typeof window<"u"}function Or(e){return gp(e)?(e.nodeName||"").toLowerCase():"#document"}function tn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Tn(e){var t;return(t=(gp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function gp(e){return $s()?e instanceof Node||e instanceof tn(e).Node:!1}function pn(e){return $s()?e instanceof Element||e instanceof tn(e).Element:!1}function kn(e){return $s()?e instanceof HTMLElement||e instanceof tn(e).HTMLElement:!1}function vp(e){return!$s()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof tn(e).ShadowRoot}const xS=new Set(["inline","contents"]);function yo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=hn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!xS.has(o)}const bS=new Set(["table","td","th"]);function wS(e){return bS.has(Or(e))}const yS=[":popover-open",":modal"];function Fs(e){return yS.some(t=>{try{return e.matches(t)}catch{return!1}})}const SS=["transform","translate","scale","rotate","perspective"],CS=["transform","translate","scale","rotate","perspective","filter"],TS=["paint","layout","strict","content"];function Ya(e){const t=Xa(),n=pn(e)?hn(e):e;return SS.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)||CS.some(r=>(n.willChange||"").includes(r))||TS.some(r=>(n.contain||"").includes(r))}function kS(e){let t=Vn(e);for(;kn(t)&&!Dr(t);){if(Ya(t))return t;if(Fs(t))return null;t=Vn(t)}return null}function Xa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ES=new Set(["html","body","#document"]);function Dr(e){return ES.has(Or(e))}function hn(e){return tn(e).getComputedStyle(e)}function Bs(e){return pn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vn(e){if(Or(e)==="html")return e;const t=e.assignedSlot||e.parentNode||vp(e)&&e.host||Tn(e);return vp(t)?t.host:t}function xp(e){const t=Vn(e);return Dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:kn(t)&&yo(t)?t:xp(t)}function So(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=xp(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=tn(o);if(s){const a=Ja(i);return t.concat(i,i.visualViewport||[],yo(o)?o:[],a&&n?So(a):[])}return t.concat(o,So(o,[],n))}function Ja(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bp(e){const t=hn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=kn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ms(n)!==s||Ms(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Za(e){return pn(e)?e:e.contextElement}function Lr(e){const t=Za(e);if(!kn(t))return Sn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=bp(t);let i=(s?Ms(n.width):n.width)/r,a=(s?Ms(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const IS=Sn(0);function wp(e){const t=tn(e);return!Xa()||!t.visualViewport?IS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function NS(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==tn(e)?!1:t}function dr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Za(e);let i=Sn(1);t&&(r?pn(r)&&(i=Lr(r)):i=Lr(e));const a=NS(s,n,r)?wp(s):Sn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=tn(s),f=r&&pn(r)?tn(r):r;let x=m,g=Ja(x);for(;g&&r&&f!==x;){const v=Lr(g),y=g.getBoundingClientRect(),w=hn(g),C=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*v.x,E=y.top+(g.clientTop+parseFloat(w.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,p*=v.y,l+=C,c+=E,x=tn(g),g=Ja(x)}}return Ls({width:d,height:p,x:l,y:c})}function zs(e,t){const n=Bs(e).scrollLeft;return t?t.left+n:dr(Tn(e)).left+n}function yp(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-zs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function AS(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Tn(r),a=t?Fs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Sn(1);const d=Sn(0),p=kn(r);if((p||!p&&!s)&&((Or(r)!=="body"||yo(i))&&(l=Bs(r)),kn(r))){const f=dr(r);c=Lr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?yp(i,l):Sn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function PS(e){return Array.from(e.getClientRects())}function jS(e){const t=Tn(e),n=Bs(e),r=e.ownerDocument.body,o=en(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=en(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+zs(e);const a=-n.scrollTop;return hn(r).direction==="rtl"&&(i+=en(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Sp=25;function _S(e,t){const n=tn(e),r=Tn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Xa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=zs(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-f);x<=Sp&&(s-=x)}else c<=Sp&&(s+=c);return{width:s,height:i,x:a,y:l}}const RS=new Set(["absolute","fixed"]);function MS(e,t){const n=dr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=kn(e)?Lr(e):Sn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Cp(e,t,n){let r;if(t==="viewport")r=_S(e,n);else if(t==="document")r=jS(Tn(e));else if(pn(t))r=MS(t,n);else{const o=wp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ls(r)}function Tp(e,t){const n=Vn(e);return n===t||!pn(n)||Dr(n)?!1:hn(n).position==="fixed"||Tp(n,t)}function OS(e,t){const n=t.get(e);if(n)return n;let r=So(e,[],!1).filter(a=>pn(a)&&Or(a)!=="body"),o=null;const s=hn(e).position==="fixed";let i=s?Vn(e):e;for(;pn(i)&&!Dr(i);){const a=hn(i),l=Ya(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&RS.has(o.position)||yo(i)&&!l&&Tp(e,i))?r=r.filter(d=>d!==i):o=a,i=Vn(i)}return t.set(e,r),r}function DS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Fs(t)?[]:OS(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=Cp(t,d,o);return c.top=en(p.top,c.top),c.right=Wn(p.right,c.right),c.bottom=Wn(p.bottom,c.bottom),c.left=en(p.left,c.left),c},Cp(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function LS(e){const{width:t,height:n}=bp(e);return{width:t,height:n}}function $S(e,t,n){const r=kn(t),o=Tn(t),s=n==="fixed",i=dr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Sn(0);function c(){l.x=zs(o)}if(r||!r&&!s)if((Or(t)!=="body"||yo(o))&&(a=Bs(t)),r){const f=dr(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?yp(o,a):Sn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function Qa(e){return hn(e).position==="static"}function kp(e,t){if(!kn(e)||hn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Tn(e)===n&&(n=n.ownerDocument.body),n}function Ep(e,t){const n=tn(e);if(Fs(e))return n;if(!kn(e)){let o=Vn(e);for(;o&&!Dr(o);){if(pn(o)&&!Qa(o))return o;o=Vn(o)}return n}let r=kp(e,t);for(;r&&wS(r)&&Qa(r);)r=kp(r,t);return r&&Dr(r)&&Qa(r)&&!Ya(r)?n:r||kS(e)||n}const FS=async function(e){const t=this.getOffsetParent||Ep,n=this.getDimensions,r=await n(e.floating);return{reference:$S(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function BS(e){return hn(e).direction==="rtl"}const zS={convertOffsetParentRelativeRectToViewportRelativeRect:AS,getDocumentElement:Tn,getClippingRect:DS,getOffsetParent:Ep,getElementRects:FS,getClientRects:PS,getDimensions:LS,getScale:Lr,isElement:pn,isRTL:BS};function Ip(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function HS(e,t){let n=null,r;const o=Tn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const x=Os(p),g=Os(o.clientWidth-(d+m)),v=Os(o.clientHeight-(p+f)),y=Os(d),C={rootMargin:-x+"px "+-g+"px "+-v+"px "+-y+"px",threshold:en(0,Wn(1,l))||1};let E=!0;function T(S){const k=S[0].intersectionRatio;if(k!==l){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Ip(c,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(T,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,C)}n.observe(e)}return i(!0),s}function US(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Za(e),d=o||s?[...c?So(c):[],...So(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?HS(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let x,g=l?dr(e):null;l&&v();function v(){const y=dr(e);g&&!Ip(g,y)&&n(),g=y,x=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(x)}}const WS=hS,VS=mS,KS=dS,qS=vS,GS=fS,Np=uS,YS=gS,XS=(e,t,n)=>{const r=new Map,o={platform:zS,...n},s={...o.platform,_c:r};return cS(e,t,{...o,platform:s})};var JS=typeof document<"u",ZS=function(){},Hs=JS?b.useLayoutEffect:ZS;function Us(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(!Us(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)&&!Us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ap(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pp(e,t){const n=Ap(e);return Math.round(t*n)/n}function el(e){const t=h.useRef(e);return Hs(()=>{t.current=e}),t}function QS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);Us(m,r)||f(r);const[x,g]=h.useState(null),[v,y]=h.useState(null),w=h.useCallback(O=>{O!==S.current&&(S.current=O,g(O))},[]),C=h.useCallback(O=>{O!==k.current&&(k.current=O,y(O))},[]),E=s||x,T=i||v,S=h.useRef(null),k=h.useRef(null),A=h.useRef(d),P=l!=null,F=el(l),$=el(o),B=el(c),K=h.useCallback(()=>{if(!S.current||!k.current)return;const O={placement:t,strategy:n,middleware:m};$.current&&(O.platform=$.current),XS(S.current,k.current,O).then(I=>{const H={...I,isPositioned:B.current!==!1};R.current&&!Us(A.current,H)&&(A.current=H,qr.flushSync(()=>{p(H)}))})},[m,t,n,$,B]);Hs(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p(O=>({...O,isPositioned:!1})))},[c]);const R=h.useRef(!1);Hs(()=>(R.current=!0,()=>{R.current=!1}),[]),Hs(()=>{if(E&&(S.current=E),T&&(k.current=T),E&&T){if(F.current)return F.current(E,T,K);K()}},[E,T,K,F,P]);const W=h.useMemo(()=>({reference:S,floating:k,setReference:w,setFloating:C}),[w,C]),Y=h.useMemo(()=>({reference:E,floating:T}),[E,T]),X=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!Y.floating)return O;const I=Pp(Y.floating,d.x),H=Pp(Y.floating,d.y);return a?{...O,transform:"translate("+I+"px, "+H+"px)",...Ap(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:H}},[n,a,Y.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:K,refs:W,elements:Y,floatingStyles:X}),[d,K,W,Y,X])}const eC=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?Np({element:r.current,padding:o}).fn(n):{}:r?Np({element:r,padding:o}).fn(n):{}}}},tC=(e,t)=>({...WS(e),options:[e,t]}),nC=(e,t)=>({...VS(e),options:[e,t]}),rC=(e,t)=>({...YS(e),options:[e,t]}),oC=(e,t)=>({...KS(e),options:[e,t]}),sC=(e,t)=>({...qS(e),options:[e,t]}),iC=(e,t)=>({...GS(e),options:[e,t]}),aC=(e,t)=>({...eC(e),options:[e,t]});var lC="Arrow",jp=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});jp.displayName=lC;var cC=jp;function _p(e){const[t,n]=h.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var tl="Popper",[Rp,$r]=nn(tl),[uC,Mp]=Rp(tl),Op=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(uC,{scope:t,anchor:r,onAnchorChange:o,children:n})};Op.displayName=tl;var Dp="PopperAnchor",Lp=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Mp(Dp,n),i=h.useRef(null),a=Me(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Lp.displayName=Dp;var nl="PopperContent",[dC,fC]=Rp(nl),$p=h.forwardRef((e,t)=>{var _,j,U,Z,se,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:x,...g}=e,v=Mp(nl,n),[y,w]=h.useState(null),C=Me(t,Se=>w(Se)),[E,T]=h.useState(null),S=_p(E),k=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,P=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(c)?c:[c],B=$.length>0,K={padding:F,boundary:$.filter(hC),altBoundary:B},{refs:R,floatingStyles:W,placement:Y,isPositioned:X,middlewareData:O}=QS({strategy:"fixed",placement:P,whileElementsMounted:(...Se)=>US(...Se,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[tC({mainAxis:o+A,alignmentAxis:i}),l&&nC({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?rC():void 0,...K}),l&&oC({...K}),sC({...K,apply:({elements:Se,rects:Ce,availableWidth:Oe,availableHeight:Fe})=>{const{width:Be,height:Ke}=Ce.reference,ze=Se.floating.style;ze.setProperty("--radix-popper-available-width",`${Oe}px`),ze.setProperty("--radix-popper-available-height",`${Fe}px`),ze.setProperty("--radix-popper-anchor-width",`${Be}px`),ze.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),E&&aC({element:E,padding:a}),mC({arrowWidth:k,arrowHeight:A}),m&&iC({strategy:"referenceHidden",...K})]}),[I,H]=zp(Y),J=xt(x);It(()=>{X&&(J==null||J())},[X,J]);const M=(_=O.arrow)==null?void 0:_.x,q=(j=O.arrow)==null?void 0:j.y,L=((U=O.arrow)==null?void 0:U.centerOffset)!==0,[D,G]=h.useState();return It(()=>{y&&G(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:X?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:D,"--radix-popper-transform-origin":[(Z=O.transformOrigin)==null?void 0:Z.x,(se=O.transformOrigin)==null?void 0:se.y].join(" "),...((ae=O.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(dC,{scope:n,placedSide:I,onArrowChange:T,arrowX:M,arrowY:q,shouldHideArrow:L,children:u.jsx(me.div,{"data-side":I,"data-align":H,...g,ref:C,style:{...g.style,animation:X?void 0:"none"}})})})});$p.displayName=nl;var Fp="PopperArrow",pC={top:"bottom",right:"left",bottom:"top",left:"right"},Bp=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=fC(Fp,r),i=pC[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(cC,{...o,ref:n,style:{...o.style,display:"block"}})})});Bp.displayName=Fp;function hC(e){return e!==null}var mC=e=>({name:"transformOrigin",options:e,fn(t){var v,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=zp(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let x="",g="";return c==="bottom"?(x=i?p:`${m}px`,g=`${-l}px`):c==="top"?(x=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(x=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(x=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x,y:g}}}});function zp(e){const[t,n="center"]=e.split("-");return[t,n]}var rl=Op,ol=Lp,sl=$p,il=Bp,al="rovingFocusGroup.onEntryFocus",gC={bubbles:!1,cancelable:!0},Co="RovingFocusGroup",[ll,Hp,vC]=_s(Co),[xC,Up]=nn(Co,[vC]),[bC,wC]=xC(Co),Wp=h.forwardRef((e,t)=>u.jsx(ll.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ll.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(yC,{...e,ref:t})})}));Wp.displayName=Co;var yC=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=Me(t,m),x=Rs(s),[g,v]=In({prop:i,defaultProp:a??null,onChange:l,caller:Co}),[y,w]=h.useState(!1),C=xt(c),E=Hp(n),T=h.useRef(!1),[S,k]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(al,C),()=>A.removeEventListener(al,C)},[C]),u.jsx(bC,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>v(A),[v]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>k(A=>A-1),[]),children:u.jsx(me.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{T.current=!0}),onFocus:le(e.onFocus,A=>{const P=!T.current;if(A.target===A.currentTarget&&P&&!y){const F=new CustomEvent(al,gC);if(A.currentTarget.dispatchEvent(F),!F.defaultPrevented){const $=E().filter(Y=>Y.focusable),B=$.find(Y=>Y.active),K=$.find(Y=>Y.id===g),W=[B,K,...$].filter(Boolean).map(Y=>Y.ref.current);qp(W,d)}}T.current=!1}),onBlur:le(e.onBlur,()=>w(!1))})})}),Vp="RovingFocusGroupItem",Kp=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=wC(Vp,n),p=d.currentTabStopId===c,m=Hp(n),{onFocusableItemAdd:f,onFocusableItemRemove:x,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>x()},[r,f,x]),u.jsx(ll.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:le(e.onMouseDown,v=>{r?d.onItemFocus(c):v.preventDefault()}),onFocus:le(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:le(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=TC(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const E=C.indexOf(v.currentTarget);C=d.loop?kC(C,E+1):C.slice(E+1)}setTimeout(()=>qp(C))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Kp.displayName=Vp;var SC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function TC(e,t,n){const r=CC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return SC[r]}function qp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function kC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var EC=Wp,IC=Kp,cl=["Enter"," "],NC=["ArrowDown","PageUp","Home"],Gp=["ArrowUp","PageDown","End"],AC=[...NC,...Gp],PC={ltr:[...cl,"ArrowRight"],rtl:[...cl,"ArrowLeft"]},jC={ltr:["ArrowLeft"],rtl:["ArrowRight"]},To="Menu",[ko,_C,RC]=_s(To),[fr,Yp]=nn(To,[RC,$r,Up]),Ws=$r(),Xp=Up(),[MC,pr]=fr(To),[OC,Eo]=fr(To),Jp=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ws(t),[l,c]=h.useState(null),d=h.useRef(!1),p=xt(s),m=Rs(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),u.jsx(rl,{...a,children:u.jsx(MC,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(OC,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Jp.displayName=To;var DC="MenuAnchor",ul=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ws(n);return u.jsx(ol,{...o,...r,ref:t})});ul.displayName=DC;var dl="MenuPortal",[LC,Zp]=fr(dl,{forceMount:void 0}),Qp=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=pr(dl,t);return u.jsx(LC,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(oo,{asChild:!0,container:o,children:r})})})};Qp.displayName=dl;var sn="MenuContent",[$C,fl]=fr(sn),eh=h.forwardRef((e,t)=>{const n=Zp(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu);return u.jsx(ko.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ko.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(FC,{...o,ref:t}):u.jsx(BC,{...o,ref:t})})})})}),FC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return ea(s)},[]),u.jsx(pl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),BC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu);return u.jsx(pl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),zC=Jt.createSlot("MenuContent.ScrollLock"),pl=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:x,...g}=e,v=pr(sn,n),y=Eo(sn,n),w=Ws(n),C=Xp(n),E=_C(n),[T,S]=h.useState(null),k=h.useRef(null),A=Me(t,k,v.onContentChange),P=h.useRef(0),F=h.useRef(""),$=h.useRef(0),B=h.useRef(null),K=h.useRef("right"),R=h.useRef(0),W=x?rs:h.Fragment,Y=x?{as:zC,allowPinchZoom:!0}:void 0,X=I=>{var _,j;const H=F.current+I,J=E().filter(U=>!U.disabled),M=document.activeElement,q=(_=J.find(U=>U.ref.current===M))==null?void 0:_.textValue,L=J.map(U=>U.textValue),D=QC(L,H,q),G=(j=J.find(U=>U.textValue===D))==null?void 0:j.ref.current;(function U(Z){F.current=Z,window.clearTimeout(P.current),Z!==""&&(P.current=window.setTimeout(()=>U(""),1e3))})(H),G&&setTimeout(()=>G.focus())};h.useEffect(()=>()=>window.clearTimeout(P.current),[]),Gi();const O=h.useCallback(I=>{var J,M;return K.current===((J=B.current)==null?void 0:J.side)&&tT(I,(M=B.current)==null?void 0:M.area)},[]);return u.jsx($C,{scope:n,searchRef:F,onItemEnter:h.useCallback(I=>{O(I)&&I.preventDefault()},[O]),onItemLeave:h.useCallback(I=>{var H;O(I)||((H=k.current)==null||H.focus(),S(null))},[O]),onTriggerLeave:h.useCallback(I=>{O(I)&&I.preventDefault()},[O]),pointerGraceTimerRef:$,onPointerGraceIntentChange:h.useCallback(I=>{B.current=I},[]),children:u.jsx(W,{...Y,children:u.jsx(Xo,{asChild:!0,trapped:o,onMountAutoFocus:le(s,I=>{var H;I.preventDefault(),(H=k.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(EC,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:S,onEntryFocus:le(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(sl,{role:"menu","aria-orientation":"vertical","data-state":vh(v.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:le(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,M=I.ctrlKey||I.altKey||I.metaKey,q=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!M&&q&&X(I.key));const L=k.current;if(I.target!==L||!AC.includes(I.key))return;I.preventDefault();const G=E().filter(_=>!_.disabled).map(_=>_.ref.current);Gp.includes(I.key)&&G.reverse(),JC(G)}),onBlur:le(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(P.current),F.current="")}),onPointerMove:le(e.onPointerMove,No(I=>{const H=I.target,J=R.current!==I.clientX;if(I.currentTarget.contains(H)&&J){const M=I.clientX>R.current?"right":"left";K.current=M,R.current=I.clientX}}))})})})})})})});eh.displayName=sn;var HC="MenuGroup",hl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});hl.displayName=HC;var UC="MenuLabel",th=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});th.displayName=UC;var Vs="MenuItem",nh="menu.itemSelect",Ks=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Eo(Vs,e.__scopeMenu),a=fl(Vs,e.__scopeMenu),l=Me(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(nh,{bubbles:!0,cancelable:!0});p.addEventListener(nh,f=>r==null?void 0:r(f),{once:!0}),Ui(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(rh,{...o,ref:l,disabled:n,onClick:le(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:le(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:le(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||cl.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ks.displayName=Vs;var rh=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=fl(Vs,n),a=Xp(n),l=h.useRef(null),c=Me(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const x=l.current;x&&f((x.textContent??"").trim())},[s.children]),u.jsx(ko.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(IC,{asChild:!0,...a,focusable:!r,children:u.jsx(me.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:le(e.onPointerMove,No(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,No(x=>i.onItemLeave(x))),onFocus:le(e.onFocus,()=>p(!0)),onBlur:le(e.onBlur,()=>p(!1))})})})}),WC="MenuCheckboxItem",oh=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ch,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ks,{role:"menuitemcheckbox","aria-checked":qs(n)?"mixed":n,...o,ref:t,"data-state":gl(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(qs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});oh.displayName=WC;var sh="MenuRadioGroup",[VC,KC]=fr(sh,{value:void 0,onValueChange:()=>{}}),ih=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=xt(r);return u.jsx(VC,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(hl,{...o,ref:t})})});ih.displayName=sh;var ah="MenuRadioItem",lh=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=KC(ah,e.__scopeMenu),s=n===o.value;return u.jsx(ch,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ks,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":gl(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lh.displayName=ah;var ml="MenuItemIndicator",[ch,qC]=fr(ml,{checked:!1}),uh=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=qC(ml,n);return u.jsx(Ft,{present:r||qs(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":gl(s.checked)})})});uh.displayName=ml;var GC="MenuSeparator",dh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});dh.displayName=GC;var YC="MenuArrow",fh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ws(n);return u.jsx(il,{...o,...r,ref:t})});fh.displayName=YC;var XC="MenuSub",[$1,ph]=fr(XC),Io="MenuSubTrigger",hh=h.forwardRef((e,t)=>{const n=pr(Io,e.__scopeMenu),r=Eo(Io,e.__scopeMenu),o=ph(Io,e.__scopeMenu),s=fl(Io,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(ul,{asChild:!0,...c,children:u.jsx(rh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vh(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:le(e.onPointerMove,No(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:le(e.onPointerLeave,No(p=>{var f,x;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(x=n.content)==null?void 0:x.dataset.side,v=g==="right",y=v?-5:5,w=m[v?"left":"right"],C=m[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:w,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:le(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||PC[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});hh.displayName=Io;var mh="MenuSubContent",gh=h.forwardRef((e,t)=>{const n=Zp(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu),a=ph(mh,e.__scopeMenu),l=h.useRef(null),c=Me(t,l);return u.jsx(ko.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ko.Slot,{scope:e.__scopeMenu,children:u.jsx(pl,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:le(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:le(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=jC[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});gh.displayName=mh;function vh(e){return e?"open":"closed"}function qs(e){return e==="indeterminate"}function gl(e){return qs(e)?"indeterminate":e?"checked":"unchecked"}function JC(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ZC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function QC(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=ZC(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function eT(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function tT(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return eT(n,t)}function No(e){return t=>t.pointerType==="mouse"?e(t):void 0}var nT=Jp,rT=ul,oT=Qp,sT=eh,iT=hl,aT=th,lT=Ks,cT=oh,uT=ih,dT=lh,fT=uh,pT=dh,hT=fh,mT=hh,gT=gh,Gs="DropdownMenu",[vT,F1]=nn(Gs,[Yp]),zt=Yp(),[xT,xh]=vT(Gs),bh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),c=h.useRef(null),[d,p]=In({prop:o,defaultProp:s??!1,onChange:i,caller:Gs});return u.jsx(xT,{scope:t,triggerId:Pt(),triggerRef:c,contentId:Pt(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(nT,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};bh.displayName=Gs;var wh="DropdownMenuTrigger",yh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=xh(wh,n),i=zt(n);return u.jsx(rT,{asChild:!0,...i,children:u.jsx(me.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:Dn(t,s.triggerRef),onPointerDown:le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yh.displayName=wh;var bT="DropdownMenuPortal",Sh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(oT,{...r,...n})};Sh.displayName=bT;var Ch="DropdownMenuContent",Th=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xh(Ch,n),s=zt(n),i=h.useRef(!1);return u.jsx(sT,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Th.displayName=Ch;var wT="DropdownMenuGroup",yT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(iT,{...o,...r,ref:t})});yT.displayName=wT;var ST="DropdownMenuLabel",kh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(aT,{...o,...r,ref:t})});kh.displayName=ST;var CT="DropdownMenuItem",Eh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(lT,{...o,...r,ref:t})});Eh.displayName=CT;var TT="DropdownMenuCheckboxItem",Ih=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(cT,{...o,...r,ref:t})});Ih.displayName=TT;var kT="DropdownMenuRadioGroup",ET=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(uT,{...o,...r,ref:t})});ET.displayName=kT;var IT="DropdownMenuRadioItem",Nh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(dT,{...o,...r,ref:t})});Nh.displayName=IT;var NT="DropdownMenuItemIndicator",Ah=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(fT,{...o,...r,ref:t})});Ah.displayName=NT;var AT="DropdownMenuSeparator",Ph=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(pT,{...o,...r,ref:t})});Ph.displayName=AT;var PT="DropdownMenuArrow",jT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(hT,{...o,...r,ref:t})});jT.displayName=PT;var _T="DropdownMenuSubTrigger",jh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(mT,{...o,...r,ref:t})});jh.displayName=_T;var RT="DropdownMenuSubContent",_h=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(gT,{...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)"}})});_h.displayName=RT;var MT=bh,OT=yh,DT=Sh,Rh=Th,Mh=kh,Oh=Eh,Dh=Ih,Lh=Nh,$h=Ah,Fh=Ph,Bh=jh,zh=_h;const Ys=MT,Xs=OT,LT=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Bh,{ref:o,className:oe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(de.ChevronRight,{className:"ml-auto h-4 w-4"})]}));LT.displayName=Bh.displayName;const $T=h.forwardRef(({className:e,...t},n)=>u.jsx(zh,{ref:n,className:oe("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}));$T.displayName=zh.displayName;const Ao=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(DT,{children:u.jsx(Rh,{ref:r,sideOffset:t,className:oe("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})}));Ao.displayName=Rh.displayName;const Kn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Oh,{ref:r,className:oe("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}));Kn.displayName=Oh.displayName;const FT=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Dh,{ref:o,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx($h,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));FT.displayName=Dh.displayName;const BT=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Lh,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx($h,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));BT.displayName=Lh.displayName;const zT=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Mh,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));zT.displayName=Mh.displayName;const HT=h.forwardRef(({className:e,...t},n)=>u.jsx(Fh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));HT.displayName=Fh.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[40px] 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}));vl.displayName="Textarea";const UT=1e4;function Hh({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=UT,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:x,validate:g,onValidationError:v}){const y=i!==void 0,[w,C]=b.useState(e),E=(y?i:w)??"",[T,S]=b.useTransition(),k=b.useRef(null),A=b.useRef(0),P=b.useRef(null),F=b.useRef("");b.useEffect(()=>{if(!y&&(C(e??""),P.current=null,k.current)){const L=!e||e.trim()==="",D=44;L?k.current.style.height=`${D}px`:(k.current.style.height="auto",k.current.style.height=`${Math.max(k.current.scrollHeight,D)}px`)}},[e,t,y]);const[$,B]=b.useState(null),K=b.useCallback(L=>L.length>s?`Message too long (${L.length}/${s} characters)`:null,[s]),R=b.useMemo(()=>g??K,[g,K]),W=b.useCallback(L=>{const D=R(L);return B(D),v==null||v(D),F.current=L,D},[R,v]),Y=b.useCallback(()=>{const L=k.current;if(!L)return;const D=!L.value||L.value.trim()==="",G=44;if(D){L.style.height=`${G}px`;return}L.style.height="auto";const _=Math.max(L.scrollHeight,G);L.style.height=`${_}px`},[]);b.useEffect(()=>{Y()},[Y,E]),b.useEffect(()=>{if(!$)return;const L=(E??"").trim();F.current!==L&&W(L)},[E,$,W]);const X=b.useCallback((L,{fromUser:D})=>{y||C(L),D&&(a==null||a(L))},[y,a]),O=b.useCallback(async L=>{L&&L.preventDefault();const D=(E??"").trim();if(!D&&!f||W(D))return;const G=++A.current;P.current={id:G,shouldClear:!0},S(()=>{var _,j,U;try{const Z=l(D);Z&&typeof Z.then=="function"?Z.then(()=>{var se,ae;((se=P.current)==null?void 0:se.id)===G&&P.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ae=P.current)==null?void 0:ae.id)===G&&(P.current=null)}).catch(()=>{var se;((se=P.current)==null?void 0:se.id)===G&&(P.current=null)}):(((_=P.current)==null?void 0:_.id)===G&&P.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((j=P.current)==null?void 0:j.id)===G&&(P.current=null))}catch{((U=P.current)==null?void 0:U.id)===G&&(P.current=null)}})},[E,l,f,y,a,W]),I=b.useCallback(L=>{const D=L.target.value;X(D,{fromUser:!0}),P.current&&(P.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),$&&W(D.trim())},[X,W,$]),H=b.useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),O()):L.key==="Escape"&&t&&(L.preventDefault(),c==null||c())},[O,t,c]),q=`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))]":""} ${m}`;return u.jsx("div",{className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(vl,{ref:k,value:E,onChange:I,onKeyDown:H,placeholder:t?"Edit your message...":n,className:q,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),u.jsx("div",{children:r?u.jsx(nt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(de.Square,{size:16})}):u.jsx(nt,{type:"button",onClick:L=>void O(L),size:"icon",className:`shrink-0 ${x??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!f||T||r,children:u.jsx(de.Send,{size:16})})})]})})}const WT=b.memo(Hh);function Uh({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:p={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:x,onFilesChange:g,onError:v,allowEmptySend:y=!1,inputError:w=null}){const[C,E]=b.useState([]),T=b.useRef(null),S=b.useRef(null),[k,A]=b.useState(0),[P,F]=b.useState(0),[$,B]=b.useState(!1),[K,R]=b.useState(null),[W,Y]=b.useState(null),X=b.useCallback(()=>{T.current&&(T.current.value=""),S.current&&(S.current.value=""),A(D=>D+1),F(D=>D+1)},[]),O=b.useCallback(D=>{E(G=>{const _=[...G,...D];return g==null||g(_),_})},[g]),I=b.useCallback(D=>{const G=Array.from(D.target.files||[]);O(G),D.target.value=""},[O]),H=b.useCallback(D=>{E(G=>{const _=G.filter((j,U)=>U!==D);return _.length===0&&X(),g==null||g(_),_})},[g,X]),J=b.useCallback(async D=>{const G=(D.target.files||[])[0];if(G&&(R(null),Y(null),!!x)){B(!0);try{await x(G),R(`Uploaded ${G.name} - processing through chat stream`)}catch(_){const j=_ instanceof Error?_.message:"Failed to upload Excel file";Y(j),v==null||v(j)}finally{B(!1),D.target.value="",X()}}},[x,v,X]),M=b.useMemo(()=>y||C.length>0,[y,C]),q=b.useCallback(async D=>{const _=await n(D,C);return C.length>0&&(E([]),g==null||g([]),X()),_},[n,X,C]),L=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"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":""} ${p.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:T,type:"file",multiple:!0,onChange:I,className:"hidden"},k),C.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:C.map((D,G)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:D.name}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>H(G),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 ${D.name}`,children:u.jsx(de.X,{size:12})})]},G))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:J,className:"hidden"},P),$&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),K&&!$&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:K}),W&&!$&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:W})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Ys,{children:[u.jsx(Xs,{asChild:!0,children:u.jsx(nt,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:p.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(Ao,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Kn,{onClick:()=>{var D;return(D=T.current)==null?void 0:D.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Kn,{onClick:()=>{var D;$||(D=S.current)==null||D.click()},className:`cursor-pointer ${$?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(WT,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:q,onCancelEdit:r,onStop:o,allowEmptySend:M,textareaClassName:L,sendButtonClassName:p.sendButton})})]})]})}const VT=b.memo(Uh),Wh={value:""};function Fr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,followNewMessages:s=!0,enableFileUpload:i=!0,enableExcelUpload:a=!1,enableMessageEditing:l=!0,showToolMessages:c=!0,toolConfig:d,toolRenderers:p,toolArtifactRenderers:m,payloadExtras:f={},customStyles:x={},messageCustomStyles:g,onMessageSent:v,onExcelUploadSuccess:y,onError:w,defaultMessage:C}){const{chatApi:E}=On(),T=E.baseUrl,{currentThreadId:S}=yr(),{threadId:k,messages:A,isLoading:P,navigateToCheckpoint:F,returnToLatest:$,checkpoint:B,checkpoints:K,interrupt:R,metadata:W,checkpointIndex:Y,respondToInterrupt:X}=no(),{isStreaming:O,error:I,connectionState:H,submit:J,stop:M}=zi(),q=k??S??null,L=(B==null?void 0:B.id)??null,D=(B==null?void 0:B.namespace)??null,G=(W==null?void 0:W.assemblingMessageId)??null;b.useEffect(()=>{console.log("[ChatInterface] streamingAssistantId changed:",{streamingAssistantId:G,isStreaming:O,assemblingMessageId:W==null?void 0:W.assemblingMessageId})},[G,O,W==null?void 0:W.assemblingMessageId]);const _=R,j=_?Oi(_.id):null,U=j!==null?{type:"interrupt",id:j}:null,[Z,se]=b.useState(!1),[ae,Se]=b.useState(!1);b.useEffect(()=>{_||se(!1)},[_]);const Ce=b.useCallback(()=>{se(!0)},[]),Oe=b.useCallback(()=>{se(!1)},[]),Fe=b.useCallback(ne=>{},[]),Be=b.useCallback(ne=>ne.name!=="ask_user_choice",[]),Ke=d??{toolRenderers:p,toolArtifactRenderers:m,getToolExpandable:Be},ze=b.useCallback(async(ne,ce,ge)=>{try{Ce(),await X(ne,ce,ge)}catch(we){console.error("Failed to respond to interrupt:",we)}finally{Oe()}},[Oe,Ce,X]),dt=b.useCallback(()=>ze(!0),[ze]),pt=b.useCallback(()=>ze(!1),[ze]),Ze=b.useCallback((ne,ce)=>ze(!0,ce),[ze]),He=!!_||Z,[Re,qe]=b.useState(null),[Ae,Ge]=b.useState(""),[Xe,Ct]=b.useState(null),[Qe,Tt]=b.useState(null),[ht,wt]=b.useState(!1),[At,jt]=b.useState(null),mt=b.useRef(!1),[gt,Ht]=b.useState(()=>Wh.value),Ve=b.useRef(gt),$e=b.useRef(null),ft=b.useCallback(ne=>{Wh.value=ne,Ht(ne)},[]),[kt,ct]=b.useState(!1),_t=b.useRef(null),xe=b.useCallback(ne=>{ft(ne)},[ft]);b.useEffect(()=>{O||Se(!1)},[O]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&Se(!1)},[W==null?void 0:W.assemblingMessageId]);const[Le,Ue]=b.useState("desktop");b.useEffect(()=>{const ne=()=>{const ce=window.innerWidth;Ue(ce<640?"phone":ce<1024?"tablet":"desktop")};return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[]),b.useEffect(()=>{mt.current=!1},[q]),b.useEffect(()=>{Ve.current=gt},[gt]),b.useEffect(()=>{if(!Re){$e.current=null;return}$e.current===null&&($e.current=Ve.current),ft(Ae??"")},[Ae,Re,ft]),b.useEffect(()=>{if(C!==void 0){jt(C);return}(async()=>{if(!T){jt(null);return}try{const ge=(await E.getAgent("default")).uiDefaultMessage||"";jt(ge||null)}catch(ce){console.warn("Failed to fetch default message:",ce),jt(null)}})()},[E,T,C]),b.useEffect(()=>{I&&!ht&&(w==null||w(I))},[I,ht,w]);const st=async(ne,ce)=>{const ge=ne.trim();if(!(!ge&&ce.length===0))try{const we=Re?(Xe==null?void 0:Xe.checkpointId)??L??void 0:L??void 0,je=Re?(Xe==null?void 0:Xe.checkpointNs)??D??void 0:D??void 0;await J({text:ge||"",attachments:ce,payload:f},{checkpointId:we,checkpointNs:je,edit:!!Re,originalMessageId:Re??void 0}),v==null||v(ge),Se(!0),ft(""),Tt(null),qe(null),Ge(""),Ct(null)}catch(we){const je=(we==null?void 0:we.message)||"Failed to send message";Tt(je),w==null||w(je),Se(!1)}},tt=b.useCallback(async ne=>{await J({attachments:[ne],payload:f},{checkpointId:L??void 0,checkpointNs:D??void 0}),y==null||y({file:ne})},[L,D,f,y,J]),ut=b.useCallback((ne,ce,ge)=>{l&&($e.current=gt,qe(ne),Ge(ce),ft(ce),Tt(null),Ct({checkpointId:(ge==null?void 0:ge.checkpointId)??null,checkpointNs:(ge==null?void 0:ge.checkpointNs)??null}))},[gt,l,ft]),et=b.useCallback(()=>{qe(null),Ge(""),Ct(null),Tt(null),ft($e.current??gt),$e.current=null},[gt,ft]),Q=b.useCallback((ne,ce,ge)=>{ut(ne,ce,ge)},[ut]),ee=b.useCallback(ne=>{let ce=null;for(let Ee=ne-1;Ee>=0;Ee--)if(A[Ee].role==="user"){ce=A[Ee];break}if(!ce)return;const ge=Array.isArray(ce.content)?ce.content:[],je=ge.filter(Ee=>(Ee==null?void 0:Ee.type)==="text").map(Ee=>Ee.text).join("")||(()=>{try{return JSON.stringify(ge,null,2)}catch{return String(ge)}})();je&&J({text:je,payload:f},{checkpointId:L??void 0,checkpointNs:D??void 0,edit:!0,originalMessageId:ce.id})},[A,J,L,D,f]),he=b.useCallback(async ne=>{if(S){ct(!0);try{if(!ne){await $(),requestAnimationFrame(()=>{var we;(we=_t.current)==null||we.scrollToLatest()});return}const ce=K.find(we=>we.checkpointId===ne),ge=(ce==null?void 0:ce.checkpointNs)??null;await F(ne,ge),requestAnimationFrame(()=>{var we;(we=_t.current)==null||we.scrollToTop()})}finally{ct(!1)}}},[K,S,_t,F,$]),ue=b.useCallback(async(ne,ce,ge)=>{await he(ge?null:ne)},[he]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${x.container||""}`,N=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${_?"pb-32":""} bg-transparent ${x.messagesArea||""}`,te=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${x.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!I&&!ht&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${N}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Ua,{ref:_t,className:"h-full",style:{height:"100%"},messages:A,isStreaming:O,streamingAssistantId:G,streamingDebounceMs:o,followNewMessages:s,layoutSize:Le,enableMessageEditing:l,editingMessageId:Re,onEdit:Q,onRegenerate:ee,onCancelEdit:et,emptyMessage:At??void 0,isNavigatingCheckpoint:kt,showToolMessages:c,toolConfig:Ke,checkpointIndex:Y,activeCheckpointId:L,onSelectCheckpoint:ue,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae,getMessageCustomStyles:g,getInterruptOptions:Fe}),(H==="reconnecting"||H==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),H==="reconnecting"?"Reconnecting…":"Connecting…"]})}),H==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),P&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),kt&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),_&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(ma,{interruptPart:U,onApprove:dt,onReject:pt,onSelectAlternative:Ze,disabled:Z,isActive:!0,payload:_.value})})})]}),u.jsxs("div",{className:te,children:[Re&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:et,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),Qe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Qe}),u.jsx(VT,{composerValue:gt,onComposerChange:xe,onSend:st,onCancelEdit:et,onStop:M,editingMessageId:Re,editingInitialValue:Ae,placeholder:Re?"Edit your message...":t,isStreaming:O,disabled:He,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:tt,onError:w,customStyles:x,textareaClassName:x.textarea||"",allowEmptySend:!1,inputError:Qe})]})]})}var Vh=1,KT=.9,qT=.8,GT=.17,xl=.1,bl=.999,YT=.9999,XT=.99,JT=/[\\\/_+.#"@\[\(\{&]/,ZT=/[\\\/_+.#"@\[\(\{&]/g,QT=/[\s-]/,Kh=/[\s-]/g;function wl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Vh:XT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,x;c>=0;)p=wl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Vh:JT.test(e.charAt(c-1))?(p*=qT,f=e.slice(o,c-1).match(ZT),f&&o>0&&(p*=Math.pow(bl,f.length))):QT.test(e.charAt(c-1))?(p*=KT,x=e.slice(o,c-1).match(Kh),x&&o>0&&(p*=Math.pow(bl,x.length))):(p*=GT,o>0&&(p*=Math.pow(bl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=YT)),(p<xl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=wl(e,t,n,r,c+1,s+2,i),m*xl>p&&(p=m*xl)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function qh(e){return e.toLowerCase().replace(Kh," ")}function ek(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,wl(e,t,qh(e),qh(t),0,0,{})}var Po='[cmdk-group=""]',yl='[cmdk-group-items=""]',tk='[cmdk-group-heading=""]',Gh='[cmdk-item=""]',Yh=`${Gh}:not([aria-disabled="true"])`,Sl="cmdk-item-select",Br="data-value",nk=(e,t,n)=>ek(e,t,n),Xh=h.createContext(void 0),jo=()=>h.useContext(Xh),Jh=h.createContext(void 0),Cl=()=>h.useContext(Jh),Zh=h.createContext(void 0),Qh=h.forwardRef((e,t)=>{let n=zr(()=>{var M,q;return{search:"",value:(q=(M=e.value)!=null?M:e.defaultValue)!=null?q:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=zr(()=>new Set),o=zr(()=>new Map),s=zr(()=>new Map),i=zr(()=>new Set),a=em(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:x,disablePointerSelection:g=!1,vimBindings:v=!0,...y}=e,w=Pt(),C=Pt(),E=Pt(),T=h.useRef(null),S=pk();hr(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,k.emit()}},[d]),hr(()=>{S(6,K)},[]);let k=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,q,L)=>{var D,G,_,j;if(!Object.is(n.current[M],q)){if(n.current[M]=q,M==="search")B(),F(),S(1,$);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(E);U?U.focus():(D=document.getElementById(w))==null||D.focus()}if(S(7,()=>{var U;n.current.selectedItemId=(U=R())==null?void 0:U.id,k.emit()}),L||S(5,K),((G=a.current)==null?void 0:G.value)!==void 0){let U=q??"";(j=(_=a.current).onValueChange)==null||j.call(_,U);return}}k.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=h.useMemo(()=>({value:(M,q,L)=>{var D;q!==((D=s.current.get(M))==null?void 0:D.value)&&(s.current.set(M,{value:q,keywords:L}),n.current.filtered.items.set(M,P(q,L)),S(2,()=>{F(),k.emit()}))},item:(M,q)=>(r.current.add(M),q&&(o.current.has(q)?o.current.get(q).add(M):o.current.set(q,new Set([M]))),S(3,()=>{B(),F(),n.current.value||$(),k.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let L=R();S(4,()=>{B(),(L==null?void 0:L.getAttribute("id"))===M&&$(),k.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:E,labelId:C,listInnerRef:T}),[]);function P(M,q){var L,D;let G=(D=(L=a.current)==null?void 0:L.filter)!=null?D:nk;return M?G(M,n.current.search,q):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,q=[];n.current.filtered.groups.forEach(D=>{let G=o.current.get(D),_=0;G.forEach(j=>{let U=M.get(j);_=Math.max(U,_)}),q.push([D,_])});let L=T.current;W().sort((D,G)=>{var _,j;let U=D.getAttribute("id"),Z=G.getAttribute("id");return((_=M.get(Z))!=null?_:0)-((j=M.get(U))!=null?j:0)}).forEach(D=>{let G=D.closest(yl);G?G.appendChild(D.parentElement===G?D:D.closest(`${yl} > *`)):L.appendChild(D.parentElement===L?D:D.closest(`${yl} > *`))}),q.sort((D,G)=>G[1]-D[1]).forEach(D=>{var G;let _=(G=T.current)==null?void 0:G.querySelector(`${Po}[${Br}="${encodeURIComponent(D[0])}"]`);_==null||_.parentElement.appendChild(_)})}function $(){let M=W().find(L=>L.getAttribute("aria-disabled")!=="true"),q=M==null?void 0:M.getAttribute(Br);k.setState("value",q||void 0)}function B(){var M,q,L,D;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let G=0;for(let _ of r.current){let j=(q=(M=s.current.get(_))==null?void 0:M.value)!=null?q:"",U=(D=(L=s.current.get(_))==null?void 0:L.keywords)!=null?D:[],Z=P(j,U);n.current.filtered.items.set(_,Z),Z>0&&G++}for(let[_,j]of o.current)for(let U of j)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(_);break}n.current.filtered.count=G}function K(){var M,q,L;let D=R();D&&(((M=D.parentElement)==null?void 0:M.firstChild)===D&&((L=(q=D.closest(Po))==null?void 0:q.querySelector(tk))==null||L.scrollIntoView({block:"nearest"})),D.scrollIntoView({block:"nearest"}))}function R(){var M;return(M=T.current)==null?void 0:M.querySelector(`${Gh}[aria-selected="true"]`)}function W(){var M;return Array.from(((M=T.current)==null?void 0:M.querySelectorAll(Yh))||[])}function Y(M){let q=W()[M];q&&k.setState("value",q.getAttribute(Br))}function X(M){var q;let L=R(),D=W(),G=D.findIndex(j=>j===L),_=D[G+M];(q=a.current)!=null&&q.loop&&(_=G+M<0?D[D.length-1]:G+M===D.length?D[0]:D[G+M]),_&&k.setState("value",_.getAttribute(Br))}function O(M){let q=R(),L=q==null?void 0:q.closest(Po),D;for(;L&&!D;)L=M>0?dk(L,Po):fk(L,Po),D=L==null?void 0:L.querySelector(Yh);D?k.setState("value",D.getAttribute(Br)):X(M)}let I=()=>Y(W().length-1),H=M=>{M.preventDefault(),M.metaKey?I():M.altKey?O(1):X(1)},J=M=>{M.preventDefault(),M.metaKey?Y(0):M.altKey?O(-1):X(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:M=>{var q;(q=y.onKeyDown)==null||q.call(y,M);let L=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||L))switch(M.key){case"n":case"j":{v&&M.ctrlKey&&H(M);break}case"ArrowDown":{H(M);break}case"p":case"k":{v&&M.ctrlKey&&J(M);break}case"ArrowUp":{J(M);break}case"Home":{M.preventDefault(),Y(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let D=R();if(D){let G=new Event(Sl);D.dispatchEvent(G)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:mk},l),Js(e,M=>h.createElement(Jh.Provider,{value:k},h.createElement(Xh.Provider,{value:A},M))))}),rk=h.forwardRef((e,t)=>{var n,r;let o=Pt(),s=h.useRef(null),i=h.useContext(Zh),a=jo(),l=em(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;hr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=tm(o,s,[e.value,e.children,s],e.keywords),p=Cl(),m=qn(S=>S.value&&S.value===d.current),f=qn(S=>c||a.filter()===!1?!0:S.search?S.filtered.items.get(o)>0:!0);h.useEffect(()=>{let S=s.current;if(!(!S||e.disabled))return S.addEventListener(Sl,x),()=>S.removeEventListener(Sl,x)},[f,e.onSelect,e.disabled]);function x(){var S,k;g(),(k=(S=l.current).onSelect)==null||k.call(S,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:v,value:y,onSelect:w,forceMount:C,keywords:E,...T}=e;return h.createElement(me.div,{ref:Dn(s,t),...T,id:o,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!m,"data-disabled":!!v,"data-selected":!!m,onPointerMove:v||a.getDisablePointerSelection()?void 0:g,onClick:v?void 0:x},e.children)}),ok=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=h.useRef(null),l=h.useRef(null),c=Pt(),d=jo(),p=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);hr(()=>d.group(i),[]),tm(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(me.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Js(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Zh.Provider,{value:m},f))))}),sk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:h.createElement(me.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),ik=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Cl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(me.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),ak=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=qn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(me.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Js(e,c=>h.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),lk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(oa,{open:n,onOpenChange:r},h.createElement(sa,{container:i},h.createElement(so,{"cmdk-overlay":"",className:o}),h.createElement(io,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Qh,{ref:t,...a}))))}),ck=h.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?h.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),uk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Js(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Gt=Object.assign(Qh,{List:ak,Item:rk,Input:ik,Group:ok,Separator:sk,Dialog:lk,Empty:ck,Loading:uk});function dk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function fk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function em(e){let t=h.useRef(e);return hr(()=>{t.current=e}),t}var hr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function zr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=Cl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function tm(e,t,n,r=[]){let o=h.useRef(),s=jo();return hr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Br,a),o.current=a}),o}var pk=()=>{let[e,t]=h.useState(),n=zr(()=>new Map);return hr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function hk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Js({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(hk(t),{ref:t.ref},n(t.props.children)):n(t)}var mk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tl.displayName=Gt.displayName;const kl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Gt.Input,{ref:n,className:oe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));kl.displayName=Gt.Input.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));El.displayName=Gt.List.displayName;const Il=h.forwardRef((e,t)=>u.jsx(Gt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Il.displayName=Gt.Empty.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Group,{ref:n,className:oe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Nl.displayName=Gt.Group.displayName;const gk=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));gk.displayName=Gt.Separator.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Item,{ref:n,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Al.displayName=Gt.Item.displayName;function Pl(e,[t,n]){return Math.min(n,Math.max(t,e))}function vk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var jl="ScrollArea",[nm,B1]=nn(jl),[xk,an]=nm(jl),rm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,x]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState(0),[C,E]=h.useState(0),[T,S]=h.useState(!1),[k,A]=h.useState(!1),P=Me(t,$=>l($)),F=Rs(o);return u.jsx(xk,{scope:n,type:r,dir:F,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:x,scrollbarXEnabled:T,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:E,children:u.jsx(me.div,{dir:F,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});rm.displayName=jl;var om="ScrollAreaViewport",sm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=an(om,n),a=h.useRef(null),l=Me(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(me.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});sm.displayName=om;var En="ScrollAreaScrollbar",_l=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,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"?u.jsx(bk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(wk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(im,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Rl,{...r,ref:t}):null});_l.displayName=En;var bk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ft,{present:n||s,children:u.jsx(im,{"data-state":s?"visible":"hidden",...r,ref:t})})}),wk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ti(()=>l("SCROLL_END"),100),[a,l]=vk("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 c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ft,{present:n||a!=="hidden",children:u.jsx(Rl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),im=h.forwardRef((e,t)=>{const n=an(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ti(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Hr(n.viewport,l),Hr(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(Rl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Rl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=an(En,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=dm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return Ek(m,i.current,a,f)}return n==="horizontal"?u.jsx(yk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=fm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(Sk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=fm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),yk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(lm,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),hm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Qs(i.paddingLeft),paddingEnd:Qs(i.paddingRight)}})}})}),Sk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(lm,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),hm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Qs(i.paddingTop),paddingEnd:Qs(i.paddingBottom)}})}})}),[Ck,am]=nm(En),lm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=an(En,n),[x,g]=h.useState(null),v=Me(t,P=>g(P)),y=h.useRef(null),w=h.useRef(""),C=f.viewport,E=r.content-r.viewport,T=xt(d),S=xt(l),k=ti(p,10);function A(P){if(y.current){const F=P.clientX-y.current.left,$=P.clientY-y.current.top;c({x:F,y:$})}}return h.useEffect(()=>{const P=F=>{const $=F.target;(x==null?void 0:x.contains($))&&T(F,E)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[C,x,E,T]),h.useEffect(S,[r,S]),Hr(x,k),Hr(f.content,k),u.jsx(Ck,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:xt(s),onThumbPointerUp:xt(i),onThumbPositionChange:S,onThumbPointerDown:xt(a),children:u.jsx(me.div,{...m,ref:v,style:{position:"absolute",...m.style},onPointerDown:le(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=x.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),A(P))}),onPointerMove:le(e.onPointerMove,A),onPointerUp:le(e.onPointerUp,P=>{const F=P.target;F.hasPointerCapture(P.pointerId)&&F.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Zs="ScrollAreaThumb",cm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=am(Zs,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(Tk,{ref:t,...r})})}),Tk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(Zs,n),i=am(Zs,n),{onThumbPositionChange:a}=i,l=Me(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=ti(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=Ik(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:le(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),x=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x,y:g})}),onPointerUp:le(e.onPointerUp,i.onThumbPointerUp)})});cm.displayName=Zs;var Ml="ScrollAreaCorner",um=h.forwardRef((e,t)=>{const n=an(Ml,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(kk,{...e,ref:t}):null});um.displayName=Ml;var kk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=an(Ml,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Hr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Hr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.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 Qs(e){return e?parseInt(e,10):0}function dm(e,t){const n=e/t;return isNaN(n)?0:n}function ei(e){const t=dm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ek(e,t,n,r="ltr"){const o=ei(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return pm([l,c],p)(e)}function fm(e,t,n="ltr"){const r=ei(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Pl(e,l);return pm([0,i],[0,a])(c)}function pm(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 hm(e,t){return e>0&&e<t}var Ik=(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 ti(e,t){const n=xt(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 Hr(e,t){const n=xt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var mm=rm,Nk=sm,Ak=um;const Ol=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(mm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Nk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(gm,{}),u.jsx(Ak,{})]}));Ol.displayName=mm.displayName;const gm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(_l,{ref:r,orientation:t,className:oe("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(cm,{className:"relative flex-1 rounded-full bg-border"})}));gm.displayName=_l.displayName;const Dl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:oe("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}));Dl.displayName="Input";const Pk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",jk="bg-slate-700 border-slate-600 hover:bg-slate-600",_k="bg-slate-600 border-slate-500";function Ll({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:x,secondaryLine:g,itemClassName:v,activeItemClassName:y}){var T;const w=n===e.threadId,C=t?`${y??_k}`:`${v??jk}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${Pk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(Dl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:x(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(de.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)}),((T=e.project)==null?void 0:T.name)&&u.jsx("span",{className:"flex items-center gap-1.5 before:content-['•'] before:text-gray-300 dark:before:text-slate-600",children:u.jsx("span",{className:"truncate max-w-[100px]",children:e.project.name})})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ys,{children:[u.jsx(Xs,{asChild:!0,children:u.jsx(nt,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(Ao,{align:"end",sideOffset:6,className:"w-44",style:{zIndex:9999},children:[u.jsxs(Kn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Kn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Kn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(de.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}var ni="Collapsible",[Rk,z1]=nn(ni),[Mk,$l]=Rk(ni),vm=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,c]=In({prop:r,defaultProp:o??!1,onChange:i,caller:ni});return u.jsx(Mk,{scope:n,disabled:s,contentId:Pt(),open:l,onOpenToggle:h.useCallback(()=>c(d=>!d),[c]),children:u.jsx(me.div,{"data-state":Bl(l),"data-disabled":s?"":void 0,...a,ref:t})})});vm.displayName=ni;var xm="CollapsibleTrigger",bm=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=$l(xm,n);return u.jsx(me.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Bl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:le(e.onClick,o.onOpenToggle)})});bm.displayName=xm;var Fl="CollapsibleContent",wm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$l(Fl,e.__scopeCollapsible);return u.jsx(Ft,{present:n||o.open,children:({present:s})=>u.jsx(Ok,{...r,ref:t,present:s})})});wm.displayName=Fl;var Ok=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=$l(Fl,n),[a,l]=h.useState(r),c=h.useRef(null),d=Me(t,c),p=h.useRef(0),m=p.current,f=h.useRef(0),x=f.current,g=i.open||a,v=h.useRef(g),y=h.useRef(void 0);return h.useEffect(()=>{const w=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(w)},[]),It(()=>{const w=c.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();p.current=C.height,f.current=C.width,v.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(me.div,{"data-state":Bl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...s,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:g&&o})});function Bl(e){return e?"open":"closed"}var Dk=vm;const Lk=Dk,$k=bm,Fk=wm,ym=25,Sm="thread-manager-view",Bk=e=>e==="default"||e==="shared",zk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Sm);if(Bk(e))return e}catch{}return null};function Cm({defaultView:e}={}){const[t,n]=b.useState(()=>zk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Sm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Hk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ri({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:x,viewState:g,showHeader:v=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:C,groupBy:E}){const{chatApi:T,authApi:S}=On(),{threads:k,sharedThreads:A,currentThreadId:P,setCurrentThreadId:F,isLoading:$,isLoadingSharedThreads:B,actions:K,shareInFlight:R,shareStatus:W,clearShareStatus:Y}=yr(),{createThread:X,deleteThread:O,renameThread:I,shareThread:H}=K,{loadThread:J}=no(),M=i??P,[q,L]=b.useState(Array.isArray(k)?k:[]),D=b.useRef(q.length>0),G=b.useRef(null),_=b.useRef(0),[j,U]=b.useState(null),[Z,se]=b.useState(""),[ae,Se]=b.useState(!1),[Ce,Oe]=b.useState(!1),[Fe,Be]=b.useState(null),[Ke,ze]=b.useState(""),[dt,pt]=b.useState([]),[Ze,He]=b.useState(!1);b.useEffect(()=>{Ce&&!y&&dt.length===0&&!Ze&&(async()=>{He(!0);try{const he=(await S.listUsers()).filter(ue=>ue.id||ue.user_id).map(ue=>({type:"user",value:ue.user_id||ue.id||"",id:ue.user_id||ue.id||"",label:ue.name||ue.username||ue.email||"Unknown User",secondaryLabel:ue.name||ue.username?ue.email:void 0}));pt(he)}catch(ee){console.error("Failed to load users for sharing:",ee)}finally{He(!1)}})()},[Ce,y,dt.length,Ze,T]);const Re=y??dt,qe=w??Ze,Ae=x&&x.length>0?x:Hk,Ge=Cm({defaultView:m}),Xe=g??Ge,Ct=p??Xe.view,Qe=b.useCallback(Q=>{p||Xe.setView(Q),f==null||f(Q)},[p,f,Xe]),Tt=Ae.find(Q=>Q.key===Ct)??Ae[0],ht=Q=>{Be(Q),ze(""),Oe(!0)},wt=()=>{Oe(!1),Be(null),ze(""),Y()},At=b.useCallback(async Q=>{if(!(!Fe||R)&&Q.id)try{await H(Fe,Q.id),setTimeout(()=>wt(),600)}catch(ee){console.error("Failed to share thread:",ee)}},[wt,R,Fe,H]),jt=b.useMemo(()=>{const Q=Re,ee=Ke.trim().toLowerCase();return ee?C?Q.filter(he=>C(he,ee)):Q.filter(he=>`${he.label} ${he.secondaryLabel??""}`.toLowerCase().includes(ee)):Q},[y,Ke,C]),mt=Ct==="shared",gt=mt?A:q,Ht=b.useMemo(()=>{if(!E||mt)return null;const Q={},ee="Default";return gt.forEach(he=>{var Ie,N;let ue=ee;E==="project"?ue=((Ie=he.project)==null?void 0:Ie.name)||((N=he.project)==null?void 0:N.id)||ee:ue=he[E]||ee,Q[ue]||(Q[ue]=[]),Q[ue].push(he)}),Object.keys(Q).forEach(he=>{Q[he].sort((ue,Ie)=>new Date(Ie.updatedAt||Ie.createdAt||"").getTime()-new Date(ue.updatedAt||ue.createdAt||"").getTime())}),Q},[gt,E,mt]),Ve=mt?B:$,$e=mt?"No shared conversations yet":"No conversations yet",ft=Q=>{const ee=Q.sharedAt?` • ${tt(Q.sharedAt)}`:"";return`Shared by ${Q.sharedByUserId}${ee}`},kt=Q=>"sharedByUserId"in Q;b.useEffect(()=>{const Q=Array.isArray(k)?k:[];if(Q.length>0){D.current=!0,L(Q);return}$||(D.current=!1,L(Q))},[k,$]),b.useEffect(()=>{if(!G.current)return;const Q=G.current.querySelector("[data-radix-scroll-area-viewport]");if(!Q)return;let ee=null,he=null;return ee=requestAnimationFrame(()=>{he=requestAnimationFrame(()=>{Q.scrollTop=_.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),he!==null&&cancelAnimationFrame(he)}},[q]);const ct=async Q=>{try{F(Q),await J(Q),a==null||a(Q),l==null||l(Q)}catch(ee){console.error("Failed to select thread:",ee)}},_t=async()=>{try{Se(!0);const Q=await X();Q&&(c==null||c(Q),a==null||a(Q))}catch(Q){console.error("Failed to create thread:",Q)}finally{Se(!1)}},xe=async(Q,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(G.current){const he=G.current.querySelector("[data-radix-scroll-area-viewport]");he&&(_.current=he.scrollTop)}try{await O(Q),d==null||d(Q)}catch(he){console.error("Failed to delete thread:",he)}}},Le=(Q,ee)=>{ee.stopPropagation(),U(Q.threadId),se(Q.title||`Thread ${Q.threadId.slice(0,8)}`)},Ue=async Q=>{if(Z.trim())try{await I(Q,Z.trim()),U(null),se("")}catch(ee){console.error("Failed to update title:",ee)}},st=()=>{U(null),se("")},tt=Q=>{if(!Q)return"";try{const ee=Q.endsWith("Z")||Q.includes("+")?Q:`${Q}Z`,he=new Date(ee),Ie=new Date().getTime()-he.getTime(),N=Math.floor(Ie/(1e3*60*60*24));return N===0?he.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):N===1?"Yesterday":N<7?`${N} days ago`:he.toLocaleDateString()}catch{return""}},ut=Q=>Q.title||`Thread ${Q.threadId.slice(0,8)}`,et=Q=>{const ee=ut(Q);return ee.length<=ym?ee:`${ee.slice(0,ym)}...`};return u.jsxs("div",{className:`thread-manager-root flex flex-col h-full ${e} ${s.container||""}`,children:[v&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(nt,{onClick:_t,disabled:ae||$,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:ae?"Creating...":"New Chat",children:[u.jsx(de.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ys,{children:[u.jsx(Xs,{asChild:!0,children:u.jsx(nt,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:Tt.label})}),u.jsx(Ao,{align:"start",sideOffset:6,className:"w-40",children:Ae.map(Q=>u.jsxs(Kn,{className:"justify-between text-[12px]",onClick:ee=>{ee.preventDefault(),Qe(Q.key)},children:[u.jsx("span",{children:Q.label}),Ct===Q.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},Q.key))})]})]})]}),u.jsx(Ol,{ref:G,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Ve?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):gt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:$e})]}):Ht?Object.entries(Ht).sort(([Q],[ee])=>{const he="Default";return Q===he?1:ee===he?-1:Q.localeCompare(ee)}).map(([Q,ee])=>u.jsxs(Lk,{defaultOpen:!0,className:"group/collapsible",children:[u.jsxs($k,{className:"flex items-center w-full px-2 py-1 text-xs font-medium text-slate-500 hover:text-slate-800 dark:hover:text-slate-200",children:[u.jsx(de.ChevronRight,{className:"w-3 h-3 mr-1 transition-transform group-data-[state=open]/collapsible:rotate-90"}),Q,u.jsx("span",{className:"ml-auto text-[10px] text-slate-400",children:ee.length})]}),u.jsx(Fk,{children:u.jsx("div",{className:"pl-2 border-l border-slate-100 dark:border-slate-800 ml-1.5 my-1 space-y-1",children:ee.map(he=>u.jsx(Ll,{thread:he,isActive:M===he.threadId,editingThreadId:j,editingTitle:Z,onSelect:ct,onStartEditing:Le,onEditingTitleChange:ue=>se(ue),onSaveEditing:Ue,onCancelEditing:st,onShare:()=>ht(he.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:tt,getDisplayThreadTitle:et,itemClassName:s.threadItem,activeItemClassName:s.activeThread},he.threadId))})})]},Q)):gt.slice().sort((Q,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(Q.updatedAt||Q.createdAt||"").getTime()).map(Q=>u.jsx(Ll,{thread:Q,isActive:M===Q.threadId,editingThreadId:j,editingTitle:Z,onSelect:ct,onStartEditing:Le,onEditingTitleChange:ee=>se(ee),onSaveEditing:Ue,onCancelEditing:st,onShare:()=>ht(Q.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:tt,getDisplayThreadTitle:et,secondaryLine:mt&&kt(Q)?ft(Q):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Q.threadId))})}),u.jsx(ia,{open:Ce,onOpenChange:Q=>!Q&&wt(),children:u.jsxs(cs,{className:"max-w-md p-0",children:[u.jsx(aa,{children:u.jsx(la,{children:"Share thread"})}),u.jsxs(Tl,{children:[u.jsx(kl,{autoFocus:!0,value:Ke,onValueChange:Q=>ze(Q),placeholder:"Search for recipients..."}),u.jsxs(El,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[R&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),u.jsx(Il,{children:qe?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),jt.length>0&&u.jsx(Nl,{heading:"Recipients",children:jt.map(Q=>u.jsx(Al,{onSelect:()=>At(Q),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Q.label}),Q.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Q.secondaryLabel})]})},Q.id))})]})]})]})})]})}function Uk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},payloadExtras:s={},...i}){const a=d=>{const p="h-full";switch(d){case"phone":return`${p} max-w-none`;case"tablet":return`${p} max-w-4xl mx-auto`;case"half-screen":return`${p} max-w-2xl`;case"desktop":default:return`${p} max-w-7xl mx-auto`}},l=d=>({"--chat-sidebar-width":d==="phone"?"100%":d==="tablet"?"280px":d==="half-screen"?"240px":"320px","--chat-message-max-width":d==="phone"?"95%":d==="tablet"?"90%":d==="half-screen"?"85%":"80%","--chat-input-height":d==="phone"?"120px":"100px"}),c=b.useCallback(d=>{var p;(p=i.onThreadChange)==null||p.call(i,d)},[i]);return e==="fullscreen"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(t),children:u.jsx(Fr,{className:"flex-1",onError:i.onError,enableFileUpload:!0,payloadExtras:s})})}):e==="tabs"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ri,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}):u.jsx(Tr,{...i,onThreadChange:c,children:u.jsxs("div",{className:`${a(t)} flex overflow-hidden ${r} ${o.container||""}`,style:l(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ri,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}function Wk({apiConfig:e,className:t="",onError:n}){return u.jsx(Tr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Fr,{})})})}function Vk({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Fr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ri,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Kk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(Tr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(nt,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(de.MoreHorizontal,{size:16})}),u.jsx(nt,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(de.Edit3,{size:16})}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(de.Maximize2,{size:14}):u.jsx(de.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Vk,{placeholder:t,onMessageSent:r})})]})})}):null}function qk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(nt,{variant:r,size:o,className:oe("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(de.Edit3,{size:16}),t??e]})}var Gk="Label",Tm=h.forwardRef((e,t)=>u.jsx(me.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())}}));Tm.displayName=Gk;var km=Tm;const Yk=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Em=h.forwardRef(({className:e,...t},n)=>u.jsx(km,{ref:n,className:oe(Yk(),e),...t}));Em.displayName=km.displayName;function Im(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 Nm=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"}),Xk="VisuallyHidden",oi=h.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...Nm,...e.style}}));oi.displayName=Xk;var Jk=oi,Zk=[" ","Enter","ArrowUp","ArrowDown"],Qk=[" ","Enter"],mr="Select",[si,ii,eE]=_s(mr),[Ur,H1]=nn(mr,[eE,$r]),ai=$r(),[tE,Gn]=Ur(mr),[nE,rE]=Ur(mr),Am=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:x}=e,g=ai(t),[v,y]=h.useState(null),[w,C]=h.useState(null),[E,T]=h.useState(!1),S=Rs(c),[k,A]=In({prop:r,defaultProp:o??!1,onChange:s,caller:mr}),[P,F]=In({prop:i,defaultProp:a,onChange:l,caller:mr}),$=h.useRef(null),B=v?x||!!v.closest("form"):!0,[K,R]=h.useState(new Set),W=Array.from(K).map(Y=>Y.props.value).join(";");return u.jsx(rl,{...g,children:u.jsxs(tE,{required:f,scope:t,trigger:v,onTriggerChange:y,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:Pt(),value:P,onValueChange:F,open:k,onOpenChange:A,dir:S,triggerPointerDownPosRef:$,disabled:m,children:[u.jsx(si.Provider,{scope:t,children:u.jsx(nE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(Y=>{R(X=>new Set(X).add(Y))},[]),onNativeOptionRemove:h.useCallback(Y=>{R(X=>{const O=new Set(X);return O.delete(Y),O})},[]),children:n})}),B?u.jsxs(Qm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:P,onChange:Y=>F(Y.target.value),disabled:m,form:x,children:[P===void 0?u.jsx("option",{value:""}):null,Array.from(K)]},W):null]})})};Am.displayName=mr;var Pm="SelectTrigger",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ai(n),i=Gn(Pm,n),a=i.disabled||r,l=Me(t,i.onTriggerChange),c=ii(n),d=h.useRef("touch"),[p,m,f]=tg(g=>{const v=c().filter(C=>!C.disabled),y=v.find(C=>C.value===i.value),w=ng(v,g,y);w!==void 0&&i.onValueChange(w.value)}),x=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ol,{asChild:!0,...s,children:u.jsx(me.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":eg(i.value)?"":void 0,...o,ref:l,onClick:le(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&x(g)}),onPointerDown:le(o.onPointerDown,g=>{d.current=g.pointerType;const v=g.target;v.hasPointerCapture(g.pointerId)&&v.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:le(o.onKeyDown,g=>{const v=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(v&&g.key===" ")&&Zk.includes(g.key)&&(x(),g.preventDefault())})})})});jm.displayName=Pm;var _m="SelectValue",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(_m,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Me(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:p,style:{pointerEvents:"none"},children:eg(l.value)?u.jsx(u.Fragment,{children:i}):s})});Rm.displayName=_m;var oE="SelectIcon",Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Mm.displayName=oE;var sE="SelectPortal",Om=e=>u.jsx(oo,{asChild:!0,...e});Om.displayName=sE;var gr="SelectContent",Dm=h.forwardRef((e,t)=>{const n=Gn(gr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(u.jsx(Lm,{scope:e.__scopeSelect,children:u.jsx(si.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx($m,{...e,ref:t})});Dm.displayName=gr;var mn=10,[Lm,Yn]=Ur(gr),iE="SelectContentImpl",aE=Jt.createSlot("SelectContent.RemoveScroll"),$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:x,hideWhenDetached:g,avoidCollisions:v,...y}=e,w=Gn(gr,n),[C,E]=h.useState(null),[T,S]=h.useState(null),k=Me(t,_=>E(_)),[A,P]=h.useState(null),[F,$]=h.useState(null),B=ii(n),[K,R]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(C)return ea(C)},[C]),Gi();const Y=h.useCallback(_=>{const[j,...U]=B().map(ae=>ae.ref.current),[Z]=U.slice(-1),se=document.activeElement;for(const ae of _)if(ae===se||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===j&&T&&(T.scrollTop=0),ae===Z&&T&&(T.scrollTop=T.scrollHeight),ae==null||ae.focus(),document.activeElement!==se))return},[B,T]),X=h.useCallback(()=>Y([A,C]),[Y,A,C]);h.useEffect(()=>{K&&X()},[K,X]);const{onOpenChange:O,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(C){let _={x:0,y:0};const j=Z=>{var se,ae;_={x:Math.abs(Math.round(Z.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ae=I.current)==null?void 0:ae.y)??0))}},U=Z=>{_.x<=10&&_.y<=10?Z.preventDefault():C.contains(Z.target)||O(!1),document.removeEventListener("pointermove",j),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",j),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,O,I]),h.useEffect(()=>{const _=()=>O(!1);return window.addEventListener("blur",_),window.addEventListener("resize",_),()=>{window.removeEventListener("blur",_),window.removeEventListener("resize",_)}},[O]);const[H,J]=tg(_=>{const j=B().filter(se=>!se.disabled),U=j.find(se=>se.ref.current===document.activeElement),Z=ng(j,_,U);Z&&setTimeout(()=>Z.ref.current.focus())}),M=h.useCallback((_,j,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===j||Z)&&(P(_),Z&&(W.current=!0))},[w.value]),q=h.useCallback(()=>C==null?void 0:C.focus(),[C]),L=h.useCallback((_,j,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===j||Z)&&$(_)},[w.value]),D=r==="popper"?zl:Fm,G=D===zl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:x,hideWhenDetached:g,avoidCollisions:v}:{};return u.jsx(Lm,{scope:n,content:C,viewport:T,onViewportChange:S,itemRefCallback:M,selectedItem:A,onItemLeave:q,itemTextRefCallback:L,focusSelectedItem:X,selectedItemText:F,position:r,isPositioned:K,searchRef:H,children:u.jsx(rs,{as:aE,allowPinchZoom:!0,children:u.jsx(Xo,{asChild:!0,trapped:w.open,onMountAutoFocus:_=>{_.preventDefault()},onUnmountAutoFocus:le(o,_=>{var j;(j=w.trigger)==null||j.focus({preventScroll:!0}),_.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:_=>_.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(D,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:_=>_.preventDefault(),...y,...G,onPlaced:()=>R(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:le(y.onKeyDown,_=>{const j=_.ctrlKey||_.altKey||_.metaKey;if(_.key==="Tab"&&_.preventDefault(),!j&&_.key.length===1&&J(_.key),["ArrowUp","ArrowDown","Home","End"].includes(_.key)){let Z=B().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(_.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(_.key)){const se=_.target,ae=Z.indexOf(se);Z=Z.slice(ae+1)}setTimeout(()=>Y(Z)),_.preventDefault()}})})})})})})});$m.displayName=iE;var lE="SelectItemAlignedPosition",Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(gr,n),i=Yn(gr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=Me(t,k=>d(k)),m=ii(n),f=h.useRef(!1),x=h.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:y,focusSelectedItem:w}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&v&&y){const k=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),F=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=F.left-A.left,ae=P.left-se,Se=k.left-ae,Ce=k.width+Se,Oe=Math.max(Ce,A.width),Fe=window.innerWidth-mn,Be=Pl(ae,[mn,Math.max(mn,Fe-Oe)]);a.style.minWidth=Ce+"px",a.style.left=Be+"px"}else{const se=A.right-F.right,ae=window.innerWidth-P.right-se,Se=window.innerWidth-k.right-ae,Ce=k.width+Se,Oe=Math.max(Ce,A.width),Fe=window.innerWidth-mn,Be=Pl(ae,[mn,Math.max(mn,Fe-Oe)]);a.style.minWidth=Ce+"px",a.style.right=Be+"px"}const $=m(),B=window.innerHeight-mn*2,K=g.scrollHeight,R=window.getComputedStyle(c),W=parseInt(R.borderTopWidth,10),Y=parseInt(R.paddingTop,10),X=parseInt(R.borderBottomWidth,10),O=parseInt(R.paddingBottom,10),I=W+Y+K+O+X,H=Math.min(v.offsetHeight*5,I),J=window.getComputedStyle(g),M=parseInt(J.paddingTop,10),q=parseInt(J.paddingBottom,10),L=k.top+k.height/2-mn,D=B-L,G=v.offsetHeight/2,_=v.offsetTop+G,j=W+Y+_,U=I-j;if(j<=L){const se=$.length>0&&v===$[$.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max(D,G+(se?q:0)+ae+X),Ce=j+Se;a.style.height=Ce+"px"}else{const se=$.length>0&&v===$[0].ref.current;a.style.top="0px";const Se=Math.max(L,W+g.offsetTop+(se?M:0)+G)+U;a.style.height=Se+"px",g.scrollTop=j-L+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=H+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,v,y,s.dir,r]);It(()=>C(),[C]);const[E,T]=h.useState();It(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const S=h.useCallback(k=>{k&&x.current===!0&&(C(),w==null||w(),x.current=!1)},[C,w]);return u.jsx(uE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:S,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:u.jsx(me.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fm.displayName=lE;var cE="SelectPopperPosition",zl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ai(n);return u.jsx(sl,{...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)"}})});zl.displayName=cE;var[uE,Hl]=Ur(gr,{}),Ul="SelectViewport",Bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ul,n),i=Hl(Ul,n),a=Me(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(si.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:le(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const x=window.innerHeight-mn*2,g=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),y=Math.max(g,v);if(y<x){const w=y+f,C=Math.min(x,w),E=w-C;p.style.height=C+"px",p.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Bm.displayName=Ul;var zm="SelectGroup",[dE,fE]=Ur(zm),pE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(dE,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});pE.displayName=zm;var Hm="SelectLabel",Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fE(Hm,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});Um.displayName=Hm;var li="SelectItem",[hE,Wm]=Ur(li),Vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(li,n),l=Yn(li,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),x=Me(t,w=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,w,r,o)}),g=Pt(),v=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(hE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{p(C=>C||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(si.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:le(i.onFocus,()=>f(!0)),onBlur:le(i.onBlur,()=>f(!1)),onClick:le(i.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:le(i.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:le(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:le(i.onPointerMove,w=>{var C;v.current=w.pointerType,o?(C=l.onItemLeave)==null||C.call(l):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:le(i.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:le(i.onKeyDown,w=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(Qk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Vm.displayName=li;var _o="SelectItemText",Km=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(_o,n),a=Yn(_o,n),l=Wm(_o,n),c=rE(_o,n),[d,p]=h.useState(null),m=Me(t,y=>p(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,x=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=c;return It(()=>(g(x),()=>v(x)),[g,v,x]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Km.displayName=_o;var qm="SelectItemIndicator",Gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Wm(qm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Gm.displayName=qm;var Wl="SelectScrollUpButton",Ym=h.forwardRef((e,t)=>{const n=Yn(Wl,e.__scopeSelect),r=Hl(Wl,e.__scopeSelect),[o,s]=h.useState(!1),i=Me(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Jm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Ym.displayName=Wl;var Vl="SelectScrollDownButton",Xm=h.forwardRef((e,t)=>{const n=Yn(Vl,e.__scopeSelect),r=Hl(Vl,e.__scopeSelect),[o,s]=h.useState(!1),i=Me(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Jm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Xm.displayName=Vl;var Jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=h.useRef(null),a=ii(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:le(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:le(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:le(o.onPointerLeave,()=>{l()})})}),mE="SelectSeparator",Zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Zm.displayName=mE;var Kl="SelectArrow",gE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ai(n),s=Gn(Kl,n),i=Yn(Kl,n);return s.open&&i.position==="popper"?u.jsx(il,{...o,...r,ref:t}):null});gE.displayName=Kl;var vE="SelectBubbleInput",Qm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Me(r,o),i=Im(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(me.select,{...n,style:{...Nm,...n.style},ref:s,defaultValue:t})});Qm.displayName=vE;function eg(e){return e===""||e===void 0}function tg(e){const t=xt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function ng(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=xE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function xE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var bE=Am,rg=jm,wE=Rm,yE=Mm,SE=Om,og=Dm,CE=Bm,sg=Um,ig=Vm,TE=Km,kE=Gm,ag=Ym,lg=Xm,cg=Zm;const EE=bE,IE=wE,ug=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(rg,{ref:r,className:oe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(yE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ug.displayName=rg.displayName;const dg=h.forwardRef(({className:e,...t},n)=>u.jsx(ag,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronUp,{className:"h-4 w-4"})}));dg.displayName=ag.displayName;const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(lg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));fg.displayName=lg.displayName;const pg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(SE,{children:u.jsxs(og,{ref:o,className:oe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(dg,{}),u.jsx(CE,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(fg,{})]})}));pg.displayName=og.displayName;const NE=h.forwardRef(({className:e,...t},n)=>u.jsx(sg,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));NE.displayName=sg.displayName;const hg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ig,{ref:r,className:oe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(kE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(TE,{children:t})]}));hg.displayName=ig.displayName;const AE=h.forwardRef(({className:e,...t},n)=>u.jsx(cg,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));AE.displayName=cg.displayName;var PE="Separator",mg="horizontal",jE=["horizontal","vertical"],gg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=mg,...o}=e,s=_E(r)?r:mg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});gg.displayName=PE;function _E(e){return jE.includes(e)}var vg=gg;const xg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(vg,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));xg.displayName=vg.displayName;var ci="Switch",[RE,U1]=nn(ci),[ME,OE]=RE(ci),bg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),x=Me(t,C=>f(C)),g=h.useRef(!1),v=m?d||!!m.closest("form"):!0,[y,w]=In({prop:o,defaultProp:s??!1,onChange:c,caller:ci});return u.jsxs(ME,{scope:n,checked:y,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:x,onClick:le(e.onClick,C=>{w(E=>!E),v&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),v&&u.jsx(Sg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});bg.displayName=ci;var wg="SwitchThumb",yg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=OE(wg,n);return u.jsx(me.span,{"data-state":Cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});yg.displayName=wg;var DE="SwitchBubbleInput",Sg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Me(i,s),l=Im(n),c=_p(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const x=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(x)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Sg.displayName=DE;function Cg(e){return e?"checked":"unchecked"}var Tg=bg,LE=yg;const kg=h.forwardRef(({className:e,...t},n)=>u.jsx(Tg,{className:oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(LE,{className:oe("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")})}));kg.displayName=Tg.displayName;const $E=oa,FE=Ww,BE=sa,Eg=h.forwardRef(({className:e,...t},n)=>u.jsx(so,{className:oe("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}));Eg.displayName=so.displayName;const zE=Kr.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"}}),Ig=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(BE,{children:[u.jsx(Eg,{}),u.jsxs(io,{ref:o,className:oe(zE({side:e}),t),...r,children:[n,u.jsxs(Rd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ig.displayName=io.displayName;const Ng=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ng.displayName="SheetHeader";const Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Ag.displayName=or.displayName;const Pg=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Pg.displayName=ls.displayName;var[ui,W1]=nn("Tooltip",[$r]),di=$r(),jg="TooltipProvider",HE=700,ql="tooltip.open",[UE,Gl]=ui(jg),_g=e=>{const{__scopeTooltip:t,delayDuration:n=HE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(UE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};_g.displayName=jg;var Ro="Tooltip",[WE,fi]=ui(Ro),Rg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Gl(Ro,e.__scopeTooltip),c=di(t),[d,p]=h.useState(null),m=Pt(),f=h.useRef(0),x=i??l.disableHoverableContent,g=a??l.delayDuration,v=h.useRef(!1),[y,w]=In({prop:r,defaultProp:o??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(ql))):l.onClose(),s==null||s(k)},caller:Ro}),C=h.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,v.current=!1,w(!0)},[w]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),S=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{v.current=!0,w(!0),f.current=0},g)},[g,w]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(rl,{...c,children:u.jsx(WE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?S():E()},[l.isOpenDelayedRef,S,E]),onTriggerLeave:h.useCallback(()=>{x?T():(window.clearTimeout(f.current),f.current=0)},[T,x]),onOpen:E,onClose:T,disableHoverableContent:x,children:n})})};Rg.displayName=Ro;var Yl="TooltipTrigger",Mg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=fi(Yl,n),s=Gl(Yl,n),i=di(n),a=h.useRef(null),l=Me(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ol,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:le(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:le(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:le(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:le(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:le(e.onBlur,o.onClose),onClick:le(e.onClick,o.onClose)})})});Mg.displayName=Yl;var VE="TooltipPortal",[V1,KE]=ui(VE,{forceMount:void 0}),Wr="TooltipContent",Og=h.forwardRef((e,t)=>{const n=KE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=fi(Wr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Dg,{side:o,...s,ref:t}):u.jsx(qE,{side:o,...s,ref:t})})}),qE=h.forwardRef((e,t)=>{const n=fi(Wr,e.__scopeTooltip),r=Gl(Wr,e.__scopeTooltip),o=h.useRef(null),s=Me(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((x,g)=>{const v=x.currentTarget,y={x:x.clientX,y:x.clientY},w=ZE(y,v.getBoundingClientRect()),C=QE(y,w),E=eI(g.getBoundingClientRect()),T=nI([...C,...E]);a(T),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const x=v=>f(v,d),g=v=>f(v,l);return l.addEventListener("pointerleave",x),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",x),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const x=g=>{const v=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(v))||(d==null?void 0:d.contains(v)),C=!tI(y,i);w?m():C&&(m(),c())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[l,d,i,c,m]),u.jsx(Dg,{...e,ref:s})}),[GE,YE]=ui(Ro,{isInside:!1}),XE=Jt.createSlottable("TooltipContent"),Dg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=fi(Wr,n),c=di(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(ql,d),()=>document.removeEventListener(ql,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(sl,{"data-state":l.stateAttribute,...c,...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:[u.jsx(XE,{children:r}),u.jsx(GE,{scope:n,isInside:!0,children:u.jsx(Jk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Og.displayName=Wr;var Lg="TooltipArrow",JE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=di(n);return YE(Lg,n).isInside?null:u.jsx(il,{...o,...r,ref:t})});JE.displayName=Lg;function ZE(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 QE(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 eI(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 tI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function nI(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),rI(t)}function rI(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 oI=_g,sI=Rg,iI=Mg,$g=Og;const aI=oI,lI=sI,cI=iI,Fg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx($g,{ref:r,sideOffset:t,className:oe("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}));Fg.displayName=$g.displayName;var Xl="ToastProvider",[Jl,uI,dI]=_s("Toast"),[Bg,K1]=nn("Toast",[dI]),[fI,pi]=Bg(Xl),zg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Xl}\`. Expected non-empty \`string\`.`),u.jsx(Jl.Provider,{scope:t,children:u.jsx(fI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};zg.displayName=Xl;var Hg="ToastViewport",pI=["F8"],Zl="toast.viewportPause",Ql="toast.viewportResume",Ug=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=pI,label:o="Notifications ({hotkey})",...s}=e,i=pi(Hg,n),a=uI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Me(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),x=i.toastCount>0;h.useEffect(()=>{const v=y=>{var C;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((C=p.current)==null||C.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r]),h.useEffect(()=>{const v=l.current,y=p.current;if(x&&v&&y){const w=()=>{if(!i.isClosePausedRef.current){const S=new CustomEvent(Zl);y.dispatchEvent(S),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const S=new CustomEvent(Ql);y.dispatchEvent(S),i.isClosePausedRef.current=!1}},E=S=>{!v.contains(S.relatedTarget)&&C()},T=()=>{v.contains(document.activeElement)||C()};return v.addEventListener("focusin",w),v.addEventListener("focusout",E),v.addEventListener("pointermove",w),v.addEventListener("pointerleave",T),window.addEventListener("blur",w),window.addEventListener("focus",C),()=>{v.removeEventListener("focusin",w),v.removeEventListener("focusout",E),v.removeEventListener("pointermove",w),v.removeEventListener("pointerleave",T),window.removeEventListener("blur",w),window.removeEventListener("focus",C)}}},[x,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:v})=>{const w=a().map(C=>{const E=C.ref.current,T=[E,...EI(E)];return v==="forwards"?T:T.reverse()});return(v==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const v=p.current;if(v){const y=w=>{var T,S,k;const C=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!C){const A=document.activeElement,P=w.shiftKey;if(w.target===v&&P){(T=c.current)==null||T.focus();return}const B=g({tabbingDirection:P?"backwards":"forwards"}),K=B.findIndex(R=>R===A);nc(B.slice(K+1))?w.preventDefault():P?(S=c.current)==null||S.focus():(k=d.current)==null||k.focus()}};return v.addEventListener("keydown",y),()=>v.removeEventListener("keydown",y)}},[a,g]),u.jsxs($b,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:x?void 0:"none"},children:[x&&u.jsx(ec,{ref:c,onFocusFromOutsideViewport:()=>{const v=g({tabbingDirection:"forwards"});nc(v)}}),u.jsx(Jl.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),x&&u.jsx(ec,{ref:d,onFocusFromOutsideViewport:()=>{const v=g({tabbingDirection:"backwards"});nc(v)}})]})});Ug.displayName=Hg;var Wg="ToastFocusProxy",ec=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=pi(Wg,n);return u.jsx(oi,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});ec.displayName=Wg;var Mo="Toast",hI="toast.swipeStart",mI="toast.swipeMove",gI="toast.swipeCancel",vI="toast.swipeEnd",Vg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=In({prop:r,defaultProp:o??!0,onChange:s,caller:Mo});return u.jsx(Ft,{present:n||a,children:u.jsx(wI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:xt(e.onPause),onResume:xt(e.onResume),onSwipeStart:le(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:le(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:le(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:le(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Vg.displayName=Mo;var[xI,bI]=Bg(Mo,{onClose(){}}),wI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...x}=e,g=pi(Mo,n),[v,y]=h.useState(null),w=Me(t,R=>y(R)),C=h.useRef(null),E=h.useRef(null),T=o||g.duration,S=h.useRef(0),k=h.useRef(T),A=h.useRef(0),{onToastAdd:P,onToastRemove:F}=g,$=xt(()=>{var W;(v==null?void 0:v.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),B=h.useCallback(R=>{!R||R===1/0||(window.clearTimeout(A.current),S.current=new Date().getTime(),A.current=window.setTimeout($,R))},[$]);h.useEffect(()=>{const R=g.viewport;if(R){const W=()=>{B(k.current),c==null||c()},Y=()=>{const X=new Date().getTime()-S.current;k.current=k.current-X,window.clearTimeout(A.current),l==null||l()};return R.addEventListener(Zl,Y),R.addEventListener(Ql,W),()=>{R.removeEventListener(Zl,Y),R.removeEventListener(Ql,W)}}},[g.viewport,T,l,c,B]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(T)},[s,T,g.isClosePausedRef,B]),h.useEffect(()=>(P(),()=>F()),[P,F]);const K=h.useMemo(()=>v?Zg(v):null,[v]);return g.viewport?u.jsxs(u.Fragment,{children:[K&&u.jsx(yI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:K}),u.jsx(xI,{scope:n,onClose:$,children:qr.createPortal(u.jsx(Jl.ItemSlot,{scope:n,children:u.jsx(Lb,{asChild:!0,onEscapeKeyDown:le(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...x,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:le(e.onKeyDown,R=>{R.key==="Escape"&&(a==null||a(R.nativeEvent),R.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:le(e.onPointerDown,R=>{R.button===0&&(C.current={x:R.clientX,y:R.clientY})}),onPointerMove:le(e.onPointerMove,R=>{if(!C.current)return;const W=R.clientX-C.current.x,Y=R.clientY-C.current.y,X=!!E.current,O=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,H=O?I(0,W):0,J=O?0:I(0,Y),M=R.pointerType==="touch"?10:2,q={x:H,y:J},L={originalEvent:R,delta:q};X?(E.current=q,hi(mI,p,L,{discrete:!1})):Qg(q,g.swipeDirection,M)?(E.current=q,hi(hI,d,L,{discrete:!1}),R.target.setPointerCapture(R.pointerId)):(Math.abs(W)>M||Math.abs(Y)>M)&&(C.current=null)}),onPointerUp:le(e.onPointerUp,R=>{const W=E.current,Y=R.target;if(Y.hasPointerCapture(R.pointerId)&&Y.releasePointerCapture(R.pointerId),E.current=null,C.current=null,W){const X=R.currentTarget,O={originalEvent:R,delta:W};Qg(W,g.swipeDirection,g.swipeThreshold)?hi(vI,f,O,{discrete:!0}):hi(gI,m,O,{discrete:!0}),X.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),yI=e=>{const{__scopeToast:t,children:n,...r}=e,o=pi(Mo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return TI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(oo,{asChild:!0,children:u.jsx(oi,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},SI="ToastTitle",Kg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Kg.displayName=SI;var CI="ToastDescription",qg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});qg.displayName=CI;var Gg="ToastAction",Yg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Jg,{altText:n,asChild:!0,children:u.jsx(tc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Gg}\`. Expected non-empty \`string\`.`),null)});Yg.displayName=Gg;var Xg="ToastClose",tc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=bI(Xg,n);return u.jsx(Jg,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:le(e.onClick,o.onClose)})})});tc.displayName=Xg;var Jg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(me.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Zg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),kI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Zg(r))}}),t}function hi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ui(o,s):o.dispatchEvent(s)}var Qg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function TI(e=()=>{}){const t=xt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function kI(e){return e.nodeType===e.ELEMENT_NODE}function EI(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 nc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var II=zg,ev=Ug,tv=Vg,nv=Kg,rv=qg,ov=Yg,sv=tc;const NI=II,iv=h.forwardRef(({className:e,...t},n)=>u.jsx(ev,{ref:n,className:oe("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));iv.displayName=ev.displayName;const AI=Kr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),av=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(tv,{ref:r,className:oe(AI({variant:t}),e),...n}));av.displayName=tv.displayName;const PI=h.forwardRef(({className:e,...t},n)=>u.jsx(ov,{ref:n,className:oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));PI.displayName=ov.displayName;const lv=h.forwardRef(({className:e,...t},n)=>u.jsx(sv,{ref:n,className:oe("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(de.X,{className:"h-4 w-4"})}));lv.displayName=sv.displayName;const cv=h.forwardRef(({className:e,...t},n)=>u.jsx(nv,{ref:n,className:oe("text-sm font-semibold",e),...t}));cv.displayName=nv.displayName;const uv=h.forwardRef(({className:e,...t},n)=>u.jsx(rv,{ref:n,className:oe("text-sm opacity-90",e),...t}));uv.displayName=rv.displayName;function jI(){const{toasts:e}=of();return u.jsxs(NI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(av,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(cv,{children:n}),r&&u.jsx(uv,{children:r})]}),o,u.jsx(lv,{})]},t)}),u.jsx(iv,{})]})}var _I=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(x=>{let g=x==="class",v=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...v),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(x,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,x=i&&f==="system"?m():f;d(x)}catch{}},RI=h.createContext(void 0),MI={setTheme:e=>{},themes:[]},OI=()=>{var e;return(e=h.useContext(RI))!=null?e:MI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${_I.toString()})(${d})`}})});var DI=e=>{switch(e){case"success":return FI;case"info":return zI;case"warning":return BI;case"error":return HI;default:return null}},LI=Array(12).fill(0),$I=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},LI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),FI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),BI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),zI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),HI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),UI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),WI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},rc=1,VI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:rc++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(qI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||rc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Yt=new VI,KI=(e,t)=>{let n=(t==null?void 0:t.id)||rc++;return Yt.addToast({title:e,...t,id:n}),n},qI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",GI=KI,YI=()=>Yt.toasts,XI=()=>Yt.getActiveToasts();Object.assign(GI,{success:Yt.success,info:Yt.info,warning:Yt.warning,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss,loading:Yt.loading},{getHistory:YI,getToasts:XI});function JI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}JI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
131
|
+
`);function mi(e){return e.label!==void 0}var ZI=3,QI="32px",e1="16px",dv=4e3,t1=356,n1=14,r1=20,o1=200;function gn(...e){return e.filter(Boolean).join(" ")}function s1(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var i1=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:x,interacting:g,setHeights:v,visibleToasts:y,heights:w,index:C,toasts:E,expanded:T,removeToast:S,defaultRichColors:k,closeButton:A,style:P,cancelButtonStyle:F,actionButtonStyle:$,className:B="",descriptionClassName:K="",duration:R,position:W,gap:Y,loadingIcon:X,expandByDefault:O,classNames:I,icons:H,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:M}=e,[q,L]=b.useState(null),[D,G]=b.useState(null),[_,j]=b.useState(!1),[U,Z]=b.useState(!1),[se,ae]=b.useState(!1),[Se,Ce]=b.useState(!1),[Oe,Fe]=b.useState(!1),[Be,Ke]=b.useState(0),[ze,dt]=b.useState(0),pt=b.useRef(f.duration||R||dv),Ze=b.useRef(null),He=b.useRef(null),Re=C===0,qe=C+1<=y,Ae=f.type,Ge=f.dismissible!==!1,Xe=f.className||"",Ct=f.descriptionClassName||"",Qe=b.useMemo(()=>w.findIndex(xe=>xe.toastId===f.id)||0,[w,f.id]),Tt=b.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:A},[f.closeButton,A]),ht=b.useMemo(()=>f.duration||R||dv,[f.duration,R]),wt=b.useRef(0),At=b.useRef(0),jt=b.useRef(0),mt=b.useRef(null),[gt,Ht]=W.split("-"),Ve=b.useMemo(()=>w.reduce((xe,Le,Ue)=>Ue>=Qe?xe:xe+Le.height,0),[w,Qe]),$e=WI(),ft=f.invert||m,kt=Ae==="loading";At.current=b.useMemo(()=>Qe*Y+Ve,[Qe,Ve]),b.useEffect(()=>{pt.current=ht},[ht]),b.useEffect(()=>{j(!0)},[]),b.useEffect(()=>{let xe=He.current;if(xe){let Le=xe.getBoundingClientRect().height;return dt(Le),v(Ue=>[{toastId:f.id,height:Le,position:f.position},...Ue]),()=>v(Ue=>Ue.filter(st=>st.toastId!==f.id))}},[v,f.id]),b.useLayoutEffect(()=>{if(!_)return;let xe=He.current,Le=xe.style.height;xe.style.height="auto";let Ue=xe.getBoundingClientRect().height;xe.style.height=Le,dt(Ue),v(st=>st.find(tt=>tt.toastId===f.id)?st.map(tt=>tt.toastId===f.id?{...tt,height:Ue}:tt):[{toastId:f.id,height:Ue,position:f.position},...st])},[_,f.title,f.description,v,f.id]);let ct=b.useCallback(()=>{Z(!0),Ke(At.current),v(xe=>xe.filter(Le=>Le.toastId!==f.id)),setTimeout(()=>{S(f)},o1)},[f,S,v,At]);b.useEffect(()=>{if(f.promise&&Ae==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return T||g||M&&$e?(()=>{if(jt.current<wt.current){let Le=new Date().getTime()-wt.current;pt.current=pt.current-Le}jt.current=new Date().getTime()})():pt.current!==1/0&&(wt.current=new Date().getTime(),xe=setTimeout(()=>{var Le;(Le=f.onAutoClose)==null||Le.call(f,f),ct()},pt.current)),()=>clearTimeout(xe)},[T,g,f,Ae,M,$e,ct]),b.useEffect(()=>{f.delete&&ct()},[ct,f.delete]);function _t(){var xe,Le,Ue;return H!=null&&H.loading?b.createElement("div",{className:gn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Ae==="loading"},H.loading):X?b.createElement("div",{className:gn(I==null?void 0:I.loader,(Le=f==null?void 0:f.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":Ae==="loading"},X):b.createElement($I,{className:gn(I==null?void 0:I.loader,(Ue=f==null?void 0:f.classNames)==null?void 0:Ue.loader),visible:Ae==="loading"})}return b.createElement("li",{tabIndex:0,ref:He,className:gn(B,Xe,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Ae],(n=f==null?void 0:f.classNames)==null?void 0:n[Ae]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:k,"data-styled":!(f.jsx||f.unstyled||x),"data-mounted":_,"data-promise":!!f.promise,"data-swiped":Oe,"data-removed":U,"data-visible":qe,"data-y-position":gt,"data-x-position":Ht,"data-index":C,"data-front":Re,"data-swiping":se,"data-dismissible":Ge,"data-type":Ae,"data-invert":ft,"data-swipe-out":Se,"data-swipe-direction":D,"data-expanded":!!(T||O&&_),style:{"--index":C,"--toasts-before":C,"--z-index":E.length-C,"--offset":`${U?Be:At.current}px`,"--initial-height":O?"auto":`${ze}px`,...P,...f.style},onDragEnd:()=>{ae(!1),L(null),mt.current=null},onPointerDown:xe=>{kt||!Ge||(Ze.current=new Date,Ke(At.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(ae(!0),mt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Le,Ue,st;if(Se||!Ge)return;mt.current=null;let tt=Number(((xe=He.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ut=Number(((Le=He.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),et=new Date().getTime()-((Ue=Ze.current)==null?void 0:Ue.getTime()),Q=q==="x"?tt:ut,ee=Math.abs(Q)/et;if(Math.abs(Q)>=r1||ee>.11){Ke(At.current),(st=f.onDismiss)==null||st.call(f,f),G(q==="x"?tt>0?"right":"left":ut>0?"down":"up"),ct(),Ce(!0),Fe(!1);return}ae(!1),L(null)},onPointerMove:xe=>{var Le,Ue,st,tt;if(!mt.current||!Ge||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;let ut=xe.clientY-mt.current.y,et=xe.clientX-mt.current.x,Q=(Ue=e.swipeDirections)!=null?Ue:s1(W);!q&&(Math.abs(et)>1||Math.abs(ut)>1)&&L(Math.abs(et)>Math.abs(ut)?"x":"y");let ee={x:0,y:0};q==="y"?(Q.includes("top")||Q.includes("bottom"))&&(Q.includes("top")&&ut<0||Q.includes("bottom")&&ut>0)&&(ee.y=ut):q==="x"&&(Q.includes("left")||Q.includes("right"))&&(Q.includes("left")&&et<0||Q.includes("right")&&et>0)&&(ee.x=et),(Math.abs(ee.x)>0||Math.abs(ee.y)>0)&&Fe(!0),(st=He.current)==null||st.style.setProperty("--swipe-amount-x",`${ee.x}px`),(tt=He.current)==null||tt.style.setProperty("--swipe-amount-y",`${ee.y}px`)}},Tt&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":kt,"data-close-button":!0,onClick:kt||!Ge?()=>{}:()=>{var xe;ct(),(xe=f.onDismiss)==null||xe.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=H==null?void 0:H.close)!=null?s:UI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,Ae||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||_t():null,f.type!=="loading"?f.icon||(H==null?void 0:H[Ae])||DI(Ae):null):null,b.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:gn(K,Ct,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&mi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||F,onClick:xe=>{var Le,Ue;mi(f.cancel)&&Ge&&((Ue=(Le=f.cancel).onClick)==null||Ue.call(Le,xe),ct())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&mi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||$,onClick:xe=>{var Le,Ue;mi(f.action)&&((Ue=(Le=f.action).onClick)==null||Ue.call(Le,xe),!xe.defaultPrevented&&ct())},className:gn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function fv(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function a1(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?e1:QI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var l1=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:x=ZI,toastOptions:g,dir:v=fv(),gap:y=n1,loadingIcon:w,icons:C,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:T}=e,[S,k]=b.useState([]),A=b.useMemo(()=>Array.from(new Set([r].concat(S.filter(M=>M.position).map(M=>M.position)))),[S,r]),[P,F]=b.useState([]),[$,B]=b.useState(!1),[K,R]=b.useState(!1),[W,Y]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),X=b.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),H=b.useRef(!1),J=b.useCallback(M=>{k(q=>{var L;return(L=q.find(D=>D.id===M.id))!=null&&L.delete||Yt.dismiss(M.id),q.filter(({id:D})=>D!==M.id)})},[]);return b.useEffect(()=>Yt.subscribe(M=>{if(M.dismiss){k(q=>q.map(L=>L.id===M.id?{...L,delete:!0}:L));return}setTimeout(()=>{Oo.flushSync(()=>{k(q=>{let L=q.findIndex(D=>D.id===M.id);return L!==-1?[...q.slice(0,L),{...q[L],...M},...q.slice(L+1)]:[M,...q]})})})}),[]),b.useEffect(()=>{if(d!=="system"){Y(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Y("dark"):Y("light")),typeof window>"u")return;let M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:q})=>{Y(q?"dark":"light")})}catch{M.addListener(({matches:L})=>{try{Y(L?"dark":"light")}catch(D){console.error(D)}})}},[d]),b.useEffect(()=>{S.length<=1&&B(!1)},[S]),b.useEffect(()=>{let M=q=>{var L,D;o.every(G=>q[G]||q.code===G)&&(B(!0),(L=X.current)==null||L.focus()),q.code==="Escape"&&(document.activeElement===X.current||(D=X.current)!=null&&D.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[o]),b.useEffect(()=>{if(X.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,H.current=!1)}},[X.current]),b.createElement("section",{ref:t,"aria-label":`${E} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((M,q)=>{var L;let[D,G]=M.split("-");return S.length?b.createElement("ol",{key:M,dir:v==="auto"?fv():v,tabIndex:-1,ref:X,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":D,"data-lifted":$&&S.length>1&&!s,"data-x-position":G,style:{"--front-toast-height":`${((L=P[0])==null?void 0:L.height)||0}px`,"--width":`${t1}px`,"--gap":`${y}px`,...f,...a1(l,c)},onBlur:_=>{H.current&&!_.currentTarget.contains(_.relatedTarget)&&(H.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:_=>{_.target instanceof HTMLElement&&_.target.dataset.dismissible==="false"||H.current||(H.current=!0,I.current=_.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{K||B(!1)},onDragEnd:()=>B(!1),onPointerDown:_=>{_.target instanceof HTMLElement&&_.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},S.filter(_=>!_.position&&q===0||_.position===M).map((_,j)=>{var U,Z;return b.createElement(i1,{key:_.id,icons:C,index:j,toast:_,defaultRichColors:p,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:x,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:K,position:M,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:S.filter(se=>se.position==_.position),heights:P.filter(se=>se.position==_.position),setHeights:F,expandByDefault:s,gap:y,loadingIcon:w,expanded:$,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const c1=({...e})=>{const{theme:t="system"}=OI();return u.jsx(l1,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};z.ApiProvider=lu,z.ArtifactRenderer=Yd,z.Badge=tf,z.Button=nt,z.Card=da,z.CardContent=ms,z.CardDescription=ha,z.CardHeader=fa,z.CardTitle=pa,z.ChatApi=ou,z.ChatApp=Uk,z.ChatInput=Hh,z.ChatInputRow=Uh,z.ChatInterface=Fr,z.ChatProviders=Tr,z.ChatWidget=Kk,z.Command=Tl,z.CommandEmpty=Il,z.CommandGroup=Nl,z.CommandInput=kl,z.CommandItem=Al,z.CommandList=El,z.DEFAULT_TIMEOUT_MS=tu,z.Dialog=ia,z.DialogContent=cs,z.DialogHeader=aa,z.DialogTitle=la,z.DropdownMenu=Ys,z.DropdownMenuContent=Ao,z.DropdownMenuItem=Kn,z.DropdownMenuTrigger=Xs,z.FileApi=su,z.HISTORY_TIMEOUT_MS=nu,z.Input=Dl,z.InterruptPartRenderer=ma,z.Label=Em,z.MarkdownContent=ir,z.MessageComponent=xs,z.MessageContent=ef,z.MessageHeader=nf,z.MessageList=Ua,z.MessageRow=Ha,z.NewChatButton=qk,z.PlotArtifact=Gd,z.SETTINGS_STORAGE_KEY=Hi,z.ScrollArea=Ol,z.Select=EE,z.SelectContent=pg,z.SelectItem=hg,z.SelectTrigger=ug,z.SelectValue=IE,z.Separator=xg,z.Sheet=$E,z.SheetContent=Ig,z.SheetDescription=Pg,z.SheetHeader=Ng,z.SheetTitle=Ag,z.SheetTrigger=FE,z.SimpleChat=Wk,z.SimpleJsonView=hs,z.Sonner=c1,z.StreamProgress=Xd,z.Switch=kg,z.Textarea=vl,z.ThinkingIndicator=Zd,z.ThreadListItem=Ll,z.ThreadManager=ri,z.ThreadStateProvider=Ru,z.ThreadsProvider=hu,z.TimelineColumn=Nv,z.Toaster=jI,z.ToolContent=lp,z.Tooltip=lI,z.TooltipContent=Fg,z.TooltipProvider=aI,z.TooltipTrigger=cI,z.UserTextContent=Qd,z.applySettings=wb,z.buildCheckpointIndex=lc,z.buildCheckpointPreviewMap=vv,z.buildLabelParts=yu,z.chatApiClient=Mn,z.collectText=vu,z.createArtifactPreviewFromPlot=Cu,z.createArtifactPreviewFromSource=Su,z.del=Ri,z.extractConfigFields=vi,z.extractToolContent=nr,z.extractToolMeta=Go,z.fileApiClient=iu,z.fileToBase64=cu,z.formatToolOutput=gu,z.get=Kt,z.getAgentNameFromMessage=bu,z.getChatToken=ji,z.getCheckpointForMessage=xv,z.getCurrentSettings=bb,z.getDefaultApiConfig=Hu,z.getDefaultChatSettings=Uu,z.getMessageAttemptInfo=cc,z.getMessageDomKey=za,z.getPreviewForMessage=gi,z.getToolProgress=Li,z.httpClient=Lt,z.hydrateHistorySnapshots=Xn,z.isEnvelope=du,z.isFileLike=Mi,z.loadStoredSettings=Wu,z.looksLikeMarkdown=mu,z.messageSignature=Di,z.normalizeInterruptId=Oi,z.normalizeMimeType=wu,z.normalizeToolPayload=Tu,z.normalizeToolPayloadValue=Cr,z.onChatTokenChanged=_i,z.parseJsonSafe=er,z.post=to,z.pretty=tr,z.processAttachments=uu,z.put=ru,z.readNumber=dc,z.readString=_n,z.sanitizeForDisplay=Sr,z.saveSettings=Vu,z.setChatToken=Rn,z.stringifyTool=xu,z.toPlainObject=jn,z.unwrap=$t,z.useApi=On,z.useCheckpointIndex=uc,z.useFilePreview=sf,z.useHasChatSession=vb,z.useParsedMessageContent=af,z.useShallowStableValue=$u,z.useStream=zi,z.useStreamingHook=zi,z.useThreadHistoryState=Au,z.useThreadManagerViewState=Cm,z.useThreadState=no,z.useThreadStateUpdater=_u,z.useThreads=yr,z.useThreadsState=fu,z.useToolPayload=cf,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
|
|
132
132
|
//# sourceMappingURL=index.umd.js.map
|