teodor-new-chat-ui 4.3.556 → 4.3.557
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/streaming/utils/types.d.ts +5 -12
- package/dist/index.esm.js +5334 -5445
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +42 -42
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(H,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):(H=typeof globalThis<"u"?globalThis:H||self,b(H.NewChatUI={},H.React,H.reactSlot,H.classVarianceAuthority,H.clsx,H.tailwindMerge,H.LucideReact,H.ReactDOM))})(this,function(H,b,Jt,Kr,
|
|
1
|
+
(function(H,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):(H=typeof globalThis<"u"?globalThis:H||self,b(H.NewChatUI={},H.React,H.reactSlot,H.classVarianceAuthority,H.clsx,H.tailwindMerge,H.LucideReact,H.ReactDOM))})(this,function(H,b,Jt,Kr,mv,gv,ue,Oo){"use strict";var fN=Object.defineProperty;var pN=(H,b,Jt)=>b in H?fN(H,b,{enumerable:!0,configurable:!0,writable:!0,value:Jt}):H[b]=Jt;var ac=(H,b,Jt)=>pN(H,typeof b!="symbol"?b+"":b,Jt);function lc(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=lc(b),qr=lc(Oo),cc=120;function vv(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>cc?`${n.slice(0,cc-3)}…`:n:""}function xi(e){return vv(e.content)||""}function xv(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=xi(o);s&&t.set(r.checkpointId,s)}}return t}function uc(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=xi(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 dc(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 bv(e,t){return e?t.getCheckpoint(e)??null:null}function fc(e){return b.useMemo(()=>uc(e),[e])}function Pn(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 pc(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 bi(e){const t=Pn(e);if(t)return Pn(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)=>wv(s,i)).filter(s=>!!s)].sort((s,i)=>hc(i.createdAt)-hc(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 wv(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=>yv(k)).filter(k=>!!k),o=Pn(e.metadata)??{},s=bi(e.config),i=Pn(e.parent_config??e.parentConfig),a=bi(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=Pn(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:pc(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:kv(r,E,t,l??null),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:x}}function yv(e){var s,i,a;if(!e||typeof e!="object")return null;const t=Sv(e);if(!t)return null;const n=Tv(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 Sv(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&Cv(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 Cv(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function Tv(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function kv(e,t,n,r,o){const s=t.length,i=Ev(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 Ev(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 hc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var wi={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 mc;function
|
|
9
|
+
*/var mc;function Iv(){if(mc)return Gr;mc=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 gc;function
|
|
18
|
-
`+R+N}}var U=!1,
|
|
19
|
-
`),Ut=
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var gc;function Nv(){return gc||(gc=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(Pe){return String(Pe)});we.unshift("Warning: "+te),Function.prototype.apply.call(console[N],console,we)}}var E=!1,T=!1,S=!1,k=!1,j=!1,P;P=Symbol.for("react.module.reference");function F(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||j||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 D(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 G(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 D(N,N.render,"ForwardRef");case p:var ce=N.displayName||null;return ce!==null?ce:G(N.type)||"Memo";case m:{var ge=N,we=ge._payload,Pe=ge._init;try{return G(Pe(we))}catch{return null}}}return null}var M=Object.assign,W=0,Y,z,A,I,K,Q,O;function q(){}q.__reactDisabledLog=!0;function L(){{if(W===0){Y=console.log,z=console.info,A=console.warn,I=console.error,K=console.group,Q=console.groupCollapsed,O=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 $(){{if(W--,W===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},N,{value:Y}),info:M({},N,{value:z}),warn:M({},N,{value:A}),error:M({},N,{value:I}),group:M({},N,{value:K}),groupCollapsed:M({},N,{value:Q}),groupEnd:M({},N,{value:O})})}W<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var X=y.ReactCurrentDispatcher,R;function _(N,te,ne){{if(R===void 0)try{throw Error()}catch(ge){var ce=ge.stack.trim().match(/\n( *(at )?)/);R=ce&&ce[1]||""}return`
|
|
18
|
+
`+R+N}}var U=!1,J;{var oe=typeof WeakMap=="function"?WeakMap:Map;J=new oe}function ae(N,te){if(!N||U)return"";{var ne=J.get(N);if(ne!==void 0)return ne}var ce;U=!0;var ge=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var we;we=X.current,X.current=null,L();try{if(te){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(Xt){ce=Xt}Reflect.construct(N,[],Pe)}else{try{Pe.call()}catch(Xt){ce=Xt}N.call(Pe.prototype)}}else{try{throw Error()}catch(Xt){ce=Xt}N()}}catch(Xt){if(Xt&&ce&&typeof Xt.stack=="string"){for(var ke=Xt.stack.split(`
|
|
19
|
+
`),Ut=ce.stack.split(`
|
|
20
|
+
`),yt=ke.length-1,Et=Ut.length-1;yt>=1&&Et>=0&&ke[yt]!==Ut[Et];)Et--;for(;yt>=1&&Et>=0;yt--,Et--)if(ke[yt]!==Ut[Et]){if(yt!==1||Et!==1)do if(yt--,Et--,Et<0||ke[yt]!==Ut[Et]){var ln=`
|
|
21
|
+
`+ke[yt].replace(" at new "," at ");return N.displayName&&ln.includes("<anonymous>")&&(ln=ln.replace("<anonymous>",N.displayName)),typeof N=="function"&&J.set(N,ln),ln}while(yt>=1&&Et>=0);break}}}finally{U=!1,X.current=we,$(),Error.prepareStackTrace=ge}var Vr=N?N.displayName||N.name:"",vr=Vr?_(Vr):"";return typeof N=="function"&&J.set(N,vr),vr}function Ee(N,te,ne){return ae(N,!1)}function Se(N){var te=N.prototype;return!!(te&&te.isReactComponent)}function Re(N,te,ne){if(N==null)return"";if(typeof N=="function")return ae(N,Se(N));if(typeof N=="string")return _(N);switch(N){case c:return _("Suspense");case d:return _("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return Ee(N.render);case p:return Re(N.type,te,ne);case m:{var ce=N,ge=ce._payload,we=ce._init;try{return Re(we(ge),te,ne)}catch{}}}return""}var He=Object.prototype.hasOwnProperty,Fe={},Ye=y.ReactDebugCurrentFrame;function Ue(N){if(N){var te=N._owner,ne=Re(N.type,N._source,te?te.type:null);Ye.setExtraStackFrame(ne)}else Ye.setExtraStackFrame(null)}function ot(N,te,ne,ce,ge){{var we=Function.call.bind(He);for(var Pe in N)if(we(N,Pe)){var ke=void 0;try{if(typeof N[Pe]!="function"){var Ut=Error((ce||"React class")+": "+ne+" type `"+Pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[Pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ut.name="Invariant Violation",Ut}ke=N[Pe](te,Pe,ce,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(yt){ke=yt}ke&&!(ke instanceof Error)&&(Ue(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,Pe,typeof ke),Ue(null)),ke instanceof Error&&!(ke.message in Fe)&&(Fe[ke.message]=!0,Ue(ge),w("Failed %s type: %s",ne,ke.message),Ue(null))}}}var pt=Array.isArray;function ct(N){return pt(N)}function We(N){{var te=typeof Symbol=="function"&&Symbol.toStringTag,ne=te&&N[Symbol.toStringTag]||N.constructor.name||"Object";return ne}}function Me(N){try{return Ke(N),!1}catch{return!0}}function Ke(N){return""+N}function Ae(N){if(Me(N))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",We(N)),Ke(N)}var qe=y.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0},Ct,Qe;function Tt(N){if(He.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(He.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"&&qe.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 Pt(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,Pe){var ke={$$typeof:t,type:N,key:te,ref:ne,props:Pe,_owner:we};return ke._store={},Object.defineProperty(ke._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ke,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ce}),Object.defineProperty(ke,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ge}),Object.freeze&&(Object.freeze(ke.props),Object.freeze(ke)),ke};function gt(N,te,ne,ce,ge){{var we,Pe={},ke=null,Ut=null;ne!==void 0&&(Ae(ne),ke=""+ne),ht(te)&&(Ae(te.key),ke=""+te.key),Tt(te)&&(Ut=te.ref,wt(te,ge));for(we in te)He.call(te,we)&&!Xe.hasOwnProperty(we)&&(Pe[we]=te[we]);if(N&&N.defaultProps){var yt=N.defaultProps;for(we in yt)Pe[we]===void 0&&(Pe[we]=yt[we])}if(ke||Ut){var Et=typeof N=="function"?N.displayName||N.name||"Unknown":N;ke&&At(Pe,Et),Ut&&Pt(Pe,Et)}return mt(N,ke,Ut,ge,ce,qe.current,Pe)}}var Ht=y.ReactCurrentOwner,Ve=y.ReactDebugCurrentFrame;function $e(N){if(N){var te=N._owner,ne=Re(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 ut(){{if(Ht.current){var N=G(Ht.current.type);if(N)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+N+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+N+"`."}return""}}function _t(N){return""}var xe={};function Le(N){{var te=ut();if(!te){var ne=typeof N=="string"?N:N.displayName||N.name;ne&&(te=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+ne+">.")}return te}}function Be(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 "+G(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(ct(N))for(var ne=0;ne<N.length;ne++){var ce=N[ne];kt(ce)&&Be(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),Pe;!(Pe=we.next()).done;)kt(Pe.value)&&Be(Pe.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=G(te);ot(ne,N.props,"prop",ce,N)}else if(te.PropTypes!==void 0&&!ft){ft=!0;var ge=G(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 dt(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 Z(N,te,ne,ce,ge,we){{var Pe=F(N);if(!Pe){var ke="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(ke+=" 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?ke+=Ut:ke+=ut();var yt;N===null?yt="null":ct(N)?yt="array":N!==void 0&&N.$$typeof===t?(yt="<"+(G(N.type)||"Unknown")+" />",ke=" 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,ke)}var Et=gt(N,te,ne,ge,we);if(Et==null)return Et;if(Pe){var ln=te.children;if(ln!==void 0)if(ce)if(ct(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(He.call(te,"key")){var vr=G(N),Xt=Object.keys(te).filter(function(dN){return dN!=="key"}),ic=Xt.length>0?"{key: someKey, "+Xt.join(": ..., ")+": ...}":"{key: someKey}";if(!et[vr+ic]){var uN=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,xr,gN,xr),mt[xr+ic]=!0}}return N===r?dt(Et):et(Et),Et}}function ae(N,Q,ee){return J(N,Q,ee,!0)}function ie(N,Q,ee){return J(N,Q,ee,!1)}var Ce=ie,Ee=ae;Yr.Fragment=r,Yr.jsx=Ce,Yr.jsxs=Ee}()),Yr}process.env.NODE_ENV==="production"?wi.exports=Px():wi.exports=_x();var u=wi.exports;const Rx=({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(p=>{const v=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"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 ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.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 xc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Mx}=Object.prototype,{getPrototypeOf:yi}=Object,{iterator:Lo,toStringTag:vc}=Symbol,$o=(e=>t=>{const n=Mx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>$o(t)===e),Fo=e=>t=>typeof t===e,{isArray:vr}=Array,br=Fo("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 Ox(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&bc(e.buffer),t}const Dx=Fo("string"),Wt=Fo("function"),wc=Fo("number"),Jr=e=>e!==null&&typeof e=="object",Lx=e=>e===!0||e===!1,Bo=e=>{if($o(e)!=="object")return!1;const t=yi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(vc in e)&&!(Lo in e)},$x=e=>{if(!Jr(e)||Xr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Fx=cn("Date"),Bx=cn("File"),zx=cn("Blob"),Hx=cn("FileList"),Ux=e=>Jr(e)&&Wt(e.pipe),Wx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Wt(e.append)&&((t=$o(e))==="formdata"||t==="object"&&Wt(e.toString)&&e.toString()==="[object FormData]"))},Vx=cn("URLSearchParams"),[Kx,qx,Gx,Yx]=["ReadableStream","Request","Response","Headers"].map(cn),Xx=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]),vr(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;Bo(n[i])&&Bo(o)?n[i]=Si(n[i],o):Bo(o)?n[i]=Si({},o):vr(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 Jx=(e,t,n,{allOwnKeys:r}={})=>(Zr(t,(o,s)=>{n&&Wt(o)?e[s]=xc(o,n):e[s]=o},{allOwnKeys:r}),e),Zx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Qx=(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)},ev=(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},tv=(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},nv=e=>{if(!e)return null;if(vr(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},rv=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yi(Uint8Array)),ov=(e,t)=>{const r=(e&&e[Lo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},sv=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},iv=cn("HTMLFormElement"),av=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),lv=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)},cv=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+"'")})}})},uv=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return vr(e)?r(e):r(String(e).split(t)),n},dv=()=>{},fv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pv(e){return!!(e&&Wt(e.append)&&e[vc]==="FormData"&&e[Lo])}const hv=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=vr(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)},mv=cn("AsyncFunction"),gv=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)),xv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||kc,V={isArray:vr,isArrayBuffer:bc,isBuffer:Xr,isFormData:Wx,isArrayBufferView:Ox,isString:Dx,isNumber:wc,isBoolean:Lx,isObject:Jr,isPlainObject:Bo,isEmptyObject:$x,isReadableStream:Kx,isRequest:qx,isResponse:Gx,isHeaders:Yx,isUndefined:br,isDate:Fx,isFile:Bx,isBlob:zx,isRegExp:lv,isFunction:Wt,isStream:Ux,isURLSearchParams:Vx,isTypedArray:rv,isFileList:Hx,forEach:Zr,merge:Si,extend:Jx,trim:Xx,stripBOM:Zx,inherits:Qx,toFlatObject:ev,kindOf:$o,kindOfTest:cn,endsWith:tv,toArray:nv,forEachEntry:ov,matchAll:sv,isHTMLForm:iv,hasOwnProperty:Cc,hasOwnProp:Cc,reduceDescriptors:Tc,freezeMethods:cv,toObjectSet:uv,toCamelCase:av,noop:dv,toFiniteNumber:fv,findKey:yc,global:Jn,isContextDefined:Sc,isSpecCompliantForm:pv,toJSONObject:hv,isAsyncFn:mv,isThenable:gv,setImmediate:kc,asap:xv,isIterable:e=>e!=null&&Wt(e[Lo])};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 Ec=Pe.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(Pe,Ic),Object.defineProperty(Ec,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(Ec);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 vv=null;function Ci(e){return V.isPlainObject(e)||V.isArray(e)}function Nc(e){return V.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 bv(e){return V.isArray(e)&&!e.some(Ci)}const wv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function zo(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,x){return!V.isUndefined(x[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(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!l&&V.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&bv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=Nc(g),y.forEach(function(C,E){!(V.isUndefined(C)||C===null)&&t.append(i===!0?Ac([g],E,s):i===null?g:g+"[]",c(C))}),!1}return Ci(v)?!0:(t.append(Ac(x,g,s),c(v)),!1)}const f=[],m=Object.assign(wv,{defaultVisitor:d,convertValue:c,isVisitable:Ci});function p(v,g){if(!V.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),V.forEach(v,function(y,w){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(w)?w.trim():w,g,m))===!0&&p(y,g?g.concat(w):[w])}),f.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return p(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&&zo(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 yv(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||yv;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 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 Rc{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 Mc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Sv={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,Cv=ki&&(!Ei||["ReactNative","NativeScript","NS"].indexOf(Ei.product)<0),Tv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",kv=ki&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ki,hasStandardBrowserEnv:Cv,hasStandardBrowserWebWorkerEnv:Tv,navigator:Ei,origin:kv},Symbol.toStringTag,{value:"Module"})),...Sv};function Ev(e,t){return zo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Iv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Nv(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&&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]=Nv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(Iv(r),o,n,0)}),n}return null}function Av(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:Mc,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(Oc(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 Ev(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return zo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Av(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:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Qr.headers[e]={}});const jv=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"]),Pv=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]||(Ov(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 Ni(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 Lc(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 $c(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 Dv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Lv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(m*1e3/p):void 0}}function $v(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Uo=(e,t,n=3)=>{let r=0;const o=Lv(50,250);return $v(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Fc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Bc=e=>(...t)=>V.asap(()=>e(...t)),Fv=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Bv=_t.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 zv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Hv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function zc(e,t,n){let r=!zv(t);return e&&(r||n==!1)?Hv(e,t):t}const Hc=e=>e instanceof Vt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,f,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,f,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,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,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,f)=>o(Hc(c),Hc(d),f,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);V.isUndefined(m)&&f!==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)):""))),V.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.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,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(_t.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Fv(t.url))){const l=o&&s&&Bv.read(s);l&&i.set(o,l)}return t},Uv=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,f,m,p,v;function g(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const C=Vt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};$c(function(k){n(k),g()},function(k){r(k),g()},T),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,x)),x=null)},x.onerror=function(E){const T=E&&E.message?E.message:"Network Error",S=new Pe(T,Pe.ERR_NETWORK,e,x);S.event=E||null,r(S),x=null},x.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||Mc;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Pe(E,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(E,T){x.setRequestHeader(T,E)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Uo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Uo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new wr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=Dv(o.url);if(w&&_t.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Wv=(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}},Vv=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},Kv=async function*(e,t){for await(const n of qv(e))yield*Vv(n,t)},qv=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=Kv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let f=d.byteLength;if(n){let m=s+=f;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:Wo}=V,Gv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Kc,TextEncoder:qc}=V.global,Gc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Yv=e=>{e=V.merge.call({skipUndefined:!0},Gv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Wo(t):typeof fetch=="function",s=Wo(n),i=Wo(r);if(!o)return!1;const a=o&&Wo(Kc),l=o&&(typeof qc=="function"?(v=>g=>v.encode(g))(new qc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Gc(()=>{let v=!1;const g=new n(_t.origin,{body:new Kc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Gc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Pe(`Response type '${v}' is not supported`,Pe.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(V.isArrayBufferView(v)||V.isArrayBuffer(v))return v.byteLength;if(V.isURLSearchParams(v)&&(v=v+""),V.isString(v))return(await l(v)).byteLength},p=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:C,timeout:E,onDownloadProgress:T,onUploadProgress:S,responseType:k,headers:A,withCredentials:j="same-origin",fetchOptions:F}=Uc(v),D=t||fetch;k=k?(k+"").toLowerCase():"text";let B=Wv([w,C&&C.toAbortSignal()],E),G=null;const M=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let W;try{if(S&&c&&x!=="get"&&x!=="head"&&(W=await p(A,y))!==0){let te=new n(g,{method:"POST",body:y,duplex:"half"}),O;if(V.isFormData(y)&&(O=te.headers.get("content-type"))&&A.setContentType(O),te.body){const[q,L]=Fc(W,Uo(Bc(S)));y=Wc(te.body,Vc,q,L)}}V.isString(j)||(j=j?"include":"omit");const Y=s&&"credentials"in n.prototype,z={...F,signal:B,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:Y?j:void 0};G=s&&new n(g,z);let P=await(s?D(G,F):D(g,z));const I=d&&(k==="stream"||k==="response");if(d&&(T||I&&M)){const te={};["status","statusText","headers"].forEach($=>{te[$]=P[$]});const O=V.toFiniteNumber(P.headers.get("content-length")),[q,L]=T&&Fc(O,Uo(Bc(T),!0))||[];P=new r(Wc(P.body,Vc,q,()=>{L&&L(),M&&M()}),te)}k=k||"text";let K=await f[V.findKey(f,k)||"text"](P,v);return!I&&M&&M(),await new Promise((te,O)=>{$c(te,O,{data:K,headers:Vt.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:G})})}catch(Y){throw M&&M(),Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,G),{cause:Y.cause||Y}):Pe.from(Y,Y&&Y.code,v,G)}}},Xv=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=Xv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Yv(t)),d=c;return c};Yc();const Ai={http:vv,xhr:Uv,fetch:{get:Yc}};V.forEach(Ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Xc=e=>`- ${e}`,Jv=e=>V.isFunction(e)||e===null||e===!1,Jc={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,!Jv(r)&&(o=Ai[(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 :
|
|
30
|
+
<%s key={someKey} {...props} />`,ic,vr,uN,vr),et[vr+ic]=!0}}return N===r?dt(Et):tt(Et),Et}}function ee(N,te,ne){return Z(N,te,ne,!0)}function he(N,te,ne){return Z(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=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 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",Rv=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)},Mv=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,V={isArray:xr,isArrayBuffer:bc,isBuffer:Xr,isFormData:Bv,isArrayBufferView:Pv,isString:_v,isNumber:wc,isBoolean:Rv,isObject:Jr,isPlainObject:Fo,isEmptyObject:Mv,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)}V.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:V.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);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 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 V.isPlainObject(e)||V.isArray(e)}function Nc(e){return V.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 V.isArray(e)&&!e.some(Ci)}const gx=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 je("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)&&mx(x)||(V.isFileList(x)||V.endsWith(g,"[]"))&&(y=V.toArray(x)))return g=Nc(g),y.forEach(function(C,E){!(V.isUndefined(C)||C===null)&&t.append(i===!0?Ac([g],E,s):i===null?g:g+"[]",c(C))}),!1}return Ci(x)?!0:(t.append(Ac(v,g,s),c(x)),!1)}const p=[],m=Object.assign(gx,{defaultVisitor:d,convertValue:c,isVisitable:Ci});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 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;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 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 Rc{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 Mc={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",Rt={...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 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 Cx(e){return V.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&&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]=Tx(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(Cx(r),o,n,0)}),n}return null}function kx(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:Mc,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(Oc(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 Sx(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),kx(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"?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: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 Ex=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"]),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]&&Ex[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Dc=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 Nx(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 Ax=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ii(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 jx(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())&&!Ax(t))i(Ix(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 Nx(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||Ii(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||Ii(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||Ii(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?jx(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[Dc]=this[Dc]={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 Ni(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 Lc(e){return!!(e&&e.__CANCEL__)}function wr(e,t,n){je.call(this,e??"canceled",je.ERR_CANCELED,t,n),this.name="CanceledError"}V.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 Rx(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 Mx(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=Rx(50,250);return Mx(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)=>V.asap(()=>e(...t)),Ox=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,Dx=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 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 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(Hc(c),Hc(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 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)):""))),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&&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,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};$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||Mc;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&&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=_x(o.url);if(w&&Rt.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=()=>V.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}=V,Wx=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Kc,TextEncoder:qc}=V.global,Gc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Vx=e=>{e=V.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"?(x=>g=>x.encode(g))(new qc):async x=>new Uint8Array(await new n(x).arrayBuffer())),c=s&&a&&Gc(()=>{let x=!1;const g=new n(Rt.origin,{body:new Kc,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!g}),d=i&&a&&Gc(()=>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 je(`Response type '${x}' is not supported`,je.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:j,withCredentials:P="same-origin",fetchOptions:F}=Uc(x),D=t||fetch;k=k?(k+"").toLowerCase():"text";let B=Bx([w,C&&C.toAbortSignal()],E),G=null;const M=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let W;try{if(S&&c&&v!=="get"&&v!=="head"&&(W=await f(j,y))!==0){let Q=new n(g,{method:"POST",body:y,duplex:"half"}),O;if(V.isFormData(y)&&(O=Q.headers.get("content-type"))&&j.setContentType(O),Q.body){const[q,L]=Fc(W,Ho(Bc(S)));y=Wc(Q.body,Vc,q,L)}}V.isString(P)||(P=P?"include":"omit");const Y=s&&"credentials"in n.prototype,z={...F,signal:B,method:v.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:Y?P:void 0};G=s&&new n(g,z);let A=await(s?D(G,F):D(g,z));const I=d&&(k==="stream"||k==="response");if(d&&(T||I&&M)){const Q={};["status","statusText","headers"].forEach($=>{Q[$]=A[$]});const O=V.toFiniteNumber(A.headers.get("content-length")),[q,L]=T&&Fc(O,Ho(Bc(T),!0))||[];A=new r(Wc(A.body,Vc,q,()=>{L&&L(),M&&M()}),Q)}k=k||"text";let K=await p[V.findKey(p,k)||"text"](A,x);return!I&&M&&M(),await new Promise((Q,O)=>{$c(Q,O,{data:K,headers:Vt.from(A.headers),status:A.status,statusText:A.statusText,config:x,request:G})})}catch(Y){throw M&&M(),Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,x,G),{cause:Y.cause||Y}):je.from(Y,Y&&Y.code,x,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}};V.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=>V.isFunction(e)||e===null||e===!1,Jc={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,!qx(r)&&(o=Ai[(a=String(r)).toLowerCase()],o===void 0))throw new je(`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
33
|
`+i.map(Xc).join(`
|
|
34
|
-
`):" "+Xc(i[0]):"as no adapter specified";throw new
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ko.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Ko.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ko.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.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"],v=>{delete s[v]}),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,f=0,m;if(!l){const v=[Zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let p=n;for(;f<m;){const v=a[f++],g=a[f++];try{p=v(p)}catch(x){g.call(this,x);break}}try{d=Zc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,m=c.length;f<m;)d=d.then(c[f++],c[f++]);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)}};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 Qv=class vx{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 vx(function(o){t=o}),cancel:t}}};function eb(e){return function(n){return e.apply(null,n)}}function tb(e){return V.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=xc(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 tu(Zn(e,o))},n}const vt=tu(Qr);vt.Axios=Qn,vt.CanceledError=wr,vt.CancelToken=Qv,vt.isCancel=Lc,vt.VERSION=Qc,vt.toFormData=zo,vt.AxiosError=Pe,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=eb,vt.isAxiosError=tb,vt.mergeConfig=Zn,vt.AxiosHeaders=Vt,vt.formToJSON=e=>Oc(V.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Jc.getAdapter,vt.HttpStatusCode=Pi,vt.default=vt;const{Axios:EN,AxiosError:IN,CanceledError:NN,isCancel:nu,CancelToken:AN,VERSION:jN,all:PN,Cancel:_N,isAxiosError:RN,spread:MN,toFormData:ON,AxiosHeaders:DN,HttpStatusCode:LN,formToJSON:$N,getAdapter:FN,mergeConfig:BN}=vt;let qo=null;const _i=new Set;function Ri(){return qo}function Rn(e){qo=e,_i.forEach(t=>t(e))}function Mi(e){return _i.add(e),()=>_i.delete(e)}const ru=3e4,ou=9e4,Dt=vt.create({timeout:ru,withCredentials:!0});Dt.interceptors.request.use(e=>(qo&&(e.headers.Authorization=`Bearer ${qo}`),e)),Dt.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 Dt.defaults.baseURL?(await Dt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function to(e,t,n){return Dt.defaults.baseURL?(await Dt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function su(e,t,n){return Dt.defaults.baseURL?(await Dt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Dt.defaults.baseURL?(await Dt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class iu{get baseUrl(){return Dt.defaults.baseURL||""}updateConfig(t){if(t.chatBaseUrl)Dt.defaults.baseURL=t.chatBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");n.endsWith("/chat")?Dt.defaults.baseURL=n:Dt.defaults.baseURL=`${n}/chat`}t.apiKey!==void 0?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(t)}async listThreads(){const t=await Kt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Kt("/threads/shared"),n=Lt(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 Lt(o)}async updateThread(t,n){const r=await su(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await to(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Kt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Kt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Kt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Kt(`/agents/${t}/schema`);return Lt(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 Lt(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 Lt(n)}async cancelRun(t){const n=await to("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return Lt(r)}}const Mn=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 nb{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?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(t)}async listUsers(){const t=await Kt("/users",{baseURL:this.baseUrl});return(t==null?void 0:t.users)??[]}}const rb=new nb,cu=b.createContext(null);function uu({children:e,apiConfig:t}){const n=Mn,r=rb;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=b.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 Di(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 no(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 hu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function mu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function gu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??mu(e);let l="",c=e.slice();if(s){const f=sb(a,s);if(f===""?l="":f===s?l=s:l=f,ib(a,l)&&(l=` ${l}`),l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const p=m.text??"",v={...m,text:p+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function sb(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function ib(e,t){if(!e||!t)return!1;const n=e.slice(-1),r=t[0];if(!n||!r||/\s/.test(n)||/\s/.test(r))return!1;const o=a=>/[A-Za-z0-9]/.test(a),s=a=>/[A-Za-z]/.test(a);return(a=>/[.,;:!?]/.test(a))(n)&&o(r)||/[A-Z]/.test(r)&&!/[\s\(\[\{]/.test(n)?!0:o(n)&&s(r)}function ab(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 no(e,r,s)}return e}function xu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function lb(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),[f,m]=b.useState(""),[p,v]=b.useState(null),[g,x]=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),j=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef({messageId:null,lastSeq:null,lastText:""}),G=b.useCallback(z=>{o(z)},[]),M=b.useCallback(()=>{m(""),v(null),d(null),j.current=null,F.current=null,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),W=b.useCallback(()=>{var K;console.debug("[use-chat] stop() invoked - aborting stream");const z=(K=A.current)==null?void 0:K.threadId,P=()=>{var te;(te=T.current)==null||te.abort(),T.current=null,A.current=null,l(!1),w(!1),k.current=0,x(0)};(z?Mn.cancelRun(z).catch(te=>{console.warn("[use-chat] cancel run failed:",te)}):Promise.resolve()).finally(P)},[]),Y=b.useCallback((z,P,I)=>{T.current&&(T.current.abort(),T.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),j.current=null,F.current=null,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""};const K=new AbortController;T.current=K;let te=null,O=null,q=!1;return A.current={threadId:z.threadId??null,headers:{}},(async()=>{var $,X,R,_,U,Z,re,ce,Ne,ye,Re,We,Fe,Ye,Ve,tt,gt,at,lt;const L=Me=>{var Ke;try{const je=JSON.parse(JSON.stringify(Me));return(Ke=je==null?void 0:je.payload)!=null&&Ke.files_info&&Array.isArray(je.payload.files_info)&&(je.payload.files_info=je.payload.files_info.map(qe=>({...qe,data:qe!=null&&qe.data?`<base64 ${String(qe.data).length} chars>`:qe==null?void 0:qe.data}))),je}catch{return Me}};try{let Me={};try{if(r)Me={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ze=window.__AUTH_TOKEN__,kt=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let ut=null;try{const ge=(X=window.localStorage)==null?void 0:X.getItem("chat-settings");ge&&(ut=((R=JSON.parse(ge))==null?void 0:R.apiKey)||null)}catch{}const Pt=ze||kt||ut||null;Pt&&(Me={Authorization:`Bearer ${Pt}`})}}catch{}console.debug("[use-chat] POST",t+n,L(z));let Ke={};if(typeof window<"u")try{const Oe=(_=window.localStorage)==null?void 0:_.getItem("authSessionId");Oe&&(Ke={"X-Session-Id":Oe})}catch{}const je={...Me,...Ke,...s.current},qe={"Content-Type":"application/json",Accept:"text/event-stream",...je},Be=await fetch(t+n,{method:"POST",headers:qe,body:JSON.stringify(z),signal:K.signal,credentials:i});if(A.current&&(A.current.headers=je),!Be.ok||!Be.body){const Oe=await Be.text().catch(()=>"");console.debug("[use-chat] non-OK response",Be.status,Oe==null?void 0:Oe.slice(0,500));const ze=`stream ${Be.status}${Oe?": "+Oe:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,ze),q=!0,te="error",O=ze,new Error(ze)}w(!0);const nt=Be.body.getReader(),ct=new TextDecoder;let ft="",yt=[];k.current=0,x(0);let Tt=0,pt=null;const At=()=>{if(yt.length){const Oe=yt.join("");yt=[],S.current&&m(ze=>ze+Oe)}pt=null},xt=()=>{typeof window<"u"&&pt==null&&(pt=requestAnimationFrame(At))};let ht=Date.now();const zt=setInterval(()=>{var Oe;if(Date.now()-ht>18e5){const ze="Stream idle timeout";d(ze),te="error",O=ze,K.abort(),(Oe=I==null?void 0:I.onError)==null||Oe.call(I,ze)}},5e3),Ht=1024*1024;try{const Oe=Be.headers.get("X-Thread-Id")||Be.headers.get("x-thread-id"),ze=Be.headers.get("X-Thread-Created")||Be.headers.get("x-thread-created"),kt=Oe??null,ut=String(ze??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:kt}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:kt,created:ut});;){const{value:Pt,done:ge}=await nt.read();if(ge)break;ft+=ct.decode(Pt,{stream:!0}),ft.length>Ht&&(ft="",console.warn("Stream buffer reset: exceeded 1MB"));let De;for(;(De=ft.indexOf(`
|
|
34
|
+
`):" "+Xc(i[0]):"as no adapter specified";throw new je("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ai};function ji(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new wr(null,e)}function Zc(e){return ji(e),e.headers=Vt.from(e.headers),e.data=Ni.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Jc.getAdapter(e.adapter||Qr.adapter,e)(e).then(function(r){return ji(e),r.data=Ni.call(e,e.transformResponse,r),r.headers=Vt.from(r.headers),r},function(r){return Lc(r)||(ji(e),r&&r.response&&(r.response.data=Ni.call(e,e.transformResponse,r.response),r.response.headers=Vt.from(r.response.headers))),Promise.reject(r)})}const Qc="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 eu={};Wo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Qc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new je(o(i," has been removed"+(n?" in "+n:"")),je.ERR_DEPRECATED);return n&&!eu[i]&&(eu[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 Gx(e,t,n){if(typeof e!="object")throw new je("options must be an object",je.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 je("option "+s+" must be "+l,je.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new je("Unknown option "+s,je.ERR_BAD_OPTION)}}const Vo={assertOptions:Gx,validators:Wo},vn=Vo.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Rc,response:new Rc}}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=[Zc.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=Zc.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=zc(t.baseURL,t.url,t.allowAbsoluteUrls);return _c(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 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 V.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 V.extend(n,Qn.prototype,t,{allOwnKeys:!0}),V.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(V.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Jc.getAdapter,vt.HttpStatusCode=Pi,vt.default=vt;const{Axios:wN,AxiosError:yN,CanceledError:SN,isCancel:nu,CancelToken:CN,VERSION:TN,all:kN,Cancel:EN,isAxiosError:IN,spread:NN,toFormData:AN,AxiosHeaders:jN,HttpStatusCode:PN,formToJSON:_N,getAdapter:RN,mergeConfig:MN}=vt;let Ko=null;const _i=new Set;function Ri(){return Ko}function Rn(e){Ko=e,_i.forEach(t=>t(e))}function Mi(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),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 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?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(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 Mn=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?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(t)}async listUsers(){const t=await Kt("/users",{baseURL:this.baseUrl});return(t==null?void 0:t.users)??[]}}const Qx=new Zx,cu=b.createContext(null);function uu({children:e,apiConfig:t}){const n=Mn,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=b.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]=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),j=b.useRef(null),P=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef({messageId:null,lastSeq:null,lastText:""}),G=b.useCallback(z=>{o(z)},[]),M=b.useCallback(()=>{m(""),x(null),d(null),P.current=null,F.current=null,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),W=b.useCallback(()=>{var K;console.debug("[use-chat] stop() invoked - aborting stream");const z=(K=j.current)==null?void 0:K.threadId,A=()=>{var Q;(Q=T.current)==null||Q.abort(),T.current=null,j.current=null,l(!1),w(!1),k.current=0,v(0)};(z?Mn.cancelRun(z).catch(Q=>{console.warn("[use-chat] cancel run failed:",Q)}):Promise.resolve()).finally(A)},[]),Y=b.useCallback((z,A,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,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""};const K=new AbortController;T.current=K;let Q=null,O=null,q=!1;return j.current={threadId:z.threadId??null,headers:{}},(async()=>{var $,X,R,_,U,J,oe,ae,Ee,Se,Re,He,Fe,Ye,Ue,ot,pt,ct;const L=We=>{var Me;try{const Ke=JSON.parse(JSON.stringify(We));return(Me=Ke==null?void 0:Ke.payload)!=null&&Me.files_info&&Array.isArray(Ke.payload.files_info)&&(Ke.payload.files_info=Ke.payload.files_info.map(Ae=>({...Ae,data:Ae!=null&&Ae.data?`<base64 ${String(Ae.data).length} chars>`:Ae==null?void 0:Ae.data}))),Ke}catch{return We}};try{let We={};try{if(r)We={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const $e=window.__AUTH_TOKEN__,ft=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let kt=null;try{const _t=(X=window.localStorage)==null?void 0:X.getItem("chat-settings");_t&&(kt=((R=JSON.parse(_t))==null?void 0:R.apiKey)||null)}catch{}const ut=$e||ft||kt||null;ut&&(We={Authorization:`Bearer ${ut}`})}}catch{}console.debug("[use-chat] POST",t+n,L(z));let Me={};if(typeof window<"u")try{const Ve=(_=window.localStorage)==null?void 0:_.getItem("authSessionId");Ve&&(Me={"X-Session-Id":Ve})}catch{}const Ke={...We,...Me,...s.current},Ae={"Content-Type":"application/json",Accept:"text/event-stream",...Ke},qe=await fetch(t+n,{method:"POST",headers:Ae,body:JSON.stringify(z),signal:K.signal,credentials:i});if(j.current&&(j.current.headers=Ke),!qe.ok||!qe.body){const Ve=await qe.text().catch(()=>"");console.debug("[use-chat] non-OK response",qe.status,Ve==null?void 0:Ve.slice(0,500));const $e=`stream ${qe.status}${Ve?": "+Ve:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,$e),q=!0,Q="error",O=$e,new Error($e)}w(!0);const Xe=qe.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),Q="error",O=$e,K.abort(),(Ve=I==null?void 0:I.onError)==null||Ve.call(I,$e)}},5e3),Ht=1024*1024;try{const Ve=qe.headers.get("X-Thread-Id")||qe.headers.get("x-thread-id"),$e=qe.headers.get("X-Thread-Created")||qe.headers.get("x-thread-created"),ft=Ve??null,kt=String($e??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:ft}),(J=I==null?void 0:I.onOpen)==null||J.call(I,{threadId:ft,created:kt});;){const{value:ut,done:_t}=await Xe.read();if(_t)break;Qe+=Ct.decode(ut,{stream:!0}),Qe.length>Ht&&(Qe="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=Qe.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const
|
|
38
|
-
`);if(!mt)continue;let J;try{J=JSON.parse(mt)}catch{console.debug("[use-chat] malformed SSE:",mt.slice(0,200));continue}dt&&typeof J=="object"&&J!==null&&!("type"in J)&&(J.type=dt);const ae=pu(J)?J.data:J;if(!ae){console.warn("[use-chat] dropped envelope event without payload",J);continue}const ie=ae;ht=Date.now();const Ce=ie.seq;if(Ce!==void 0){if(Ce<=Tt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ce,lastProcessedSeq:Tt,type:ie.type});continue}Tt>0&&Ce>Tt+1&&((re=I==null?void 0:I.onGap)==null||re.call(I,{from:Tt,to:Ce})),Tt=Ce,k.current=Ce,x(Ce)}if(ie.type==="message.start"&&ie.role==="assistant"){const Ee=xu(ie.model);B.current={messageId:ie.id,lastSeq:Ce??null,lastText:""},E({id:ie.id,role:"assistant",name:Ee??void 0,model:ie.model,createdAt:new Date().toISOString(),content:[]})}if(ie.type==="checkpoint")j.current=ie.checkpointId??null,F.current=ie.checkpointNs??null,v(ie.checkpointId??null);else if(ie.type==="state_history"){D.current=ie;try{const N=Xn(ie).latest;N&&(j.current=N.checkpointId??null,F.current=N.checkpointNs??null,v(N.checkpointId??null))}catch(Ee){console.warn("[use-chat] Failed to hydrate state_history payload",Ee)}}try{P==null||P(ie)}catch(Ee){console.error("[use-chat] Error in onEvent callback:",Ee,"for event:",ie.type)}if(ie.type==="messages/partial"){const N=ie.messages;if(Array.isArray(N)&&N.length>0){const Q=N.find(ee=>ee.type==="ai");if(Q){const ee=Q.id,le=Q.content??"",me=Q.response_metadata??{};if(B.current.messageId!==ee){const be=me.model_name??me.model_provider??"assistant";B.current={messageId:ee,lastSeq:null,lastText:""},E({id:ee,role:"assistant",name:be,model:be,createdAt:new Date().toISOString(),content:[{type:"text",text:le}]})}else E(be=>!be||be.id!==ee?be:{...be,content:[{type:"text",text:le}]});const Se=B.current.lastText||"";if(le.length>Se.length){const be=le.slice(Se.length);B.current.lastText=le,e.autoAppendAssistant!==!1&&(yt.push(be),xt())}}}}else if(ie.type==="message.delta"){E(Q=>{const ee=B.current;if(!Q||ee.messageId!==Q.id)return Q;const le=ie,{newParts:me,newMeta:Se,changed:be}=gu(Q.content??[],le.delta,{lastSeq:ee.lastSeq,lastText:ee.lastText},Ce??null);return be?(B.current={...ee,lastSeq:Se.lastSeq??ee.lastSeq,lastText:Se.lastText??ee.lastText},{...Q,content:me}):Q});const N=((ce=ie.delta)==null?void 0:ce.filter(Q=>Q.type==="text").map(Q=>Q.text).join(""))??"";N&&e.autoAppendAssistant!==!1&&(yt.push(N),xt())}else if(ie.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Ne=I==null?void 0:I.onHeartbeat)==null||Ne.call(I,ie)}catch(Ee){console.warn("[use-chat] heartbeat callback failed",Ee)}}else if(pt!==null&&cancelAnimationFrame(pt),At(),ie.type==="checkpoint")v(ie.checkpointId);else if(ie.type==="error"){const Ee=ie;if(d(Ee.message),te="error",O=Ee.message,Ee.error_type==="auth_error"||Ee.code==="TOKEN_EXPIRED"||((ye=Ee.message)==null?void 0:ye.includes("token"))||((Re=Ee.message)==null?void 0:Re.includes("401"))||((We=Ee.message)==null?void 0:We.includes("unauthorized"))||((Fe=Ee.message)==null?void 0:Fe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ee.message);try{(Ye=I==null?void 0:I.onAuthError)==null||Ye.call(I,Ee.message)}catch(Q){console.warn("[use-chat] onAuthError handler failed",Q)}K.abort()}}}}At(),te===null&&!K.signal.aborted&&(te="complete")}catch(Oe){if(Oe.name==="AbortError")te=te??"aborted";else{const ze=Oe.message||String(Oe);te="error",O=ze,d(ze),(Ve=I==null?void 0:I.onError)==null||Ve.call(I,ze)}}finally{try{await nt.cancel()}catch{}finally{(tt=nt.releaseLock)==null||tt.call(nt)}pt!==null&&typeof window<"u"&&window.cancelAnimationFrame(pt),clearInterval(zt)}}catch(Me){if(Me.name==="AbortError")te=te??"aborted";else{const Ke=Me.message||String(Me);te="error",O=Ke,d(Ke),(gt=I==null?void 0:I.onError)==null||gt.call(I,Ke),q||((at=I==null?void 0:I.onConnectionError)==null||at.call(I,Ke),q=!0)}}finally{const Me=k.current,Ke=j.current,je=F.current,qe=D.current,Be=te??(K.signal.aborted?"aborted":O?"error":"complete");try{(lt=I==null?void 0:I.onClosed)==null||lt.call(I,{reason:Be,lastSeq:Me,lastCheckpointId:Ke,lastCheckpointNs:je,lastStateHistory:qe,error:O})}catch(nt){console.warn("[use-chat] onClosed callback failed",nt)}l(!1),w(!1),T.current=null,k.current=0,x(0),A.current=null}})(),{close:()=>K.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var z;S.current=!1,(z=T.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:C,lastCheckpointId:p,lastSeq:g,connected:y,stream:Y,stop:W,clear:M,setToken:G}}const cb=["detail","message","error","description","title"];function Go(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=Go(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of cb){const r=Go(t[n]);if(r)return r}if("errors"in t){const n=Go(t.errors);if(n)return n}}return null}function ub(e){if(!e)return"Request failed";const t=e.response,n=Go(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 vu({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),[f,m]=b.useState(null),[p,v]=b.useState([]),[g,x]=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 P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),j=b.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{A()},[A]),b.useEffect(()=>{j()},[j]),b.useEffect(()=>{r==null||r(a)},[a,r]);const F=b.useCallback(async(P,I)=>{try{const K=await e.createThread(P,I);return l(K.threadId),await A(),K.threadId}catch(K){const te=String(K);return n==null||n(te),null}},[e,n,A]),D=b.useCallback(async P=>{const I=s;i(te=>te.filter(O=>O.threadId!==P));const K=new AbortController;k.current.set(P,K);try{await e.deleteThread(P),S.current===P&&(l(null),o==null||o())}catch(te){i(I);const O=String(te);n==null||n(O)}finally{k.current.delete(P)}},[e,o,n,s]),B=b.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await A()}catch(K){n==null||n(String(K))}},[e,n,A]),G=b.useCallback(async(P,I)=>{T(!0),C("Sharing thread…");try{await e.shareThread(P,I),await j(),C("Shared successfully")}catch(K){const te=ub(K);throw n==null||n(te),C(`Failed to share: ${te}`),new Error(te)}finally{T(!1)}},[e,n,j]),M=b.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await j()}catch(K){const te=String(K);throw n==null||n(te),K}},[e,n,j]),W=b.useMemo(()=>({createThread:F,deleteThread:D,renameThread:B,refreshThreads:A,refreshSharedThreads:j,shareThread:G,unshareThread:M}),[F,D,B,A,j,G,M]),Y=b.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,project:P.project,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(K=>{let te=!1;const O=K.map(q=>q.threadId===I.threadId?(te=!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 te?O:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...K])})},[]),z=b.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:S,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:Y,shareInFlight:E,shareStatus:w,clearShareStatus:z}}const bu=b.createContext(null);function wu({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:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=vu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,f,m,p,g,x,y,v]);return u.jsx(bu.Provider,{value:w,children:e})}function yr(){const e=b.useContext(bu);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=db(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function db(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 Li(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(Li(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(Li(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function yu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Su(e){const t=tr(e);return typeof e=="string"&&yu(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 Cu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Yo(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 $i(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Tu(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 ku(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Fi(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 Eu(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Iu(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Nu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Eu(n),i=o?`data:${s};base64,${e}`:t,a=Iu(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Au(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 Nu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Bi(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 ju(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}const fb={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function pb(e,t){var n;switch(t.type){case"reset":return{messages:Di(((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=Di(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=Di(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 Pu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Pu(o,s),e):e}default:return e}}function hb(e=[]){const[t,n]=b.useReducer(pb,{...fb,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function Pu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=xu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return gb(e,t);if(t.type==="tool.progress")return xb(e,t);if(t.type==="tool.end")return vb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??hu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(T=>T.id===s&&T.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},f=d[s],m=f??{lastSeq:null,lastText:mu(l.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof m.lastSeq=="number"&&p<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=gu(l.content,t.delta,m,p);if(!x)return e;const y={...l,content:v},w=no(i,a,y),C=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,E=C?{...d,[s]:g}:c;return C?{...e,messages:w,messagesStreamMeta:E}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??hu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=l.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return console.log("[MessageReducer] message.end - clearing assemblingId",{wasId:e.assemblingId}),{...e,assemblingId:null}}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=ab(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Xn(t),i=s.interrupt,a=s.latest,l=i===null?ob(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function zi(e){return e.call_id??e.id??null}function _u(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ru(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||Yo(r).toolCallId===t)return n}return-1}function mb(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 Mu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function gb(e,t){const n=zi(t),r=Hi(e.messages,n),o=t.name??t.tool??void 0,s=_u(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:no(e.messages,r,d)}}const i=Ru(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function xb(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=Mu(e.messages[r],o);return{...e,messages:no(e.messages,r,a)}}function vb(e,t){const n=zi(t),r=_u(t);let o=e.messages,s=Hi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Ru(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=mb(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 f=Mu(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:no(o,s,p)}}function Ou({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,f]=b.useState(null),p=b.useMemo(()=>Xn(d),[d]).checkpoints,v=fc(p),g=v.timeline,[x,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),j=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef(new Map),G=b.useRef(null);b.useEffect(()=>{S.current=r},[r]);const M=b.useCallback(async L=>{var X,R;if(!L.threadId)return;const $=L.threadId;(X=L.onStart)==null||X.call(L),L.setLoading(!0);try{await L.action($)}catch(_){if(!nu(_)&&S.current===$){const Z=String(_);(R=L.handleError)==null||R.call(L,Z),n==null||n(Z)}throw _}finally{L.setLoading(!1)}},[n]),W=b.useCallback(async(L,$)=>{var Z;if(!L)return;const X=`${L}:${$??"latest"}`,R=B.current.get(X);if(R)return R;(Z=G.current)==null||Z.abort();const _=new AbortController;G.current=_;const U=M({threadId:L,setLoading:y,onStart:()=>T(null),handleError:re=>T(re),action:async re=>{const ce=await e.getStateHistory({threadId:re,checkpointId:$??void 0,signal:_.signal});if(S.current!==re){console.log(`[useThreadHistoryState] Thread changed during load (was ${re}, now ${S.current}), discarding stale data`);return}const{checkpoints:Ne}=Xn(ce),ye=Ne.find(Re=>Re.messages&&Re.messages.length>0)??($?Ne.find(Re=>Re.checkpointId===$):null)??Ne[0];t((ye==null?void 0:ye.messages)??[],{checkpointId:(ye==null?void 0:ye.checkpointId)??null,checkpointNs:(ye==null?void 0:ye.checkpointNs)??null,pendingInterrupt:(ye==null?void 0:ye.interrupt)??null}),f(ce)}});B.current.set(X,U);try{await U}finally{B.current.delete(X),G.current===_&&(G.current=null)}return S.current===L&&(D.current=X),U},[e,t,M]),Y=b.useCallback(async(L,$)=>{F.current=L;try{await W(L,$)}catch(X){if(!nu(X))throw X}finally{F.current===L&&(F.current=null)}},[W]),z=b.useCallback(L=>{A.current=L},[]),P=b.useCallback(L=>{j.current=L},[]),I=b.useCallback(L=>{const $=L.threadId??S.current;if(!$||S.current&&S.current!==$)return;const{checkpoints:X}=Xn(L);if(!X.length)return;const R=X.find(U=>U.messages&&U.messages.length>0)??X.find(U=>!!U.checkpointId)??X[0],_=j.current===$;!l&&!_&&t((R==null?void 0:R.messages)??[],{checkpointId:(R==null?void 0:R.checkpointId)??null,checkpointNs:(R==null?void 0:R.checkpointNs)??null,pendingInterrupt:(R==null?void 0:R.interrupt)??null}),f(L),D.current=`${$}:latest`,A.current=null,j.current===$&&(j.current=null)},[t,l]),K=b.useCallback(async(L,$)=>{const X=S.current;await M({threadId:X,setLoading:C,action:async R=>{const _=await e.getStateHistory({threadId:R,checkpointId:L,checkpointNs:$??void 0});if(S.current!==R)return;const{checkpoints:U}=Xn(_),Z=U.find(re=>re.checkpointId===L&&($?re.checkpointNs===$:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:$});return}f(_),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,M]),te=b.useCallback((L,$)=>{t(c(),{checkpointId:L??null,checkpointNs:$??null})},[c,t]),O=b.useCallback(async()=>{S.current&&await Y(S.current)},[Y]);b.useEffect(()=>{if(!a||!r||x||l)return;if(A.current===r){A.current=null,k.current=r;return}if(j.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 $=`${r}:latest`;D.current!==$&&Y(r,L)},[a,r,s,i,o,x,l,Y]);const q=b.useCallback(()=>{f(null),y(!1),C(!1),T(null),A.current=null,j.current=null,k.current=null,D.current=null,F.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:w,threadStateError:E,loadThread:Y,navigateToCheckpoint:K,setCurrentCheckpointId:te,returnToLatest:O,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:P,resetHistoryState:q}}const Du=b.createContext(null),Lu=b.createContext(null);function ro(){const e=b.useContext(Du);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function $u(){const e=b.useContext(Lu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Fu({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:f,onEvent:m}=hb(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:w,loadThread:C,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:F}=Ou({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])}),[D,B]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[G,M]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),F())},[l,d,F]);const W=b.useCallback(K=>B(()=>K),[]),Y=b.useCallback(K=>M(()=>K),[]),z=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),P=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:p,checkpointIndex:g,timelineCheckpoints:v,metadata:z,isLoading:x,isLoadingCheckpoint:y,error:w,clearState:D,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,loadThread:C,clearThread:D,respondToInterrupt:G,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:F,pushUser:f,onEvent:m}),[l,c,p,v,g,z,x,y,w,D,E,T,S,C,G,g.messagePreviews,k,A,j,F,f,m]),I=b.useMemo(()=>({registerClearThread:W,registerRespondToInterrupt:Y}),[W,Y]);return u.jsx(Lu.Provider,{value:I,children:u.jsx(Du.Provider,{value:P,children:e})})}function Bu(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 bb(e){const t=Bu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Bu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function wb(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 yb(e,t){const n=[...e].sort(wb);for(const r of n){if(r.messageId!==t)continue;const o=bb(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 zu=b.createContext(null),Hu=b.createContext(!1);function Sb({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:f}=On(),m=f,{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=lb({baseUrl:m}),[w,C]=b.useState(!1);return b.useEffect(()=>{C(g)},[g]),u.jsx(wu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Fu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Hu.Provider,{value:!0,children:u.jsx(Cb,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function Cb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:v}=yr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:C,resetHistoryState:E,pushUser:T,onEvent:S}=ro(),{registerClearThread:k,registerRespondToInterrupt:A}=$u(),j=b.useCallback(z=>{v(z),p.current!==z.threadId&&((z.created??!p.current)&&w(z.threadId),C(z.threadId),m(z.threadId))},[v,w,C,m,p]),F=b.useCallback(z=>{z.type==="thread_info"?j(z):z.type==="state_history"?y(z):z.type==="tool.end"?(S(z),i==null||i(z)):S(z)},[j,y,S,i]),D=b.useCallback(z=>{a(z,F,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,F,r,o,s]),B=b.useRef(g);b.useEffect(()=>{B.current=g},[g]);const G=b.useCallback(async(z,P,I)=>{const K=p.current;if(!K)throw new Error("No active thread to handle interrupt");const te=z?P??!0:!1,O=B.current,q={threadId:K,checkpointId:O.id??void 0,checkpointNs:O.namespace??void 0,command:{kind:"resume",value:te},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};D(q)},[p,D]);b.useEffect(()=>{A(G)},[G,A]);const M=b.useCallback(async()=>{l(),E(),m(null)},[E,m,l]);b.useEffect(()=>{k(M)},[M,k]);const W=b.useCallback(async(z,P)=>{c&&l();let I=p.current;const K=(z==null?void 0:z.text)??"",te=(z==null?void 0:z.attachments)??[],O=(K==null?void 0:K.trim())??"",q={...(z==null?void 0:z.payload)??{}},L=Array.isArray(q.messages)?q.messages:void 0;L&&delete q.messages;const $=!!(L&&L.length),X=!!(z.contentParts&&z.contentParts.length>0);if(!I&&!O&&te.length===0&&!$&&!X)return;if(!I){const tt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),gt=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${tt}${gt}`,w(I),m(I)}let R=null;z.contentParts&&z.contentParts.length>0&&(R=z.contentParts);const{contentParts:_,filesInfo:U}=R?{contentParts:R,filesInfo:[]}:await fu(te),Z=[..._];O&&Z.push({type:"text",text:K});const re=P==null?void 0:P.originalMessageId,ce=!!(P!=null&&P.edit&&re),Ne=!$&&Z.length>0;let ye=null;Ne&&(ye={id:ce?re:`msg-${Date.now()}`,role:"user",content:Z,createdAt:new Date().toISOString()},ce?T(ye,re):T(ye));const Re=$?L:ye?[ye]:[],We={...q,...U.length?{files_info:U}:{}};Re.length?We.messages=Re:"messages"in We||(We.messages=[]);let Fe=(P==null?void 0:P.checkpointId)??g.id??void 0,Ye=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(ce&&re){const tt=yb(x,re);Fe=tt.checkpointId,Ye=tt.checkpointNs??void 0}const Ve={threadId:I,payload:We,checkpointId:Fe,checkpointNs:Ye,config:P==null?void 0:P.config,edit:!!(P!=null&&P.edit)};D(Ve)},[g,p,c,w,T,D,l,x]),Y=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:f}),[c,d,W,l,f]);return u.jsx(zu.Provider,{value:Y,children:e})}function Ui(){const e=b.useContext(zu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Tb(){return b.useContext(Hu)}function Uu(e){return typeof e=="object"&&e!==null}function kb(e,t){if(Object.is(e,t))return!0;if(!Uu(e)||!Uu(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 Wu(e){const t=b.useRef(e),n=b.useRef(e);return kb(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 f=Wu(t),m=oo(a),p=oo(l),v=oo(i),g=oo(c),x=oo(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,v,g,x]);return u.jsx(uu,{apiConfig:f,children:u.jsx(Sb,{...y,children:e})})}function oo(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 Vu(){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 Ku(){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 qu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"");return""}function Gu(){const e={},t=Vu(),n=Ku();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Yu(){const e=Gu(),t=Mn.getAuthToken(),n=Vu();return{apiBaseUrl:qu(e.baseUrl,n),apiKey:t||e.apiKey||Ku()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Wi="chat-settings";function Xu(){try{const e=localStorage.getItem(Wi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Ju(e){try{const t={...e,apiBaseUrl:e.apiBaseUrl.trim().replace(/\/+$/,"")};localStorage.setItem(Wi,JSON.stringify(t)),t.apiKey&&Mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Eb(){const e=Yu(),t=Xu(),n=Mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:qu(Mn.baseUrl,r,e.apiBaseUrl)}}function Ib(e){Mn.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),Ju(e)}function oe(...e){return wx.twMerge(bx.clsx(e))}const Nb=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"}}),Xe=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(Nb({variant:t,size:n,className:e})),ref:s,...o})});Xe.displayName="Button";function ue(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 Zu(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=Zu(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():Zu(e[o],null)}}}}function Le(...e){return h.useCallback(Dn(...e),e)}function Ab(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=f=>{var y;const{scope:m,children:p,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:p})};c.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>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,jb(o,...t)]}function jb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Pb=h[" useId ".trim().toString()]||(()=>{}),_b=0;function jt(e){const[t,n]=h.useState(Pb());return It(()=>{n(r=>r??String(_b++))},[e]),e||(t?`radix-${t}`:"")}var Rb=h[" useInsertionEffect ".trim().toString()]||It;function In({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Mb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var f;if(a){const m=Ob(d)?d(e):d;m!==e&&((f=i.current)==null||f.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Mb({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Rb(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Ob(e){return typeof e=="function"}var Db=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],he=Db.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 bt(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 Lb(e,t=globalThis==null?void 0:globalThis.document){const n=bt(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",Fb="dismissableLayer.pointerDownOutside",Bb="dismissableLayer.focusOutside",Qu,ed=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(ed),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Le(t,k=>f(k)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,E=w>=y,T=Hb(k=>{const A=k.target,j=[...c.branches].some(F=>F.contains(A));!E||j||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),S=Ub(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 Lb(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),nd(),()=>{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),nd())},[d,c]),h.useEffect(()=>{const k=()=>p({});return document.addEventListener(Ki,k),()=>document.removeEventListener(Ki,k)},[]),u.jsx(he.div,{...l,ref:v,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:ue(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ue(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ue(e.onPointerDownCapture,T.onPointerDownCapture)})});Er.displayName=$b;var zb="DismissableLayerBranch",td=h.forwardRef((e,t)=>{const n=h.useContext(ed),r=h.useRef(null),o=Le(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(he.div,{...e,ref:o})});td.displayName=zb;function Hb(e,t=globalThis==null?void 0:globalThis.document){const n=bt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){rd(Fb,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 Ub(e,t=globalThis==null?void 0:globalThis.document){const n=bt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&rd(Bb,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 nd(){const e=new CustomEvent(Ki);document.dispatchEvent(e)}function rd(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 Wb=Er,Vb=td,qi="focusScope.autoFocusOnMount",Gi="focusScope.autoFocusOnUnmount",od={bubbles:!1,cancelable:!0},Kb="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=bt(o),d=bt(s),f=h.useRef(null),m=Le(t,g=>l(g)),p=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(p.paused||!a)return;const E=C.target;a.contains(E)?f.current=E:Ln(f.current,{select:!0})},x=function(C){if(p.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Ln(f.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",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,p.paused]),h.useEffect(()=>{if(a){ad.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(qi,od);a.addEventListener(qi,c),a.dispatchEvent(y),y.defaultPrevented||(qb(Zb(sd(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(qi,c),setTimeout(()=>{const y=new CustomEvent(Gi,od);a.addEventListener(Gi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Gi,d),ad.remove(p)},0)}}},[a,c,d,p]);const v=h.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[C,E]=Gb(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,p.paused]);return u.jsx(he.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Xo.displayName=Kb;function qb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Gb(e){const t=sd(e),n=id(t,e),r=id(t.reverse(),e);return[n,r]}function sd(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 id(e,t){for(const n of e)if(!Yb(n,{upTo:t}))return n}function Yb(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 Xb(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&&Xb(e)&&t&&e.select()}}var ad=Jb();function Jb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ld(e,t),e.unshift(t)},remove(t){var n;e=ld(e,t),(n=e[0])==null||n.resume()}}}function ld(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Zb(e){return e.filter(t=>t.tagName!=="A")}var Qb="Portal",so=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?Do.createPortal(u.jsx(he.div,{...r,ref:t}),i):null});so.displayName=Qb;function ew(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var $t=e=>{const{present:t,children:n}=e,r=tw(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Le(r.ref,nw(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};$t.displayName="Presence";function tw(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=ew(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,p=Jo(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const g=Jo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=p=>{p.target===t&&(s.current=Jo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}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 nw(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]??cd()),document.body.insertAdjacentElement("beforeend",e[1]??cd()),Yi++,()=>{Yi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Yi--}},[])}function cd(){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 vn=function(){return vn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},vn.apply(this,arguments)};function ud(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 rw(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",ow="with-scroll-bars-hidden",sw="--removed-body-scroll-bar-size";function Ji(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function iw(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 aw=typeof window<"u"?h.useLayoutEffect:h.useEffect,dd=new WeakMap;function lw(e,t){var n=iw(null,function(r){return e.forEach(function(o){return Ji(o,r)})});return aw(function(){var r=dd.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)})}dd.set(n,e)},[e]),n}function cw(e){return e}function uw(e,t){t===void 0&&(t=cw);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 dw(e){e===void 0&&(e={});var t=uw(null);return t.options=vn({async:!0,ssr:!1},e),t}var fd=function(e){var t=e.sideCar,n=ud(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,vn({},n))};fd.isSideCarExport=!0;function fw(e,t){return e.useMedium(t),fd}var pd=dw(),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,f=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,C=e.gapMode,E=ud(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,S=lw([n,t]),k=vn(vn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(T,{sideCar:pd,removeScrollBar:c,shards:f,noRelative:p,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),vn(vn({},k),{ref:S})):h.createElement(w,vn({},k,{className:l,ref:S}),a))});es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},es.classNames={fullWidth:Qo,zeroRight:Zo};var pw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=pw();return t&&e.setAttribute("nonce",t),e}function mw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function gw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var xw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=hw())&&(mw(t,n),gw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vw=function(){var e=xw();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},hd=function(){var e=vw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},bw={left:0,top:0,right:0,gap:0},Qi=function(e){return parseInt(e||"",10)||0},ww=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)]},yw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return bw;var t=ww(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])}},Sw=hd(),Ir="data-scroll-locked",Cw=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 Be=Le.split(/\r?\n/),st=[];let tt=null;for(const de of Be){if(de.startsWith(":")){de.startsWith(": heartbeat")&&console.debug("[use-chat] SSE heartbeat comment received");continue}if(de){if(de.startsWith("event:")){const Ie=de.slice(6).trim();Ie&&(tt=Ie);continue}if(de.startsWith("data:")){const Ie=de.slice(5);st.push(Ie.startsWith(" ")?Ie.slice(1):Ie)}}}const dt=st.join(`
|
|
38
|
+
`);if(!dt)continue;let et;try{et=JSON.parse(dt)}catch{console.debug("[use-chat] malformed SSE:",dt.slice(0,200));continue}tt&&typeof et=="object"&&et!==null&&!("type"in et)&&(et.type=tt);const Z=pu(et)?et.data:et;if(!Z){console.warn("[use-chat] dropped envelope event without payload",et);continue}const ee=Z;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&&((oe=I==null?void 0:I.onGap)==null||oe.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"){D.current=ee;try{const Ie=Xn(ee).latest;Ie&&(P.current=Ie.checkpointId??null,F.current=Ie.checkpointNs??null,x(Ie.checkpointId??null))}catch(de){console.warn("[use-chat] Failed to hydrate state_history payload",de)}}try{A==null||A(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(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),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{A==null||A(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{A==null||A(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")x(ee.checkpointId);else if(ee.type==="error"){const de=ee;if(d(de.message),Q="error",O=de.message,de.error_type==="auth_error"||de.code==="TOKEN_EXPIRED"||((Ee=de.message)==null?void 0:Ee.includes("token"))||((Se=de.message)==null?void 0:Se.includes("401"))||((Re=de.message)==null?void 0:Re.includes("unauthorized"))||((He=de.message)==null?void 0:He.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",de.message);try{(Fe=I==null?void 0:I.onAuthError)==null||Fe.call(I,de.message)}catch(N){console.warn("[use-chat] onAuthError handler failed",N)}K.abort()}}}}At(),Q===null&&!K.signal.aborted&&(Q="complete")}catch(Ve){if(Ve.name==="AbortError")Q=Q??"aborted";else{const $e=Ve.message||String(Ve);Q="error",O=$e,d($e),(Ye=I==null?void 0:I.onError)==null||Ye.call(I,$e)}}finally{try{await Xe.cancel()}catch{}finally{(Ue=Xe.releaseLock)==null||Ue.call(Xe)}wt!==null&&typeof window<"u"&&window.cancelAnimationFrame(wt),clearInterval(gt)}}catch(We){if(We.name==="AbortError")Q=Q??"aborted";else{const Me=We.message||String(We);Q="error",O=Me,d(Me),(ot=I==null?void 0:I.onError)==null||ot.call(I,Me),q||((pt=I==null?void 0:I.onConnectionError)==null||pt.call(I,Me),q=!0)}}finally{const We=k.current,Me=P.current,Ke=F.current,Ae=D.current,qe=Q??(K.signal.aborted?"aborted":O?"error":"complete");try{(ct=I==null?void 0:I.onClosed)==null||ct.call(I,{reason:qe,lastSeq:We,lastCheckpointId:Me,lastCheckpointNs:Ke,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),j.current=null}})(),{close:()=>K.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var z;S.current=!1,(z=T.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:Y,stop:W,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]=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 j=b.useCallback(async()=>{d(!0),m(null);try{const A=await e.listThreads();i(A??[])}catch(A){const I=String(A);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),P=b.useCallback(async()=>{v(!0),y(null);try{const A=await e.listSharedThreads();x(A??[])}catch(A){const I=String(A);y(I),n==null||n(I)}finally{v(!1)}},[e,n]);b.useEffect(()=>{j()},[j]),b.useEffect(()=>{P()},[P]),b.useEffect(()=>{r==null||r(a)},[a,r]);const F=b.useCallback(async(A,I)=>{try{const K=await e.createThread(A,I);return l(K.threadId),await j(),K.threadId}catch(K){const Q=String(K);return n==null||n(Q),null}},[e,n,j]),D=b.useCallback(async A=>{const I=s;i(Q=>Q.filter(O=>O.threadId!==A));const K=new AbortController;k.current.set(A,K);try{await e.deleteThread(A),S.current===A&&(l(null),o==null||o())}catch(Q){i(I);const O=String(Q);n==null||n(O)}finally{k.current.delete(A)}},[e,o,n,s]),B=b.useCallback(async(A,I)=>{try{await e.updateThread(A,I),await j()}catch(K){n==null||n(String(K))}},[e,n,j]),G=b.useCallback(async(A,I)=>{T(!0),C("Sharing thread…");try{await e.shareThread(A,I),await P(),C("Shared successfully")}catch(K){const Q=nb(K);throw n==null||n(Q),C(`Failed to share: ${Q}`),new Error(Q)}finally{T(!1)}},[e,n,P]),M=b.useCallback(async(A,I)=>{try{await e.unshareThread(A,I),await P()}catch(K){const Q=String(K);throw n==null||n(Q),K}},[e,n,P]),W=b.useMemo(()=>({createThread:F,deleteThread:D,renameThread:B,refreshThreads:j,refreshSharedThreads:P,shareThread:G,unshareThread:M}),[F,D,B,j,P,G,M]),Y=b.useCallback(A=>{if(!(A!=null&&A.threadId))return;const I={threadId:A.threadId,title:A.title||`Thread ${A.threadId.slice(0,8)}`,project:A.project,createdAt:A.createdAt||new Date().toISOString(),updatedAt:A.updatedAt||new Date().toISOString(),messageCount:A.messageCount??1};i(K=>{let Q=!1;const O=K.map(q=>q.threadId===I.threadId?(Q=!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 Q?O:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...K])})},[]),z=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:z}}const mu=b.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:x,shareInFlight:g,shareStatus:v,clearShareStatus:y}=hu({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(mu.Provider,{value:w,children:e})}function yr(){const e=b.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]=b.useReducer(ab,{...ib,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 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 x=t.name??t.tool??void 0;o=[...o,Au(r,n,x,{})],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]=b.useState(null),f=b.useMemo(()=>Xn(d),[d]).checkpoints,x=fc(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),j=b.useRef(null),P=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef(new Map),G=b.useRef(null);b.useEffect(()=>{S.current=r},[r]);const M=b.useCallback(async L=>{var X,R;if(!L.threadId)return;const $=L.threadId;(X=L.onStart)==null||X.call(L),L.setLoading(!0);try{await L.action($)}catch(_){if(!nu(_)&&S.current===$){const J=String(_);(R=L.handleError)==null||R.call(L,J),n==null||n(J)}throw _}finally{L.setLoading(!1)}},[n]),W=b.useCallback(async(L,$)=>{var J;if(!L)return;const X=`${L}:${$??"latest"}`,R=B.current.get(X);if(R)return R;(J=G.current)==null||J.abort();const _=new AbortController;G.current=_;const U=M({threadId:L,setLoading:y,onStart:()=>T(null),handleError:oe=>T(oe),action:async oe=>{const ae=await e.getStateHistory({threadId:oe,checkpointId:$??void 0,signal:_.signal});if(S.current!==oe){console.log(`[useThreadHistoryState] Thread changed during load (was ${oe}, now ${S.current}), discarding stale data`);return}const{checkpoints:Ee}=Xn(ae),Se=Ee.find(Re=>Re.messages&&Re.messages.length>0)??($?Ee.find(Re=>Re.checkpointId===$):null)??Ee[0];t((Se==null?void 0:Se.messages)??[],{checkpointId:(Se==null?void 0:Se.checkpointId)??null,checkpointNs:(Se==null?void 0:Se.checkpointNs)??null,pendingInterrupt:(Se==null?void 0:Se.interrupt)??null}),p(ae)}});B.current.set(X,U);try{await U}finally{B.current.delete(X),G.current===_&&(G.current=null)}return S.current===L&&(D.current=X),U},[e,t,M]),Y=b.useCallback(async(L,$)=>{F.current=L;try{await W(L,$)}catch(X){if(!nu(X))throw X}finally{F.current===L&&(F.current=null)}},[W]),z=b.useCallback(L=>{j.current=L},[]),A=b.useCallback(L=>{P.current=L},[]),I=b.useCallback(L=>{const $=L.threadId??S.current;if(!$||S.current&&S.current!==$)return;const{checkpoints:X}=Xn(L);if(!X.length)return;const R=X.find(U=>U.messages&&U.messages.length>0)??X.find(U=>!!U.checkpointId)??X[0],_=P.current===$;!l&&!_&&t((R==null?void 0:R.messages)??[],{checkpointId:(R==null?void 0:R.checkpointId)??null,checkpointNs:(R==null?void 0:R.checkpointNs)??null,pendingInterrupt:(R==null?void 0:R.interrupt)??null}),p(L),D.current=`${$}:latest`,j.current=null,P.current===$&&(P.current=null)},[t,l]),K=b.useCallback(async(L,$)=>{const X=S.current;await M({threadId:X,setLoading:C,action:async R=>{const _=await e.getStateHistory({threadId:R,checkpointId:L,checkpointNs:$??void 0});if(S.current!==R)return;const{checkpoints:U}=Xn(_),J=U.find(oe=>oe.checkpointId===L&&($?oe.checkpointNs===$:!0));if(!J){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:$});return}p(_),t(J.messages??[],{checkpointId:J.checkpointId??null,checkpointNs:J.checkpointNs??null})}}).catch(()=>{})},[e,t,M]),Q=b.useCallback((L,$)=>{t(c(),{checkpointId:L??null,checkpointNs:$??null})},[c,t]),O=b.useCallback(async()=>{S.current&&await Y(S.current)},[Y]);b.useEffect(()=>{if(!a||!r||v||l)return;if(j.current===r){j.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 $=`${r}:latest`;D.current!==$&&Y(r,L)},[a,r,s,i,o,v,l,Y]);const q=b.useCallback(()=>{p(null),y(!1),C(!1),T(null),j.current=null,P.current=null,k.current=null,D.current=null,F.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:x,isLoadingThread:v,isLoadingCheckpoint:w,threadStateError:E,loadThread:Y,navigateToCheckpoint:K,setCurrentCheckpointId:Q,returnToLatest:O,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:A,resetHistoryState:q}}const _u=b.createContext(null),Ru=b.createContext(null);function no(){const e=b.useContext(_u);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Mu(){const e=b.useContext(Ru);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:x,checkpointIndex:g,isLoadingThread:v,isLoadingCheckpoint:y,threadStateError:w,loadThread:C,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,handleStateHistoryEvent:k,markSkipNextLoad:j,markStreamPendingThread:P,resetHistoryState:F}=Pu({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])}),[D,B]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[G,M]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),F())},[l,d,F]);const W=b.useCallback(K=>B(()=>K),[]),Y=b.useCallback(K=>M(()=>K),[]),z=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),A=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:z,isLoading:v,isLoadingCheckpoint:y,error:w,clearState:D,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,loadThread:C,clearThread:D,respondToInterrupt:G,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:j,markStreamPendingThread:P,resetHistoryState:F,pushUser:p,onEvent:m}),[l,c,f,x,g,z,v,y,w,D,E,T,S,C,G,g.messagePreviews,k,j,P,F,p,m]),I=b.useMemo(()=>({registerClearThread:W,registerRespondToInterrupt:Y}),[W,Y]);return u.jsx(Ru.Provider,{value:I,children:u.jsx(_u.Provider,{value:A,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=b.createContext(null),$u=b.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:x,isStreaming:g,error:v,setToken:y}=eb({baseUrl:m}),[w,C]=b.useState(!1);return b.useEffect(()=>{C(g)},[g]),u.jsx(gu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Ou,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx($u.Provider,{value:!0,children:u.jsx(vb,{api:d,streamApi:{stream:f,stop:x,isStreaming:g,error:v,setToken:y},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,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:x}=yr(),{checkpoint:g,timelineCheckpoints:v,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:C,resetHistoryState:E,pushUser:T,onEvent:S}=no(),{registerClearThread:k,registerRespondToInterrupt:j}=Mu(),P=b.useCallback(z=>{x(z),f.current!==z.threadId&&((z.created??!f.current)&&w(z.threadId),C(z.threadId),m(z.threadId))},[x,w,C,m,f]),F=b.useCallback(z=>{z.type==="thread_info"?P(z):z.type==="state_history"?y(z):z.type==="tool.end"?(S(z),i==null||i(z)):S(z)},[P,y,S,i]),D=b.useCallback(z=>{a(z,F,{onError:A=>{console.error("[StreamingProvider] Stream error:",A),r==null||r(A)},onAuthError:A=>{console.error("[StreamingProvider] Auth error:",A),o==null||o(A)},onConnectionError:A=>{console.error("[StreamingProvider] Connection error:",A),s==null||s(A)}})},[a,F,r,o,s]),B=b.useRef(g);b.useEffect(()=>{B.current=g},[g]);const G=b.useCallback(async(z,A,I)=>{const K=f.current;if(!K)throw new Error("No active thread to handle interrupt");const Q=z?A??!0:!1,O=B.current,q={threadId:K,checkpointId:O.id??void 0,checkpointNs:O.namespace??void 0,command:{kind:"resume",value:Q},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};D(q)},[f,D]);b.useEffect(()=>{j(G)},[G,j]);const M=b.useCallback(async()=>{l(),E(),m(null)},[E,m,l]);b.useEffect(()=>{k(M)},[M,k]);const W=b.useCallback(async(z,A)=>{c&&l();let I=f.current;const K=(z==null?void 0:z.text)??"",Q=(z==null?void 0:z.attachments)??[],O=(K==null?void 0:K.trim())??"",q={...(z==null?void 0:z.payload)??{}},L=Array.isArray(q.messages)?q.messages:void 0;L&&delete q.messages;const $=!!(L&&L.length),X=!!(z.contentParts&&z.contentParts.length>0);if(!I&&!O&&Q.length===0&&!$&&!X)return;if(!I){const ot=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),pt=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${ot}${pt}`,w(I),m(I)}let R=null;z.contentParts&&z.contentParts.length>0&&(R=z.contentParts);const{contentParts:_,filesInfo:U}=R?{contentParts:R,filesInfo:[]}:await fu(Q),J=[..._];O&&J.push({type:"text",text:K});const oe=A==null?void 0:A.originalMessageId,ae=!!(A!=null&&A.edit&&oe),Ee=!$&&J.length>0;let Se=null;Ee&&(Se={id:ae?oe:`msg-${Date.now()}`,role:"user",content:J,createdAt:new Date().toISOString()},ae?T(Se,oe):T(Se));const Re=$?L:Se?[Se]:[],He={...q,...U.length?{files_info:U}:{}};Re.length?He.messages=Re:"messages"in He||(He.messages=[]);let Fe=(A==null?void 0:A.checkpointId)??g.id??void 0,Ye=(A==null?void 0:A.checkpointNs)??g.namespace??void 0;if(ae&&oe){const ot=mb(v,oe);Fe=ot.checkpointId,Ye=ot.checkpointNs??void 0}const Ue={threadId:I,payload:He,checkpointId:Fe,checkpointNs:Ye,config:A==null?void 0:A.config,edit:!!(A!=null&&A.edit)};D(Ue)},[g,f,c,w,T,D,l,v]),Y=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:p}),[c,d,W,l,p]);return u.jsx(Lu.Provider,{value:Y,children:e})}function Ui(){const e=b.useContext(Lu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function xb(){return b.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=b.useRef(e),n=b.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),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(uu,{apiConfig:p,children:u.jsx(gb,{...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 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=Mn.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&&Mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function wb(){const e=Vu(),t=Ku(),n=Mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Uu(Mn.baseUrl,r,e.apiBaseUrl)}}function yb(e){Mn.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),qu(e)}function se(...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"}}),Je=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Jt.Slot:"button";return u.jsx(i,{className:se(Sb({variant:t,size:n,className:e})),ref:s,...o})});Je.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 Oe(...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,...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,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",Rb="dismissableLayer.pointerDownOutside",Mb="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({}),x=Oe(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 j=k.target,P=[...c.branches].some(F=>F.contains(j));!E||P||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),S=Lb(k=>{const j=k.target;[...c.branches].some(F=>F.contains(j))||(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: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=_b;var Ob="DismissableLayerBranch",Ju=h.forwardRef((e,t)=>{const n=h.useContext(Xu),r=h.useRef(null),o=Oe(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(Rb,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(Mb,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=Oe(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 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]=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:x})});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=Oe(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=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 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,x=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: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 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(Zb,` {
|
|
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(Qb,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},
|
|
76
|
+
`)},dd=function(){var e=parseInt(document.body.getAttribute(Ir)||"0",10);return isFinite(e)?e:0},xw=function(){h.useEffect(function(){return document.body.setAttribute(Ir,(dd()+1).toString()),function(){var e=dd()-1;e<=0?document.body.removeAttribute(Ir):document.body.setAttribute(Ir,e.toString())}},[])},bw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;xw();var s=h.useMemo(function(){return mw(o)},[o]);return h.createElement(gw,{styles:vw(s,!t,o,n?"":"!important")})},ea=!1;if(typeof window<"u")try{var ts=Object.defineProperty({},"passive",{get:function(){return ea=!0,!0}});window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{ea=!1}var Nr=ea?{passive:!1}:!1,ww=function(e){return e.tagName==="TEXTAREA"},fd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!ww(e)&&n[t]==="visible")},yw=function(e){return fd(e,"overflowY")},Sw=function(e){return fd(e,"overflowX")},pd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=hd(e,r);if(o){var s=md(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Cw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Tw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},hd=function(e,t){return e==="v"?yw(t):Sw(t)},md=function(e,t){return e==="v"?Cw(t):Tw(t)},kw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Ew=function(e,t,n,r,o){var s=kw(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=md(e,a),x=f[0],g=f[1],v=f[2],y=g-v-s*x;(x||y)&&hd(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]},gd=function(e){return[e.deltaX,e.deltaY]},vd=function(e){return e&&"current"in e?e.current:e},Iw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Nw=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},
|
|
79
|
+
`)},Aw=0,Ar=[];function jw(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Aw++)[0],s=h.useState(ud)[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=Jb([e.lockRef.current],(e.shards||[]).map(vd),!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 j=pd(k,S);if(!j)return!0;if(j?T=k:(T=k==="v"?"h":"v",j=pd(k,S)),!j)return!1;if(!r.current&&"changedTouches"in g&&(C||E)&&(r.current=T),!T)return!0;var P=r.current||T;return Ew(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?gd(v):ns(v),w=t.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&Iw(T.delta,y)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var C=(i.current.shards||[]).map(vd).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,gd(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:Nw(o)}):null,f?h.createElement(bw,{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 _w=iw(cd,jw);var rs=h.forwardRef(function(e,t){return h.createElement(es,xn({},e,{ref:t,sideCar:_w}))});rs.classNames=es.classNames;var Rw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,os=new WeakMap,ss={},ta=0,xd=function(e){return e&&(e.host||xd(e.parentNode))},Mw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=xd(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})},Ow=function(e,t,n,r){var o=Mw(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=(jr.get(m)||0)+1,v=(s.get(m)||0)+1;jr.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(),ta++,function(){i.forEach(function(p){var m=jr.get(p)-1,f=s.get(p)-1;jr.set(p,m),s.set(p,f),m||(os.has(p)||p.removeAttribute(r),os.delete(p)),f||p.removeAttribute(n)}),ta--,ta||(jr=new WeakMap,jr=new WeakMap,os=new WeakMap,ss={})}},na=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Rw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ow(r,o,n,"aria-hidden")):function(){return null}},is="Dialog",[bd,ON]=nn(is),[Dw,un]=bd(is),wd=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(Dw,{scope:t,triggerRef:a,contentRef:l,contentId:jt(),titleId:jt(),descriptionId:jt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};wd.displayName=is;var yd="DialogTrigger",Sd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(yd,n),s=Oe(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":sa(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});Sd.displayName=yd;var ra="DialogPortal",[Lw,Cd]=bd(ra,{forceMount:void 0}),Td=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=un(ra,t);return u.jsx(Lw,{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})}))})};Td.displayName=ra;var as="DialogOverlay",kd=h.forwardRef((e,t)=>{const n=Cd(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(Fw,{...o,ref:t})}):null});kd.displayName=as;var $w=Jt.createSlot("DialogOverlay.RemoveScroll"),Fw=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(as,n);return u.jsx(rs,{as:$w,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":sa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),rr="DialogContent",Ed=h.forwardRef((e,t)=>{const n=Cd(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(Bw,{...o,ref:t}):u.jsx(zw,{...o,ref:t})})});Ed.displayName=rr;var Bw=h.forwardRef((e,t)=>{const n=un(rr,e.__scopeDialog),r=h.useRef(null),o=Oe(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return na(s)},[]),u.jsx(Id,{...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())})}),zw=h.forwardRef((e,t)=>{const n=un(rr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(Id,{...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()}})}),Id=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=un(rr,n),l=h.useRef(null),c=Oe(t,l);return Xi(),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":sa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(Hw,{titleId:a.titleId}),u.jsx(Ww,{contentRef:l,descriptionId:a.descriptionId})]})]})}),oa="DialogTitle",Nd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(oa,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Nd.displayName=oa;var Ad="DialogDescription",jd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Ad,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});jd.displayName=Ad;var Pd="DialogClose",_d=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Pd,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});_d.displayName=Pd;function sa(e){return e?"open":"closed"}var Rd="DialogTitleWarning",[DN,Md]=Cb(Rd,{contentName:rr,titleName:oa,docsSlug:"dialog"}),Hw=({titleId:e})=>{const t=Md(Rd),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},Yw="DialogDescriptionWarning",Xw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$d(Yw).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=Td,Jw=Ed,aa=Nd,io=Ad,ao=jd,or=_d,ls=Md,Fd=Dd;const la=ia,Zw=aa,Bd=h.forwardRef(({className:e,...t},n)=>u.jsx(io,{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}));Bd.displayName=io.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(Zw,{children:[u.jsx(Bd,{}),u.jsxs(ao,{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(Fd,{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=ao.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 ey=1,ty=1e6;let ca=0;function ny(){return ca=(ca+1)%Number.MAX_SAFE_INTEGER,ca.toString()}const ua=new Map,zd=e=>{if(ua.has(e))return;const t=setTimeout(()=>{ua.delete(e),lo({type:"REMOVE_TOAST",toastId:e})},ty);ua.set(e,t)},ry=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,ey)};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?zd(n):e.toasts.forEach(r=>{zd(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 lo(e){ps=ry(ps,e),fs.forEach(t=>{t(ps)})}function oy({...e}){const t=ny(),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 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:oy,dismiss:n=>lo({type:"DISMISS_TOAST",toastId:n})}}function fa(e,t){return t==="application/octet-stream"&&e.toLowerCase().endsWith(".pdf")?"application/pdf":t}function sy({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:f}=da(),{fileApi:m}=On(),p=b.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]);b.useEffect(()=>{e&&n&&p()},[e,n,p]);const v=async()=>{if(n)try{await m.downloadFileById(n),f({title:"Download started",description:`Downloading ${r}`})}catch(w){console.error("Failed to download file:",w),f({title:"Download failed",description:String(w),variant:"destructive"})}},g=async()=>{if(n)try{const w=await m.getFileContent(n),C=fa(r,o),E=new Blob([w],{type:C}),T=URL.createObjectURL(E);window.open(T,"_blank"),URL.revokeObjectURL(T)}catch(w){console.error("Failed to open file externally:",w),f({title:"Failed to open file",description:String(w),variant:"destructive"})}},x=()=>{if(s)return u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(de.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(Xe,{onClick:p,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("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${w};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):w==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):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.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(de.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]})},y=()=>fa(r,o).startsWith("image/")?u.jsx(de.Image,{className:"h-5 w-5"}):u.jsx(de.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.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Xe,{variant:"outline",size:"sm",onClick:g,className:"flex items-center gap-2",children:[u.jsx(de.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Xe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(de.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function Hd(){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=Hd();function iy(e){sr=e}const Ud=/[&<>"']/,ay=new RegExp(Ud.source,"g"),Wd=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ly=new RegExp(Wd.source,"g"),cy={"&":"&","<":"<",">":">",'"':""","'":"'"},Vd=e=>cy[e];function Rt(e,t){if(t){if(Ud.test(e))return e.replace(ay,Vd)}else if(Wd.test(e))return e.replace(ly,Vd);return e}const uy=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Kd(e){return e.replace(uy,(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 dy=/(^|[^\[])\^/g;function Ze(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(dy,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const fy=/[^\w:]/g,py=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function qd(e,t,n){if(e){let r;try{r=decodeURIComponent(Kd(n)).replace(fy,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!py.test(n)&&(n=xy(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const hs={},hy=/^[^:]+:\/*[^/]*$/,my=/^([^:]+:)[\s\S]*$/,gy=/^([^:]+:\/*[^/]*)[\s\S]*$/;function xy(e,t){hs[" "+e]||(hy.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(my,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(gy,"$1")+t:e+t}const ms={exec:function(){}};function Gd(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 vy(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 by(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 Yd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Xd(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 wy(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},Uw="DialogDescriptionWarning",Ww=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Md(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:se("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:se("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:se("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:se("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:se("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})}}function fa(e,t){return t==="application/octet-stream"&&e.toLowerCase().endsWith(".pdf")?"application/pdf":t}function Qw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:p}=da(),{fileApi:m}=On(),f=b.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]);b.useEffect(()=>{e&&n&&f()},[e,n,f]);const x=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=async()=>{if(n)try{const w=await m.getFileContent(n),C=fa(r,o),E=new Blob([w],{type:C}),T=URL.createObjectURL(E);window.open(T,"_blank"),URL.revokeObjectURL(T)}catch(w){console.error("Failed to open file externally:",w),p({title:"Failed to open file",description:String(w),variant:"destructive"})}},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(Je,{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("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${w};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):w==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):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.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]})},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.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Je,{variant:"outline",size:"sm",onClick:g,className:"flex items-center gap-2",children:[u.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Je,{variant:"outline",size:"sm",onClick:x,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 ey(e){sr=e}const Fd=/[&<>"']/,ty=new RegExp(Fd.source,"g"),Bd=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ny=new RegExp(Bd.source,"g"),ry={"&":"&","<":"<",">":">",'"':""","'":"'"},zd=e=>ry[e];function Mt(e,t){if(t){if(Fd.test(e))return e.replace(ty,zd)}else if(Bd.test(e))return e.replace(ny,zd);return e}const oy=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Hd(e){return e.replace(oy,(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 sy=/(^|[^\[])\^/g;function nt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(sy,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const iy=/[^\w:]/g,ay=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ud(e,t,n){if(e){let r;try{r=decodeURIComponent(Hd(n)).replace(iy,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!ay.test(n)&&(n=dy(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const hs={},ly=/^[^:]+:\/*[^/]*$/,cy=/^([^:]+:)[\s\S]*$/,uy=/^([^:]+:\/*[^/]*)[\s\S]*$/;function dy(e,t){hs[" "+e]||(ly.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(cy,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(uy,"$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 fy(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 py(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?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 hy(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
85
|
`)}class pa{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:gs(r,`
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
87
|
-
`,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),
|
|
88
|
-
`,1)[0],this.options.pedantic?(i=2,
|
|
89
|
-
`,t=t.substring(
|
|
90
|
-
`,1)[0],
|
|
91
|
-
`+
|
|
92
|
-
`+
|
|
93
|
-
`,t=t.substring(m.length+1),d=
|
|
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",
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=hy(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=gs(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
|
+
`,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),p=t.split(`
|
|
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),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
|
+
`,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
|
+
`+p.slice(i);else{if(l||d.search(/[^ ]/)>=4||S.test(d)||k.test(d)||T.test(d))break;f+=`
|
|
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]):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:Wd(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]=Wd(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=gs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=fy(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)),Kd(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 Kd(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:ms,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=nt(ye.def).replace("label",ye._label).replace("title",ye._title).getRegex(),ye.bullet=/(?:[*+-]|\d{1,9}[.)])/,ye.listItemStart=nt(/^( *)(bull) */).replace("bull",ye.bullet).getRegex(),ye.list=nt(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=nt(ye.html,"i").replace("comment",ye._comment).replace("tag",ye._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ye.paragraph=nt(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=nt(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=nt(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=nt(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:nt(`^ *(?: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:ms,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:nt(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:ms,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=nt(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=nt(ye._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=nt(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=nt(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=nt(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=nt(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=nt(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=nt(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=nt(pe.reflink).replace("label",pe._label).replace("ref",ye._label).getRegex(),pe.nolink=nt(pe.nolink).replace("ref",ye._label).getRegex(),pe.reflinkSearch=nt(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:nt(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:nt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:nt(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=nt(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:nt(pe.br).replace("{2,}","*").getRegex(),text:nt(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function my(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 qd(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 pa,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)+"["+Vd("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)+"["+Vd("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,qd)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,qd))){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,my)){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 ha{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
|
-
`+(
|
|
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 ef(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=Sy(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(by(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const c=function(f){let m;if(!f)try{r.walkTokens&&ve.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ve.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return c(m);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ve.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&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return ef($n.lex,Fn.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},iy(ve.defaults),ve},ve.getDefaults=Hd,ve.defaults=sr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.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=ve.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=ve.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=ve.defaults.hooks||new xs;for(const s in n.hooks){const i=o[s];xs.passThroughHooks.has(s)?o[s]=a=>{if(ve.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=ve.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}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=ef($n.lexInline,Fn.parseInline),ve.Parser=Fn,ve.parser=Fn.parse,ve.Renderer=ha,ve.TextRenderer=Zd,ve.Lexer=$n,ve.lexer=$n.lex,ve.Tokenizer=pa,ve.Slugger=Qd,ve.Hooks=xs,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.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 ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(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 tf({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 nf({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Au(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(tf,{preview:r,idx:o},`${t}-plot-${o}`))}):null}const Cy="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 vs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:Cy,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 rf({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 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 xa=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));xa.displayName="CardTitle";const va=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));va.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 of=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));of.displayName="CardFooter";const Ty=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=Ty(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 f=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:f})}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(xa,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(va,{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(f=>u.jsx(Xe,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),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:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(bs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(of,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Xe,{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(Xe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function sf({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 af({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(Xe,{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 ky(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 lf({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,toolExpandable:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptPart:d,isStreamingMessage:f,streamingDebounceMs:m,enableStreamingMarkdownBuffer:p,renderStreamingMarkdown:v,defaultMessage:g,handleFileClick:x,uploadingFiles:y,messageRole:w,truncateUserMessages:C,userMessagePreviewLength:E,isUserExpanded:T,setIsUserExpanded:S,isCompactLayout:k,iconForeground:A,toolConfig:j,handleInterruptApprove:F,handleInterruptReject:D,handleInterruptAlternative:B,disableInterruptActions:G,isInterruptMessage:M}){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"})]}),[]),z=ky(i,(p??!0)&&f,m??0),P=b.useMemo(()=>z.filter(_=>_.type==="text"),[z]),I=b.useMemo(()=>P.map(_=>_.text??"").join(""),[P]),K=b.useMemo(()=>{if(!v)return null;const _=Iy(I);return{stablePart:I.slice(0,_),tailPart:I.slice(_)}},[I,v]),te=b.useMemo(()=>{if(!K)return null;const{stablePart:_,tailPart:U}=K;return!_&&!U?null:u.jsxs("div",{className:"space-y-2",children:[_?u.jsx(ir,{content:_,allowHtml:!1}):null,U?u.jsx(ir,{content:U,allowHtml:!1}):null]})},[K]),O=b.useMemo(()=>{if(!v)return z;const _=[];let U=!1;for(const Z of z){if(Z.type==="text"){U||(_.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),U=!0);continue}_.push(Z)}return _},[z,v]),L=(v?O:z).filter(_=>_.type!=="interrupt"&&_.type!=="image_url"),$=()=>!l||l.length===0?null:u.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.map((_,U)=>{const Z=_;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)})}),X=b.useCallback(({part:_,i:U})=>{if(_.type==="text"){if(v)return null;const Z=_.text??"",re=Z.trim(),ce=er(re);return ce&&w!=="tool"?u.jsx(vs,{data:ce},U):w==="user"&&C&&re.length>E?u.jsx(af,{text:re,expanded:T,onExpandedChange:S,previewLength:E,isCompact:k},U):u.jsx(ir,{content:Z,allowHtml:!1},U)}if(_.type==="image_url")return null;if(_.type==="file"){const Z=_,re=Z.name||"file";return u.jsxs("a",{href:Z.url,onClick:ce=>x(ce,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(
|
|
130
|
-
`),d=er(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=Py(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=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,toolConfig:m,customStyles:p={},streamingDebounceMs:v=300,renderStreamingMarkdown:g=!0,enableStreamingMarkdownBuffer:x,onEdit:y,onRegenerate:w,onCopy:C,getInterruptOptions:E,attemptCount:T=1,attemptIndex:S=0,onSelectCheckpoint:k,attemptMetas:A=[]}){const[j,F]=b.useState(!1),[D,B]=b.useState(!1),{currentThreadId:G}=yr(),{respondToInterrupt:M}=ro(),[W,Y]=b.useState(!1),z=l==="phone"||l==="half-screen",P=t.role,I=P==="interrupt",K=P==="tool"||I,O=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:$}=m??{},X=b.useMemo(()=>!$||t.role!=="tool"?!1:$(t),[$,t.id,t.role]),[R,_]=b.useState(X?"preview":"expanded");b.useEffect(()=>{_(X?"preview":"expanded")},[X,t.id]);const U=b.useMemo(()=>t.role==="default_message"?t:null,[t]),Z=!!U,re=!(r&&P!=="user"),{uploadingFiles:ce,handleFileClick:Ne,fileViewerOpen:ye,currentFileInfo:Re,closeFileViewer:We}=df({allowFileOpen:re,currentThreadId:G}),Fe=b.useMemo(()=>{switch(P){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))]"}},[P]),Ye=ff(t,U),{contentParts:Ve,imageParts:tt,fileParts:gt,textContent:at,toolMeta:lt,toolRaw:Me,isToolStreaming:Ke,interruptParts:je}=Ye,qe=x??v!==0,Be=b.useMemo(()=>je.length?je[0]:null,[je]),nt=b.useCallback(async()=>{const ae=K?Me:at;async function ie(Ce){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ce);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ee=new Blob([Ce],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ee})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ie(ae),F(!0),setTimeout(()=>F(!1),2e3),C==null||C(ae)}catch(Ce){console.error("Failed to copy:",Ce)}},[K,Me,at,C]),ct=b.useCallback(async(ae,ie)=>{if(!Be)return;if(!$i(Be.id)){console.warn("Interrupt part missing id",Be);return}Y(!0);try{const Ee=E==null?void 0:E(t);await M(ae,ie,Ee)}catch(Ee){console.error("Failed to respond to interrupt:",Ee)}finally{Y(!1)}},[Be,M]),ft=b.useCallback(()=>ct(!0),[ct]),yt=b.useCallback(()=>ct(!1),[ct]),Tt=b.useCallback((ae,ie)=>{if(!ie)return;const Ce={alternativeId:ie.id??ie.label??void 0,alternativeLabel:ie.label};ct(!0,Ce)},[ct]),pt=b.useCallback(()=>{if(!y||!t.id)return;const ae=(K?Me:at)??"",ie="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,ae,ie)},[y,K,Me,at,t]),At=b.useCallback(()=>{w==null||w(n)},[w,n]),xt=b.useCallback(()=>{const ie=oe(z?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Fe);switch(P){case"user":return u.jsx(de.User,{className:ie});case"assistant":return u.jsx(de.Bot,{className:ie});case"tool":return u.jsx(de.Wrench,{className:ie});case"interrupt":return u.jsx(de.Bot,{className:ie});default:return u.jsx(de.Bot,{className:ie})}},[z,Fe,P]),ht=b.useCallback(()=>{const ae="group relative mb-4 flex w-full";switch(P){case"user":return oe(ae,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return oe(ae,"justify-start");default:return ae}},[P]),zt=b.useCallback(()=>{const ae=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",z&&"px-3 py-2 text-sm");if(Z)return oe(ae,"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(P){case"user":return oe(ae,"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(ae,"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(ae,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(ae,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(ae,"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")}},[z,Z,P]),Ht=X&&!I&&O,Oe=b.useCallback(()=>{Ht&&_(ae=>ae==="expanded"?"preview":"expanded")},[Ht]),kt=I?"expanded":R,ut=(f||I)&&O,Pt=u.jsx(lf,{message:t,isToolMessage:K,showToolMessages:ut,toolViewMode:kt,toolExpandable:X,toolConfig:{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:$},isToolStreaming:Ke,contentParts:Ve,textContent:at,imageParts:tt,fileParts:gt,isStreamingMessage:r,defaultMessage:U,enableStreamingMarkdownBuffer:qe,renderStreamingMarkdown:g,streamingDebounceMs:v,handleFileClick:Ne,uploadingFiles:ce,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:D,setIsUserExpanded:B,isCompactLayout:z,iconForeground:Fe,interruptPart:Be,handleInterruptApprove:ft,handleInterruptReject:yt,handleInterruptAlternative:Tt,disableInterruptActions:W,isInterruptMessage:I}),ge=b.useMemo(()=>U?"Assistant":ku(t),[U,t]),De=xt(),He=P==="user"&&(T??1)>1&&typeof k=="function",st=(A==null?void 0:A.length)??0,et=st>0&&S<st-1?A[S+1]:void 0,dt=st>0&&S>0?A[S-1]:void 0,mt=b.useCallback(()=>{!et||!k||k(et.id,void 0,!!et.isLatestAttempt)},[et,k]),J=b.useCallback(()=>{!dt||!k||k(dt.id,void 0,!!dt.isLatestAttempt)},[dt,k]);return K&&!f?null:Z&&U?u.jsx("div",{className:oe(ht(),p.container),children:u.jsxs("div",{className:oe(zt(),p.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",Fe)}),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(ht(),p.container),children:u.jsxs("div",{className:oe(zt(),p.content),children:[u.jsx(uf,{showTimestamp:i,showAgentName:a,isToolMessage:K,iconForeground:Fe,agentName:ge,messageIcon:De,customHeaderClass:p.header,customActionsClass:p.actions,isCompactLayout:z,showActions:s,isEditing:o,messageRole:P,toolViewMode:kt,toolExpandable:X,isInterruptMessage:I,toolMeta:lt,onToggleToolView:Oe,onCopy:nt,onEdit:pt,onRegenerate:At,showCheckpointControls:He,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:mt,handleNewerAttemptSelect:J,messageCreatedAt:t.createdAt,copied:j}),u.jsx("div",{className:"relative",children:Pt}),!(i||a||K)&&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",p.actions),children:[u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.Copy,{className:oe(j?"text-success":"text-current",z?"h-3 w-3":"h-4 w-4")})}),P==="user"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:pt,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.Edit,{className:oe("text-current",z?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&w&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:At,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:oe("text-current",z?"h-3 w-3":"h-4 w-4")})})]})]})}),Re&&u.jsx(sy,{isOpen:ye,onClose:We,fileId:Re.id,fileName:Re.name,mimeType:Re.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Fi(e.message)===Fi(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolConfig"].every(x=>e[x]===t[x]),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)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Bi(e.message),a=Bi(t.message);return i.length===a.length});ws.displayName="MessageComponent";const ys=0,Bn=1,Pr=2,mf=4;function gf(e){return()=>e}function _y(e){e()}function xf(e,t){return n=>e(t(n))}function vf(e,t){return()=>e(t)}function Ry(e,t){return n=>e(t,n)}function wa(e){return e!==void 0}function My(...e){return()=>{e.map(_y)}}function _r(){}function Ss(e,t){return t(e),e}function Oy(e,t){return t(e)}function rt(...e){return e}function Je(e,t){return e(Bn,t)}function _e(e,t){e(ys,t)}function ya(e){e(Pr)}function wt(e){return e(mf)}function xe(e,t){return Je(e,Ry(t,ys))}function dn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function bf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function wf(e,t){return e===t}function ot(e=wf){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=>xf(t,e)}function bn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=Dy(...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 $e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);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 Dy(...e){return t=>e.reduceRight(Oy,t)}function Ly(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 se(e){let t=e;const n=Ue();return(r,o)=>{switch(r){case ys:t=o;break;case Bn:{o(t);break}case mf:return t}return n(r,o)}}function Mt(e,t){return Ss(se(t),n=>xe(e,n))}function Ue(){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(Ue(),t=>xe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:$y(),singleton:n}}const $y=()=>Symbol();function Fy(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function Ct(...e){const t=Ue(),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=wf){return ne(e,ot(t))}function Sa(...e){return function(t,n){switch(t){case Pr:return;case Bn:return My(...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 By={0:"debug",3:"error",1:"log",2:"warn"},zy=()=>typeof globalThis>"u"?window:globalThis,zn=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=zy().VIRTUOSO_LOG_LEVEL)!=null?o:wt(e);r>=s&&console[By[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=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 Hy(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=Uy(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const p=m.lastElementChild.dataset.viewportType==="window";let v;p&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?yf("column-gap",getComputedStyle(d).columnGap,o):yf("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ca(c,n,l)}function Uy(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 f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function yf(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 Sf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,m;if(t){const p=t.getBoundingClientRect(),v=c.top-p.top;m=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ca(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 Ft=Ge(()=>{const e=Ue(),t=Ue(),n=se(0),r=Ue(),o=se(0),s=Ue(),i=Ue(),a=se(0),l=se(0),c=se(0),d=se(0),f=Ue(),m=Ue(),p=se(!1),v=se(!1),g=se(!1);return xe(ne(e,fe(({scrollTop:x})=>x)),t),xe(ne(e,fe(({scrollHeight:x})=>x)),i),xe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),uo={lvl:0};function Cf(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 Qe(e){return e===uo}function fo(e,t){if(!Qe(e))return t===e.k?e.v:t<e.k?fo(e.l,t):fo(e.r,t)}function fn(e,t,n="k"){if(Qe(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 Qe(e)?Ef(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?If(Nt(e,{l:Qt(e.l,t,n)})):If(Nt(e,{r:Qt(e.r,t,n)}))}function Rr(){return uo}function Cs(e,t,n){if(Qe(e))return[];const r=fn(e,t)[0];return Wy(ka(e,r,n))}function Ta(e,t){if(Qe(e))return uo;const{k:n,l:r,r:o}=e;if(t===n){if(Qe(r))return o;if(Qe(o))return r;{const[s,i]=kf(r);return Ts(Nt(e,{k:s,l:Tf(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 Qe(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function ka(e,t,n){if(Qe(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 Nf(Nt(e,{lvl:n-1}));if(!Qe(t)&&!Qe(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(!Qe(r)&&!Qe(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 Ef(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 Tf(e){return Qe(e.r)?e.l:Ts(Nt(e,{r:Tf(e.r)}))}function Ea(e){return Qe(e)||e.lvl>e.r.lvl}function kf(e){return Qe(e.r)?[e.k,e.v]:kf(e.r)}function Ef(e,t,n,r=uo,o=uo){return{k:e,l:r,lvl:n,r:o,v:t}}function If(e){return Ia(Nf(e))}function Nf(e){const{l:t}=e;return!Qe(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function Ia(e){const{lvl:t,r:n}=e;return!Qe(n)&&!Qe(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function Wy(e){return Cf(e,({k:t,v:n})=>({index:t,value:n}))}function Af(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function po(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Na=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function jf(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 Vy(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!Qe(e.groupOffsetTree)}function Aa({index:e},t){return t===e?0:t<e?-1:1}function Ky(){return{groupIndices:[],groupOffsetTree:Rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rr()}}function qy(e,t){let n=Qe(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Qe(e)){e=Qt(e,0,s);continue}const a=Cs(e,i-1,o+1);if(a.some(e0(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Ta(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function Gy(e){return typeof e.groupIndex<"u"}function Yy({offset:e},t){return t===e?0:t<e?-1:1}function ho(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=jf(t,e,Aa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Pf(e,t){if(!Es(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function _f(e,t,n){if(Gy(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Pf(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Xy(e,t,n,r=0){return r>0&&(t=Math.max(t,jf(e,r,Aa).offset)),Cf(Vy(e,t,n,Yy),Qy)}function Jy(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&&Qe(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,p),i)}else[i,a]=qy(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=ja(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>Qt(m,p,ho(p,f,o)),Rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function Zy(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 Rf(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 f=c-s,m=f*i+a+f*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 e0(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 t0={offsetHeight:"height",offsetWidth:"width"},yn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=Ue(),r=Ue(),o=Mt(r,0),s=Ue(),i=Ue(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),f=se((T,S)=>Hn(T,t0[S])),m=se(void 0),p=se(0),v=Ky(),g=Mt(ne(n,$e(l,e,p),wn(Jy,v),ot()),v),x=Mt(ne(l,ot(),wn((T,S)=>({current:S,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);xe(ne(l,ke(T=>T.length>0),$e(g,p),fe(([T,S,k])=>{const A=T.reduce((j,F,D)=>Qt(j,F,ho(F,S.offsetTree,k)||D),Rr());return{...S,groupIndices:T,groupOffsetTree:A}})),g),xe(ne(r,$e(g),ke(([T,{lastIndex:S}])=>T<S),fe(([T,{lastIndex:S,lastSize:k}])=>[{endIndex:S,size:k,startIndex:T}])),n),xe(c,d);const y=Mt(ne(c,fe(T=>T===void 0)),!0);xe(ne(d,ke(T=>T!==void 0&&Qe(wt(g).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Zt(ne(n,$e(g),wn(({sizes:T},[S,k])=>({changed:k!==T,sizes:k}),{changed:!1,sizes:v}),fe(T=>T.changed)));Je(ne(a,wn((T,S)=>({diff:T.prev-S,prev:S}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:S}=wt(g);if(T>0)_e(t,!0),_e(s,T+Rf(T,S));else if(T<0){const k=wt(x);k.length>0&&(T-=Rf(-T,k)),_e(i,T)}}),Je(ne(a,$e(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);xe(ne(s,$e(g),fe(([T,S])=>{const k=S.groupIndices.length>0,A=[],j=S.lastSize;if(k){const F=fo(S.sizeTree,0);let D=0,B=0;for(;D<T;){const M=S.groupIndices[B],W=S.groupIndices.length===B+1?1/0:S.groupIndices[B+1]-M-1;A.push({endIndex:M,size:F,startIndex:M}),A.push({endIndex:M+1+W-1,size:j,startIndex:M+1}),B++,D+=W+1}const G=cr(S.sizeTree);return D!==T&&G.shift(),G.reduce((M,{k:W,v:Y})=>{let z=M.ranges;return M.prevSize!==0&&(z=[...M.ranges,{endIndex:W+T-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:W+T,prevSize:Y,ranges:z}},{prevIndex:T,prevSize:0,ranges:A}).ranges}return cr(S.sizeTree).reduce((F,{k:D,v:B})=>({prevIndex:D+T,prevSize:B,ranges:[...F.ranges,{endIndex:D+T-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=Zt(ne(i,$e(g,p),fe(([T,{offsetTree:S},k])=>{const A=-T;return ho(A,S,k)})));return xe(ne(i,$e(g,p),fe(([T,S,k])=>{if(S.groupIndices.length>0){if(Qe(S.sizeTree))return S;let A=Rr();const j=wt(x);let F=0,D=0,B=0;for(;F<-T;){B=j[D];const G=j[D+1]-B-1;D++,F+=G+1}if(A=cr(S.sizeTree).reduce((G,{k:M,v:W})=>Qt(G,Math.max(0,M+T),W),A),F!==-T){const G=fo(S.sizeTree,B);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:F,v:D})=>Qt(j,Math.max(0,F+T),D),Rr());return{...S,sizeTree:A,...ja(S.offsetTree,0,A,k)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(zn,Na),{singleton:!0});function n0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Mf=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ue(),i=Ue(),a=Zt(ne(s,fe(n0)));return xe(ne(a,fe(l=>l.totalCount)),n),xe(ne(a,fe(l=>l.groupIndices)),e),xe(ne(Ct(o,t,r),ke(([l,c])=>Es(c)),fe(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(yn,Ft)),Un=Ge(([{log:e}])=>{const t=se(!1),n=Zt(ne(t,ke(r=>r),ot()));return Je(t,r=>{r&&wt(e)("props updated",{},qt.DEBUG)}),{didMount:n,propsReady:t}},rt(zn),{singleton:!0}),r0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Of(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!r0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const mo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=Ue(),v=Ue(),g=se(0);let x=null,y=null,w=null;function C(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),_e(l,!1)}return xe(ne(p,$e(n,f,r,g,a,i,m),$e(e,s,o),fe(([[E,T,S,k,A,j,F,D],B,G,M])=>{const W=Of(E),{align:Y,behavior:z,offset:P}=W,I=k-1,K=_f(W,T,I);let te=ho(K,T.offsetTree,B)+j;Y==="end"?(te+=G+fn(T.sizeTree,K)[1]-S+M,K===I&&(te+=F)):Y==="center"?te+=(G+fn(T.sizeTree,K)[1]-S+M)/2:te-=A,P&&(te+=P);const O=q=>{C(),q?(D("retrying to scroll to",{location:E},qt.DEBUG),_e(p,E)):(_e(v,!0),D("list did not change, scroll successful",{},qt.DEBUG))};if(C(),z==="smooth"){let q=!1;w=Je(t,L=>{q=q||L}),x=dn(d,()=>{O(q)})}else x=dn(ne(t,o0(150)),O);return y=setTimeout(()=>{C()},1200),_e(l,!0),D("scrolling from index to",{behavior:z,index:K,top:te},qt.DEBUG),{behavior:z,top:te}})),c),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},rt(yn,Ft,zn),{singleton:!0});function o0(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 go=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return xe(ne(i,$e(l),ke(([d,f])=>!!f),bn(!1)),a),xe(ne(i,$e(l),ke(([d,f])=>!!f),bn(!1)),c),Je(ne(Ct(t,i),$e(a,n,e,c),ke(([[,d],f,{sizeTree:m},p,v])=>d&&(!Qe(m)||wa(p))&&!f&&!v),$e(l)),([,d])=>{dn(o,()=>{_e(c,!0)}),Pa(4,()=>{dn(r,()=>{_e(a,!0)}),_e(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(yn,Ft,mo,Un),{singleton:!0});function Df(e,t){return Math.abs(e-t)<1.01}const xo="up",vo="down",s0="none",i0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},a0=0,bo=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=Ue(),c=Ue(),d=se(4),f=se(a0),m=Mt(ne(Sa(ne(Te(o),ar(1),bn(!0)),ne(Te(o),ar(1),bn(!1),bf(100))),ot()),!1),p=Mt(ne(Sa(ne(n,bn(!0)),ne(n,bn(!1),bf(200))),ot()),!1);xe(ne(Ct(Te(o),Te(f)),fe(([w,C])=>w<=C),ot()),a),xe(ne(a,Nn(50)),c);const v=Zt(ne(Ct(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,F={scrollHeight:C,scrollTop:E,viewportHeight:T};if(j){let B,G;return E>w.state.scrollTop?(B="SCROLLED_DOWN",G=w.state.scrollTop-E):(B="SIZE_DECREASED",G=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:G,state:F}}let D;return F.scrollHeight>w.state.scrollHeight?D="SIZE_INCREASED":T<w.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:F}},i0),ot((w,C)=>w&&w.atBottom===C.atBottom))),g=Mt(ne(r,wn((w,{scrollHeight:C,scrollTop:E,viewportHeight:T})=>{if(Df(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);xe(ne(v,fe(w=>w.atBottom)),i),xe(ne(i,Nn(50)),l);const x=se(vo);xe(ne(r,fe(({scrollTop:w})=>w),ot(),wn((w,C)=>wt(p)?{direction:w.direction,prevScrollTop:C}:{direction:C<w.prevScrollTop?xo:vo,prevScrollTop:C},{direction:vo,prevScrollTop:0}),fe(w=>w.direction)),x),xe(ne(r,Nn(50),bn(s0)),x);const y=se(0);return xe(ne(m,ke(w=>!w),bn(0)),y),xe(ne(o,Nn(100),$e(m),ke(([w,C])=>!!C),wn(([w,C],[E])=>[C,E],[0,0]),fe(([w,C])=>C-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Ft)),Is="top",Ns="bottom",Lf="none";function $f(e,t,n){return typeof e=="number"?n===xo&&t===Is||n===vo&&t===Ns?e:0:n===xo?t===Is?e.main:e.reverse:t===Ns?e.main:e.reverse}function Ff(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ra=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ue(),i=se(0),a=se(0),l=se(0),c=Mt(ne(Ct(Te(r),Te(o),Te(n),Te(s,po),Te(l),Te(i),Te(t),Te(e),Te(a)),fe(([d,f,m,[p,v],g,x,y,w,C])=>{const E=d-w,T=x+y,S=Math.max(m-E,0);let k=Lf;const A=Ff(C,Is),j=Ff(C,Ns);return p-=w,p+=m+y,v+=m+y,v-=w,p>d+T-A&&(k=xo),v<d-S+f+j&&(k=vo),k!==Lf?[Math.max(E-m-$f(g,Is,k)-A,0),E-S-y+f+$f(g,Ns,k)+j]:null}),ke(d=>d!=null),ot(po)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},rt(Ft),{singleton:!0});function l0(e,t,n){if(Es(t)){const r=Pf(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 Ma={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 f=n-i,m=a+f*l+(f-1)*r,p=c,v=m-d;return{bottom:d,firstItemIndex:s,items:zf(e,o,s),offsetBottom:v,offsetTop:c,top:p,topItems:zf(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Bf(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,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return As(c,[],a,o,n,r)}function zf(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=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Ue();xe(s.topItemsIndexes,g);const w=Mt(ne(Ct(p,v,Te(l,po),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),ke(([S,k,,A,,,,,,,j])=>{const F=j&&j.length!==A;return S&&!k&&!F}),fe(([,,[S,k],A,j,F,D,B,G,M,W])=>{const Y=j,{offsetTree:z,sizeTree:P}=Y,I=wt(x);if(A===0)return{...Ma,totalCount:A};if(S===0&&k===0)return I===0?{...Ma,totalCount:A}:Bf(I,F,j,G,M,W||[]);if(Qe(P))return I>0?null:As(l0(_a(F,A),Y,W),[],A,M,Y,G);const K=[];if(B.length>0){const $=B[0],X=B[B.length-1];let R=0;for(const _ of Cs(P,$,X)){const U=_.value,Z=Math.max(_.start,$),re=Math.min(_.end,X);for(let ce=Z;ce<=re;ce++)K.push({data:W==null?void 0:W[ce],index:ce,offset:R,size:U}),R+=U}}if(!D)return As([],K,A,M,Y,G);const te=B.length>0?B[B.length-1]+1:0,O=Xy(z,S,k,te);if(O.length===0)return null;const q=A-1,L=Ss([],$=>{for(const X of O){const R=X.value;let _=R.offset,U=X.start;const Z=R.size;if(R.offset<S){U+=Math.floor((S-R.offset+M)/(Z+M));const ce=U-X.start;_+=ce*Z+ce*M}U<te&&(_+=(te-U)*Z,U=te);const re=Math.min(X.end,q);for(let ce=U;ce<=re&&!(_>=k);ce++)$.push({data:W==null?void 0:W[ce],index:ce,offset:_,size:Z}),_+=Z+M}});return As(L,K,A,M,Y,G)}),ke(S=>S!==null),ot()),Ma);xe(ne(e,ke(wa),fe(S=>S==null?void 0:S.length)),o),xe(ne(w,fe(S=>S.topListHeight)),f),xe(f,a),xe(ne(w,fe(S=>[S.top,S.bottom])),i),xe(ne(w,fe(S=>S.items)),y);const C=Zt(ne(w,ke(({items:S})=>S.length>0),$e(o,e),ke(([{items:S},k])=>S[S.length-1].originalIndex===k-1),fe(([,S,k])=>[S-1,k]),ot(po),fe(([S])=>S))),E=Zt(ne(w,Nn(200),ke(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),fe(({items:S})=>S[0].index),ot())),T=Zt(ne(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}}),ot(Af)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:T,startReached:E,topItemsIndexes:g,...m}},rt(yn,Mf,Ra,go,mo,bo,Un,Na),{singleton:!0}),Hf=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ue(),i=Mt(ne(Ct(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return xe(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Ft,ur),{singleton:!0}),c0=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Mt(ne(Ct(n,e,t),ke(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Nn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Ft,Hf),{singleton:!0}),Uf=Ge(()=>({context:se(null)})),u0=({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,Wf=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ue();return xe(ne(d,$e(t,l,n,s,o,r,a),$e(e),fe(([[f,m,p,v,g,x,y,w],C])=>{const{align:E,behavior:T,calculateViewLocation:S=u0,done:k,...A}=f,j=_f(f,m,v-1),F=ho(j,m.offsetTree,C)+g+x,D=F+fn(m.sizeTree,j)[1],B=w+x,G=w+p-y,M=S({itemBottom:D,itemTop:F,locationParams:{align:E,behavior:T,...A},viewportBottom:G,viewportTop:B});return M?k&&dn(ne(i,ke(W=>!W),ar(wt(i)?1:2)),k):k&&k(),M}),ke(f=>f!==null)),c),{scrollIntoView:d}},rt(yn,Ft,mo,ur,zn),{singleton:!0});function Vf(e){return e?e==="smooth"?"smooth":"auto":!1}const d0=(e,t)=>typeof e=="function"?Vf(e(t)):t&&Vf(e),f0=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const v=se(!1),g=Ue();let x=null;function y(T){_e(i,{align:"end",behavior:T,index:"LAST"})}Je(ne(Ct(ne(Te(t),ar(1)),l),$e(Te(v),s,a,f),fe(([[T,S],k,A,j,F])=>{let D=S&&j,B="auto";return D&&(B=d0(k,A||F),D=D&&!!B),{followOutputBehavior:B,shouldFollow:D,totalCount:T}}),ke(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:S})=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T)}):x=dn(e,()=>{wt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T),x=null})});function w(T){const S=dn(o,k=>{T&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(wt(d)("scrolling to bottom due to increased size",{},qt.DEBUG),y("auto"))});setTimeout(S,100)}Je(ne(Ct(Te(v),t,c),ke(([T,,S])=>T&&S),wn(({value:T},[,S])=>({refreshed:T===S,value:S}),{refreshed:!1,value:0}),ke(({refreshed:T})=>T),$e(v,t)),([,T])=>{wt(a)&&w(T!==!1)}),Je(g,()=>{w(wt(v)!==!1)}),Je(Ct(Te(v),o),([T,S])=>{T&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=se(null),E=Ue();return xe(Sa(ne(Te(r),fe(T=>{var S;return(S=T==null?void 0:T.length)!=null?S:0})),ne(Te(t))),E),Je(ne(Ct(ne(E,ar(1)),l),$e(Te(C),a,f,m),fe(([[T,S],k,A,j,F])=>S&&A&&(k==null?void 0:k({context:F,totalCount:T,scrollingInProgress:j}))),ke(T=>!!T),Nn(0)),T=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("scrolling into view",{}),_e(p,T)}):x=dn(e,()=>{wt(d)("scrolling into view",{}),_e(p,T),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},rt(yn,bo,mo,go,Un,zn,Ft,Uf,Wf)),p0=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(ne(a,$e(s),ke(([,l])=>l!==0),$e(o,r,t,n,e),fe(([[,l],c,d,f,m,p=[]])=>Bf(l,c,d,f,m,p))),i),{}),rt(yn,go,ur,Un),{singleton:!0}),h0=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Je(ne(e,$e(r),ke(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(ne(n,ar(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{_e(t,o)})})}),{initialScrollTop:r}},rt(Un,Ft,ur),{singleton:!0}),Kf=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=Ue(),r=se(!1);return xe(ne(e,$e(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}),ot()),t),Je(ne(Ct(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(bo),{singleton:!0}),Oa=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ue(),r=Ue(),o=Ue(),s=se(!1),i=se(void 0);return xe(ne(Ct(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),xe(ne(t,$e(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Ft)),m0=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ue(),d=se(void 0),f=se(null),m=se(null);return xe(a,f),xe(l,m),Je(ne(c,$e(t,r,i,f,m,n)),([p,v,g,x,y,w,C])=>{const E=Zy(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=C,p({ranges:E,scrollTop:g})}),xe(ne(d,ke(wa),fe(g0)),o),xe(ne(s,$e(d),ke(([,p])=>p!==void 0),ot(),fe(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},rt(yn,Ft,go,Un,Oa));function g0(e){return{align:"start",index:0,offset:e.scrollTop}}const x0=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return xe(ne(t,ke(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(ur));function qf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const v0=qf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),b0=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:v}])=>{const g=Zt(ne(l,$e(i),wn(([,y,w,C],[{bottom:E,items:T,offsetBottom:S,totalCount:k},A])=>{const j=E+S;let F=0;return w===k&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||(F=j-C,F!==0&&(F+=A))),[F,T,k,j]},[0,[],0,0]),ke(([y])=>y!==0),$e(r,a,n,o,p,v),ke(([,y,w,C,,,E])=>!E&&!C&&y!==0&&w===xo),fe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},qt.DEBUG),y))));function x(y){y>0?(_e(t,{behavior:"auto",top:-y}),_e(e,0)):(_e(e,0),_e(t,{behavior:"auto",top:-y}))}return Je(ne(g,$e(e,s)),([y,w,C])=>{C&&v0()?_e(e,w-y):x(-y)}),Je(ne(Ct(Mt(s,!1),e,v),ke(([y,w,C])=>!y&&!C&&w!==0),fe(([y,w])=>w),Nn(1)),x),xe(ne(f,fe(y=>({top:-y}))),t),Je(ne(c,$e(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=fo(E,0);let j=0,F=0;for(;j<y;){j++,k+=A;let D=w.length===F+1?1/0:w[F+1]-w[F]-1;j+D>y&&(k-=A,D=y-j+1),j+=D,k+=S(D),F++}return k}})),y=>{_e(e,y),requestAnimationFrame(()=>{_e(t,{top:y}),requestAnimationFrame(()=>{_e(e,0),_e(v,!1)})})}),{deviation:e}},rt(Ft,bo,ur,yn,zn,Na)),w0=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),rt(Ra,p0,Un,Kf,Hf,h0,c0,Oa,Wf,zn,Uf)),Gf=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:C,...E},{scrollToIndex:T},S,{topItemCount:k},{groupCounts:A},j])=>(xe(E.rangeChanged,j.scrollSeekRangeChanged),xe(ne(j.windowViewportRect,fe(F=>F.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:k,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...E,...j,...g,sizes:l,...x}),rt(yn,go,Ft,m0,f0,ur,mo,b0,x0,Mf,w0));function y0(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"?b.useLayoutEffect:b.useEffect;function Yf(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(x,y){x.propsReady&&_e(x.propsReady,!1);for(const w of r){const C=x[t.required[w]];_e(C,y[w])}for(const w of o)if(w in y){const C=x[t.optional[w]];_e(C,y[w])}x.propsReady&&_e(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=C=>{const E=x[t.methods[w]];_e(E,C)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=Ly(x[t.events[w]]),y),{})}const f=b.forwardRef((x,y)=>{const{children:w,...C}=x,[E]=b.useState(()=>Ss(Fy(e),k=>{l(k,C)})),[T]=b.useState(vf(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)}),b.useImperativeHandle(y,gf(c(E)));const S=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(S,{...y0([...r,...o,...i],C),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{_e(y[x],w)},[y,x])},p=x=>{const y=b.useContext(a)[x],w=b.useCallback(C=>Je(y,C),[y]);return b.useSyncExternalStore(w,()=>wt(y),()=>wt(y))},v=x=>{const y=b.useContext(a)[x],[w,C]=b.useState(vf(wt,y));return js(()=>Je(y,E=>{E!==w&&C(gf(E))}),[y,w]),w},g=b.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const w=b.useContext(a)[x];js(()=>Je(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Xf=b.createContext(void 0),Jf=b.createContext(void 0),Zf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Da(e){return"self"in e}function S0(e){return"body"in e}function Qf(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 p,v,g;const x=m.target;if(S0(x)||Da(x)){const w=Da(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Do.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-v)&&(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 p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Da(p)?(x=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(x=p[s?"scrollWidth":"scrollHeight"],g=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),Df(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(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}),p.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const La="-webkit-sticky",ep="sticky",$a=qf(()=>{if(typeof document>"u")return ep;const e=document.createElement("div");return e.style.position=La,e.style.position===La?La:ep});function Fa(e){return e}const C0=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Fa),o=se("div"),s=se(_r),i=(a,l=null)=>Mt(ne(n,fe(c=>c[a]),ot()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),T0=Ge(([e,t])=>({...e,...t}),rt(Gf,C0)),k0=({height:e})=>u.jsx("div",{style:{height:e}}),E0={overflowAnchor:"none",position:$a(),zIndex:1},tp={overflowAnchor:"none"},I0={...tp,display:"inline-block",height:"100%"},np=b.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=rn("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),c=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),m=Ae("itemSize"),p=Ae("log"),v=rn("gap"),g=Ae("horizontalDirection"),{callbackRef:x}=Hy(n,m,f,e?_r:a,p,v,o,g,Ae("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Ba("deviation",M=>{y!==M&&w(M)});const C=Ae("EmptyPlaceholder"),E=Ae("ScrollSeekPlaceholder")||k0,T=Ae("ListComponent"),S=Ae("ItemComponent"),k=Ae("GroupComponent"),A=Ae("computeItemKey"),j=Ae("isSeeking"),F=Ae("groupIndices").length>0,D=Ae("alignToBottom"),B=Ae("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Ot(C,c)}):u.jsx(T,{...Ot(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(M=>{const W=M.originalIndex,Y=A(W+t.firstItemIndex,M.data,c);return j?b.createElement(E,{...Ot(E,c),height:M.size,index:M.index,key:Y,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?b.createElement(k,{...Ot(k,c),"data-index":W,"data-item-index":M.index,"data-known-size":M.size,key:Y,style:E0},d(M.index,c)):b.createElement(S,{...Ot(S,c),...P0(S,M.data),"data-index":W,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:Y,style:g?I0:tp},F?l(M.index,M.groupIndex,M.data,c):l(M.index,M.data,c))})})}),N0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},A0={outline:"none",overflowX:"auto",position:"relative"},Ps=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),j0={position:$a(),top:0,width:"100%",zIndex:1};function Ot(e,t){if(typeof e!="string")return{context:t}}function P0(e,t){return{item:typeof e=="string"?void 0:t}}const _0=b.memo(function(){const e=Ae("HeaderComponent"),t=rn("headerHeight"),n=Ae("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),R0=b.memo(function(){const e=Ae("FooterComponent"),t=rn("footerHeight"),n=Ae("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null});function rp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:v}=Qf(a,c,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?A0:N0,...o},tabIndex:0,...i,...Ot(l,s),children:r})})}function op({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),m=t("customScrollParent"),p=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Qf(a,c,l,v,m);return Zf(()=>{var w;return x.current=m||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Ot(l,s),children:r})})}const M0=({children:e})=>{const t=b.useContext(Xf),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=b.useMemo(()=>xf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=lr(i,!0,Ae("skipAnimationFrameInResizeObserver"));return b.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})},O0=({children:e})=>{const t=b.useContext(Xf),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ae("customScrollParent"),s=Sf(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("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:Ps(i),children:e})},D0=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...j0,marginTop:`${n}px`},o=Ae("context");return u.jsx(t,{style:r,...Ot(t,o),children:e})},L0=b.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return u.jsxs(r||t?B0:F0,{...e,context:o,children:[n&&u.jsx(D0,{children:u.jsx(np,{showTopList:!0})}),u.jsxs(r||t?O0:M0,{children:[u.jsx(_0,{}),u.jsx(np,{}),u.jsx(R0,{})]})]})}),{Component:$0,useEmitter:Ba,useEmitterValue:Ae,usePublisher:rn}=Yf(T0,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},L0),F0=rp({useEmitter:Ba,useEmitterValue:Ae,usePublisher:rn}),B0=op({useEmitter:Ba,useEmitterValue:Ae,usePublisher:rn}),z0=$0;rt(Gf,Ge(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(Fa),a=se(_r),l=(c,d=null)=>Mt(ne(s,fe(f=>f[c]),ot()),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 sp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},H0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ip,floor:_s,max:wo,min:za,round:ap}=Math;function lp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function U0(e){return{...H0,items:e}}function Rs(e,t){return e&&e.width===t.width&&e.height===t.height}function W0(e,t){return e&&e.column===t.column&&e.row===t.row}const V0=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E},T])=>{const S=se(0),k=se(0),A=se(sp),j=se({height:0,width:0}),F=se({height:0,width:0}),D=Ue(),B=Ue(),G=se(0),M=se(null),W=se({column:0,row:0}),Y=Ue(),z=Ue(),P=se(!1),I=se(0),K=se(!0),te=se(!1),O=se(!1);Je(ne(v,$e(I),ke(([_,U])=>!!U)),()=>{_e(K,!1)}),Je(ne(Ct(v,K,F,j,I,te),ke(([_,U,Z,re,,ce])=>_&&!U&&Z.height!==0&&re.height!==0&&!ce)),([,,,,_])=>{_e(te,!0),Pa(1,()=>{_e(D,_)}),dn(ne(c),()=>{_e(t,[0,0]),_e(K,!0)})}),xe(ne(z,ke(_=>_!=null&&_.scrollTop>0),bn(0)),k),Je(ne(v,$e(z),ke(([,_])=>_!=null)),([,_])=>{_&&(_e(j,_.viewport),_e(F,_.item),_e(W,_.gap),_.scrollTop>0&&(_e(P,!0),dn(ne(c,ar(1)),U=>{_e(P,!1)}),_e(l,{top:_.scrollTop})))}),xe(ne(j,fe(({height:_})=>_)),f),xe(ne(Ct(Te(j,Rs),Te(F,Rs),Te(W,(_,U)=>_&&_.column===U.column&&_.row===U.row),Te(c)),fe(([_,U,Z,re])=>({gap:Z,item:U,scrollTop:re,viewport:_}))),Y),xe(ne(Ct(Te(S),r,Te(W,W0),Te(F,Rs),Te(j,Rs),Te(M),Te(k),Te(P),Te(K),Te(I)),ke(([,,,,,,,_])=>!_),fe(([_,[U,Z],re,ce,Ne,ye,Re,,We,Fe])=>{const{column:Ye,row:Ve}=re,{height:tt,width:gt}=ce,{width:at}=Ne;if(Re===0&&(_===0||at===0))return sp;if(gt===0){const ft=_a(Fe,_),yt=ft+Math.max(Re-1,0);return U0(lp(ft,yt,ye))}const lt=cp(at,gt,Ye);let Me,Ke;We?U===0&&Z===0&&Re>0?(Me=0,Ke=Re-1):(Me=lt*_s((U+Ve)/(tt+Ve)),Ke=lt*ip((Z+Ve)/(tt+Ve))-1,Ke=za(_-1,wo(Ke,lt-1)),Me=za(Ke,wo(0,Me))):(Me=0,Ke=-1);const je=lp(Me,Ke,ye),{bottom:qe,top:Be}=up(Ne,re,ce,je),nt=ip(_/lt),ct=nt*tt+(nt-1)*Ve-qe;return{bottom:qe,itemHeight:tt,items:je,itemWidth:gt,offsetBottom:ct,offsetTop:Be,top:Be}})),A),xe(ne(M,ke(_=>_!==null),fe(_=>_.length)),S),xe(ne(Ct(j,F,A,W),ke(([_,U,{items:Z}])=>Z.length>0&&U.height!==0&&_.height!==0),fe(([_,U,{items:Z},re])=>{const{bottom:ce,top:Ne}=up(_,re,U,Z);return[Ne,ce]}),ot(po)),t);const q=se(!1);xe(ne(c,$e(q),fe(([_,U])=>U||_!==0)),q);const L=Zt(ne(Ct(A,S),ke(([{items:_}])=>_.length>0),$e(q),ke(([[_,U],Z])=>{const re=_.items[_.items.length-1].index===U-1;return(Z||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===U)&&re}),fe(([[,_]])=>_-1),ot())),$=Zt(ne(Te(A),ke(({items:_})=>_.length>0&&_[0].index===0),bn(0),ot())),X=Zt(ne(Te(A),$e(P),ke(([{items:_},U])=>_.length>0&&!U),fe(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),ot(Af),Nn(0)));xe(X,p.scrollSeekRangeChanged),xe(ne(D,$e(j,F,S,W),fe(([_,U,Z,re,ce])=>{const Ne=Of(_),{align:ye,behavior:Re,offset:We}=Ne;let Fe=Ne.index;Fe==="LAST"&&(Fe=re-1),Fe=wo(0,Fe,za(re-1,Fe));let Ye=Ha(U,ce,Z,Fe);return ye==="end"?Ye=ap(Ye-U.height+Z.height):ye==="center"&&(Ye=ap(Ye-U.height/2+Z.height/2)),We&&(Ye+=We),{behavior:Re,top:Ye}})),l);const R=Mt(ne(A,fe(_=>_.offsetBottom+_.bottom)),0);return xe(ne(E,fe(_=>({height:_.visibleHeight,width:_.visibleWidth}))),j),{customScrollParent:x,data:M,deviation:G,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:F,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:D,scrollTop:c,smoothScrollTargetReached:d,totalCount:S,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E,...p,gridState:A,horizontalDirection:O,initialTopMostItemIndex:I,totalListHeight:R,...m,endReached:L,propsReady:g,rangeChanged:X,startReached:$,stateChanged:Y,stateRestoreInProgress:P,...T}},rt(Ra,Ft,bo,Kf,Un,Oa,zn));function cp(e,t,n){return wo(1,_s((e+n)/(_s(t)+n)))}function up(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=cp(e.width,n.width,t.column),s=_s(r/o),i=s*n.height+wo(0,s-1)*t.row;return i>0?i+t.row:i}const K0=Ge(()=>{const e=se(f=>`Item ${f}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Fa),i=se("div"),a=se(_r),l=(f,m=null)=>Mt(ne(t,fe(p=>p[f]),ot()),m),c=se(!1),d=se(!1);return xe(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")}}),q0=Ge(([e,t])=>({...e,...t}),rt(V0,K0)),G0=b.memo(function(){const e=it("gridState"),t=it("listClassName"),n=it("itemClassName"),r=it("itemContent"),o=it("computeItemKey"),s=it("isSeeking"),i=on("scrollHeight"),a=it("ItemComponent"),l=it("ListComponent"),c=it("ScrollSeekPlaceholder"),d=it("context"),f=on("itemDimensions"),m=on("gap"),p=it("log"),v=it("stateRestoreInProgress"),g=on("reportReadyState"),x=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();f({height:E,width:T})}m({column:fp("column-gap",getComputedStyle(y).columnGap,p),row:fp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Zf(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Ot(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,{...Ot(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Ot(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),Y0=b.memo(function(){const e=it("HeaderComponent"),t=on("headerHeight"),n=it("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),X0=b.memo(function(){const e=it("FooterComponent"),t=on("footerHeight"),n=it("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),J0=({children:e})=>{const t=b.useContext(Jf),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:Ps(!1),children:e})},Z0=({children:e})=>{const t=b.useContext(Jf),n=on("windowViewportRect"),r=on("itemDimensions"),o=it("customScrollParent"),s=Sf(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:Ps(!1),children:e})},Q0=b.memo(function({...e}){const t=it("useWindowScroll"),n=it("customScrollParent"),r=n||t?tS:eS,o=n||t?Z0:J0,s=it("context");return u.jsx(r,{...e,...Ot(r,s),children:u.jsxs(o,{children:[u.jsx(Y0,{}),u.jsx(G0,{}),u.jsx(X0,{})]})})}),{useEmitter:dp,useEmitterValue:it,usePublisher:on}=Yf(q0,{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),eS=rp({useEmitter:dp,useEmitterValue:it,usePublisher:on}),tS=op({useEmitter:dp,useEmitterValue:it,usePublisher:on});function fp(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 nS={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},Ua=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Wa=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:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolConfig:y}){const w=Ua(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming||o===t.id&&t.role==="assistant",k=p??nS,A=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:j,attemptIndex:F,attempts:D}=b.useMemo(()=>dc(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(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:f,getInterruptOptions:x,showToolMessages:m,attemptCount:j,attemptIndex:F,attemptMetas:D,onSelectCheckpoint:v,customStyles:B,toolConfig:y})})});Wa.displayName="MessageRow";const Va=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:f,style:m,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:w=!0,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,createSyntheticThinkingMessage:k=!0,forceSyntheticThinking:A=!1,getMessageCustomStyles:j,getInterruptOptions:F},D)=>{const B=b.useRef(null),G=b.useRef(null),M=b.useRef(!1),W=b.useRef(!1),Y=e,z=b.useMemo(()=>{const R=n&&Y.some(U=>U.id===n);return k&&(t||A)&&!R&&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]),P=b.useMemo(()=>w?z:z.filter(R=>(R==null?void 0:R.role)!=="tool"),[z,w]),I=b.useCallback(R=>{x&&x(!R),y&&y(R)},[x,y]),K=b.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),te=b.useMemo(()=>!v||g?!1:"auto",[v,g]),O=b.useMemo(()=>{if(typeof p!="string")return null;const R=p.trim();return!R||P&&P.length>0?null:{id:"default-message",role:"default_message",content:R,createdAt:new Date().toISOString()}},[p,P]),q=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),L=()=>{if(O){const R=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:R,getInterruptOptions:F})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},$=P.length,X=$>0;return b.useEffect(()=>{var R,_;if($===0){W.current=!1;return}if(!W.current)if(W.current=!0,B.current&&P.length>0){const U=P.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},[$,P.length]),b.useImperativeHandle(D,()=>({scrollToLatest:()=>{var R,_;if(B.current&&P.length>0){const U=P.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},scrollToTop:()=>{var R,_;B.current&&P.length>0?(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:0,align:"start",behavior:"auto"}):G.current&&(G.current.scrollTop=0)}}),[P]),u.jsx("div",{className:q,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:X?u.jsx(z0,{ref:R=>{B.current=R},scrollerRef:R=>{G.current=R instanceof HTMLDivElement?R:null},data:P,followOutput:te,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{K&&K()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,_)=>Ua(_,R),itemContent:(R,_)=>u.jsx(Wa,{message:_,index:R,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:F})}):L()})})});Va.displayName="MessageList";function pp({message:e,viewMode:t,isStreaming:n=!1,toolConfig:r,expandable:o=!1}){var F;const s=Yo(e),i=e.artifact??null,a=hf(e),c=(a?ju(a):null)??a,d=e.content.find(D=>D.type!=="tool_call"),f=D=>{if(D==null)return null;const B=typeof D=="string"?er(D)??D:D;if(B&&typeof B=="object")return u.jsx(vs,{data:B});const G=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:G})},m=D=>{if(D==null)return null;const{content:B,isMarkdown:G}=Su(D);return G?u.jsx(ir,{content:B,className:"text-current"}):f(D)},p=D=>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(vs,{data:D})]}),v=()=>{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 W=nr(M);return m(W)}const D=Sr(d),B=nr(D);return m(B)},g=()=>(c==null?void 0:c.kind)==="dict"?p(c.data):v(),x=()=>{if(!y)return;if(s.name){const B=y[s.name];if(B)return B}const D=(c==null?void 0:c.kind)??(a==null?void 0:a.kind);if(D){const B=y[D];if(B)return B}return y.default},{toolRenderers:y,toolArtifactRenderers:w}=r??{},C=x(),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 D=i==null?void 0:i.type;if(typeof D=="string"){const B=w[D];if(B)return B}return w.default})())==null?void 0:F({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(nf,{artifact:i,idx:0})),u.jsx(rf,{message:e,isStreaming:n}),T?j:null]})}function Ms(e){const t=e+"CollectionProvider",[n,r]=nn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),C=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Jt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,C=s(a,y),E=Le(x,C.collectionRef);return u.jsx(l,{ref:E,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Jt.createSlot(d),p=b.forwardRef((g,x)=>{const{scope:y,children:w,...C}=g,E=b.useRef(null),T=Le(x,E),S=s(d,y);return b.useEffect(()=>(S.itemMap.set(E,{ref:E,...C}),()=>void S.itemMap.delete(E))),u.jsx(m,{[f]:"",ref:T,children:w})});p.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((S,k)=>C.indexOf(S.ref.current)-C.indexOf(k.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},v,r]}var rS=h.createContext(void 0);function Os(e){const t=h.useContext(rS);return e||t||"ltr"}const oS=["top","right","bottom","left"],Wn=Math.min,en=Math.max,Ds=Math.round,Ls=Math.floor,Sn=e=>({x:e,y:e}),sS={left:"right",right:"left",bottom:"top",top:"bottom"},iS={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 Mr(e){return e.split("-")[1]}function qa(e){return e==="x"?"y":"x"}function Ga(e){return e==="y"?"height":"width"}const aS=new Set(["top","bottom"]);function Cn(e){return aS.has(jn(e))?"y":"x"}function Ya(e){return qa(Cn(e))}function lS(e,t,n){n===void 0&&(n=!1);const r=Mr(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 cS(e){const t=$s(e);return[Xa(e),t,Xa(t)]}function Xa(e){return e.replace(/start|end/g,t=>iS[t])}const hp=["left","right"],mp=["right","left"],uS=["top","bottom"],dS=["bottom","top"];function fS(e,t,n){switch(e){case"top":case"bottom":return n?t?mp:hp:t?hp:mp;case"left":case"right":return t?uS:dS;default:return[]}}function pS(e,t,n,r){const o=Mr(e);let s=fS(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=>sS[t])}function hS(e){return{top:0,right:0,bottom:0,left:0,...e}}function gp(e){return typeof e!="number"?hS(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 xp(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,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Mr(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const mS=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=xp(c,r,l),m=r,p={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:C,data:E,reset:T}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=C??f,p={...p,[x]:{...p[x],...E}},T&&v<=50&&(v++,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:f}=xp(c,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function yo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=An(t,e),v=gp(p),x=a[m?f==="floating"?"reference":"floating":f],y=Fs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,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+v.top)/E.y,bottom:(T.bottom-y.bottom+v.bottom)/E.y,left:(y.left-T.left+v.left)/E.x,right:(T.right-y.right+v.right)/E.x}}const gS=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const f=gp(d),m={x:n,y:r},p=Ya(o),v=Ga(p),g=await i.getDimensions(c),x=p==="y",y=x?"top":"left",w=x?"bottom":"right",C=x?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-m[p]-s.floating[v],T=m[p]-s.reference[p],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[v]);const A=E/2-T/2,j=k/2-g[v]/2-1,F=Wn(f[y],j),D=Wn(f[w],j),B=F,G=k-g[v]-D,M=k/2-g[v]/2+A,W=Ka(B,M,G),Y=!l.arrow&&Mr(o)!=null&&M!==W&&s.reference[v]/2-(M<B?F:D)-g[v]/2<0,z=Y?M<B?M-B:M-G:0;return{[p]:m[p]+z,data:{[p]:W,centerOffset:M-W-z,...Y&&{alignmentOffset:z}},reset:Y}}}),xS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=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)]:cS(a)),S=v!=="none";!m&&S&&T.push(...pS(a,g,v,E));const k=[a,...T],A=await yo(t,x),j=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const M=lS(o,i,E);j.push(A[M[0]],A[M[1]])}if(F=[...F,{placement:o,overflows:j}],!j.every(M=>M<=0)){var D,B;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,W=k[M];if(W&&(!(f==="alignment"?w!==Cn(W):!1)||F.every(P=>Cn(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:M,overflows:F},reset:{placement:W}};let Y=(B=F.filter(z=>z.overflows[0]<=0).sort((z,P)=>z.overflows[1]-P.overflows[1])[0])==null?void 0:B.placement;if(!Y)switch(p){case"bestFit":{var G;const z=(G=F.filter(P=>{if(S){const I=Cn(P.placement);return I===w||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,K)=>I+K,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:G[0];z&&(Y=z);break}case"initialPlacement":Y=a;break}if(o!==Y)return{reset:{placement:Y}}}return{}}}};function vp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bp(e){return oS.some(t=>e[t]>=0)}const vS=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 yo(t,{...o,elementContext:"reference"}),i=vp(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:bp(i)}}}case"escaped":{const s=await yo(t,{...o,altBoundary:!0}),i=vp(s,n.floating);return{data:{escapedOffsets:i,escaped:bp(i)}}}default:return{}}}}},wp=new Set(["left","top"]);async function bS(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=Mr(n),l=Cn(n)==="y",c=wp.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:m*c}:{x:m*c,y:p*d}}const wS=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 bS(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}}}}},yS=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:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await yo(t,l),f=Cn(jn(o)),m=qa(f);let p=c[m],v=c[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=p+d[x],C=p-d[y];p=Ka(w,p,C)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=v+d[x],C=v-d[y];v=Ka(w,v,C)}const g=a.fn({...t,[m]:p,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},SS=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},f=Cn(o),m=qa(f);let p=d[m],v=d[f];const g=An(a,t),x=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]+x.mainAxis,T=s.reference[m]+s.reference[C]-x.mainAxis;p<E?p=E:p>T&&(p=T)}if(c){var y,w;const C=m==="y"?"width":"height",E=wp.has(jn(o)),T=s.reference[f]-s.floating[C]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:x.crossAxis),S=s.reference[f]+s.reference[C]+(E?0:((w=i.offset)==null?void 0:w[f])||0)-(E?x.crossAxis:0);v<T?v=T:v>S&&(v=S)}return{[m]:p,[f]:v}}}},CS=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 yo(t,c),f=jn(o),m=Mr(o),p=Cn(o)==="y",{width:v,height:g}=s.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,C=v-d.left-d.right,E=Wn(g-d[x],w),T=Wn(v-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),D=en(d.right,0),B=en(d.top,0),G=en(d.bottom,0);p?A=v-2*(F!==0||D!==0?F+D:en(d.left,d.right)):k=g-2*(B!==0||G!==0?B+G:en(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:k});const j=await i.getDimensions(a.floating);return v!==j.width||g!==j.height?{reset:{rects:!0}}:{}}}};function Bs(){return typeof window<"u"}function Or(e){return yp(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=(yp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function yp(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 Sp(e){return!Bs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof tn(e).ShadowRoot}const TS=new Set(["inline","contents"]);function So(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=hn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!TS.has(o)}const kS=new Set(["table","td","th"]);function ES(e){return kS.has(Or(e))}const IS=[":popover-open",":modal"];function zs(e){return IS.some(t=>{try{return e.matches(t)}catch{return!1}})}const NS=["transform","translate","scale","rotate","perspective"],AS=["transform","translate","scale","rotate","perspective","filter"],jS=["paint","layout","strict","content"];function Ja(e){const t=Za(),n=pn(e)?hn(e):e;return NS.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)||AS.some(r=>(n.willChange||"").includes(r))||jS.some(r=>(n.contain||"").includes(r))}function PS(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 _S=new Set(["html","body","#document"]);function Dr(e){return _S.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||Sp(e)&&e.host||Tn(e);return Sp(t)?t.host:t}function Cp(e){const t=Vn(e);return Dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:kn(t)&&So(t)?t:Cp(t)}function Co(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Cp(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||[],So(o)?o:[],a&&n?Co(a):[])}return t.concat(o,Co(o,[],n))}function Qa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Tp(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}=Tp(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 RS=Sn(0);function kp(e){const t=tn(e);return!Za()||!t.visualViewport?RS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function MS(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=MS(s,n,r)?kp(s):Sn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=tn(s),p=r&&pn(r)?tn(r):r;let v=m,g=Qa(v);for(;g&&r&&p!==v;){const x=Lr(g),y=g.getBoundingClientRect(),w=hn(g),C=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,E=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,f*=x.y,l+=C,c+=E,v=tn(g),g=Qa(v)}}return Fs({width:d,height:f,x:l,y:c})}function Us(e,t){const n=Hs(e).scrollLeft;return t?t.left+n:dr(Tn(e)).left+n}function Ep(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 OS(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),f=kn(r);if((f||!f&&!s)&&((Or(r)!=="body"||So(i))&&(l=Hs(r)),kn(r))){const p=dr(r);c=Lr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?Ep(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 DS(e){return Array.from(e.getClientRects())}function LS(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 Ip=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=Za();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Us(r);if(c<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Ip&&(s-=v)}else c<=Ip&&(s+=c);return{width:s,height:i,x:a,y:l}}const FS=new Set(["absolute","fixed"]);function BS(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 Np(e,t,n){let r;if(t==="viewport")r=$S(e,n);else if(t==="document")r=LS(Tn(e));else if(pn(t))r=BS(t,n);else{const o=kp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Fs(r)}function Ap(e,t){const n=Vn(e);return n===t||!pn(n)||Dr(n)?!1:hn(n).position==="fixed"||Ap(n,t)}function zS(e,t){const n=t.get(e);if(n)return n;let r=Co(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&&FS.has(o.position)||So(i)&&!l&&Ap(e,i))?r=r.filter(d=>d!==i):o=a,i=Vn(i)}return t.set(e,r),r}function HS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zs(t)?[]:zS(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Np(t,d,o);return c.top=en(f.top,c.top),c.right=Wn(f.right,c.right),c.bottom=Wn(f.bottom,c.bottom),c.left=en(f.left,c.left),c},Np(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function US(e){const{width:t,height:n}=Tp(e);return{width:t,height:n}}function WS(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"||So(o))&&(a=Hs(t)),r){const p=dr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?Ep(o,a):Sn(0),f=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function tl(e){return hn(e).position==="static"}function jp(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 Pp(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=jp(e,t);for(;r&&ES(r)&&tl(r);)r=jp(r,t);return r&&Dr(r)&&tl(r)&&!Ja(r)?n:r||PS(e)||n}const VS=async function(e){const t=this.getOffsetParent||Pp,n=this.getDimensions,r=await n(e.floating);return{reference:WS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function KS(e){return hn(e).direction==="rtl"}const qS={convertOffsetParentRelativeRectToViewportRelativeRect:OS,getDocumentElement:Tn,getClippingRect:HS,getOffsetParent:Pp,getElementRects:VS,getClientRects:DS,getDimensions:US,getScale:Lr,isElement:pn,isRTL:KS};function _p(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function GS(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:f,width:m,height:p}=c;if(a||t(),!m||!p)return;const v=Ls(f),g=Ls(o.clientWidth-(d+m)),x=Ls(o.clientHeight-(f+p)),y=Ls(d),C={rootMargin:-v+"px "+-g+"px "+-x+"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&&!_p(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 YS(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?Co(c):[],...Co(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?GS(c,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let v,g=l?dr(e):null;l&&x();function x(){const y=dr(e);g&&!_p(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const XS=wS,JS=yS,ZS=xS,QS=CS,eC=vS,Rp=gS,tC=SS,nC=(e,t,n)=>{const r=new Map,o={platform:qS,...n},s={...o.platform,_c:r};return mS(e,t,{...o,platform:s})};var rC=typeof document<"u",oC=function(){},Ws=rC?b.useLayoutEffect:oC;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 Mp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Op(e,t){const n=Mp(e);return Math.round(t*n)/n}function nl(e){const t=h.useRef(e);return Ws(()=>{t.current=e}),t}function sC(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);Vs(m,r)||p(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback(P=>{P!==S.current&&(S.current=P,g(P))},[]),C=h.useCallback(P=>{P!==k.current&&(k.current=P,y(P))},[]),E=s||v,T=i||x,S=h.useRef(null),k=h.useRef(null),A=h.useRef(d),j=l!=null,F=nl(l),D=nl(o),B=nl(c),G=h.useCallback(()=>{if(!S.current||!k.current)return;const P={placement:t,strategy:n,middleware:m};D.current&&(P.platform=D.current),nC(S.current,k.current,P).then(I=>{const K={...I,isPositioned:B.current!==!1};M.current&&!Vs(A.current,K)&&(A.current=K,qr.flushSync(()=>{f(K)}))})},[m,t,n,D,B]);Ws(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(P=>({...P,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(F.current)return F.current(E,T,G);G()}},[E,T,G,F,j]);const W=h.useMemo(()=>({reference:S,floating:k,setReference:w,setFloating:C}),[w,C]),Y=h.useMemo(()=>({reference:E,floating:T}),[E,T]),z=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!Y.floating)return P;const I=Op(Y.floating,d.x),K=Op(Y.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+K+"px)",...Mp(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:K}},[n,a,Y.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:G,refs:W,elements:Y,floatingStyles:z}),[d,G,W,Y,z])}const iC=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?Rp({element:r.current,padding:o}).fn(n):{}:r?Rp({element:r,padding:o}).fn(n):{}}}},aC=(e,t)=>({...XS(e),options:[e,t]}),lC=(e,t)=>({...JS(e),options:[e,t]}),cC=(e,t)=>({...tC(e),options:[e,t]}),uC=(e,t)=>({...ZS(e),options:[e,t]}),dC=(e,t)=>({...QS(e),options:[e,t]}),fC=(e,t)=>({...eC(e),options:[e,t]}),pC=(e,t)=>({...iC(e),options:[e,t]});var hC="Arrow",Dp=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(he.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"})})});Dp.displayName=hC;var mC=Dp;function Lp(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",[$p,$r]=nn(rl),[gC,Fp]=$p(rl),Bp=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(gC,{scope:t,anchor:r,onAnchorChange:o,children:n})};Bp.displayName=rl;var zp="PopperAnchor",Hp=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Fp(zp,n),i=h.useRef(null),a=Le(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(he.div,{...o,ref:a})});Hp.displayName=zp;var ol="PopperContent",[xC,vC]=$p(ol),Up=h.forwardRef((e,t)=>{var R,_,U,Z,re,ce;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=Fp(ol,n),[y,w]=h.useState(null),C=Le(t,Ne=>w(Ne)),[E,T]=h.useState(null),S=Lp(E),k=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,j=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(c)?c:[c],B=D.length>0,G={padding:F,boundary:D.filter(wC),altBoundary:B},{refs:M,floatingStyles:W,placement:Y,isPositioned:z,middlewareData:P}=sC({strategy:"fixed",placement:j,whileElementsMounted:(...Ne)=>YS(...Ne,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[aC({mainAxis:o+A,alignmentAxis:i}),l&&lC({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?cC():void 0,...G}),l&&uC({...G}),dC({...G,apply:({elements:Ne,rects:ye,availableWidth:Re,availableHeight:We})=>{const{width:Fe,height:Ye}=ye.reference,Ve=Ne.floating.style;Ve.setProperty("--radix-popper-available-width",`${Re}px`),Ve.setProperty("--radix-popper-available-height",`${We}px`),Ve.setProperty("--radix-popper-anchor-width",`${Fe}px`),Ve.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),E&&pC({element:E,padding:a}),yC({arrowWidth:k,arrowHeight:A}),m&&fC({strategy:"referenceHidden",...G})]}),[I,K]=Kp(Y),te=bt(v);It(()=>{z&&(te==null||te())},[z,te]);const O=(R=P.arrow)==null?void 0:R.x,q=(_=P.arrow)==null?void 0:_.y,L=((U=P.arrow)==null?void 0:U.centerOffset)!==0,[$,X]=h.useState();return It(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:z?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Z=P.transformOrigin)==null?void 0:Z.x,(re=P.transformOrigin)==null?void 0:re.y].join(" "),...((ce=P.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(xC,{scope:n,placedSide:I,onArrowChange:T,arrowX:O,arrowY:q,shouldHideArrow:L,children:u.jsx(he.div,{"data-side":I,"data-align":K,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Up.displayName=ol;var Wp="PopperArrow",bC={top:"bottom",right:"left",bottom:"top",left:"right"},Vp=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=vC(Wp,r),i=bC[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(mC,{...o,ref:n,style:{...o.style,display:"block"}})})});Vp.displayName=Wp;function wC(e){return e!==null}var yC=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Kp(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?f:`${m}px`,g=`${-l}px`):c==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?f:`${p}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:v,y:g}}}});function Kp(e){const[t,n="center"]=e.split("-");return[t,n]}var sl=Bp,il=Hp,al=Up,ll=Vp,cl="rovingFocusGroup.onEntryFocus",SC={bubbles:!1,cancelable:!0},To="RovingFocusGroup",[ul,qp,CC]=Ms(To),[TC,Gp]=nn(To,[CC]),[kC,EC]=TC(To),Yp=h.forwardRef((e,t)=>u.jsx(ul.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ul.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(IC,{...e,ref:t})})}));Yp.displayName=To;var IC=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,...f}=e,m=h.useRef(null),p=Le(t,m),v=Os(s),[g,x]=In({prop:i,defaultProp:a??null,onChange:l,caller:To}),[y,w]=h.useState(!1),C=bt(c),E=qp(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(kC,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>k(A=>A-1),[]),children:u.jsx(he.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ue(e.onMouseDown,()=>{T.current=!0}),onFocus:ue(e.onFocus,A=>{const j=!T.current;if(A.target===A.currentTarget&&j&&!y){const F=new CustomEvent(cl,SC);if(A.currentTarget.dispatchEvent(F),!F.defaultPrevented){const D=E().filter(Y=>Y.focusable),B=D.find(Y=>Y.active),G=D.find(Y=>Y.id===g),W=[B,G,...D].filter(Boolean).map(Y=>Y.ref.current);Zp(W,d)}}T.current=!1}),onBlur:ue(e.onBlur,()=>w(!1))})})}),Xp="RovingFocusGroupItem",Jp=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=EC(Xp,n),f=d.currentTabStopId===c,m=qp(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(ul.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(he.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ue(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ue(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ue(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=jC(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.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(x.currentTarget);C=d.loop?PC(C,E+1):C.slice(E+1)}setTimeout(()=>Zp(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Jp.displayName=Xp;var NC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function AC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function jC(e,t,n){const r=AC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return NC[r]}function Zp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function PC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _C=Yp,RC=Jp,dl=["Enter"," "],MC=["ArrowDown","PageUp","Home"],Qp=["ArrowUp","PageDown","End"],OC=[...MC,...Qp],DC={ltr:[...dl,"ArrowRight"],rtl:[...dl,"ArrowLeft"]},LC={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ko="Menu",[Eo,$C,FC]=Ms(ko),[fr,eh]=nn(ko,[FC,$r,Gp]),Ks=$r(),th=Gp(),[BC,pr]=fr(ko),[zC,Io]=fr(ko),nh=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),f=bt(s),m=Os(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(sl,{...a,children:u.jsx(BC,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(zC,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};nh.displayName=ko;var HC="MenuAnchor",fl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(il,{...o,...r,ref:t})});fl.displayName=HC;var pl="MenuPortal",[UC,rh]=fr(pl,{forceMount:void 0}),oh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=pr(pl,t);return u.jsx(UC,{scope:t,forceMount:n,children:u.jsx($t,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};oh.displayName=pl;var sn="MenuContent",[WC,hl]=fr(sn),sh=h.forwardRef((e,t)=>{const n=rh(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Io(sn,e.__scopeMenu);return u.jsx(Eo.Provider,{scope:e.__scopeMenu,children:u.jsx($t,{present:r||s.open,children:u.jsx(Eo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(VC,{...o,ref:t}):u.jsx(KC,{...o,ref:t})})})})}),VC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu),r=h.useRef(null),o=Le(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:ue(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),KC=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)})}),qC=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:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:v,...g}=e,x=pr(sn,n),y=Io(sn,n),w=Ks(n),C=th(n),E=$C(n),[T,S]=h.useState(null),k=h.useRef(null),A=Le(t,k,x.onContentChange),j=h.useRef(0),F=h.useRef(""),D=h.useRef(0),B=h.useRef(null),G=h.useRef("right"),M=h.useRef(0),W=v?rs:h.Fragment,Y=v?{as:qC,allowPinchZoom:!0}:void 0,z=I=>{var R,_;const K=F.current+I,te=E().filter(U=>!U.disabled),O=document.activeElement,q=(R=te.find(U=>U.ref.current===O))==null?void 0:R.textValue,L=te.map(U=>U.textValue),$=sT(L,K,q),X=(_=te.find(U=>U.textValue===$))==null?void 0:_.ref.current;(function U(Z){F.current=Z,window.clearTimeout(j.current),Z!==""&&(j.current=window.setTimeout(()=>U(""),1e3))})(K),X&&setTimeout(()=>X.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Xi();const P=h.useCallback(I=>{var te,O;return G.current===((te=B.current)==null?void 0:te.side)&&aT(I,(O=B.current)==null?void 0:O.area)},[]);return u.jsx(WC,{scope:n,searchRef:F,onItemEnter:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:h.useCallback(I=>{var K;P(I)||((K=k.current)==null||K.focus(),S(null))},[P]),onTriggerLeave:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:h.useCallback(I=>{B.current=I},[]),children:u.jsx(W,{...Y,children:u.jsx(Xo,{asChild:!0,trapped:o,onMountAutoFocus:ue(s,I=>{var K;I.preventDefault(),(K=k.current)==null||K.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(_C,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:S,onEntryFocus:ue(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(al,{role:"menu","aria-orientation":"vertical","data-state":Sh(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ue(g.onKeyDown,I=>{const te=I.target.closest("[data-radix-menu-content]")===I.currentTarget,O=I.ctrlKey||I.altKey||I.metaKey,q=I.key.length===1;te&&(I.key==="Tab"&&I.preventDefault(),!O&&q&&z(I.key));const L=k.current;if(I.target!==L||!OC.includes(I.key))return;I.preventDefault();const X=E().filter(R=>!R.disabled).map(R=>R.ref.current);Qp.includes(I.key)&&X.reverse(),rT(X)}),onBlur:ue(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(j.current),F.current="")}),onPointerMove:ue(e.onPointerMove,Ao(I=>{const K=I.target,te=M.current!==I.clientX;if(I.currentTarget.contains(K)&&te){const O=I.clientX>M.current?"right":"left";G.current=O,M.current=I.clientX}}))})})})})})})});sh.displayName=sn;var GC="MenuGroup",gl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"group",...r,ref:t})});gl.displayName=GC;var YC="MenuLabel",ih=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});ih.displayName=YC;var qs="MenuItem",ah="menu.itemSelect",Gs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Io(qs,e.__scopeMenu),a=hl(qs,e.__scopeMenu),l=Le(t,s),c=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(ah,{bubbles:!0,cancelable:!0});f.addEventListener(ah,p=>r==null?void 0:r(p),{once:!0}),Vi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(lh,{...o,ref:l,disabled:n,onClick:ue(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),c.current=!0},onPointerUp:ue(e.onPointerUp,f=>{var m;c.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ue(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||dl.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Gs.displayName=qs;var lh=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=hl(qs,n),a=th(n),l=h.useRef(null),c=Le(t,l),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),u.jsx(Eo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(RC,{asChild:!0,...a,focusable:!r,children:u.jsx(he.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ue(e.onPointerMove,Ao(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ue(e.onPointerLeave,Ao(v=>i.onItemLeave(v))),onFocus:ue(e.onFocus,()=>f(!0)),onBlur:ue(e.onBlur,()=>f(!1))})})})}),XC="MenuCheckboxItem",ch=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(hh,{scope:e.__scopeMenu,checked:n,children:u.jsx(Gs,{role:"menuitemcheckbox","aria-checked":Ys(n)?"mixed":n,...o,ref:t,"data-state":vl(n),onSelect:ue(o.onSelect,()=>r==null?void 0:r(Ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ch.displayName=XC;var uh="MenuRadioGroup",[JC,ZC]=fr(uh,{value:void 0,onValueChange:()=>{}}),dh=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=bt(r);return u.jsx(JC,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(gl,{...o,ref:t})})});dh.displayName=uh;var fh="MenuRadioItem",ph=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=ZC(fh,e.__scopeMenu),s=n===o.value;return u.jsx(hh,{scope:e.__scopeMenu,checked:s,children:u.jsx(Gs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":vl(s),onSelect:ue(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});ph.displayName=fh;var xl="MenuItemIndicator",[hh,QC]=fr(xl,{checked:!1}),mh=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=QC(xl,n);return u.jsx($t,{present:r||Ys(s.checked)||s.checked===!0,children:u.jsx(he.span,{...o,ref:t,"data-state":vl(s.checked)})})});mh.displayName=xl;var eT="MenuSeparator",gh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});gh.displayName=eT;var tT="MenuArrow",xh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(ll,{...o,...r,ref:t})});xh.displayName=tT;var nT="MenuSub",[WN,vh]=fr(nT),No="MenuSubTrigger",bh=h.forwardRef((e,t)=>{const n=pr(No,e.__scopeMenu),r=Io(No,e.__scopeMenu),o=vh(No,e.__scopeMenu),s=hl(No,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 f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(fl,{asChild:!0,...c,children:u.jsx(lh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Sh(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ue(e.onPointerMove,Ao(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ue(e.onPointerLeave,Ao(f=>{var p,v;d();const m=(p=n.content)==null?void 0:p.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.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(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ue(e.onKeyDown,f=>{var p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||DC[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});bh.displayName=No;var wh="MenuSubContent",yh=h.forwardRef((e,t)=>{const n=rh(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Io(sn,e.__scopeMenu),a=vh(wh,e.__scopeMenu),l=h.useRef(null),c=Le(t,l);return u.jsx(Eo.Provider,{scope:e.__scopeMenu,children:u.jsx($t,{present:r||s.open,children:u.jsx(Eo.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 f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ue(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ue(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ue(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),m=LC[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});yh.displayName=wh;function Sh(e){return e?"open":"closed"}function Ys(e){return e==="indeterminate"}function vl(e){return Ys(e)?"indeterminate":e?"checked":"unchecked"}function rT(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function oT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function sT(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=oT(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 iT(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function aT(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return iT(n,t)}function Ao(e){return t=>t.pointerType==="mouse"?e(t):void 0}var lT=nh,cT=fl,uT=oh,dT=sh,fT=gl,pT=ih,hT=Gs,mT=ch,gT=dh,xT=ph,vT=mh,bT=gh,wT=xh,yT=bh,ST=yh,Xs="DropdownMenu",[CT,VN]=nn(Xs,[eh]),Bt=eh(),[TT,Ch]=CT(Xs),Th=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Bt(t),c=h.useRef(null),[d,f]=In({prop:o,defaultProp:s??!1,onChange:i,caller:Xs});return u.jsx(TT,{scope:t,triggerId:jt(),triggerRef:c,contentId:jt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(lT,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Th.displayName=Xs;var kh="DropdownMenuTrigger",Eh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Ch(kh,n),i=Bt(n);return u.jsx(cT,{asChild:!0,...i,children:u.jsx(he.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:ue(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ue(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Eh.displayName=kh;var kT="DropdownMenuPortal",Ih=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Bt(t);return u.jsx(uT,{...r,...n})};Ih.displayName=kT;var Nh="DropdownMenuContent",Ah=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ch(Nh,n),s=Bt(n),i=h.useRef(!1);return u.jsx(dT,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ue(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ue(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)"}})});Ah.displayName=Nh;var ET="DropdownMenuGroup",IT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(fT,{...o,...r,ref:t})});IT.displayName=ET;var NT="DropdownMenuLabel",jh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(pT,{...o,...r,ref:t})});jh.displayName=NT;var AT="DropdownMenuItem",Ph=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(hT,{...o,...r,ref:t})});Ph.displayName=AT;var jT="DropdownMenuCheckboxItem",_h=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(mT,{...o,...r,ref:t})});_h.displayName=jT;var PT="DropdownMenuRadioGroup",_T=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(gT,{...o,...r,ref:t})});_T.displayName=PT;var RT="DropdownMenuRadioItem",Rh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(xT,{...o,...r,ref:t})});Rh.displayName=RT;var MT="DropdownMenuItemIndicator",Mh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(vT,{...o,...r,ref:t})});Mh.displayName=MT;var OT="DropdownMenuSeparator",Oh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(bT,{...o,...r,ref:t})});Oh.displayName=OT;var DT="DropdownMenuArrow",LT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(wT,{...o,...r,ref:t})});LT.displayName=DT;var $T="DropdownMenuSubTrigger",Dh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(yT,{...o,...r,ref:t})});Dh.displayName=$T;var FT="DropdownMenuSubContent",Lh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(ST,{...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)"}})});Lh.displayName=FT;var BT=Th,zT=Eh,HT=Ih,$h=Ah,Fh=jh,Bh=Ph,zh=_h,Hh=Rh,Uh=Mh,Wh=Oh,Vh=Dh,Kh=Lh;const Js=BT,Zs=zT,UT=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Vh,{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"})]}));UT.displayName=Vh.displayName;const WT=h.forwardRef(({className:e,...t},n)=>u.jsx(Kh,{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}));WT.displayName=Kh.displayName;const jo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(HT,{children:u.jsx($h,{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})}));jo.displayName=$h.displayName;const Kn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Bh,{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=Bh.displayName;const VT=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(zh,{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(Uh,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));VT.displayName=zh.displayName;const KT=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hh,{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(Uh,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));KT.displayName=Hh.displayName;const qT=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Fh,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));qT.displayName=Fh.displayName;const GT=h.forwardRef(({className:e,...t},n)=>u.jsx(Wh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));GT.displayName=Wh.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 YT=1e4;function qh({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=YT,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:v,validate:g,onValidationError:x}){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),j=b.useRef(null),F=b.useRef("");b.useEffect(()=>{if(!y&&(C(e??""),j.current=null,k.current)){const L=!e||e.trim()==="",$=44;L?k.current.style.height=`${$}px`:(k.current.style.height="auto",k.current.style.height=`${Math.max(k.current.scrollHeight,$)}px`)}},[e,t,y]);const[D,B]=b.useState(null),G=b.useCallback(L=>L.length>s?`Message too long (${L.length}/${s} characters)`:null,[s]),M=b.useMemo(()=>g??G,[g,G]),W=b.useCallback(L=>{const $=M(L);return B($),x==null||x($),F.current=L,$},[M,x]),Y=b.useCallback(()=>{const L=k.current;if(!L)return;const $=!L.value||L.value.trim()==="",X=44;if($){L.style.height=`${X}px`;return}L.style.height="auto";const R=Math.max(L.scrollHeight,X);L.style.height=`${R}px`},[]);b.useEffect(()=>{Y()},[Y,E]),b.useEffect(()=>{if(!D)return;const L=(E??"").trim();F.current!==L&&W(L)},[E,D,W]);const z=b.useCallback((L,{fromUser:$})=>{y||C(L),$&&(a==null||a(L))},[y,a]),P=b.useCallback(async L=>{L&&L.preventDefault();const $=(E??"").trim();if(!$&&!p||W($))return;const X=++A.current;j.current={id:X,shouldClear:!0},S(()=>{var R,_,U;try{const Z=l($);Z&&typeof Z.then=="function"?Z.then(()=>{var re,ce;((re=j.current)==null?void 0:re.id)===X&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ce=j.current)==null?void 0:ce.id)===X&&(j.current=null)}).catch(()=>{var re;((re=j.current)==null?void 0:re.id)===X&&(j.current=null)}):(((R=j.current)==null?void 0:R.id)===X&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((_=j.current)==null?void 0:_.id)===X&&(j.current=null))}catch{((U=j.current)==null?void 0:U.id)===X&&(j.current=null)}})},[E,l,p,y,a,W]),I=b.useCallback(L=>{const $=L.target.value;z($,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),D&&W($.trim())},[z,W,D]),K=b.useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),P()):L.key==="Escape"&&t&&(L.preventDefault(),c==null||c())},[P,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 ${f}`,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:K,placeholder:t?"Edit your message...":n,className:q,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),D&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:D})]}),u.jsx("div",{children:r?u.jsx(Xe,{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(Xe,{type:"button",onClick:L=>void P(L),size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!p||T||r,children:u.jsx(de.Send,{size:16})})})]})})}const XT=b.memo(qh);function Gh({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:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:v,onFilesChange:g,onError:x,allowEmptySend:y=!1,inputError:w=null}){const[C,E]=b.useState([]),T=b.useRef(null),S=b.useRef(null),[k,A]=b.useState(0),[j,F]=b.useState(0),[D,B]=b.useState(!1),[G,M]=b.useState(null),[W,Y]=b.useState(null),z=b.useCallback(()=>{T.current&&(T.current.value=""),S.current&&(S.current.value=""),A($=>$+1),F($=>$+1)},[]),P=b.useCallback($=>{E(X=>{const R=[...X,...$];return g==null||g(R),R})},[g]),I=b.useCallback($=>{const X=Array.from($.target.files||[]);P(X),$.target.value=""},[P]),K=b.useCallback($=>{E(X=>{const R=X.filter((_,U)=>U!==$);return R.length===0&&z(),g==null||g(R),R})},[g,z]),te=b.useCallback(async $=>{const X=($.target.files||[])[0];if(X&&(M(null),Y(null),!!v)){B(!0);try{await v(X),M(`Uploaded ${X.name} - processing through chat stream`)}catch(R){const _=R instanceof Error?R.message:"Failed to upload Excel file";Y(_),x==null||x(_)}finally{B(!1),$.target.value="",z()}}},[v,x,z]),O=b.useMemo(()=>y||C.length>0,[y,C]),q=b.useCallback(async $=>{const R=await n($,C);return C.length>0&&(E([]),g==null||g([]),z()),R},[n,z,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":""} ${f.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||p)&&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(($,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(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:$.name}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>K(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 ${$.name}`,children:u.jsx(de.X,{size:12})})]},X))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:te,className:"hidden"},j),D&&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..."]}),G&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:G}),W&&!D&&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||p)&&u.jsxs(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(Xe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:f.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(jo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Kn,{onClick:()=>{var $;return($=T.current)==null?void 0:$.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Kn,{onClick:()=>{var $;D||($=S.current)==null||$.click()},className:`cursor-pointer ${D?"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(XT,{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:O,textareaClassName:L,sendButtonClassName:f.sendButton})})]})]})}const JT=b.memo(Gh),Yh={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:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:w,defaultMessage:C}){const{chatApi:E}=On(),T=E.baseUrl,{currentThreadId:S}=yr(),{threadId:k,messages:A,isLoading:j,navigateToCheckpoint:F,returnToLatest:D,checkpoint:B,checkpoints:G,interrupt:M,metadata:W,checkpointIndex:Y,respondToInterrupt:z}=ro(),{isStreaming:P,error:I,connectionState:K,submit:te,stop:O}=Ui(),q=k??S??null,L=(B==null?void 0:B.id)??null,$=(B==null?void 0:B.namespace)??null,X=(W==null?void 0:W.assemblingMessageId)??null;b.useEffect(()=>{console.log("[ChatInterface] streamingAssistantId changed:",{streamingAssistantId:X,isStreaming:P,assemblingMessageId:W==null?void 0:W.assemblingMessageId})},[X,P,W==null?void 0:W.assemblingMessageId]);const R=M,_=R?$i(R.id):null,U=_!==null?{type:"interrupt",id:_}:null,[Z,re]=b.useState(!1),[ce,Ne]=b.useState(!1);b.useEffect(()=>{R||re(!1)},[R]);const ye=b.useCallback(()=>{re(!0)},[]),Re=b.useCallback(()=>{re(!1)},[]),We=b.useCallback(ee=>{},[]),Fe=b.useCallback(ee=>ee.name!=="ask_user_choice",[]),Ye=d??{toolRenderers:f,toolArtifactRenderers:m,getToolExpandable:Fe},Ve=b.useCallback(async(ee,le,me)=>{try{ye(),await z(ee,le,me)}catch(Se){console.error("Failed to respond to interrupt:",Se)}finally{Re()}},[Re,ye,z]),tt=b.useCallback(()=>Ve(!0),[Ve]),gt=b.useCallback(()=>Ve(!1),[Ve]),at=b.useCallback((ee,le)=>Ve(!0,le),[Ve]),lt=!!R||Z,[Me,Ke]=b.useState(null),[je,qe]=b.useState(""),[Be,nt]=b.useState(null),[ct,ft]=b.useState(null),[yt,Tt]=b.useState(!1),[pt,At]=b.useState(null),xt=b.useRef(!1),[ht,zt]=b.useState(()=>Yh.value),Ht=b.useRef(ht),Oe=b.useRef(null),ze=b.useCallback(ee=>{Yh.value=ee,zt(ee)},[]),[kt,ut]=b.useState(!1),Pt=b.useRef(null),ge=b.useCallback(ee=>{ze(ee)},[ze]);b.useEffect(()=>{P||Ne(!1)},[P]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&Ne(!1)},[W==null?void 0:W.assemblingMessageId]);const[De,He]=b.useState("desktop");b.useEffect(()=>{const ee=()=>{const le=window.innerWidth;He(le<640?"phone":le<1024?"tablet":"desktop")};return ee(),window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[]),b.useEffect(()=>{xt.current=!1},[q]),b.useEffect(()=>{Ht.current=ht},[ht]),b.useEffect(()=>{if(!Me){Oe.current=null;return}Oe.current===null&&(Oe.current=Ht.current),ze(je??"")},[je,Me,ze]),b.useEffect(()=>{if(C!==void 0){At(C);return}(async()=>{if(!T){At(null);return}try{const me=(await E.getAgent("default")).uiDefaultMessage||"";At(me||null)}catch(le){console.warn("Failed to fetch default message:",le),At(null)}})()},[E,T,C]),b.useEffect(()=>{I&&!yt&&(w==null||w(I))},[I,yt,w]);const st=async(ee,le)=>{const me=ee.trim();if(!(!me&&le.length===0))try{const Se=Me?(Be==null?void 0:Be.checkpointId)??L??void 0:L??void 0,be=Me?(Be==null?void 0:Be.checkpointNs)??$??void 0:$??void 0;await te({text:me||"",attachments:le,payload:p},{checkpointId:Se,checkpointNs:be,edit:!!Me,originalMessageId:Me??void 0}),x==null||x(me),Ne(!0),ze(""),ft(null),Ke(null),qe(""),nt(null)}catch(Se){const be=(Se==null?void 0:Se.message)||"Failed to send message";ft(be),w==null||w(be),Ne(!1)}},et=b.useCallback(async ee=>{await te({attachments:[ee],payload:p},{checkpointId:L??void 0,checkpointNs:$??void 0}),y==null||y({file:ee})},[L,$,p,y,te]),dt=b.useCallback((ee,le,me)=>{l&&(Oe.current=ht,Ke(ee),qe(le),ze(le),ft(null),nt({checkpointId:(me==null?void 0:me.checkpointId)??null,checkpointNs:(me==null?void 0:me.checkpointNs)??null}))},[ht,l,ze]),mt=b.useCallback(()=>{Ke(null),qe(""),nt(null),ft(null),ze(Oe.current??ht),Oe.current=null},[ht,ze]),J=b.useCallback((ee,le,me)=>{dt(ee,le,me)},[dt]),ae=b.useCallback(ee=>{let le=null;for(let Ie=ee-1;Ie>=0;Ie--)if(A[Ie].role==="user"){le=A[Ie];break}if(!le)return;const me=Array.isArray(le.content)?le.content:[],be=me.filter(Ie=>(Ie==null?void 0:Ie.type)==="text").map(Ie=>Ie.text).join("")||(()=>{try{return JSON.stringify(me,null,2)}catch{return String(me)}})();be&&te({text:be,payload:p},{checkpointId:L??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:le.id})},[A,te,L,$,p]),ie=b.useCallback(async ee=>{if(S){ut(!0);try{if(!ee){await D(),requestAnimationFrame(()=>{var Se;(Se=Pt.current)==null||Se.scrollToLatest()});return}const le=G.find(Se=>Se.checkpointId===ee),me=(le==null?void 0:le.checkpointNs)??null;await F(ee,me),requestAnimationFrame(()=>{var Se;(Se=Pt.current)==null||Se.scrollToTop()})}finally{ut(!1)}}},[G,S,Pt,F,D]),Ce=b.useCallback(async(ee,le,me)=>{await ie(me?null:ee)},[ie]),Ee=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.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 ${R?"pb-32":""} bg-transparent ${v.messagesArea||""}`,Q=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Ee,children:[!!I&&!yt&&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(Xe,{variant:"ghost",size:"sm",onClick:()=>Tt(!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(Va,{ref:Pt,className:"h-full",style:{height:"100%"},messages:A,isStreaming:P,streamingAssistantId:X,streamingDebounceMs:o,followNewMessages:s,layoutSize:De,enableMessageEditing:l,editingMessageId:Me,onEdit:J,onRegenerate:ae,onCancelEdit:mt,emptyMessage:pt??void 0,isNavigatingCheckpoint:kt,showToolMessages:c,toolConfig:Ye,checkpointIndex:Y,activeCheckpointId:L,onSelectCheckpoint:Ce,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ce,getMessageCustomStyles:g,getInterruptOptions:We}),(K==="reconnecting"||K==="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"}),K==="reconnecting"?"Reconnecting…":"Connecting…"]})}),K==="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(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…"})]}),R&&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(ba,{interruptPart:U,onApprove:tt,onReject:gt,onSelectAlternative:at,disabled:Z,isActive:!0,payload:R.value})})})]}),u.jsxs("div",{className:Q,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(de.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:mt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),ct&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ct}),u.jsx(JT,{composerValue:ht,onComposerChange:ge,onSend:st,onCancelEdit:mt,onStop:O,editingMessageId:Me,editingInitialValue:je,placeholder:Me?"Edit your message...":t,isStreaming:P,disabled:lt,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:et,onError:w,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:ct})]})]})}var Xh=1,ZT=.9,QT=.8,ek=.17,wl=.1,yl=.999,tk=.9999,nk=.99,rk=/[\\\/_+.#"@\[\(\{&]/,ok=/[\\\/_+.#"@\[\(\{&]/g,sk=/[\s-]/,Jh=/[\s-]/g;function Sl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Xh:nk;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,f,m,p,v;c>=0;)f=Sl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Xh:rk.test(e.charAt(c-1))?(f*=QT,p=e.slice(o,c-1).match(ok),p&&o>0&&(f*=Math.pow(yl,p.length))):sk.test(e.charAt(c-1))?(f*=ZT,v=e.slice(o,c-1).match(Jh),v&&o>0&&(f*=Math.pow(yl,v.length))):(f*=ek,o>0&&(f*=Math.pow(yl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=tk)),(f<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>f&&(f=m*wl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Zh(e){return e.toLowerCase().replace(Jh," ")}function ik(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Sl(e,t,Zh(e),Zh(t),0,0,{})}var Po='[cmdk-group=""]',Cl='[cmdk-group-items=""]',ak='[cmdk-group-heading=""]',Qh='[cmdk-item=""]',em=`${Qh}:not([aria-disabled="true"])`,Tl="cmdk-item-select",Br="data-value",lk=(e,t,n)=>ik(e,t,n),tm=h.createContext(void 0),_o=()=>h.useContext(tm),nm=h.createContext(void 0),kl=()=>h.useContext(nm),rm=h.createContext(void 0),om=h.forwardRef((e,t)=>{let n=zr(()=>{var O,q;return{search:"",value:(q=(O=e.value)!=null?O: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=sm(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=jt(),C=jt(),E=jt(),T=h.useRef(null),S=bk();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,q,L)=>{var $,X,R,_;if(!Object.is(n.current[O],q)){if(n.current[O]=q,O==="search")B(),F(),S(1,D);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(E);U?U.focus():($=document.getElementById(w))==null||$.focus()}if(S(7,()=>{var U;n.current.selectedItemId=(U=M())==null?void 0:U.id,k.emit()}),L||S(5,G),((X=a.current)==null?void 0:X.value)!==void 0){let U=q??"";(_=(R=a.current).onValueChange)==null||_.call(R,U);return}}k.emit()}},emit:()=>{i.current.forEach(O=>O())}}),[]),A=h.useMemo(()=>({value:(O,q,L)=>{var $;q!==(($=s.current.get(O))==null?void 0:$.value)&&(s.current.set(O,{value:q,keywords:L}),n.current.filtered.items.set(O,j(q,L)),S(2,()=>{F(),k.emit()}))},item:(O,q)=>(r.current.add(O),q&&(o.current.has(q)?o.current.get(q).add(O):o.current.set(q,new Set([O]))),S(3,()=>{B(),F(),n.current.value||D(),k.emit()}),()=>{s.current.delete(O),r.current.delete(O),n.current.filtered.items.delete(O);let L=M();S(4,()=>{B(),(L==null?void 0:L.getAttribute("id"))===O&&D(),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,q){var L,$;let X=($=(L=a.current)==null?void 0:L.filter)!=null?$:lk;return O?X(O,n.current.search,q):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let O=n.current.filtered.items,q=[];n.current.filtered.groups.forEach($=>{let X=o.current.get($),R=0;X.forEach(_=>{let U=O.get(_);R=Math.max(U,R)}),q.push([$,R])});let L=T.current;W().sort(($,X)=>{var R,_;let U=$.getAttribute("id"),Z=X.getAttribute("id");return((R=O.get(Z))!=null?R:0)-((_=O.get(U))!=null?_:0)}).forEach($=>{let X=$.closest(Cl);X?X.appendChild($.parentElement===X?$:$.closest(`${Cl} > *`)):L.appendChild($.parentElement===L?$:$.closest(`${Cl} > *`))}),q.sort(($,X)=>X[1]-$[1]).forEach($=>{var X;let R=(X=T.current)==null?void 0:X.querySelector(`${Po}[${Br}="${encodeURIComponent($[0])}"]`);R==null||R.parentElement.appendChild(R)})}function D(){let O=W().find(L=>L.getAttribute("aria-disabled")!=="true"),q=O==null?void 0:O.getAttribute(Br);k.setState("value",q||void 0)}function B(){var O,q,L,$;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 R of r.current){let _=(q=(O=s.current.get(R))==null?void 0:O.value)!=null?q:"",U=($=(L=s.current.get(R))==null?void 0:L.keywords)!=null?$:[],Z=j(_,U);n.current.filtered.items.set(R,Z),Z>0&&X++}for(let[R,_]of o.current)for(let U of _)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(R);break}n.current.filtered.count=X}function G(){var O,q,L;let $=M();$&&(((O=$.parentElement)==null?void 0:O.firstChild)===$&&((L=(q=$.closest(Po))==null?void 0:q.querySelector(ak))==null||L.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function M(){var O;return(O=T.current)==null?void 0:O.querySelector(`${Qh}[aria-selected="true"]`)}function W(){var O;return Array.from(((O=T.current)==null?void 0:O.querySelectorAll(em))||[])}function Y(O){let q=W()[O];q&&k.setState("value",q.getAttribute(Br))}function z(O){var q;let L=M(),$=W(),X=$.findIndex(_=>_===L),R=$[X+O];(q=a.current)!=null&&q.loop&&(R=X+O<0?$[$.length-1]:X+O===$.length?$[0]:$[X+O]),R&&k.setState("value",R.getAttribute(Br))}function P(O){let q=M(),L=q==null?void 0:q.closest(Po),$;for(;L&&!$;)L=O>0?xk(L,Po):vk(L,Po),$=L==null?void 0:L.querySelector(em);$?k.setState("value",$.getAttribute(Br)):z(O)}let I=()=>Y(W().length-1),K=O=>{O.preventDefault(),O.metaKey?I():O.altKey?P(1):z(1)},te=O=>{O.preventDefault(),O.metaKey?Y(0):O.altKey?P(-1):z(-1)};return h.createElement(he.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:O=>{var q;(q=y.onKeyDown)==null||q.call(y,O);let L=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||L))switch(O.key){case"n":case"j":{x&&O.ctrlKey&&K(O);break}case"ArrowDown":{K(O);break}case"p":case"k":{x&&O.ctrlKey&&te(O);break}case"ArrowUp":{te(O);break}case"Home":{O.preventDefault(),Y(0);break}case"End":{O.preventDefault(),I();break}case"Enter":{O.preventDefault();let $=M();if($){let X=new Event(Tl);$.dispatchEvent(X)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:yk},l),Qs(e,O=>h.createElement(nm.Provider,{value:k},h.createElement(tm.Provider,{value:A},O))))}),ck=h.forwardRef((e,t)=>{var n,r;let o=jt(),s=h.useRef(null),i=h.useContext(rm),a=_o(),l=sm(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=im(o,s,[e.value,e.children,s],e.keywords),f=kl(),m=qn(S=>S.value&&S.value===d.current),p=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,v),()=>S.removeEventListener(Tl,v)},[p,e.onSelect,e.disabled]);function v(){var S,k;g(),(k=(S=l.current).onSelect)==null||k.call(S,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:w,forceMount:C,keywords:E,...T}=e;return h.createElement(he.div,{ref:Dn(s,t),...T,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),uk=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=_o(),f=qn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);hr(()=>d.group(i),[]),im(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(he.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Qs(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(rm.Provider,{value:m},p))))}),dk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:h.createElement(he.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),fk=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=_o();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(he.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)}})}),pk=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=_o();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),h.createElement(he.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)))}),hk=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(io,{"cmdk-overlay":"",className:o}),h.createElement(ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(om,{ref:t,...a}))))}),mk=h.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?h.createElement(he.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),gk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(he.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(om,{List:pk,Item:ck,Input:fk,Group:uk,Separator:dk,Dialog:hk,Empty:mk,Loading:gk});function xk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function vk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function sm(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 im(e,t,n,r=[]){let o=h.useRef(),s=_o();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 bk=()=>{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 wk(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(wk(t),{ref:t.ref},n(t.props.children)):n(t)}var yk={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(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})]}));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 Sk=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));Sk.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 Ck(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Rl="ScrollArea",[am,KN]=nn(Rl),[Tk,an]=am(Rl),lm=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),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[C,E]=h.useState(0),[T,S]=h.useState(!1),[k,A]=h.useState(!1),j=Le(t,D=>l(D)),F=Os(o);return u.jsx(Tk,{scope:n,type:r,dir:F,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:T,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:E,children:u.jsx(he.div,{dir:F,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});lm.displayName=Rl;var cm="ScrollAreaViewport",um=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=an(cm,n),a=h.useRef(null),l=Le(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(he.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})})]})});um.displayName=cm;var En="ScrollAreaScrollbar",Ml=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(kk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ek,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(dm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ol,{...r,ref:t}):null});Ml.displayName=En;var kk=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($t,{present:n||s,children:u.jsx(dm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ek=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]=Ck("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 f=c[d];const m=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx($t,{present:n||a!=="hidden",children:u.jsx(Ol,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ue(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ue(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),dm=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($t,{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=gm(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 f(m,p){return _k(m,i.current,a,p)}return n==="horizontal"?u.jsx(Ik,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=xm(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(Nk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=xm(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),Ik=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=Le(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(pm,{"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,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),bm(m,f)&&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)}})}})}),Nk=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=Le(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(pm,{"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,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),bm(m,f)&&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)}})}})}),[Ak,fm]=am(En),pm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,p=an(En,n),[v,g]=h.useState(null),x=Le(t,j=>g(j)),y=h.useRef(null),w=h.useRef(""),C=p.viewport,E=r.content-r.viewport,T=bt(d),S=bt(l),k=ri(f,10);function A(j){if(y.current){const F=j.clientX-y.current.left,D=j.clientY-y.current.top;c({x:F,y:D})}}return h.useEffect(()=>{const j=F=>{const D=F.target;(v==null?void 0:v.contains(D))&&T(F,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[C,v,E,T]),h.useEffect(S,[r,S]),Hr(v,k),Hr(p.content,k),u.jsx(Ak,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:bt(s),onThumbPointerUp:bt(i),onThumbPositionChange:S,onThumbPointerDown:bt(a),children:u.jsx(he.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ue(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:ue(e.onPointerMove,A),onPointerUp:ue(e.onPointerUp,j=>{const F=j.target;F.hasPointerCapture(j.pointerId)&&F.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",hm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=fm(ei,e.__scopeScrollArea);return u.jsx($t,{present:n||o.hasThumb,children:u.jsx(jk,{ref:t,...r})})}),jk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(ei,n),i=fm(ei,n),{onThumbPositionChange:a}=i,l=Le(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=ri(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const p=Rk(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(he.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:ue(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ue(e.onPointerUp,i.onThumbPointerUp)})});hm.displayName=ei;var Dl="ScrollAreaCorner",mm=h.forwardRef((e,t)=>{const n=an(Dl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Pk,{...e,ref:t}):null});mm.displayName=Dl;var Pk=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 f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Hr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(he.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 gm(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=gm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function _k(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,f=r==="ltr"?[0,d]:[d*-1,0];return vm([l,c],f)(e)}function xm(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 vm([0,i],[0,a])(c)}function vm(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 bm(e,t){return e>0&&e<t}var Rk=(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=bt(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=bt(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 wm=lm,Mk=um,Ok=mm;const Ll=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(wm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Mk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(ym,{}),u.jsx(Ok,{})]}));Ll.displayName=wm.displayName;const ym=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ml,{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(hm,{className:"relative flex-1 rounded-full bg-border"})}));ym.displayName=Ml.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 Dk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Lk="bg-slate-700 border-slate-600 hover:bg-slate-600",$k="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:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){var T;const w=n===e.threadId,C=t?`${y??$k}`:`${x??Lk}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${Dk} ${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(Xe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(Xe,{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:v(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:p(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(Xe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(jo,{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"]}),f&&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 oi="Collapsible",[Fk,qN]=nn(oi),[Bk,Bl]=Fk(oi),Sm=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(Bk,{scope:n,disabled:s,contentId:jt(),open:l,onOpenToggle:h.useCallback(()=>c(d=>!d),[c]),children:u.jsx(he.div,{"data-state":Hl(l),"data-disabled":s?"":void 0,...a,ref:t})})});Sm.displayName=oi;var Cm="CollapsibleTrigger",Tm=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Bl(Cm,n);return u.jsx(he.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:ue(e.onClick,o.onOpenToggle)})});Tm.displayName=Cm;var zl="CollapsibleContent",km=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bl(zl,e.__scopeCollapsible);return u.jsx($t,{present:n||o.open,children:({present:s})=>u.jsx(zk,{...r,ref:t,present:s})})});km.displayName=zl;var zk=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=Le(t,c),f=h.useRef(0),m=f.current,p=h.useRef(0),v=p.current,g=i.open||a,x=h.useRef(g),y=h.useRef(void 0);return h.useEffect(()=>{const w=requestAnimationFrame(()=>x.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();f.current=C.height,p.current=C.width,x.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(he.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":v?`${v}px`:void 0,...e.style},children:g&&o})});function Hl(e){return e?"open":"closed"}var Hk=Sm;const Uk=Hk,Wk=Tm,Vk=km,Em=25,Im="thread-manager-view",Kk=e=>e==="default"||e==="shared",qk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Im);if(Kk(e))return e}catch{}return null};function Nm({defaultView:e}={}){const[t,n]=b.useState(()=>qk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Im,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Gk=[{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:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:C,groupBy:E}){const{chatApi:T,authApi:S}=On(),{threads:k,sharedThreads:A,currentThreadId:j,setCurrentThreadId:F,isLoading:D,isLoadingSharedThreads:B,actions:G,shareInFlight:M,shareStatus:W,clearShareStatus:Y}=yr(),{createThread:z,deleteThread:P,renameThread:I,shareThread:K}=G,{loadThread:te}=ro(),O=i??j,[q,L]=b.useState(Array.isArray(k)?k:[]),$=b.useRef(q.length>0),X=b.useRef(null),R=b.useRef(0),[_,U]=b.useState(null),[Z,re]=b.useState(""),[ce,Ne]=b.useState(!1),[ye,Re]=b.useState(!1),[We,Fe]=b.useState(null),[Ye,Ve]=b.useState(""),[tt,gt]=b.useState([]),[at,lt]=b.useState(!1);b.useEffect(()=>{ye&&!y&&tt.length===0&&!at&&(async()=>{lt(!0);try{const ie=(await S.listUsers()).filter(Ce=>Ce.id||Ce.user_id).map(Ce=>({type:"user",value:Ce.user_id||Ce.id||"",id:Ce.user_id||Ce.id||"",label:Ce.name||Ce.username||Ce.email||"Unknown User",secondaryLabel:Ce.name||Ce.username?Ce.email:void 0}));gt(ie)}catch(ae){console.error("Failed to load users for sharing:",ae)}finally{lt(!1)}})()},[ye,y,tt.length,at,T]);const Me=y??tt,Ke=w??at,je=v&&v.length>0?v:Gk,qe=Nm({defaultView:m}),Be=g??qe,nt=f??Be.view,ct=b.useCallback(J=>{f||Be.setView(J),p==null||p(J)},[f,p,Be]),ft=je.find(J=>J.key===nt)??je[0],yt=J=>{Fe(J),Ve(""),Re(!0)},Tt=()=>{Re(!1),Fe(null),Ve(""),Y()},pt=b.useCallback(async J=>{if(!(!We||M)&&J.id)try{await K(We,J.id),setTimeout(()=>Tt(),600)}catch(ae){console.error("Failed to share thread:",ae)}},[Tt,M,We,K]),At=b.useMemo(()=>{const J=Me,ae=Ye.trim().toLowerCase();return ae?C?J.filter(ie=>C(ie,ae)):J.filter(ie=>`${ie.label} ${ie.secondaryLabel??""}`.toLowerCase().includes(ae)):J},[y,Ye,C]),xt=nt==="shared",ht=xt?A:q,zt=b.useMemo(()=>{if(!E||xt)return null;const J={},ae="Default";return ht.forEach(ie=>{var Ee,N;let Ce=ae;E==="project"?Ce=((Ee=ie.project)==null?void 0:Ee.name)||((N=ie.project)==null?void 0:N.id)||ae:Ce=ie[E]||ae,J[Ce]||(J[Ce]=[]),J[Ce].push(ie)}),Object.keys(J).forEach(ie=>{J[ie].sort((Ce,Ee)=>new Date(Ee.updatedAt||Ee.createdAt||"").getTime()-new Date(Ce.updatedAt||Ce.createdAt||"").getTime())}),J},[ht,E,xt]),Ht=xt?B:D,Oe=xt?"No shared conversations yet":"No conversations yet",ze=J=>{const ae=J.sharedAt?` • ${et(J.sharedAt)}`:"";return`Shared by ${J.sharedByUserId}${ae}`},kt=J=>"sharedByUserId"in J;b.useEffect(()=>{const J=Array.isArray(k)?k:[];if(J.length>0){$.current=!0,L(J);return}D||($.current=!1,L(J))},[k,D]),b.useEffect(()=>{if(!X.current)return;const J=X.current.querySelector("[data-radix-scroll-area-viewport]");if(!J)return;let ae=null,ie=null;return ae=requestAnimationFrame(()=>{ie=requestAnimationFrame(()=>{J.scrollTop=R.current})}),()=>{ae!==null&&cancelAnimationFrame(ae),ie!==null&&cancelAnimationFrame(ie)}},[q]);const ut=async J=>{try{F(J),await te(J),a==null||a(J),l==null||l(J)}catch(ae){console.error("Failed to select thread:",ae)}},Pt=async()=>{try{Ne(!0);const J=await z();J&&(c==null||c(J),a==null||a(J))}catch(J){console.error("Failed to create thread:",J)}finally{Ne(!1)}},ge=async(J,ae)=>{if(ae.stopPropagation(),!!confirm("Delete this thread?")){if(X.current){const ie=X.current.querySelector("[data-radix-scroll-area-viewport]");ie&&(R.current=ie.scrollTop)}try{await P(J),d==null||d(J)}catch(ie){console.error("Failed to delete thread:",ie)}}},De=(J,ae)=>{ae.stopPropagation(),U(J.threadId),re(J.title||`Thread ${J.threadId.slice(0,8)}`)},He=async J=>{if(Z.trim())try{await I(J,Z.trim()),U(null),re("")}catch(ae){console.error("Failed to update title:",ae)}},st=()=>{U(null),re("")},et=J=>{if(!J)return"";try{const ae=J.endsWith("Z")||J.includes("+")?J:`${J}Z`,ie=new Date(ae),Ee=new Date().getTime()-ie.getTime(),N=Math.floor(Ee/(1e3*60*60*24));return N===0?ie.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):N===1?"Yesterday":N<7?`${N} days ago`:ie.toLocaleDateString()}catch{return""}},dt=J=>J.title||`Thread ${J.threadId.slice(0,8)}`,mt=J=>{const ae=dt(J);return ae.length<=Em?ae:`${ae.slice(0,Em)}...`};return u.jsxs("div",{className:`thread-manager-root flex flex-col h-full ${e} ${s.container||""}`,children:[x&&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(Xe,{onClick:Pt,disabled:ce||D,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:ce?"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(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(Xe,{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:ft.label})}),u.jsx(jo,{align:"start",sideOffset:6,className:"w-40",children:je.map(J=>u.jsxs(Kn,{className:"justify-between text-[12px]",onClick:ae=>{ae.preventDefault(),ct(J.key)},children:[u.jsx("span",{children:J.label}),nt===J.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},J.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:Ht?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…"})]}):ht.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:Oe})]}):zt?Object.entries(zt).sort(([J],[ae])=>{const ie="Default";return J===ie?1:ae===ie?-1:J.localeCompare(ae)}).map(([J,ae])=>u.jsxs(Uk,{defaultOpen:!0,className:"group/collapsible",children:[u.jsxs(Wk,{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"}),J,u.jsx("span",{className:"ml-auto text-[10px] text-slate-400",children:ae.length})]}),u.jsx(Vk,{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:ae.map(ie=>u.jsx(Fl,{thread:ie,isActive:O===ie.threadId,editingThreadId:_,editingTitle:Z,onSelect:ut,onStartEditing:De,onEditingTitleChange:Ce=>re(Ce),onSaveEditing:He,onCancelEditing:st,onShare:()=>yt(ie.threadId),onDelete:ge,showEditTitle:r,showDeleteButton:n,formatDate:et,getDisplayThreadTitle:mt,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ie.threadId))})})]},J)):ht.slice().sort((J,ae)=>new Date(ae.updatedAt||ae.createdAt||"").getTime()-new Date(J.updatedAt||J.createdAt||"").getTime()).map(J=>u.jsx(Fl,{thread:J,isActive:O===J.threadId,editingThreadId:_,editingTitle:Z,onSelect:ut,onStartEditing:De,onEditingTitleChange:ae=>re(ae),onSaveEditing:He,onCancelEditing:st,onShare:()=>yt(J.threadId),onDelete:ge,showEditTitle:r,showDeleteButton:n,formatDate:et,getDisplayThreadTitle:mt,secondaryLine:xt&&kt(J)?ze(J):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},J.threadId))})}),u.jsx(la,{open:ye,onOpenChange:J=>!J&&Tt(),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:Ye,onValueChange:J=>Ve(J),placeholder:"Search for recipients..."}),u.jsxs(Nl,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[M&&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(Al,{children:Ke?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"}),At.length>0&&u.jsx(jl,{heading:"Recipients",children:At.map(J=>u.jsx(Pl,{onSelect:()=>pt(J),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:J.label}),J.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:J.secondaryLabel})]})},J.id))})]})]})]})})]})}function Yk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},payloadExtras:s={},...i}){const a=d=>{const f="h-full";switch(d){case"phone":return`${f} max-w-none`;case"tablet":return`${f} max-w-4xl mx-auto`;case"half-screen":return`${f} max-w-2xl`;case"desktop":default:return`${f} 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 f;(f=i.onThreadChange)==null||f.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 Xk({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 Jk({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(si,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Zk({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(Xe,{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(Xe,{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(Xe,{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(Jk,{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(Xe,{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 eE="Label",Am=h.forwardRef((e,t)=>u.jsx(he.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())}}));Am.displayName=eE;var jm=Am;const tE=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Pm=h.forwardRef(({className:e,...t},n)=>u.jsx(jm,{ref:n,className:oe(tE(),e),...t}));Pm.displayName=jm.displayName;function _m(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 Rm=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"}),nE="VisuallyHidden",ii=h.forwardRef((e,t)=>u.jsx(he.span,{...e,ref:t,style:{...Rm,...e.style}}));ii.displayName=nE;var rE=ii,oE=[" ","Enter","ArrowUp","ArrowDown"],sE=[" ","Enter"],mr="Select",[ai,li,iE]=Ms(mr),[Ur,GN]=nn(mr,[iE,$r]),ci=$r(),[aE,Gn]=Ur(mr),[lE,cE]=Ur(mr),Mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=ci(t),[x,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,F]=In({prop:i,defaultProp:a,onChange:l,caller:mr}),D=h.useRef(null),B=x?v||!!x.closest("form"):!0,[G,M]=h.useState(new Set),W=Array.from(G).map(Y=>Y.props.value).join(";");return u.jsx(sl,{...g,children:u.jsxs(aE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:jt(),value:j,onValueChange:F,open:k,onOpenChange:A,dir:S,triggerPointerDownPosRef:D,disabled:m,children:[u.jsx(ai.Provider,{scope:t,children:u.jsx(lE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(Y=>{M(z=>new Set(z).add(Y))},[]),onNativeOptionRemove:h.useCallback(Y=>{M(z=>{const P=new Set(z);return P.delete(Y),P})},[]),children:n})}),B?u.jsxs(og,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:Y=>F(Y.target.value),disabled:m,form:v,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},W):null]})})};Mm.displayName=mr;var Om="SelectTrigger",Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ci(n),i=Gn(Om,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),c=li(n),d=h.useRef("touch"),[f,m,p]=ig(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),w=ag(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(il,{asChild:!0,...s,children:u.jsx(he.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":sg(i.value)?"":void 0,...o,ref:l,onClick:ue(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ue(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ue(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&oE.includes(g.key)&&(v(),g.preventDefault())})})})});Dm.displayName=Om;var Lm="SelectValue",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(Lm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Le(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(he.span,{...a,ref:f,style:{pointerEvents:"none"},children:sg(l.value)?u.jsx(u.Fragment,{children:i}):s})});$m.displayName=Lm;var uE="SelectIcon",Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(he.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Fm.displayName=uE;var dE="SelectPortal",Bm=e=>u.jsx(so,{asChild:!0,...e});Bm.displayName=dE;var gr="SelectContent",zm=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(Hm,{scope:e.__scopeSelect,children:u.jsx(ai.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Um,{...e,ref:t})});zm.displayName=gr;var mn=10,[Hm,Yn]=Ur(gr),fE="SelectContentImpl",pE=Jt.createSlot("SelectContent.RemoveScroll"),Um=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:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Gn(gr,n),[C,E]=h.useState(null),[T,S]=h.useState(null),k=Le(t,R=>E(R)),[A,j]=h.useState(null),[F,D]=h.useState(null),B=li(n),[G,M]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(C)return na(C)},[C]),Xi();const Y=h.useCallback(R=>{const[_,...U]=B().map(ce=>ce.ref.current),[Z]=U.slice(-1),re=document.activeElement;for(const ce of R)if(ce===re||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===_&&T&&(T.scrollTop=0),ce===Z&&T&&(T.scrollTop=T.scrollHeight),ce==null||ce.focus(),document.activeElement!==re))return},[B,T]),z=h.useCallback(()=>Y([A,C]),[Y,A,C]);h.useEffect(()=>{G&&z()},[G,z]);const{onOpenChange:P,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(C){let R={x:0,y:0};const _=Z=>{var re,ce;R={x:Math.abs(Math.round(Z.pageX)-(((re=I.current)==null?void 0:re.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ce=I.current)==null?void 0:ce.y)??0))}},U=Z=>{R.x<=10&&R.y<=10?Z.preventDefault():C.contains(Z.target)||P(!1),document.removeEventListener("pointermove",_),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,P,I]),h.useEffect(()=>{const R=()=>P(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[P]);const[K,te]=ig(R=>{const _=B().filter(re=>!re.disabled),U=_.find(re=>re.ref.current===document.activeElement),Z=ag(_,R,U);Z&&setTimeout(()=>Z.ref.current.focus())}),O=h.useCallback((R,_,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===_||Z)&&(j(R),Z&&(W.current=!0))},[w.value]),q=h.useCallback(()=>C==null?void 0:C.focus(),[C]),L=h.useCallback((R,_,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===_||Z)&&D(R)},[w.value]),$=r==="popper"?Ul:Wm,X=$===Ul?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Hm,{scope:n,content:C,viewport:T,onViewportChange:S,itemRefCallback:O,selectedItem:A,onItemLeave:q,itemTextRefCallback:L,focusSelectedItem:z,selectedItemText:F,position:r,isPositioned:G,searchRef:K,children:u.jsx(rs,{as:pE,allowPinchZoom:!0,children:u.jsx(Xo,{asChild:!0,trapped:w.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:ue(o,R=>{var _;(_=w.trigger)==null||_.focus({preventScroll:!0}),R.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:R=>R.preventDefault(),...y,...X,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ue(y.onKeyDown,R=>{const _=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!_&&R.key.length===1&&te(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let Z=B().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(R.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const re=R.target,ce=Z.indexOf(re);Z=Z.slice(ce+1)}setTimeout(()=>Y(Z)),R.preventDefault()}})})})})})})});Um.displayName=fE;var hE="SelectItemAlignedPosition",Wm=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),f=Le(t,k=>d(k)),m=li(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const k=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),F=y.getBoundingClientRect();if(s.dir!=="rtl"){const re=F.left-A.left,ce=j.left-re,Ne=k.left-ce,ye=k.width+Ne,Re=Math.max(ye,A.width),We=window.innerWidth-mn,Fe=_l(ce,[mn,Math.max(mn,We-Re)]);a.style.minWidth=ye+"px",a.style.left=Fe+"px"}else{const re=A.right-F.right,ce=window.innerWidth-j.right-re,Ne=window.innerWidth-k.right-ce,ye=k.width+Ne,Re=Math.max(ye,A.width),We=window.innerWidth-mn,Fe=_l(ce,[mn,Math.max(mn,We-Re)]);a.style.minWidth=ye+"px",a.style.right=Fe+"px"}const D=m(),B=window.innerHeight-mn*2,G=g.scrollHeight,M=window.getComputedStyle(c),W=parseInt(M.borderTopWidth,10),Y=parseInt(M.paddingTop,10),z=parseInt(M.borderBottomWidth,10),P=parseInt(M.paddingBottom,10),I=W+Y+G+P+z,K=Math.min(x.offsetHeight*5,I),te=window.getComputedStyle(g),O=parseInt(te.paddingTop,10),q=parseInt(te.paddingBottom,10),L=k.top+k.height/2-mn,$=B-L,X=x.offsetHeight/2,R=x.offsetTop+X,_=W+Y+R,U=I-_;if(_<=L){const re=D.length>0&&x===D[D.length-1].ref.current;a.style.bottom="0px";const ce=c.clientHeight-g.offsetTop-g.offsetHeight,Ne=Math.max($,X+(re?q:0)+ce+z),ye=_+Ne;a.style.height=ye+"px"}else{const re=D.length>0&&x===D[0].ref.current;a.style.top="0px";const Ne=Math.max(L,W+g.offsetTop+(re?O:0)+X)+U;a.style.height=Ne+"px",g.scrollTop=_-L+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=K+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,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&&v.current===!0&&(C(),w==null||w(),v.current=!1)},[C,w]);return u.jsx(gE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:u.jsx(he.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Wm.displayName=hE;var mE="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=mE;var[gE,Wl]=Ur(gr,{}),Vl="SelectViewport",Vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Vl,n),i=Wl(Vl,n),a=Le(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(he.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ue(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const w=y+p,C=Math.min(v,w),E=w-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Vm.displayName=Vl;var Km="SelectGroup",[xE,vE]=Ur(Km),bE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jt();return u.jsx(xE,{scope:n,id:o,children:u.jsx(he.div,{role:"group","aria-labelledby":o,...r,ref:t})})});bE.displayName=Km;var qm="SelectLabel",Gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=vE(qm,n);return u.jsx(he.div,{id:o.id,...r,ref:t})});Gm.displayName=qm;var ui="SelectItem",[wE,Ym]=Ur(ui),Xm=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,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Le(t,w=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,w,r,o)}),g=jt(),x=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(wE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{f(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(he.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:v,onFocus:ue(i.onFocus,()=>p(!0)),onBlur:ue(i.onBlur,()=>p(!1)),onClick:ue(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ue(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ue(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ue(i.onPointerMove,w=>{var C;x.current=w.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ue(i.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ue(i.onKeyDown,w=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(sE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Xm.displayName=ui;var Ro="SelectItemText",Jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ro,n),a=Yn(Ro,n),l=Ym(Ro,n),c=cE(Ro,n),[d,f]=h.useState(null),m=Le(t,y=>f(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(he.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Jm.displayName=Ro;var Zm="SelectItemIndicator",Qm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Ym(Zm,n).isSelected?u.jsx(he.span,{"aria-hidden":!0,...r,ref:t}):null});Qm.displayName=Zm;var Kl="SelectScrollUpButton",eg=h.forwardRef((e,t)=>{const n=Yn(Kl,e.__scopeSelect),r=Wl(Kl,e.__scopeSelect),[o,s]=h.useState(!1),i=Le(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(ng,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});eg.displayName=Kl;var ql="SelectScrollDownButton",tg=h.forwardRef((e,t)=>{const n=Yn(ql,e.__scopeSelect),r=Wl(ql,e.__scopeSelect),[o,s]=h.useState(!1),i=Le(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(ng,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});tg.displayName=ql;var ng=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(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(he.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ue(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ue(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ue(o.onPointerLeave,()=>{l()})})}),yE="SelectSeparator",rg=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(he.div,{"aria-hidden":!0,...r,ref:t})});rg.displayName=yE;var Gl="SelectArrow",SE=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});SE.displayName=Gl;var CE="SelectBubbleInput",og=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Le(r,o),i=_m(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 f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(he.select,{...n,style:{...Rm,...n.style},ref:s,defaultValue:t})});og.displayName=CE;function sg(e){return e===""||e===void 0}function ig(e){const t=bt(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 ag(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=TE(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 TE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kE=Mm,lg=Dm,EE=$m,IE=Fm,NE=Bm,cg=zm,AE=Vm,ug=Gm,dg=Xm,jE=Jm,PE=Qm,fg=eg,pg=tg,hg=rg;const _E=kE,RE=EE,mg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(lg,{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(IE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));mg.displayName=lg.displayName;const gg=h.forwardRef(({className:e,...t},n)=>u.jsx(fg,{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"})}));gg.displayName=fg.displayName;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(pg,{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"})}));xg.displayName=pg.displayName;const vg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(NE,{children:u.jsxs(cg,{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(gg,{}),u.jsx(AE,{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(xg,{})]})}));vg.displayName=cg.displayName;const ME=h.forwardRef(({className:e,...t},n)=>u.jsx(ug,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));ME.displayName=ug.displayName;const bg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(dg,{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(PE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(jE,{children:t})]}));bg.displayName=dg.displayName;const OE=h.forwardRef(({className:e,...t},n)=>u.jsx(hg,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));OE.displayName=hg.displayName;var DE="Separator",wg="horizontal",LE=["horizontal","vertical"],yg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=wg,...o}=e,s=$E(r)?r:wg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(he.div,{"data-orientation":s,...a,...o,ref:t})});yg.displayName=DE;function $E(e){return LE.includes(e)}var Sg=yg;const Cg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Sg,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Cg.displayName=Sg.displayName;var di="Switch",[FE,YN]=nn(di),[BE,zE]=FE(di),Tg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,p]=h.useState(null),v=Le(t,C=>p(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=In({prop:o,defaultProp:s??!1,onChange:c,caller:di});return u.jsxs(BE,{scope:n,checked:y,disabled:a,children:[u.jsx(he.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Ng(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ue(e.onClick,C=>{w(E=>!E),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(Ig,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Tg.displayName=di;var kg="SwitchThumb",Eg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=zE(kg,n);return u.jsx(he.span,{"data-state":Ng(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Eg.displayName=kg;var HE="SwitchBubbleInput",Ig=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Le(i,s),l=_m(n),c=Lp(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),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}})});Ig.displayName=HE;function Ng(e){return e?"checked":"unchecked"}var Ag=Tg,UE=Eg;const jg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ag,{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(UE,{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")})}));jg.displayName=Ag.displayName;const WE=ia,VE=Jw,KE=aa,Pg=h.forwardRef(({className:e,...t},n)=>u.jsx(io,{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}));Pg.displayName=io.displayName;const qE=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"}}),_g=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(KE,{children:[u.jsx(Pg,{}),u.jsxs(ao,{ref:o,className:oe(qE({side:e}),t),...r,children:[n,u.jsxs(Fd,{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"})]})]})]}));_g.displayName=ao.displayName;const Rg=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});Rg.displayName="SheetHeader";const Mg=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Mg.displayName=or.displayName;const Og=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Og.displayName=ls.displayName;var[fi,XN]=nn("Tooltip",[$r]),pi=$r(),Dg="TooltipProvider",GE=700,Yl="tooltip.open",[YE,Xl]=fi(Dg),Lg=e=>{const{__scopeTooltip:t,delayDuration:n=GE,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(YE,{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})};Lg.displayName=Dg;var Mo="Tooltip",[XE,hi]=fi(Mo),$g=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,f]=h.useState(null),m=jt(),p=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=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?x.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,w(!0)},[w]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w(!1)},[w]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,w(!0),p.current=0},g)},[g,w]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(sl,{...c,children:u.jsx(XE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?S():E()},[l.isOpenDelayedRef,S,E]),onTriggerLeave:h.useCallback(()=>{v?T():(window.clearTimeout(p.current),p.current=0)},[T,v]),onOpen:E,onClose:T,disableHoverableContent:v,children:n})})};$g.displayName=Mo;var Jl="TooltipTrigger",Fg=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=Le(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(il,{asChild:!0,...i,children:u.jsx(he.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ue(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ue(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ue(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ue(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ue(e.onBlur,o.onClose),onClick:ue(e.onClick,o.onClose)})})});Fg.displayName=Jl;var JE="TooltipPortal",[JN,ZE]=fi(JE,{forceMount:void 0}),Wr="TooltipContent",Bg=h.forwardRef((e,t)=>{const n=ZE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Wr,e.__scopeTooltip);return u.jsx($t,{present:r||i.open,children:i.disableHoverableContent?u.jsx(zg,{side:o,...s,ref:t}):u.jsx(QE,{side:o,...s,ref:t})})}),QE=h.forwardRef((e,t)=>{const n=hi(Wr,e.__scopeTooltip),r=Xl(Wr,e.__scopeTooltip),o=h.useRef(null),s=Le(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=oI(y,x.getBoundingClientRect()),C=sI(y,w),E=iI(g.getBoundingClientRect()),T=lI([...C,...E]);a(T),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!aI(y,i);w?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(zg,{...e,ref:s})}),[eI,tI]=fi(Mo,{isInside:!1}),nI=Jt.createSlottable("TooltipContent"),zg=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 f=m=>{const p=m.target;p!=null&&p.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.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(nI,{children:r}),u.jsx(eI,{scope:n,isInside:!0,children:u.jsx(rE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Bg.displayName=Wr;var Hg="TooltipArrow",rI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=pi(n);return tI(Hg,n).isInside?null:u.jsx(ll,{...o,...r,ref:t})});rI.displayName=Hg;function oI(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 sI(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 iI(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 aI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function lI(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),cI(t)}function cI(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 uI=Lg,dI=$g,fI=Fg,Ug=Bg;const pI=uI,hI=dI,mI=fI,Wg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Ug,{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}));Wg.displayName=Ug.displayName;var Zl="ToastProvider",[Ql,gI,xI]=Ms("Toast"),[Vg,ZN]=nn("Toast",[xI]),[vI,mi]=Vg(Zl),Kg=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),f=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(vI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Kg.displayName=Zl;var qg="ToastViewport",bI=["F8"],ec="toast.viewportPause",tc="toast.viewportResume",Gg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=bI,label:o="Notifications ({hotkey})",...s}=e,i=mi(qg,n),a=gI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Le(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((C=f.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&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=>{!x.contains(S.relatedTarget)&&C()},T=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",w),x.addEventListener("focusout",E),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",T),window.addEventListener("blur",w),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",E),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",T),window.removeEventListener("blur",w),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(C=>{const E=C.ref.current,T=[E,..._I(E)];return x==="forwards"?T:T.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){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===x&&j){(T=c.current)==null||T.focus();return}const B=g({tabbingDirection:j?"backwards":"forwards"}),G=B.findIndex(M=>M===A);oc(B.slice(G+1))?w.preventDefault():j?(S=c.current)==null||S.focus():(k=d.current)==null||k.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Vb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(nc,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});oc(x)}}),u.jsx(Ql.Slot,{scope:n,children:u.jsx(he.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(nc,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});oc(x)}})]})});Gg.displayName=qg;var Yg="ToastFocusProxy",nc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=mi(Yg,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=Yg;var Oo="Toast",wI="toast.swipeStart",yI="toast.swipeMove",SI="toast.swipeCancel",CI="toast.swipeEnd",Xg=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:Oo});return u.jsx($t,{present:n||a,children:u.jsx(EI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:bt(e.onPause),onResume:bt(e.onResume),onSwipeStart:ue(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ue(e.onSwipeMove,c=>{const{x:d,y:f}=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",`${f}px`)}),onSwipeCancel:ue(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:ue(e.onSwipeEnd,c=>{const{x:d,y:f}=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",`${f}px`),l(!1)})})})});Xg.displayName=Oo;var[TI,kI]=Vg(Oo,{onClose(){}}),EI=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:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=mi(Oo,n),[x,y]=h.useState(null),w=Le(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:F}=g,D=bt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),B=h.useCallback(M=>{!M||M===1/0||(window.clearTimeout(A.current),S.current=new Date().getTime(),A.current=window.setTimeout(D,M))},[D]);h.useEffect(()=>{const M=g.viewport;if(M){const W=()=>{B(k.current),c==null||c()},Y=()=>{const z=new Date().getTime()-S.current;k.current=k.current-z,window.clearTimeout(A.current),l==null||l()};return M.addEventListener(ec,Y),M.addEventListener(tc,W),()=>{M.removeEventListener(ec,Y),M.removeEventListener(tc,W)}}},[g.viewport,T,l,c,B]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(T)},[s,T,g.isClosePausedRef,B]),h.useEffect(()=>(j(),()=>F()),[j,F]);const G=h.useMemo(()=>x?rx(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(II,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(TI,{scope:n,onClose:D,children:qr.createPortal(u.jsx(Ql.ItemSlot,{scope:n,children:u.jsx(Wb,{asChild:!0,onEscapeKeyDown:ue(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||D(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(he.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ue(e.onKeyDown,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),onPointerDown:ue(e.onPointerDown,M=>{M.button===0&&(C.current={x:M.clientX,y:M.clientY})}),onPointerMove:ue(e.onPointerMove,M=>{if(!C.current)return;const W=M.clientX-C.current.x,Y=M.clientY-C.current.y,z=!!E.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,K=P?I(0,W):0,te=P?0:I(0,Y),O=M.pointerType==="touch"?10:2,q={x:K,y:te},L={originalEvent:M,delta:q};z?(E.current=q,gi(yI,f,L,{discrete:!1})):ox(q,g.swipeDirection,O)?(E.current=q,gi(wI,d,L,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(W)>O||Math.abs(Y)>O)&&(C.current=null)}),onPointerUp:ue(e.onPointerUp,M=>{const W=E.current,Y=M.target;if(Y.hasPointerCapture(M.pointerId)&&Y.releasePointerCapture(M.pointerId),E.current=null,C.current=null,W){const z=M.currentTarget,P={originalEvent:M,delta:W};ox(W,g.swipeDirection,g.swipeThreshold)?gi(CI,p,P,{discrete:!0}):gi(SI,m,P,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),II=e=>{const{__scopeToast:t,children:n,...r}=e,o=mi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return jI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ii,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},NI="ToastTitle",Jg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Jg.displayName=NI;var AI="ToastDescription",Zg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Zg.displayName=AI;var Qg="ToastAction",ex=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(nx,{altText:n,asChild:!0,children:u.jsx(rc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Qg}\`. Expected non-empty \`string\`.`),null)});ex.displayName=Qg;var tx="ToastClose",rc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=kI(tx,n);return u.jsx(nx,{asChild:!0,children:u.jsx(he.button,{type:"button",...r,ref:t,onClick:ue(e.onClick,o.onClose)})})});rc.displayName=tx;var nx=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(he.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function rx(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),PI(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(...rx(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 ox=(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 jI(e=()=>{}){const t=bt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function PI(e){return e.nodeType===e.ELEMENT_NODE}function _I(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 RI=Kg,sx=Gg,ix=Xg,ax=Jg,lx=Zg,cx=ex,ux=rc;const MI=RI,dx=h.forwardRef(({className:e,...t},n)=>u.jsx(sx,{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}));dx.displayName=sx.displayName;const OI=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"}}),fx=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(ix,{ref:r,className:oe(OI({variant:t}),e),...n}));fx.displayName=ix.displayName;const DI=h.forwardRef(({className:e,...t},n)=>u.jsx(cx,{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}));DI.displayName=cx.displayName;const px=h.forwardRef(({className:e,...t},n)=>u.jsx(ux,{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"})}));px.displayName=ux.displayName;const hx=h.forwardRef(({className:e,...t},n)=>u.jsx(ax,{ref:n,className:oe("text-sm font-semibold",e),...t}));hx.displayName=ax.displayName;const mx=h.forwardRef(({className:e,...t},n)=>u.jsx(lx,{ref:n,className:oe("text-sm opacity-90",e),...t}));mx.displayName=lx.displayName;function LI(){const{toasts:e}=da();return u.jsxs(MI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(fx,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(hx,{children:n}),r&&u.jsx(mx,{children:r})]}),o,u.jsx(px,{})]},t)}),u.jsx(dx,{})]})}var $I=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[p]?s[p]:p)):l.setAttribute(v,p)}),f(p)}function f(p){a&&c.includes(p)&&(l.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},FI=h.createContext(void 0),BI={setTheme:e=>{},themes:[]},zI=()=>{var e;return(e=h.useContext(FI))!=null?e:BI};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 HI=e=>{switch(e){case"success":return VI;case"info":return qI;case"warning":return KI;case"error":return GI;default:return null}},UI=Array(12).fill(0),WI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},UI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),VI=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"})),KI=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"})),qI=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"})),GI=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"})),YI=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"})),XI=()=>{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},sc=1,JI=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],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)||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 JI,ZI=(e,t)=>{let n=(t==null?void 0:t.id)||sc++;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",eN=ZI,tN=()=>Yt.toasts,nN=()=>Yt.getActiveToasts();Object.assign(eN,{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:tN,getToasts:nN});function rN(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))}rN(`: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 xi(e){return e.label!==void 0}var oN=3,sN="32px",iN="16px",gx=4e3,aN=356,lN=14,cN=20,uN=200;function gn(...e){return e.filter(Boolean).join(" ")}function dN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var fN=e=>{var t,n,r,o,s,i,a,l,c,d,f;let{invert:m,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:C,toasts:E,expanded:T,removeToast:S,defaultRichColors:k,closeButton:A,style:j,cancelButtonStyle:F,actionButtonStyle:D,className:B="",descriptionClassName:G="",duration:M,position:W,gap:Y,loadingIcon:z,expandByDefault:P,classNames:I,icons:K,closeButtonAriaLabel:te="Close toast",pauseWhenPageIsHidden:O}=e,[q,L]=b.useState(null),[$,X]=b.useState(null),[R,_]=b.useState(!1),[U,Z]=b.useState(!1),[re,ce]=b.useState(!1),[Ne,ye]=b.useState(!1),[Re,We]=b.useState(!1),[Fe,Ye]=b.useState(0),[Ve,tt]=b.useState(0),gt=b.useRef(p.duration||M||gx),at=b.useRef(null),lt=b.useRef(null),Me=C===0,Ke=C+1<=y,je=p.type,qe=p.dismissible!==!1,Be=p.className||"",nt=p.descriptionClassName||"",ct=b.useMemo(()=>w.findIndex(ge=>ge.toastId===p.id)||0,[w,p.id]),ft=b.useMemo(()=>{var ge;return(ge=p.closeButton)!=null?ge:A},[p.closeButton,A]),yt=b.useMemo(()=>p.duration||M||gx,[p.duration,M]),Tt=b.useRef(0),pt=b.useRef(0),At=b.useRef(0),xt=b.useRef(null),[ht,zt]=W.split("-"),Ht=b.useMemo(()=>w.reduce((ge,De,He)=>He>=ct?ge:ge+De.height,0),[w,ct]),Oe=XI(),ze=p.invert||m,kt=je==="loading";pt.current=b.useMemo(()=>ct*Y+Ht,[ct,Ht]),b.useEffect(()=>{gt.current=yt},[yt]),b.useEffect(()=>{_(!0)},[]),b.useEffect(()=>{let ge=lt.current;if(ge){let De=ge.getBoundingClientRect().height;return tt(De),x(He=>[{toastId:p.id,height:De,position:p.position},...He]),()=>x(He=>He.filter(st=>st.toastId!==p.id))}},[x,p.id]),b.useLayoutEffect(()=>{if(!R)return;let ge=lt.current,De=ge.style.height;ge.style.height="auto";let He=ge.getBoundingClientRect().height;ge.style.height=De,tt(He),x(st=>st.find(et=>et.toastId===p.id)?st.map(et=>et.toastId===p.id?{...et,height:He}:et):[{toastId:p.id,height:He,position:p.position},...st])},[R,p.title,p.description,x,p.id]);let ut=b.useCallback(()=>{Z(!0),Ye(pt.current),x(ge=>ge.filter(De=>De.toastId!==p.id)),setTimeout(()=>{S(p)},uN)},[p,S,x,pt]);b.useEffect(()=>{if(p.promise&&je==="loading"||p.duration===1/0||p.type==="loading")return;let ge;return T||g||O&&Oe?(()=>{if(At.current<Tt.current){let De=new Date().getTime()-Tt.current;gt.current=gt.current-De}At.current=new Date().getTime()})():gt.current!==1/0&&(Tt.current=new Date().getTime(),ge=setTimeout(()=>{var De;(De=p.onAutoClose)==null||De.call(p,p),ut()},gt.current)),()=>clearTimeout(ge)},[T,g,p,je,O,Oe,ut]),b.useEffect(()=>{p.delete&&ut()},[ut,p.delete]);function Pt(){var ge,De,He;return K!=null&&K.loading?b.createElement("div",{className:gn(I==null?void 0:I.loader,(ge=p==null?void 0:p.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":je==="loading"},K.loading):z?b.createElement("div",{className:gn(I==null?void 0:I.loader,(De=p==null?void 0:p.classNames)==null?void 0:De.loader,"sonner-loader"),"data-visible":je==="loading"},z):b.createElement(WI,{className:gn(I==null?void 0:I.loader,(He=p==null?void 0:p.classNames)==null?void 0:He.loader),visible:je==="loading"})}return b.createElement("li",{tabIndex:0,ref:lt,className:gn(B,Be,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[je],(n=p==null?void 0:p.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:k,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":R,"data-promise":!!p.promise,"data-swiped":Re,"data-removed":U,"data-visible":Ke,"data-y-position":ht,"data-x-position":zt,"data-index":C,"data-front":Me,"data-swiping":re,"data-dismissible":qe,"data-type":je,"data-invert":ze,"data-swipe-out":Ne,"data-swipe-direction":$,"data-expanded":!!(T||P&&R),style:{"--index":C,"--toasts-before":C,"--z-index":E.length-C,"--offset":`${U?Fe:pt.current}px`,"--initial-height":P?"auto":`${Ve}px`,...j,...p.style},onDragEnd:()=>{ce(!1),L(null),xt.current=null},onPointerDown:ge=>{kt||!qe||(at.current=new Date,Ye(pt.current),ge.target.setPointerCapture(ge.pointerId),ge.target.tagName!=="BUTTON"&&(ce(!0),xt.current={x:ge.clientX,y:ge.clientY}))},onPointerUp:()=>{var ge,De,He,st;if(Ne||!qe)return;xt.current=null;let et=Number(((ge=lt.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),dt=Number(((De=lt.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),mt=new Date().getTime()-((He=at.current)==null?void 0:He.getTime()),J=q==="x"?et:dt,ae=Math.abs(J)/mt;if(Math.abs(J)>=cN||ae>.11){Ye(pt.current),(st=p.onDismiss)==null||st.call(p,p),X(q==="x"?et>0?"right":"left":dt>0?"down":"up"),ut(),ye(!0),We(!1);return}ce(!1),L(null)},onPointerMove:ge=>{var De,He,st,et;if(!xt.current||!qe||((De=window.getSelection())==null?void 0:De.toString().length)>0)return;let dt=ge.clientY-xt.current.y,mt=ge.clientX-xt.current.x,J=(He=e.swipeDirections)!=null?He:dN(W);!q&&(Math.abs(mt)>1||Math.abs(dt)>1)&&L(Math.abs(mt)>Math.abs(dt)?"x":"y");let ae={x:0,y:0};q==="y"?(J.includes("top")||J.includes("bottom"))&&(J.includes("top")&&dt<0||J.includes("bottom")&&dt>0)&&(ae.y=dt):q==="x"&&(J.includes("left")||J.includes("right"))&&(J.includes("left")&&mt<0||J.includes("right")&&mt>0)&&(ae.x=mt),(Math.abs(ae.x)>0||Math.abs(ae.y)>0)&&We(!0),(st=lt.current)==null||st.style.setProperty("--swipe-amount-x",`${ae.x}px`),(et=lt.current)==null||et.style.setProperty("--swipe-amount-y",`${ae.y}px`)}},ft&&!p.jsx?b.createElement("button",{"aria-label":te,"data-disabled":kt,"data-close-button":!0,onClick:kt||!qe?()=>{}:()=>{var ge;ut(),(ge=p.onDismiss)==null||ge.call(p,p)},className:gn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=K==null?void 0:K.close)!=null?s:YI):null,p.jsx||b.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:b.createElement(b.Fragment,null,je||p.icon||p.promise?b.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||Pt():null,p.type!=="loading"?p.icon||(K==null?void 0:K[je])||HI(je):null):null,b.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?b.createElement("div",{"data-description":"",className:gn(G,nt,I==null?void 0:I.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),b.isValidElement(p.cancel)?p.cancel:p.cancel&&xi(p.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||F,onClick:ge=>{var De,He;xi(p.cancel)&&qe&&((He=(De=p.cancel).onClick)==null||He.call(De,ge),ut())},className:gn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,b.isValidElement(p.action)?p.action:p.action&&xi(p.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||D,onClick:ge=>{var De,He;xi(p.action)&&((He=(De=p.action).onClick)==null||He.call(De,ge),!ge.defaultPrevented&&ut())},className:gn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function xx(){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 pN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?iN:sN;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 hN=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:f,duration:m,style:p,visibleToasts:v=oN,toastOptions:g,dir:x=xx(),gap:y=lN,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(O=>O.position).map(O=>O.position)))),[S,r]),[j,F]=b.useState([]),[D,B]=b.useState(!1),[G,M]=b.useState(!1),[W,Y]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),K=b.useRef(!1),te=b.useCallback(O=>{k(q=>{var L;return(L=q.find($=>$.id===O.id))!=null&&L.delete||Yt.dismiss(O.id),q.filter(({id:$})=>$!==O.id)})},[]);return b.useEffect(()=>Yt.subscribe(O=>{if(O.dismiss){k(q=>q.map(L=>L.id===O.id?{...L,delete:!0}:L));return}setTimeout(()=>{Do.flushSync(()=>{k(q=>{let L=q.findIndex($=>$.id===O.id);return L!==-1?[...q.slice(0,L),{...q[L],...O},...q.slice(L+1)]:[O,...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 O=window.matchMedia("(prefers-color-scheme: dark)");try{O.addEventListener("change",({matches:q})=>{Y(q?"dark":"light")})}catch{O.addListener(({matches:L})=>{try{Y(L?"dark":"light")}catch($){console.error($)}})}},[d]),b.useEffect(()=>{S.length<=1&&B(!1)},[S]),b.useEffect(()=>{let O=q=>{var L,$;o.every(X=>q[X]||q.code===X)&&(B(!0),(L=z.current)==null||L.focus()),q.code==="Escape"&&(document.activeElement===z.current||($=z.current)!=null&&$.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[o]),b.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,K.current=!1)}},[z.current]),b.createElement("section",{ref:t,"aria-label":`${E} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((O,q)=>{var L;let[$,X]=O.split("-");return S.length?b.createElement("ol",{key:O,dir:x==="auto"?xx():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":$,"data-lifted":D&&S.length>1&&!s,"data-x-position":X,style:{"--front-toast-height":`${((L=j[0])==null?void 0:L.height)||0}px`,"--width":`${aN}px`,"--gap":`${y}px`,...p,...pN(l,c)},onBlur:R=>{K.current&&!R.currentTarget.contains(R.relatedTarget)&&(K.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||K.current||(K.current=!0,I.current=R.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{G||B(!1)},onDragEnd:()=>B(!1),onPointerDown:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||M(!0)},onPointerUp:()=>M(!1)},S.filter(R=>!R.position&&q===0||R.position===O).map((R,_)=>{var U,Z;return b.createElement(fN,{key:R.id,icons:C,index:_,toast:R,defaultRichColors:f,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:v,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:te,toasts:S.filter(re=>re.position==R.position),heights:j.filter(re=>re.position==R.position),setHeights:F,expandByDefault:s,gap:y,loadingIcon:w,expanded:D,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const mN=({...e})=>{const{theme:t="system"}=zI();return u.jsx(hN,{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=nf,H.Badge=cf,H.Button=Xe,H.Card=ma,H.CardContent=bs,H.CardDescription=va,H.CardHeader=ga,H.CardTitle=xa,H.ChatApi=iu,H.ChatApp=Yk,H.ChatInput=qh,H.ChatInputRow=Gh,H.ChatInterface=Fr,H.ChatProviders=Tr,H.ChatWidget=Zk,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=jo,H.DropdownMenuItem=Kn,H.DropdownMenuTrigger=Zs,H.FileApi=au,H.HISTORY_TIMEOUT_MS=ou,H.Input=$l,H.InterruptPartRenderer=ba,H.Label=Pm,H.MarkdownContent=ir,H.MessageComponent=ws,H.MessageContent=lf,H.MessageHeader=uf,H.MessageList=Va,H.MessageRow=Wa,H.NewChatButton=Qk,H.PlotArtifact=tf,H.SETTINGS_STORAGE_KEY=Wi,H.ScrollArea=Ll,H.Select=_E,H.SelectContent=vg,H.SelectItem=bg,H.SelectTrigger=mg,H.SelectValue=RE,H.Separator=Cg,H.Sheet=WE,H.SheetContent=_g,H.SheetDescription=Og,H.SheetHeader=Rg,H.SheetTitle=Mg,H.SheetTrigger=VE,H.SimpleChat=Xk,H.SimpleJsonView=vs,H.Sonner=mN,H.StreamProgress=rf,H.Switch=jg,H.Textarea=bl,H.ThinkingIndicator=sf,H.ThreadListItem=Fl,H.ThreadManager=si,H.ThreadStateProvider=Fu,H.ThreadsProvider=wu,H.TimelineColumn=Rx,H.Toaster=LI,H.ToolContent=pp,H.Tooltip=hI,H.TooltipContent=Wg,H.TooltipProvider=pI,H.TooltipTrigger=mI,H.UserTextContent=af,H.applySettings=Ib,H.buildCheckpointIndex=uc,H.buildCheckpointPreviewMap=Sx,H.buildLabelParts=Iu,H.chatApiClient=Mn,H.collectText=Cu,H.createArtifactPreviewFromPlot=Au,H.createArtifactPreviewFromSource=Nu,H.del=Oi,H.extractConfigFields=bi,H.extractToolContent=nr,H.extractToolMeta=Yo,H.fileApiClient=lu,H.fileToBase64=du,H.formatToolOutput=Su,H.get=Kt,H.getAgentNameFromMessage=ku,H.getChatToken=Ri,H.getCheckpointForMessage=Cx,H.getCurrentSettings=Eb,H.getDefaultApiConfig=Gu,H.getDefaultChatSettings=Yu,H.getMessageAttemptInfo=dc,H.getMessageDomKey=Ua,H.getPreviewForMessage=vi,H.getToolProgress=Bi,H.httpClient=Dt,H.hydrateHistorySnapshots=Xn,H.isEnvelope=pu,H.isFileLike=Li,H.loadStoredSettings=Xu,H.looksLikeMarkdown=yu,H.messageSignature=Fi,H.normalizeInterruptId=$i,H.normalizeMimeType=Eu,H.normalizeToolPayload=ju,H.normalizeToolPayloadValue=Cr,H.onChatTokenChanged=Mi,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=Ju,H.setChatToken=Rn,H.stringifyTool=Tu,H.toPlainObject=Pn,H.unwrap=Lt,H.useApi=On,H.useCheckpointIndex=fc,H.useFilePreview=df,H.useHasChatSession=Tb,H.useParsedMessageContent=ff,H.useShallowStableValue=Wu,H.useStream=Ui,H.useStreamingHook=Ui,H.useThreadHistoryState=Ou,H.useThreadManagerViewState=Nm,H.useThreadState=ro,H.useThreadStateUpdater=$u,H.useThreads=yr,H.useThreadsState=vu,H.useToolPayload=hf,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=Ud(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=Ud(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 Gd{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 Yd{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 ha,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Gd,this.slugger=new Yd}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,Hd(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 j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class vs{constructor(t){this.options=t||sr}preprocess(t){return t}postprocess(t){return t}}ac(vs,"passThroughHooks",new Set(["preprocess","postprocess"]));function gy(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 Xd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=gy(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(py(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},ey(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=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:se("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=b.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 vy="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:vy,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=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(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:se("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:se("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:se("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:se("text-sm text-muted-foreground",e),...t}));xa.displayName="CardDescription";const bs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:se("p-6 pt-0",e),...t}));bs.displayName="CardContent";const ef=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:se("flex items-center p-6 pt-0",e),...t}));ef.displayName="CardFooter";const xy=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=xy(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:se("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(Je,{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(Je,{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(Je,{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=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:se("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:se("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:se("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(Je,{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 by(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 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:x,defaultMessage:g,handleFileClick:v,uploadingFiles:y,messageRole:w,truncateUserMessages:C,userMessagePreviewLength:E,isUserExpanded:T,setIsUserExpanded:S,isCompactLayout:k,iconForeground:j,toolConfig:P,handleInterruptApprove:F,handleInterruptReject:D,handleInterruptAlternative:B,disableInterruptActions:G,isInterruptMessage:M}){const W=b.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"})]}),[]),z=by(i,(f??!0)&&p,m??0),A=b.useMemo(()=>z.filter(_=>_.type==="text"),[z]),I=b.useMemo(()=>A.map(_=>_.text??"").join(""),[A]),K=b.useMemo(()=>{if(!x)return null;const _=yy(I);return{stablePart:I.slice(0,_),tailPart:I.slice(_)}},[I,x]),Q=b.useMemo(()=>{if(!K)return null;const{stablePart:_,tailPart:U}=K;return!_&&!U?null:u.jsxs("div",{className:"space-y-2",children:[_?u.jsx(ir,{content:_,allowHtml:!1}):null,U?u.jsx(ir,{content:U,allowHtml:!1}):null]})},[K]),O=b.useMemo(()=>{if(!x)return z;const _=[];let U=!1;for(const J of z){if(J.type==="text"){U||(_.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),U=!0);continue}_.push(J)}return _},[z,x]),L=(x?O:z).filter(_=>_.type!=="interrupt"&&_.type!=="image_url"),$=()=>!l||l.length===0?null:u.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.map((_,U)=>{const J=_;return u.jsx("div",{className:"relative group",children:u.jsx("img",{src:J.url,alt:J.alt??"Image",loading:"lazy",onClick:()=>window.open(J.url,"_blank"),className:"h-20 w-20 object-cover rounded-md border border-border/50 cursor-pointer hover:opacity-90 transition-opacity"})},U)})}),X=b.useCallback(({part:_,i:U})=>{if(_.type==="text"){if(x)return null;const J=_.text??"",oe=J.trim(),ae=er(oe);return ae&&w!=="tool"?u.jsx(xs,{data:ae},U):w==="user"&&C&&oe.length>E?u.jsx(nf,{text:oe,expanded:T,onExpandedChange:S,previewLength:E,isCompact:k},U):u.jsx(ir,{content:J,allowHtml:!1},U)}if(_.type==="image_url")return null;if(_.type==="file"){const J=_,oe=J.name||"file";return u.jsxs("a",{href:J.url,onClick:ae=>v(ae,J,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(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[oe,y[U]?" (processing)":""]})]},U)}return null},[v,k,T,w,C,y,E,x,S]),R=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&&!R&&!p)return null;if(t){if(!n)return null;if(M&&d){const _=d.value,U=!G,J=F??(()=>{}),oe=D??(()=>{});return u.jsx(ba,{interruptPart:d,payload:_,onApprove:J,onReject:oe,onSelectAlternative:B,disabled:G,isActive:U})}return u.jsx(cp,{message:e,viewMode:r,expandable:o,isStreaming:s,toolConfig:P},e.id)}if(!g){const _=u.jsxs("div",{className:"space-y-2",children:[$(),L.map((U,J)=>x&&Sy(U)?Q?u.jsx("div",{className:"space-y-2",children:Q},`streaming-md-${J}`):null:u.jsx(X,{part:U,i:J},J))]});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[_,u.jsx(tf,{className:j})]}):_}return null}function wy(e){return e?!(lo(e,/```/g)||lo(e,/`/g)||lo(e,/\*\*/g)||lo(e,/__/g)||lo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function lo(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function yy(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(wy(e.slice(0,t)))return t;return 0}function Sy(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const Cy=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 of({className:e,variant:t,...n}){return u.jsx("div",{className:se(Cy({variant:t}),e),...n})}function sf({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:j,messageCreatedAt:P,copied:F}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:se("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:se("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(of,{variant:"outline",className:se("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:D=>{x&&(D.key==="Enter"||D.key===" ")&&(D.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(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.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:se("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(ue.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:se("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||j()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&P&&u.jsx("time",{className:se("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:se("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:se("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(ue.Copy,{className:se(F?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&w&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:w,className:se("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:se(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&C&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:C,className:se("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:se(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}function af(e){const{allowFileOpen:t,currentThreadId:n}=e,{fileApi:r}=On(),{toast:o}=da(),[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(j=>!j||typeof j!="object"||!((j.filename??"")===(g.name??""))?!1:typeof g.size=="number"&&typeof j.size=="number"?j.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 lf(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:bu(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:wu(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const cf="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(cf))continue;const s=o.slice(cf.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 uf(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 ws=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:j=[]}){const[P,F]=b.useState(!1),[D,B]=b.useState(!1),{currentThreadId:G}=yr(),{respondToInterrupt:M}=no(),[W,Y]=b.useState(!1),z=l==="phone"||l==="half-screen",A=t.role,I=A==="interrupt",K=A==="tool"||I,O=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:$}=m??{},X=b.useMemo(()=>!$||t.role!=="tool"?!1:$(t),[$,t.id,t.role]),[R,_]=b.useState(X?"preview":"expanded");b.useEffect(()=>{_(X?"preview":"expanded")},[X,t.id]);const U=b.useMemo(()=>t.role==="default_message"?t:null,[t]),J=!!U,oe=!(r&&A!=="user"),{uploadingFiles:ae,handleFileClick:Ee,fileViewerOpen:Se,currentFileInfo:Re,closeFileViewer:He}=af({allowFileOpen:oe,currentThreadId:G}),Fe=b.useMemo(()=>{switch(A){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))]"}},[A]),Ye=lf(t,U),{contentParts:Ue,imageParts:ot,fileParts:pt,textContent:ct,toolMeta:We,toolRaw:Me,isToolStreaming:Ke,interruptParts:Ae}=Ye,qe=v??x!==0,Xe=b.useMemo(()=>Ae.length?Ae[0]:null,[Ae]),Ct=b.useCallback(async()=>{const ee=K?Me:ct;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),F(!0),setTimeout(()=>F(!1),2e3),C==null||C(ee)}catch(de){console.error("Failed to copy:",de)}},[K,Me,ct,C]),Qe=b.useCallback(async(ee,he)=>{if(!Xe)return;if(!Li(Xe.id)){console.warn("Interrupt part missing id",Xe);return}Y(!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{Y(!1)}},[Xe,M]),Tt=b.useCallback(()=>Qe(!0),[Qe]),ht=b.useCallback(()=>Qe(!1),[Qe]),wt=b.useCallback((ee,he)=>{if(!he)return;const de={alternativeId:he.id??he.label??void 0,alternativeLabel:he.label};Qe(!0,de)},[Qe]),At=b.useCallback(()=>{if(!y||!t.id)return;const ee=(K?Me:ct)??"",he="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,ee,he)},[y,K,Me,ct,t]),Pt=b.useCallback(()=>{w==null||w(n)},[w,n]),mt=b.useCallback(()=>{const he=se(z?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Fe);switch(A){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})}},[z,Fe,A]),gt=b.useCallback(()=>{const ee="group relative mb-4 flex w-full";switch(A){case"user":return se(ee,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return se(ee,"justify-start");default:return ee}},[A]),Ht=b.useCallback(()=>{const ee=se("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",z&&"px-3 py-2 text-sm");if(J)return se(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(A){case"user":return se(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 se(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 se(ee,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return se(ee,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return se(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")}},[z,J,A]),Ve=X&&!I&&O,$e=b.useCallback(()=>{Ve&&_(ee=>ee==="expanded"?"preview":"expanded")},[Ve]),kt=I?"expanded":R,ut=(p||I)&&O,_t=u.jsx(rf,{message:t,isToolMessage:K,showToolMessages:ut,toolViewMode:kt,toolExpandable:X,toolConfig:{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:$},isToolStreaming:Ke,contentParts:Ue,textContent:ct,imageParts:ot,fileParts:pt,isStreamingMessage:r,defaultMessage:U,enableStreamingMarkdownBuffer:qe,renderStreamingMarkdown:g,streamingDebounceMs:x,handleFileClick:Ee,uploadingFiles:ae,messageRole:A,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:D,setIsUserExpanded:B,isCompactLayout:z,iconForeground:Fe,interruptPart:Xe,handleInterruptApprove:Tt,handleInterruptReject:ht,handleInterruptAlternative:wt,disableInterruptActions:W,isInterruptMessage:I}),xe=b.useMemo(()=>U?"Assistant":yu(t),[U,t]),Le=mt(),Be=A==="user"&&(T??1)>1&&typeof k=="function",st=(j==null?void 0:j.length)??0,tt=st>0&&S<st-1?j[S+1]:void 0,dt=st>0&&S>0?j[S-1]:void 0,et=b.useCallback(()=>{!tt||!k||k(tt.id,void 0,!!tt.isLatestAttempt)},[tt,k]),Z=b.useCallback(()=>{!dt||!k||k(dt.id,void 0,!!dt.isLatestAttempt)},[dt,k]);return K&&!p?null:J&&U?u.jsx("div",{className:se(gt(),f.container),children:u.jsxs("div",{className:se(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:se("h-4 w-4",Fe)}),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:se(gt(),f.container),children:u.jsxs("div",{className:se(Ht(),f.content),children:[u.jsx(sf,{showTimestamp:i,showAgentName:a,isToolMessage:K,iconForeground:Fe,agentName:xe,messageIcon:Le,customHeaderClass:f.header,customActionsClass:f.actions,isCompactLayout:z,showActions:s,isEditing:o,messageRole:A,toolViewMode:kt,toolExpandable:X,isInterruptMessage:I,toolMeta:We,onToggleToolView:$e,onCopy:Ct,onEdit:At,onRegenerate:Pt,showCheckpointControls:Be,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:et,handleNewerAttemptSelect:Z,messageCreatedAt:t.createdAt,copied:P}),u.jsx("div",{className:"relative",children:_t}),!(i||a||K)&&s&&!o&&u.jsxs("div",{className:se("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:se("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:se(P?"text-success":"text-current",z?"h-3 w-3":"h-4 w-4")})}),A==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:At,className:se("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:se("text-current",z?"h-3 w-3":"h-4 w-4")})}),A==="assistant"&&w&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Pt,className:se("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:se("text-current",z?"h-3 w-3":"h-4 w-4")})})]})]})}),Re&&u.jsx(Qw,{isOpen:Se,onClose:He,fileId:Re.id,fileName:Re.name,mimeType:Re.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,x,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)&&((x=e.customStyles)==null?void 0:x.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 Ey(e){e()}function pf(e,t){return n=>e(t(n))}function hf(e,t){return()=>e(t)}function Iy(e,t){return n=>e(t,n)}function wa(e){return e!==void 0}function Ny(...e){return()=>{e.map(Ey)}}function _r(){}function Ss(e,t){return t(e),e}function Ay(e,t){return t(e)}function it(...e){return e}function Ze(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 Ze(e,Iy(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 Te(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=jy(...t);return(r,o)=>{switch(r){case Pr:ya(e);return;case Bn:return Ze(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);Ze(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 jy(...e){return t=>e.reduceRight(Ay,t)}function Py(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=Ze(e,s),t):(r(),_r);case Pr:r(),n=null;return}}}function ie(e){let t=e;const n=ze();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 ze(){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(ze(),t=>ve(e,t))}function Ge(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=ze(),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);Ze(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),Ze(t,i)}}}function Ce(e,t=gf){return re(e,at(t))}function Sa(...e){return function(t,n){switch(t){case Pr:return;case Bn:return Ny(...e.map(r=>Ze(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=Ge(()=>{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 Ca(e,t,n).callbackRef}function Ca(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?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 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 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=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}=Ca(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=Ge(()=>{const e=ze(),t=ze(),n=ie(0),r=ze(),o=ie(0),s=ze(),i=ze(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),p=ze(),m=ze(),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 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 rt(e){return e===co}function uo(e,t){if(!rt(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(rt(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 rt(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 Rr(){return co}function Cs(e,t,n){if(rt(e))return[];const r=fn(e,t)[0];return $y(ka(e,r,n))}function Ta(e,t){if(rt(e))return co;const{k:n,l:r,r:o}=e;if(t===n){if(rt(r))return o;if(rt(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 rt(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function ka(e,t,n){if(rt(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(!rt(t)&&!rt(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(!rt(r)&&!rt(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 rt(e.r)?e.l:Ts(Nt(e,{r:wf(e.r)}))}function Ea(e){return rt(e)||e.lvl>e.r.lvl}function yf(e){return rt(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!rt(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function Ia(e){const{lvl:t,r:n}=e;return!rt(n)&&!rt(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 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=Ge(()=>({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 Fy(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!rt(e.groupOffsetTree)}function Aa({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=rt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),rt(e)){e=Qt(e,0,s);continue}const a=Cs(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=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 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}=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(Hy(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 Wy(e,t,n,r=0){return r>0&&(t=Math.max(t,Ef(e,r,Aa).offset)),bf(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&&rt(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}=ja(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 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 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=Ge(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Ot(r,0),s=ze(),i=ze(),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,Te(T=>T.length>0),De(g,f),fe(([T,S,k])=>{const j=T.reduce((P,F,D)=>Qt(P,F,po(F,S.offsetTree,k)||D),Rr());return{...S,groupIndices:T,groupOffsetTree:j}})),g),ve(re(r,De(g),Te(([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,Te(T=>T!==void 0&&rt(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)));Ze(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)}}),Ze(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,j=[],P=S.lastSize;if(k){const F=uo(S.sizeTree,0);let D=0,B=0;for(;D<T;){const M=S.groupIndices[B],W=S.groupIndices.length===B+1?1/0:S.groupIndices[B+1]-M-1;j.push({endIndex:M,size:F,startIndex:M}),j.push({endIndex:M+1+W-1,size:P,startIndex:M+1}),B++,D+=W+1}const G=cr(S.sizeTree);return D!==T&&G.shift(),G.reduce((M,{k:W,v:Y})=>{let z=M.ranges;return M.prevSize!==0&&(z=[...M.ranges,{endIndex:W+T-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:W+T,prevSize:Y,ranges:z}},{prevIndex:T,prevSize:0,ranges:j}).ranges}return cr(S.sizeTree).reduce((F,{k:D,v:B})=>({prevIndex:D+T,prevSize:B,ranges:[...F.ranges,{endIndex:D+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 j=-T;return po(j,S,k)})));return ve(re(i,De(g,f),fe(([T,S,k])=>{if(S.groupIndices.length>0){if(rt(S.sizeTree))return S;let j=Rr();const P=bt(v);let F=0,D=0,B=0;for(;F<-T;){B=P[D];const G=P[D+1]-B-1;D++,F+=G+1}if(j=cr(S.sizeTree).reduce((G,{k:M,v:W})=>Qt(G,Math.max(0,M+T),W),j),F!==-T){const G=uo(S.sizeTree,B);j=Qt(j,0,G);const M=fn(S.sizeTree,-T+1)[1];j=Qt(j,1,M)}return{...S,sizeTree:j,...ja(S.offsetTree,0,j,k)}}else{const j=cr(S.sizeTree).reduce((P,{k:F,v:D})=>Qt(P,Math.max(0,F+T),D),Rr());return{...S,sizeTree:j,...ja(S.offsetTree,0,j,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 Xy(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const jf=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),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),Te(([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=Ge(([{log:e}])=>{const t=ie(!1),n=Zt(re(t,Te(r=>r),at()));return Ze(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=Ge(([{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=ze(),x=ze(),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,j,P,F,D],B,G,M])=>{const W=Pf(E),{align:Y,behavior:z,offset:A}=W,I=k-1,K=Nf(W,T,I);let Q=po(K,T.offsetTree,B)+P;Y==="end"?(Q+=G+fn(T.sizeTree,K)[1]-S+M,K===I&&(Q+=F)):Y==="center"?Q+=(G+fn(T.sizeTree,K)[1]-S+M)/2:Q-=j,A&&(Q+=A);const O=q=>{C(),q?(D("retrying to scroll to",{location:E},qt.DEBUG),_e(f,E)):(_e(x,!0),D("list did not change, scroll successful",{},qt.DEBUG))};if(C(),z==="smooth"){let q=!1;w=Ze(t,L=>{q=q||L}),v=dn(d,()=>{O(q)})}else v=dn(re(t,Zy(150)),O);return y=setTimeout(()=>{C()},1200),_e(l,!0),D("scrolling from index to",{behavior:z,index:K,top:Q},qt.DEBUG),{behavior:z,top:Q}})),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 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=Ge(([{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),Te(([d,p])=>!!p),bn(!1)),a),ve(re(i,De(l),Te(([d,p])=>!!p),bn(!1)),c),Ze(re(St(t,i),De(a,n,e,c),Te(([[,d],p,{sizeTree:m},f,x])=>d&&(!rt(m)||wa(f))&&!p&&!x),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",Qy="none",e0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},t0=0,xo=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=ze(),c=ze(),d=ie(4),p=ie(t0),m=Ot(re(Sa(re(Ce(o),ar(1),bn(!0)),re(Ce(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(Ce(o),Ce(p)),fe(([w,C])=>w<=C),at()),a),ve(re(a,Nn(50)),c);const x=Zt(re(St(r,Ce(s),Ce(t),Ce(e),Ce(d)),wn((w,[{scrollHeight:C,scrollTop:E},T,S,k,j])=>{const P=E+T-C>-j,F={scrollHeight:C,scrollTop:E,viewportHeight:T};if(P){let B,G;return E>w.state.scrollTop?(B="SCROLLED_DOWN",G=w.state.scrollTop-E):(B="SIZE_DECREASED",G=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:G,state:F}}let D;return F.scrollHeight>w.state.scrollHeight?D="SIZE_INCREASED":T<w.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:F}},e0),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}),Te(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,Te(w=>!w),bn(0)),y),ve(re(o,Nn(100),De(m),Te(([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)),Is="top",Ns="bottom",Rf="none";function Mf(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 Ra=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=ie(0),a=ie(0),l=ie(0),c=Ot(re(St(Ce(r),Ce(o),Ce(n),Ce(s,fo),Ce(l),Ce(i),Ce(t),Ce(e),Ce(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=Rf;const j=Of(C,Is),P=Of(C,Ns);return f-=w,f+=m+y,x+=m+y,x-=w,f>d+T-j&&(k=go),x<d-S+p+P&&(k=vo),k!==Rf?[Math.max(E-m-Mf(g,Is,k)-j,0),E-S-y+p+Mf(g,Ns,k)+P]:null}),Te(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(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 Ma={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,x=m-d;return{bottom:d,firstItemIndex:s,items:Lf(e,o,s),offsetBottom:x,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=Ge(([{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=ze();ve(s.topItemsIndexes,g);const w=Ot(re(St(f,x,Ce(l,fo),Ce(o),Ce(r),Ce(c),d,Ce(g),Ce(t),Ce(n),e),Te(([S,k,,j,,,,,,,P])=>{const F=P&&P.length!==j;return S&&!k&&!F}),fe(([,,[S,k],j,P,F,D,B,G,M,W])=>{const Y=P,{offsetTree:z,sizeTree:A}=Y,I=bt(v);if(j===0)return{...Ma,totalCount:j};if(S===0&&k===0)return I===0?{...Ma,totalCount:j}:Df(I,F,P,G,M,W||[]);if(rt(A))return I>0?null:As(n0(_a(F,j),Y,W),[],j,M,Y,G);const K=[];if(B.length>0){const $=B[0],X=B[B.length-1];let R=0;for(const _ of Cs(A,$,X)){const U=_.value,J=Math.max(_.start,$),oe=Math.min(_.end,X);for(let ae=J;ae<=oe;ae++)K.push({data:W==null?void 0:W[ae],index:ae,offset:R,size:U}),R+=U}}if(!D)return As([],K,j,M,Y,G);const Q=B.length>0?B[B.length-1]+1:0,O=Wy(z,S,k,Q);if(O.length===0)return null;const q=j-1,L=Ss([],$=>{for(const X of O){const R=X.value;let _=R.offset,U=X.start;const J=R.size;if(R.offset<S){U+=Math.floor((S-R.offset+M)/(J+M));const ae=U-X.start;_+=ae*J+ae*M}U<Q&&(_+=(Q-U)*J,U=Q);const oe=Math.min(X.end,q);for(let ae=U;ae<=oe&&!(_>=k);ae++)$.push({data:W==null?void 0:W[ae],index:ae,offset:_,size:J}),_+=J+M}});return As(L,K,j,M,Y,G)}),Te(S=>S!==null),at()),Ma);ve(re(e,Te(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,Te(({items:S})=>S.length>0),De(o,e),Te(([{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),Te(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),fe(({items:S})=>S[0].index),at())),T=Zt(re(w,Te(({items:S})=>S.length>0),fe(({items:S})=>{let k=0,j=S.length-1;for(;S[k].type==="group"&&k<j;)k++;for(;S[j].type==="group"&&j>k;)j--;return{endIndex:S[j].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,Ra,mo,ho,xo,Un,Na),{singleton:!0}),$f=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),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(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Bt,ur),{singleton:!0}),r0=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=Ot(re(St(n,e,t),Te(([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=Ge(()=>({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,Bf=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=ze();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,...j}=p,P=Nf(p,m,x-1),F=po(P,m.offsetTree,C)+g+v,D=F+fn(m.sizeTree,P)[1],B=w+v,G=w+f-y,M=S({itemBottom:D,itemTop:F,locationParams:{align:E,behavior:T,...j},viewportBottom:G,viewportTop:B});return M?k&&dn(re(i,Te(W=>!W),ar(bt(i)?1:2)),k):k&&k(),M}),Te(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 s0=(e,t)=>typeof e=="function"?zf(e(t)):t&&zf(e),i0=Ge(([{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=ze();let v=null;function y(T){_e(i,{align:"end",behavior:T,index:"LAST"})}Ze(re(St(re(Ce(t),ar(1)),l),De(Ce(x),s,a,p),fe(([[T,S],k,j,P,F])=>{let D=S&&P,B="auto";return D&&(B=s0(k,j||F),D=D&&!!B),{followOutputBehavior:B,shouldFollow:D,totalCount:T}}),Te(({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)}Ze(re(St(Ce(x),t,c),Te(([T,,S])=>T&&S),wn(({value:T},[,S])=>({refreshed:T===S,value:S}),{refreshed:!1,value:0}),Te(({refreshed:T})=>T),De(x,t)),([,T])=>{bt(a)&&w(T!==!1)}),Ze(g,()=>{w(bt(x)!==!1)}),Ze(St(Ce(x),o),([T,S])=>{T&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=ie(null),E=ze();return ve(Sa(re(Ce(r),fe(T=>{var S;return(S=T==null?void 0:T.length)!=null?S:0})),re(Ce(t))),E),Ze(re(St(re(E,ar(1)),l),De(Ce(C),a,p,m),fe(([[T,S],k,j,P,F])=>S&&j&&(k==null?void 0:k({context:F,totalCount:T,scrollingInProgress:P}))),Te(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,Ff,Bf)),a0=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(re(a,De(s),Te(([,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}),l0=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return Ze(re(e,De(r),Te(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(re(n,ar(1),Te(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{_e(t,o)})})}),{initialScrollTop:r}},it(Un,Bt,ur),{singleton:!0}),Hf=Ge(([{scrollVelocity:e}])=>{const t=ie(!1),n=ze(),r=ie(!1);return ve(re(e,De(r,t,n),Te(([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),Ze(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=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),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=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ze(),d=ie(void 0),p=ie(null),m=ie(null);return ve(a,p),ve(l,m),Ze(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,Te(wa),fe(u0)),o),ve(re(s,De(d),Te(([,f])=>f!==void 0),at(),fe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(yn,Bt,mo,Un,Oa));function u0(e){return{align:"start",index:0,offset:e.scrollTop}}const d0=Ge(([{topItemsIndexes:e}])=>{const t=ie(0);return ve(re(t,Te(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 f0=Uf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),p0=Ge(([{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},j])=>{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+=j))),[F,T,k,P]},[0,[],0,0]),Te(([y])=>y!==0),De(r,a,n,o,f,x),Te(([,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 Ze(re(g,De(e,s)),([y,w,C])=>{C&&f0()?_e(e,w-y):v(-y)}),Ze(re(St(Ot(s,!1),e,x),Te(([y,w,C])=>!y&&!C&&w!==0),fe(([y,w])=>w),Nn(1)),v),ve(re(p,fe(y=>({top:-y}))),t),Ze(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 j=uo(E,0);let P=0,F=0;for(;P<y;){P++,k+=j;let D=w.length===F+1?1/0:w[F+1]-w[F]-1;P+D>y&&(k-=j,D=y-P+1),P+=D,k+=S(D),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,Na)),h0=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it(Ra,a0,Un,Hf,$f,l0,r0,Oa,Bf,zn,Ff)),Wf=Ge(([{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:j},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:j,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,jf,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 js=typeof document<"u"?b.useLayoutEffect:b.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=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]=Py(v[t.events[w]]),y),{})}const p=b.forwardRef((v,y)=>{const{children:w,...C}=v,[E]=b.useState(()=>Ss(Ry(e),k=>{l(k,C)})),[T]=b.useState(hf(d,E));js(()=>{for(const k of i)k in C&&Ze(T[k],C[k]);return()=>{Object.values(T).map(ya)}},[C,T,E]),js(()=>{l(E,C)}),b.useImperativeHandle(y,ff(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=>Ze(y,C),[y]);return b.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},x=v=>{const y=b.useContext(a)[v],[w,C]=b.useState(hf(bt,y));return js(()=>Ze(y,E=>{E!==w&&C(ff(E))}),[y,w]),w},g=b.version.startsWith("18")?f:x;return{Component:p,useEmitter:(v,y)=>{const w=b.useContext(a)[v];js(()=>Ze(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Kf=b.createContext(void 0),qf=b.createContext(void 0),Gf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Da(e){return"self"in e}function g0(e){return"body"in e}function Yf(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)||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,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;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}),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 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 v0=Ge(()=>{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")}}),x0=Ge(([e,t])=>({...e,...t}),it(Wf,v0)),b0=({height:e})=>u.jsx("div",{style:{height:e}}),w0={overflowAnchor:"none",position:$a(),zIndex:1},Jf={overflowAnchor:"none"},y0={...Jf,display:"inline-block",height:"100%"},Zf=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);Ba("deviation",M=>{y!==M&&w(M)});const C=Ne("EmptyPlaceholder"),E=Ne("ScrollSeekPlaceholder")||b0,T=Ne("ListComponent"),S=Ne("ItemComponent"),k=Ne("GroupComponent"),j=Ne("computeItemKey"),P=Ne("isSeeking"),F=Ne("groupIndices").length>0,D=Ne("alignToBottom"),B=Ne("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:D?"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:G,children:(e?t.topItems:t.items).map(M=>{const W=M.originalIndex,Y=j(W+t.firstItemIndex,M.data,c);return P?b.createElement(E,{...Dt(E,c),height:M.size,index:M.index,key:Y,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?b.createElement(k,{...Dt(k,c),"data-index":W,"data-item-index":M.index,"data-known-size":M.size,key:Y,style:w0},d(M.index,c)):b.createElement(S,{...Dt(S,c),...k0(S,M.data),"data-index":W,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:Y,style:g?y0:Jf},F?l(M.index,M.groupIndex,M.data,c):l(M.index,M.data,c))})})}),S0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},C0={outline:"none",overflowX:"auto",position:"relative"},Ps=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),T0={position:$a(),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 Qf({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}=Yf(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 ep({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}=Yf(a,c,l,x,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 N0=({children:e})=>{const t=b.useContext(Kf),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=b.useMemo(()=>pf(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:Ps(o),children:e})},A0=({children:e})=>{const t=b.useContext(Kf),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ne("customScrollParent"),s=xf(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:Ps(i),children:e})},j0=({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})},P0=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(j0,{children:u.jsx(Zf,{showTopList:!0})}),u.jsxs(r||t?A0:N0,{children:[u.jsx(E0,{}),u.jsx(Zf,{}),u.jsx(I0,{})]})]})}),{Component:_0,useEmitter:Ba,useEmitterValue:Ne,usePublisher:rn}=Vf(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"}},P0),R0=Qf({useEmitter:Ba,useEmitterValue:Ne,usePublisher:rn}),M0=ep({useEmitter:Ba,useEmitterValue:Ne,usePublisher:rn}),O0=_0;it(Wf,Ge(()=>{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},D0={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 L0(e){return{...D0,items:e}}function Rs(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=Ge(([{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),j=ie(tp),P=ie({height:0,width:0}),F=ie({height:0,width:0}),D=ze(),B=ze(),G=ie(0),M=ie(null),W=ie({column:0,row:0}),Y=ze(),z=ze(),A=ie(!1),I=ie(0),K=ie(!0),Q=ie(!1),O=ie(!1);Ze(re(x,De(I),Te(([_,U])=>!!U)),()=>{_e(K,!1)}),Ze(re(St(x,K,F,P,I,Q),Te(([_,U,J,oe,,ae])=>_&&!U&&J.height!==0&&oe.height!==0&&!ae)),([,,,,_])=>{_e(Q,!0),Pa(1,()=>{_e(D,_)}),dn(re(c),()=>{_e(t,[0,0]),_e(K,!0)})}),ve(re(z,Te(_=>_!=null&&_.scrollTop>0),bn(0)),k),Ze(re(x,De(z),Te(([,_])=>_!=null)),([,_])=>{_&&(_e(P,_.viewport),_e(F,_.item),_e(W,_.gap),_.scrollTop>0&&(_e(A,!0),dn(re(c,ar(1)),U=>{_e(A,!1)}),_e(l,{top:_.scrollTop})))}),ve(re(P,fe(({height:_})=>_)),p),ve(re(St(Ce(P,Rs),Ce(F,Rs),Ce(W,(_,U)=>_&&_.column===U.column&&_.row===U.row),Ce(c)),fe(([_,U,J,oe])=>({gap:J,item:U,scrollTop:oe,viewport:_}))),Y),ve(re(St(Ce(S),r,Ce(W,$0),Ce(F,Rs),Ce(P,Rs),Ce(M),Ce(k),Ce(A),Ce(K),Ce(I)),Te(([,,,,,,,_])=>!_),fe(([_,[U,J],oe,ae,Ee,Se,Re,,He,Fe])=>{const{column:Ye,row:Ue}=oe,{height:ot,width:pt}=ae,{width:ct}=Ee;if(Re===0&&(_===0||ct===0))return tp;if(pt===0){const Tt=_a(Fe,_),ht=Tt+Math.max(Re-1,0);return L0(op(Tt,ht,Se))}const We=sp(ct,pt,Ye);let Me,Ke;He?U===0&&J===0&&Re>0?(Me=0,Ke=Re-1):(Me=We*_s((U+Ue)/(ot+Ue)),Ke=We*np((J+Ue)/(ot+Ue))-1,Ke=za(_-1,bo(Ke,We-1)),Me=za(Ke,bo(0,Me))):(Me=0,Ke=-1);const Ae=op(Me,Ke,Se),{bottom:qe,top:Xe}=ip(Ee,oe,ae,Ae),Ct=np(_/We),Qe=Ct*ot+(Ct-1)*Ue-qe;return{bottom:qe,itemHeight:ot,items:Ae,itemWidth:pt,offsetBottom:Qe,offsetTop:Xe,top:Xe}})),j),ve(re(M,Te(_=>_!==null),fe(_=>_.length)),S),ve(re(St(P,F,j,W),Te(([_,U,{items:J}])=>J.length>0&&U.height!==0&&_.height!==0),fe(([_,U,{items:J},oe])=>{const{bottom:ae,top:Ee}=ip(_,oe,U,J);return[Ee,ae]}),at(fo)),t);const q=ie(!1);ve(re(c,De(q),fe(([_,U])=>U||_!==0)),q);const L=Zt(re(St(j,S),Te(([{items:_}])=>_.length>0),De(q),Te(([[_,U],J])=>{const oe=_.items[_.items.length-1].index===U-1;return(J||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===U)&&oe}),fe(([[,_]])=>_-1),at())),$=Zt(re(Ce(j),Te(({items:_})=>_.length>0&&_[0].index===0),bn(0),at())),X=Zt(re(Ce(j),De(A),Te(([{items:_},U])=>_.length>0&&!U),fe(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),at(kf),Nn(0)));ve(X,f.scrollSeekRangeChanged),ve(re(D,De(P,F,S,W),fe(([_,U,J,oe,ae])=>{const Ee=Pf(_),{align:Se,behavior:Re,offset:He}=Ee;let Fe=Ee.index;Fe==="LAST"&&(Fe=oe-1),Fe=bo(0,Fe,za(oe-1,Fe));let Ye=Ha(U,ae,J,Fe);return Se==="end"?Ye=rp(Ye-U.height+J.height):Se==="center"&&(Ye=rp(Ye-U.height/2+J.height/2)),He&&(Ye+=He),{behavior:Re,top:Ye}})),l);const R=Ot(re(j,fe(_=>_.offsetBottom+_.bottom)),0);return ve(re(E,fe(_=>({height:_.visibleHeight,width:_.visibleWidth}))),P),{customScrollParent:v,data:M,deviation:G,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:F,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:D,scrollTop:c,smoothScrollTargetReached:d,totalCount:S,useWindowScroll:y,viewportDimensions:P,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E,...f,gridState:j,horizontalDirection:O,initialTopMostItemIndex:I,totalListHeight:R,...m,endReached:L,propsReady:g,rangeChanged:X,startReached:$,stateChanged:Y,stateRestoreInProgress:A,...T}},it(Ra,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 B0=Ge(()=>{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(Ce(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),z0=Ge(([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: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]),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(qf),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:Ps(!1),children:e})},K0=({children:e})=>{const t=b.useContext(qf),n=on("windowViewportRect"),r=on("itemDimensions"),o=lt("customScrollParent"),s=xf(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:Ps(!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:ap,useEmitterValue:lt,usePublisher:on}=Vf(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=Qf({useEmitter:ap,useEmitterValue:lt,usePublisher:on}),Y0=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 X0={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},Ua=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Wa=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=Ua(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming||o===t.id&&t.role==="assistant",k=f??X0,j=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:P,attemptIndex:F,attempts:D}=b.useMemo(()=>dc(t.id,j,k),[t.id,j,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(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:P,attemptIndex:F,attemptMetas:D,onSelectCheckpoint:x,customStyles:B,toolConfig:y})})});Wa.displayName="MessageRow";const Va=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:j=!1,getMessageCustomStyles:P,getInterruptOptions:F},D)=>{const B=b.useRef(null),G=b.useRef(null),M=b.useRef(!1),W=b.useRef(!1),Y=e,z=b.useMemo(()=>{const R=n&&Y.some(U=>U.id===n);return k&&(t||j)&&!R&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y},[Y,t,n,k,j]),A=b.useMemo(()=>w?z:z.filter(R=>(R==null?void 0:R.role)!=="tool"),[z,w]),I=b.useCallback(R=>{v&&v(!R),y&&y(R)},[v,y]),K=b.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),Q=b.useMemo(()=>!x||g?!1:"auto",[x,g]),O=b.useMemo(()=>{if(typeof f!="string")return null;const R=f.trim();return!R||A&&A.length>0?null:{id:"default-message",role:"default_message",content:R,createdAt:new Date().toISOString()}},[f,A]),q=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),L=()=>{if(O){const R=P==null?void 0:P(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:R,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!"})},$=A.length,X=$>0;return b.useEffect(()=>{var R,_;if($===0){W.current=!1;return}if(!W.current)if(W.current=!0,B.current&&A.length>0){const U=A.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},[$,A.length]),b.useImperativeHandle(D,()=>({scrollToLatest:()=>{var R,_;if(B.current&&A.length>0){const U=A.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},scrollToTop:()=>{var R,_;B.current&&A.length>0?(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:0,align:"start",behavior:"auto"}):G.current&&(G.current.scrollTop=0)}}),[A]),u.jsx("div",{className:q,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:X?u.jsx(O0,{ref:R=>{B.current=R},scrollerRef:R=>{G.current=R instanceof HTMLDivElement?R:null},data:A,followOutput:Q,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{K&&K()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,_)=>Ua(_,R),itemContent:(R,_)=>u.jsx(Wa,{message:_,index:R,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()})})});Va.displayName="MessageList";function cp({message:e,viewMode:t,isStreaming:n=!1,toolConfig:r,expandable:o=!1}){var F;const s=Go(e),i=e.artifact??null,a=uf(e),c=(a?Eu(a):null)??a,d=e.content.find(D=>D.type!=="tool_call"),p=D=>{if(D==null)return null;const B=typeof D=="string"?er(D)??D:D;if(B&&typeof B=="object")return u.jsx(xs,{data:B});const G=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:G})},m=D=>{if(D==null)return null;const{content:B,isMarkdown:G}=xu(D);return G?u.jsx(ir,{content:B,className:"text-current"}):p(D)},f=D=>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:D})]}),x=()=>{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 W=nr(M);return m(W)}const D=Sr(d),B=nr(D);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 D=(c==null?void 0:c.kind)??(a==null?void 0:a.kind);if(D){const B=y[D];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,j=((F=(()=>{if(!w)return;const D=i==null?void 0:i.type;if(typeof D=="string"){const B=w[D];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&&(j??u.jsx(Zd,{artifact:i,idx:0})),u.jsx(Qd,{message:e,isStreaming:n}),T?P:null]})}function Ms(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=Oe(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=Oe(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 Os(e){const t=h.useContext(J0);return e||t||"ltr"}const Z0=["top","right","bottom","left"],Wn=Math.min,en=Math.max,Ds=Math.round,Ls=Math.floor,Sn=e=>({x:e,y:e}),Q0={left:"right",right:"left",bottom:"top",top:"bottom"},eS={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 Mr(e){return e.split("-")[1]}function qa(e){return e==="x"?"y":"x"}function Ga(e){return e==="y"?"height":"width"}const tS=new Set(["top","bottom"]);function Cn(e){return tS.has(jn(e))?"y":"x"}function Ya(e){return qa(Cn(e))}function nS(e,t,n){n===void 0&&(n=!1);const r=Mr(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 rS(e){const t=$s(e);return[Xa(e),t,Xa(t)]}function Xa(e){return e.replace(/start|end/g,t=>eS[t])}const up=["left","right"],dp=["right","left"],oS=["top","bottom"],sS=["bottom","top"];function iS(e,t,n){switch(e){case"top":case"bottom":return n?t?dp:up:t?up:dp;case"left":case"right":return t?oS:sS;default:return[]}}function aS(e,t,n,r){const o=Mr(e);let s=iS(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=>Q0[t])}function lS(e){return{top:0,right:0,bottom:0,left:0,...e}}function fp(e){return typeof e!="number"?lS(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(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}=pp(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}=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),x=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+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=fp(d),m={x:n,y:r},f=Ya(o),x=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[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 j=E/2-T/2,P=k/2-g[x]/2-1,F=Wn(p[y],P),D=Wn(p[w],P),B=F,G=k-g[x]-D,M=k/2-g[x]/2+j,W=Ka(B,M,G),Y=!l.arrow&&Mr(o)!=null&&M!==W&&s.reference[x]/2-(M<B?F:D)-g[x]/2<0,z=Y?M<B?M-B:M-G:0;return{[f]:m[f]+z,data:{[f]:W,centerOffset:M-W-z,...Y&&{alignmentOffset:z}},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=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)]:rS(a)),S=x!=="none";!m&&S&&T.push(...aS(a,g,x,E));const k=[a,...T],j=await wo(t,v),P=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(j[y]),p){const M=nS(o,i,E);P.push(j[M[0]],j[M[1]])}if(F=[...F,{placement:o,overflows:P}],!P.every(M=>M<=0)){var D,B;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,W=k[M];if(W&&(!(p==="alignment"?w!==Cn(W):!1)||F.every(A=>Cn(A.placement)===w?A.overflows[0]>0:!0)))return{data:{index:M,overflows:F},reset:{placement:W}};let Y=(B=F.filter(z=>z.overflows[0]<=0).sort((z,A)=>z.overflows[1]-A.overflows[1])[0])==null?void 0:B.placement;if(!Y)switch(f){case"bestFit":{var G;const z=(G=F.filter(A=>{if(S){const I=Cn(A.placement);return I===w||I==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(I=>I>0).reduce((I,K)=>I+K,0)]).sort((A,I)=>A[1]-I[1])[0])==null?void 0:G[0];z&&(Y=z);break}case"initialPlacement":Y=a;break}if(o!==Y)return{reset:{placement:Y}}}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 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=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 pS(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=Mr(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: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(jn(o)),m=qa(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=Ka(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=Ka(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=qa(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=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);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=jn(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,j=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),S&&!m){const F=en(d.left,0),D=en(d.right,0),B=en(d.top,0),G=en(d.bottom,0);f?j=x-2*(F!==0||D!==0?F+D:en(d.left,d.right)):k=g-2*(B!==0||G!==0?B+G:en(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:k});const P=await i.getDimensions(a.floating);return x!==P.width||g!==P.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 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 zs(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 Ja(e){const t=Za(),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(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 ES=new Set(["html","body","#document"]);function Dr(e){return ES.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 IS=Sn(0);function yp(e){const t=tn(e);return!Za()||!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=el(e);let i=Sn(1);t&&(r?pn(r)&&(i=Lr(r)):i=Lr(e));const a=NS(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 x=m,g=Qa(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=Qa(x)}}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 AS(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 jS(e){return Array.from(e.getClientRects())}function PS(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 _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=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,x=Math.abs(r.clientWidth-p.clientWidth-f);x<=Cp&&(s-=x)}else c<=Cp&&(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 Tp(e,t,n){let r;if(t==="viewport")r=_S(e,n);else if(t==="document")r=PS(Tn(e));else if(pn(t))r=MS(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 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=Ja(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&RS.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 DS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zs(t)?[]:OS(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 LS(e){const{width:t,height:n}=wp(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=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&&wS(r)&&tl(r);)r=Ep(r,t);return r&&Dr(r)&&tl(r)&&!Ja(r)?n:r||kS(e)||n}const FS=async function(e){const t=this.getOffsetParent||Ip,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:Ip,getElementRects:FS,getClientRects:jS,getDimensions:LS,getScale:Lr,isElement:pn,isRTL:BS};function Np(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=Ls(p),g=Ls(o.clientWidth-(d+m)),v=Ls(o.clientHeight-(p+f)),y=Ls(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&&!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 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=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?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&&!Np(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,Ap=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(){},Ws=JS?b.useLayoutEffect:ZS;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 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);Vs(m,r)||f(r);const[x,g]=h.useState(null),[v,y]=h.useState(null),w=h.useCallback(A=>{A!==S.current&&(S.current=A,g(A))},[]),C=h.useCallback(A=>{A!==k.current&&(k.current=A,y(A))},[]),E=s||x,T=i||v,S=h.useRef(null),k=h.useRef(null),j=h.useRef(d),P=l!=null,F=nl(l),D=nl(o),B=nl(c),G=h.useCallback(()=>{if(!S.current||!k.current)return;const A={placement:t,strategy:n,middleware:m};D.current&&(A.platform=D.current),XS(S.current,k.current,A).then(I=>{const K={...I,isPositioned:B.current!==!1};M.current&&!Vs(j.current,K)&&(j.current=K,qr.flushSync(()=>{p(K)}))})},[m,t,n,D,B]);Ws(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,p(A=>({...A,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(F.current)return F.current(E,T,G);G()}},[E,T,G,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]),z=h.useMemo(()=>{const A={position:n,left:0,top:0};if(!Y.floating)return A;const I=Pp(Y.floating,d.x),K=Pp(Y.floating,d.y);return a?{...A,transform:"translate("+I+"px, "+K+"px)",...jp(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:K}},[n,a,Y.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:G,refs:W,elements:Y,floatingStyles:z}),[d,G,W,Y,z])}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?Ap({element:r.current,padding:o}).fn(n):{}:r?Ap({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",_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=lC;var cC=_p;function Rp(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",[Mp,$r]=nn(rl),[uC,Op]=Mp(rl),Dp=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(uC,{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=Oe(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",[dC,fC]=Mp(ol),Fp=h.forwardRef((e,t)=>{var R,_,U,J,oe,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=Op(ol,n),[y,w]=h.useState(null),C=Oe(t,Ee=>w(Ee)),[E,T]=h.useState(null),S=Rp(E),k=(S==null?void 0:S.width)??0,j=(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},D=Array.isArray(c)?c:[c],B=D.length>0,G={padding:F,boundary:D.filter(hC),altBoundary:B},{refs:M,floatingStyles:W,placement:Y,isPositioned:z,middlewareData:A}=QS({strategy:"fixed",placement:P,whileElementsMounted:(...Ee)=>US(...Ee,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[tC({mainAxis:o+j,alignmentAxis:i}),l&&nC({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?rC():void 0,...G}),l&&oC({...G}),sC({...G,apply:({elements:Ee,rects:Se,availableWidth:Re,availableHeight:He})=>{const{width:Fe,height:Ye}=Se.reference,Ue=Ee.floating.style;Ue.setProperty("--radix-popper-available-width",`${Re}px`),Ue.setProperty("--radix-popper-available-height",`${He}px`),Ue.setProperty("--radix-popper-anchor-width",`${Fe}px`),Ue.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),E&&aC({element:E,padding:a}),mC({arrowWidth:k,arrowHeight:j}),m&&iC({strategy:"referenceHidden",...G})]}),[I,K]=Hp(Y),Q=xt(x);It(()=>{z&&(Q==null||Q())},[z,Q]);const O=(R=A.arrow)==null?void 0:R.x,q=(_=A.arrow)==null?void 0:_.y,L=((U=A.arrow)==null?void 0:U.centerOffset)!==0,[$,X]=h.useState();return It(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:z?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(J=A.transformOrigin)==null?void 0:J.x,(oe=A.transformOrigin)==null?void 0:oe.y].join(" "),...((ae=A.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(dC,{scope:n,placedSide:I,onArrowChange:T,arrowX:O,arrowY:q,shouldHideArrow:L,children:u.jsx(me.div,{"data-side":I,"data-align":K,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Fp.displayName=ol;var Bp="PopperArrow",pC={top:"bottom",right:"left",bottom:"top",left:"right"},zp=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=fC(Bp,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"}})})});zp.displayName=Bp;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]=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 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 Hp(e){const[t,n="center"]=e.split("-");return[t,n]}var sl=Dp,il=$p,al=Fp,ll=zp,cl="rovingFocusGroup.onEntryFocus",gC={bubbles:!1,cancelable:!0},Co="RovingFocusGroup",[ul,Up,vC]=Ms(Co),[xC,Wp]=nn(Co,[vC]),[bC,wC]=xC(Co),Vp=h.forwardRef((e,t)=>u.jsx(ul.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ul.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(yC,{...e,ref:t})})}));Vp.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=Oe(t,m),x=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 j=m.current;if(j)return j.addEventListener(cl,C),()=>j.removeEventListener(cl,C)},[C]),u.jsx(bC,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(j=>v(j),[v]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(j=>j+1),[]),onFocusableItemRemove:h.useCallback(()=>k(j=>j-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,j=>{const P=!T.current;if(j.target===j.currentTarget&&P&&!y){const F=new CustomEvent(cl,gC);if(j.currentTarget.dispatchEvent(F),!F.defaultPrevented){const D=E().filter(Y=>Y.focusable),B=D.find(Y=>Y.active),G=D.find(Y=>Y.id===g),W=[B,G,...D].filter(Boolean).map(Y=>Y.ref.current);Gp(W,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=wC(Kp,n),p=d.currentTabStopId===c,m=Up(n),{onFocusableItemAdd:f,onFocusableItemRemove:x,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>x()},[r,f,x]),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=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(()=>Gp(C))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});qp.displayName=Kp;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 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 kC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var EC=Vp,IC=qp,dl=["Enter"," "],NC=["ArrowDown","PageUp","Home"],Yp=["ArrowUp","PageDown","End"],AC=[...NC,...Yp],jC={ltr:[...dl,"ArrowRight"],rtl:[...dl,"ArrowLeft"]},PC={ltr:["ArrowLeft"],rtl:["ArrowRight"]},To="Menu",[ko,_C,RC]=Ms(To),[fr,Xp]=nn(To,[RC,$r,Wp]),Ks=$r(),Jp=Wp(),[MC,pr]=fr(To),[OC,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",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(sl,{...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})})})};Zp.displayName=To;var DC="MenuAnchor",fl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(il,{...o,...r,ref:t})});fl.displayName=DC;var pl="MenuPortal",[LC,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(LC,{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",[$C,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(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=Oe(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)})}),BC=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)})}),zC=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:x,...g}=e,v=pr(sn,n),y=Eo(sn,n),w=Ks(n),C=Jp(n),E=_C(n),[T,S]=h.useState(null),k=h.useRef(null),j=Oe(t,k,v.onContentChange),P=h.useRef(0),F=h.useRef(""),D=h.useRef(0),B=h.useRef(null),G=h.useRef("right"),M=h.useRef(0),W=x?rs:h.Fragment,Y=x?{as:zC,allowPinchZoom:!0}:void 0,z=I=>{var R,_;const K=F.current+I,Q=E().filter(U=>!U.disabled),O=document.activeElement,q=(R=Q.find(U=>U.ref.current===O))==null?void 0:R.textValue,L=Q.map(U=>U.textValue),$=QC(L,K,q),X=(_=Q.find(U=>U.textValue===$))==null?void 0:_.ref.current;(function U(J){F.current=J,window.clearTimeout(P.current),J!==""&&(P.current=window.setTimeout(()=>U(""),1e3))})(K),X&&setTimeout(()=>X.focus())};h.useEffect(()=>()=>window.clearTimeout(P.current),[]),Xi();const A=h.useCallback(I=>{var Q,O;return G.current===((Q=B.current)==null?void 0:Q.side)&&tT(I,(O=B.current)==null?void 0:O.area)},[]);return u.jsx($C,{scope:n,searchRef:F,onItemEnter:h.useCallback(I=>{A(I)&&I.preventDefault()},[A]),onItemLeave:h.useCallback(I=>{var K;A(I)||((K=k.current)==null||K.focus(),S(null))},[A]),onTriggerLeave:h.useCallback(I=>{A(I)&&I.preventDefault()},[A]),pointerGraceTimerRef:D,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 K;I.preventDefault(),(K=k.current)==null||K.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(al,{role:"menu","aria-orientation":"vertical","data-state":xh(v.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:le(g.onKeyDown,I=>{const Q=I.target.closest("[data-radix-menu-content]")===I.currentTarget,O=I.ctrlKey||I.altKey||I.metaKey,q=I.key.length===1;Q&&(I.key==="Tab"&&I.preventDefault(),!O&&q&&z(I.key));const L=k.current;if(I.target!==L||!AC.includes(I.key))return;I.preventDefault();const X=E().filter(R=>!R.disabled).map(R=>R.ref.current);Yp.includes(I.key)&&X.reverse(),JC(X)}),onBlur:le(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(P.current),F.current="")}),onPointerMove:le(e.onPointerMove,No(I=>{const K=I.target,Q=M.current!==I.clientX;if(I.currentTarget.contains(K)&&Q){const O=I.clientX>M.current?"right":"left";G.current=O,M.current=I.clientX}}))})})})})})})});th.displayName=sn;var HC="MenuGroup",gl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});gl.displayName=HC;var UC="MenuLabel",nh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});nh.displayName=UC;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=Oe(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=Oe(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",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=WC;var ih="MenuRadioGroup",[VC,KC]=fr(ih,{value:void 0,onValueChange:()=>{}}),ah=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(gl,{...o,ref:t})})});ah.displayName=ih;var lh="MenuRadioItem",ch=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=KC(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,qC]=fr(vl,{checked:!1}),dh=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=qC(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 GC="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=GC;var YC="MenuArrow",ph=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(ll,{...o,...r,ref:t})});ph.displayName=YC;var XC="MenuSub",[$N,hh]=fr(XC),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,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===" "||jC[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=Oe(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=PC[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 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=Zp,rT=fl,oT=eh,sT=th,iT=gl,aT=nh,lT=Gs,cT=sh,uT=ah,dT=ch,fT=dh,pT=fh,hT=ph,mT=mh,gT=vh,Xs="DropdownMenu",[vT,FN]=nn(Xs,[Xp]),zt=Xp(),[xT,bh]=vT(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(xT,{scope:t,triggerId:jt(),triggerRef:c,contentId:jt(),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})})};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(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())})})})});Sh.displayName=yh;var bT="DropdownMenuPortal",Ch=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(oT,{...r,...n})};Ch.displayName=bT;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(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)"}})});kh.displayName=Th;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",Eh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(aT,{...o,...r,ref:t})});Eh.displayName=ST;var CT="DropdownMenuItem",Ih=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(lT,{...o,...r,ref:t})});Ih.displayName=CT;var TT="DropdownMenuCheckboxItem",Nh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(cT,{...o,...r,ref:t})});Nh.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",Ah=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(dT,{...o,...r,ref:t})});Ah.displayName=IT;var NT="DropdownMenuItemIndicator",jh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(fT,{...o,...r,ref:t})});jh.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 jT="DropdownMenuArrow",PT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(hT,{...o,...r,ref:t})});PT.displayName=jT;var _T="DropdownMenuSubTrigger",_h=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(mT,{...o,...r,ref:t})});_h.displayName=_T;var RT="DropdownMenuSubContent",Rh=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)"}})});Rh.displayName=RT;var MT=wh,OT=Sh,DT=Ch,Mh=kh,Oh=Eh,Dh=Ih,Lh=Nh,$h=Ah,Fh=jh,Bh=Ph,zh=_h,Hh=Rh;const Js=MT,Zs=OT,LT=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(zh,{ref:o,className:se("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"})]}));LT.displayName=zh.displayName;const $T=h.forwardRef(({className:e,...t},n)=>u.jsx(Hh,{ref:n,className:se("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=Hh.displayName;const Ao=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(DT,{children:u.jsx(Mh,{ref:r,sideOffset:t,className:se("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=Mh.displayName;const Kn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Dh,{ref:r,className:se("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 FT=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Lh,{ref:o,className:se("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]}));FT.displayName=Lh.displayName;const BT=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($h,{ref:r,className:se("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]}));BT.displayName=$h.displayName;const zT=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Oh,{ref:r,className:se("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));zT.displayName=Oh.displayName;const HT=h.forwardRef(({className:e,...t},n)=>u.jsx(Bh,{ref:n,className:se("-mx-1 my-1 h-px bg-muted",e),...t}));HT.displayName=Bh.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:se("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 UT=1e4;function Uh({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),j=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()==="",$=44;L?k.current.style.height=`${$}px`:(k.current.style.height="auto",k.current.style.height=`${Math.max(k.current.scrollHeight,$)}px`)}},[e,t,y]);const[D,B]=b.useState(null),G=b.useCallback(L=>L.length>s?`Message too long (${L.length}/${s} characters)`:null,[s]),M=b.useMemo(()=>g??G,[g,G]),W=b.useCallback(L=>{const $=M(L);return B($),v==null||v($),F.current=L,$},[M,v]),Y=b.useCallback(()=>{const L=k.current;if(!L)return;const $=!L.value||L.value.trim()==="",X=44;if($){L.style.height=`${X}px`;return}L.style.height="auto";const R=Math.max(L.scrollHeight,X);L.style.height=`${R}px`},[]);b.useEffect(()=>{Y()},[Y,E]),b.useEffect(()=>{if(!D)return;const L=(E??"").trim();F.current!==L&&W(L)},[E,D,W]);const z=b.useCallback((L,{fromUser:$})=>{y||C(L),$&&(a==null||a(L))},[y,a]),A=b.useCallback(async L=>{L&&L.preventDefault();const $=(E??"").trim();if(!$&&!f||W($))return;const X=++j.current;P.current={id:X,shouldClear:!0},S(()=>{var R,_,U;try{const J=l($);J&&typeof J.then=="function"?J.then(()=>{var oe,ae;((oe=P.current)==null?void 0:oe.id)===X&&P.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ae=P.current)==null?void 0:ae.id)===X&&(P.current=null)}).catch(()=>{var oe;((oe=P.current)==null?void 0:oe.id)===X&&(P.current=null)}):(((R=P.current)==null?void 0:R.id)===X&&P.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((_=P.current)==null?void 0:_.id)===X&&(P.current=null))}catch{((U=P.current)==null?void 0:U.id)===X&&(P.current=null)}})},[E,l,f,y,a,W]),I=b.useCallback(L=>{const $=L.target.value;z($,{fromUser:!0}),P.current&&(P.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),D&&W($.trim())},[z,W,D]),K=b.useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),A()):L.key==="Escape"&&t&&(L.preventDefault(),c==null||c())},[A,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(bl,{ref:k,value:E,onChange:I,onKeyDown:K,placeholder:t?"Edit your message...":n,className:q,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),D&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:D})]}),u.jsx("div",{children:r?u.jsx(Je,{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(Je,{type:"button",onClick:L=>void A(L),size:"icon",className:`shrink-0 ${x??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!f||T||r,children:u.jsx(ue.Send,{size:16})})})]})})}const WT=b.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: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,j]=b.useState(0),[P,F]=b.useState(0),[D,B]=b.useState(!1),[G,M]=b.useState(null),[W,Y]=b.useState(null),z=b.useCallback(()=>{T.current&&(T.current.value=""),S.current&&(S.current.value=""),j($=>$+1),F($=>$+1)},[]),A=b.useCallback($=>{E(X=>{const R=[...X,...$];return g==null||g(R),R})},[g]),I=b.useCallback($=>{const X=Array.from($.target.files||[]);A(X),$.target.value=""},[A]),K=b.useCallback($=>{E(X=>{const R=X.filter((_,U)=>U!==$);return R.length===0&&z(),g==null||g(R),R})},[g,z]),Q=b.useCallback(async $=>{const X=($.target.files||[])[0];if(X&&(M(null),Y(null),!!x)){B(!0);try{await x(X),M(`Uploaded ${X.name} - processing through chat stream`)}catch(R){const _=R instanceof Error?R.message:"Failed to upload Excel file";Y(_),v==null||v(_)}finally{B(!1),$.target.value="",z()}}},[x,v,z]),O=b.useMemo(()=>y||C.length>0,[y,C]),q=b.useCallback(async $=>{const R=await n($,C);return C.length>0&&(E([]),g==null||g([]),z()),R},[n,z,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(($,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:$.name}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>K(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 ${$.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:Q,className:"hidden"},P),D&&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&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:G}),W&&!D&&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(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(Je,{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 $;return($=T.current)==null?void 0:$.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||($=S.current)==null||$.click()},className:`cursor-pointer ${D?"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(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:O,textareaClassName:L,sendButtonClassName:p.sendButton})})]})]})}const VT=b.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:x={},messageCustomStyles:g,onMessageSent:v,onExcelUploadSuccess:y,onError:w,defaultMessage:C}){const{chatApi:E}=On(),T=E.baseUrl,{currentThreadId:S}=yr(),{threadId:k,messages:j,isLoading:P,navigateToCheckpoint:F,returnToLatest:D,checkpoint:B,checkpoints:G,interrupt:M,metadata:W,checkpointIndex:Y,respondToInterrupt:z}=no(),{isStreaming:A,error:I,connectionState:K,submit:Q,stop:O}=Ui(),q=k??S??null,L=(B==null?void 0:B.id)??null,$=(B==null?void 0:B.namespace)??null,X=(W==null?void 0:W.assemblingMessageId)??null;b.useEffect(()=>{console.log("[ChatInterface] streamingAssistantId changed:",{streamingAssistantId:X,isStreaming:A,assemblingMessageId:W==null?void 0:W.assemblingMessageId})},[X,A,W==null?void 0:W.assemblingMessageId]);const R=M,_=R?Li(R.id):null,U=_!==null?{type:"interrupt",id:_}:null,[J,oe]=b.useState(!1),[ae,Ee]=b.useState(!1);b.useEffect(()=>{R||oe(!1)},[R]);const Se=b.useCallback(()=>{oe(!0)},[]),Re=b.useCallback(()=>{oe(!1)},[]),He=b.useCallback(ne=>{},[]),Fe=b.useCallback(ne=>ne.name!=="ask_user_choice",[]),Ye=d??{toolRenderers:p,toolArtifactRenderers:m,getToolExpandable:Fe},Ue=b.useCallback(async(ne,ce,ge)=>{try{Se(),await z(ne,ce,ge)}catch(we){console.error("Failed to respond to interrupt:",we)}finally{Re()}},[Re,Se,z]),ot=b.useCallback(()=>Ue(!0),[Ue]),pt=b.useCallback(()=>Ue(!1),[Ue]),ct=b.useCallback((ne,ce)=>Ue(!0,ce),[Ue]),We=!!R||J,[Me,Ke]=b.useState(null),[Ae,qe]=b.useState(""),[Xe,Ct]=b.useState(null),[Qe,Tt]=b.useState(null),[ht,wt]=b.useState(!1),[At,Pt]=b.useState(null),mt=b.useRef(!1),[gt,Ht]=b.useState(()=>Vh.value),Ve=b.useRef(gt),$e=b.useRef(null),ft=b.useCallback(ne=>{Vh.value=ne,Ht(ne)},[]),[kt,ut]=b.useState(!1),_t=b.useRef(null),xe=b.useCallback(ne=>{ft(ne)},[ft]);b.useEffect(()=>{A||Ee(!1)},[A]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&Ee(!1)},[W==null?void 0:W.assemblingMessageId]);const[Le,Be]=b.useState("desktop");b.useEffect(()=>{const ne=()=>{const ce=window.innerWidth;Be(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(!Me){$e.current=null;return}$e.current===null&&($e.current=Ve.current),ft(Ae??"")},[Ae,Me,ft]),b.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]),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=Me?(Xe==null?void 0:Xe.checkpointId)??L??void 0:L??void 0,Pe=Me?(Xe==null?void 0:Xe.checkpointNs)??$??void 0:$??void 0;await Q({text:ge||"",attachments:ce,payload:f},{checkpointId:we,checkpointNs:Pe,edit:!!Me,originalMessageId:Me??void 0}),v==null||v(ge),Ee(!0),ft(""),Tt(null),Ke(null),qe(""),Ct(null)}catch(we){const Pe=(we==null?void 0:we.message)||"Failed to send message";Tt(Pe),w==null||w(Pe),Ee(!1)}},tt=b.useCallback(async ne=>{await Q({attachments:[ne],payload:f},{checkpointId:L??void 0,checkpointNs:$??void 0}),y==null||y({file:ne})},[L,$,f,y,Q]),dt=b.useCallback((ne,ce,ge)=>{l&&($e.current=gt,Ke(ne),qe(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(()=>{Ke(null),qe(""),Ct(null),Tt(null),ft($e.current??gt),$e.current=null},[gt,ft]),Z=b.useCallback((ne,ce,ge)=>{dt(ne,ce,ge)},[dt]),ee=b.useCallback(ne=>{let ce=null;for(let ke=ne-1;ke>=0;ke--)if(j[ke].role==="user"){ce=j[ke];break}if(!ce)return;const ge=Array.isArray(ce.content)?ce.content:[],Pe=ge.filter(ke=>(ke==null?void 0:ke.type)==="text").map(ke=>ke.text).join("")||(()=>{try{return JSON.stringify(ge,null,2)}catch{return String(ge)}})();Pe&&Q({text:Pe,payload:f},{checkpointId:L??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:ce.id})},[j,Q,L,$,f]),he=b.useCallback(async ne=>{if(S){ut(!0);try{if(!ne){await D(),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 F(ne,ge),requestAnimationFrame(()=>{var we;(we=_t.current)==null||we.scrollToTop()})}finally{ut(!1)}}},[G,S,_t,F,D]),de=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 ${R?"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(Je,{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:j,isStreaming:A,streamingAssistantId:X,streamingDebounceMs:o,followNewMessages:s,layoutSize:Le,enableMessageEditing:l,editingMessageId:Me,onEdit:Z,onRegenerate:ee,onCancelEdit:et,emptyMessage:At??void 0,isNavigatingCheckpoint:kt,showToolMessages:c,toolConfig:Ye,checkpointIndex:Y,activeCheckpointId:L,onSelectCheckpoint:de,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae,getMessageCustomStyles:g,getInterruptOptions:He}),(K==="reconnecting"||K==="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"}),K==="reconnecting"?"Reconnecting…":"Connecting…"]})}),K==="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(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…"})]}),R&&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(ba,{interruptPart:U,onApprove:ot,onReject:pt,onSelectAlternative:ct,disabled:J,isActive:!0,payload:R.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(Je,{variant:"ghost",size:"sm",onClick:et,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(VT,{composerValue:gt,onComposerChange:xe,onSend:st,onCancelEdit:et,onStop:O,editingMessageId:Me,editingInitialValue:Ae,placeholder:Me?"Edit your message...":t,isStreaming:A,disabled:We,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:tt,onError:w,customStyles:x,textareaClassName:x.textarea||"",allowEmptySend:!1,inputError:Qe})]})]})}var Kh=1,KT=.9,qT=.8,GT=.17,wl=.1,yl=.999,YT=.9999,XT=.99,JT=/[\\\/_+.#"@\[\(\{&]/,ZT=/[\\\/_+.#"@\[\(\{&]/g,QT=/[\s-]/,qh=/[\s-]/g;function Sl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Kh: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=Sl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Kh:JT.test(e.charAt(c-1))?(p*=qT,f=e.slice(o,c-1).match(ZT),f&&o>0&&(p*=Math.pow(yl,f.length))):QT.test(e.charAt(c-1))?(p*=KT,x=e.slice(o,c-1).match(qh),x&&o>0&&(p*=Math.pow(yl,x.length))):(p*=GT,o>0&&(p*=Math.pow(yl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=YT)),(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 ek(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=""]',tk='[cmdk-group-heading=""]',Yh='[cmdk-item=""]',Xh=`${Yh}:not([aria-disabled="true"])`,Tl="cmdk-item-select",Br="data-value",nk=(e,t,n)=>ek(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,q;return{search:"",value:(q=(O=e.value)!=null?O: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=tm(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:x,disablePointerSelection:g=!1,vimBindings:v=!0,...y}=e,w=jt(),C=jt(),E=jt(),T=h.useRef(null),S=pk();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,q,L)=>{var $,X,R,_;if(!Object.is(n.current[O],q)){if(n.current[O]=q,O==="search")B(),F(),S(1,D);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(E);U?U.focus():($=document.getElementById(w))==null||$.focus()}if(S(7,()=>{var U;n.current.selectedItemId=(U=M())==null?void 0:U.id,k.emit()}),L||S(5,G),((X=a.current)==null?void 0:X.value)!==void 0){let U=q??"";(_=(R=a.current).onValueChange)==null||_.call(R,U);return}}k.emit()}},emit:()=>{i.current.forEach(O=>O())}}),[]),j=h.useMemo(()=>({value:(O,q,L)=>{var $;q!==(($=s.current.get(O))==null?void 0:$.value)&&(s.current.set(O,{value:q,keywords:L}),n.current.filtered.items.set(O,P(q,L)),S(2,()=>{F(),k.emit()}))},item:(O,q)=>(r.current.add(O),q&&(o.current.has(q)?o.current.get(q).add(O):o.current.set(q,new Set([O]))),S(3,()=>{B(),F(),n.current.value||D(),k.emit()}),()=>{s.current.delete(O),r.current.delete(O),n.current.filtered.items.delete(O);let L=M();S(4,()=>{B(),(L==null?void 0:L.getAttribute("id"))===O&&D(),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 P(O,q){var L,$;let X=($=(L=a.current)==null?void 0:L.filter)!=null?$:nk;return O?X(O,n.current.search,q):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let O=n.current.filtered.items,q=[];n.current.filtered.groups.forEach($=>{let X=o.current.get($),R=0;X.forEach(_=>{let U=O.get(_);R=Math.max(U,R)}),q.push([$,R])});let L=T.current;W().sort(($,X)=>{var R,_;let U=$.getAttribute("id"),J=X.getAttribute("id");return((R=O.get(J))!=null?R:0)-((_=O.get(U))!=null?_:0)}).forEach($=>{let X=$.closest(Cl);X?X.appendChild($.parentElement===X?$:$.closest(`${Cl} > *`)):L.appendChild($.parentElement===L?$:$.closest(`${Cl} > *`))}),q.sort(($,X)=>X[1]-$[1]).forEach($=>{var X;let R=(X=T.current)==null?void 0:X.querySelector(`${jo}[${Br}="${encodeURIComponent($[0])}"]`);R==null||R.parentElement.appendChild(R)})}function D(){let O=W().find(L=>L.getAttribute("aria-disabled")!=="true"),q=O==null?void 0:O.getAttribute(Br);k.setState("value",q||void 0)}function B(){var O,q,L,$;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 R of r.current){let _=(q=(O=s.current.get(R))==null?void 0:O.value)!=null?q:"",U=($=(L=s.current.get(R))==null?void 0:L.keywords)!=null?$:[],J=P(_,U);n.current.filtered.items.set(R,J),J>0&&X++}for(let[R,_]of o.current)for(let U of _)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(R);break}n.current.filtered.count=X}function G(){var O,q,L;let $=M();$&&(((O=$.parentElement)==null?void 0:O.firstChild)===$&&((L=(q=$.closest(jo))==null?void 0:q.querySelector(tk))==null||L.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function M(){var O;return(O=T.current)==null?void 0:O.querySelector(`${Yh}[aria-selected="true"]`)}function W(){var O;return Array.from(((O=T.current)==null?void 0:O.querySelectorAll(Xh))||[])}function Y(O){let q=W()[O];q&&k.setState("value",q.getAttribute(Br))}function z(O){var q;let L=M(),$=W(),X=$.findIndex(_=>_===L),R=$[X+O];(q=a.current)!=null&&q.loop&&(R=X+O<0?$[$.length-1]:X+O===$.length?$[0]:$[X+O]),R&&k.setState("value",R.getAttribute(Br))}function A(O){let q=M(),L=q==null?void 0:q.closest(jo),$;for(;L&&!$;)L=O>0?dk(L,jo):fk(L,jo),$=L==null?void 0:L.querySelector(Xh);$?k.setState("value",$.getAttribute(Br)):z(O)}let I=()=>Y(W().length-1),K=O=>{O.preventDefault(),O.metaKey?I():O.altKey?A(1):z(1)},Q=O=>{O.preventDefault(),O.metaKey?Y(0):O.altKey?A(-1):z(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:O=>{var q;(q=y.onKeyDown)==null||q.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&&K(O);break}case"ArrowDown":{K(O);break}case"p":case"k":{v&&O.ctrlKey&&Q(O);break}case"ArrowUp":{Q(O);break}case"Home":{O.preventDefault(),Y(0);break}case"End":{O.preventDefault(),I();break}case"Enter":{O.preventDefault();let $=M();if($){let X=new Event(Tl);$.dispatchEvent(X)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:mk},l),Qs(e,O=>h.createElement(Zh.Provider,{value:k},h.createElement(Jh.Provider,{value:j},O))))}),rk=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,x),()=>S.removeEventListener(Tl,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=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))))}),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=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)}})}),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=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)))}),lk=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}))))}),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},Qs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Gt=Object.assign(em,{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 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 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 Qs({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 El=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt,{ref:n,className:se("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:se("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:se("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:se("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 gk=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Separator,{ref:n,className:se("-mx-1 h-px bg-border",e),...t}));gk.displayName=Gt.Separator.displayName;const Pl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Item,{ref:n,className:se("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 vk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Rl="ScrollArea",[rm,BN]=nn(Rl),[xk,an]=rm(Rl),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,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,j]=h.useState(!1),P=Oe(t,D=>l(D)),F=Os(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:j,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}})})});om.displayName=Rl;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=Oe(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",Ml=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(am,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ol,{...r,ref:t}):null});Ml.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(am,{"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=ri(()=>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(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 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=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(Sk,{...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}),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=Oe(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)}})}})}),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=Oe(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)}})}})}),[Ck,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),[x,g]=h.useState(null),v=Oe(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=ri(p,10);function j(P){if(y.current){const F=P.clientX-y.current.left,D=P.clientY-y.current.top;c({x:F,y:D})}}return h.useEffect(()=>{const P=F=>{const D=F.target;(x==null?void 0:x.contains(D))&&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"),j(P))}),onPointerMove:le(e.onPointerMove,j),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})})})}),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(Tk,{ref:t,...r})})}),Tk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(ei,n),i=lm(ei,n),{onThumbPositionChange:a}=i,l=Oe(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=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)})});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(kk,{...e,ref:t}):null});dm.displayName=Dl;var kk=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 Ek(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 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 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,Nk=im,Ak=dm;const Ll=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gm,{ref:r,className:se("relative overflow-hidden",e),...n,children:[u.jsx(Nk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(vm,{}),u.jsx(Ak,{})]}));Ll.displayName=gm.displayName;const vm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ml,{ref:r,orientation:t,className:se("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=Ml.displayName;const $l=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:se("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 jk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Pk="bg-slate-700 border-slate-600 hover:bg-slate-600",_k="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:x,secondaryLine:g,itemClassName:v,activeItemClassName:y}){var T;const w=n===e.threadId,C=t?`${y??_k}`:`${v??Pk}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${jk} ${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(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Je,{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: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(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(Je,{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",[Rk,zN]=nn(oi),[Mk,Bl]=Rk(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(Mk,{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(Ok,{...r,ref:t,present:s})})});ym.displayName=zl;var Ok=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=Oe(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":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":x?`${x}px`:void 0,...e.style},children:g&&o})});function Hl(e){return e?"open":"closed"}var Dk=xm;const Lk=Dk,$k=wm,Fk=ym,Sm=25,Cm="thread-manager-view",Bk=e=>e==="default"||e==="shared",zk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Cm);if(Bk(e))return e}catch{}return null};function Tm({defaultView:e}={}){const[t,n]=b.useState(()=>zk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Cm,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 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:x,viewState:g,showHeader:v=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:C,groupBy:E}){const{chatApi:T,authApi:S}=On(),{threads:k,sharedThreads:j,currentThreadId:P,setCurrentThreadId:F,isLoading:D,isLoadingSharedThreads:B,actions:G,shareInFlight:M,shareStatus:W,clearShareStatus:Y}=yr(),{createThread:z,deleteThread:A,renameThread:I,shareThread:K}=G,{loadThread:Q}=no(),O=i??P,[q,L]=b.useState(Array.isArray(k)?k:[]),$=b.useRef(q.length>0),X=b.useRef(null),R=b.useRef(0),[_,U]=b.useState(null),[J,oe]=b.useState(""),[ae,Ee]=b.useState(!1),[Se,Re]=b.useState(!1),[He,Fe]=b.useState(null),[Ye,Ue]=b.useState(""),[ot,pt]=b.useState([]),[ct,We]=b.useState(!1);b.useEffect(()=>{Se&&!y&&ot.length===0&&!ct&&(async()=>{We(!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{We(!1)}})()},[Se,y,ot.length,ct,T]);const Me=y??ot,Ke=w??ct,Ae=x&&x.length>0?x:Hk,qe=Tm({defaultView:m}),Xe=g??qe,Ct=p??Xe.view,Qe=b.useCallback(Z=>{p||Xe.setView(Z),f==null||f(Z)},[p,f,Xe]),Tt=Ae.find(Z=>Z.key===Ct)??Ae[0],ht=Z=>{Fe(Z),Ue(""),Re(!0)},wt=()=>{Re(!1),Fe(null),Ue(""),Y()},At=b.useCallback(async Z=>{if(!(!He||M)&&Z.id)try{await K(He,Z.id),setTimeout(()=>wt(),600)}catch(ee){console.error("Failed to share thread:",ee)}},[wt,M,He,K]),Pt=b.useMemo(()=>{const Z=Me,ee=Ye.trim().toLowerCase();return ee?C?Z.filter(he=>C(he,ee)):Z.filter(he=>`${he.label} ${he.secondaryLabel??""}`.toLowerCase().includes(ee)):Z},[y,Ye,C]),mt=Ct==="shared",gt=mt?j:q,Ht=b.useMemo(()=>{if(!E||mt)return null;const Z={},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,Z[de]||(Z[de]=[]),Z[de].push(he)}),Object.keys(Z).forEach(he=>{Z[he].sort((de,Ie)=>new Date(Ie.updatedAt||Ie.createdAt||"").getTime()-new Date(de.updatedAt||de.createdAt||"").getTime())}),Z},[gt,E,mt]),Ve=mt?B:D,$e=mt?"No shared conversations yet":"No conversations yet",ft=Z=>{const ee=Z.sharedAt?` • ${tt(Z.sharedAt)}`:"";return`Shared by ${Z.sharedByUserId}${ee}`},kt=Z=>"sharedByUserId"in Z;b.useEffect(()=>{const Z=Array.isArray(k)?k:[];if(Z.length>0){$.current=!0,L(Z);return}D||($.current=!1,L(Z))},[k,D]),b.useEffect(()=>{if(!X.current)return;const Z=X.current.querySelector("[data-radix-scroll-area-viewport]");if(!Z)return;let ee=null,he=null;return ee=requestAnimationFrame(()=>{he=requestAnimationFrame(()=>{Z.scrollTop=R.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),he!==null&&cancelAnimationFrame(he)}},[q]);const ut=async Z=>{try{F(Z),await Q(Z),a==null||a(Z),l==null||l(Z)}catch(ee){console.error("Failed to select thread:",ee)}},_t=async()=>{try{Ee(!0);const Z=await z();Z&&(c==null||c(Z),a==null||a(Z))}catch(Z){console.error("Failed to create thread:",Z)}finally{Ee(!1)}},xe=async(Z,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(X.current){const he=X.current.querySelector("[data-radix-scroll-area-viewport]");he&&(R.current=he.scrollTop)}try{await A(Z),d==null||d(Z)}catch(he){console.error("Failed to delete thread:",he)}}},Le=(Z,ee)=>{ee.stopPropagation(),U(Z.threadId),oe(Z.title||`Thread ${Z.threadId.slice(0,8)}`)},Be=async Z=>{if(J.trim())try{await I(Z,J.trim()),U(null),oe("")}catch(ee){console.error("Failed to update title:",ee)}},st=()=>{U(null),oe("")},tt=Z=>{if(!Z)return"";try{const ee=Z.endsWith("Z")||Z.includes("+")?Z:`${Z}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""}},dt=Z=>Z.title||`Thread ${Z.threadId.slice(0,8)}`,et=Z=>{const ee=dt(Z);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(Je,{onClick:_t,disabled:ae||D,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(Je,{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(Z=>u.jsxs(Kn,{className:"justify-between text-[12px]",onClick:ee=>{ee.preventDefault(),Qe(Z.key)},children:[u.jsx("span",{children:Z.label}),Ct===Z.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Z.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(([Z],[ee])=>{const he="Default";return Z===he?1:ee===he?-1:Z.localeCompare(ee)}).map(([Z,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(ue.ChevronRight,{className:"w-3 h-3 mr-1 transition-transform group-data-[state=open]/collapsible:rotate-90"}),Z,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(Fl,{thread:he,isActive:O===he.threadId,editingThreadId:_,editingTitle:J,onSelect:ut,onStartEditing:Le,onEditingTitleChange:de=>oe(de),onSaveEditing:Be,onCancelEditing:st,onShare:()=>ht(he.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:tt,getDisplayThreadTitle:et,itemClassName:s.threadItem,activeItemClassName:s.activeThread},he.threadId))})})]},Z)):gt.slice().sort((Z,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(Z.updatedAt||Z.createdAt||"").getTime()).map(Z=>u.jsx(Fl,{thread:Z,isActive:O===Z.threadId,editingThreadId:_,editingTitle:J,onSelect:ut,onStartEditing:Le,onEditingTitleChange:ee=>oe(ee),onSaveEditing:Be,onCancelEditing:st,onShare:()=>ht(Z.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:tt,getDisplayThreadTitle:et,secondaryLine:mt&&kt(Z)?ft(Z):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Z.threadId))})}),u.jsx(la,{open:Se,onOpenChange:Z=>!Z&&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:Ye,onValueChange:Z=>Ue(Z),placeholder:"Search for recipients..."}),u.jsxs(Nl,{children:[W&&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:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),u.jsx(Al,{children:Ke?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(Z=>u.jsx(Pl,{onSelect:()=>At(Z),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Z.label}),Z.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Z.secondaryLabel})]})},Z.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(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 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(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 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(Je,{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(Je,{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(Je,{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(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(Je,{variant:r,size:o,className:se("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 Gk="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=Gk;var Em=km;const Yk=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:se(Yk(),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"}),Xk="VisuallyHidden",ii=h.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...Am,...e.style}}));ii.displayName=Xk;var Jk=ii,Zk=[" ","Enter","ArrowUp","ArrowDown"],Qk=[" ","Enter"],mr="Select",[ai,li,eE]=Ms(mr),[Ur,HN]=nn(mr,[eE,$r]),ci=$r(),[tE,Gn]=Ur(mr),[nE,rE]=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:x}=e,g=ci(t),[v,y]=h.useState(null),[w,C]=h.useState(null),[E,T]=h.useState(!1),S=Os(c),[k,j]=In({prop:r,defaultProp:o??!1,onChange:s,caller:mr}),[P,F]=In({prop:i,defaultProp:a,onChange:l,caller:mr}),D=h.useRef(null),B=v?x||!!v.closest("form"):!0,[G,M]=h.useState(new Set),W=Array.from(G).map(Y=>Y.props.value).join(";");return u.jsx(sl,{...g,children:u.jsxs(tE,{required:f,scope:t,trigger:v,onTriggerChange:y,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:jt(),value:P,onValueChange:F,open:k,onOpenChange:j,dir:S,triggerPointerDownPosRef:D,disabled:m,children:[u.jsx(ai.Provider,{scope:t,children:u.jsx(nE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(Y=>{M(z=>new Set(z).add(Y))},[]),onNativeOptionRemove:h.useCallback(Y=>{M(z=>{const A=new Set(z);return A.delete(Y),A})},[]),children:n})}),B?u.jsxs(eg,{"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(G)]},W):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=Oe(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)}),x=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"&&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())})})})});_m.displayName=Pm;var Rm="SelectValue",Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(Rm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Oe(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})});Mm.displayName=Rm;var oE="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=oE;var sE="SelectPortal",Dm=e=>u.jsx(oo,{asChild:!0,...e});Dm.displayName=sE;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),iE="SelectContentImpl",aE=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:x,hideWhenDetached:g,avoidCollisions:v,...y}=e,w=Gn(gr,n),[C,E]=h.useState(null),[T,S]=h.useState(null),k=Oe(t,R=>E(R)),[j,P]=h.useState(null),[F,D]=h.useState(null),B=li(n),[G,M]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(C)return na(C)},[C]),Xi();const Y=h.useCallback(R=>{const[_,...U]=B().map(ae=>ae.ref.current),[J]=U.slice(-1),oe=document.activeElement;for(const ae of R)if(ae===oe||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===_&&T&&(T.scrollTop=0),ae===J&&T&&(T.scrollTop=T.scrollHeight),ae==null||ae.focus(),document.activeElement!==oe))return},[B,T]),z=h.useCallback(()=>Y([j,C]),[Y,j,C]);h.useEffect(()=>{G&&z()},[G,z]);const{onOpenChange:A,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(C){let R={x:0,y:0};const _=J=>{var oe,ae;R={x:Math.abs(Math.round(J.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(J.pageY)-(((ae=I.current)==null?void 0:ae.y)??0))}},U=J=>{R.x<=10&&R.y<=10?J.preventDefault():C.contains(J.target)||A(!1),document.removeEventListener("pointermove",_),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,A,I]),h.useEffect(()=>{const R=()=>A(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[A]);const[K,Q]=ng(R=>{const _=B().filter(oe=>!oe.disabled),U=_.find(oe=>oe.ref.current===document.activeElement),J=rg(_,R,U);J&&setTimeout(()=>J.ref.current.focus())}),O=h.useCallback((R,_,U)=>{const J=!W.current&&!U;(w.value!==void 0&&w.value===_||J)&&(P(R),J&&(W.current=!0))},[w.value]),q=h.useCallback(()=>C==null?void 0:C.focus(),[C]),L=h.useCallback((R,_,U)=>{const J=!W.current&&!U;(w.value!==void 0&&w.value===_||J)&&D(R)},[w.value]),$=r==="popper"?Ul:Bm,X=$===Ul?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:x,hideWhenDetached:g,avoidCollisions:v}:{};return u.jsx($m,{scope:n,content:C,viewport:T,onViewportChange:S,itemRefCallback:O,selectedItem:j,onItemLeave:q,itemTextRefCallback:L,focusSelectedItem:z,selectedItemText:F,position:r,isPositioned:G,searchRef:K,children:u.jsx(rs,{as:aE,allowPinchZoom:!0,children:u.jsx(Xo,{asChild:!0,trapped:w.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:le(o,R=>{var _;(_=w.trigger)==null||_.focus({preventScroll:!0}),R.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:R=>R.preventDefault(),...y,...X,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:le(y.onKeyDown,R=>{const _=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!_&&R.key.length===1&&Q(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let J=B().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(R.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const oe=R.target,ae=J.indexOf(oe);J=J.slice(ae+1)}setTimeout(()=>Y(J)),R.preventDefault()}})})})})})})});Fm.displayName=iE;var lE="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=Oe(t,k=>d(k)),m=li(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(),j=c.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),F=y.getBoundingClientRect();if(s.dir!=="rtl"){const oe=F.left-j.left,ae=P.left-oe,Ee=k.left-ae,Se=k.width+Ee,Re=Math.max(Se,j.width),He=window.innerWidth-mn,Fe=_l(ae,[mn,Math.max(mn,He-Re)]);a.style.minWidth=Se+"px",a.style.left=Fe+"px"}else{const oe=j.right-F.right,ae=window.innerWidth-P.right-oe,Ee=window.innerWidth-k.right-ae,Se=k.width+Ee,Re=Math.max(Se,j.width),He=window.innerWidth-mn,Fe=_l(ae,[mn,Math.max(mn,He-Re)]);a.style.minWidth=Se+"px",a.style.right=Fe+"px"}const D=m(),B=window.innerHeight-mn*2,G=g.scrollHeight,M=window.getComputedStyle(c),W=parseInt(M.borderTopWidth,10),Y=parseInt(M.paddingTop,10),z=parseInt(M.borderBottomWidth,10),A=parseInt(M.paddingBottom,10),I=W+Y+G+A+z,K=Math.min(v.offsetHeight*5,I),Q=window.getComputedStyle(g),O=parseInt(Q.paddingTop,10),q=parseInt(Q.paddingBottom,10),L=k.top+k.height/2-mn,$=B-L,X=v.offsetHeight/2,R=v.offsetTop+X,_=W+Y+R,U=I-_;if(_<=L){const oe=D.length>0&&v===D[D.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-g.offsetTop-g.offsetHeight,Ee=Math.max($,X+(oe?q:0)+ae+z),Se=_+Ee;a.style.height=Se+"px"}else{const oe=D.length>0&&v===D[0].ref.current;a.style.top="0px";const Ee=Math.max(L,W+g.offsetTop+(oe?O:0)+X)+U;a.style.height=Ee+"px",g.scrollTop=_-L+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=K+"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}})})})});Bm.displayName=lE;var cE="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=cE;var[uE,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=Oe(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 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})})})]})});zm.displayName=Vl;var Hm="SelectGroup",[dE,fE]=Ur(Hm),pE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jt();return u.jsx(dE,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});pE.displayName=Hm;var Um="SelectLabel",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fE(Um,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});Wm.displayName=Um;var ui="SelectItem",[hE,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),x=Oe(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(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(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: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())})})})})});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=rE(_o,n),[d,p]=h.useState(null),m=Oe(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]})});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=Oe(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=Oe(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()})})}),mE="SelectSeparator",Qm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Qm.displayName=mE;var Gl="SelectArrow",gE=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});gE.displayName=Gl;var vE="SelectBubbleInput",eg=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Oe(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=vE;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=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=jm,og=_m,wE=Mm,yE=Om,SE=Dm,sg=Lm,CE=zm,ig=Wm,ag=Km,TE=qm,kE=Ym,lg=Xm,cg=Jm,ug=Qm;const EE=bE,IE=wE,dg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(og,{ref:r,className:se("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(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:se("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:se("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(SE,{children:u.jsxs(sg,{ref:o,className:se("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(CE,{className:se("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 NE=h.forwardRef(({className:e,...t},n)=>u.jsx(ig,{ref:n,className:se("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));NE.displayName=ig.displayName;const mg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ag,{ref:r,className:se("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(ue.Check,{className:"h-4 w-4"})})}),u.jsx(TE,{children:t})]}));mg.displayName=ag.displayName;const AE=h.forwardRef(({className:e,...t},n)=>u.jsx(ug,{ref:n,className:se("-mx-1 my-1 h-px bg-muted",e),...t}));AE.displayName=ug.displayName;var jE="Separator",gg="horizontal",PE=["horizontal","vertical"],vg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=gg,...o}=e,s=_E(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=jE;function _E(e){return PE.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:se("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));bg.displayName=xg.displayName;var di="Switch",[RE,UN]=nn(di),[ME,OE]=RE(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),x=Oe(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(ME,{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:x,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=OE(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 DE="SwitchBubbleInput",Cg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Oe(i,s),l=Nm(n),c=Rp(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}})});Cg.displayName=DE;function Tg(e){return e?"checked":"unchecked"}var kg=wg,LE=Sg;const Eg=h.forwardRef(({className:e,...t},n)=>u.jsx(kg,{className:se("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:se("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 $E=ia,FE=Vw,BE=aa,Ig=h.forwardRef(({className:e,...t},n)=>u.jsx(so,{className:se("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 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"}}),Ng=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(BE,{children:[u.jsx(Ig,{}),u.jsxs(io,{ref:o,className:se(zE({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:se("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:se("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:se("text-sm text-muted-foreground",e),...t}));Pg.displayName=ls.displayName;var[fi,WN]=nn("Tooltip",[$r]),pi=$r(),_g="TooltipProvider",HE=700,Yl="tooltip.open",[UE,Xl]=fi(_g),Rg=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})};Rg.displayName=_g;var Ro="Tooltip",[WE,hi]=fi(Ro),Mg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Xl(Ro,e.__scopeTooltip),c=pi(t),[d,p]=h.useState(null),m=jt(),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(Yl))):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(sl,{...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})})};Mg.displayName=Ro;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=Oe(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 VE="TooltipPortal",[VN,KE]=fi(VE,{forceMount:void 0}),Wr="TooltipContent",Dg=h.forwardRef((e,t)=>{const n=KE(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(qE,{side:o,...s,ref:t})})}),qE=h.forwardRef((e,t)=>{const n=hi(Wr,e.__scopeTooltip),r=Xl(Wr,e.__scopeTooltip),o=h.useRef(null),s=Oe(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(Lg,{...e,ref:s})}),[GE,YE]=fi(Ro,{isInside:!1}),XE=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(XE,{children:r}),u.jsx(GE,{scope:n,isInside:!0,children:u.jsx(Jk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Dg.displayName=Wr;var $g="TooltipArrow",JE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=pi(n);return YE($g,n).isInside?null:u.jsx(ll,{...o,...r,ref:t})});JE.displayName=$g;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=Rg,sI=Mg,iI=Og,Fg=Dg;const aI=oI,lI=sI,cI=iI,Bg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Fg,{ref:r,sideOffset:t,className:se("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,uI,dI]=Ms("Toast"),[zg,KN]=nn("Toast",[dI]),[fI,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(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})})};Hg.displayName=Zl;var Ug="ToastViewport",pI=["F8"],ec="toast.viewportPause",tc="toast.viewportResume",Wg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=pI,label:o="Notifications ({hotkey})",...s}=e,i=mi(Ug,n),a=uI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Oe(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(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)}}},[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 j=document.activeElement,P=w.shiftKey;if(w.target===v&&P){(T=c.current)==null||T.focus();return}const B=g({tabbingDirection:P?"backwards":"forwards"}),G=B.findIndex(M=>M===j);oc(B.slice(G+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(Fb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:x?void 0:"none"},children:[x&&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})}),x&&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 Mo="Toast",hI="toast.swipeStart",mI="toast.swipeMove",gI="toast.swipeCancel",vI="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: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)})})})});Kg.displayName=Mo;var[xI,bI]=zg(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=mi(Mo,n),[v,y]=h.useState(null),w=Oe(t,M=>y(M)),C=h.useRef(null),E=h.useRef(null),T=o||g.duration,S=h.useRef(0),k=h.useRef(T),j=h.useRef(0),{onToastAdd:P,onToastRemove:F}=g,D=xt(()=>{var W;(v==null?void 0:v.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),B=h.useCallback(M=>{!M||M===1/0||(window.clearTimeout(j.current),S.current=new Date().getTime(),j.current=window.setTimeout(D,M))},[D]);h.useEffect(()=>{const M=g.viewport;if(M){const W=()=>{B(k.current),c==null||c()},Y=()=>{const z=new Date().getTime()-S.current;k.current=k.current-z,window.clearTimeout(j.current),l==null||l()};return M.addEventListener(ec,Y),M.addEventListener(tc,W),()=>{M.removeEventListener(ec,Y),M.removeEventListener(tc,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 G=h.useMemo(()=>v?Qg(v):null,[v]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(yI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(xI,{scope:n,onClose:D,children:qr.createPortal(u.jsx(Ql.ItemSlot,{scope:n,children:u.jsx($b,{asChild:!0,onEscapeKeyDown:le(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||D(),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,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),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 W=M.clientX-C.current.x,Y=M.clientY-C.current.y,z=!!E.current,A=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,K=A?I(0,W):0,Q=A?0:I(0,Y),O=M.pointerType==="touch"?10:2,q={x:K,y:Q},L={originalEvent:M,delta:q};z?(E.current=q,gi(mI,p,L,{discrete:!1})):ev(q,g.swipeDirection,O)?(E.current=q,gi(hI,d,L,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(W)>O||Math.abs(Y)>O)&&(C.current=null)}),onPointerUp:le(e.onPointerUp,M=>{const W=E.current,Y=M.target;if(Y.hasPointerCapture(M.pointerId)&&Y.releasePointerCapture(M.pointerId),E.current=null,C.current=null,W){const z=M.currentTarget,A={originalEvent:M,delta:W};ev(W,g.swipeDirection,g.swipeThreshold)?gi(vI,f,A,{discrete:!0}):gi(gI,m,A,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),yI=e=>{const{__scopeToast:t,children:n,...r}=e,o=mi(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(ii,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},SI="ToastTitle",qg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});qg.displayName=SI;var CI="ToastDescription",Gg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Gg.displayName=CI;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=bI(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),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(...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 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 oc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var II=Hg,tv=Wg,nv=Kg,rv=qg,ov=Gg,sv=Xg,iv=rc;const NI=II,av=h.forwardRef(({className:e,...t},n)=>u.jsx(tv,{ref:n,className:se("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 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"}}),lv=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(nv,{ref:r,className:se(AI({variant:t}),e),...n}));lv.displayName=nv.displayName;const jI=h.forwardRef(({className:e,...t},n)=>u.jsx(sv,{ref:n,className:se("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}));jI.displayName=sv.displayName;const cv=h.forwardRef(({className:e,...t},n)=>u.jsx(iv,{ref:n,className:se("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:se("text-sm font-semibold",e),...t}));uv.displayName=rv.displayName;const dv=h.forwardRef(({className:e,...t},n)=>u.jsx(ov,{ref:n,className:se("text-sm opacity-90",e),...t}));dv.displayName=ov.displayName;function PI(){const{toasts:e}=da();return u.jsxs(NI,{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 _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},sc=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: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],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)||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 VI,KI=(e,t)=>{let n=(t==null?void 0:t.id)||sc++;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 vi(e){return e.label!==void 0}var ZI=3,QI="32px",eN="16px",fv=4e3,tN=356,nN=14,rN=20,oN=200;function gn(...e){return e.filter(Boolean).join(" ")}function sN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var iN=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:j,style:P,cancelButtonStyle:F,actionButtonStyle:D,className:B="",descriptionClassName:G="",duration:M,position:W,gap:Y,loadingIcon:z,expandByDefault:A,classNames:I,icons:K,closeButtonAriaLabel:Q="Close toast",pauseWhenPageIsHidden:O}=e,[q,L]=b.useState(null),[$,X]=b.useState(null),[R,_]=b.useState(!1),[U,J]=b.useState(!1),[oe,ae]=b.useState(!1),[Ee,Se]=b.useState(!1),[Re,He]=b.useState(!1),[Fe,Ye]=b.useState(0),[Ue,ot]=b.useState(0),pt=b.useRef(f.duration||M||fv),ct=b.useRef(null),We=b.useRef(null),Me=C===0,Ke=C+1<=y,Ae=f.type,qe=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:j},[f.closeButton,j]),ht=b.useMemo(()=>f.duration||M||fv,[f.duration,M]),wt=b.useRef(0),At=b.useRef(0),Pt=b.useRef(0),mt=b.useRef(null),[gt,Ht]=W.split("-"),Ve=b.useMemo(()=>w.reduce((xe,Le,Be)=>Be>=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(()=>{_(!0)},[]),b.useEffect(()=>{let xe=We.current;if(xe){let Le=xe.getBoundingClientRect().height;return ot(Le),v(Be=>[{toastId:f.id,height:Le,position:f.position},...Be]),()=>v(Be=>Be.filter(st=>st.toastId!==f.id))}},[v,f.id]),b.useLayoutEffect(()=>{if(!R)return;let xe=We.current,Le=xe.style.height;xe.style.height="auto";let Be=xe.getBoundingClientRect().height;xe.style.height=Le,ot(Be),v(st=>st.find(tt=>tt.toastId===f.id)?st.map(tt=>tt.toastId===f.id?{...tt,height:Be}:tt):[{toastId:f.id,height:Be,position:f.position},...st])},[R,f.title,f.description,v,f.id]);let ut=b.useCallback(()=>{J(!0),Ye(At.current),v(xe=>xe.filter(Le=>Le.toastId!==f.id)),setTimeout(()=>{S(f)},oN)},[f,S,v,At]);b.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),ut()},pt.current)),()=>clearTimeout(xe)},[T,g,f,Ae,O,$e,ut]),b.useEffect(()=>{f.delete&&ut()},[ut,f.delete]);function _t(){var xe,Le,Be;return K!=null&&K.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"},K.loading):z?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"},z):b.createElement($I,{className:gn(I==null?void 0:I.loader,(Be=f==null?void 0:f.classNames)==null?void 0:Be.loader),visible:Ae==="loading"})}return b.createElement("li",{tabIndex:0,ref:We,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":R,"data-promise":!!f.promise,"data-swiped":Re,"data-removed":U,"data-visible":Ke,"data-y-position":gt,"data-x-position":Ht,"data-index":C,"data-front":Me,"data-swiping":oe,"data-dismissible":qe,"data-type":Ae,"data-invert":ft,"data-swipe-out":Ee,"data-swipe-direction":$,"data-expanded":!!(T||A&&R),style:{"--index":C,"--toasts-before":C,"--z-index":E.length-C,"--offset":`${U?Fe:At.current}px`,"--initial-height":A?"auto":`${Ue}px`,...P,...f.style},onDragEnd:()=>{ae(!1),L(null),mt.current=null},onPointerDown:xe=>{kt||!qe||(ct.current=new Date,Ye(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,Be,st;if(Ee||!qe)return;mt.current=null;let tt=Number(((xe=We.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),dt=Number(((Le=We.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),et=new Date().getTime()-((Be=ct.current)==null?void 0:Be.getTime()),Z=q==="x"?tt:dt,ee=Math.abs(Z)/et;if(Math.abs(Z)>=rN||ee>.11){Ye(At.current),(st=f.onDismiss)==null||st.call(f,f),X(q==="x"?tt>0?"right":"left":dt>0?"down":"up"),ut(),Se(!0),He(!1);return}ae(!1),L(null)},onPointerMove:xe=>{var Le,Be,st,tt;if(!mt.current||!qe||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;let dt=xe.clientY-mt.current.y,et=xe.clientX-mt.current.x,Z=(Be=e.swipeDirections)!=null?Be:sN(W);!q&&(Math.abs(et)>1||Math.abs(dt)>1)&&L(Math.abs(et)>Math.abs(dt)?"x":"y");let ee={x:0,y:0};q==="y"?(Z.includes("top")||Z.includes("bottom"))&&(Z.includes("top")&&dt<0||Z.includes("bottom")&&dt>0)&&(ee.y=dt):q==="x"&&(Z.includes("left")||Z.includes("right"))&&(Z.includes("left")&&et<0||Z.includes("right")&&et>0)&&(ee.x=et),(Math.abs(ee.x)>0||Math.abs(ee.y)>0)&&He(!0),(st=We.current)==null||st.style.setProperty("--swipe-amount-x",`${ee.x}px`),(tt=We.current)==null||tt.style.setProperty("--swipe-amount-y",`${ee.y}px`)}},Tt&&!f.jsx?b.createElement("button",{"aria-label":Q,"data-disabled":kt,"data-close-button":!0,onClick:kt||!qe?()=>{}:()=>{var xe;ut(),(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=K==null?void 0:K.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||(K==null?void 0:K[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(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),b.isValidElement(f.cancel)?f.cancel:f.cancel&&vi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||F,onClick:xe=>{var Le,Be;vi(f.cancel)&&qe&&((Be=(Le=f.cancel).onClick)==null||Be.call(Le,xe),ut())},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&&vi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||D,onClick:xe=>{var Le,Be;vi(f.action)&&((Be=(Le=f.action).onClick)==null||Be.call(Le,xe),!xe.defaultPrevented&&ut())},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 aN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?eN: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 lN=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=pv(),gap:y=nN,loadingIcon:w,icons:C,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:T}=e,[S,k]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(S.filter(O=>O.position).map(O=>O.position)))),[S,r]),[P,F]=b.useState([]),[D,B]=b.useState(!1),[G,M]=b.useState(!1),[W,Y]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=b.useRef(null),A=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),K=b.useRef(!1),Q=b.useCallback(O=>{k(q=>{var L;return(L=q.find($=>$.id===O.id))!=null&&L.delete||Yt.dismiss(O.id),q.filter(({id:$})=>$!==O.id)})},[]);return b.useEffect(()=>Yt.subscribe(O=>{if(O.dismiss){k(q=>q.map(L=>L.id===O.id?{...L,delete:!0}:L));return}setTimeout(()=>{Oo.flushSync(()=>{k(q=>{let L=q.findIndex($=>$.id===O.id);return L!==-1?[...q.slice(0,L),{...q[L],...O},...q.slice(L+1)]:[O,...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 O=window.matchMedia("(prefers-color-scheme: dark)");try{O.addEventListener("change",({matches:q})=>{Y(q?"dark":"light")})}catch{O.addListener(({matches:L})=>{try{Y(L?"dark":"light")}catch($){console.error($)}})}},[d]),b.useEffect(()=>{S.length<=1&&B(!1)},[S]),b.useEffect(()=>{let O=q=>{var L,$;o.every(X=>q[X]||q.code===X)&&(B(!0),(L=z.current)==null||L.focus()),q.code==="Escape"&&(document.activeElement===z.current||($=z.current)!=null&&$.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[o]),b.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,K.current=!1)}},[z.current]),b.createElement("section",{ref:t,"aria-label":`${E} ${A}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((O,q)=>{var L;let[$,X]=O.split("-");return S.length?b.createElement("ol",{key:O,dir:v==="auto"?pv():v,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":$,"data-lifted":D&&S.length>1&&!s,"data-x-position":X,style:{"--front-toast-height":`${((L=P[0])==null?void 0:L.height)||0}px`,"--width":`${tN}px`,"--gap":`${y}px`,...f,...aN(l,c)},onBlur:R=>{K.current&&!R.currentTarget.contains(R.relatedTarget)&&(K.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||K.current||(K.current=!0,I.current=R.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{G||B(!1)},onDragEnd:()=>B(!1),onPointerDown:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||M(!0)},onPointerUp:()=>M(!1)},S.filter(R=>!R.position&&q===0||R.position===O).map((R,_)=>{var U,J;return b.createElement(iN,{key:R.id,icons:C,index:_,toast:R,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:(J=g==null?void 0:g.closeButton)!=null?J: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:Q,toasts:S.filter(oe=>oe.position==R.position),heights:P.filter(oe=>oe.position==R.position),setHeights:F,expandByDefault:s,gap:y,loadingIcon:w,expanded:D,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const cN=({...e})=>{const{theme:t="system"}=OI();return u.jsx(lN,{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=Je,H.Card=ma,H.CardContent=bs,H.CardDescription=xa,H.CardHeader=ga,H.CardTitle=va,H.ChatApi=iu,H.ChatApp=Uk,H.ChatInput=Uh,H.ChatInputRow=Wh,H.ChatInterface=Fr,H.ChatProviders=Tr,H.ChatWidget=Kk,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=qk,H.PlotArtifact=Jd,H.SETTINGS_STORAGE_KEY=Wi,H.ScrollArea=Ll,H.Select=EE,H.SelectContent=hg,H.SelectItem=mg,H.SelectTrigger=dg,H.SelectValue=IE,H.Separator=bg,H.Sheet=$E,H.SheetContent=Ng,H.SheetDescription=Pg,H.SheetHeader=Ag,H.SheetTitle=jg,H.SheetTrigger=FE,H.SimpleChat=Wk,H.SimpleJsonView=xs,H.Sonner=cN,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=PI,H.ToolContent=cp,H.Tooltip=lI,H.TooltipContent=Bg,H.TooltipProvider=aI,H.TooltipTrigger=cI,H.UserTextContent=nf,H.applySettings=yb,H.buildCheckpointIndex=uc,H.buildCheckpointPreviewMap=xv,H.buildLabelParts=Cu,H.chatApiClient=Mn,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=Ri,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=Mi,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=Rn,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=Mu,H.useThreads=yr,H.useThreadsState=hu,H.useToolPayload=uf,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|
|
132
132
|
//# sourceMappingURL=index.umd.js.map
|