teodor-new-chat-ui 4.3.474 → 4.3.476
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1017 -1026
- package/dist/index.umd.js +34 -34
- 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,qt,Hr,lx,cx,le,
|
|
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,qt,Hr,lx,cx,le,Ro){"use strict";var pN=Object.defineProperty;var mN=(H,b,qt)=>b in H?pN(H,b,{enumerable:!0,configurable:!0,writable:!0,value:qt}):H[b]=qt;var ix=(H,b,qt)=>mN(H,typeof b!="symbol"?b+"":b,qt);function Ql(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 p=Ql(b),Ur=Ql(Ro),ec=120;function ux(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>ec?`${n.slice(0,ec-3)}…`:n:""}function xi(e){return ux(e.content)||""}function dx(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 tc(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],f=d.checkpointId,m=f??`cp-${c}`,h=d.metadata??{},v=typeof h.step=="number"?h.step:null,g=typeof h.source=="string"?h.source:null;let x=null,y=null;const w=Array.isArray(d.messages)?d.messages:[];for(const T of w)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:x};if(o.push(C),f&&t.set(f,C),f&&y){const T=xi(y);T&&r.set(f,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}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((f,m)=>{const h=f.createdAt?Date.parse(f.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-h});const d=c.length;for(let f=0;f<c.length;f++){const m=c[f];m.attemptCount=d,m.attemptIndex=f,m.isLatestAttempt=f===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 f of t.values())f.userMessageId===c&&d.push(f);return d.length?(d.sort((f,m)=>{const h=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return h-v}),d):[]}}}function nc(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 fx(e,t){return e?t.getCheckpoint(e)??null:null}function rc(e){return b.useMemo(()=>tc(e),[e])}function Pn(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Mn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function oc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function vi(e){const t=Pn(e);if(t)return Pn(t.configurable)??t}function Rn(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)=>hx(s,i)).filter(s=>!!s)].sort((s,i)=>sc(i.createdAt)-sc(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 hx(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>px(k)).filter(k=>!!k),o=Pn(e.metadata)??{},s=vi(e.config),i=Pn(e.parent_config??e.parentConfig),a=vi(i),l=Mn(s,["checkpoint_id","checkpointId"]),c=Mn(s,["checkpoint_ns","checkpointNs"]),d=Mn(a,["checkpoint_id","checkpointId"]),f=Mn(a,["checkpoint_id","checkpointId"])??null,m=Mn(a,["checkpoint_ns","checkpointNs"])??null,h=Pn(e.config),v=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=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:oc(o,["step"])??0,source:Mn(o,["source"])??null},w=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:w,nextCursor:f,nextCursorNs:m,interrupt:vx(r,t),metadata:y,config:h??null,parentConfig:i??null,next:g,tasks:v}}function px(e){var s,i,a;if(!e||typeof e!="object")return null;const t=mx(e);if(!t)return null;const n=xx(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 mx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&gx(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 gx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function xx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function vx(e,t){return bx(e,t)}function bx(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 sc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var bi={exports:{}},Wr={};/**
|
|
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 ic;function wx(){if(ic)return Wr;ic=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,
|
|
9
|
+
*/var ic;function wx(){if(ic)return Wr;ic=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,f={},m=null,h=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(h=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:h,props:f,_owner:o.current}}return Wr.Fragment=n,Wr.jsx=i,Wr.jsxs=i,Wr}var Vr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,29 +14,29 @@
|
|
|
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 ac;function yx(){return ac||(ac=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"),
|
|
18
|
-
`+
|
|
17
|
+
*/var ac;function yx(){return ac||(ac=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"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var re=v&&N[v]||N[g];return typeof re=="function"?re:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(N){{for(var re=arguments.length,ce=new Array(re>1?re-1:0),Ie=1;Ie<re;Ie++)ce[Ie-1]=arguments[Ie];S("error",N,ce)}}function S(N,re,ce){{var Ie=y.ReactDebugCurrentFrame,Je=Ie.getStackAddendum();Je!==""&&(re+="%s",ce=ce.concat([Je]));var rt=ce.map(function(Ve){return String(Ve)});rt.unshift("Warning: "+re),Function.prototype.apply.call(console[N],console,rt)}}var k=!1,C=!1,T=!1,E=!1,j=!1,_;_=Symbol.for("react.module.reference");function D(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||j||N===o||N===c||N===d||E||N===h||k||C||T||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===f||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===_||N.getModuleId!==void 0))}function F(N,re,ce){var Ie=N.displayName;if(Ie)return Ie;var Je=re.displayName||re.name||"";return Je!==""?ce+"("+Je+")":ce}function W(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 re=N;return W(re)+".Consumer";case i:var ce=N;return W(ce._context)+".Provider";case l:return F(N,N.render,"ForwardRef");case f:var Ie=N.displayName||null;return Ie!==null?Ie:G(N.type)||"Memo";case m:{var Je=N,rt=Je._payload,Ve=Je._init;try{return G(Ve(rt))}catch{return null}}}return null}var A=Object.assign,Y=0,q,z,M,I,U,K,P;function O(){}O.__reactDisabledLog=!0;function R(){{if(Y===0){q=console.log,z=console.info,M=console.warn,I=console.error,U=console.group,K=console.groupCollapsed,P=console.groupEnd;var N={configurable:!0,enumerable:!0,value:O,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}Y++}}function L(){{if(Y--,Y===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},N,{value:q}),info:A({},N,{value:z}),warn:A({},N,{value:M}),error:A({},N,{value:I}),group:A({},N,{value:U}),groupCollapsed:A({},N,{value:K}),groupEnd:A({},N,{value:P})})}Y<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ee=y.ReactCurrentDispatcher,B;function $(N,re,ce){{if(B===void 0)try{throw Error()}catch(Je){var Ie=Je.stack.trim().match(/\n( *(at )?)/);B=Ie&&Ie[1]||""}return`
|
|
18
|
+
`+B+N}}var Q=!1,X;{var te=typeof WeakMap=="function"?WeakMap:Map;X=new te}function J(N,re){if(!N||Q)return"";{var ce=X.get(N);if(ce!==void 0)return ce}var Ie;Q=!0;var Je=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var rt;rt=ee.current,ee.current=null,R();try{if(re){var Ve=function(){throw Error()};if(Object.defineProperty(Ve.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ve,[])}catch(Kt){Ie=Kt}Reflect.construct(N,[],Ve)}else{try{Ve.call()}catch(Kt){Ie=Kt}N.call(Ve.prototype)}}else{try{throw Error()}catch(Kt){Ie=Kt}N()}}catch(Kt){if(Kt&&Ie&&typeof Kt.stack=="string"){for(var He=Kt.stack.split(`
|
|
19
19
|
`),$t=Ie.stack.split(`
|
|
20
20
|
`),xt=He.length-1,bt=$t.length-1;xt>=1&&bt>=0&&He[xt]!==$t[bt];)bt--;for(;xt>=1&&bt>=0;xt--,bt--)if(He[xt]!==$t[bt]){if(xt!==1||bt!==1)do if(xt--,bt--,bt<0||He[xt]!==$t[bt]){var sn=`
|
|
21
|
-
`+He[xt].replace(" at new "," at ");return N.displayName&&sn.includes("<anonymous>")&&(sn=sn.replace("<anonymous>",N.displayName)),typeof N=="function"&&X.set(N,sn),sn}while(xt>=1&&bt>=0);break}}}finally{Q=!1,ee.current=rt,L(),Error.prepareStackTrace=Je}var zr=N?N.displayName||N.name:"",hr=zr?$(zr):"";return typeof N=="function"&&X.set(N,hr),hr}function ae(N,re,ce){return J(N,!1)}function ve(N){var re=N.prototype;return!!(re&&re.isReactComponent)}function de(N,re,ce){if(N==null)return"";if(typeof N=="function")return J(N,ve(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 ae(N.render);case
|
|
21
|
+
`+He[xt].replace(" at new "," at ");return N.displayName&&sn.includes("<anonymous>")&&(sn=sn.replace("<anonymous>",N.displayName)),typeof N=="function"&&X.set(N,sn),sn}while(xt>=1&&bt>=0);break}}}finally{Q=!1,ee.current=rt,L(),Error.prepareStackTrace=Je}var zr=N?N.displayName||N.name:"",hr=zr?$(zr):"";return typeof N=="function"&&X.set(N,hr),hr}function ae(N,re,ce){return J(N,!1)}function ve(N){var re=N.prototype;return!!(re&&re.isReactComponent)}function de(N,re,ce){if(N==null)return"";if(typeof N=="function")return J(N,ve(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 ae(N.render);case f:return de(N.type,re,ce);case m:{var Ie=N,Je=Ie._payload,rt=Ie._init;try{return de(rt(Je),re,ce)}catch{}}}return""}var me=Object.prototype.hasOwnProperty,Ce={},Te=y.ReactDebugCurrentFrame;function _e(N){if(N){var re=N._owner,ce=de(N.type,N._source,re?re.type:null);Te.setExtraStackFrame(ce)}else Te.setExtraStackFrame(null)}function dt(N,re,ce,Ie,Je){{var rt=Function.call.bind(me);for(var Ve in N)if(rt(N,Ve)){var He=void 0;try{if(typeof N[Ve]!="function"){var $t=Error((Ie||"React class")+": "+ce+" type `"+Ve+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[Ve]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw $t.name="Invariant Violation",$t}He=N[Ve](re,Ve,Ie,ce,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(xt){He=xt}He&&!(He instanceof Error)&&(_e(Je),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).",Ie||"React class",ce,Ve,typeof He),_e(null)),He instanceof Error&&!(He.message in Ce)&&(Ce[He.message]=!0,_e(Je),w("Failed %s type: %s",ce,He.message),_e(null))}}}var lt=Array.isArray;function Be(N){return lt(N)}function Fe(N){{var re=typeof Symbol=="function"&&Symbol.toStringTag,ce=re&&N[Symbol.toStringTag]||N.constructor.name||"Object";return ce}}function Le(N){try{return Ye(N),!1}catch{return!0}}function Ye(N){return""+N}function Me(N){if(Le(N))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Fe(N)),Ye(N)}var $e=y.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},It,it;function yt(N){if(me.call(N,"ref")){var re=Object.getOwnPropertyDescriptor(N,"ref").get;if(re&&re.isReactWarning)return!1}return N.ref!==void 0}function St(N){if(me.call(N,"key")){var re=Object.getOwnPropertyDescriptor(N,"key").get;if(re&&re.isReactWarning)return!1}return N.key!==void 0}function Ct(N,re){typeof N.ref=="string"&&$e.current}function kt(N,re){{var ce=function(){It||(It=!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)",re))};ce.isReactWarning=!0,Object.defineProperty(N,"key",{get:ce,configurable:!0})}}function on(N,re){{var ce=function(){it||(it=!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)",re))};ce.isReactWarning=!0,Object.defineProperty(N,"ref",{get:ce,configurable:!0})}}var Nt=function(N,re,ce,Ie,Je,rt,Ve){var He={$$typeof:t,type:N,key:re,ref:ce,props:Ve,_owner:rt};return He._store={},Object.defineProperty(He._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(He,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(He,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Je}),Object.freeze&&(Object.freeze(He.props),Object.freeze(He)),He};function Vt(N,re,ce,Ie,Je){{var rt,Ve={},He=null,$t=null;ce!==void 0&&(Me(ce),He=""+ce),St(re)&&(Me(re.key),He=""+re.key),yt(re)&&($t=re.ref,Ct(re,Je));for(rt in re)me.call(re,rt)&&!Qe.hasOwnProperty(rt)&&(Ve[rt]=re[rt]);if(N&&N.defaultProps){var xt=N.defaultProps;for(rt in xt)Ve[rt]===void 0&&(Ve[rt]=xt[rt])}if(He||$t){var bt=typeof N=="function"?N.displayName||N.name||"Unknown":N;He&&kt(Ve,bt),$t&&on(Ve,bt)}return Nt(N,He,$t,Je,Ie,$e.current,Ve)}}var Et=y.ReactCurrentOwner,ze=y.ReactDebugCurrentFrame;function Ke(N){if(N){var re=N._owner,ce=de(N.type,N._source,re?re.type:null);ze.setExtraStackFrame(ce)}else ze.setExtraStackFrame(null)}var At;At=!1;function Z(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function ue(){{if(Et.current){var N=G(Et.current.type);if(N)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+N+"`."}return""}}function We(N){return""}var be={};function pe(N){{var re=ue();if(!re){var ce=typeof N=="string"?N:N.displayName||N.name;ce&&(re=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+ce+">.")}return re}}function ye(N,re){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ce=pe(re);if(be[ce])return;be[ce]=!0;var Ie="";N&&N._owner&&N._owner!==Et.current&&(Ie=" It was passed a child from "+G(N._owner.type)+"."),Ke(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.',ce,Ie),Ke(null)}}function
|
|
25
|
+
Check the top-level render call using <`+ce+">.")}return re}}function ye(N,re){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ce=pe(re);if(be[ce])return;be[ce]=!0;var Ie="";N&&N._owner&&N._owner!==Et.current&&(Ie=" It was passed a child from "+G(N._owner.type)+"."),Ke(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.',ce,Ie),Ke(null)}}function Re(N,re){{if(typeof N!="object")return;if(Be(N))for(var ce=0;ce<N.length;ce++){var Ie=N[ce];Z(Ie)&&ye(Ie,re)}else if(Z(N))N._store&&(N._store.validated=!0);else if(N){var Je=x(N);if(typeof Je=="function"&&Je!==N.entries)for(var rt=Je.call(N),Ve;!(Ve=rt.next()).done;)Z(Ve.value)&&ye(Ve.value,re)}}}function qe(N){{var re=N.type;if(re==null||typeof re=="string")return;var ce;if(typeof re=="function")ce=re.propTypes;else if(typeof re=="object"&&(re.$$typeof===l||re.$$typeof===f))ce=re.propTypes;else return;if(ce){var Ie=G(re);dt(ce,N.props,"prop",Ie,N)}else if(re.PropTypes!==void 0&&!At){At=!0;var Je=G(re);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Je||"Unknown")}typeof re.getDefaultProps=="function"&&!re.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ct(N){{for(var re=Object.keys(N.props),ce=0;ce<re.length;ce++){var Ie=re[ce];if(Ie!=="children"&&Ie!=="key"){Ke(N),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),Ke(null);break}}N.ref!==null&&(Ke(N),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ke(null))}}var ut={};function Pe(N,re,ce,Ie,Je,rt){{var Ve=D(N);if(!Ve){var He="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(He+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var $t=We();$t?He+=$t:He+=ue();var xt;N===null?xt="null":Be(N)?xt="array":N!==void 0&&N.$$typeof===t?(xt="<"+(G(N.type)||"Unknown")+" />",He=" Did you accidentally export a JSX literal instead of a component?"):xt=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",xt,He)}var bt=Vt(N,re,ce,Je,rt);if(bt==null)return bt;if(Ve){var sn=re.children;if(sn!==void 0)if(Ie)if(Be(sn)){for(var zr=0;zr<sn.length;zr++)Re(sn[zr],N);Object.freeze&&Object.freeze(sn)}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 Re(sn,N)}if(me.call(re,"key")){var hr=G(N),Kt=Object.keys(re).filter(function(hN){return hN!=="key"}),Zl=Kt.length>0?"{key: someKey, "+Kt.join(": ..., ")+": ...}":"{key: someKey}";if(!ut[hr+Zl]){var fN=Kt.length>0?"{"+Kt.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} />`,Zl,hr,fN,hr),ut[hr+Zl]=!0}}return N===r?ct(bt):qe(bt),bt}}function gt(N,re,ce){return Pe(N,re,ce,!0)}function et(N,re,ce){return Pe(N,re,ce,!1)}var ft=et,In=gt;Vr.Fragment=r,Vr.jsx=ft,Vr.jsxs=In}()),Vr}process.env.NODE_ENV==="production"?bi.exports=wx():bi.exports=yx();var u=bi.exports;const Sx=({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 p=["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:p,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 v=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 ${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: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 lc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cx}=Object.prototype,{getPrototypeOf:wi}=Object,{iterator:Oo,toStringTag:cc}=Symbol,Do=(e=>t=>{const n=Cx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Lo("undefined");function Kr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const uc=an("ArrayBuffer");function Tx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uc(e.buffer),t}const kx=Lo("string"),Ft=Lo("function"),dc=Lo("number"),qr=e=>e!==null&&typeof e=="object",Ex=e=>e===!0||e===!1,$o=e=>{if(Do(e)!=="object")return!1;const t=wi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(cc in e)&&!(Oo in e)},Ix=e=>{if(!qr(e)||Kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Nx=an("Date"),Ax=an("File"),jx=an("Blob"),_x=an("FileList"),Px=e=>qr(e)&&Ft(e.pipe),Rx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=Do(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},Mx=an("URLSearchParams"),[Ox,Dx,Lx,$x]=["ReadableStream","Request","Response","Headers"].map(an),Fx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Gr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Kr(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 fc(e,t){if(Kr(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,hc=e=>!mr(e)&&e!==Jn;function yi(){const{caseless:e,skipUndefined:t}=hc(this)&&this||{},n={},r=(o,s)=>{const i=e&&fc(n,s)||s;$o(n[i])&&$o(o)?n[i]=yi(n[i],o):$o(o)?n[i]=yi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Gr(arguments[o],r);return n}const Bx=(e,t,n,{allOwnKeys:r}={})=>(Gr(t,(o,s)=>{n&&Ft(o)?e[s]=lc(o,n):e[s]=o},{allOwnKeys:r}),e),zx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hx=(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)},Ux=(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&&wi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wx=(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},Vx=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!dc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Kx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&wi(Uint8Array)),qx=(e,t)=>{const r=(e&&e[Oo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Gx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yx=an("HTMLFormElement"),Xx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),pc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Jx=an("RegExp"),mc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Gr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Zx=e=>{mc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(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+"'")})}})},Qx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},ev=()=>{},tv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nv(e){return!!(e&&Ft(e.append)&&e[cc]==="FormData"&&e[Oo])}const rv=e=>{const t=new Array(10),n=(r,o)=>{if(qr(r)){if(t.indexOf(r)>=0)return;if(Kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return Gr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ov=an("AsyncFunction"),sv=e=>e&&(qr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),gc=((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",Ft(Jn.postMessage)),iv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||gc,V={isArray:pr,isArrayBuffer:uc,isBuffer:Kr,isFormData:Rx,isArrayBufferView:Tx,isString:kx,isNumber:dc,isBoolean:Ex,isObject:qr,isPlainObject:$o,isEmptyObject:Ix,isReadableStream:Ox,isRequest:Dx,isResponse:Lx,isHeaders:$x,isUndefined:mr,isDate:Nx,isFile:Ax,isBlob:jx,isRegExp:Jx,isFunction:Ft,isStream:Px,isURLSearchParams:Mx,isTypedArray:Kx,isFileList:_x,forEach:Gr,merge:yi,extend:Bx,trim:Fx,stripBOM:zx,inherits:Hx,toFlatObject:Ux,kindOf:Do,kindOfTest:an,endsWith:Wx,toArray:Vx,forEachEntry:qx,matchAll:Gx,isHTMLForm:Yx,hasOwnProperty:pc,hasOwnProp:pc,reduceDescriptors:mc,freezeMethods:Zx,toObjectSet:Qx,toCamelCase:Xx,noop:ev,toFiniteNumber:tv,findKey:fc,global:Jn,isContextDefined:hc,isSpecCompliantForm:nv,toJSONObject:rv,isAsyncFn:ov,isThenable:sv,setImmediate:gc,asap:iv,isIterable:e=>e!=null&&Ft(e[Oo])};function Ae(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(Ae,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 xc=Ae.prototype,vc={};["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=>{vc[e]={value:e}}),Object.defineProperties(Ae,vc),Object.defineProperty(xc,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(xc);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 Ae.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 av=null;function Si(e){return V.isPlainObject(e)||V.isArray(e)}function bc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function wc(e,t,n){return e?e.concat(t).map(function(o,s){return o=bc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function lv(e){return V.isArray(e)&&!e.some(Si)}const cv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(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 Ae("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)&&lv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=bc(g),y.forEach(function(S,k){!(V.isUndefined(S)||S===null)&&t.append(i===!0?wc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return Si(v)?!0:(t.append(wc(x,g,s),c(v)),!1)}const h=[],p=Object.assign(cv,{defaultVisitor:d,convertValue:c,isVisitable:Si});function f(v,g){if(!V.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),V.forEach(v,function(y,w){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(w)?w.trim():w,g,p))===!0&&f(y,g?g.concat(w):[w])}),h.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return f(e),t}function yc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ci(e,t){this._pairs=[],e&&Fo(e,this,t)}const Sc=Ci.prototype;Sc.append=function(t,n){this._pairs.push([t,n])},Sc.toString=function(t){const n=t?function(r){return t.call(this,r,yc)}:yc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function uv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Cc(e,t,n){if(!t)return e;const r=n&&n.encode||uv;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 Ci(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Tc{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 kc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ci,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ti=typeof window<"u"&&typeof document<"u",ki=typeof navigator=="object"&&navigator||void 0,fv=Ti&&(!ki||["ReactNative","NativeScript","NS"].indexOf(ki.product)<0),hv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pv=Ti&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ti,hasStandardBrowserEnv:fv,hasStandardBrowserWebWorkerEnv:hv,navigator:ki,origin:pv},Symbol.toStringTag,{value:"Module"})),...dv};function mv(e,t){return Fo(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function gv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xv(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 Ec(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]=xv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(gv(r),o,n,0)}),n}return null}function vv(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 Yr={transitional:kc,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(Ec(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 mv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),vv(t)):t}],transformResponse:[function(t){const n=this.transitional||Yr.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"?Ae.from(a,Ae.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:jt.classes.FormData,Blob:jt.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=>{Yr.headers[e]={}});const bv=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"]),wv=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]&&bv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ic=Symbol("internals");function Xr(e){return e&&String(e).trim().toLowerCase()}function Bo(e){return e===!1||e==null?e:V.isArray(e)?e.map(Bo):String(e)}function yv(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 Sv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ei(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 Cv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Tv(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 Bt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Xr(l);if(!d)throw new Error("header name must be a non-empty string");const
|
|
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[Ic]=this[Ic]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Xr(i);r[a]||(Tv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Bt);function Ii(e,t){const n=this||Yr,r=t||n,o=Bt.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 Nc(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(gr,Ae,{__CANCEL__:!0});function Ac(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function kv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ev(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 h=s,p=0;for(;h!==o;)p+=n[h++],h=h%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(p*1e3/f):void 0}}function Iv(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(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const zo=(e,t,n=3)=>{let r=0;const o=Ev(50,250);return Iv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={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(h)},n)},jc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},_c=e=>(...t)=>V.asap(()=>e(...t)),Nv=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,Av=jt.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 jv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _v(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Pc(e,t,n){let r=!jv(t);return e&&(r||n==!1)?_v(e,t):t}const Rc=e=>e instanceof Bt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,h,p){return V.isPlainObject(c)&&V.isPlainObject(d)?V.merge.call({caseless:p},c,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(c,d,h,p){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,h,p)}else return r(c,d,h,p)}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,h){if(h in t)return r(c,d);if(h 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,h)=>o(Rc(c),Rc(d),h,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,p=h(e[d],t[d],d);V.isUndefined(p)&&h!==a||(n[d]=p)}),n}const Mc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.from(i),t.url=Cc(Pc(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(jt.hasStandardBrowserEnv||jt.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,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(jt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Nv(t.url))){const l=o&&s&&Av.read(s);l&&i.set(o,l)}return t},Pv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Mc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,p,f,v;function g(){f&&f(),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 S=Bt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Ac(function(E){n(E),g()},function(E){r(E),g()},C),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 Ae("Request aborted",Ae.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Ae(C,Ae.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||kc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ae(k,C.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([p,v]=zo(c,!0),x.addEventListener("progress",p)),l&&x.upload&&([h,f]=zo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=kv(o.url);if(w&&jt.protocols.indexOf(w)===-1){r(new Ae("Unsupported protocol "+w+":",Ae.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Rv=(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 Ae?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.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}},Mv=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},Ov=async function*(e,t){for await(const n of Dv(e))yield*Mv(n,t)},Dv=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()}},Oc=(e,t,n,r)=>{const o=Ov(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 h=d.byteLength;if(n){let p=s+=h;n(p)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Dc=64*1024,{isFunction:Ho}=V,Lv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Lc,TextEncoder:$c}=V.global,Fc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$v=e=>{e=V.merge.call({skipUndefined:!0},Lv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(Lc),l=o&&(typeof $c=="function"?(v=>g=>v.encode(g))(new $c):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Fc(()=>{let v=!1;const g=new n(jt.origin,{body:new Lc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Fc(()=>V.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Ae(`Response type '${v}' is not supported`,Ae.ERR_NOT_SUPPORT,x)})});const p=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(jt.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},f=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??p(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:_="same-origin",fetchOptions:D}=Mc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let W=Rv([w,S&&S.toAbortSignal()],k),G=null;const A=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let Y;try{if(T&&c&&x!=="get"&&x!=="head"&&(Y=await f(j,y))!==0){let K=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(V.isFormData(y)&&(P=K.headers.get("content-type"))&&j.setContentType(P),K.body){const[O,M]=jc(Y,zo(_c(T)));y=Oc(K.body,Dc,O,M)}}V.isString(_)||(_=_?"include":"omit");const q=s&&"credentials"in n.prototype,B={...D,signal:W,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:q?_:void 0};G=s&&new n(g,B);let R=await(s?F(G,D):F(g,B));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&A)){const K={};["status","statusText","headers"].forEach(L=>{K[L]=R[L]});const P=V.toFiniteNumber(R.headers.get("content-length")),[O,M]=C&&jc(P,zo(_c(C),!0))||[];R=new r(Oc(R.body,Dc,O,()=>{M&&M(),A&&A()}),K)}E=E||"text";let U=await h[V.findKey(h,E)||"text"](R,v);return!I&&A&&A(),await new Promise((K,P)=>{Ac(K,P,{data:U,headers:Bt.from(R.headers),status:R.status,statusText:R.statusText,config:v,request:G})})}catch(q){throw A&&A(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,v,G),{cause:q.cause||q}):Ae.from(q,q&&q.code,v,G)}}},Fv=new Map,Bc=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=Fv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:$v(t)),d=c;return c};Bc();const Ni={http:av,xhr:Pv,fetch:{get:Bc}};V.forEach(Ni,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const zc=e=>`- ${e}`,Bv=e=>V.isFunction(e)||e===null||e===!1,Hc={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,!Bv(r)&&(o=Ni[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`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} />`,Zl,hr,fN,hr),ut[hr+Zl]=!0}}return N===r?ct(bt):qe(bt),bt}}function gt(N,re,ce){return Pe(N,re,ce,!0)}function et(N,re,ce){return Pe(N,re,ce,!1)}var ft=et,In=gt;Vr.Fragment=r,Vr.jsx=ft,Vr.jsxs=In}()),Vr}process.env.NODE_ENV==="production"?bi.exports=wx():bi.exports=yx();var u=bi.exports;const Sx=({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(h=>{const v=d===h.id,g=(r==null?void 0:r.get(h.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(h.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:h.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[h.step!==null?`STEP ${h.step}`:"STEP —",h.next?` - ${h.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},h.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 lc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cx}=Object.prototype,{getPrototypeOf:wi}=Object,{iterator:Oo,toStringTag:cc}=Symbol,Do=(e=>t=>{const n=Cx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Lo("undefined");function Kr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const uc=an("ArrayBuffer");function Tx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uc(e.buffer),t}const kx=Lo("string"),Ft=Lo("function"),dc=Lo("number"),qr=e=>e!==null&&typeof e=="object",Ex=e=>e===!0||e===!1,$o=e=>{if(Do(e)!=="object")return!1;const t=wi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(cc in e)&&!(Oo in e)},Ix=e=>{if(!qr(e)||Kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Nx=an("Date"),Ax=an("File"),jx=an("Blob"),_x=an("FileList"),Px=e=>qr(e)&&Ft(e.pipe),Mx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=Do(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},Rx=an("URLSearchParams"),[Ox,Dx,Lx,$x]=["ReadableStream","Request","Response","Headers"].map(an),Fx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Gr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Kr(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 fc(e,t){if(Kr(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,hc=e=>!mr(e)&&e!==Jn;function yi(){const{caseless:e,skipUndefined:t}=hc(this)&&this||{},n={},r=(o,s)=>{const i=e&&fc(n,s)||s;$o(n[i])&&$o(o)?n[i]=yi(n[i],o):$o(o)?n[i]=yi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Gr(arguments[o],r);return n}const Bx=(e,t,n,{allOwnKeys:r}={})=>(Gr(t,(o,s)=>{n&&Ft(o)?e[s]=lc(o,n):e[s]=o},{allOwnKeys:r}),e),zx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hx=(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)},Ux=(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&&wi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wx=(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},Vx=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!dc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Kx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&wi(Uint8Array)),qx=(e,t)=>{const r=(e&&e[Oo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Gx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yx=an("HTMLFormElement"),Xx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),pc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Jx=an("RegExp"),mc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Gr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Zx=e=>{mc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(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+"'")})}})},Qx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},ev=()=>{},tv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nv(e){return!!(e&&Ft(e.append)&&e[cc]==="FormData"&&e[Oo])}const rv=e=>{const t=new Array(10),n=(r,o)=>{if(qr(r)){if(t.indexOf(r)>=0)return;if(Kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return Gr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ov=an("AsyncFunction"),sv=e=>e&&(qr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),gc=((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",Ft(Jn.postMessage)),iv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||gc,V={isArray:pr,isArrayBuffer:uc,isBuffer:Kr,isFormData:Mx,isArrayBufferView:Tx,isString:kx,isNumber:dc,isBoolean:Ex,isObject:qr,isPlainObject:$o,isEmptyObject:Ix,isReadableStream:Ox,isRequest:Dx,isResponse:Lx,isHeaders:$x,isUndefined:mr,isDate:Nx,isFile:Ax,isBlob:jx,isRegExp:Jx,isFunction:Ft,isStream:Px,isURLSearchParams:Rx,isTypedArray:Kx,isFileList:_x,forEach:Gr,merge:yi,extend:Bx,trim:Fx,stripBOM:zx,inherits:Hx,toFlatObject:Ux,kindOf:Do,kindOfTest:an,endsWith:Wx,toArray:Vx,forEachEntry:qx,matchAll:Gx,isHTMLForm:Yx,hasOwnProperty:pc,hasOwnProp:pc,reduceDescriptors:mc,freezeMethods:Zx,toObjectSet:Qx,toCamelCase:Xx,noop:ev,toFiniteNumber:tv,findKey:fc,global:Jn,isContextDefined:hc,isSpecCompliantForm:nv,toJSONObject:rv,isAsyncFn:ov,isThenable:sv,setImmediate:gc,asap:iv,isIterable:e=>e!=null&&Ft(e[Oo])};function Ae(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(Ae,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 xc=Ae.prototype,vc={};["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=>{vc[e]={value:e}}),Object.defineProperties(Ae,vc),Object.defineProperty(xc,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(xc);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 Ae.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 av=null;function Si(e){return V.isPlainObject(e)||V.isArray(e)}function bc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function wc(e,t,n){return e?e.concat(t).map(function(o,s){return o=bc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function lv(e){return V.isArray(e)&&!e.some(Si)}const cv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(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 Ae("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)&&lv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=bc(g),y.forEach(function(S,k){!(V.isUndefined(S)||S===null)&&t.append(i===!0?wc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return Si(v)?!0:(t.append(wc(x,g,s),c(v)),!1)}const f=[],m=Object.assign(cv,{defaultVisitor:d,convertValue:c,isVisitable:Si});function h(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&&h(y,g?g.concat(w):[w])}),f.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return h(e),t}function yc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ci(e,t){this._pairs=[],e&&Fo(e,this,t)}const Sc=Ci.prototype;Sc.append=function(t,n){this._pairs.push([t,n])},Sc.toString=function(t){const n=t?function(r){return t.call(this,r,yc)}:yc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function uv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Cc(e,t,n){if(!t)return e;const r=n&&n.encode||uv;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 Ci(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Tc{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 kc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ci,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ti=typeof window<"u"&&typeof document<"u",ki=typeof navigator=="object"&&navigator||void 0,fv=Ti&&(!ki||["ReactNative","NativeScript","NS"].indexOf(ki.product)<0),hv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pv=Ti&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ti,hasStandardBrowserEnv:fv,hasStandardBrowserWebWorkerEnv:hv,navigator:ki,origin:pv},Symbol.toStringTag,{value:"Module"})),...dv};function mv(e,t){return Fo(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function gv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xv(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 Ec(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]=xv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(gv(r),o,n,0)}),n}return null}function vv(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 Yr={transitional:kc,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(Ec(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 mv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),vv(t)):t}],transformResponse:[function(t){const n=this.transitional||Yr.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"?Ae.from(a,Ae.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:jt.classes.FormData,Blob:jt.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=>{Yr.headers[e]={}});const bv=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"]),wv=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]&&bv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ic=Symbol("internals");function Xr(e){return e&&String(e).trim().toLowerCase()}function Bo(e){return e===!1||e==null?e:V.isArray(e)?e.map(Bo):String(e)}function yv(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 Sv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ei(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 Cv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Tv(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 Bt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Xr(l);if(!d)throw new Error("header name must be a non-empty string");const f=V.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=Bo(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())&&!Sv(t))i(wv(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=Xr(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return yv(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=Xr(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ei(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Xr(i),i){const a=V.findKey(r,i);a&&(!n||Ei(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||Ei(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]=Bo(o),delete n[s];return}const a=t?Cv(s):String(s).trim();a!==s&&delete n[s],n[a]=Bo(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[Ic]=this[Ic]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Xr(i);r[a]||(Tv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Bt);function Ii(e,t){const n=this||Yr,r=t||n,o=Bt.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 Nc(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(gr,Ae,{__CANCEL__:!0});function Ac(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function kv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ev(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 h=d&&c-d;return h?Math.round(m*1e3/h):void 0}}function Iv(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 zo=(e,t,n=3)=>{let r=0;const o=Ev(50,250);return Iv(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)},jc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},_c=e=>(...t)=>V.asap(()=>e(...t)),Nv=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,Av=jt.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 jv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _v(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Pc(e,t,n){let r=!jv(t);return e&&(r||n==!1)?_v(e,t):t}const Mc=e=>e instanceof Bt?{...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(Mc(c),Mc(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 Rc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.from(i),t.url=Cc(Pc(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(jt.hasStandardBrowserEnv||jt.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(jt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Nv(t.url))){const l=o&&s&&Av.read(s);l&&i.set(o,l)}return t},Pv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Rc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,m,h,v;function g(){h&&h(),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 S=Bt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Ac(function(E){n(E),g()},function(E){r(E),g()},C),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 Ae("Request aborted",Ae.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Ae(C,Ae.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||kc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ae(k,C.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=zo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,h]=zo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=kv(o.url);if(w&&jt.protocols.indexOf(w)===-1){r(new Ae("Unsupported protocol "+w+":",Ae.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Mv=(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 Ae?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.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}},Rv=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},Ov=async function*(e,t){for await(const n of Dv(e))yield*Rv(n,t)},Dv=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()}},Oc=(e,t,n,r)=>{const o=Ov(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})},Dc=64*1024,{isFunction:Ho}=V,Lv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Lc,TextEncoder:$c}=V.global,Fc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$v=e=>{e=V.merge.call({skipUndefined:!0},Lv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(Lc),l=o&&(typeof $c=="function"?(v=>g=>v.encode(g))(new $c):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Fc(()=>{let v=!1;const g=new n(jt.origin,{body:new Lc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Fc(()=>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 Ae(`Response type '${v}' is not supported`,Ae.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(jt.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},h=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:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:_="same-origin",fetchOptions:D}=Rc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let W=Mv([w,S&&S.toAbortSignal()],k),G=null;const A=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let Y;try{if(T&&c&&x!=="get"&&x!=="head"&&(Y=await h(j,y))!==0){let K=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(V.isFormData(y)&&(P=K.headers.get("content-type"))&&j.setContentType(P),K.body){const[O,R]=jc(Y,zo(_c(T)));y=Oc(K.body,Dc,O,R)}}V.isString(_)||(_=_?"include":"omit");const q=s&&"credentials"in n.prototype,z={...D,signal:W,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:q?_:void 0};G=s&&new n(g,z);let M=await(s?F(G,D):F(g,z));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&A)){const K={};["status","statusText","headers"].forEach(L=>{K[L]=M[L]});const P=V.toFiniteNumber(M.headers.get("content-length")),[O,R]=C&&jc(P,zo(_c(C),!0))||[];M=new r(Oc(M.body,Dc,O,()=>{R&&R(),A&&A()}),K)}E=E||"text";let U=await f[V.findKey(f,E)||"text"](M,v);return!I&&A&&A(),await new Promise((K,P)=>{Ac(K,P,{data:U,headers:Bt.from(M.headers),status:M.status,statusText:M.statusText,config:v,request:G})})}catch(q){throw A&&A(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,v,G),{cause:q.cause||q}):Ae.from(q,q&&q.code,v,G)}}},Fv=new Map,Bc=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=Fv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:$v(t)),d=c;return c};Bc();const Ni={http:av,xhr:Pv,fetch:{get:Bc}};V.forEach(Ni,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const zc=e=>`- ${e}`,Bv=e=>V.isFunction(e)||e===null||e===!1,Hc={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,!Bv(r)&&(o=Ni[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`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(zc).join(`
|
|
34
34
|
`):" "+zc(i[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ni};function Ai(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Uc(e){return Ai(e),e.headers=Bt.from(e.headers),e.data=Ii.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Hc.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){return Ai(e),r.data=Ii.call(e,e.transformResponse,r),r.headers=Bt.from(r.headers),r},function(r){return Nc(r)||(Ai(e),r&&r.response&&(r.response.data=Ii.call(e,e.transformResponse,r.response),r.response.headers=Bt.from(r.response.headers))),Promise.reject(r)})}const Wc="1.12.2",Uo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Uo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Vc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Wc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ae(o(i," has been removed"+(n?" in "+n:"")),Ae.ERR_DEPRECATED);return n&&!Vc[i]&&(Vc[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}},Uo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function zv(e,t,n){if(typeof e!="object")throw new Ae("options must be an object",Ae.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 Ae("option "+s+" must be "+l,Ae.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ae("Unknown option "+s,Ae.ERR_BAD_OPTION)}}const Wo={assertOptions:zv,validators:Uo},gn=Wo.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Tc,response:new Tc}}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&&Wo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Wo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.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=Bt.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,h=0,p;if(!l){const v=[Uc.bind(this),void 0];for(v.unshift(...a),v.push(...c),p=v.length,d=Promise.resolve(n);h<p;)d=d.then(v[h++],v[h++]);return d}p=a.length;let f=n;for(;h<p;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Uc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,p=c.length;h<p;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Pc(t.baseURL,t.url,t.allowAbsoluteUrls);return Cc(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 Hv=class ax{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ax(function(o){t=o}),cancel:t}}};function Uv(e){return function(n){return e.apply(null,n)}}function Wv(e){return V.isObject(e)&&e.isAxiosError===!0}const ji={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(ji).forEach(([e,t])=>{ji[t]=e});function Kc(e){const t=new Qn(e),n=lc(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 Kc(Zn(e,o))},n}const ht=Kc(Yr);ht.Axios=Qn,ht.CanceledError=gr,ht.CancelToken=Hv,ht.isCancel=Nc,ht.VERSION=Wc,ht.toFormData=Fo,ht.AxiosError=Ae,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Uv,ht.isAxiosError=Wv,ht.mergeConfig=Zn,ht.AxiosHeaders=Bt,ht.formToJSON=e=>Ec(V.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=Hc.getAdapter,ht.HttpStatusCode=ji,ht.default=ht;const{Axios:SN,AxiosError:CN,CanceledError:TN,isCancel:qc,CancelToken:kN,VERSION:EN,all:IN,Cancel:NN,isAxiosError:AN,spread:jN,toFormData:_N,AxiosHeaders:PN,HttpStatusCode:RN,formToJSON:MN,getAdapter:ON,mergeConfig:DN}=ht,Gc=typeof window<"u"?window.__API_BASE_URL__:void 0,Yc=Gc?xn(Gc):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Vo=null;const _i=new Set;function Xc(){return Vo}function Ko(e){Vo=e,_i.forEach(t=>t(e))}function Jc(e){return _i.add(e),()=>_i.delete(e)}const Zc=3e4,Qc=9e4,Gt=ht.create({...Yc?{baseURL:Yc}:{},timeout:Zc,withCredentials:!0});Gt.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),Gt.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),Ko(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 Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qo(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function eu(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Pi(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Go{get baseUrl(){const t=Gt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Ko(t.authToken)}getAuthToken(){return Xc()}setAuthToken(t){Ko(t)}onTokenChange(t){return Jc(t)}async listThreads(){const t=await Yt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qo("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await eu(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await Pi(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await qo(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Yt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Qc,signal:t.signal});return Ot(n)}async cancelRun(t){const n=await qo("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await Pi(`/threads/${t}/share/${n}`);return Ot(r)}}const Nn=new Go,Vv=Go,Kv=Go;async function Ri(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function qv(e,t){const n=await Ri(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Mi(e,t){return await(await Ri(`/files/${e}/view`,t)).text()}async function tu(e,t){const n=await Ri(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Gv(e){return await Yt(`/files/${e}`)}async function nu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const ru=b.createContext(null);function ou({children:e,apiConfig:t}){const n=Nn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(ru.Provider,{value:r,children:e})}async function su(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 iu(e=[]){const t=[],n=[];for(const r of e)try{const o=await su(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Jr(){const e=b.useContext(ru);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function au(e){return!!e&&typeof e=="object"&&"data"in e}function Oi(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 Zr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Yv(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 lu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function cu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function uu(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(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??cu(e);let l="",c=e.slice();if(s){const h=Xv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const p=c[c.length-1];if((p==null?void 0:p.type)==="text"){const f=p.text??"",v={...p,text:f+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 du(e){return e.replace(/\s+/g," ").trim()}function Xv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=du(e),o=du(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function Jv(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 Zr(e,r,s)}return e}function fu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Zv(e={}){const t=b.useMemo(()=>xn(e.baseUrl),[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),[h,p]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),E=b.useRef(0),j=b.useRef(null),_=b.useRef(null),D=b.useRef(null),F=b.useRef(null),W=b.useRef({messageId:null,lastSeq:null,lastText:""}),G=b.useCallback(B=>{o(B)},[]),A=b.useCallback(()=>{p(""),v(null),d(null),_.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=b.useCallback(()=>{var U;console.debug("[use-chat] stop() invoked - aborting stream");const B=(U=j.current)==null?void 0:U.threadId,R=()=>{var K;(K=C.current)==null||K.abort(),C.current=null,j.current=null,l(!1),w(!1),E.current=0,x(0)};(B?Nn.cancelRun(B).catch(K=>{console.warn("[use-chat] cancel run failed:",K)}):Promise.resolve()).finally(R)},[]),q=b.useCallback((B,R,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&p(""),v(null),_.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""};const U=new AbortController;C.current=U;let K=null,P=null,O=!1;return j.current={threadId:B.threadId??null,headers:{}},(async()=>{var L,ee,z,$,Q,X,te,J,ae,ve,de,me,Ce,Te,_e,dt,lt,Be;const M=Fe=>{var Le;try{const Ye=JSON.parse(JSON.stringify(Fe));return(Le=Ye==null?void 0:Ye.payload)!=null&&Le.files_info&&Array.isArray(Ye.payload.files_info)&&(Ye.payload.files_info=Ye.payload.files_info.map(Re=>({...Re,data:Re!=null&&Re.data?`<base64 ${String(Re.data).length} chars>`:Re==null?void 0:Re.data}))),Ye}catch{return Fe}};try{let Fe={};try{if(r)Fe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,At=((L=window.localStorage)==null?void 0:L.getItem("authToken"))||null;let Z=null;try{const We=(ee=window.localStorage)==null?void 0:ee.getItem("chat-settings");We&&(Z=((z=JSON.parse(We))==null?void 0:z.apiKey)||null)}catch{}const ue=Ke||At||Z||null;ue&&(Fe={Authorization:`Bearer ${ue}`})}}catch{}console.debug("[use-chat] POST",t+n,M(B));let Le={};if(typeof window<"u")try{const ze=($=window.localStorage)==null?void 0:$.getItem("authSessionId");ze&&(Le={"X-Session-Id":ze})}catch{}const Ye={...Fe,...Le,...s.current},Re={"Content-Type":"application/json",Accept:"text/event-stream",...Ye},$e=await fetch(t+n,{method:"POST",headers:Re,body:JSON.stringify(B),signal:U.signal,credentials:i});if(j.current&&(j.current.headers=Ye),!$e.ok||!$e.body){const ze=await $e.text().catch(()=>"");console.debug("[use-chat] non-OK response",$e.status,ze==null?void 0:ze.slice(0,500));const Ke=`stream ${$e.status}${ze?": "+ze:""}`;throw(Q=I==null?void 0:I.onConnectionError)==null||Q.call(I,Ke),O=!0,K="error",P=Ke,new Error(Ke)}w(!0);const Qe=$e.body.getReader(),It=new TextDecoder;let it="",yt=[];E.current=0,x(0);let St=0,Ct=null;const kt=()=>{if(yt.length){const ze=yt.join("");yt=[],T.current&&p(Ke=>Ke+ze)}Ct=null},on=()=>{typeof window<"u"&&Ct==null&&(Ct=requestAnimationFrame(kt))};let Nt=Date.now();const Vt=setInterval(()=>{var ze;if(Date.now()-Nt>18e5){const Ke="Stream idle timeout";d(Ke),K="error",P=Ke,U.abort(),(ze=I==null?void 0:I.onError)==null||ze.call(I,Ke)}},5e3),Et=1024*1024;try{const ze=$e.headers.get("X-Thread-Id")||$e.headers.get("x-thread-id"),Ke=$e.headers.get("X-Thread-Created")||$e.headers.get("x-thread-created"),At=ze??null,Z=String(Ke??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:At}),(X=I==null?void 0:I.onOpen)==null||X.call(I,{threadId:At,created:Z});;){const{value:ue,done:We}=await Qe.read();if(We)break;it+=It.decode(ue,{stream:!0}),it.length>Et&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let be;for(;(be=it.indexOf(`
|
|
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&&Wo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Wo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.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=Bt.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=[Uc.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 h=n;for(;f<m;){const v=a[f++],g=a[f++];try{h=v(h)}catch(x){g.call(this,x);break}}try{d=Uc.call(this,h)}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=Pc(t.baseURL,t.url,t.allowAbsoluteUrls);return Cc(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 Hv=class ax{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ax(function(o){t=o}),cancel:t}}};function Uv(e){return function(n){return e.apply(null,n)}}function Wv(e){return V.isObject(e)&&e.isAxiosError===!0}const ji={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(ji).forEach(([e,t])=>{ji[t]=e});function Kc(e){const t=new Qn(e),n=lc(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 Kc(Zn(e,o))},n}const ht=Kc(Yr);ht.Axios=Qn,ht.CanceledError=gr,ht.CancelToken=Hv,ht.isCancel=Nc,ht.VERSION=Wc,ht.toFormData=Fo,ht.AxiosError=Ae,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Uv,ht.isAxiosError=Wv,ht.mergeConfig=Zn,ht.AxiosHeaders=Bt,ht.formToJSON=e=>Ec(V.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=Hc.getAdapter,ht.HttpStatusCode=ji,ht.default=ht;const{Axios:SN,AxiosError:CN,CanceledError:TN,isCancel:qc,CancelToken:kN,VERSION:EN,all:IN,Cancel:NN,isAxiosError:AN,spread:jN,toFormData:_N,AxiosHeaders:PN,HttpStatusCode:MN,formToJSON:RN,getAdapter:ON,mergeConfig:DN}=ht,Gc=typeof window<"u"?window.__API_BASE_URL__:void 0,Yc=Gc?xn(Gc):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Vo=null;const _i=new Set;function Xc(){return Vo}function Ko(e){Vo=e,_i.forEach(t=>t(e))}function Jc(e){return _i.add(e),()=>_i.delete(e)}const Zc=3e4,Qc=9e4,Gt=ht.create({...Yc?{baseURL:Yc}:{},timeout:Zc,withCredentials:!0});Gt.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),Gt.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),Ko(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 Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qo(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function eu(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Pi(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Go{get baseUrl(){const t=Gt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Ko(t.authToken)}getAuthToken(){return Xc()}setAuthToken(t){Ko(t)}onTokenChange(t){return Jc(t)}async listThreads(){const t=await Yt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qo("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await eu(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await Pi(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await qo(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Yt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Qc,signal:t.signal});return Ot(n)}async cancelRun(t){const n=await qo("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await Pi(`/threads/${t}/share/${n}`);return Ot(r)}}const Nn=new Go,Vv=Go,Kv=Go;async function Mi(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function qv(e,t){const n=await Mi(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ri(e,t){return await(await Mi(`/files/${e}/view`,t)).text()}async function tu(e,t){const n=await Mi(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Gv(e){return await Yt(`/files/${e}`)}async function nu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const ru=b.createContext(null);function ou({children:e,apiConfig:t}){const n=Nn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(ru.Provider,{value:r,children:e})}async function su(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 iu(e=[]){const t=[],n=[];for(const r of e)try{const o=await su(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Jr(){const e=b.useContext(ru);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function au(e){return!!e&&typeof e=="object"&&"data"in e}function Oi(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 Zr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Yv(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 lu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function cu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function uu(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??cu(e);let l="",c=e.slice();if(s){const f=Xv(a,s);if(f===""?l="":f===s?l=s:l=f,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const h=m.text??"",v={...m,text:h+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 du(e){return e.replace(/\s+/g," ").trim()}function Xv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=du(e),o=du(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function Jv(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 Zr(e,r,s)}return e}function fu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Zv(e={}){const t=b.useMemo(()=>xn(e.baseUrl),[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(""),[h,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),E=b.useRef(0),j=b.useRef(null),_=b.useRef(null),D=b.useRef(null),F=b.useRef(null),W=b.useRef({messageId:null,lastSeq:null,lastText:""}),G=b.useCallback(z=>{o(z)},[]),A=b.useCallback(()=>{m(""),v(null),d(null),_.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=b.useCallback(()=>{var U;console.debug("[use-chat] stop() invoked - aborting stream");const z=(U=j.current)==null?void 0:U.threadId,M=()=>{var K;(K=C.current)==null||K.abort(),C.current=null,j.current=null,l(!1),w(!1),E.current=0,x(0)};(z?Nn.cancelRun(z).catch(K=>{console.warn("[use-chat] cancel run failed:",K)}):Promise.resolve()).finally(M)},[]),q=b.useCallback((z,M,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),_.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""};const U=new AbortController;C.current=U;let K=null,P=null,O=!1;return j.current={threadId:z.threadId??null,headers:{}},(async()=>{var L,ee,B,$,Q,X,te,J,ae,ve,de,me,Ce,Te,_e,dt,lt,Be;const R=Fe=>{var Le;try{const Ye=JSON.parse(JSON.stringify(Fe));return(Le=Ye==null?void 0:Ye.payload)!=null&&Le.files_info&&Array.isArray(Ye.payload.files_info)&&(Ye.payload.files_info=Ye.payload.files_info.map(Me=>({...Me,data:Me!=null&&Me.data?`<base64 ${String(Me.data).length} chars>`:Me==null?void 0:Me.data}))),Ye}catch{return Fe}};try{let Fe={};try{if(r)Fe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,At=((L=window.localStorage)==null?void 0:L.getItem("authToken"))||null;let Z=null;try{const We=(ee=window.localStorage)==null?void 0:ee.getItem("chat-settings");We&&(Z=((B=JSON.parse(We))==null?void 0:B.apiKey)||null)}catch{}const ue=Ke||At||Z||null;ue&&(Fe={Authorization:`Bearer ${ue}`})}}catch{}console.debug("[use-chat] POST",t+n,R(z));let Le={};if(typeof window<"u")try{const ze=($=window.localStorage)==null?void 0:$.getItem("authSessionId");ze&&(Le={"X-Session-Id":ze})}catch{}const Ye={...Fe,...Le,...s.current},Me={"Content-Type":"application/json",Accept:"text/event-stream",...Ye},$e=await fetch(t+n,{method:"POST",headers:Me,body:JSON.stringify(z),signal:U.signal,credentials:i});if(j.current&&(j.current.headers=Ye),!$e.ok||!$e.body){const ze=await $e.text().catch(()=>"");console.debug("[use-chat] non-OK response",$e.status,ze==null?void 0:ze.slice(0,500));const Ke=`stream ${$e.status}${ze?": "+ze:""}`;throw(Q=I==null?void 0:I.onConnectionError)==null||Q.call(I,Ke),O=!0,K="error",P=Ke,new Error(Ke)}w(!0);const Qe=$e.body.getReader(),It=new TextDecoder;let it="",yt=[];E.current=0,x(0);let St=0,Ct=null;const kt=()=>{if(yt.length){const ze=yt.join("");yt=[],T.current&&m(Ke=>Ke+ze)}Ct=null},on=()=>{typeof window<"u"&&Ct==null&&(Ct=requestAnimationFrame(kt))};let Nt=Date.now();const Vt=setInterval(()=>{var ze;if(Date.now()-Nt>18e5){const Ke="Stream idle timeout";d(Ke),K="error",P=Ke,U.abort(),(ze=I==null?void 0:I.onError)==null||ze.call(I,Ke)}},5e3),Et=1024*1024;try{const ze=$e.headers.get("X-Thread-Id")||$e.headers.get("x-thread-id"),Ke=$e.headers.get("X-Thread-Created")||$e.headers.get("x-thread-created"),At=ze??null,Z=String(Ke??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:At}),(X=I==null?void 0:I.onOpen)==null||X.call(I,{threadId:At,created:Z});;){const{value:ue,done:We}=await Qe.read();if(We)break;it+=It.decode(ue,{stream:!0}),it.length>Et&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let be;for(;(be=it.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const pe=it.slice(0,be);it=it.slice(be+2);const ye=pe.split(/\r?\n/),
|
|
38
|
-
`);if(!qe)continue;let ct;try{ct=JSON.parse(qe)}catch{console.debug("[use-chat] malformed SSE:",qe.slice(0,200));continue}const ut=au(ct)?ct.data:ct;if(!ut){console.warn("[use-chat] dropped envelope event without payload",ct);continue}const Pe=ut;Nt=Date.now();const gt=Pe.seq;if(gt!==void 0){if(gt<=St){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:gt,lastProcessedSeq:St,type:Pe.type});continue}St>0&>>St+1&&((te=I==null?void 0:I.onGap)==null||te.call(I,{from:St,to:gt})),St=gt,E.current=gt,x(gt)}if(Pe.type==="message.start"&&Pe.role==="assistant"){const et=fu(Pe.model);W.current={messageId:Pe.id,lastSeq:gt??null,lastText:""},k({id:Pe.id,role:"assistant",name:et??void 0,model:Pe.model,createdAt:new Date().toISOString(),content:[]})}if(Pe.type==="checkpoint")_.current=Pe.checkpointId??null,D.current=Pe.checkpointNs??null,v(Pe.checkpointId??null);else if(Pe.type==="state_history"){F.current=Pe;try{const ft=Mn(Pe).latest;ft&&(_.current=ft.checkpointId??null,D.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(et){console.warn("[use-chat] Failed to hydrate state_history payload",et)}}try{R==null||R(Pe)}catch(et){console.error("[use-chat] Error in onEvent callback:",et,"for event:",Pe.type)}if(Pe.type==="message.delta"){k(ft=>{const In=W.current;if(!ft||In.messageId!==ft.id)return ft;const{newParts:N,newMeta:re,changed:ce}=uu(ft.content??[],Pe.delta,{lastSeq:In.lastSeq,lastText:In.lastText},gt??null);return ce?(W.current={...In,lastSeq:re.lastSeq??In.lastSeq,lastText:re.lastText??In.lastText},{...ft,content:N}):ft});const et=Pe.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");et&&e.autoAppendAssistant!==!1&&(yt.push(et),on())}else if(Pe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(J=I==null?void 0:I.onHeartbeat)==null||J.call(I,Pe)}catch(et){console.warn("[use-chat] heartbeat callback failed",et)}}else if(Ct!==null&&cancelAnimationFrame(Ct),kt(),Pe.type==="checkpoint")v(Pe.checkpointId);else if(Pe.type==="error"){const et=Pe;if(d(et.message),K="error",P=et.message,et.error_type==="auth_error"||et.code==="TOKEN_EXPIRED"||((ae=et.message)==null?void 0:ae.includes("token"))||((ve=et.message)==null?void 0:ve.includes("401"))||((de=et.message)==null?void 0:de.includes("unauthorized"))||((me=et.message)==null?void 0:me.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",et.message);try{(Ce=I==null?void 0:I.onAuthError)==null||Ce.call(I,et.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}U.abort()}}}}kt(),K===null&&!U.signal.aborted&&(K="complete")}catch(ze){if(ze.name==="AbortError")K=K??"aborted";else{const Ke=ze.message||String(ze);K="error",P=Ke,d(Ke),(Te=I==null?void 0:I.onError)==null||Te.call(I,Ke)}}finally{try{await Qe.cancel()}catch{}finally{(_e=Qe.releaseLock)==null||_e.call(Qe)}Ct!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ct),clearInterval(Vt)}}catch(Fe){if(Fe.name==="AbortError")K=K??"aborted";else{const Le=Fe.message||String(Fe);K="error",P=Le,d(Le),(dt=I==null?void 0:I.onError)==null||dt.call(I,Le),O||((lt=I==null?void 0:I.onConnectionError)==null||lt.call(I,Le),O=!0)}}finally{const Fe=E.current,Le=_.current,Ye=D.current,Re=F.current,$e=K??(U.signal.aborted?"aborted":P?"error":"complete");try{(Be=I==null?void 0:I.onClosed)==null||Be.call(I,{reason:$e,lastSeq:Fe,lastCheckpointId:Le,lastCheckpointNs:Ye,lastStateHistory:Re,error:P})}catch(Qe){console.warn("[use-chat] onClosed callback failed",Qe)}l(!1),w(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var B;T.current=!1,(B=C.current)==null||B.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:q,stop:Y,clear:A,setToken:G}}const Qv=["detail","message","error","description","title"];function Yo(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=Yo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Qv){const r=Yo(t[n]);if(r)return r}if("errors"in t){const n=Yo(t.errors);if(n)return n}}return null}function eb(e){if(!e)return"Request failed";const t=e.response,n=Yo(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),[h,p]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const j=b.useCallback(async()=>{d(!0),p(null);try{const R=await e.listThreads();i(R??[])}catch(R){const I=String(R);p(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=b.useCallback(async()=>{x(!0),y(null);try{const R=await e.listSharedThreads();v(R??[])}catch(R){const I=String(R);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{j()},[j]),b.useEffect(()=>{_()},[_]),b.useEffect(()=>{r==null||r(a)},[a,r]);const D=b.useCallback(async R=>{try{const I=await e.createThread(R);return l(I.threadId),await j(),I.threadId}catch(I){const U=String(I);return n==null||n(U),null}},[e,n,j]),F=b.useCallback(async R=>{const I=s;i(K=>K.filter(P=>P.threadId!==R));const U=new AbortController;E.current.set(R,U);try{await e.deleteThread(R),T.current===R&&(l(null),o==null||o())}catch(K){i(I);const P=String(K);n==null||n(P)}finally{E.current.delete(R)}},[e,o,n,s]),W=b.useCallback(async(R,I)=>{try{await e.updateThread(R,I),await j()}catch(U){n==null||n(String(U))}},[e,n,j]),G=b.useCallback(async(R,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(R,I),await _(),S("Shared successfully")}catch(U){const K=eb(U);throw n==null||n(K),S(`Failed to share: ${K}`),new Error(K)}finally{C(!1)}},[e,n,_]),A=b.useCallback(async(R,I)=>{try{await e.unshareThread(R,I),await _()}catch(U){const K=String(U);throw n==null||n(K),U}},[e,n,_]),Y=b.useMemo(()=>({createThread:D,deleteThread:F,renameThread:W,refreshThreads:j,refreshSharedThreads:_,shareThread:G,unshareThread:A}),[D,F,W,j,_,G,A]),q=b.useCallback(R=>{if(!(R!=null&&R.threadId))return;const I={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(U=>{let K=!1;const P=U.map(O=>O.threadId===I.threadId?(K=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return K?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...U])})},[]),B=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:q,shareInFlight:k,shareStatus:w,clearShareStatus:B}}const pu=b.createContext(null);function mu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Jr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:p,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,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:h,isLoadingSharedThreads:p,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,p,f,g,x,y,v]);return u.jsx(pu.Provider,{value:w,children:e})}function xr(){const e=b.useContext(pu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qr(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function gu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function eo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(eo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(gu(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=eo(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 vr(e){if(typeof e=="string")return e;if(gu(e))return"";try{const t=eo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function tb(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function nb(e){const t=vr(e);return typeof e=="string"&&tb(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function br(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Qr(t);if(n!==null)return br(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?br(e.content):e}function rb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Di(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 Xo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function ob(e){const t=r=>{try{const o=eo(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 sb(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function xu(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 ib(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ab(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function lb({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=ib(n),i=o?`data:${s};base64,${e}`:t,a=ab(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function cb(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 lb({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function vu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const ub={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function db(e,t){var n;switch(t.type){case"reset":return{messages:Oi(((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]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Oi(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=Oi(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 bu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>bu(o,s),e):e}default:return e}}function fb(e=[]){const[t,n]=b.useReducer(db,{...ub,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,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function bu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=fu(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 pb(e,t);if(t.type==="tool.progress")return mb(e,t);if(t.type==="tool.end")return gb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??lu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],p=h??{lastSeq:null,lastText:cu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof p.lastSeq=="number"&&f<=p.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:p.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=uu(l.content,t.delta,p,f);if(!x)return e;const y={...l,content:v},w=Zr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??lu(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 h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Jv(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=Mn(t),i=s.interrupt,a=s.latest,l=i===null?Yv(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 Li(e){return e.call_id??e.id??null}function wu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function yu(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 $i(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||Di(r).toolCallId===t)return n}return-1}function hb(e){if(e==null)return[];const t=br(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function Su(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function pb(e,t){const n=Li(t),r=$i(e.messages,n),o=t.name??t.tool??void 0,s=wu(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:Zr(e.messages,r,d)}}const i=yu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function mb(e,t){const n=Li(t);if(!n)return e;const r=$i(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=Su(e.messages[r],o);return{...e,messages:Zr(e.messages,r,a)}}function gb(e,t){const n=Li(t),r=wu(t);let o=e.messages,s=$i(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,yu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=hb(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 h=Su(i,d),p=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:p,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Zr(o,s,f)}}function Cu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,p]=b.useState(null),v=b.useMemo(()=>Mn(h),[h]).checkpoints,g=rc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,j]=b.useState(!1),[_,D]=b.useState(!1),[F,W]=b.useState(null),G=b.useRef(o),A=b.useRef(null),Y=b.useRef(null),q=b.useRef(null),B=b.useRef(null),R=b.useRef(null),I=b.useRef(new Map),U=b.useRef(null);b.useEffect(()=>{G.current=o},[o]);const K=b.useCallback(async J=>{var ve,de;if(!J.threadId)return;const ae=J.threadId;(ve=J.onStart)==null||ve.call(J),J.setLoading(!0);try{await J.action(ae)}catch(me){if(!qc(me)&&G.current===ae){const Te=String(me);(de=J.handleError)==null||de.call(J,Te),r==null||r(Te)}throw me}finally{J.setLoading(!1)}},[r]),P=b.useCallback(async(J,ae)=>{var Te;if(!J)return;const ve=`${J}:${ae??"latest"}`,de=I.current.get(ve);if(de)return de;(Te=U.current)==null||Te.abort();const me=new AbortController;U.current=me;const Ce=K({threadId:J,setLoading:T,onStart:()=>W(null),handleError:_e=>W(_e),action:async _e=>{const dt=await e.getStateHistory({threadId:_e,checkpointId:ae??void 0,signal:me.signal});if(G.current!==_e){console.log(`[useThreadHistoryState] Thread changed during load (was ${_e}, now ${G.current}), discarding stale data`);return}const{checkpoints:lt}=Mn(dt),Be=lt.find(Fe=>Fe.messages&&Fe.messages.length>0)??(ae?lt.find(Fe=>Fe.checkpointId===ae):null)??lt[0];t((Be==null?void 0:Be.messages)??[],{checkpointId:(Be==null?void 0:Be.checkpointId)??null,checkpointNs:(Be==null?void 0:Be.checkpointNs)??null}),p(dt),w(!!(Be!=null&&Be.nextCursor)),k((Be==null?void 0:Be.nextCursor)??null)}});I.current.set(ve,Ce);try{await Ce}finally{I.current.delete(ve),U.current===me&&(U.current=null)}return G.current===J&&(R.current=ve),Ce},[e,t,K]),O=b.useCallback(async(J,ae)=>{B.current=J;try{await P(J,ae)}catch(ve){if(!qc(ve))throw ve}finally{B.current===J&&(B.current=null)}},[P]),M=b.useCallback(J=>{Y.current=J},[]),L=b.useCallback(J=>{q.current=J},[]),ee=b.useCallback(J=>{const ae=J.threadId??G.current;if(!ae||G.current&&G.current!==ae)return;const{checkpoints:ve}=Mn(J);if(!ve.length)return;const de=ve.find(Ce=>Ce.messages&&Ce.messages.length>0)??ve.find(Ce=>!!Ce.checkpointId)??ve[0],me=q.current===ae;!c&&!me&&t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),p(J),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),R.current=`${ae}:latest`,Y.current=null,q.current===ae&&(q.current=null)},[t,c]),z=b.useCallback(async(J,ae)=>{const ve=G.current;await K({threadId:ve,setLoading:D,action:async de=>{const me=await e.getStateHistory({threadId:de,checkpointId:J,checkpointNs:ae??void 0});if(G.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${G.current}), discarding stale data`);return}const{checkpoints:Ce}=Mn(me),Te=Ce.find(_e=>_e.checkpointId===J&&(ae?_e.checkpointNs===ae:!0));if(!Te){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:J,checkpointNs:ae});return}p(me),t(Te.messages??[],{checkpointId:Te.checkpointId??null,checkpointNs:Te.checkpointNs??null})}}).catch(()=>{})},[e,t,K]),$=b.useCallback((J,ae)=>{t(d(),{checkpointId:J??null,checkpointNs:ae??null})},[d,t]),Q=b.useCallback(async()=>{G.current&&await O(G.current)},[O]),X=b.useCallback(async()=>{const J=G.current;!J||!S||await K({threadId:J,setLoading:j,action:async ae=>{const ve=await e.getStateHistory({threadId:ae,checkpointId:S});if(G.current!==ae)return;const{checkpoints:de}=Mn(ve);if(de.length>0){const me=de[de.length-1];n((me==null?void 0:me.messages)??[]),w(!!(me!=null&&me.nextCursor)),k((me==null?void 0:me.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,K]);b.useEffect(()=>{if(!l||!o||C||c)return;if(Y.current===o){Y.current=null,A.current=o;return}if(q.current===o){A.current=o;return}if(B.current===o){B.current=null,A.current=o;return}if(A.current===o)return;A.current=o;let J;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const ae=`${o}:latest`;R.current!==ae&&O(o,J)},[l,o,i,a,s,C,c,O]);const te=b.useCallback(()=>{p(null),w(!1),k(null),T(!1),j(!1),D(!1),W(null),Y.current=null,q.current=null,A.current=null,R.current=null,B.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:_,threadStateError:F,hasMoreHistory:y,loadThread:O,navigateToCheckpoint:z,loadOlderMessages:X,setCurrentCheckpointId:$,returnToLatest:Q,handleStateHistoryEvent:ee,markSkipNextLoad:M,markStreamPendingThread:L,resetHistoryState:te}}const Tu=b.createContext(null),ku=b.createContext(null);function to(){const e=b.useContext(Tu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Eu(){const e=b.useContext(ku);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Iu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Jr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:h,pushUser:p,onEvent:f}=fb(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:_,returnToLatest:D,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A}=Cu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[Y,q]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[B,R]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),A())},[l,d,A]);const I=b.useCallback(M=>q(()=>M),[]),U=b.useCallback(M=>R(()=>M),[]),K=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:v,checkpointIndex:x,timelineCheckpoints:g,metadata:K,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:Y,navigateToCheckpoint:E,setCurrentCheckpointId:_,returnToLatest:D,loadThread:T,clearThread:Y,respondToInterrupt:B,messagePreviews:x.messagePreviews,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A,pushUser:p,onEvent:f}),[l,c,v,g,x,K,y,w,S,k,C,j,Y,E,_,D,T,B,x.messagePreviews,F,W,G,A,p,f]),O=b.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:U}),[I,U]);return u.jsx(ku.Provider,{value:O,children:u.jsx(Tu.Provider,{value:P,children:e})})}function Nu(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return Rn(r,t)??null}function xb(e){const t=Nu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Nu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function vb(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 bb(e,t){const n=[...e].sort(vb);for(const r of n){if(r.messageId!==t)continue;const o=xb(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 Au=b.createContext(null),ju=b.createContext(!1);function wb({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{api:d,baseUrl:h}=Jr(),p=b.useMemo(()=>xn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Zv({baseUrl:p}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(mu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Iu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(ju.Provider,{value:!0,children:u.jsx(yb,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function yb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:p,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=to(),{registerClearThread:E,registerRespondToInterrupt:j}=Eu(),_=b.useCallback(B=>{v(B),f.current!==B.threadId&&((B.created??!f.current)&&w(B.threadId),S(B.threadId),p(B.threadId))},[v,w,S,p,f]),D=b.useCallback(B=>{B.type==="thread_info"?_(B):B.type==="state_history"?y(B):B.type==="tool.end"?i==null||i(B):T(B)},[_,y,T,i]),F=b.useCallback(B=>{a(B,D,{onError:R=>{console.error("[StreamingProvider] Stream error:",R),r==null||r(R)},onAuthError:R=>{console.error("[StreamingProvider] Auth error:",R),o==null||o(R)},onConnectionError:R=>{console.error("[StreamingProvider] Connection error:",R),s==null||s(R)}})},[a,D,r,o,s]),W=b.useRef(g);b.useEffect(()=>{W.current=g},[g]);const G=b.useCallback(async(B,R,I)=>{const U=f.current;if(!U)throw new Error("No active thread to handle interrupt");const K=R?I??!0:!1,P=W.current,O={threadId:U,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:K}};F(O)},[f,F]);b.useEffect(()=>{j(G)},[G,j]);const A=b.useCallback(async()=>{l(),k(),p(null);try{await t.getAgent("default")}catch(B){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",B)}},[t,k,p,l]);b.useEffect(()=>{E(A)},[A,E]);const Y=b.useCallback(async(B,R)=>{let I=f.current;const U=(B==null?void 0:B.text)??"",K=(B==null?void 0:B.attachments)??[],P=(U==null?void 0:U.trim())??"",O={...(B==null?void 0:B.payload)??{}},M=Array.isArray(O.messages)?O.messages:void 0;M&&delete O.messages;const L=!!(M&&M.length);if(!I&&!P&&K.length===0&&!L)return;if(!I){const Te=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),_e=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Te}${_e}`,w(I),p(I)}const{contentParts:ee,filesInfo:z}=await iu(K),$=[...ee];P&&$.push({type:"text",text:U});const Q=R==null?void 0:R.originalMessageId,X=!!(R!=null&&R.edit&&Q),te=!L&&$.length>0;let J=null;te&&(J={id:X?Q:`msg-${Date.now()}`,role:"user",content:$,createdAt:new Date().toISOString()},X?C(J,Q):C(J));const ae=L?M:J?[J]:[],ve={...O,...z.length?{files_info:z}:{}};ae.length?ve.messages=ae:"messages"in ve||(ve.messages=[]);let de=(R==null?void 0:R.checkpointId)??g.id??void 0,me=(R==null?void 0:R.checkpointNs)??g.namespace??void 0;if(X&&Q){const Te=bb(x,Q);de=Te.checkpointId,me=Te.checkpointNs??void 0}const Ce={threadId:I,payload:ve,checkpointId:de,checkpointNs:me,edit:!!(R!=null&&R.edit)};F(Ce)},[g,f,w,C,F,x]),q=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:Y,send:Y,stop:l,setAuthToken:h}),[c,d,Y,l,h]);return u.jsx(Au.Provider,{value:q,children:e})}function Fi(){const e=b.useContext(Au);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Sb(){return b.useContext(ju)}function _u(e){return typeof e=="object"&&e!==null}function Cb(e,t){if(Object.is(e,t))return!0;if(!_u(e)||!_u(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 Pu(e){const t=b.useRef(e),n=b.useRef(e);return Cb(t.current,e)||(t.current=e,n.current=e),n.current}function wr({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 h=Pu(t),p=no(a),f=no(l),v=no(i),g=no(c),x=no(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:p,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,p,f,v,g,x]);return u.jsx(ou,{apiConfig:h,children:u.jsx(wb,{...y,children:e})})}function no(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 yr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Tb(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Ru(){const e=[yr("__API_BASE_URL__"),yr("__CHAT_API_BASE_URL__"),yr("__CHAT_API_URL__")];for(const t of e){const n=Tb(t);if(n)return n}}function Mu(){const e=[yr("__API_AUTH_TOKEN__"),yr("__CHAT_API_KEY__"),yr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ou(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Du(){const e={},t=Ru(),n=Mu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Lu(){const e=Du(),t=Nn.getAuthToken(),n=Ru();return{apiBaseUrl:Ou(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Mu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Bi="chat-settings";function $u(){try{const e=localStorage.getItem(Bi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Fu(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Bi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function kb(){const e=Lu(),t=$u(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ou(Nn.baseUrl,r,e.apiBaseUrl)}}function Eb(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Fu(e)}function oe(...e){return cx.twMerge(lx.clsx(e))}const Ib=Hr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ze=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:oe(Ib({variant:t,size:n,className:e})),ref:s,...o})});Ze.displayName="Button";function ie(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 Bu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Bu(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():Bu(e[o],null)}}}}function Oe(...e){return m.useCallback(On(...e),e)}function Nb(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function ln(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:p,children:f,...v}=h,g=((y=p==null?void 0:p[e])==null?void 0:y[l])||a,x=m.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,p){var g;const f=((g=p==null?void 0:p[e])==null?void 0:g[l])||a,v=m.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Ab(o,...t)]}function Ab(...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 h=l(s)[`__scope${c}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},jb=m[" useInsertionEffect ".trim().toString()]||Tt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=_b({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"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=m.useCallback(d=>{var h;if(a){const p=Pb(d)?d(e):d;p!==e&&((h=i.current)==null||h.call(i,p))}else s(d)},[a,e,s,i]);return[l,c]}function _b({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return jb(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Pb(e){return typeof e=="function"}var Rb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=Rb.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function zi(e,t){e&&Ur.flushSync(()=>e.dispatchEvent(t))}function Jo(e){const t=e+"CollectionProvider",[n,r]=ln(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=qt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=Oe(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",p=qt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=Oe(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(p,{[h]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Mb=m.createContext(void 0);function Zo(e){const t=m.useContext(Mb);return e||t||"ltr"}function pt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Ob(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Db="DismissableLayer",Hi="dismissableLayer.update",Lb="dismissableLayer.pointerDownOutside",$b="dismissableLayer.focusOutside",zu,Hu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sr=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=m.useContext(Hu),[d,h]=m.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=m.useState({}),v=Oe(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Bb(E=>{const j=E.target,_=[...c.branches].some(D=>D.contains(j));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},p),T=zb(E=>{const j=E.target;[...c.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},p);return Ob(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},p),m.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(zu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Wu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=zu)}},[d,p,n,c]),m.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Wu())},[d,c]),m.useEffect(()=>{const E=()=>f({});return document.addEventListener(Hi,E),()=>document.removeEventListener(Hi,E)},[]),u.jsx(ge.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,C.onPointerDownCapture)})});Sr.displayName=Db;var Fb="DismissableLayerBranch",Uu=m.forwardRef((e,t)=>{const n=m.useContext(Hu),r=m.useRef(null),o=Oe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ge.div,{...e,ref:o})});Uu.displayName=Fb;function Bb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Vu(Lb,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 zb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&Vu($b,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 Wu(){const e=new CustomEvent(Hi);document.dispatchEvent(e)}function Vu(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?zi(o,s):o.dispatchEvent(s)}var Hb=Sr,Ub=Uu,Ui=0;function Wi(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ku()),document.body.insertAdjacentElement("beforeend",e[1]??Ku()),Ui++,()=>{Ui===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ui--}},[])}function Ku(){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 Vi="focusScope.autoFocusOnMount",Ki="focusScope.autoFocusOnUnmount",qu={bubbles:!1,cancelable:!0},Wb="FocusScope",Qo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),c=pt(o),d=pt(s),h=m.useRef(null),p=Oe(t,g=>l(g)),f=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.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,f.paused]),m.useEffect(()=>{if(a){Xu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Vi,qu);a.addEventListener(Vi,c),a.dispatchEvent(y),y.defaultPrevented||(Vb(Xb(Gu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Vi,c),setTimeout(()=>{const y=new CustomEvent(Ki,qu);a.addEventListener(Ki,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Ki,d),Xu.remove(f)},0)}}},[a,c,d,f]);const v=m.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Kb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ge.div,{tabIndex:-1,...i,ref:p,onKeyDown:v})});Qo.displayName=Wb;function Vb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Kb(e){const t=Gu(e),n=Yu(t,e),r=Yu(t.reverse(),e);return[n,r]}function Gu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Yu(e,t){for(const n of e)if(!qb(n,{upTo:t}))return n}function qb(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Gb(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&&Gb(e)&&t&&e.select()}}var Xu=Yb();function Yb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ju(e,t),e.unshift(t)},remove(t){var n;e=Ju(e,t),(n=e[0])==null||n.resume()}}}function Ju(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Xb(e){return e.filter(t=>t.tagName!=="A")}var Jb=m[" useId ".trim().toString()]||(()=>{}),Zb=0;function _t(e){const[t,n]=m.useState(Jb());return Tt(()=>{n(r=>r??String(Zb++))},[e]),t?`radix-${t}`:""}const Qb=["top","right","bottom","left"],$n=Math.min,Xt=Math.max,es=Math.round,ts=Math.floor,vn=e=>({x:e,y:e}),ew={left:"right",right:"left",bottom:"top",top:"bottom"},tw={start:"end",end:"start"};function qi(e,t,n){return Xt(e,$n(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Cr(e){return e.split("-")[1]}function Gi(e){return e==="x"?"y":"x"}function Yi(e){return e==="y"?"height":"width"}const nw=new Set(["top","bottom"]);function bn(e){return nw.has(jn(e))?"y":"x"}function Xi(e){return Gi(bn(e))}function rw(e,t,n){n===void 0&&(n=!1);const r=Cr(e),o=Xi(e),s=Yi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ns(i)),[i,ns(i)]}function ow(e){const t=ns(e);return[Ji(e),t,Ji(t)]}function Ji(e){return e.replace(/start|end/g,t=>tw[t])}const Zu=["left","right"],Qu=["right","left"],sw=["top","bottom"],iw=["bottom","top"];function aw(e,t,n){switch(e){case"top":case"bottom":return n?t?Qu:Zu:t?Zu:Qu;case"left":case"right":return t?sw:iw;default:return[]}}function lw(e,t,n,r){const o=Cr(e);let s=aw(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ji)))),s}function ns(e){return e.replace(/left|right|bottom|top/g,t=>ew[t])}function cw(e){return{top:0,right:0,bottom:0,left:0,...e}}function ed(e){return typeof e!="number"?cw(e):{top:e,right:e,bottom:e,left:e}}function rs(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 td(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Xi(t),a=Yi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,p=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:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Cr(t)){case"start":f[i]-=p*(n&&c?-1:1);break;case"end":f[i]+=p*(n&&c?-1:1);break}return f}const uw=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:h}=td(c,r,l),p=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:p,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=td(c,p,l)),g=-1)}return{x:d,y:h,placement:p,strategy:o,middlewareData:f}};async function ro(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:h="floating",altBoundary:p=!1,padding:f=0}=An(t,e),v=ed(f),x=a[p?h==="floating"?"reference":"floating":h],y=rs(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=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=rs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const dw=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 h=ed(d),p={x:n,y:r},f=Xi(o),v=Yi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-p[f]-s.floating[v],C=p[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,_=E/2-g[v]/2-1,D=$n(h[y],_),F=$n(h[w],_),W=D,G=E-g[v]-F,A=E/2-g[v]/2+j,Y=qi(W,A,G),q=!l.arrow&&Cr(o)!=null&&A!==Y&&s.reference[v]/2-(A<W?D:F)-g[v]/2<0,B=q?A<W?A-W:A-G:0;return{[f]:p[f]+B,data:{[f]:Y,centerOffset:A-Y-B,...q&&{alignmentOffset:B}},reset:q}}}),fw=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:h=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=bn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=p||(S||!g?[ns(a)]:ow(a)),T=v!=="none";!p&&T&&C.push(...lw(a,g,v,k));const E=[a,...C],j=await ro(t,x),_=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(j[y]),h){const A=rw(o,i,k);_.push(j[A[0]],j[A[1]])}if(D=[...D,{placement:o,overflows:_}],!_.every(A=>A<=0)){var F,W;const A=(((F=s.flip)==null?void 0:F.index)||0)+1,Y=E[A];if(Y&&(!(h==="alignment"?w!==bn(Y):!1)||D.every(R=>bn(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:Y}};let q=(W=D.filter(B=>B.overflows[0]<=0).sort((B,R)=>B.overflows[1]-R.overflows[1])[0])==null?void 0:W.placement;if(!q)switch(f){case"bestFit":{var G;const B=(G=D.filter(R=>{if(T){const I=bn(R.placement);return I===w||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,U)=>I+U,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:G[0];B&&(q=B);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function nd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function rd(e){return Qb.some(t=>e[t]>=0)}const hw=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 ro(t,{...o,elementContext:"reference"}),i=nd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:rd(i)}}}case"escaped":{const s=await ro(t,{...o,altBoundary:!0}),i=nd(s,n.floating);return{data:{escapedOffsets:i,escaped:rd(i)}}}default:return{}}}}},od=new Set(["left","top"]);async function pw(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=Cr(n),l=bn(n)==="y",c=od.has(i)?-1:1,d=s&&l?-1:1,h=An(t,e);let{mainAxis:p,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:p*c}:{x:p*c,y:f*d}}const mw=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 pw(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}}}}},gw=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 ro(t,l),h=bn(jn(o)),p=Gi(h);let f=c[p],v=c[h];if(s){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=qi(w,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=qi(w,v,S)}const g=a.fn({...t,[p]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:s,[h]:i}}}}}},xw=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},h=bn(o),p=Gi(h);let f=d[p],v=d[h];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=p==="y"?"height":"width",k=s.reference[p]-s.floating[S]+x.mainAxis,C=s.reference[p]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=p==="y"?"width":"height",k=od.has(jn(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[p]:f,[h]:v}}}},vw=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 ro(t,c),h=jn(o),p=Cr(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=p==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],w),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!p){const D=Xt(d.left,0),F=Xt(d.right,0),W=Xt(d.top,0),G=Xt(d.bottom,0);f?j=v-2*(D!==0||F!==0?D+F:Xt(d.left,d.right)):E=g-2*(W!==0||G!==0?W+G:Xt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const _=await i.getDimensions(a.floating);return v!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function os(){return typeof window<"u"}function Tr(e){return sd(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(sd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function sd(e){return os()?e instanceof Node||e instanceof Jt(e).Node:!1}function cn(e){return os()?e instanceof Element||e instanceof Jt(e).Element:!1}function yn(e){return os()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function id(e){return!os()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const bw=new Set(["inline","contents"]);function oo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=un(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!bw.has(o)}const ww=new Set(["table","td","th"]);function yw(e){return ww.has(Tr(e))}const Sw=[":popover-open",":modal"];function ss(e){return Sw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Cw=["transform","translate","scale","rotate","perspective"],Tw=["transform","translate","scale","rotate","perspective","filter"],kw=["paint","layout","strict","content"];function Zi(e){const t=Qi(),n=cn(e)?un(e):e;return Cw.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)||Tw.some(r=>(n.willChange||"").includes(r))||kw.some(r=>(n.contain||"").includes(r))}function Ew(e){let t=Fn(e);for(;yn(t)&&!kr(t);){if(Zi(t))return t;if(ss(t))return null;t=Fn(t)}return null}function Qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Iw=new Set(["html","body","#document"]);function kr(e){return Iw.has(Tr(e))}function un(e){return Jt(e).getComputedStyle(e)}function is(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Tr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||id(e)&&e.host||wn(e);return id(t)?t.host:t}function ad(e){const t=Fn(e);return kr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&oo(t)?t:ad(t)}function so(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ad(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=ea(i);return t.concat(i,i.visualViewport||[],oo(o)?o:[],a&&n?so(a):[])}return t.concat(o,so(o,[],n))}function ea(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ld(e){const t=un(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=es(n)!==s||es(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ta(e){return cn(e)?e:e.contextElement}function Er(e){const t=ta(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ld(t);let i=(s?es(n.width):n.width)/r,a=(s?es(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Nw=vn(0);function cd(e){const t=Jt(e);return!Qi()||!t.visualViewport?Nw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Aw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ta(e);let i=vn(1);t&&(r?cn(r)&&(i=Er(r)):i=Er(e));const a=Aw(s,n,r)?cd(s):vn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const p=Jt(s),f=r&&cn(r)?Jt(r):r;let v=p,g=ea(v);for(;g&&r&&f!==v;){const x=Er(g),y=g.getBoundingClientRect(),w=un(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=S,c+=k,v=Jt(g),g=ea(v)}}return rs({width:d,height:h,x:l,y:c})}function as(e,t){const n=is(e).scrollLeft;return t?t.left+n:er(wn(e)).left+n}function ud(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-as(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function jw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?ss(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=vn(1);const d=vn(0),h=yn(r);if((h||!h&&!s)&&((Tr(r)!=="body"||oo(i))&&(l=is(r)),yn(r))){const f=er(r);c=Er(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const p=i&&!h&&!s?ud(i,l):vn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function _w(e){return Array.from(e.getClientRects())}function Pw(e){const t=wn(e),n=is(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+as(e);const a=-n.scrollTop;return un(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const dd=25;function Rw(e,t){const n=Jt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=as(r);if(c<=0){const d=r.ownerDocument,h=d.body,p=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=dd&&(s-=v)}else c<=dd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Mw=new Set(["absolute","fixed"]);function Ow(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?Er(e):vn(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 fd(e,t,n){let r;if(t==="viewport")r=Rw(e,n);else if(t==="document")r=Pw(wn(e));else if(cn(t))r=Ow(t,n);else{const o=cd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(r)}function hd(e,t){const n=Fn(e);return n===t||!cn(n)||kr(n)?!1:un(n).position==="fixed"||hd(n,t)}function Dw(e,t){const n=t.get(e);if(n)return n;let r=so(e,[],!1).filter(a=>cn(a)&&Tr(a)!=="body"),o=null;const s=un(e).position==="fixed";let i=s?Fn(e):e;for(;cn(i)&&!kr(i);){const a=un(i),l=Zi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Mw.has(o.position)||oo(i)&&!l&&hd(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function Lw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ss(t)?[]:Dw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=fd(t,d,o);return c.top=Xt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Xt(h.left,c.left),c},fd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function $w(e){const{width:t,height:n}=ld(e);return{width:t,height:n}}function Fw(e,t,n){const r=yn(t),o=wn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=as(o)}if(r||!r&&!s)if((Tr(t)!=="body"||oo(o))&&(a=is(t)),r){const f=er(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?ud(o,a):vn(0),h=i.left+a.scrollLeft-l.x-d.x,p=i.top+a.scrollTop-l.y-d.y;return{x:h,y:p,width:i.width,height:i.height}}function na(e){return un(e).position==="static"}function pd(e,t){if(!yn(e)||un(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function md(e,t){const n=Jt(e);if(ss(e))return n;if(!yn(e)){let o=Fn(e);for(;o&&!kr(o);){if(cn(o)&&!na(o))return o;o=Fn(o)}return n}let r=pd(e,t);for(;r&&yw(r)&&na(r);)r=pd(r,t);return r&&kr(r)&&na(r)&&!Zi(r)?n:r||Ew(e)||n}const Bw=async function(e){const t=this.getOffsetParent||md,n=this.getDimensions,r=await n(e.floating);return{reference:Fw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zw(e){return un(e).direction==="rtl"}const Hw={convertOffsetParentRelativeRectToViewportRelativeRect:jw,getDocumentElement:wn,getClippingRect:Lw,getOffsetParent:md,getElementRects:Bw,getClientRects:_w,getDimensions:$w,getScale:Er,isElement:cn,isRTL:zw};function gd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Uw(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:p,height:f}=c;if(a||t(),!p||!f)return;const v=ts(h),g=ts(o.clientWidth-(d+p)),x=ts(o.clientHeight-(h+f)),y=ts(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,$n(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!gd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Ww(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=ta(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 h=c&&a?Uw(c,n):null;let p=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!gd(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)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Vw=mw,Kw=gw,qw=fw,Gw=vw,Yw=hw,xd=dw,Xw=xw,Jw=(e,t,n)=>{const r=new Map,o={platform:Hw,...n},s={...o.platform,_c:r};return uw(e,t,{...o,platform:s})};var Zw=typeof document<"u",Qw=function(){},ls=Zw?b.useLayoutEffect:Qw;function cs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!cs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function vd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function bd(e,t){const n=vd(e);return Math.round(t*n)/n}function ra(e){const t=m.useRef(e);return ls(()=>{t.current=e}),t}function ey(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,f]=m.useState(r);cs(p,r)||f(r);const[v,g]=m.useState(null),[x,y]=m.useState(null),w=m.useCallback(R=>{R!==T.current&&(T.current=R,g(R))},[]),S=m.useCallback(R=>{R!==E.current&&(E.current=R,y(R))},[]),k=s||v,C=i||x,T=m.useRef(null),E=m.useRef(null),j=m.useRef(d),_=l!=null,D=ra(l),F=ra(o),W=ra(c),G=m.useCallback(()=>{if(!T.current||!E.current)return;const R={placement:t,strategy:n,middleware:p};F.current&&(R.platform=F.current),Jw(T.current,E.current,R).then(I=>{const U={...I,isPositioned:W.current!==!1};A.current&&!cs(j.current,U)&&(j.current=U,Ur.flushSync(()=>{h(U)}))})},[p,t,n,F,W]);ls(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,h(R=>({...R,isPositioned:!1})))},[c]);const A=m.useRef(!1);ls(()=>(A.current=!0,()=>{A.current=!1}),[]),ls(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(D.current)return D.current(k,C,G);G()}},[k,C,G,D,_]);const Y=m.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),q=m.useMemo(()=>({reference:k,floating:C}),[k,C]),B=m.useMemo(()=>{const R={position:n,left:0,top:0};if(!q.floating)return R;const I=bd(q.floating,d.x),U=bd(q.floating,d.y);return a?{...R,transform:"translate("+I+"px, "+U+"px)",...vd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:U}},[n,a,q.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:G,refs:Y,elements:q,floatingStyles:B}),[d,G,Y,q,B])}const ty=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?xd({element:r.current,padding:o}).fn(n):{}:r?xd({element:r,padding:o}).fn(n):{}}}},ny=(e,t)=>({...Vw(e),options:[e,t]}),ry=(e,t)=>({...Kw(e),options:[e,t]}),oy=(e,t)=>({...Xw(e),options:[e,t]}),sy=(e,t)=>({...qw(e),options:[e,t]}),iy=(e,t)=>({...Gw(e),options:[e,t]}),ay=(e,t)=>({...Yw(e),options:[e,t]}),ly=(e,t)=>({...ty(e),options:[e,t]});var cy="Arrow",wd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ge.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"})})});wd.displayName=cy;var uy=wd;function yd(e){const[t,n]=m.useState(void 0);return Tt(()=>{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 oa="Popper",[Sd,Ir]=ln(oa),[dy,Cd]=Sd(oa),Td=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return u.jsx(dy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Td.displayName=oa;var kd="PopperAnchor",Ed=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Cd(kd,n),i=m.useRef(null),a=Oe(t,i),l=m.useRef(null);return m.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(ge.div,{...o,ref:a})});Ed.displayName=kd;var sa="PopperContent",[fy,hy]=Sd(sa),Id=m.forwardRef((e,t)=>{var z,$,Q,X,te,J;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:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=Cd(sa,n),[y,w]=m.useState(null),S=Oe(t,ae=>w(ae)),[k,C]=m.useState(null),T=yd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],W=F.length>0,G={padding:D,boundary:F.filter(my),altBoundary:W},{refs:A,floatingStyles:Y,placement:q,isPositioned:B,middlewareData:R}=ey({strategy:"fixed",placement:_,whileElementsMounted:(...ae)=>Ww(...ae,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[ny({mainAxis:o+j,alignmentAxis:i}),l&&ry({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?oy():void 0,...G}),l&&sy({...G}),iy({...G,apply:({elements:ae,rects:ve,availableWidth:de,availableHeight:me})=>{const{width:Ce,height:Te}=ve.reference,_e=ae.floating.style;_e.setProperty("--radix-popper-available-width",`${de}px`),_e.setProperty("--radix-popper-available-height",`${me}px`),_e.setProperty("--radix-popper-anchor-width",`${Ce}px`),_e.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),k&&ly({element:k,padding:a}),gy({arrowWidth:E,arrowHeight:j}),p&&ay({strategy:"referenceHidden",...G})]}),[I,U]=jd(q),K=pt(v);Tt(()=>{B&&(K==null||K())},[B,K]);const P=(z=R.arrow)==null?void 0:z.x,O=($=R.arrow)==null?void 0:$.y,M=((Q=R.arrow)==null?void 0:Q.centerOffset)!==0,[L,ee]=m.useState();return Tt(()=>{y&&ee(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:B?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(X=R.transformOrigin)==null?void 0:X.x,(te=R.transformOrigin)==null?void 0:te.y].join(" "),...((J=R.hide)==null?void 0:J.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(fy,{scope:n,placedSide:I,onArrowChange:C,arrowX:P,arrowY:O,shouldHideArrow:M,children:u.jsx(ge.div,{"data-side":I,"data-align":U,...g,ref:S,style:{...g.style,animation:B?void 0:"none"}})})})});Id.displayName=sa;var Nd="PopperArrow",py={top:"bottom",right:"left",bottom:"top",left:"right"},Ad=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=hy(Nd,r),i=py[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(uy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ad.displayName=Nd;function my(e){return e!==null}var gy=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]=jd(n),h={start:"0%",center:"50%",end:"100%"}[d],p=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?h:`${p}px`,g=`${-l}px`):c==="top"?(v=i?h:`${p}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function jd(e){const[t,n="center"]=e.split("-");return[t,n]}var ia=Td,aa=Ed,la=Id,ca=Ad,xy="Portal",io=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Mo.createPortal(u.jsx(ge.div,{...r,ref:t}),i):null});io.displayName=xy;function vy(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=by(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Oe(r.ref,wy(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function by(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=vy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const c=us(r.current);s.current=a==="mounted"?c:"none"},[a]),Tt(()=>{const c=r.current,d=o.current;if(d!==e){const p=s.current,f=us(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&p!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Tt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=us(r.current).includes(CSS.escape(f.animationName));if(f.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)})}},p=f=>{f.target===t&&(s.current=us(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function us(e){return(e==null?void 0:e.animationName)||"none"}function wy(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 ua="rovingFocusGroup.onEntryFocus",yy={bubbles:!1,cancelable:!0},ao="RovingFocusGroup",[da,_d,Sy]=Jo(ao),[Cy,Pd]=ln(ao,[Sy]),[Ty,ky]=Cy(ao),Rd=m.forwardRef((e,t)=>u.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Ey,{...e,ref:t})})}));Rd.displayName=ao;var Ey=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,p=m.useRef(null),f=Oe(t,p),v=Zo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:ao}),[y,w]=m.useState(!1),S=pt(c),k=_d(n),C=m.useRef(!1),[T,E]=m.useState(0);return m.useEffect(()=>{const j=p.current;if(j)return j.addEventListener(ua,S),()=>j.removeEventListener(ua,S)},[S]),u.jsx(Ty,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:m.useCallback(j=>x(j),[x]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:m.useCallback(()=>E(j=>j-1),[]),children:u.jsx(ge.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{C.current=!0}),onFocus:ie(e.onFocus,j=>{const _=!C.current;if(j.target===j.currentTarget&&_&&!y){const D=new CustomEvent(ua,yy);if(j.currentTarget.dispatchEvent(D),!D.defaultPrevented){const F=k().filter(q=>q.focusable),W=F.find(q=>q.active),G=F.find(q=>q.id===g),Y=[W,G,...F].filter(Boolean).map(q=>q.ref.current);Dd(Y,d)}}C.current=!1}),onBlur:ie(e.onBlur,()=>w(!1))})})}),Md="RovingFocusGroupItem",Od=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_t(),c=s||l,d=ky(Md,n),h=d.currentTabStopId===c,p=_d(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return m.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(da.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ge.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ay(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=p().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?jy(S,k+1):S.slice(k+1)}setTimeout(()=>Dd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Od.displayName=Md;var Iy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ny(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ay(e,t,n){const r=Ny(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Iy[r]}function Dd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function jy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _y=Rd,Py=Od,Ry=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Nr=new WeakMap,ds=new WeakMap,fs={},fa=0,Ld=function(e){return e&&(e.host||Ld(e.parentNode))},My=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ld(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})},Oy=function(e,t,n,r){var o=My(t,Array.isArray(e)?e:[e]);fs[n]||(fs[n]=new WeakMap);var s=fs[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(p){if(a.has(p))d(p);else try{var f=p.getAttribute(r),v=f!==null&&f!=="false",g=(Nr.get(p)||0)+1,x=(s.get(p)||0)+1;Nr.set(p,g),s.set(p,x),i.push(p),g===1&&v&&ds.set(p,!0),x===1&&p.setAttribute(n,"true"),v||p.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",p,y)}})};return d(t),a.clear(),fa++,function(){i.forEach(function(h){var p=Nr.get(h)-1,f=s.get(h)-1;Nr.set(h,p),s.set(h,f),p||(ds.has(h)||h.removeAttribute(r),ds.delete(h)),f||h.removeAttribute(n)}),fa--,fa||(Nr=new WeakMap,Nr=new WeakMap,ds=new WeakMap,fs={})}},ha=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ry(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Oy(r,o,n,"aria-hidden")):function(){return null}},Sn=function(){return Sn=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},Sn.apply(this,arguments)};function $d(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 Dy(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 hs="right-scroll-bar-position",ps="width-before-scroll-bar",Ly="with-scroll-bars-hidden",$y="--removed-body-scroll-bar-size";function pa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Fy(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 By=typeof window<"u"?m.useLayoutEffect:m.useEffect,Fd=new WeakMap;function zy(e,t){var n=Fy(null,function(r){return e.forEach(function(o){return pa(o,r)})});return By(function(){var r=Fd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||pa(a,null)}),s.forEach(function(a){o.has(a)||pa(a,i)})}Fd.set(n,e)},[e]),n}function Hy(e){return e}function Uy(e,t){t===void 0&&(t=Hy);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 Wy(e){e===void 0&&(e={});var t=Uy(null);return t.options=Sn({async:!0,ssr:!1},e),t}var Bd=function(e){var t=e.sideCar,n=$d(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,Sn({},n))};Bd.isSideCarExport=!0;function Vy(e,t){return e.useMedium(t),Bd}var zd=Wy(),ma=function(){},ms=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:ma,onWheelCapture:ma,onTouchMoveCapture:ma}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,p=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=$d(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,T=zy([n,t]),E=Sn(Sn({},k),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:zd,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),Sn(Sn({},E),{ref:T})):m.createElement(w,Sn({},E,{className:l,ref:T}),a))});ms.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ms.classNames={fullWidth:ps,zeroRight:hs};var Ky=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Ky();return t&&e.setAttribute("nonce",t),e}function Gy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Xy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qy())&&(Gy(t,n),Yy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Jy=function(){var e=Xy();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Hd=function(){var e=Jy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Zy={left:0,top:0,right:0,gap:0},ga=function(e){return parseInt(e||"",10)||0},Qy=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[ga(n),ga(r),ga(o)]},e0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Zy;var t=Qy(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])}},t0=Hd(),Ar="data-scroll-locked",n0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
37
|
+
`))>=0;){const pe=it.slice(0,be);it=it.slice(be+2);const ye=pe.split(/\r?\n/),Re=[];for(const et of ye)if(!(!et||et.startsWith(":"))&&et.startsWith("data:")){const ft=et.slice(5);Re.push(ft.startsWith(" ")?ft.slice(1):ft)}const qe=Re.join(`
|
|
38
|
+
`);if(!qe)continue;let ct;try{ct=JSON.parse(qe)}catch{console.debug("[use-chat] malformed SSE:",qe.slice(0,200));continue}const ut=au(ct)?ct.data:ct;if(!ut){console.warn("[use-chat] dropped envelope event without payload",ct);continue}const Pe=ut;Nt=Date.now();const gt=Pe.seq;if(gt!==void 0){if(gt<=St){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:gt,lastProcessedSeq:St,type:Pe.type});continue}St>0&>>St+1&&((te=I==null?void 0:I.onGap)==null||te.call(I,{from:St,to:gt})),St=gt,E.current=gt,x(gt)}if(Pe.type==="message.start"&&Pe.role==="assistant"){const et=fu(Pe.model);W.current={messageId:Pe.id,lastSeq:gt??null,lastText:""},k({id:Pe.id,role:"assistant",name:et??void 0,model:Pe.model,createdAt:new Date().toISOString(),content:[]})}if(Pe.type==="checkpoint")_.current=Pe.checkpointId??null,D.current=Pe.checkpointNs??null,v(Pe.checkpointId??null);else if(Pe.type==="state_history"){F.current=Pe;try{const ft=Rn(Pe).latest;ft&&(_.current=ft.checkpointId??null,D.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(et){console.warn("[use-chat] Failed to hydrate state_history payload",et)}}try{M==null||M(Pe)}catch(et){console.error("[use-chat] Error in onEvent callback:",et,"for event:",Pe.type)}if(Pe.type==="message.delta"){k(ft=>{const In=W.current;if(!ft||In.messageId!==ft.id)return ft;const{newParts:N,newMeta:re,changed:ce}=uu(ft.content??[],Pe.delta,{lastSeq:In.lastSeq,lastText:In.lastText},gt??null);return ce?(W.current={...In,lastSeq:re.lastSeq??In.lastSeq,lastText:re.lastText??In.lastText},{...ft,content:N}):ft});const et=Pe.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");et&&e.autoAppendAssistant!==!1&&(yt.push(et),on())}else if(Pe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(J=I==null?void 0:I.onHeartbeat)==null||J.call(I,Pe)}catch(et){console.warn("[use-chat] heartbeat callback failed",et)}}else if(Ct!==null&&cancelAnimationFrame(Ct),kt(),Pe.type==="checkpoint")v(Pe.checkpointId);else if(Pe.type==="error"){const et=Pe;if(d(et.message),K="error",P=et.message,et.error_type==="auth_error"||et.code==="TOKEN_EXPIRED"||((ae=et.message)==null?void 0:ae.includes("token"))||((ve=et.message)==null?void 0:ve.includes("401"))||((de=et.message)==null?void 0:de.includes("unauthorized"))||((me=et.message)==null?void 0:me.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",et.message);try{(Ce=I==null?void 0:I.onAuthError)==null||Ce.call(I,et.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}U.abort()}}}}kt(),K===null&&!U.signal.aborted&&(K="complete")}catch(ze){if(ze.name==="AbortError")K=K??"aborted";else{const Ke=ze.message||String(ze);K="error",P=Ke,d(Ke),(Te=I==null?void 0:I.onError)==null||Te.call(I,Ke)}}finally{try{await Qe.cancel()}catch{}finally{(_e=Qe.releaseLock)==null||_e.call(Qe)}Ct!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ct),clearInterval(Vt)}}catch(Fe){if(Fe.name==="AbortError")K=K??"aborted";else{const Le=Fe.message||String(Fe);K="error",P=Le,d(Le),(dt=I==null?void 0:I.onError)==null||dt.call(I,Le),O||((lt=I==null?void 0:I.onConnectionError)==null||lt.call(I,Le),O=!0)}}finally{const Fe=E.current,Le=_.current,Ye=D.current,Me=F.current,$e=K??(U.signal.aborted?"aborted":P?"error":"complete");try{(Be=I==null?void 0:I.onClosed)==null||Be.call(I,{reason:$e,lastSeq:Fe,lastCheckpointId:Le,lastCheckpointNs:Ye,lastStateHistory:Me,error:P})}catch(Qe){console.warn("[use-chat] onClosed callback failed",Qe)}l(!1),w(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var z;T.current=!1,(z=C.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:S,lastCheckpointId:h,lastSeq:g,connected:y,stream:q,stop:Y,clear:A,setToken:G}}const Qv=["detail","message","error","description","title"];function Yo(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=Yo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Qv){const r=Yo(t[n]);if(r)return r}if("errors"in t){const n=Yo(t.errors);if(n)return n}}return null}function eb(e){if(!e)return"Request failed";const t=e.response,n=Yo(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),[f,m]=b.useState(null),[h,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const j=b.useCallback(async()=>{d(!0),m(null);try{const M=await e.listThreads();i(M??[])}catch(M){const I=String(M);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=b.useCallback(async()=>{x(!0),y(null);try{const M=await e.listSharedThreads();v(M??[])}catch(M){const I=String(M);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{j()},[j]),b.useEffect(()=>{_()},[_]),b.useEffect(()=>{r==null||r(a)},[a,r]);const D=b.useCallback(async M=>{try{const I=await e.createThread(M);return l(I.threadId),await j(),I.threadId}catch(I){const U=String(I);return n==null||n(U),null}},[e,n,j]),F=b.useCallback(async M=>{const I=s;i(K=>K.filter(P=>P.threadId!==M));const U=new AbortController;E.current.set(M,U);try{await e.deleteThread(M),T.current===M&&(l(null),o==null||o())}catch(K){i(I);const P=String(K);n==null||n(P)}finally{E.current.delete(M)}},[e,o,n,s]),W=b.useCallback(async(M,I)=>{try{await e.updateThread(M,I),await j()}catch(U){n==null||n(String(U))}},[e,n,j]),G=b.useCallback(async(M,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(M,I),await _(),S("Shared successfully")}catch(U){const K=eb(U);throw n==null||n(K),S(`Failed to share: ${K}`),new Error(K)}finally{C(!1)}},[e,n,_]),A=b.useCallback(async(M,I)=>{try{await e.unshareThread(M,I),await _()}catch(U){const K=String(U);throw n==null||n(K),U}},[e,n,_]),Y=b.useMemo(()=>({createThread:D,deleteThread:F,renameThread:W,refreshThreads:j,refreshSharedThreads:_,shareThread:G,unshareThread:A}),[D,F,W,j,_,G,A]),q=b.useCallback(M=>{if(!(M!=null&&M.threadId))return;const I={threadId:M.threadId,title:M.title||`Thread ${M.threadId.slice(0,8)}`,createdAt:M.createdAt||new Date().toISOString(),updatedAt:M.updatedAt||new Date().toISOString(),messageCount:M.messageCount??1};i(U=>{let K=!1;const P=U.map(O=>O.threadId===I.threadId?(K=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return K?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...U])})},[]),z=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:h,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:q,shareInFlight:k,shareStatus:w,clearShareStatus:z}}const pu=b.createContext(null);function mu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Jr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:h,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,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:f,isLoadingSharedThreads:m,actions:h,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,f,m,h,g,x,y,v]);return u.jsx(pu.Provider,{value:w,children:e})}function xr(){const e=b.useContext(pu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qr(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function gu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function eo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(eo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(gu(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=eo(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 vr(e){if(typeof e=="string")return e;if(gu(e))return"";try{const t=eo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function tb(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function nb(e){const t=vr(e);return typeof e=="string"&&tb(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function br(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Qr(t);if(n!==null)return br(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?br(e.content):e}function rb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Di(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 Xo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function ob(e){const t=r=>{try{const o=eo(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 sb(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function xu(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 ib(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ab(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function lb({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=ib(n),i=o?`data:${s};base64,${e}`:t,a=ab(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function cb(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 lb({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function vu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const ub={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function db(e,t){var n;switch(t.type){case"reset":return{messages:Oi(((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]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Oi(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=Oi(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 bu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>bu(o,s),e):e}default:return e}}function fb(e=[]){const[t,n]=b.useReducer(db,{...ub,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 bu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=fu(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 pb(e,t);if(t.type==="tool.progress")return mb(e,t);if(t.type==="tool.end")return gb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??lu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},f=d[s],m=f??{lastSeq:null,lastText:cu(l.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof m.lastSeq=="number"&&h<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=uu(l.content,t.delta,m,h);if(!x)return e;const y={...l,content:v},w=Zr(i,a,y),S=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??lu(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 e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Jv(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=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Yv(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 Li(e){return e.call_id??e.id??null}function wu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function yu(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 $i(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||Di(r).toolCallId===t)return n}return-1}function hb(e){if(e==null)return[];const t=br(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function Su(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function pb(e,t){const n=Li(t),r=$i(e.messages,n),o=t.name??t.tool??void 0,s=wu(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:Zr(e.messages,r,d)}}const i=yu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function mb(e,t){const n=Li(t);if(!n)return e;const r=$i(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=Su(e.messages[r],o);return{...e,messages:Zr(e.messages,r,a)}}function gb(e,t){const n=Li(t),r=wu(t);let o=e.messages,s=$i(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,yu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=hb(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=Su(i,d),m=t.artifact??i.artifact,h={...f,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Zr(o,s,h)}}function Cu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[f,m]=b.useState(null),v=b.useMemo(()=>Rn(f),[f]).checkpoints,g=rc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,j]=b.useState(!1),[_,D]=b.useState(!1),[F,W]=b.useState(null),G=b.useRef(o),A=b.useRef(null),Y=b.useRef(null),q=b.useRef(null),z=b.useRef(null),M=b.useRef(null),I=b.useRef(new Map),U=b.useRef(null);b.useEffect(()=>{G.current=o},[o]);const K=b.useCallback(async J=>{var ve,de;if(!J.threadId)return;const ae=J.threadId;(ve=J.onStart)==null||ve.call(J),J.setLoading(!0);try{await J.action(ae)}catch(me){if(!qc(me)&&G.current===ae){const Te=String(me);(de=J.handleError)==null||de.call(J,Te),r==null||r(Te)}throw me}finally{J.setLoading(!1)}},[r]),P=b.useCallback(async(J,ae)=>{var Te;if(!J)return;const ve=`${J}:${ae??"latest"}`,de=I.current.get(ve);if(de)return de;(Te=U.current)==null||Te.abort();const me=new AbortController;U.current=me;const Ce=K({threadId:J,setLoading:T,onStart:()=>W(null),handleError:_e=>W(_e),action:async _e=>{const dt=await e.getStateHistory({threadId:_e,checkpointId:ae??void 0,signal:me.signal});if(G.current!==_e){console.log(`[useThreadHistoryState] Thread changed during load (was ${_e}, now ${G.current}), discarding stale data`);return}const{checkpoints:lt}=Rn(dt),Be=lt.find(Fe=>Fe.messages&&Fe.messages.length>0)??(ae?lt.find(Fe=>Fe.checkpointId===ae):null)??lt[0];t((Be==null?void 0:Be.messages)??[],{checkpointId:(Be==null?void 0:Be.checkpointId)??null,checkpointNs:(Be==null?void 0:Be.checkpointNs)??null}),m(dt),w(!!(Be!=null&&Be.nextCursor)),k((Be==null?void 0:Be.nextCursor)??null)}});I.current.set(ve,Ce);try{await Ce}finally{I.current.delete(ve),U.current===me&&(U.current=null)}return G.current===J&&(M.current=ve),Ce},[e,t,K]),O=b.useCallback(async(J,ae)=>{z.current=J;try{await P(J,ae)}catch(ve){if(!qc(ve))throw ve}finally{z.current===J&&(z.current=null)}},[P]),R=b.useCallback(J=>{Y.current=J},[]),L=b.useCallback(J=>{q.current=J},[]),ee=b.useCallback(J=>{const ae=J.threadId??G.current;if(!ae||G.current&&G.current!==ae)return;const{checkpoints:ve}=Rn(J);if(!ve.length)return;const de=ve.find(Ce=>Ce.messages&&Ce.messages.length>0)??ve.find(Ce=>!!Ce.checkpointId)??ve[0],me=q.current===ae;!c&&!me&&t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),m(J),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),M.current=`${ae}:latest`,Y.current=null,q.current===ae&&(q.current=null)},[t,c]),B=b.useCallback(async(J,ae)=>{const ve=G.current;await K({threadId:ve,setLoading:D,action:async de=>{const me=await e.getStateHistory({threadId:de,checkpointId:J,checkpointNs:ae??void 0});if(G.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${G.current}), discarding stale data`);return}const{checkpoints:Ce}=Rn(me),Te=Ce.find(_e=>_e.checkpointId===J&&(ae?_e.checkpointNs===ae:!0));if(!Te){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:J,checkpointNs:ae});return}m(me),t(Te.messages??[],{checkpointId:Te.checkpointId??null,checkpointNs:Te.checkpointNs??null})}}).catch(()=>{})},[e,t,K]),$=b.useCallback((J,ae)=>{t(d(),{checkpointId:J??null,checkpointNs:ae??null})},[d,t]),Q=b.useCallback(async()=>{G.current&&await O(G.current)},[O]),X=b.useCallback(async()=>{const J=G.current;!J||!S||await K({threadId:J,setLoading:j,action:async ae=>{const ve=await e.getStateHistory({threadId:ae,checkpointId:S});if(G.current!==ae)return;const{checkpoints:de}=Rn(ve);if(de.length>0){const me=de[de.length-1];n((me==null?void 0:me.messages)??[]),w(!!(me!=null&&me.nextCursor)),k((me==null?void 0:me.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,K]);b.useEffect(()=>{if(!l||!o||C||c)return;if(Y.current===o){Y.current=null,A.current=o;return}if(q.current===o){A.current=o;return}if(z.current===o){z.current=null,A.current=o;return}if(A.current===o)return;A.current=o;let J;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const ae=`${o}:latest`;M.current!==ae&&O(o,J)},[l,o,i,a,s,C,c,O]);const te=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),j(!1),D(!1),W(null),Y.current=null,q.current=null,A.current=null,M.current=null,z.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:_,threadStateError:F,hasMoreHistory:y,loadThread:O,navigateToCheckpoint:B,loadOlderMessages:X,setCurrentCheckpointId:$,returnToLatest:Q,handleStateHistoryEvent:ee,markSkipNextLoad:R,markStreamPendingThread:L,resetHistoryState:te}}const Tu=b.createContext(null),ku=b.createContext(null);function to(){const e=b.useContext(Tu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Eu(){const e=b.useContext(ku);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Iu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Jr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:f,pushUser:m,onEvent:h}=fb(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:_,returnToLatest:D,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A}=Cu({api:a,seed:d,prepend:f,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[Y,q]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[z,M]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),A())},[l,d,A]);const I=b.useCallback(R=>q(()=>R),[]),U=b.useCallback(R=>M(()=>R),[]),K=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:v,checkpointIndex:x,timelineCheckpoints:g,metadata:K,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:Y,navigateToCheckpoint:E,setCurrentCheckpointId:_,returnToLatest:D,loadThread:T,clearThread:Y,respondToInterrupt:z,messagePreviews:x.messagePreviews,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A,pushUser:m,onEvent:h}),[l,c,v,g,x,K,y,w,S,k,C,j,Y,E,_,D,T,z,x.messagePreviews,F,W,G,A,m,h]),O=b.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:U}),[I,U]);return u.jsx(ku.Provider,{value:O,children:u.jsx(Tu.Provider,{value:P,children:e})})}function Nu(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return Mn(r,t)??null}function xb(e){const t=Nu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Nu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function vb(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 bb(e,t){const n=[...e].sort(vb);for(const r of n){if(r.messageId!==t)continue;const o=xb(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 Au=b.createContext(null),ju=b.createContext(!1);function wb({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{api:d,baseUrl:f}=Jr(),m=b.useMemo(()=>xn(f),[f]),{stream:h,stop:v,isStreaming:g,error:x,setToken:y}=Zv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(mu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Iu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(ju.Provider,{value:!0,children:u.jsx(yb,{api:d,streamApi:{stream:h,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function yb({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:h,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=to(),{registerClearThread:E,registerRespondToInterrupt:j}=Eu(),_=b.useCallback(z=>{v(z),h.current!==z.threadId&&((z.created??!h.current)&&w(z.threadId),S(z.threadId),m(z.threadId))},[v,w,S,m,h]),D=b.useCallback(z=>{z.type==="thread_info"?_(z):z.type==="state_history"?y(z):z.type==="tool.end"?i==null||i(z):T(z)},[_,y,T,i]),F=b.useCallback(z=>{a(z,D,{onError:M=>{console.error("[StreamingProvider] Stream error:",M),r==null||r(M)},onAuthError:M=>{console.error("[StreamingProvider] Auth error:",M),o==null||o(M)},onConnectionError:M=>{console.error("[StreamingProvider] Connection error:",M),s==null||s(M)}})},[a,D,r,o,s]),W=b.useRef(g);b.useEffect(()=>{W.current=g},[g]);const G=b.useCallback(async(z,M,I)=>{const U=h.current;if(!U)throw new Error("No active thread to handle interrupt");const K=M?I??!0:!1,P=W.current,O={threadId:U,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:K}};F(O)},[h,F]);b.useEffect(()=>{j(G)},[G,j]);const A=b.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);b.useEffect(()=>{E(A)},[A,E]);const Y=b.useCallback(async(z,M)=>{let I=h.current;const U=(z==null?void 0:z.text)??"",K=(z==null?void 0:z.attachments)??[],P=(U==null?void 0:U.trim())??"",O={...(z==null?void 0:z.payload)??{}},R=Array.isArray(O.messages)?O.messages:void 0;R&&delete O.messages;const L=!!(R&&R.length);if(!I&&!P&&K.length===0&&!L)return;if(!I){const Te=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),_e=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Te}${_e}`,w(I),m(I)}const{contentParts:ee,filesInfo:B}=await iu(K),$=[...ee];P&&$.push({type:"text",text:U});const Q=M==null?void 0:M.originalMessageId,X=!!(M!=null&&M.edit&&Q),te=!L&&$.length>0;let J=null;te&&(J={id:X?Q:`msg-${Date.now()}`,role:"user",content:$,createdAt:new Date().toISOString()},X?C(J,Q):C(J));const ae=L?R:J?[J]:[],ve={...O,...B.length?{files_info:B}:{}};ae.length?ve.messages=ae:"messages"in ve||(ve.messages=[]);let de=(M==null?void 0:M.checkpointId)??g.id??void 0,me=(M==null?void 0:M.checkpointNs)??g.namespace??void 0;if(X&&Q){const Te=bb(x,Q);de=Te.checkpointId,me=Te.checkpointNs??void 0}const Ce={threadId:I,payload:ve,checkpointId:de,checkpointNs:me,edit:!!(M!=null&&M.edit)};F(Ce)},[g,h,w,C,F,x]),q=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:Y,send:Y,stop:l,setAuthToken:f}),[c,d,Y,l,f]);return u.jsx(Au.Provider,{value:q,children:e})}function Fi(){const e=b.useContext(Au);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Sb(){return b.useContext(ju)}function _u(e){return typeof e=="object"&&e!==null}function Cb(e,t){if(Object.is(e,t))return!0;if(!_u(e)||!_u(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 Pu(e){const t=b.useRef(e),n=b.useRef(e);return Cb(t.current,e)||(t.current=e,n.current=e),n.current}function wr({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=Pu(t),m=no(a),h=no(l),v=no(i),g=no(c),x=no(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:h,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,h,v,g,x]);return u.jsx(ou,{apiConfig:f,children:u.jsx(wb,{...y,children:e})})}function no(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 yr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Tb(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Mu(){const e=[yr("__API_BASE_URL__"),yr("__CHAT_API_BASE_URL__"),yr("__CHAT_API_URL__")];for(const t of e){const n=Tb(t);if(n)return n}}function Ru(){const e=[yr("__API_AUTH_TOKEN__"),yr("__CHAT_API_KEY__"),yr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ou(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Du(){const e={},t=Mu(),n=Ru();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Lu(){const e=Du(),t=Nn.getAuthToken(),n=Mu();return{apiBaseUrl:Ou(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Ru()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Bi="chat-settings";function $u(){try{const e=localStorage.getItem(Bi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Fu(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Bi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function kb(){const e=Lu(),t=$u(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ou(Nn.baseUrl,r,e.apiBaseUrl)}}function Eb(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Fu(e)}function oe(...e){return cx.twMerge(lx.clsx(e))}const Ib=Hr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ze=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:oe(Ib({variant:t,size:n,className:e})),ref:s,...o})});Ze.displayName="Button";function ie(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 Bu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Bu(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():Bu(e[o],null)}}}}function Oe(...e){return p.useCallback(On(...e),e)}function Nb(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.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 ln(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=f=>{var y;const{scope:m,children:h,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:h})};c.displayName=s+"Provider";function d(f,m){var g;const h=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(h);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=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Ab(o,...t)]}function Ab(...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 p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},jb=p[" useInsertionEffect ".trim().toString()]||Tt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=_b({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.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=p.useCallback(d=>{var f;if(a){const m=Pb(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 _b({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return jb(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Pb(e){return typeof e=="function"}var Mb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=Mb.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=p.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 zi(e,t){e&&Ur.flushSync(()=>e.dispatchEvent(t))}function Jo(e){const t=e+"CollectionProvider",[n,r]=ln(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=qt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=Oe(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=qt.createSlot(d),h=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=Oe(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[f]:"",ref:C,children:w})});h.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},v,r]}var Rb=p.createContext(void 0);function Zo(e){const t=p.useContext(Rb);return e||t||"ltr"}function pt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Ob(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e);p.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 Db="DismissableLayer",Hi="dismissableLayer.update",Lb="dismissableLayer.pointerDownOutside",$b="dismissableLayer.focusOutside",zu,Hu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Hu),[d,f]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=p.useState({}),v=Oe(t,E=>f(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Bb(E=>{const j=E.target,_=[...c.branches].some(D=>D.contains(j));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=zb(E=>{const j=E.target;[...c.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Ob(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(zu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Wu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=zu)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Wu())},[d,c]),p.useEffect(()=>{const E=()=>h({});return document.addEventListener(Hi,E),()=>document.removeEventListener(Hi,E)},[]),u.jsx(ge.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,C.onPointerDownCapture)})});Sr.displayName=Db;var Fb="DismissableLayerBranch",Uu=p.forwardRef((e,t)=>{const n=p.useContext(Hu),r=p.useRef(null),o=Oe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ge.div,{...e,ref:o})});Uu.displayName=Fb;function Bb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Vu(Lb,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 zb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Vu($b,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 Wu(){const e=new CustomEvent(Hi);document.dispatchEvent(e)}function Vu(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?zi(o,s):o.dispatchEvent(s)}var Hb=Sr,Ub=Uu,Ui=0;function Wi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ku()),document.body.insertAdjacentElement("beforeend",e[1]??Ku()),Ui++,()=>{Ui===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ui--}},[])}function Ku(){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 Vi="focusScope.autoFocusOnMount",Ki="focusScope.autoFocusOnUnmount",qu={bubbles:!1,cancelable:!0},Wb="FocusScope",Qo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=pt(o),d=pt(s),f=p.useRef(null),m=Oe(t,g=>l(g)),h=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(h.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:Ln(f.current,{select:!0})},x=function(S){if(h.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.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,h.paused]),p.useEffect(()=>{if(a){Xu.add(h);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Vi,qu);a.addEventListener(Vi,c),a.dispatchEvent(y),y.defaultPrevented||(Vb(Xb(Gu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Vi,c),setTimeout(()=>{const y=new CustomEvent(Ki,qu);a.addEventListener(Ki,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Ki,d),Xu.remove(h)},0)}}},[a,c,d,h]);const v=p.useCallback(g=>{if(!n&&!r||h.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Kb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,h.paused]);return u.jsx(ge.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Qo.displayName=Wb;function Vb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Kb(e){const t=Gu(e),n=Yu(t,e),r=Yu(t.reverse(),e);return[n,r]}function Gu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Yu(e,t){for(const n of e)if(!qb(n,{upTo:t}))return n}function qb(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Gb(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&&Gb(e)&&t&&e.select()}}var Xu=Yb();function Yb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ju(e,t),e.unshift(t)},remove(t){var n;e=Ju(e,t),(n=e[0])==null||n.resume()}}}function Ju(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Xb(e){return e.filter(t=>t.tagName!=="A")}var Jb=p[" useId ".trim().toString()]||(()=>{}),Zb=0;function _t(e){const[t,n]=p.useState(Jb());return Tt(()=>{n(r=>r??String(Zb++))},[e]),t?`radix-${t}`:""}const Qb=["top","right","bottom","left"],$n=Math.min,Xt=Math.max,es=Math.round,ts=Math.floor,vn=e=>({x:e,y:e}),ew={left:"right",right:"left",bottom:"top",top:"bottom"},tw={start:"end",end:"start"};function qi(e,t,n){return Xt(e,$n(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Cr(e){return e.split("-")[1]}function Gi(e){return e==="x"?"y":"x"}function Yi(e){return e==="y"?"height":"width"}const nw=new Set(["top","bottom"]);function bn(e){return nw.has(jn(e))?"y":"x"}function Xi(e){return Gi(bn(e))}function rw(e,t,n){n===void 0&&(n=!1);const r=Cr(e),o=Xi(e),s=Yi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ns(i)),[i,ns(i)]}function ow(e){const t=ns(e);return[Ji(e),t,Ji(t)]}function Ji(e){return e.replace(/start|end/g,t=>tw[t])}const Zu=["left","right"],Qu=["right","left"],sw=["top","bottom"],iw=["bottom","top"];function aw(e,t,n){switch(e){case"top":case"bottom":return n?t?Qu:Zu:t?Zu:Qu;case"left":case"right":return t?sw:iw;default:return[]}}function lw(e,t,n,r){const o=Cr(e);let s=aw(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ji)))),s}function ns(e){return e.replace(/left|right|bottom|top/g,t=>ew[t])}function cw(e){return{top:0,right:0,bottom:0,left:0,...e}}function ed(e){return typeof e!="number"?cw(e):{top:e,right:e,bottom:e,left:e}}function rs(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 td(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Xi(t),a=Yi(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 h;switch(l){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Cr(t)){case"start":h[i]-=m*(n&&c?-1:1);break;case"end":h[i]+=m*(n&&c?-1:1);break}return h}const uw=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}=td(c,r,l),m=r,h={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,h={...h,[x]:{...h[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=td(c,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:h}};async function ro(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:h=0}=An(t,e),v=ed(h),x=a[m?f==="floating"?"reference":"floating":f],y=rs(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,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=rs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const dw=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=ed(d),m={x:n,y:r},h=Xi(o),v=Yi(h),g=await i.getDimensions(c),x=h==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[h]-m[h]-s.floating[v],C=m[h]-s.reference[h],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,_=E/2-g[v]/2-1,D=$n(f[y],_),F=$n(f[w],_),W=D,G=E-g[v]-F,A=E/2-g[v]/2+j,Y=qi(W,A,G),q=!l.arrow&&Cr(o)!=null&&A!==Y&&s.reference[v]/2-(A<W?D:F)-g[v]/2<0,z=q?A<W?A-W:A-G:0;return{[h]:m[h]+z,data:{[h]:Y,centerOffset:A-Y-z,...q&&{alignmentOffset:z}},reset:q}}}),fw=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:h="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=bn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[ns(a)]:ow(a)),T=v!=="none";!m&&T&&C.push(...lw(a,g,v,k));const E=[a,...C],j=await ro(t,x),_=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(j[y]),f){const A=rw(o,i,k);_.push(j[A[0]],j[A[1]])}if(D=[...D,{placement:o,overflows:_}],!_.every(A=>A<=0)){var F,W;const A=(((F=s.flip)==null?void 0:F.index)||0)+1,Y=E[A];if(Y&&(!(f==="alignment"?w!==bn(Y):!1)||D.every(M=>bn(M.placement)===w?M.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:Y}};let q=(W=D.filter(z=>z.overflows[0]<=0).sort((z,M)=>z.overflows[1]-M.overflows[1])[0])==null?void 0:W.placement;if(!q)switch(h){case"bestFit":{var G;const z=(G=D.filter(M=>{if(T){const I=bn(M.placement);return I===w||I==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(I=>I>0).reduce((I,U)=>I+U,0)]).sort((M,I)=>M[1]-I[1])[0])==null?void 0:G[0];z&&(q=z);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function nd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function rd(e){return Qb.some(t=>e[t]>=0)}const hw=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 ro(t,{...o,elementContext:"reference"}),i=nd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:rd(i)}}}case"escaped":{const s=await ro(t,{...o,altBoundary:!0}),i=nd(s,n.floating);return{data:{escapedOffsets:i,escaped:rd(i)}}}default:return{}}}}},od=new Set(["left","top"]);async function pw(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=Cr(n),l=bn(n)==="y",c=od.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:h,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"&&(h=a==="end"?v*-1:v),l?{x:h*d,y:m*c}:{x:m*c,y:h*d}}const mw=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 pw(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}}}}},gw=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 ro(t,l),f=bn(jn(o)),m=Gi(f);let h=c[m],v=c[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=h+d[x],S=h-d[y];h=qi(w,h,S)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=qi(w,v,S)}const g=a.fn({...t,[m]:h,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},xw=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=bn(o),m=Gi(f);let h=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 S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;h<k?h=k:h>C&&(h=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=od.has(jn(o)),C=s.reference[f]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[f])||0)+(k?0:x.crossAxis),T=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:h,[f]:v}}}},vw=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 ro(t,c),f=jn(o),m=Cr(o),h=bn(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,S=v-d.left-d.right,k=$n(g-d[x],w),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const D=Xt(d.left,0),F=Xt(d.right,0),W=Xt(d.top,0),G=Xt(d.bottom,0);h?j=v-2*(D!==0||F!==0?D+F:Xt(d.left,d.right)):E=g-2*(W!==0||G!==0?W+G:Xt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const _=await i.getDimensions(a.floating);return v!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function os(){return typeof window<"u"}function Tr(e){return sd(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(sd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function sd(e){return os()?e instanceof Node||e instanceof Jt(e).Node:!1}function cn(e){return os()?e instanceof Element||e instanceof Jt(e).Element:!1}function yn(e){return os()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function id(e){return!os()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const bw=new Set(["inline","contents"]);function oo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=un(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!bw.has(o)}const ww=new Set(["table","td","th"]);function yw(e){return ww.has(Tr(e))}const Sw=[":popover-open",":modal"];function ss(e){return Sw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Cw=["transform","translate","scale","rotate","perspective"],Tw=["transform","translate","scale","rotate","perspective","filter"],kw=["paint","layout","strict","content"];function Zi(e){const t=Qi(),n=cn(e)?un(e):e;return Cw.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)||Tw.some(r=>(n.willChange||"").includes(r))||kw.some(r=>(n.contain||"").includes(r))}function Ew(e){let t=Fn(e);for(;yn(t)&&!kr(t);){if(Zi(t))return t;if(ss(t))return null;t=Fn(t)}return null}function Qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Iw=new Set(["html","body","#document"]);function kr(e){return Iw.has(Tr(e))}function un(e){return Jt(e).getComputedStyle(e)}function is(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Tr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||id(e)&&e.host||wn(e);return id(t)?t.host:t}function ad(e){const t=Fn(e);return kr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&oo(t)?t:ad(t)}function so(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ad(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=ea(i);return t.concat(i,i.visualViewport||[],oo(o)?o:[],a&&n?so(a):[])}return t.concat(o,so(o,[],n))}function ea(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ld(e){const t=un(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=es(n)!==s||es(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ta(e){return cn(e)?e:e.contextElement}function Er(e){const t=ta(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ld(t);let i=(s?es(n.width):n.width)/r,a=(s?es(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Nw=vn(0);function cd(e){const t=Jt(e);return!Qi()||!t.visualViewport?Nw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Aw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ta(e);let i=vn(1);t&&(r?cn(r)&&(i=Er(r)):i=Er(e));const a=Aw(s,n,r)?cd(s):vn(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=Jt(s),h=r&&cn(r)?Jt(r):r;let v=m,g=ea(v);for(;g&&r&&h!==v;){const x=Er(g),y=g.getBoundingClientRect(),w=un(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,f*=x.y,l+=S,c+=k,v=Jt(g),g=ea(v)}}return rs({width:d,height:f,x:l,y:c})}function as(e,t){const n=is(e).scrollLeft;return t?t.left+n:er(wn(e)).left+n}function ud(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-as(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function jw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?ss(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=vn(1);const d=vn(0),f=yn(r);if((f||!f&&!s)&&((Tr(r)!=="body"||oo(i))&&(l=is(r)),yn(r))){const h=er(r);c=Er(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const m=i&&!f&&!s?ud(i,l):vn(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 _w(e){return Array.from(e.getClientRects())}function Pw(e){const t=wn(e),n=is(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+as(e);const a=-n.scrollTop;return un(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const dd=25;function Mw(e,t){const n=Jt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=as(r);if(c<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-h);v<=dd&&(s-=v)}else c<=dd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Rw=new Set(["absolute","fixed"]);function Ow(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?Er(e):vn(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 fd(e,t,n){let r;if(t==="viewport")r=Mw(e,n);else if(t==="document")r=Pw(wn(e));else if(cn(t))r=Ow(t,n);else{const o=cd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(r)}function hd(e,t){const n=Fn(e);return n===t||!cn(n)||kr(n)?!1:un(n).position==="fixed"||hd(n,t)}function Dw(e,t){const n=t.get(e);if(n)return n;let r=so(e,[],!1).filter(a=>cn(a)&&Tr(a)!=="body"),o=null;const s=un(e).position==="fixed";let i=s?Fn(e):e;for(;cn(i)&&!kr(i);){const a=un(i),l=Zi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Rw.has(o.position)||oo(i)&&!l&&hd(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function Lw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ss(t)?[]:Dw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=fd(t,d,o);return c.top=Xt(f.top,c.top),c.right=$n(f.right,c.right),c.bottom=$n(f.bottom,c.bottom),c.left=Xt(f.left,c.left),c},fd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function $w(e){const{width:t,height:n}=ld(e);return{width:t,height:n}}function Fw(e,t,n){const r=yn(t),o=wn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=as(o)}if(r||!r&&!s)if((Tr(t)!=="body"||oo(o))&&(a=is(t)),r){const h=er(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ud(o,a):vn(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 na(e){return un(e).position==="static"}function pd(e,t){if(!yn(e)||un(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function md(e,t){const n=Jt(e);if(ss(e))return n;if(!yn(e)){let o=Fn(e);for(;o&&!kr(o);){if(cn(o)&&!na(o))return o;o=Fn(o)}return n}let r=pd(e,t);for(;r&&yw(r)&&na(r);)r=pd(r,t);return r&&kr(r)&&na(r)&&!Zi(r)?n:r||Ew(e)||n}const Bw=async function(e){const t=this.getOffsetParent||md,n=this.getDimensions,r=await n(e.floating);return{reference:Fw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zw(e){return un(e).direction==="rtl"}const Hw={convertOffsetParentRelativeRectToViewportRelativeRect:jw,getDocumentElement:wn,getClippingRect:Lw,getOffsetParent:md,getElementRects:Bw,getClientRects:_w,getDimensions:$w,getScale:Er,isElement:cn,isRTL:zw};function gd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Uw(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:m,height:h}=c;if(a||t(),!m||!h)return;const v=ts(f),g=ts(o.clientWidth-(d+m)),x=ts(o.clientHeight-(f+h)),y=ts(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,$n(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!gd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Ww(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=ta(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 f=c&&a?Uw(c,n):null;let m=-1,h=null;i&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(t)})),n()}),c&&!l&&h.observe(c),h.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!gd(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=h)==null||y.disconnect(),h=null,l&&cancelAnimationFrame(v)}}const Vw=mw,Kw=gw,qw=fw,Gw=vw,Yw=hw,xd=dw,Xw=xw,Jw=(e,t,n)=>{const r=new Map,o={platform:Hw,...n},s={...o.platform,_c:r};return uw(e,t,{...o,platform:s})};var Zw=typeof document<"u",Qw=function(){},ls=Zw?b.useLayoutEffect:Qw;function cs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!cs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function vd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function bd(e,t){const n=vd(e);return Math.round(t*n)/n}function ra(e){const t=p.useRef(e);return ls(()=>{t.current=e}),t}function ey(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=p.useState(r);cs(m,r)||h(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),w=p.useCallback(M=>{M!==T.current&&(T.current=M,g(M))},[]),S=p.useCallback(M=>{M!==E.current&&(E.current=M,y(M))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),j=p.useRef(d),_=l!=null,D=ra(l),F=ra(o),W=ra(c),G=p.useCallback(()=>{if(!T.current||!E.current)return;const M={placement:t,strategy:n,middleware:m};F.current&&(M.platform=F.current),Jw(T.current,E.current,M).then(I=>{const U={...I,isPositioned:W.current!==!1};A.current&&!cs(j.current,U)&&(j.current=U,Ur.flushSync(()=>{f(U)}))})},[m,t,n,F,W]);ls(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[c]);const A=p.useRef(!1);ls(()=>(A.current=!0,()=>{A.current=!1}),[]),ls(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(D.current)return D.current(k,C,G);G()}},[k,C,G,D,_]);const Y=p.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),q=p.useMemo(()=>({reference:k,floating:C}),[k,C]),z=p.useMemo(()=>{const M={position:n,left:0,top:0};if(!q.floating)return M;const I=bd(q.floating,d.x),U=bd(q.floating,d.y);return a?{...M,transform:"translate("+I+"px, "+U+"px)",...vd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:U}},[n,a,q.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:G,refs:Y,elements:q,floatingStyles:z}),[d,G,Y,q,z])}const ty=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?xd({element:r.current,padding:o}).fn(n):{}:r?xd({element:r,padding:o}).fn(n):{}}}},ny=(e,t)=>({...Vw(e),options:[e,t]}),ry=(e,t)=>({...Kw(e),options:[e,t]}),oy=(e,t)=>({...Xw(e),options:[e,t]}),sy=(e,t)=>({...qw(e),options:[e,t]}),iy=(e,t)=>({...Gw(e),options:[e,t]}),ay=(e,t)=>({...Yw(e),options:[e,t]}),ly=(e,t)=>({...ty(e),options:[e,t]});var cy="Arrow",wd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ge.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"})})});wd.displayName=cy;var uy=wd;function yd(e){const[t,n]=p.useState(void 0);return Tt(()=>{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 oa="Popper",[Sd,Ir]=ln(oa),[dy,Cd]=Sd(oa),Td=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(dy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Td.displayName=oa;var kd="PopperAnchor",Ed=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Cd(kd,n),i=p.useRef(null),a=Oe(t,i),l=p.useRef(null);return p.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(ge.div,{...o,ref:a})});Ed.displayName=kd;var sa="PopperContent",[fy,hy]=Sd(sa),Id=p.forwardRef((e,t)=>{var B,$,Q,X,te,J;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:h="optimized",onPlaced:v,...g}=e,x=Cd(sa,n),[y,w]=p.useState(null),S=Oe(t,ae=>w(ae)),[k,C]=p.useState(null),T=yd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],W=F.length>0,G={padding:D,boundary:F.filter(my),altBoundary:W},{refs:A,floatingStyles:Y,placement:q,isPositioned:z,middlewareData:M}=ey({strategy:"fixed",placement:_,whileElementsMounted:(...ae)=>Ww(...ae,{animationFrame:h==="always"}),elements:{reference:x.anchor},middleware:[ny({mainAxis:o+j,alignmentAxis:i}),l&&ry({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?oy():void 0,...G}),l&&sy({...G}),iy({...G,apply:({elements:ae,rects:ve,availableWidth:de,availableHeight:me})=>{const{width:Ce,height:Te}=ve.reference,_e=ae.floating.style;_e.setProperty("--radix-popper-available-width",`${de}px`),_e.setProperty("--radix-popper-available-height",`${me}px`),_e.setProperty("--radix-popper-anchor-width",`${Ce}px`),_e.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),k&&ly({element:k,padding:a}),gy({arrowWidth:E,arrowHeight:j}),m&&ay({strategy:"referenceHidden",...G})]}),[I,U]=jd(q),K=pt(v);Tt(()=>{z&&(K==null||K())},[z,K]);const P=(B=M.arrow)==null?void 0:B.x,O=($=M.arrow)==null?void 0:$.y,R=((Q=M.arrow)==null?void 0:Q.centerOffset)!==0,[L,ee]=p.useState();return Tt(()=>{y&&ee(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:z?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(X=M.transformOrigin)==null?void 0:X.x,(te=M.transformOrigin)==null?void 0:te.y].join(" "),...((J=M.hide)==null?void 0:J.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(fy,{scope:n,placedSide:I,onArrowChange:C,arrowX:P,arrowY:O,shouldHideArrow:R,children:u.jsx(ge.div,{"data-side":I,"data-align":U,...g,ref:S,style:{...g.style,animation:z?void 0:"none"}})})})});Id.displayName=sa;var Nd="PopperArrow",py={top:"bottom",right:"left",bottom:"top",left:"right"},Ad=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=hy(Nd,r),i=py[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(uy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ad.displayName=Nd;function my(e){return e!==null}var gy=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]=jd(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,h=(((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:`${h}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?f:`${h}px`),{data:{x:v,y:g}}}});function jd(e){const[t,n="center"]=e.split("-");return[t,n]}var ia=Td,aa=Ed,la=Id,ca=Ad,xy="Portal",io=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ro.createPortal(u.jsx(ge.div,{...r,ref:t}),i):null});io.displayName=xy;function vy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=by(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Oe(r.ref,wy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function by(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=vy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=us(r.current);s.current=a==="mounted"?c:"none"},[a]),Tt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,h=us(c);e?l("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Tt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=h=>{const g=us(r.current).includes(CSS.escape(h.animationName));if(h.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=h=>{h.target===t&&(s.current=us(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:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function us(e){return(e==null?void 0:e.animationName)||"none"}function wy(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 ua="rovingFocusGroup.onEntryFocus",yy={bubbles:!1,cancelable:!0},ao="RovingFocusGroup",[da,_d,Sy]=Jo(ao),[Cy,Pd]=ln(ao,[Sy]),[Ty,ky]=Cy(ao),Md=p.forwardRef((e,t)=>u.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Ey,{...e,ref:t})})}));Md.displayName=ao;var Ey=p.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=p.useRef(null),h=Oe(t,m),v=Zo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:ao}),[y,w]=p.useState(!1),S=pt(c),k=_d(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ua,S),()=>j.removeEventListener(ua,S)},[S]),u.jsx(Ty,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(j=>x(j),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:p.useCallback(()=>E(j=>j-1),[]),children:u.jsx(ge.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{C.current=!0}),onFocus:ie(e.onFocus,j=>{const _=!C.current;if(j.target===j.currentTarget&&_&&!y){const D=new CustomEvent(ua,yy);if(j.currentTarget.dispatchEvent(D),!D.defaultPrevented){const F=k().filter(q=>q.focusable),W=F.find(q=>q.active),G=F.find(q=>q.id===g),Y=[W,G,...F].filter(Boolean).map(q=>q.ref.current);Dd(Y,d)}}C.current=!1}),onBlur:ie(e.onBlur,()=>w(!1))})})}),Rd="RovingFocusGroupItem",Od=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_t(),c=s||l,d=ky(Rd,n),f=d.currentTabStopId===c,m=_d(n),{onFocusableItemAdd:h,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return h(),()=>v()},[r,h,v]),u.jsx(da.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ge.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ay(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?jy(S,k+1):S.slice(k+1)}setTimeout(()=>Dd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Od.displayName=Rd;var Iy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ny(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ay(e,t,n){const r=Ny(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Iy[r]}function Dd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function jy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _y=Md,Py=Od,My=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Nr=new WeakMap,ds=new WeakMap,fs={},fa=0,Ld=function(e){return e&&(e.host||Ld(e.parentNode))},Ry=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ld(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})},Oy=function(e,t,n,r){var o=Ry(t,Array.isArray(e)?e:[e]);fs[n]||(fs[n]=new WeakMap);var s=fs[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(m){if(a.has(m))d(m);else try{var h=m.getAttribute(r),v=h!==null&&h!=="false",g=(Nr.get(m)||0)+1,x=(s.get(m)||0)+1;Nr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&ds.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),fa++,function(){i.forEach(function(f){var m=Nr.get(f)-1,h=s.get(f)-1;Nr.set(f,m),s.set(f,h),m||(ds.has(f)||f.removeAttribute(r),ds.delete(f)),h||f.removeAttribute(n)}),fa--,fa||(Nr=new WeakMap,Nr=new WeakMap,ds=new WeakMap,fs={})}},ha=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=My(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Oy(r,o,n,"aria-hidden")):function(){return null}},Sn=function(){return Sn=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},Sn.apply(this,arguments)};function $d(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 Dy(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 hs="right-scroll-bar-position",ps="width-before-scroll-bar",Ly="with-scroll-bars-hidden",$y="--removed-body-scroll-bar-size";function pa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Fy(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 By=typeof window<"u"?p.useLayoutEffect:p.useEffect,Fd=new WeakMap;function zy(e,t){var n=Fy(null,function(r){return e.forEach(function(o){return pa(o,r)})});return By(function(){var r=Fd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||pa(a,null)}),s.forEach(function(a){o.has(a)||pa(a,i)})}Fd.set(n,e)},[e]),n}function Hy(e){return e}function Uy(e,t){t===void 0&&(t=Hy);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 Wy(e){e===void 0&&(e={});var t=Uy(null);return t.options=Sn({async:!0,ssr:!1},e),t}var Bd=function(e){var t=e.sideCar,n=$d(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 p.createElement(r,Sn({},n))};Bd.isSideCarExport=!0;function Vy(e,t){return e.useMedium(t),Bd}var zd=Wy(),ma=function(){},ms=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ma,onWheelCapture:ma,onTouchMoveCapture:ma}),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,h=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=$d(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=zy([n,t]),E=Sn(Sn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:zd,removeScrollBar:c,shards:f,noRelative:h,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Sn(Sn({},E),{ref:T})):p.createElement(w,Sn({},E,{className:l,ref:T}),a))});ms.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ms.classNames={fullWidth:ps,zeroRight:hs};var Ky=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Ky();return t&&e.setAttribute("nonce",t),e}function Gy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Xy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qy())&&(Gy(t,n),Yy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Jy=function(){var e=Xy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Hd=function(){var e=Jy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Zy={left:0,top:0,right:0,gap:0},ga=function(e){return parseInt(e||"",10)||0},Qy=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[ga(n),ga(r),ga(o)]},e0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Zy;var t=Qy(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])}},t0=Hd(),Ar="data-scroll-locked",n0=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
40
|
.`.concat(Ly,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -73,26 +73,26 @@ React keys must be passed directly to JSX without using spread:
|
|
|
73
73
|
body[`).concat(Ar,`] {
|
|
74
74
|
`).concat($y,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},Ud=function(){var e=parseInt(document.body.getAttribute(Ar)||"0",10);return isFinite(e)?e:0},r0=function(){
|
|
76
|
+
`)},Ud=function(){var e=parseInt(document.body.getAttribute(Ar)||"0",10);return isFinite(e)?e:0},r0=function(){p.useEffect(function(){return document.body.setAttribute(Ar,(Ud()+1).toString()),function(){var e=Ud()-1;e<=0?document.body.removeAttribute(Ar):document.body.setAttribute(Ar,e.toString())}},[])},o0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;r0();var s=p.useMemo(function(){return e0(o)},[o]);return p.createElement(t0,{styles:n0(s,!t,o,n?"":"!important")})},xa=!1;if(typeof window<"u")try{var gs=Object.defineProperty({},"passive",{get:function(){return xa=!0,!0}});window.addEventListener("test",gs,gs),window.removeEventListener("test",gs,gs)}catch{xa=!1}var jr=xa?{passive:!1}:!1,s0=function(e){return e.tagName==="TEXTAREA"},Wd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!s0(e)&&n[t]==="visible")},i0=function(e){return Wd(e,"overflowY")},a0=function(e){return Wd(e,"overflowX")},Vd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Kd(e,r);if(o){var s=qd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},l0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},c0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Kd=function(e,t){return e==="v"?i0(t):a0(t)},qd=function(e,t){return e==="v"?l0(t):c0(t)},u0=function(e,t){return e==="h"&&t==="rtl"?-1:1},d0=function(e,t,n,r,o){var s=u0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,m=0;do{if(!a)break;var h=qd(e,a),v=h[0],g=h[1],x=h[2],y=g-x-s*v;(v||y)&&Kd(e,a)&&(f+=y,m+=v);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(f)<1||!d&&Math.abs(m)<1)&&(c=!0),c},xs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Gd=function(e){return[e.deltaX,e.deltaY]},Yd=function(e){return e&&"current"in e?e.current:e},f0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},h0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},p0=0,_r=[];function m0(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(p0++)[0],s=m.useState(Hd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Dy([e.lockRef.current],(e.shards||[]).map(Yd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=xs(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Vd(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Vd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return d0(_,x,g,_==="h"?S:k)},[]),l=m.useCallback(function(g){var x=g;if(!(!_r.length||_r[_r.length-1]!==s)){var y="deltaY"in x?Gd(x):xs(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&f0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Yd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=m.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:g0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=m.useCallback(function(g){n.current=xs(g),r.current=void 0},[]),h=m.useCallback(function(g){c(g.type,Gd(g),g.target,a(g,e.lockRef.current))},[]),p=m.useCallback(function(g){c(g.type,xs(g),g.target,a(g,e.lockRef.current))},[]);m.useEffect(function(){return _r.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",l,jr),document.addEventListener("touchmove",l,jr),document.addEventListener("touchstart",d,jr),function(){_r=_r.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,jr),document.removeEventListener("touchmove",l,jr),document.removeEventListener("touchstart",d,jr)}},[]);var f=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:h0(o)}):null,f?m.createElement(o0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function g0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const x0=Vy(zd,m0);var vs=m.forwardRef(function(e,t){return m.createElement(ms,Sn({},e,{ref:t,sideCar:x0}))});vs.classNames=ms.classNames;var va=["Enter"," "],v0=["ArrowDown","PageUp","Home"],Xd=["ArrowUp","PageDown","End"],b0=[...v0,...Xd],w0={ltr:[...va,"ArrowRight"],rtl:[...va,"ArrowLeft"]},y0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},lo="Menu",[co,S0,C0]=Jo(lo),[tr,Jd]=ln(lo,[C0,Ir,Pd]),bs=Ir(),Zd=Pd(),[T0,nr]=tr(lo),[k0,uo]=tr(lo),Qd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=bs(t),[l,c]=m.useState(null),d=m.useRef(!1),h=pt(s),p=Zo(o);return m.useEffect(()=>{const f=()=>{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",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ia,{...a,children:u.jsx(T0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(k0,{scope:t,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Qd.displayName=lo;var E0="MenuAnchor",ba=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(aa,{...o,...r,ref:t})});ba.displayName=E0;var wa="MenuPortal",[I0,ef]=tr(wa,{forceMount:void 0}),tf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(wa,t);return u.jsx(I0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:r})})})};tf.displayName=wa;var en="MenuContent",[N0,ya]=tr(en),nf=m.forwardRef((e,t)=>{const n=ef(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=uo(en,e.__scopeMenu);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(A0,{...o,ref:t}):u.jsx(j0,{...o,ref:t})})})})}),A0=m.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu),r=m.useRef(null),o=Oe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Sa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),j0=m.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu);return u.jsx(Sa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),_0=qt.createSlot("MenuContent.ScrollLock"),Sa=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:p,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(en,n),y=uo(en,n),w=bs(n),S=Zd(n),k=S0(n),[C,T]=m.useState(null),E=m.useRef(null),j=Oe(t,E,x.onContentChange),_=m.useRef(0),D=m.useRef(""),F=m.useRef(0),W=m.useRef(null),G=m.useRef("right"),A=m.useRef(0),Y=v?vs:m.Fragment,q=v?{as:_0,allowPinchZoom:!0}:void 0,B=I=>{var z,$;const U=D.current+I,K=k().filter(Q=>!Q.disabled),P=document.activeElement,O=(z=K.find(Q=>Q.ref.current===P))==null?void 0:z.textValue,M=K.map(Q=>Q.textValue),L=U0(M,U,O),ee=($=K.find(Q=>Q.textValue===L))==null?void 0:$.ref.current;(function Q(X){D.current=X,window.clearTimeout(_.current),X!==""&&(_.current=window.setTimeout(()=>Q(""),1e3))})(U),ee&&setTimeout(()=>ee.focus())};m.useEffect(()=>()=>window.clearTimeout(_.current),[]),Wi();const R=m.useCallback(I=>{var K,P;return G.current===((K=W.current)==null?void 0:K.side)&&V0(I,(P=W.current)==null?void 0:P.area)},[]);return u.jsx(N0,{scope:n,searchRef:D,onItemEnter:m.useCallback(I=>{R(I)&&I.preventDefault()},[R]),onItemLeave:m.useCallback(I=>{var U;R(I)||((U=E.current)==null||U.focus(),T(null))},[R]),onTriggerLeave:m.useCallback(I=>{R(I)&&I.preventDefault()},[R]),pointerGraceTimerRef:F,onPointerGraceIntentChange:m.useCallback(I=>{W.current=I},[]),children:u.jsx(Y,{...q,children:u.jsx(Qo,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var U;I.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:p,onDismiss:f,children:u.jsx(_y,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(la,{role:"menu","aria-orientation":"vertical","data-state":wf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const K=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;K&&(I.key==="Tab"&&I.preventDefault(),!P&&O&&B(I.key));const M=E.current;if(I.target!==M||!b0.includes(I.key))return;I.preventDefault();const ee=k().filter(z=>!z.disabled).map(z=>z.ref.current);Xd.includes(I.key)&&ee.reverse(),z0(ee)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),D.current="")}),onPointerMove:ie(e.onPointerMove,ho(I=>{const U=I.target,K=A.current!==I.clientX;if(I.currentTarget.contains(U)&&K){const P=I.clientX>A.current?"right":"left";G.current=P,A.current=I.clientX}}))})})})})})})});nf.displayName=en;var P0="MenuGroup",Ca=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{role:"group",...r,ref:t})});Ca.displayName=P0;var R0="MenuLabel",rf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});rf.displayName=R0;var ws="MenuItem",of="menu.itemSelect",ys=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=uo(ws,e.__scopeMenu),a=ya(ws,e.__scopeMenu),l=Oe(t,s),c=m.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const p=new CustomEvent(of,{bubbles:!0,cancelable:!0});h.addEventListener(of,f=>r==null?void 0:r(f),{once:!0}),zi(h,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(sf,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:h=>{var p;(p=e.onPointerDown)==null||p.call(e,h),c.current=!0},onPointerUp:ie(e.onPointerUp,h=>{var p;c.current||(p=h.currentTarget)==null||p.click()}),onKeyDown:ie(e.onKeyDown,h=>{const p=a.searchRef.current!=="";n||p&&h.key===" "||va.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ys.displayName=ws;var sf=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ya(ws,n),a=Zd(n),l=m.useRef(null),c=Oe(t,l),[d,h]=m.useState(!1),[p,f]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(co.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(Py,{asChild:!0,...a,focusable:!r,children:u.jsx(ge.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,ho(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,ho(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>h(!0)),onBlur:ie(e.onBlur,()=>h(!1))})})})}),M0="MenuCheckboxItem",af=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ff,{scope:e.__scopeMenu,checked:n,children:u.jsx(ys,{role:"menuitemcheckbox","aria-checked":Ss(n)?"mixed":n,...o,ref:t,"data-state":ka(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(Ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});af.displayName=M0;var lf="MenuRadioGroup",[O0,D0]=tr(lf,{value:void 0,onValueChange:()=>{}}),cf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(O0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ca,{...o,ref:t})})});cf.displayName=lf;var uf="MenuRadioItem",df=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=D0(uf,e.__scopeMenu),s=n===o.value;return u.jsx(ff,{scope:e.__scopeMenu,checked:s,children:u.jsx(ys,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ka(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});df.displayName=uf;var Ta="MenuItemIndicator",[ff,L0]=tr(Ta,{checked:!1}),hf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=L0(Ta,n);return u.jsx(zt,{present:r||Ss(s.checked)||s.checked===!0,children:u.jsx(ge.span,{...o,ref:t,"data-state":ka(s.checked)})})});hf.displayName=Ta;var $0="MenuSeparator",pf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});pf.displayName=$0;var F0="MenuArrow",mf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ca,{...o,...r,ref:t})});mf.displayName=F0;var B0="MenuSub",[LN,gf]=tr(B0),fo="MenuSubTrigger",xf=m.forwardRef((e,t)=>{const n=nr(fo,e.__scopeMenu),r=uo(fo,e.__scopeMenu),o=gf(fo,e.__scopeMenu),s=ya(fo,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(ba,{asChild:!0,...c,children:u.jsx(sf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wf(n.open),...e,ref:On(t,o.onTriggerChange),onClick:h=>{var p;(p=e.onClick)==null||p.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ie(e.onPointerMove,ho(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,ho(h=>{var f,v;d();const p=(f=n.content)==null?void 0:f.getBoundingClientRect();if(p){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=p[x?"left":"right"],S=p[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:w,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:w,y:p.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,h=>{var f;const p=s.searchRef.current!=="";e.disabled||p&&h.key===" "||w0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});xf.displayName=fo;var vf="MenuSubContent",bf=m.forwardRef((e,t)=>{const n=ef(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=uo(en,e.__scopeMenu),a=gf(vf,e.__scopeMenu),l=m.useRef(null),c=Oe(t,l);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:u.jsx(Sa,{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 h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),p=y0[i.dir].includes(d.key);h&&p&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});bf.displayName=vf;function wf(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function ka(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function z0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function H0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function U0(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=H0(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 W0(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,h=l.x,p=l.y;d>r!=p>r&&n<(h-c)*(r-d)/(p-d)+c&&(o=!o)}return o}function V0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return W0(n,t)}function ho(e){return t=>t.pointerType==="mouse"?e(t):void 0}var K0=Qd,q0=ba,G0=tf,Y0=nf,X0=Ca,J0=rf,Z0=ys,Q0=af,eS=cf,tS=df,nS=hf,rS=pf,oS=mf,sS=xf,iS=bf,Cs="DropdownMenu",[aS,$N]=ln(Cs,[Jd]),Dt=Jd(),[lS,yf]=aS(Cs),Sf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=m.useRef(null),[d,h]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:Cs});return u.jsx(lS,{scope:t,triggerId:_t(),triggerRef:c,contentId:_t(),open:d,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),modal:a,children:u.jsx(K0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};Sf.displayName=Cs;var Cf="DropdownMenuTrigger",Tf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=yf(Cf,n),i=Dt(n);return u.jsx(q0,{asChild:!0,...i,children:u.jsx(ge.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:On(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Tf.displayName=Cf;var cS="DropdownMenuPortal",kf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(G0,{...r,...n})};kf.displayName=cS;var Ef="DropdownMenuContent",If=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yf(Ef,n),s=Dt(n),i=m.useRef(!1);return u.jsx(Y0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(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)"}})});If.displayName=Ef;var uS="DropdownMenuGroup",dS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(X0,{...o,...r,ref:t})});dS.displayName=uS;var fS="DropdownMenuLabel",Nf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(J0,{...o,...r,ref:t})});Nf.displayName=fS;var hS="DropdownMenuItem",Af=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Z0,{...o,...r,ref:t})});Af.displayName=hS;var pS="DropdownMenuCheckboxItem",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Q0,{...o,...r,ref:t})});jf.displayName=pS;var mS="DropdownMenuRadioGroup",gS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(eS,{...o,...r,ref:t})});gS.displayName=mS;var xS="DropdownMenuRadioItem",_f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(tS,{...o,...r,ref:t})});_f.displayName=xS;var vS="DropdownMenuItemIndicator",Pf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(nS,{...o,...r,ref:t})});Pf.displayName=vS;var bS="DropdownMenuSeparator",Rf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(rS,{...o,...r,ref:t})});Rf.displayName=bS;var wS="DropdownMenuArrow",yS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(oS,{...o,...r,ref:t})});yS.displayName=wS;var SS="DropdownMenuSubTrigger",Mf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(sS,{...o,...r,ref:t})});Mf.displayName=SS;var CS="DropdownMenuSubContent",Of=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(iS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=CS;var TS=Sf,kS=Tf,ES=kf,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf,Hf=Rf,Uf=Mf,Wf=Of;const Ts=TS,ks=kS,IS=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Uf,{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(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));IS.displayName=Uf.displayName;const NS=m.forwardRef(({className:e,...t},n)=>u.jsx(Wf,{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}));NS.displayName=Wf.displayName;const po=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(ES,{children:u.jsx(Df,{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})}));po.displayName=Df.displayName;const Bn=m.forwardRef(({className:e,inset:t,...n},r)=>u.jsx($f,{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}));Bn.displayName=$f.displayName;const AS=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Ff,{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(zf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));AS.displayName=Ff.displayName;const jS=m.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Bf,{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(zf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));jS.displayName=Bf.displayName;const _S=m.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Lf,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));_S.displayName=Lf.displayName;const PS=m.forwardRef(({className:e,...t},n)=>u.jsx(Hf,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));PS.displayName=Hf.displayName;const Ea=m.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ea.displayName="Textarea";const RS=1e4;function Vf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=RS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",textareaClassName:p="",allowEmptySend:f=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[w,S]=b.useState(e),k=(y?i:w)??"",[C,T]=b.useTransition(),E=b.useRef(null),j=b.useRef(0),_=b.useRef(null),D=b.useRef("");b.useEffect(()=>{y||(S(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,W]=b.useState(null),G=b.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),A=b.useMemo(()=>g??G,[g,G]),Y=b.useCallback(M=>{const L=A(M);return W(L),x==null||x(L),D.current=M,L},[A,x]),q=b.useCallback(()=>{const M=E.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);b.useEffect(()=>{q()},[q,k]),b.useEffect(()=>{if(!F)return;const M=(k??"").trim();D.current!==M&&Y(M)},[k,F,Y]);const B=b.useCallback((M,{fromUser:L})=>{y||S(M),L&&(a==null||a(M))},[y,a]),R=b.useCallback(async M=>{M&&M.preventDefault();const L=(k??"").trim();if(!L&&!f||Y(L))return;const ee=++j.current;_.current={id:ee,shouldClear:!0},T(()=>{var z,$,Q;try{const X=l(L);X&&typeof X.then=="function"?X.then(()=>{var te,J;((te=_.current)==null?void 0:te.id)===ee&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((J=_.current)==null?void 0:J.id)===ee&&(_.current=null)}).catch(()=>{var te;((te=_.current)==null?void 0:te.id)===ee&&(_.current=null)}):(((z=_.current)==null?void 0:z.id)===ee&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),(($=_.current)==null?void 0:$.id)===ee&&(_.current=null))}catch{((Q=_.current)==null?void 0:Q.id)===ee&&(_.current=null)}})},[k,l,f,y,a,Y]),I=b.useCallback(M=>{const L=M.target.value;B(L,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&Y(L.trim())},[B,Y,F]),U=b.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),R()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[R,t,c]),O=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${p}`;return u.jsx("form",{onSubmit:M=>void R(M),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ea,{ref:E,value:k,onChange:I,onKeyDown:U,placeholder:t?"Edit your message...":n,className:O,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),F&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:F})]}),u.jsx("div",{children:r?u.jsx(Ze,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(Ze,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||C,children:u.jsx(le.Send,{size:16})})})]})})}const MS=b.memo(Vf);function Kf({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:h={},enableFileUpload:p=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[w,S]=b.useState([]),k=b.useRef(null),C=b.useRef(null),[T,E]=b.useState(0),[j,_]=b.useState(0),[D,F]=b.useState(!1),[W,G]=b.useState(null),[A,Y]=b.useState(null),q=b.useCallback(()=>{k.current&&(k.current.value=""),C.current&&(C.current.value=""),E(M=>M+1),_(M=>M+1)},[]),B=b.useCallback(M=>{S(L=>[...L,...M])},[]),R=b.useCallback(M=>{const L=Array.from(M.target.files||[]);B(L),M.target.value=""},[B]),I=b.useCallback(M=>{S(L=>{const ee=L.filter((z,$)=>$!==M);return ee.length===0&&q(),ee})},[q]),U=b.useCallback(async M=>{const L=(M.target.files||[])[0];if(L&&(G(null),Y(null),!!v)){F(!0);try{await v(L),G(`Uploaded ${L.name} - processing through chat stream`)}catch(ee){const z=ee instanceof Error?ee.message:"Failed to upload Excel file";Y(z),g==null||g(z)}finally{F(!1),M.target.value="",q()}}},[v,g,q]),K=b.useMemo(()=>x||w.length>0,[x,w]),P=b.useCallback(async M=>{const L=n(M,w);try{const ee=await L;return w.length>0&&(S([]),q()),ee}catch(ee){throw ee}},[n,q,w]),O=`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":""} ${y?"border-red-400":""} ${h.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(p||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:R,className:"hidden"},T),w.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:w.map((M,L)=>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(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:M.name}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>I(L),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 ${M.name}`,children:u.jsx(le.X,{size:12})})]},L))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"file",accept:".xls,.xlsx,.xlsm",onChange:U,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),W&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:W}),A&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:A})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(p||f)&&u.jsxs(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Ze,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:h.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(po,{align:"start",sideOffset:6,className:"w-52",children:[p&&u.jsxs(Bn,{onClick:()=>{var M;return(M=k.current)==null?void 0:M.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Bn,{onClick:()=>{var M;D||(M=C.current)==null||M.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(MS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:P,onCancelEdit:r,onStop:o,allowEmptySend:K,textareaClassName:O,sendButtonClassName:h.sendButton})})]})]})}const OS=b.memo(Kf),Es=0,zn=1,Pr=2,qf=4;function Gf(e){return()=>e}function DS(e){e()}function Yf(e,t){return n=>e(t(n))}function Xf(e,t){return()=>e(t)}function LS(e,t){return n=>e(t,n)}function Ia(e){return e!==void 0}function $S(...e){return()=>{e.map(DS)}}function Rr(){}function Is(e,t){return t(e),e}function FS(e,t){return t(e)}function ot(...e){return e}function Xe(e,t){return e(zn,t)}function je(e,t){e(Es,t)}function Na(e){e(Pr)}function mt(e){return e(qf)}function xe(e,t){return Xe(e,LS(t,Es))}function dn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function Jf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Zf(e,t){return e===t}function st(e=Zf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Yf(t,e)}function Cn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=BS(...t);return(r,o)=>{switch(r){case Pr:Na(e);return;case zn:return Xe(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(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 BS(...e){return t=>e.reduceRight(FS,t)}function zS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),Rr);case Pr:r(),n=null;return}}}function se(e){let t=e;const n=Ue();return(r,o)=>{switch(r){case Es:t=o;break;case zn:{o(t);break}case qf:return t}return n(r,o)}}function Pt(e,t){return Is(se(t),n=>xe(e,n))}function Ue(){const e=[];return(t,n)=>{switch(t){case Es:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Is(Ue(),t=>xe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:HS(),singleton:n}}const HS=()=>Symbol();function US(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 vt(...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);Xe(s,l=>{n[i]=l,r=r|a,r===o&&je(t,n)})}),function(s,i){switch(s){case Pr:{Na(t);return}case zn:return r===o&&i(n),Xe(t,i)}}}function ke(e,t=Zf){return ne(e,st(t))}function Aa(...e){return function(t,n){switch(t){case Pr:return;case zn:return $S(...e.map(r=>Xe(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const WS={0:"debug",3:"error",1:"log",2:"warn"},VS=()=>typeof globalThis>"u"?window:globalThis,Hn=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=VS().VIRTUOSO_LOG_LEVEL)!=null?o:mt(e);r>=s&&console[WS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return ja(e,t,n).callbackRef}function ja(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 KS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const h=qS(d.children,t,a?"offsetWidth":"offsetHeight",o);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const f=p.lastElementChild.dataset.viewportType==="window";let v;f&&(v=p.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Qf("column-gap",getComputedStyle(d).columnGap,o):Qf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return ja(c,n,l)}function qS(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},Ht.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Qf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function eh(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 h,p;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;p=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;p=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:p,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ja(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 Lt=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),h=Ue(),p=Ue(),f=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:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),mo={lvl:0};function th(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 tt(e){return e===mo}function go(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?go(e.l,t):go(e.r,t)}function fn(e,t,n="k"){if(tt(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 tt(e)?oh(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?sh(wt(e,{l:Qt(e.l,t,n)})):sh(wt(e,{r:Qt(e.r,t,n)}))}function Mr(){return mo}function Ns(e,t,n){if(tt(e))return[];const r=fn(e,t)[0];return GS(Pa(e,r,n))}function _a(e,t){if(tt(e))return mo;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=rh(r);return As(wt(e,{k:s,l:nh(r),v:i}))}}else return t<n?As(wt(e,{l:_a(r,t)})):As(wt(e,{r:_a(o,t)}))}function sr(e){return tt(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function Pa(e,t,n){if(tt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Pa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Pa(s,t,n))),a}function As(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(Ra(t))return ih(wt(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ra(e))return Ma(wt(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=Ra(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ma(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return oh(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 nh(e){return tt(e.r)?e.l:As(wt(e,{r:nh(e.r)}))}function Ra(e){return tt(e)||e.lvl>e.r.lvl}function rh(e){return tt(e.r)?[e.k,e.v]:rh(e.r)}function oh(e,t,n,r=mo,o=mo){return{k:e,l:r,lvl:n,r:o,v:t}}function sh(e){return Ma(ih(e))}function ih(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function Ma(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function GS(e){return th(e,({k:t,v:n})=>({index:t,value:n}))}function ah(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function xo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Oa=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function lh(e,t,n){return e[js(e,t,n)]}function js(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 YS(e,t,n,r){const o=js(e,t,r),s=js(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function _s(e){return!tt(e.groupOffsetTree)}function Da({index:e},t){return t===e?0:t<e?-1:1}function XS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function JS(e,t){let n=tt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),tt(e)){e=Qt(e,0,s);continue}const a=Ns(e,i-1,o+1);if(a.some(oC(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:p}of a)l?(o>=h||s===p)&&(e=_a(e,h)):(c=p!==s,l=!0),d>o&&o>=h&&p!==s&&(e=Qt(e,o+1,p));c&&(e=Qt(e,i,s))}return[e,n]}function ZS(e){return typeof e.groupIndex<"u"}function QS({offset:e},t){return t===e?0:t<e?-1:1}function vo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=lh(t,e,Da),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function ch(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function uh(e,t,n){if(ZS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=ch(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function eC(e,t,n,r=0){return r>0&&(t=Math.max(t,lh(e,r,Da).offset)),th(YS(e,t,n,QS),rC)}function tC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&tt(s)&&t.length===2){const p=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,p),g+1,f),i)}else[i,a]=JS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=La(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,f)=>Qt(p,f,vo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function nC(e){return sr(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 dh(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 La(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=js(o,t-1,Da),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 Ns(n,t,1/0)){const h=c-s,p=h*i+a+h*r;o.push({index:c,offset:p,size:d}),s=c,a=p,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function rC(e){return{index:e.index,value:e}}function oC(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 sC={offsetHeight:"height",offsetWidth:"width"},kn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=Ue(),r=Ue(),o=Pt(r,0),s=Ue(),i=Ue(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),h=se((C,T)=>Un(C,sC[T])),p=se(void 0),f=se(0),v=XS(),g=Pt(ne(n,De(l,e,f),Tn(tC,v),st()),v),x=Pt(ne(l,st(),Tn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),fe(({prev:C})=>C)),[]);xe(ne(l,Ee(C=>C.length>0),De(g,f),fe(([C,T,E])=>{const j=C.reduce((_,D,F)=>Qt(_,D,vo(D,T.offsetTree,E)||F),Mr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),xe(ne(r,De(g),Ee(([C,{lastIndex:T}])=>C<T),fe(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),xe(c,d);const y=Pt(ne(c,fe(C=>C===void 0)),!0);xe(ne(d,Ee(C=>C!==void 0&&tt(mt(g).sizeTree)),fe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Zt(ne(n,De(g),Tn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),fe(C=>C.changed)));Xe(ne(a,Tn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),fe(C=>C.diff)),C=>{const{groupIndices:T}=mt(g);if(C>0)je(t,!0),je(s,C+dh(C,T));else if(C<0){const E=mt(x);E.length>0&&(C-=dh(-C,E)),je(i,C)}}),Xe(ne(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ht.ERROR)});const S=Zt(s);xe(ne(s,De(g),fe(([C,T])=>{const E=T.groupIndices.length>0,j=[],_=T.lastSize;if(E){const D=go(T.sizeTree,0);let F=0,W=0;for(;F<C;){const A=T.groupIndices[W],Y=T.groupIndices.length===W+1?1/0:T.groupIndices[W+1]-A-1;j.push({endIndex:A,size:D,startIndex:A}),j.push({endIndex:A+1+Y-1,size:_,startIndex:A+1}),W++,F+=Y+1}const G=sr(T.sizeTree);return F!==C&&G.shift(),G.reduce((A,{k:Y,v:q})=>{let B=A.ranges;return A.prevSize!==0&&(B=[...A.ranges,{endIndex:Y+C-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:Y+C,prevSize:q,ranges:B}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((D,{k:F,v:W})=>({prevIndex:F+C,prevSize:W,ranges:[...D.ranges,{endIndex:F+C-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Zt(ne(i,De(g,f),fe(([C,{offsetTree:T},E])=>{const j=-C;return vo(j,T,E)})));return xe(ne(i,De(g,f),fe(([C,T,E])=>{if(T.groupIndices.length>0){if(tt(T.sizeTree))return T;let j=Mr();const _=mt(x);let D=0,F=0,W=0;for(;D<-C;){W=_[F];const G=_[F+1]-W-1;F++,D+=G+1}if(j=sr(T.sizeTree).reduce((G,{k:A,v:Y})=>Qt(G,Math.max(0,A+C),Y),j),D!==-C){const G=go(T.sizeTree,W);j=Qt(j,0,G);const A=fn(T.sizeTree,-C+1)[1];j=Qt(j,1,A)}return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((_,{k:D,v:F})=>Qt(_,Math.max(0,D+C),F),Mr());return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ot(Hn,Oa),{singleton:!0});function iC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const fh=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ue(),i=Ue(),a=Zt(ne(s,fe(iC)));return xe(ne(a,fe(l=>l.totalCount)),n),xe(ne(a,fe(l=>l.groupIndices)),e),xe(ne(vt(o,t,r),Ee(([l,c])=>_s(c)),fe(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(kn,Lt)),Wn=Ge(([{log:e}])=>{const t=se(!1),n=Zt(ne(t,Ee(r=>r),st()));return Xe(t,r=>{r&&mt(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},ot(Hn),{singleton:!0}),aC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function hh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!aC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const bo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:p}])=>{const f=Ue(),v=Ue(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),je(l,!1)}return xe(ne(f,De(n,h,r,g,a,i,p),De(e,s,o),fe(([[k,C,T,E,j,_,D,F],W,G,A])=>{const Y=hh(k),{align:q,behavior:B,offset:R}=Y,I=E-1,U=uh(Y,C,I);let K=vo(U,C.offsetTree,W)+_;q==="end"?(K+=G+fn(C.sizeTree,U)[1]-T+A,U===I&&(K+=D)):q==="center"?K+=(G+fn(C.sizeTree,U)[1]-T+A)/2:K-=j,R&&(K+=R);const P=O=>{S(),O?(F("retrying to scroll to",{location:k},Ht.DEBUG),je(f,k)):(je(v,!0),F("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),B==="smooth"){let O=!1;w=Xe(t,M=>{O=O||M}),x=dn(d,()=>{P(O)})}else x=dn(ne(t,lC(150)),P);return y=setTimeout(()=>{S()},1200),je(l,!0),F("scrolling from index to",{behavior:B,index:U,top:K},Ht.DEBUG),{behavior:B,top:K}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ot(kn,Lt,Hn),{singleton:!0});function lC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function $a(e,t){e==0?t():requestAnimationFrame(()=>{$a(e-1,t)})}function Fa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const wo=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,De(l),Ee(([d,h])=>!!h),Cn(!1)),a),xe(ne(i,De(l),Ee(([d,h])=>!!h),Cn(!1)),c),Xe(ne(vt(t,i),De(a,n,e,c),Ee(([[,d],h,{sizeTree:p},f,v])=>d&&(!tt(p)||Ia(f))&&!h&&!v),De(l)),([,d])=>{dn(o,()=>{je(c,!0)}),$a(4,()=>{dn(r,()=>{je(a,!0)}),je(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(kn,Lt,bo,Wn),{singleton:!0});function ph(e,t){return Math.abs(e-t)<1.01}const yo="up",So="down",cC="none",uC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},dC=0,Co=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),h=se(dC),p=Pt(ne(Aa(ne(ke(o),rr(1),Cn(!0)),ne(ke(o),rr(1),Cn(!1),Jf(100))),st()),!1),f=Pt(ne(Aa(ne(n,Cn(!0)),ne(n,Cn(!1),Jf(200))),st()),!1);xe(ne(vt(ke(o),ke(h)),fe(([w,S])=>w<=S),st()),a),xe(ne(a,_n(50)),c);const v=Zt(ne(vt(r,ke(s),ke(t),ke(e),ke(d)),Tn((w,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const _=k+C-S>-j,D={scrollHeight:S,scrollTop:k,viewportHeight:C};if(_){let W,G;return k>w.state.scrollTop?(W="SCROLLED_DOWN",G=w.state.scrollTop-k):(W="SIZE_DECREASED",G=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:G,state:D}}let F;return D.scrollHeight>w.state.scrollHeight?F="SIZE_INCREASED":C<w.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:D}},uC),st((w,S)=>w&&w.atBottom===S.atBottom))),g=Pt(ne(r,Tn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(ph(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(w=>w.changed),fe(w=>w.jump)),0);xe(ne(v,fe(w=>w.atBottom)),i),xe(ne(i,_n(50)),l);const x=se(So);xe(ne(r,fe(({scrollTop:w})=>w),st(),Tn((w,S)=>mt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?yo:So,prevScrollTop:S},{direction:So,prevScrollTop:0}),fe(w=>w.direction)),x),xe(ne(r,_n(50),Cn(cC)),x);const y=se(0);return xe(ne(p,Ee(w=>!w),Cn(0)),y),xe(ne(o,_n(100),De(p),Ee(([w,S])=>!!S),Tn(([w,S],[k])=>[S,k],[0,0]),fe(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ot(Lt)),Ps="top",Rs="bottom",mh="none";function gh(e,t,n){return typeof e=="number"?n===yo&&t===Ps||n===So&&t===Rs?e:0:n===yo?t===Ps?e.main:e.reverse:t===Rs?e.main:e.reverse}function xh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ba=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ue(),i=se(0),a=se(0),l=se(0),c=Pt(ne(vt(ke(r),ke(o),ke(n),ke(s,xo),ke(l),ke(i),ke(t),ke(e),ke(a)),fe(([d,h,p,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(p-k,0);let E=mh;const j=xh(S,Ps),_=xh(S,Rs);return f-=w,f+=p+y,v+=p+y,v-=w,f>d+C-j&&(E=yo),v<d-T+h+_&&(E=So),E!==mh?[Math.max(k-p-gh(g,Ps,E)-j,0),k-T-y+h+gh(g,Rs,E)+_]:null}),Ee(d=>d!=null),st(xo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ot(Lt),{singleton:!0});function fC(e,t,n){if(_s(t)){const r=ch(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 za={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ms(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 h=n-i,p=a+h*l+(h-1)*r,f=c,v=p-d;return{bottom:d,firstItemIndex:s,items:bh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:bh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function vh(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=Fa(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ms(c,[],a,o,n,r)}function bh(e,t,n){if(e.length===0)return[];if(!_s(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=Ns(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 ir=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},p,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Ue();xe(s.topItemsIndexes,g);const w=Pt(ne(vt(f,v,ke(l,xo),ke(o),ke(r),ke(c),d,ke(g),ke(t),ke(n),e),Ee(([T,E,,j,,,,,,,_])=>{const D=_&&_.length!==j;return T&&!E&&!D}),fe(([,,[T,E],j,_,D,F,W,G,A,Y])=>{const q=_,{offsetTree:B,sizeTree:R}=q,I=mt(x);if(j===0)return{...za,totalCount:j};if(T===0&&E===0)return I===0?{...za,totalCount:j}:vh(I,D,_,G,A,Y||[]);if(tt(R))return I>0?null:Ms(fC(Fa(D,j),q,Y),[],j,A,q,G);const U=[];if(W.length>0){const L=W[0],ee=W[W.length-1];let z=0;for(const $ of Ns(R,L,ee)){const Q=$.value,X=Math.max($.start,L),te=Math.min($.end,ee);for(let J=X;J<=te;J++)U.push({data:Y==null?void 0:Y[J],index:J,offset:z,size:Q}),z+=Q}}if(!F)return Ms([],U,j,A,q,G);const K=W.length>0?W[W.length-1]+1:0,P=eC(B,T,E,K);if(P.length===0)return null;const O=j-1,M=Is([],L=>{for(const ee of P){const z=ee.value;let $=z.offset,Q=ee.start;const X=z.size;if(z.offset<T){Q+=Math.floor((T-z.offset+A)/(X+A));const J=Q-ee.start;$+=J*X+J*A}Q<K&&($+=(K-Q)*X,Q=K);const te=Math.min(ee.end,O);for(let J=Q;J<=te&&!($>=E);J++)L.push({data:Y==null?void 0:Y[J],index:J,offset:$,size:X}),$+=X+A}});return Ms(M,U,j,A,q,G)}),Ee(T=>T!==null),st()),za);xe(ne(e,Ee(Ia),fe(T=>T==null?void 0:T.length)),o),xe(ne(w,fe(T=>T.topListHeight)),h),xe(h,a),xe(ne(w,fe(T=>[T.top,T.bottom])),i),xe(ne(w,fe(T=>T.items)),y);const S=Zt(ne(w,Ee(({items:T})=>T.length>0),De(o,e),Ee(([{items:T},E])=>T[T.length-1].originalIndex===E-1),fe(([,T,E])=>[T-1,E]),st(xo),fe(([T])=>T))),k=Zt(ne(w,_n(200),Ee(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),fe(({items:T})=>T[0].index),st())),C=Zt(ne(w,Ee(({items:T})=>T.length>0),fe(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),st(ah)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...p}},ot(kn,fh,Ba,wo,bo,Co,Wn,Oa),{singleton:!0}),wh=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ue(),i=Pt(ne(vt(n,e,r,t,o),fe(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return xe(ke(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(Lt,ir),{singleton:!0}),hC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Pt(ne(vt(n,e,t),Ee(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),_n(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(Lt,wh),{singleton:!0}),yh=Ge(()=>({context:se(null)})),pC=({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,Sh=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,De(t,l,n,s,o,r,a),De(e),fe(([[h,p,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=pC,done:E,...j}=h,_=uh(h,p,v-1),D=vo(_,p.offsetTree,S)+g+x,F=D+fn(p.sizeTree,_)[1],W=w+x,G=w+f-y,A=T({itemBottom:F,itemTop:D,locationParams:{align:k,behavior:C,...j},viewportBottom:G,viewportTop:W});return A?E&&dn(ne(i,Ee(Y=>!Y),rr(mt(i)?1:2)),E):E&&E(),A}),Ee(h=>h!==null)),c),{scrollIntoView:d}},ot(kn,Lt,bo,ir,Hn),{singleton:!0});function Ch(e){return e?e==="smooth"?"smooth":"auto":!1}const mC=(e,t)=>typeof e=="function"?Ch(e(t)):t&&Ch(e),gC=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:h},{context:p},{scrollIntoView:f}])=>{const v=se(!1),g=Ue();let x=null;function y(C){je(i,{align:"end",behavior:C,index:"LAST"})}Xe(ne(vt(ne(ke(t),rr(1)),l),De(ke(v),s,a,h),fe(([[C,T],E,j,_,D])=>{let F=T&&_,W="auto";return F&&(W=mC(E,j||D),F=F&&!!W),{followOutputBehavior:W,shouldFollow:F,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C)}):x=dn(e,()=>{mt(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C),x=null})});function w(C){const T=dn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(mt(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(T,100)}Xe(ne(vt(ke(v),t,c),Ee(([C,,T])=>C&&T),Tn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),De(v,t)),([,C])=>{mt(a)&&w(C!==!1)}),Xe(g,()=>{w(mt(v)!==!1)}),Xe(vt(ke(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=Ue();return xe(Aa(ne(ke(r),fe(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ne(ke(t))),k),Xe(ne(vt(ne(k,rr(1)),l),De(ke(S),a,h,p),fe(([[C,T],E,j,_,D])=>T&&j&&(E==null?void 0:E({context:D,totalCount:C,scrollingInProgress:_}))),Ee(C=>!!C),_n(0)),C=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("scrolling into view",{}),je(f,C)}):x=dn(e,()=>{mt(d)("scrolling into view",{}),je(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},ot(kn,Co,bo,wo,Wn,Hn,Lt,yh,Sh)),xC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(ne(a,De(s),Ee(([,l])=>l!==0),De(o,r,t,n,e),fe(([[,l],c,d,h,p,f=[]])=>vh(l,c,d,h,p,f))),i),{}),ot(kn,wo,ir,Wn),{singleton:!0}),vC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Xe(ne(e,De(r),Ee(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(ne(n,rr(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{je(t,o)})})}),{initialScrollTop:r}},ot(Wn,Lt,ir),{singleton:!0}),Th=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=Ue(),r=se(!1);return xe(ne(e,De(r,t,n),Ee(([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}),st()),t),Xe(ne(vt(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}},ot(Co),{singleton:!0}),Ha=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ue(),r=Ue(),o=Ue(),s=se(!1),i=se(void 0);return xe(ne(vt(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,De(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(Lt)),bC=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),h=se(null),p=se(null);return xe(a,h),xe(l,p),Xe(ne(c,De(t,r,i,h,p,n)),([f,v,g,x,y,w,S])=>{const k=nC(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),xe(ne(d,Ee(Ia),fe(wC)),o),xe(ne(s,De(d),Ee(([,f])=>f!==void 0),st(),fe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ot(kn,Lt,wo,Wn,Ha));function wC(e){return{align:"start",index:0,offset:e.scrollTop}}const yC=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return xe(ne(t,Ee(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(ir));function kh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const SC=kh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),CC=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:p},{log:f},{recalcInProgress:v}])=>{const g=Zt(ne(l,De(i),Tn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const _=k+T;let D=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(D=_-S,D!==0&&(D+=j))),[D,C,E,_]},[0,[],0,0]),Ee(([y])=>y!==0),De(r,a,n,o,f,v),Ee(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===yo),fe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Ht.DEBUG),y))));function x(y){y>0?(je(t,{behavior:"auto",top:-y}),je(e,0)):(je(e,0),je(t,{behavior:"auto",top:-y}))}return Xe(ne(g,De(e,s)),([y,w,S])=>{S&&SC()?je(e,w-y):x(-y)}),Xe(ne(vt(Pt(s,!1),e,v),Ee(([y,w,S])=>!y&&!S&&w!==0),fe(([y,w])=>w),_n(1)),x),xe(ne(h,fe(y=>({top:-y}))),t),Xe(ne(c,De(p,d),fe(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const j=go(k,0);let _=0,D=0;for(;_<y;){_++,E+=j;let F=w.length===D+1?1/0:w[D+1]-w[D]-1;_+F>y&&(E-=j,F=y-_+1),_+=F,E+=T(F),D++}return E}})),y=>{je(e,y),requestAnimationFrame(()=>{je(t,{top:y}),requestAnimationFrame(()=>{je(e,0),je(v,!1)})})}),{deviation:e}},ot(Lt,Co,ir,kn,Hn,Oa)),TC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ot(Ba,xC,Wn,Th,wh,vC,hC,Ha,Sh,Hn,yh)),Eh=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:p,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},_])=>(xe(k.rangeChanged,_.scrollSeekRangeChanged),xe(ne(_.windowViewportRect,fe(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:p,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,..._,...g,sizes:l,...x}),ot(kn,wo,Lt,bC,gC,ir,bo,CC,yC,fh,TC));function kC(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 Os=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ih(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&&je(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];je(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];je(S,y[w])}x.propsReady&&je(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];je(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=zS(x[t.events[w]]),y),{})}const h=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>Is(US(e),E=>{l(E,S)})),[C]=b.useState(Xf(d,k));Os(()=>{for(const E of i)E in S&&Xe(C[E],S[E]);return()=>{Object.values(C).map(Na)}},[S,C,k]),Os(()=>{l(k,S)}),b.useImperativeHandle(y,Gf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...kC([...r,...o,...i],S),children:w}):w})}),p=x=>{const y=b.useContext(a);return b.useCallback(w=>{je(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Xe(y,S),[y]);return b.useSyncExternalStore(w,()=>mt(y),()=>mt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Xf(mt,y));return Os(()=>Xe(y,k=>{k!==w&&S(Gf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Os(()=>Xe(w,y),[y,w])},useEmitterValue:g,usePublisher:p}}const Nh=b.createContext(void 0),Ah=b.createContext(void 0),jh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ua(e){return"self"in e}function EC(e){return"body"in e}function _h(e,t,n,r=Rr,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(p=>{let f,v,g;const x=p.target;if(EC(x)||Ua(x)){const w=Ua(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};p.suppressFlushSync?y():Mo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const p=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(p){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=p.behavior==="smooth";let g,x,y;Ua(f)?(x=Math.max(Un(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):(x=f[s?"scrollWidth":"scrollHeight"],g=Un(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(p.top=Math.ceil(Math.max(Math.min(w,p.top),0)),ph(g,x)||p.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=p.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(p={behavior:p.behavior,left:p.top}),f.scrollTo(p)}function h(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Wa="-webkit-sticky",Ph="sticky",Va=kh(()=>{if(typeof document>"u")return Ph;const e=document.createElement("div");return e.style.position=Wa,e.style.position===Wa?Wa:Ph});function Ka(e){return e}const IC=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Ka),o=se("div"),s=se(Rr),i=(a,l=null)=>Pt(ne(n,fe(c=>c[a]),st()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),NC=Ge(([e,t])=>({...e,...t}),ot(Eh,IC)),AC=({height:e})=>u.jsx("div",{style:{height:e}}),jC={overflowAnchor:"none",position:Va(),zIndex:1},Rh={overflowAnchor:"none"},_C={...Rh,display:"inline-block",height:"100%"},Mh=b.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=tn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),h=Ne("trackItemSizes"),p=Ne("itemSize"),f=Ne("log"),v=tn("gap"),g=Ne("horizontalDirection"),{callbackRef:x}=KS(n,p,h,e?Rr:a,f,v,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);qa("deviation",A=>{y!==A&&w(A)});const S=Ne("EmptyPlaceholder"),k=Ne("ScrollSeekPlaceholder")||AC,C=Ne("ListComponent"),T=Ne("ItemComponent"),E=Ne("GroupComponent"),j=Ne("computeItemKey"),_=Ne("isSeeking"),D=Ne("groupIndices").length>0,F=Ne("alignToBottom"),W=Ne("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:F?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Rt(S,c)}):u.jsx(C,{...Rt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(A=>{const Y=A.originalIndex,q=j(Y+t.firstItemIndex,A.data,c);return _?b.createElement(k,{...Rt(k,c),height:A.size,index:A.index,key:q,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?b.createElement(E,{...Rt(E,c),"data-index":Y,"data-item-index":A.index,"data-known-size":A.size,key:q,style:jC},d(A.index,c)):b.createElement(T,{...Rt(T,c),...OC(T,A.data),"data-index":Y,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:q,style:g?_C:Rh},D?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),PC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},RC={outline:"none",overflowX:"auto",position:"relative"},Ds=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),MC={position:Va(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function OC(e,t){return{item:typeof e=="string"?void 0:t}}const DC=b.memo(function(){const e=Ne("HeaderComponent"),t=tn("headerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),LC=b.memo(function(){const e=Ne("FooterComponent"),t=tn("footerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null});function Oh({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"),h=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:f,scrollToCallback:v}=_h(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?RC:PC,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Dh({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"),h=t("deviation"),p=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=_h(a,c,l,v,p);return jh(()=>{var w;return x.current=p||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,p]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+h}:{}},...i,...Rt(l,s),children:r})})}const $C=({children:e})=>{const t=b.useContext(Nh),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=b.useMemo(()=>Yf(n,l=>Un(l,s?"width":"height")),[n,s]),a=or(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:Ds(o),children:e})},FC=({children:e})=>{const t=b.useContext(Nh),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Ne("customScrollParent"),s=eh(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:Ds(i),children:e})},BC=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...MC,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},zC=b.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?WC:UC,{...e,context:o,children:[n&&u.jsx(BC,{children:u.jsx(Mh,{showTopList:!0})}),u.jsxs(r||t?FC:$C,{children:[u.jsx(DC,{}),u.jsx(Mh,{}),u.jsx(LC,{})]})]})}),{Component:HC,useEmitter:qa,useEmitterValue:Ne,usePublisher:tn}=Ih(NC,{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"}},zC),UC=Oh({useEmitter:qa,useEmitterValue:Ne,usePublisher:tn}),WC=Dh({useEmitter:qa,useEmitterValue:Ne,usePublisher:tn}),VC=HC;ot(Eh,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(Ka),a=se(Rr),l=(c,d=null)=>Pt(ne(s,fe(h=>h[c]),st()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Va();const Lh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},KC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:$h,floor:Ls,max:To,min:Ga,round:Fh}=Math;function Bh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function qC(e){return{...KC,items:e}}function $s(e,t){return e&&e.width===t.width&&e.height===t.height}function GC(e,t){return e&&e.column===t.column&&e.row===t.row}const YC=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},p,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),j=se(Lh),_=se({height:0,width:0}),D=se({height:0,width:0}),F=Ue(),W=Ue(),G=se(0),A=se(null),Y=se({column:0,row:0}),q=Ue(),B=Ue(),R=se(!1),I=se(0),U=se(!0),K=se(!1),P=se(!1);Xe(ne(v,De(I),Ee(([$,Q])=>!!Q)),()=>{je(U,!1)}),Xe(ne(vt(v,U,D,_,I,K),Ee(([$,Q,X,te,,J])=>$&&!Q&&X.height!==0&&te.height!==0&&!J)),([,,,,$])=>{je(K,!0),$a(1,()=>{je(F,$)}),dn(ne(c),()=>{je(t,[0,0]),je(U,!0)})}),xe(ne(B,Ee($=>$!=null&&$.scrollTop>0),Cn(0)),E),Xe(ne(v,De(B),Ee(([,$])=>$!=null)),([,$])=>{$&&(je(_,$.viewport),je(D,$.item),je(Y,$.gap),$.scrollTop>0&&(je(R,!0),dn(ne(c,rr(1)),Q=>{je(R,!1)}),je(l,{top:$.scrollTop})))}),xe(ne(_,fe(({height:$})=>$)),h),xe(ne(vt(ke(_,$s),ke(D,$s),ke(Y,($,Q)=>$&&$.column===Q.column&&$.row===Q.row),ke(c)),fe(([$,Q,X,te])=>({gap:X,item:Q,scrollTop:te,viewport:$}))),q),xe(ne(vt(ke(T),r,ke(Y,GC),ke(D,$s),ke(_,$s),ke(A),ke(E),ke(R),ke(U),ke(I)),Ee(([,,,,,,,$])=>!$),fe(([$,[Q,X],te,J,ae,ve,de,,me,Ce])=>{const{column:Te,row:_e}=te,{height:dt,width:lt}=J,{width:Be}=ae;if(de===0&&($===0||Be===0))return Lh;if(lt===0){const yt=Fa(Ce,$),St=yt+Math.max(de-1,0);return qC(Bh(yt,St,ve))}const Fe=zh(Be,lt,Te);let Le,Ye;me?Q===0&&X===0&&de>0?(Le=0,Ye=de-1):(Le=Fe*Ls((Q+_e)/(dt+_e)),Ye=Fe*$h((X+_e)/(dt+_e))-1,Ye=Ga($-1,To(Ye,Fe-1)),Le=Ga(Ye,To(0,Le))):(Le=0,Ye=-1);const Re=Bh(Le,Ye,ve),{bottom:$e,top:Qe}=Hh(ae,te,J,Re),It=$h($/Fe),it=It*dt+(It-1)*_e-$e;return{bottom:$e,itemHeight:dt,items:Re,itemWidth:lt,offsetBottom:it,offsetTop:Qe,top:Qe}})),j),xe(ne(A,Ee($=>$!==null),fe($=>$.length)),T),xe(ne(vt(_,D,j,Y),Ee(([$,Q,{items:X}])=>X.length>0&&Q.height!==0&&$.height!==0),fe(([$,Q,{items:X},te])=>{const{bottom:J,top:ae}=Hh($,te,Q,X);return[ae,J]}),st(xo)),t);const O=se(!1);xe(ne(c,De(O),fe(([$,Q])=>Q||$!==0)),O);const M=Zt(ne(vt(j,T),Ee(([{items:$}])=>$.length>0),De(O),Ee(([[$,Q],X])=>{const te=$.items[$.items.length-1].index===Q-1;return(X||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===Q)&&te}),fe(([[,$]])=>$-1),st())),L=Zt(ne(ke(j),Ee(({items:$})=>$.length>0&&$[0].index===0),Cn(0),st())),ee=Zt(ne(ke(j),De(R),Ee(([{items:$},Q])=>$.length>0&&!Q),fe(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),st(ah),_n(0)));xe(ee,f.scrollSeekRangeChanged),xe(ne(F,De(_,D,T,Y),fe(([$,Q,X,te,J])=>{const ae=hh($),{align:ve,behavior:de,offset:me}=ae;let Ce=ae.index;Ce==="LAST"&&(Ce=te-1),Ce=To(0,Ce,Ga(te-1,Ce));let Te=Ya(Q,J,X,Ce);return ve==="end"?Te=Fh(Te-Q.height+X.height):ve==="center"&&(Te=Fh(Te-Q.height/2+X.height/2)),me&&(Te+=me),{behavior:de,top:Te}})),l);const z=Pt(ne(j,fe($=>$.offsetBottom+$.bottom)),0);return xe(ne(k,fe($=>({height:$.visibleHeight,width:$.visibleWidth}))),_),{customScrollParent:x,data:A,deviation:G,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:z,...p,endReached:M,propsReady:g,rangeChanged:ee,startReached:L,stateChanged:q,stateRestoreInProgress:R,...C}},ot(Ba,Lt,Co,Th,Wn,Ha,Hn));function zh(e,t,n){return To(1,Ls((e+n)/(Ls(t)+n)))}function Hh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ya(e,t,n,r[0].index);return{bottom:Ya(e,t,n,r[r.length-1].index)+o,top:s}}function Ya(e,t,n,r){const o=zh(e.width,n.width,t.column),s=Ls(r/o),i=s*n.height+To(0,s-1)*t.row;return i>0?i+t.row:i}const XC=Ge(()=>{const e=se(h=>`Item ${h}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Ka),i=se("div"),a=se(Rr),l=(h,p=null)=>Pt(ne(t,fe(f=>f[h]),st()),p),c=se(!1),d=se(!1);return xe(ke(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")}}),JC=Ge(([e,t])=>({...e,...t}),ot(YC,XC)),ZC=b.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=nn("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),c=at("ScrollSeekPlaceholder"),d=at("context"),h=nn("itemDimensions"),p=nn("gap"),f=at("log"),v=at("stateRestoreInProgress"),g=nn("reportReadyState"),x=or(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}p({column:Wh("column-gap",getComputedStyle(y).columnGap,f),row:Wh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,p,f]),!0,!1);return jh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Rt(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,{...Rt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),QC=b.memo(function(){const e=at("HeaderComponent"),t=nn("headerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),eT=b.memo(function(){const e=at("FooterComponent"),t=nn("footerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),tT=({children:e})=>{const t=b.useContext(Ah),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=or(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:Ds(!1),children:e})},nT=({children:e})=>{const t=b.useContext(Ah),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=at("customScrollParent"),s=eh(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:Ds(!1),children:e})},rT=b.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?sT:oT,o=n||t?nT:tT,s=at("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(QC,{}),u.jsx(ZC,{}),u.jsx(eT,{})]})})}),{useEmitter:Uh,useEmitterValue:at,usePublisher:nn}=Ih(JC,{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"}},rT),oT=Oh({useEmitter:Uh,useEmitterValue:at,usePublisher:nn}),sT=Dh({useEmitter:Uh,useEmitterValue:at,usePublisher:nn});function Wh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}var Fs="Dialog",[Vh,BN]=ln(Fs),[iT,hn]=Vh(Fs),Kh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[c,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Fs});return u.jsx(iT,{scope:t,triggerRef:a,contentRef:l,contentId:_t(),titleId:_t(),descriptionId:_t(),open:c,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Kh.displayName=Fs;var qh="DialogTrigger",Gh=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(qh,n),s=Oe(t,o.triggerRef);return u.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Za(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});Gh.displayName=qh;var Xa="DialogPortal",[aT,Yh]=Vh(Xa,{forceMount:void 0}),Xh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Xa,t);return u.jsx(aT,{scope:t,forceMount:n,children:m.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:i})}))})};Xh.displayName=Xa;var Bs="DialogOverlay",Jh=m.forwardRef((e,t)=>{const n=Yh(Bs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Bs,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(cT,{...o,ref:t})}):null});Jh.displayName=Bs;var lT=qt.createSlot("DialogOverlay.RemoveScroll"),cT=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Bs,n);return u.jsx(vs,{as:lT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ge.div,{"data-state":Za(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Zh=m.forwardRef((e,t)=>{const n=Yh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ar,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(uT,{...o,ref:t}):u.jsx(dT,{...o,ref:t})})});Zh.displayName=ar;var uT=m.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=m.useRef(null),o=Oe(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Qh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),dT=m.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return u.jsx(Qh,{...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()}})}),Qh=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ar,n),l=m.useRef(null),c=Oe(t,l);return Wi(),u.jsxs(u.Fragment,{children:[u.jsx(Qo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Sr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Za(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(fT,{titleId:a.titleId}),u.jsx(pT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ja="DialogTitle",ep=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Ja,n);return u.jsx(ge.h2,{id:o.titleId,...r,ref:t})});ep.displayName=Ja;var tp="DialogDescription",np=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(tp,n);return u.jsx(ge.p,{id:o.descriptionId,...r,ref:t})});np.displayName=tp;var rp="DialogClose",op=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(rp,n);return u.jsx(ge.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});op.displayName=rp;function Za(e){return e?"open":"closed"}var sp="DialogTitleWarning",[zN,ip]=Nb(sp,{contentName:ar,titleName:Ja,docsSlug:"dialog"}),fT=({titleId:e})=>{const t=ip(sp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},p0=0,_r=[];function m0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(p0++)[0],s=p.useState(Hd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Dy([e.lockRef.current],(e.shards||[]).map(Yd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=xs(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Vd(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Vd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return d0(_,x,g,_==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!_r.length||_r[_r.length-1]!==s)){var y="deltaY"in x?Gd(x):xs(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&f0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Yd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:g0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=xs(g),r.current=void 0},[]),f=p.useCallback(function(g){c(g.type,Gd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,xs(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return _r.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,jr),document.addEventListener("touchmove",l,jr),document.addEventListener("touchstart",d,jr),function(){_r=_r.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,jr),document.removeEventListener("touchmove",l,jr),document.removeEventListener("touchstart",d,jr)}},[]);var h=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:h0(o)}):null,h?p.createElement(o0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function g0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const x0=Vy(zd,m0);var vs=p.forwardRef(function(e,t){return p.createElement(ms,Sn({},e,{ref:t,sideCar:x0}))});vs.classNames=ms.classNames;var va=["Enter"," "],v0=["ArrowDown","PageUp","Home"],Xd=["ArrowUp","PageDown","End"],b0=[...v0,...Xd],w0={ltr:[...va,"ArrowRight"],rtl:[...va,"ArrowLeft"]},y0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},lo="Menu",[co,S0,C0]=Jo(lo),[tr,Jd]=ln(lo,[C0,Ir,Pd]),bs=Ir(),Zd=Pd(),[T0,nr]=tr(lo),[k0,uo]=tr(lo),Qd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=bs(t),[l,c]=p.useState(null),d=p.useRef(!1),f=pt(s),m=Zo(o);return p.useEffect(()=>{const h=()=>{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",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ia,{...a,children:u.jsx(T0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(k0,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Qd.displayName=lo;var E0="MenuAnchor",ba=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(aa,{...o,...r,ref:t})});ba.displayName=E0;var wa="MenuPortal",[I0,ef]=tr(wa,{forceMount:void 0}),tf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(wa,t);return u.jsx(I0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:r})})})};tf.displayName=wa;var en="MenuContent",[N0,ya]=tr(en),nf=p.forwardRef((e,t)=>{const n=ef(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=uo(en,e.__scopeMenu);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(A0,{...o,ref:t}):u.jsx(j0,{...o,ref:t})})})})}),A0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu),r=p.useRef(null),o=Oe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Sa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),j0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu);return u.jsx(Sa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),_0=qt.createSlot("MenuContent.ScrollLock"),Sa=p.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:h,disableOutsideScroll:v,...g}=e,x=nr(en,n),y=uo(en,n),w=bs(n),S=Zd(n),k=S0(n),[C,T]=p.useState(null),E=p.useRef(null),j=Oe(t,E,x.onContentChange),_=p.useRef(0),D=p.useRef(""),F=p.useRef(0),W=p.useRef(null),G=p.useRef("right"),A=p.useRef(0),Y=v?vs:p.Fragment,q=v?{as:_0,allowPinchZoom:!0}:void 0,z=I=>{var B,$;const U=D.current+I,K=k().filter(Q=>!Q.disabled),P=document.activeElement,O=(B=K.find(Q=>Q.ref.current===P))==null?void 0:B.textValue,R=K.map(Q=>Q.textValue),L=U0(R,U,O),ee=($=K.find(Q=>Q.textValue===L))==null?void 0:$.ref.current;(function Q(X){D.current=X,window.clearTimeout(_.current),X!==""&&(_.current=window.setTimeout(()=>Q(""),1e3))})(U),ee&&setTimeout(()=>ee.focus())};p.useEffect(()=>()=>window.clearTimeout(_.current),[]),Wi();const M=p.useCallback(I=>{var K,P;return G.current===((K=W.current)==null?void 0:K.side)&&V0(I,(P=W.current)==null?void 0:P.area)},[]);return u.jsx(N0,{scope:n,searchRef:D,onItemEnter:p.useCallback(I=>{M(I)&&I.preventDefault()},[M]),onItemLeave:p.useCallback(I=>{var U;M(I)||((U=E.current)==null||U.focus(),T(null))},[M]),onTriggerLeave:p.useCallback(I=>{M(I)&&I.preventDefault()},[M]),pointerGraceTimerRef:F,onPointerGraceIntentChange:p.useCallback(I=>{W.current=I},[]),children:u.jsx(Y,{...q,children:u.jsx(Qo,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var U;I.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:h,children:u.jsx(_y,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(la,{role:"menu","aria-orientation":"vertical","data-state":wf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const K=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;K&&(I.key==="Tab"&&I.preventDefault(),!P&&O&&z(I.key));const R=E.current;if(I.target!==R||!b0.includes(I.key))return;I.preventDefault();const ee=k().filter(B=>!B.disabled).map(B=>B.ref.current);Xd.includes(I.key)&&ee.reverse(),z0(ee)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),D.current="")}),onPointerMove:ie(e.onPointerMove,ho(I=>{const U=I.target,K=A.current!==I.clientX;if(I.currentTarget.contains(U)&&K){const P=I.clientX>A.current?"right":"left";G.current=P,A.current=I.clientX}}))})})})})})})});nf.displayName=en;var P0="MenuGroup",Ca=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{role:"group",...r,ref:t})});Ca.displayName=P0;var M0="MenuLabel",rf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});rf.displayName=M0;var ws="MenuItem",of="menu.itemSelect",ys=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=uo(ws,e.__scopeMenu),a=ya(ws,e.__scopeMenu),l=Oe(t,s),c=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(of,{bubbles:!0,cancelable:!0});f.addEventListener(of,h=>r==null?void 0:r(h),{once:!0}),zi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(sf,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),c.current=!0},onPointerUp:ie(e.onPointerUp,f=>{var m;c.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||va.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ys.displayName=ws;var sf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ya(ws,n),a=Zd(n),l=p.useRef(null),c=Oe(t,l),[d,f]=p.useState(!1),[m,h]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&h((v.textContent??"").trim())},[s.children]),u.jsx(co.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Py,{asChild:!0,...a,focusable:!r,children:u.jsx(ge.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,ho(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,ho(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>f(!0)),onBlur:ie(e.onBlur,()=>f(!1))})})})}),R0="MenuCheckboxItem",af=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ff,{scope:e.__scopeMenu,checked:n,children:u.jsx(ys,{role:"menuitemcheckbox","aria-checked":Ss(n)?"mixed":n,...o,ref:t,"data-state":ka(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(Ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});af.displayName=R0;var lf="MenuRadioGroup",[O0,D0]=tr(lf,{value:void 0,onValueChange:()=>{}}),cf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(O0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ca,{...o,ref:t})})});cf.displayName=lf;var uf="MenuRadioItem",df=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=D0(uf,e.__scopeMenu),s=n===o.value;return u.jsx(ff,{scope:e.__scopeMenu,checked:s,children:u.jsx(ys,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ka(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});df.displayName=uf;var Ta="MenuItemIndicator",[ff,L0]=tr(Ta,{checked:!1}),hf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=L0(Ta,n);return u.jsx(zt,{present:r||Ss(s.checked)||s.checked===!0,children:u.jsx(ge.span,{...o,ref:t,"data-state":ka(s.checked)})})});hf.displayName=Ta;var $0="MenuSeparator",pf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});pf.displayName=$0;var F0="MenuArrow",mf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ca,{...o,...r,ref:t})});mf.displayName=F0;var B0="MenuSub",[LN,gf]=tr(B0),fo="MenuSubTrigger",xf=p.forwardRef((e,t)=>{const n=nr(fo,e.__scopeMenu),r=uo(fo,e.__scopeMenu),o=gf(fo,e.__scopeMenu),s=ya(fo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(ba,{asChild:!0,...c,children:u.jsx(sf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wf(n.open),...e,ref:On(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:ie(e.onPointerMove,ho(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,ho(f=>{var h,v;d();const m=(h=n.content)==null?void 0:h.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"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,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:ie(e.onKeyDown,f=>{var h;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||w0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});xf.displayName=fo;var vf="MenuSubContent",bf=p.forwardRef((e,t)=>{const n=ef(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=uo(en,e.__scopeMenu),a=gf(vf,e.__scopeMenu),l=p.useRef(null),c=Oe(t,l);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:u.jsx(Sa,{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:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var h;const f=d.currentTarget.contains(d.target),m=y0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});bf.displayName=vf;function wf(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function ka(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function z0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function H0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function U0(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=H0(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 W0(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 V0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return W0(n,t)}function ho(e){return t=>t.pointerType==="mouse"?e(t):void 0}var K0=Qd,q0=ba,G0=tf,Y0=nf,X0=Ca,J0=rf,Z0=ys,Q0=af,eS=cf,tS=df,nS=hf,rS=pf,oS=mf,sS=xf,iS=bf,Cs="DropdownMenu",[aS,$N]=ln(Cs,[Jd]),Dt=Jd(),[lS,yf]=aS(Cs),Sf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=p.useRef(null),[d,f]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:Cs});return u.jsx(lS,{scope:t,triggerId:_t(),triggerRef:c,contentId:_t(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(K0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Sf.displayName=Cs;var Cf="DropdownMenuTrigger",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=yf(Cf,n),i=Dt(n);return u.jsx(q0,{asChild:!0,...i,children:u.jsx(ge.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:On(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Tf.displayName=Cf;var cS="DropdownMenuPortal",kf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(G0,{...r,...n})};kf.displayName=cS;var Ef="DropdownMenuContent",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yf(Ef,n),s=Dt(n),i=p.useRef(!1);return u.jsx(Y0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(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)"}})});If.displayName=Ef;var uS="DropdownMenuGroup",dS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(X0,{...o,...r,ref:t})});dS.displayName=uS;var fS="DropdownMenuLabel",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(J0,{...o,...r,ref:t})});Nf.displayName=fS;var hS="DropdownMenuItem",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Z0,{...o,...r,ref:t})});Af.displayName=hS;var pS="DropdownMenuCheckboxItem",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Q0,{...o,...r,ref:t})});jf.displayName=pS;var mS="DropdownMenuRadioGroup",gS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(eS,{...o,...r,ref:t})});gS.displayName=mS;var xS="DropdownMenuRadioItem",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(tS,{...o,...r,ref:t})});_f.displayName=xS;var vS="DropdownMenuItemIndicator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(nS,{...o,...r,ref:t})});Pf.displayName=vS;var bS="DropdownMenuSeparator",Mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(rS,{...o,...r,ref:t})});Mf.displayName=bS;var wS="DropdownMenuArrow",yS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(oS,{...o,...r,ref:t})});yS.displayName=wS;var SS="DropdownMenuSubTrigger",Rf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(sS,{...o,...r,ref:t})});Rf.displayName=SS;var CS="DropdownMenuSubContent",Of=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(iS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=CS;var TS=Sf,kS=Tf,ES=kf,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf,Hf=Mf,Uf=Rf,Wf=Of;const Ts=TS,ks=kS,IS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Uf,{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(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));IS.displayName=Uf.displayName;const NS=p.forwardRef(({className:e,...t},n)=>u.jsx(Wf,{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}));NS.displayName=Wf.displayName;const po=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(ES,{children:u.jsx(Df,{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})}));po.displayName=Df.displayName;const Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx($f,{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}));Bn.displayName=$f.displayName;const AS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Ff,{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(zf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));AS.displayName=Ff.displayName;const jS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Bf,{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(zf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));jS.displayName=Bf.displayName;const _S=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Lf,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));_S.displayName=Lf.displayName;const PS=p.forwardRef(({className:e,...t},n)=>u.jsx(Hf,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));PS.displayName=Hf.displayName;const Ea=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ea.displayName="Textarea";const MS=1e4;function Vf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=MS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:h=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[w,S]=b.useState(e),k=(y?i:w)??"",[C,T]=b.useTransition(),E=b.useRef(null),j=b.useRef(0),_=b.useRef(null),D=b.useRef("");b.useEffect(()=>{y||(S(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,W]=b.useState(null),G=b.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),A=b.useMemo(()=>g??G,[g,G]),Y=b.useCallback(R=>{const L=A(R);return W(L),x==null||x(L),D.current=R,L},[A,x]),q=b.useCallback(()=>{const R=E.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);b.useEffect(()=>{q()},[q,k]),b.useEffect(()=>{if(!F)return;const R=(k??"").trim();D.current!==R&&Y(R)},[k,F,Y]);const z=b.useCallback((R,{fromUser:L})=>{y||S(R),L&&(a==null||a(R))},[y,a]),M=b.useCallback(async R=>{R&&R.preventDefault();const L=(k??"").trim();if(!L&&!h||Y(L))return;const ee=++j.current;_.current={id:ee,shouldClear:!0},T(()=>{var B,$,Q;try{const X=l(L);X&&typeof X.then=="function"?X.then(()=>{var te,J;((te=_.current)==null?void 0:te.id)===ee&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((J=_.current)==null?void 0:J.id)===ee&&(_.current=null)}).catch(()=>{var te;((te=_.current)==null?void 0:te.id)===ee&&(_.current=null)}):(((B=_.current)==null?void 0:B.id)===ee&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),(($=_.current)==null?void 0:$.id)===ee&&(_.current=null))}catch{((Q=_.current)==null?void 0:Q.id)===ee&&(_.current=null)}})},[k,l,h,y,a,Y]),I=b.useCallback(R=>{const L=R.target.value;z(L,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&Y(L.trim())},[z,Y,F]),U=b.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),M()):R.key==="Escape"&&t&&(R.preventDefault(),c==null||c())},[M,t,c]),O=`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("form",{onSubmit:R=>void M(R),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ea,{ref:E,value:k,onChange:I,onKeyDown:U,placeholder:t?"Edit your message...":n,className:O,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),F&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:F})]}),u.jsx("div",{children:r?u.jsx(Ze,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(Ze,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!h||C,children:u.jsx(le.Send,{size:16})})})]})})}const RS=b.memo(Vf);function Kf({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:h=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[w,S]=b.useState([]),k=b.useRef(null),C=b.useRef(null),[T,E]=b.useState(0),[j,_]=b.useState(0),[D,F]=b.useState(!1),[W,G]=b.useState(null),[A,Y]=b.useState(null),q=b.useCallback(()=>{k.current&&(k.current.value=""),C.current&&(C.current.value=""),E(R=>R+1),_(R=>R+1)},[]),z=b.useCallback(R=>{S(L=>[...L,...R])},[]),M=b.useCallback(R=>{const L=Array.from(R.target.files||[]);z(L),R.target.value=""},[z]),I=b.useCallback(R=>{S(L=>{const ee=L.filter((B,$)=>$!==R);return ee.length===0&&q(),ee})},[q]),U=b.useCallback(async R=>{const L=(R.target.files||[])[0];if(L&&(G(null),Y(null),!!v)){F(!0);try{await v(L),G(`Uploaded ${L.name} - processing through chat stream`)}catch(ee){const B=ee instanceof Error?ee.message:"Failed to upload Excel file";Y(B),g==null||g(B)}finally{F(!1),R.target.value="",q()}}},[v,g,q]),K=b.useMemo(()=>x||w.length>0,[x,w]),P=b.useCallback(async R=>{const L=n(R,w);try{const ee=await L;return w.length>0&&(S([]),q()),ee}catch(ee){throw ee}},[n,q,w]),O=`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":""} ${y?"border-red-400":""} ${f.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||h)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:M,className:"hidden"},T),w.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:w.map((R,L)=>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(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:R.name}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>I(L),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 ${R.name}`,children:u.jsx(le.X,{size:12})})]},L))})]}),h&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"file",accept:".xls,.xlsx,.xlsm",onChange:U,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),W&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:W}),A&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:A})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||h)&&u.jsxs(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Ze,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:f.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(po,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Bn,{onClick:()=>{var R;return(R=k.current)==null?void 0:R.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),h&&u.jsxs(Bn,{onClick:()=>{var R;D||(R=C.current)==null||R.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(RS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:P,onCancelEdit:r,onStop:o,allowEmptySend:K,textareaClassName:O,sendButtonClassName:f.sendButton})})]})]})}const OS=b.memo(Kf),Es=0,zn=1,Pr=2,qf=4;function Gf(e){return()=>e}function DS(e){e()}function Yf(e,t){return n=>e(t(n))}function Xf(e,t){return()=>e(t)}function LS(e,t){return n=>e(t,n)}function Ia(e){return e!==void 0}function $S(...e){return()=>{e.map(DS)}}function Mr(){}function Is(e,t){return t(e),e}function FS(e,t){return t(e)}function ot(...e){return e}function Xe(e,t){return e(zn,t)}function je(e,t){e(Es,t)}function Na(e){e(Pr)}function mt(e){return e(qf)}function xe(e,t){return Xe(e,LS(t,Es))}function dn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function Jf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Zf(e,t){return e===t}function st(e=Zf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Yf(t,e)}function Cn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=BS(...t);return(r,o)=>{switch(r){case Pr:Na(e);return;case zn:return Xe(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(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 BS(...e){return t=>e.reduceRight(FS,t)}function zS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),Mr);case Pr:r(),n=null;return}}}function se(e){let t=e;const n=Ue();return(r,o)=>{switch(r){case Es:t=o;break;case zn:{o(t);break}case qf:return t}return n(r,o)}}function Pt(e,t){return Is(se(t),n=>xe(e,n))}function Ue(){const e=[];return(t,n)=>{switch(t){case Es:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Is(Ue(),t=>xe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:HS(),singleton:n}}const HS=()=>Symbol();function US(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 vt(...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);Xe(s,l=>{n[i]=l,r=r|a,r===o&&je(t,n)})}),function(s,i){switch(s){case Pr:{Na(t);return}case zn:return r===o&&i(n),Xe(t,i)}}}function ke(e,t=Zf){return ne(e,st(t))}function Aa(...e){return function(t,n){switch(t){case Pr:return;case zn:return $S(...e.map(r=>Xe(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const WS={0:"debug",3:"error",1:"log",2:"warn"},VS=()=>typeof globalThis>"u"?window:globalThis,Hn=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=VS().VIRTUOSO_LOG_LEVEL)!=null?o:mt(e);r>=s&&console[WS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return ja(e,t,n).callbackRef}function ja(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 KS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=qS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const h=m.lastElementChild.dataset.viewportType==="window";let v;h&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:h?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:h?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:h?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Qf("column-gap",getComputedStyle(d).columnGap,o):Qf("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ja(c,n,l)}function qS(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},Ht.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 Qf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function eh(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 h=t.getBoundingClientRect(),v=c.top-h.top;m=h.height-Math.max(0,v),f=v+t.scrollTop}else{const h=i.current.ownerDocument.defaultView;m=h.innerHeight-Math.max(0,c.top),f=c.top+h.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ja(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 Lt=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(),h=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:h,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),mo={lvl:0};function th(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 tt(e){return e===mo}function go(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?go(e.l,t):go(e.r,t)}function fn(e,t,n="k"){if(tt(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 tt(e)?oh(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?sh(wt(e,{l:Qt(e.l,t,n)})):sh(wt(e,{r:Qt(e.r,t,n)}))}function Rr(){return mo}function Ns(e,t,n){if(tt(e))return[];const r=fn(e,t)[0];return GS(Pa(e,r,n))}function _a(e,t){if(tt(e))return mo;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=rh(r);return As(wt(e,{k:s,l:nh(r),v:i}))}}else return t<n?As(wt(e,{l:_a(r,t)})):As(wt(e,{r:_a(o,t)}))}function sr(e){return tt(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function Pa(e,t,n){if(tt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Pa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Pa(s,t,n))),a}function As(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(Ma(t))return ih(wt(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ma(e))return Ra(wt(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=Ma(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ra(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return oh(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 nh(e){return tt(e.r)?e.l:As(wt(e,{r:nh(e.r)}))}function Ma(e){return tt(e)||e.lvl>e.r.lvl}function rh(e){return tt(e.r)?[e.k,e.v]:rh(e.r)}function oh(e,t,n,r=mo,o=mo){return{k:e,l:r,lvl:n,r:o,v:t}}function sh(e){return Ra(ih(e))}function ih(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function Ra(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function GS(e){return th(e,({k:t,v:n})=>({index:t,value:n}))}function ah(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function xo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Oa=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function lh(e,t,n){return e[js(e,t,n)]}function js(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 YS(e,t,n,r){const o=js(e,t,r),s=js(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function _s(e){return!tt(e.groupOffsetTree)}function Da({index:e},t){return t===e?0:t<e?-1:1}function XS(){return{groupIndices:[],groupOffsetTree:Rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rr()}}function JS(e,t){let n=tt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),tt(e)){e=Qt(e,0,s);continue}const a=Ns(e,i-1,o+1);if(a.some(oC(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=_a(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 ZS(e){return typeof e.groupIndex<"u"}function QS({offset:e},t){return t===e?0:t<e?-1:1}function vo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=lh(t,e,Da),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function ch(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function uh(e,t,n){if(ZS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=ch(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function eC(e,t,n,r=0){return r>0&&(t=Math.max(t,lh(e,r,Da).offset)),th(YS(e,t,n,QS),rC)}function tC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&tt(s)&&t.length===2){const m=t[0].size,h=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,h),i)}else[i,a]=JS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=La(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,h)=>Qt(m,h,vo(h,f,o)),Rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function nC(e){return sr(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 dh(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 La(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=js(o,t-1,Da),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 Ns(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 rC(e){return{index:e.index,value:e}}function oC(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 sC={offsetHeight:"height",offsetWidth:"width"},kn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=Ue(),r=Ue(),o=Pt(r,0),s=Ue(),i=Ue(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),f=se((C,T)=>Un(C,sC[T])),m=se(void 0),h=se(0),v=XS(),g=Pt(ne(n,De(l,e,h),Tn(tC,v),st()),v),x=Pt(ne(l,st(),Tn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),fe(({prev:C})=>C)),[]);xe(ne(l,Ee(C=>C.length>0),De(g,h),fe(([C,T,E])=>{const j=C.reduce((_,D,F)=>Qt(_,D,vo(D,T.offsetTree,E)||F),Rr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),xe(ne(r,De(g),Ee(([C,{lastIndex:T}])=>C<T),fe(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),xe(c,d);const y=Pt(ne(c,fe(C=>C===void 0)),!0);xe(ne(d,Ee(C=>C!==void 0&&tt(mt(g).sizeTree)),fe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Zt(ne(n,De(g),Tn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),fe(C=>C.changed)));Xe(ne(a,Tn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),fe(C=>C.diff)),C=>{const{groupIndices:T}=mt(g);if(C>0)je(t,!0),je(s,C+dh(C,T));else if(C<0){const E=mt(x);E.length>0&&(C-=dh(-C,E)),je(i,C)}}),Xe(ne(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ht.ERROR)});const S=Zt(s);xe(ne(s,De(g),fe(([C,T])=>{const E=T.groupIndices.length>0,j=[],_=T.lastSize;if(E){const D=go(T.sizeTree,0);let F=0,W=0;for(;F<C;){const A=T.groupIndices[W],Y=T.groupIndices.length===W+1?1/0:T.groupIndices[W+1]-A-1;j.push({endIndex:A,size:D,startIndex:A}),j.push({endIndex:A+1+Y-1,size:_,startIndex:A+1}),W++,F+=Y+1}const G=sr(T.sizeTree);return F!==C&&G.shift(),G.reduce((A,{k:Y,v:q})=>{let z=A.ranges;return A.prevSize!==0&&(z=[...A.ranges,{endIndex:Y+C-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:Y+C,prevSize:q,ranges:z}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((D,{k:F,v:W})=>({prevIndex:F+C,prevSize:W,ranges:[...D.ranges,{endIndex:F+C-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Zt(ne(i,De(g,h),fe(([C,{offsetTree:T},E])=>{const j=-C;return vo(j,T,E)})));return xe(ne(i,De(g,h),fe(([C,T,E])=>{if(T.groupIndices.length>0){if(tt(T.sizeTree))return T;let j=Rr();const _=mt(x);let D=0,F=0,W=0;for(;D<-C;){W=_[F];const G=_[F+1]-W-1;F++,D+=G+1}if(j=sr(T.sizeTree).reduce((G,{k:A,v:Y})=>Qt(G,Math.max(0,A+C),Y),j),D!==-C){const G=go(T.sizeTree,W);j=Qt(j,0,G);const A=fn(T.sizeTree,-C+1)[1];j=Qt(j,1,A)}return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((_,{k:D,v:F})=>Qt(_,Math.max(0,D+C),F),Rr());return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:h,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ot(Hn,Oa),{singleton:!0});function iC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const fh=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ue(),i=Ue(),a=Zt(ne(s,fe(iC)));return xe(ne(a,fe(l=>l.totalCount)),n),xe(ne(a,fe(l=>l.groupIndices)),e),xe(ne(vt(o,t,r),Ee(([l,c])=>_s(c)),fe(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(kn,Lt)),Wn=Ge(([{log:e}])=>{const t=se(!1),n=Zt(ne(t,Ee(r=>r),st()));return Xe(t,r=>{r&&mt(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},ot(Hn),{singleton:!0}),aC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function hh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!aC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const bo=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 h=Ue(),v=Ue(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),je(l,!1)}return xe(ne(h,De(n,f,r,g,a,i,m),De(e,s,o),fe(([[k,C,T,E,j,_,D,F],W,G,A])=>{const Y=hh(k),{align:q,behavior:z,offset:M}=Y,I=E-1,U=uh(Y,C,I);let K=vo(U,C.offsetTree,W)+_;q==="end"?(K+=G+fn(C.sizeTree,U)[1]-T+A,U===I&&(K+=D)):q==="center"?K+=(G+fn(C.sizeTree,U)[1]-T+A)/2:K-=j,M&&(K+=M);const P=O=>{S(),O?(F("retrying to scroll to",{location:k},Ht.DEBUG),je(h,k)):(je(v,!0),F("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),z==="smooth"){let O=!1;w=Xe(t,R=>{O=O||R}),x=dn(d,()=>{P(O)})}else x=dn(ne(t,lC(150)),P);return y=setTimeout(()=>{S()},1200),je(l,!0),F("scrolling from index to",{behavior:z,index:U,top:K},Ht.DEBUG),{behavior:z,top:K}})),c),{scrollTargetReached:v,scrollToIndex:h,topListHeight:g}},ot(kn,Lt,Hn),{singleton:!0});function lC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function $a(e,t){e==0?t():requestAnimationFrame(()=>{$a(e-1,t)})}function Fa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const wo=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,De(l),Ee(([d,f])=>!!f),Cn(!1)),a),xe(ne(i,De(l),Ee(([d,f])=>!!f),Cn(!1)),c),Xe(ne(vt(t,i),De(a,n,e,c),Ee(([[,d],f,{sizeTree:m},h,v])=>d&&(!tt(m)||Ia(h))&&!f&&!v),De(l)),([,d])=>{dn(o,()=>{je(c,!0)}),$a(4,()=>{dn(r,()=>{je(a,!0)}),je(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(kn,Lt,bo,Wn),{singleton:!0});function ph(e,t){return Math.abs(e-t)<1.01}const yo="up",So="down",cC="none",uC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},dC=0,Co=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(dC),m=Pt(ne(Aa(ne(ke(o),rr(1),Cn(!0)),ne(ke(o),rr(1),Cn(!1),Jf(100))),st()),!1),h=Pt(ne(Aa(ne(n,Cn(!0)),ne(n,Cn(!1),Jf(200))),st()),!1);xe(ne(vt(ke(o),ke(f)),fe(([w,S])=>w<=S),st()),a),xe(ne(a,_n(50)),c);const v=Zt(ne(vt(r,ke(s),ke(t),ke(e),ke(d)),Tn((w,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const _=k+C-S>-j,D={scrollHeight:S,scrollTop:k,viewportHeight:C};if(_){let W,G;return k>w.state.scrollTop?(W="SCROLLED_DOWN",G=w.state.scrollTop-k):(W="SIZE_DECREASED",G=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:G,state:D}}let F;return D.scrollHeight>w.state.scrollHeight?F="SIZE_INCREASED":C<w.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:D}},uC),st((w,S)=>w&&w.atBottom===S.atBottom))),g=Pt(ne(r,Tn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(ph(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(w=>w.changed),fe(w=>w.jump)),0);xe(ne(v,fe(w=>w.atBottom)),i),xe(ne(i,_n(50)),l);const x=se(So);xe(ne(r,fe(({scrollTop:w})=>w),st(),Tn((w,S)=>mt(h)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?yo:So,prevScrollTop:S},{direction:So,prevScrollTop:0}),fe(w=>w.direction)),x),xe(ne(r,_n(50),Cn(cC)),x);const y=se(0);return xe(ne(m,Ee(w=>!w),Cn(0)),y),xe(ne(o,_n(100),De(m),Ee(([w,S])=>!!S),Tn(([w,S],[k])=>[S,k],[0,0]),fe(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ot(Lt)),Ps="top",Ms="bottom",mh="none";function gh(e,t,n){return typeof e=="number"?n===yo&&t===Ps||n===So&&t===Ms?e:0:n===yo?t===Ps?e.main:e.reverse:t===Ms?e.main:e.reverse}function xh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ba=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ue(),i=se(0),a=se(0),l=se(0),c=Pt(ne(vt(ke(r),ke(o),ke(n),ke(s,xo),ke(l),ke(i),ke(t),ke(e),ke(a)),fe(([d,f,m,[h,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=mh;const j=xh(S,Ps),_=xh(S,Ms);return h-=w,h+=m+y,v+=m+y,v-=w,h>d+C-j&&(E=yo),v<d-T+f+_&&(E=So),E!==mh?[Math.max(k-m-gh(g,Ps,E)-j,0),k-T-y+f+gh(g,Ms,E)+_]:null}),Ee(d=>d!=null),st(xo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ot(Lt),{singleton:!0});function fC(e,t,n){if(_s(t)){const r=ch(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 za={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Rs(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,h=c,v=m-d;return{bottom:d,firstItemIndex:s,items:bh(e,o,s),offsetBottom:v,offsetTop:c,top:h,topItems:bh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function vh(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=Fa(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Rs(c,[],a,o,n,r)}function bh(e,t,n){if(e.length===0)return[];if(!_s(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=Ns(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 ir=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:h},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Ue();xe(s.topItemsIndexes,g);const w=Pt(ne(vt(h,v,ke(l,xo),ke(o),ke(r),ke(c),d,ke(g),ke(t),ke(n),e),Ee(([T,E,,j,,,,,,,_])=>{const D=_&&_.length!==j;return T&&!E&&!D}),fe(([,,[T,E],j,_,D,F,W,G,A,Y])=>{const q=_,{offsetTree:z,sizeTree:M}=q,I=mt(x);if(j===0)return{...za,totalCount:j};if(T===0&&E===0)return I===0?{...za,totalCount:j}:vh(I,D,_,G,A,Y||[]);if(tt(M))return I>0?null:Rs(fC(Fa(D,j),q,Y),[],j,A,q,G);const U=[];if(W.length>0){const L=W[0],ee=W[W.length-1];let B=0;for(const $ of Ns(M,L,ee)){const Q=$.value,X=Math.max($.start,L),te=Math.min($.end,ee);for(let J=X;J<=te;J++)U.push({data:Y==null?void 0:Y[J],index:J,offset:B,size:Q}),B+=Q}}if(!F)return Rs([],U,j,A,q,G);const K=W.length>0?W[W.length-1]+1:0,P=eC(z,T,E,K);if(P.length===0)return null;const O=j-1,R=Is([],L=>{for(const ee of P){const B=ee.value;let $=B.offset,Q=ee.start;const X=B.size;if(B.offset<T){Q+=Math.floor((T-B.offset+A)/(X+A));const J=Q-ee.start;$+=J*X+J*A}Q<K&&($+=(K-Q)*X,Q=K);const te=Math.min(ee.end,O);for(let J=Q;J<=te&&!($>=E);J++)L.push({data:Y==null?void 0:Y[J],index:J,offset:$,size:X}),$+=X+A}});return Rs(R,U,j,A,q,G)}),Ee(T=>T!==null),st()),za);xe(ne(e,Ee(Ia),fe(T=>T==null?void 0:T.length)),o),xe(ne(w,fe(T=>T.topListHeight)),f),xe(f,a),xe(ne(w,fe(T=>[T.top,T.bottom])),i),xe(ne(w,fe(T=>T.items)),y);const S=Zt(ne(w,Ee(({items:T})=>T.length>0),De(o,e),Ee(([{items:T},E])=>T[T.length-1].originalIndex===E-1),fe(([,T,E])=>[T-1,E]),st(xo),fe(([T])=>T))),k=Zt(ne(w,_n(200),Ee(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),fe(({items:T})=>T[0].index),st())),C=Zt(ne(w,Ee(({items:T})=>T.length>0),fe(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),st(ah)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},ot(kn,fh,Ba,wo,bo,Co,Wn,Oa),{singleton:!0}),wh=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ue(),i=Pt(ne(vt(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return xe(ke(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(Lt,ir),{singleton:!0}),hC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Pt(ne(vt(n,e,t),Ee(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),_n(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(Lt,wh),{singleton:!0}),yh=Ge(()=>({context:se(null)})),pC=({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,Sh=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,De(t,l,n,s,o,r,a),De(e),fe(([[f,m,h,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=pC,done:E,...j}=f,_=uh(f,m,v-1),D=vo(_,m.offsetTree,S)+g+x,F=D+fn(m.sizeTree,_)[1],W=w+x,G=w+h-y,A=T({itemBottom:F,itemTop:D,locationParams:{align:k,behavior:C,...j},viewportBottom:G,viewportTop:W});return A?E&&dn(ne(i,Ee(Y=>!Y),rr(mt(i)?1:2)),E):E&&E(),A}),Ee(f=>f!==null)),c),{scrollIntoView:d}},ot(kn,Lt,bo,ir,Hn),{singleton:!0});function Ch(e){return e?e==="smooth"?"smooth":"auto":!1}const mC=(e,t)=>typeof e=="function"?Ch(e(t)):t&&Ch(e),gC=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:h}])=>{const v=se(!1),g=Ue();let x=null;function y(C){je(i,{align:"end",behavior:C,index:"LAST"})}Xe(ne(vt(ne(ke(t),rr(1)),l),De(ke(v),s,a,f),fe(([[C,T],E,j,_,D])=>{let F=T&&_,W="auto";return F&&(W=mC(E,j||D),F=F&&!!W),{followOutputBehavior:W,shouldFollow:F,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C)}):x=dn(e,()=>{mt(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C),x=null})});function w(C){const T=dn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(mt(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(T,100)}Xe(ne(vt(ke(v),t,c),Ee(([C,,T])=>C&&T),Tn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),De(v,t)),([,C])=>{mt(a)&&w(C!==!1)}),Xe(g,()=>{w(mt(v)!==!1)}),Xe(vt(ke(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=Ue();return xe(Aa(ne(ke(r),fe(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ne(ke(t))),k),Xe(ne(vt(ne(k,rr(1)),l),De(ke(S),a,f,m),fe(([[C,T],E,j,_,D])=>T&&j&&(E==null?void 0:E({context:D,totalCount:C,scrollingInProgress:_}))),Ee(C=>!!C),_n(0)),C=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("scrolling into view",{}),je(h,C)}):x=dn(e,()=>{mt(d)("scrolling into view",{}),je(h,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},ot(kn,Co,bo,wo,Wn,Hn,Lt,yh,Sh)),xC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(ne(a,De(s),Ee(([,l])=>l!==0),De(o,r,t,n,e),fe(([[,l],c,d,f,m,h=[]])=>vh(l,c,d,f,m,h))),i),{}),ot(kn,wo,ir,Wn),{singleton:!0}),vC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Xe(ne(e,De(r),Ee(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(ne(n,rr(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{je(t,o)})})}),{initialScrollTop:r}},ot(Wn,Lt,ir),{singleton:!0}),Th=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=Ue(),r=se(!1);return xe(ne(e,De(r,t,n),Ee(([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}),st()),t),Xe(ne(vt(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}},ot(Co),{singleton:!0}),Ha=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ue(),r=Ue(),o=Ue(),s=se(!1),i=se(void 0);return xe(ne(vt(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,De(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(Lt)),bC=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),Xe(ne(c,De(t,r,i,f,m,n)),([h,v,g,x,y,w,S])=>{const k=nC(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,h({ranges:k,scrollTop:g})}),xe(ne(d,Ee(Ia),fe(wC)),o),xe(ne(s,De(d),Ee(([,h])=>h!==void 0),st(),fe(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:d}},ot(kn,Lt,wo,Wn,Ha));function wC(e){return{align:"start",index:0,offset:e.scrollTop}}const yC=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return xe(ne(t,Ee(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(ir));function kh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const SC=kh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),CC=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:h},{recalcInProgress:v}])=>{const g=Zt(ne(l,De(i),Tn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const _=k+T;let D=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(D=_-S,D!==0&&(D+=j))),[D,C,E,_]},[0,[],0,0]),Ee(([y])=>y!==0),De(r,a,n,o,h,v),Ee(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===yo),fe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Ht.DEBUG),y))));function x(y){y>0?(je(t,{behavior:"auto",top:-y}),je(e,0)):(je(e,0),je(t,{behavior:"auto",top:-y}))}return Xe(ne(g,De(e,s)),([y,w,S])=>{S&&SC()?je(e,w-y):x(-y)}),Xe(ne(vt(Pt(s,!1),e,v),Ee(([y,w,S])=>!y&&!S&&w!==0),fe(([y,w])=>w),_n(1)),x),xe(ne(f,fe(y=>({top:-y}))),t),Xe(ne(c,De(m,d),fe(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const j=go(k,0);let _=0,D=0;for(;_<y;){_++,E+=j;let F=w.length===D+1?1/0:w[D+1]-w[D]-1;_+F>y&&(E-=j,F=y-_+1),_+=F,E+=T(F),D++}return E}})),y=>{je(e,y),requestAnimationFrame(()=>{je(t,{top:y}),requestAnimationFrame(()=>{je(e,0),je(v,!1)})})}),{deviation:e}},ot(Lt,Co,ir,kn,Hn,Oa)),TC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ot(Ba,xC,Wn,Th,wh,vC,hC,Ha,Sh,Hn,yh)),Eh=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:h,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},_])=>(xe(k.rangeChanged,_.scrollSeekRangeChanged),xe(ne(_.windowViewportRect,fe(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:f,...k,..._,...g,sizes:l,...x}),ot(kn,wo,Lt,bC,gC,ir,bo,CC,yC,fh,TC));function kC(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 Os=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ih(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&&je(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];je(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];je(S,y[w])}x.propsReady&&je(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];je(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=zS(x[t.events[w]]),y),{})}const f=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>Is(US(e),E=>{l(E,S)})),[C]=b.useState(Xf(d,k));Os(()=>{for(const E of i)E in S&&Xe(C[E],S[E]);return()=>{Object.values(C).map(Na)}},[S,C,k]),Os(()=>{l(k,S)}),b.useImperativeHandle(y,Gf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...kC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{je(y[x],w)},[y,x])},h=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Xe(y,S),[y]);return b.useSyncExternalStore(w,()=>mt(y),()=>mt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Xf(mt,y));return Os(()=>Xe(y,k=>{k!==w&&S(Gf(k))}),[y,w]),w},g=b.version.startsWith("18")?h:v;return{Component:f,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Os(()=>Xe(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Nh=b.createContext(void 0),Ah=b.createContext(void 0),jh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ua(e){return"self"in e}function EC(e){return"body"in e}function _h(e,t,n,r=Mr,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let h,v,g;const x=m.target;if(EC(x)||Ua(x)){const w=Ua(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,h=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,h=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:h,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Ro.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===h-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 h=i.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ua(h)?(x=Math.max(Un(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),g=s?h.innerWidth:h.innerHeight,y=s?window.scrollX:window.scrollY):(x=h[s?"scrollWidth":"scrollHeight"],g=Un(h,s?"width":"height"),y=h[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),ph(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}),h.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 Wa="-webkit-sticky",Ph="sticky",Va=kh(()=>{if(typeof document>"u")return Ph;const e=document.createElement("div");return e.style.position=Wa,e.style.position===Wa?Wa:Ph});function Ka(e){return e}const IC=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Ka),o=se("div"),s=se(Mr),i=(a,l=null)=>Pt(ne(n,fe(c=>c[a]),st()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),NC=Ge(([e,t])=>({...e,...t}),ot(Eh,IC)),AC=({height:e})=>u.jsx("div",{style:{height:e}}),jC={overflowAnchor:"none",position:Va(),zIndex:1},Mh={overflowAnchor:"none"},_C={...Mh,display:"inline-block",height:"100%"},Rh=b.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=tn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),f=Ne("trackItemSizes"),m=Ne("itemSize"),h=Ne("log"),v=tn("gap"),g=Ne("horizontalDirection"),{callbackRef:x}=KS(n,m,f,e?Mr:a,h,v,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);qa("deviation",A=>{y!==A&&w(A)});const S=Ne("EmptyPlaceholder"),k=Ne("ScrollSeekPlaceholder")||AC,C=Ne("ListComponent"),T=Ne("ItemComponent"),E=Ne("GroupComponent"),j=Ne("computeItemKey"),_=Ne("isSeeking"),D=Ne("groupIndices").length>0,F=Ne("alignToBottom"),W=Ne("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:F?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Mt(S,c)}):u.jsx(C,{...Mt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(A=>{const Y=A.originalIndex,q=j(Y+t.firstItemIndex,A.data,c);return _?b.createElement(k,{...Mt(k,c),height:A.size,index:A.index,key:q,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?b.createElement(E,{...Mt(E,c),"data-index":Y,"data-item-index":A.index,"data-known-size":A.size,key:q,style:jC},d(A.index,c)):b.createElement(T,{...Mt(T,c),...OC(T,A.data),"data-index":Y,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:q,style:g?_C:Mh},D?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),PC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},MC={outline:"none",overflowX:"auto",position:"relative"},Ds=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),RC={position:Va(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function OC(e,t){return{item:typeof e=="string"?void 0:t}}const DC=b.memo(function(){const e=Ne("HeaderComponent"),t=tn("headerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),LC=b.memo(function(){const e=Ne("FooterComponent"),t=tn("footerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function Oh({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:h,scrollToCallback:v}=_h(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:h,style:{...f?MC:PC,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Dh({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"),h=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=_h(a,c,l,v,m);return jh(()=>{var w;return x.current=m||((w=h.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(l,s),children:r})})}const $C=({children:e})=>{const t=b.useContext(Nh),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=b.useMemo(()=>Yf(n,l=>Un(l,s?"width":"height")),[n,s]),a=or(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:Ds(o),children:e})},FC=({children:e})=>{const t=b.useContext(Nh),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Ne("customScrollParent"),s=eh(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:Ds(i),children:e})},BC=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...RC,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},zC=b.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?WC:UC,{...e,context:o,children:[n&&u.jsx(BC,{children:u.jsx(Rh,{showTopList:!0})}),u.jsxs(r||t?FC:$C,{children:[u.jsx(DC,{}),u.jsx(Rh,{}),u.jsx(LC,{})]})]})}),{Component:HC,useEmitter:qa,useEmitterValue:Ne,usePublisher:tn}=Ih(NC,{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"}},zC),UC=Oh({useEmitter:qa,useEmitterValue:Ne,usePublisher:tn}),WC=Dh({useEmitter:qa,useEmitterValue:Ne,usePublisher:tn}),VC=HC;ot(Eh,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(Ka),a=se(Mr),l=(c,d=null)=>Pt(ne(s,fe(f=>f[c]),st()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Va();const Lh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},KC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:$h,floor:Ls,max:To,min:Ga,round:Fh}=Math;function Bh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function qC(e){return{...KC,items:e}}function $s(e,t){return e&&e.width===t.width&&e.height===t.height}function GC(e,t){return e&&e.column===t.column&&e.row===t.row}const YC=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,h,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),j=se(Lh),_=se({height:0,width:0}),D=se({height:0,width:0}),F=Ue(),W=Ue(),G=se(0),A=se(null),Y=se({column:0,row:0}),q=Ue(),z=Ue(),M=se(!1),I=se(0),U=se(!0),K=se(!1),P=se(!1);Xe(ne(v,De(I),Ee(([$,Q])=>!!Q)),()=>{je(U,!1)}),Xe(ne(vt(v,U,D,_,I,K),Ee(([$,Q,X,te,,J])=>$&&!Q&&X.height!==0&&te.height!==0&&!J)),([,,,,$])=>{je(K,!0),$a(1,()=>{je(F,$)}),dn(ne(c),()=>{je(t,[0,0]),je(U,!0)})}),xe(ne(z,Ee($=>$!=null&&$.scrollTop>0),Cn(0)),E),Xe(ne(v,De(z),Ee(([,$])=>$!=null)),([,$])=>{$&&(je(_,$.viewport),je(D,$.item),je(Y,$.gap),$.scrollTop>0&&(je(M,!0),dn(ne(c,rr(1)),Q=>{je(M,!1)}),je(l,{top:$.scrollTop})))}),xe(ne(_,fe(({height:$})=>$)),f),xe(ne(vt(ke(_,$s),ke(D,$s),ke(Y,($,Q)=>$&&$.column===Q.column&&$.row===Q.row),ke(c)),fe(([$,Q,X,te])=>({gap:X,item:Q,scrollTop:te,viewport:$}))),q),xe(ne(vt(ke(T),r,ke(Y,GC),ke(D,$s),ke(_,$s),ke(A),ke(E),ke(M),ke(U),ke(I)),Ee(([,,,,,,,$])=>!$),fe(([$,[Q,X],te,J,ae,ve,de,,me,Ce])=>{const{column:Te,row:_e}=te,{height:dt,width:lt}=J,{width:Be}=ae;if(de===0&&($===0||Be===0))return Lh;if(lt===0){const yt=Fa(Ce,$),St=yt+Math.max(de-1,0);return qC(Bh(yt,St,ve))}const Fe=zh(Be,lt,Te);let Le,Ye;me?Q===0&&X===0&&de>0?(Le=0,Ye=de-1):(Le=Fe*Ls((Q+_e)/(dt+_e)),Ye=Fe*$h((X+_e)/(dt+_e))-1,Ye=Ga($-1,To(Ye,Fe-1)),Le=Ga(Ye,To(0,Le))):(Le=0,Ye=-1);const Me=Bh(Le,Ye,ve),{bottom:$e,top:Qe}=Hh(ae,te,J,Me),It=$h($/Fe),it=It*dt+(It-1)*_e-$e;return{bottom:$e,itemHeight:dt,items:Me,itemWidth:lt,offsetBottom:it,offsetTop:Qe,top:Qe}})),j),xe(ne(A,Ee($=>$!==null),fe($=>$.length)),T),xe(ne(vt(_,D,j,Y),Ee(([$,Q,{items:X}])=>X.length>0&&Q.height!==0&&$.height!==0),fe(([$,Q,{items:X},te])=>{const{bottom:J,top:ae}=Hh($,te,Q,X);return[ae,J]}),st(xo)),t);const O=se(!1);xe(ne(c,De(O),fe(([$,Q])=>Q||$!==0)),O);const R=Zt(ne(vt(j,T),Ee(([{items:$}])=>$.length>0),De(O),Ee(([[$,Q],X])=>{const te=$.items[$.items.length-1].index===Q-1;return(X||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===Q)&&te}),fe(([[,$]])=>$-1),st())),L=Zt(ne(ke(j),Ee(({items:$})=>$.length>0&&$[0].index===0),Cn(0),st())),ee=Zt(ne(ke(j),De(M),Ee(([{items:$},Q])=>$.length>0&&!Q),fe(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),st(ah),_n(0)));xe(ee,h.scrollSeekRangeChanged),xe(ne(F,De(_,D,T,Y),fe(([$,Q,X,te,J])=>{const ae=hh($),{align:ve,behavior:de,offset:me}=ae;let Ce=ae.index;Ce==="LAST"&&(Ce=te-1),Ce=To(0,Ce,Ga(te-1,Ce));let Te=Ya(Q,J,X,Ce);return ve==="end"?Te=Fh(Te-Q.height+X.height):ve==="center"&&(Te=Fh(Te-Q.height/2+X.height/2)),me&&(Te+=me),{behavior:de,top:Te}})),l);const B=Pt(ne(j,fe($=>$.offsetBottom+$.bottom)),0);return xe(ne(k,fe($=>({height:$.visibleHeight,width:$.visibleWidth}))),_),{customScrollParent:x,data:A,deviation:G,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...h,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:B,...m,endReached:R,propsReady:g,rangeChanged:ee,startReached:L,stateChanged:q,stateRestoreInProgress:M,...C}},ot(Ba,Lt,Co,Th,Wn,Ha,Hn));function zh(e,t,n){return To(1,Ls((e+n)/(Ls(t)+n)))}function Hh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ya(e,t,n,r[0].index);return{bottom:Ya(e,t,n,r[r.length-1].index)+o,top:s}}function Ya(e,t,n,r){const o=zh(e.width,n.width,t.column),s=Ls(r/o),i=s*n.height+To(0,s-1)*t.row;return i>0?i+t.row:i}const XC=Ge(()=>{const e=se(f=>`Item ${f}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Ka),i=se("div"),a=se(Mr),l=(f,m=null)=>Pt(ne(t,fe(h=>h[f]),st()),m),c=se(!1),d=se(!1);return xe(ke(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")}}),JC=Ge(([e,t])=>({...e,...t}),ot(YC,XC)),ZC=b.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=nn("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),c=at("ScrollSeekPlaceholder"),d=at("context"),f=nn("itemDimensions"),m=nn("gap"),h=at("log"),v=at("stateRestoreInProgress"),g=nn("reportReadyState"),x=or(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();f({height:k,width:C})}m({column:Wh("column-gap",getComputedStyle(y).columnGap,h),row:Wh("row-gap",getComputedStyle(y).rowGap,h)})},[i,f,m,h]),!0,!1);return jh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Mt(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,{...Mt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),QC=b.memo(function(){const e=at("HeaderComponent"),t=nn("headerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),eT=b.memo(function(){const e=at("FooterComponent"),t=nn("footerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),tT=({children:e})=>{const t=b.useContext(Ah),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=or(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:Ds(!1),children:e})},nT=({children:e})=>{const t=b.useContext(Ah),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=at("customScrollParent"),s=eh(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:Ds(!1),children:e})},rT=b.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?sT:oT,o=n||t?nT:tT,s=at("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(QC,{}),u.jsx(ZC,{}),u.jsx(eT,{})]})})}),{useEmitter:Uh,useEmitterValue:at,usePublisher:nn}=Ih(JC,{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"}},rT),oT=Oh({useEmitter:Uh,useEmitterValue:at,usePublisher:nn}),sT=Dh({useEmitter:Uh,useEmitterValue:at,usePublisher:nn});function Wh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}var Fs="Dialog",[Vh,BN]=ln(Fs),[iT,hn]=Vh(Fs),Kh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Fs});return u.jsx(iT,{scope:t,triggerRef:a,contentRef:l,contentId:_t(),titleId:_t(),descriptionId:_t(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Kh.displayName=Fs;var qh="DialogTrigger",Gh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(qh,n),s=Oe(t,o.triggerRef);return u.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Za(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});Gh.displayName=qh;var Xa="DialogPortal",[aT,Yh]=Vh(Xa,{forceMount:void 0}),Xh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Xa,t);return u.jsx(aT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:i})}))})};Xh.displayName=Xa;var Bs="DialogOverlay",Jh=p.forwardRef((e,t)=>{const n=Yh(Bs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Bs,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(cT,{...o,ref:t})}):null});Jh.displayName=Bs;var lT=qt.createSlot("DialogOverlay.RemoveScroll"),cT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Bs,n);return u.jsx(vs,{as:lT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ge.div,{"data-state":Za(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Zh=p.forwardRef((e,t)=>{const n=Yh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ar,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(uT,{...o,ref:t}):u.jsx(dT,{...o,ref:t})})});Zh.displayName=ar;var uT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(null),o=Oe(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Qh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),dT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Qh,{...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()}})}),Qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ar,n),l=p.useRef(null),c=Oe(t,l);return Wi(),u.jsxs(u.Fragment,{children:[u.jsx(Qo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Sr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Za(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(fT,{titleId:a.titleId}),u.jsx(pT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ja="DialogTitle",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Ja,n);return u.jsx(ge.h2,{id:o.titleId,...r,ref:t})});ep.displayName=Ja;var tp="DialogDescription",np=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(tp,n);return u.jsx(ge.p,{id:o.descriptionId,...r,ref:t})});np.displayName=tp;var rp="DialogClose",op=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(rp,n);return u.jsx(ge.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});op.displayName=rp;function Za(e){return e?"open":"closed"}var sp="DialogTitleWarning",[zN,ip]=Nb(sp,{contentName:ar,titleName:Ja,docsSlug:"dialog"}),fT=({titleId:e})=>{const t=ip(sp),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 m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hT="DialogDescriptionWarning",pT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ip(hT).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Qa=Kh,mT=Gh,el=Xh,ko=Jh,Eo=Zh,lr=ep,zs=np,ap=op;const tl=Qa,gT=el,lp=m.forwardRef(({className:e,...t},n)=>u.jsx(ko,{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}));lp.displayName=ko.displayName;const Hs=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.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(gT,{children:[u.jsx(lp,{}),u.jsxs(Eo,{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(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(ap,{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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Hs.displayName=Eo.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 Ws=m.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));Ws.displayName=lr.displayName;const xT=m.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));xT.displayName=zs.displayName;const vT=1,bT=1e6;let nl=0;function wT(){return nl=(nl+1)%Number.MAX_SAFE_INTEGER,nl.toString()}const rl=new Map,cp=e=>{if(rl.has(e))return;const t=setTimeout(()=>{rl.delete(e),Io({type:"REMOVE_TOAST",toastId:e})},bT);rl.set(e,t)},yT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,vT)};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?cp(n):e.toasts.forEach(r=>{cp(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)}}},Vs=[];let Ks={toasts:[]};function Io(e){Ks=yT(Ks,e),Vs.forEach(t=>{t(Ks)})}function ST({...e}){const t=wT(),n=o=>Io({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Io({type:"DISMISS_TOAST",toastId:t});return Io({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ol(){const[e,t]=m.useState(Ks);return m.useEffect(()=>(Vs.push(t),()=>{const n=Vs.indexOf(t);n>-1&&Vs.splice(n,1)}),[e]),{...e,toast:ST,dismiss:n=>Io({type:"DISMISS_TOAST",toastId:n})}}function up({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:h}=ol(),p=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Mi(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&p()},[e,n,p]);const f=async()=>{if(n)try{await tu(n),h({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),h({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Mi(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),h({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(le.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?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(Ze,{onClick:p,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="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})}):o.startsWith("text/")||o.includes("json")||o.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(le.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."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(le.Image,{className:"h-5 w-5"}):u.jsx(le.FileText,{className:"h-5 w-5"});return u.jsx(tl,{open:e,onOpenChange:t,children:u.jsxs(Hs,{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:[x(),u.jsxs("div",{children:[u.jsx(Ws,{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(Ze,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Ze,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(le.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function dp(){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 cr=dp();function CT(e){cr=e}const fp=/[&<>"']/,TT=new RegExp(fp.source,"g"),hp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,kT=new RegExp(hp.source,"g"),ET={"&":"&","<":"<",">":">",'"':""","'":"'"},pp=e=>ET[e];function Mt(e,t){if(t){if(fp.test(e))return e.replace(TT,pp)}else if(hp.test(e))return e.replace(kT,pp);return e}const IT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function mp(e){return e.replace(IT,(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 NT=/(^|[^\[])\^/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(NT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const AT=/[^\w:]/g,jT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function gp(e,t,n){if(e){let r;try{r=decodeURIComponent(mp(n)).replace(AT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!jT.test(n)&&(n=MT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const qs={},_T=/^[^:]+:\/*[^/]*$/,PT=/^([^:]+:)[\s\S]*$/,RT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function MT(e,t){qs[" "+e]||(_T.test(e)?qs[" "+e]=e+"/":qs[" "+e]=Ys(e,"/",!0)),e=qs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(PT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(RT,"$1")+t:e+t}const Gs={exec:function(){}};function xp(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 Ys(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 OT(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 DT(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 vp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function bp(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 LT(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 p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hT="DialogDescriptionWarning",pT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ip(hT).contentName}}.`;return p.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},Qa=Kh,mT=Gh,el=Xh,ko=Jh,Eo=Zh,lr=ep,zs=np,ap=op;const tl=Qa,gT=el,lp=p.forwardRef(({className:e,...t},n)=>u.jsx(ko,{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}));lp.displayName=ko.displayName;const Hs=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.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(gT,{children:[u.jsx(lp,{}),u.jsxs(Eo,{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(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(ap,{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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Hs.displayName=Eo.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 Ws=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));Ws.displayName=lr.displayName;const xT=p.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));xT.displayName=zs.displayName;const vT=1,bT=1e6;let nl=0;function wT(){return nl=(nl+1)%Number.MAX_SAFE_INTEGER,nl.toString()}const rl=new Map,cp=e=>{if(rl.has(e))return;const t=setTimeout(()=>{rl.delete(e),Io({type:"REMOVE_TOAST",toastId:e})},bT);rl.set(e,t)},yT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,vT)};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?cp(n):e.toasts.forEach(r=>{cp(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)}}},Vs=[];let Ks={toasts:[]};function Io(e){Ks=yT(Ks,e),Vs.forEach(t=>{t(Ks)})}function ST({...e}){const t=wT(),n=o=>Io({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Io({type:"DISMISS_TOAST",toastId:t});return Io({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ol(){const[e,t]=p.useState(Ks);return p.useEffect(()=>(Vs.push(t),()=>{const n=Vs.indexOf(t);n>-1&&Vs.splice(n,1)}),[e]),{...e,toast:ST,dismiss:n=>Io({type:"DISMISS_TOAST",toastId:n})}}function up({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}=ol(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Ri(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&m()},[e,n,m]);const h=async()=>{if(n)try{await tu(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Ri(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(le.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?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(Ze,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="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})}):o.startsWith("text/")||o.includes("json")||o.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(le.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."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(le.Image,{className:"h-5 w-5"}):u.jsx(le.FileText,{className:"h-5 w-5"});return u.jsx(tl,{open:e,onOpenChange:t,children:u.jsxs(Hs,{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:[x(),u.jsxs("div",{children:[u.jsx(Ws,{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(Ze,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Ze,{variant:"outline",size:"sm",onClick:h,className:"flex items-center gap-2",children:[u.jsx(le.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function dp(){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 cr=dp();function CT(e){cr=e}const fp=/[&<>"']/,TT=new RegExp(fp.source,"g"),hp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,kT=new RegExp(hp.source,"g"),ET={"&":"&","<":"<",">":">",'"':""","'":"'"},pp=e=>ET[e];function Rt(e,t){if(t){if(fp.test(e))return e.replace(TT,pp)}else if(hp.test(e))return e.replace(kT,pp);return e}const IT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function mp(e){return e.replace(IT,(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 NT=/(^|[^\[])\^/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(NT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const AT=/[^\w:]/g,jT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function gp(e,t,n){if(e){let r;try{r=decodeURIComponent(mp(n)).replace(AT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!jT.test(n)&&(n=RT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const qs={},_T=/^[^:]+:\/*[^/]*$/,PT=/^([^:]+:)[\s\S]*$/,MT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function RT(e,t){qs[" "+e]||(_T.test(e)?qs[" "+e]=e+"/":qs[" "+e]=Ys(e,"/",!0)),e=qs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(PT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(MT,"$1")+t:e+t}const Gs={exec:function(){}};function xp(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 Ys(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 OT(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 DT(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 vp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function bp(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 LT(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 sl{constructor(t){this.options=t||cr}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:Ys(r,`
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=LT(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=Ys(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,
|
|
87
|
-
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),
|
|
88
|
-
`,1)[0],this.options.pedantic?(i=2,
|
|
89
|
-
`,t=t.substring(
|
|
90
|
-
`,1)[0],
|
|
91
|
-
`+
|
|
92
|
-
`+
|
|
93
|
-
`,t=t.substring(
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=LT(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=Ys(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,f,m,h,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const w=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!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+/,k=>" ".repeat(3*k.length)),f=t.split(`
|
|
88
|
+
`,1)[0],this.options.pedantic?(i=2,h=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,h=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
89
|
+
`,t=t.substring(f.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
90
|
+
`,1)[0],f=m,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||E.test(f)||k.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())h+=`
|
|
91
|
+
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||C.test(d))break;h+=`
|
|
92
|
+
`+f}!l&&!f.trim()&&(l=!0),r+=m+`
|
|
93
|
+
`,t=t.substring(m.length+1),d=f.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(h),o&&(s=o[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:h}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=h.trimRight(),y.raw=y.raw.trimRight();const S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;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]):Rt(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:xp(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
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]=xp(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:
|
|
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:Rt(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]):Rt(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=Ys(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=OT(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)),bp(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 bp(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const h=m.slice(2,-2);return{type:"strong",raw:m,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Rt(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=Rt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Rt(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=Rt(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=Rt(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]):Rt(r[0]):r[0]:o=Rt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Gs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=nt(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=nt(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=nt(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=nt(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=nt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.blockquote=nt(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=nt(Se.gfm.table).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.gfm.paragraph=nt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:nt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Gs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:nt(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
|
|
96
96
|
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Gs,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:Gs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=nt(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=nt(Se._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=nt(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=nt(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=nt(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=nt(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=nt(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=nt(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=nt(he.reflink).replace("label",he._label).replace("ref",Se._label).getRegex(),he.nolink=nt(he.nolink).replace("ref",Se._label).getRegex(),he.reflinkSearch=nt(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.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",he._label).getRegex(),reflink:nt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:nt(he.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=nt(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:nt(he.br).replace("{2,}","*").getRegex(),text:nt(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function $T(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 wp(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 Vn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||cr,this.options.tokenizer=this.options.tokenizer||new sl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Se.normal,inline:he.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:he}}static lex(t,n){return new Vn(n).lex(t)}static lexInline(t,n){return new Vn(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+=`
|
|
@@ -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)+"["+vp("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)+"["+vp("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,wp)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,wp))){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
|
|
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)+"["+vp("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)+"["+vp("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,wp)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,wp))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let m;this.options.extensions.startInline.forEach(function(h){m=h.call({lexer:this},f),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,$T)){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 il{constructor(t){this.options=t||cr}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+Rt(o)+'">'+(r?t:Rt(t,!0))+`</code></pre>
|
|
108
|
+
`:"<pre><code>"+(r?t:Rt(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,9 +123,9 @@ ${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=gp(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=gp(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 yp{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 Sp{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 Kn{constructor(t){this.options=t||cr,this.options.renderer=this.options.renderer||new il,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new yp,this.slugger=new Sp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,
|
|
127
|
-
`+(
|
|
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 Cp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=FT(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(DT(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(h){return i(h)}const c=function(h){let p;if(!h)try{r.walkTokens&&we.walkTokens(l,r.walkTokens),p=t(l,r),r.hooks&&(p=r.hooks.postprocess(p))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,p)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;we.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(p,f){if(p)return c(p);f!=null&&f!==h.text&&(h.text=f,h.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(we.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&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return Cp(Vn.lex,Kn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},CT(we.defaults),we},we.getDefaults=dp,we.defaults=cr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.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=we.defaults.renderer||new il;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=we.defaults.tokenizer||new sl;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=we.defaults.hooks||new Xs;for(const s in n.hooks){const i=o[s];Xs.passThroughHooks.has(s)?o[s]=a=>{if(we.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=we.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}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=Cp(Vn.lexInline,Kn.parseInline),we.Parser=Kn,we.parser=Kn.parse,we.Renderer=il,we.TextRenderer=yp,we.Lexer=Vn,we.lexer=Vn.lex,we.Tokenizer=sl,we.Slugger=Sp,we.Hooks=Xs,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,Kn.parse,Vn.lex;function qn({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 we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(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 Tp({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})}})})]})}const kp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},BT=e=>{if(!e)return kp.processing;const t=e.toLowerCase().trim();return kp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},zT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Ep({artifact:e}){const t=BT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(le.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:zT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(qn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(le.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Ip({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>cb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Ep,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Tp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const al=m.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));al.displayName="Card";const ll=m.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));ll.displayName="CardHeader";const cl=m.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));cl.displayName="CardTitle";const ul=m.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));ul.displayName="CardDescription";const dl=m.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));dl.displayName="CardContent";const Np=m.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));Np.displayName="CardFooter";function Ap({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(al,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ll,{className:"pb-3",children:[u.jsx(cl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ul,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(dl,{className:"pt-0 pb-3",children:a}),u.jsx(Np,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Ze,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Ze,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const HT="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 Js({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:HT,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:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function jp({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(le.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}function _p({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Pp({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(qn,{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(Ze,{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(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}const Rp={desirability:"from-[#ffd6e6] to-[#ffb7cf]",feasibility:"from-[#fff6ca] to-[#ffe58f]",viability:"from-[#d5f2cf] to-[#b3e7b4]",other:"from-[#dfe7ff] to-[#c4d6ff]"};function fl(e){return(e.type??"other").toLowerCase()}function UT({issues:e}){if(!e.length)return null;const t=b.useMemo(()=>{const n={};return e.forEach(r=>{const o=fl(r).toUpperCase();n[o]||(n[o]=[]),n[o].push(r)}),n},[e]);return u.jsxs("div",{className:"rounded-3xl border border-muted-foreground/30 bg-background/80 p-4 shadow-lg shadow-slate-900/5",children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-muted-foreground/20 pb-2",children:[u.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Issue Sticky Notes"}),u.jsxs("div",{className:"text-xs font-semibold text-muted-foreground",children:[e.length," total"]})]}),u.jsx("div",{className:"mt-4 flex w-full flex-col gap-6",children:Object.entries(t).map(([n,r])=>u.jsxs("details",{className:"w-full rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsxs("summary",{className:"cursor-pointer text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:[n," (",r.length,")"]}),u.jsx("div",{className:"mt-3 space-y-3",children:r.map((o,s)=>{const i=o.title||o.name||`Issue ${s+1}`,a=Rp[fl(o)]?fl(o):"other";return u.jsxs("div",{className:`relative overflow-hidden rounded-2xl border border-muted-foreground/30 bg-gradient-to-br p-4 text-sm font-medium text-foreground/90 shadow-[0_20px_30px_rgba(15,23,42,0.15)] ${Rp[a]}`,children:[u.jsx("div",{className:"text-base font-semibold text-foreground",children:i}),o.description?u.jsxs("details",{className:"mt-2 rounded-xl border border-border/40 bg-background/60 p-2 text-[12px] text-foreground/80",children:[u.jsx("summary",{className:"cursor-pointer font-semibold uppercase tracking-[0.3em] text-foreground/80",children:"View description"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-foreground/80",children:o.description})]}):null]},o.id??`${n}-${s}`)})})]},n))})]})}function Mp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ol(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=b.useCallback(f=>{a(f),c(!0)},[]),p=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await nu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:p,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Op(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:rb(r),toolMeta:Di(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:ob(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Dp="data:";function WT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Dp))continue;const s=o.slice(Dp.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qr(s);i&&typeof i=="object"&&t.push(i)}return t}function VT(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!="object")return null;const t=e.issues;if(Array.isArray(t))return t;if(t&&typeof t=="object"){const n=t.issues;if(Array.isArray(n))return n}return null}function KT(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 qT(e){return b.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>WT(c.text??""));if(!r.length){const c=t.map(h=>h.text??"").join(`
|
|
129
|
-
`),d=Qr(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=KT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=br(i),l=VT(a);return l&&l.length?{kind:"issues",value:a,issues:l,event:s}:a&&typeof a=="object"&&!Array.isArray(a)?{kind:"dict",value:a,data:a,event:s}:{kind:"generic",value:a,event:s}},[e])}function Lp({message:e,viewMode:t,isStreaming:n=!1}){
|
|
130
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[M]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ee,g[M]?" (processing)":""]})]},M)}if(O.type==="interrupt"){const L=O,ee=Xo((L==null?void 0:L.id)??(L==null?void 0:L.interrupt_id)),z=!!(_&&ee&&ee===_),$=z?D??(L==null?void 0:L.value):L==null?void 0:L.value,Q=ee?{...L,id:ee,interrupt_id:ee}:L;return u.jsx(Ap,{interruptPart:Q,onApprove:x,onReject:y,disabled:w,isActive:z,payload:$},M)}return null},[_,D,w,v,x,y,j,T,S,k,g,C,p,E]),P=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return W();if(!t&&!P&&!d)return null;if(t)return n?u.jsx(Lp,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!f){const O=u.jsx("div",{className:"space-y-2",children:U.map((M,L)=>p&&ZT(M)?R?u.jsx("div",{className:"space-y-2",children:R},`streaming-md-${L}`):null:u.jsx(K,{part:M,i:L},L))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[O,u.jsx(_p,{className:F})]}):O}return null}function $p(e){return e?!(No(e,/```/g)||No(e,/`/g)||No(e,/\*\*/g)||No(e,/__/g)||No(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function No(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function JT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if($p(e.slice(0,t)))return t;return 0}function ZT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const QT=Hr.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 Fp({className:e,variant:t,...n}){return u.jsx("div",{className:oe(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:h,toolViewMode:p,toolMeta:f,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:oe("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Fp,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":p==="expanded",onClick:v,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),p==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(le.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:oe("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Ze,{variant:"ghost",size:"sm",onClick:g,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:oe(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:x,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Zs=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:h=!0,customStyles:p={},streamingDebounceMs:f=300,renderStreamingMarkdown:v=!1,enableStreamingMarkdownBuffer:g,onEdit:x,onRegenerate:y,onCopy:w,activeInterrupt:S,disableInterruptActions:k=!1,onInterruptActionStart:C,onInterruptActionEnd:T,attemptCount:E=1,attemptIndex:j=0,onSelectCheckpoint:_,attemptMetas:D=[]}){const[F,W]=b.useState(!1),[G,A]=b.useState("preview"),[Y,q]=b.useState(!1),{currentThreadId:B}=xr(),{respondToInterrupt:R}=to(),I=l==="phone"||l==="half-screen",U=t.role,K=U==="tool",P=b.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!P,M=!(r&&U!=="user"),{uploadingFiles:L,handleFileClick:ee,fileViewerOpen:z,currentFileInfo:$,closeFileViewer:Q}=Mp({allowFileOpen:M,currentThreadId:B}),X=b.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[U]),te=Op(t,P),{contentParts:J,imageParts:ae,fileParts:ve,interruptParts:de,textContent:me,toolMeta:Ce,toolRaw:Te,isToolStreaming:_e}=te,dt=g??f!==0,lt=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),Be=Xo(lt),Fe=S==null?void 0:S.value,Le=b.useCallback(async()=>{const Z=K?Te:me;async function ue(We){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(We);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const be=new Blob([We],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":be})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ue(Z),W(!0),setTimeout(()=>W(!1),2e3),w==null||w(Z)}catch(We){console.error("Failed to copy:",We)}},[K,Te,me,w]),Ye=b.useCallback(()=>{if(!x||!t.id)return;const Z=(K?Te:me)??"",ue="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,Z,ue)},[x,t.id,K,Te,me,t]),Re=b.useCallback(()=>{y==null||y(n)},[y,n]),$e=b.useCallback(()=>{A(Z=>Z==="expanded"?"preview":"expanded")},[]),Qe=b.useCallback(()=>{const ue=oe(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",X);switch(U){case"user":return u.jsx(le.User,{className:ue});case"assistant":return u.jsx(le.Bot,{className:ue});case"tool":return u.jsx(le.Wrench,{className:ue});default:return u.jsx(le.Bot,{className:ue})}},[I,X,U]),It=b.useCallback(()=>{const Z="group relative mb-4 flex w-full";switch(U){case"user":return oe(Z,"justify-end");case"assistant":case"tool":case"system":return oe(Z,"justify-start");default:return Z}},[U]),it=b.useCallback(()=>{const Z=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(O)return oe(Z,"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(U){case"user":return oe(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return oe(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return oe(Z,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(Z,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[I,O,U]),yt=b.useCallback(async Z=>{if(k)return;const ue=Xo((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ue){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await R(ue,!0)}catch(We){console.error("Failed to approve interrupt:",We)}finally{T==null||T()}},[k,T,C,R]),St=b.useCallback(async Z=>{if(k)return;const ue=Xo((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ue){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await R(ue,!1)}catch(We){console.error("Failed to reject interrupt:",We)}finally{T==null||T()}},[k,T,C,R]),Ct=u.jsx(XT,{message:t,isToolMessage:K,showToolMessages:h,toolViewMode:G,isToolStreaming:_e,contentParts:J,textContent:me,imageParts:ae,fileParts:ve,interruptParts:de,isStreamingMessage:r,defaultMessage:P,enableStreamingMarkdownBuffer:dt,renderStreamingMarkdown:v,handleFileClick:ee,uploadingFiles:L,handleInterruptApprove:yt,handleInterruptReject:St,disableInterruptActions:k,messageRole:U,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:Y,setIsUserExpanded:q,isCompactLayout:I,activeInterruptId:Be,activeInterruptValue:Fe,iconForeground:X}),kt=b.useMemo(()=>P?"Assistant":sb(t),[P,t]),on=Qe(),Nt=U==="user"&&(E??1)>1&&typeof _=="function",Vt=(D==null?void 0:D.length)??0,Et=Vt>0&&j<Vt-1?D[j+1]:void 0,ze=Vt>0&&j>0?D[j-1]:void 0,Ke=b.useCallback(()=>{!Et||!_||_(Et.id,void 0,!!Et.isLatestAttempt)},[Et,_]),At=b.useCallback(()=>{!ze||!_||_(ze.id,void 0,!!ze.isLatestAttempt)},[ze,_]);return K&&!h?null:O&&P?u.jsx("div",{className:oe(It(),p.container),children:u.jsxs("div",{className:oe(it(),p.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:oe("h-4 w-4",X)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(qn,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(It(),p.container),children:u.jsxs("div",{className:oe(it(),p.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:K,iconForeground:X,agentName:kt,messageIcon:on,customHeaderClass:p.header,customActionsClass:p.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:U,toolViewMode:G,toolMeta:Ce,onToggleToolView:$e,onCopy:Le,onEdit:Ye,onRegenerate:Re,showCheckpointControls:Nt,attemptCount:E,attemptIndex:j,handleOlderAttemptSelect:Ke,handleNewerAttemptSelect:At,messageCreatedAt:t.createdAt,copied:F}),u.jsx("div",{className:"relative",children:Ct}),K&&G==="expanded"&&(Ce.toolCallId||Ce.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[Ce.name&&u.jsxs("div",{children:["Function: ",Ce.name]}),Ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ce.toolCallId]})]}),!(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(Ze,{variant:"ghost",size:"sm",onClick:()=>Le(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Copy,{className:oe(F?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="user"&&x&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:Ye,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Edit,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&y&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:Re,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),$&&u.jsx(up,{isOpen:z,onClose:Q,fileId:$.id,fileName:$.name,mimeType:$.mimeType})]})},(e,t)=>{var l,c,d,h,p,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&xu(e.message)===xu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].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)===((h=t.customStyles)==null?void 0:h.content)&&((p=e.customStyles)==null?void 0:p.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=vu(e.message),a=vu(t.message);return i.length===a.length});Zs.displayName="MessageComponent";const ml=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:h,style:p,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_,createSyntheticThinkingMessage:D=!0,forceSyntheticThinking:F=!1},W)=>{const G=b.useRef(null),A=b.useRef(null),Y=b.useRef(!1),q=b.useRef(!1),B=b.useMemo(()=>w?e.some(X=>X.role==="default_message"?!1:Array.isArray(X==null?void 0:X.content)&&X.content.some(te=>te&&te.type==="interrupt"&&(te.id??te.interrupt_id)===w.id)):!1,[w,e]),R=b.useMemo(()=>{if(!w||B)return null;const X=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let te;const J=w.value;if(J&&typeof J=="object"&&!Array.isArray(J)){const ae=J.title;typeof ae=="string"&&ae.trim()&&(te=ae.trim())}return{id:`interrupt-${X}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:X,value:J,title:te}]}},[w,B]),I=b.useMemo(()=>R?[...e,R]:e,[e,R]),U=b.useMemo(()=>{const X=n&&I.some(J=>J.id===n);return D&&(t||F)&&!X&&I.length>0?[...I,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:I},[I,t,n,D,F]),K=b.useMemo(()=>T?U:U.filter(X=>(X==null?void 0:X.role)!=="tool"),[U,T]),P=b.useCallback(X=>{x&&x(!X),y&&y(X)},[x,y]),O=b.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),M=b.useMemo(()=>!v||g?!1:"auto",[v,g]),L=b.useMemo(()=>{if(typeof f!="string")return null;const X=f.trim();return!X||K&&K.length>0?null:{id:"default-message",role:"default_message",content:X,createdAt:new Date().toISOString()}},[f,K]),ee=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),z=()=>L?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Zs,{message:L,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),$=K.length,Q=$>0;return b.useEffect(()=>{var X,te;if($===0){q.current=!1;return}if(!q.current)if(q.current=!0,G.current&&K.length>0){const J=K.length-1;(te=(X=G.current).scrollToIndex)==null||te.call(X,{index:J,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},[$,K.length]),b.useImperativeHandle(W,()=>({scrollToLatest:()=>{var X,te;if(G.current&&K.length>0){const J=K.length-1;(te=(X=G.current).scrollToIndex)==null||te.call(X,{index:J,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},scrollToTop:()=>{var X,te;G.current&&K.length>0?(te=(X=G.current).scrollToIndex)==null||te.call(X,{index:0,align:"start",behavior:"auto"}):A.current&&(A.current.scrollTop=0)}}),[K]),u.jsx("div",{className:ee,style:p,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Q?u.jsx(VC,{ref:X=>{G.current=X},scrollerRef:X=>{A.current=X instanceof HTMLDivElement?X:null},data:K,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{O&&O()},atBottomStateChange:P,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(X,te)=>hl(te,X),itemContent:(X,te)=>u.jsx(pl,{message:te,index:X,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_})}):z()})})});ml.displayName="MessageList";const Bp={value:""};function Or({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,payloadExtras:h={},customStyles:p={},onMessageSent:f,onExcelUploadSuccess:v,onError:g,defaultMessage:x}){const{api:y}=Jr(),{currentThreadId:w}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:_,checkpoints:D,interrupt:F,metadata:W,checkpointIndex:G}=to(),{isStreaming:A,error:Y,connectionState:q,submit:B,stop:R}=Fi(),I=S??w??null,U=(_==null?void 0:_.id)??null,K=(_==null?void 0:_.namespace)??null,P=(W==null?void 0:W.assemblingMessageId)??null,O=F,[M,L]=b.useState(!1),[ee,z]=b.useState(!1);b.useEffect(()=>{O||L(!1)},[O]);const $=b.useCallback(()=>{L(!0)},[]),Q=b.useCallback(()=>{L(!1)},[]),X=!!O||M,[te,J]=b.useState(null),[ae,ve]=b.useState(""),[de,me]=b.useState(null),[Ce,Te]=b.useState(null),[_e,dt]=b.useState(!1),[lt,Be]=b.useState(null),Fe=b.useRef(!1),[Le,Ye]=b.useState(()=>Bp.value),Re=b.useRef(Le),$e=b.useRef(null),Qe=b.useCallback(pe=>{Bp.value=pe,Ye(pe)},[]),[It,it]=b.useState(!1),yt=b.useRef(null),St=b.useCallback(pe=>{Qe(pe)},[Qe]);b.useEffect(()=>{A||z(!1)},[A]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&z(!1)},[W==null?void 0:W.assemblingMessageId]);const[Ct,kt]=b.useState("desktop");b.useEffect(()=>{const pe=()=>{const ye=window.innerWidth;kt(ye<640?"phone":ye<1024?"tablet":"desktop")};return pe(),window.addEventListener("resize",pe),()=>window.removeEventListener("resize",pe)},[]),b.useEffect(()=>{Fe.current=!1},[I]),b.useEffect(()=>{Re.current=Le},[Le]),b.useEffect(()=>{if(!te){$e.current=null;return}$e.current===null&&($e.current=Re.current),Qe(ae??"")},[ae,te,Qe]),b.useEffect(()=>{if(x!==void 0){Be(x);return}(async()=>{if(!y.baseUrl){Be(null);return}try{const Me=(await y.getAgent("default")).uiDefaultMessage||"";Be(Me||null)}catch(ye){console.warn("Failed to fetch default message:",ye),Be(null)}})()},[y.baseUrl,x]),b.useEffect(()=>{Y&&!_e&&(g==null||g(Y))},[Y,_e,g]);const on=async(pe,ye)=>{const Me=pe.trim();if(!(!Me&&ye.length===0))try{const qe=te?(de==null?void 0:de.checkpointId)??U??void 0:U??void 0,ct=te?(de==null?void 0:de.checkpointNs)??K??void 0:K??void 0;await B({text:Me||"",attachments:ye,payload:h},{checkpointId:qe,checkpointNs:ct,edit:!!te,originalMessageId:te??void 0}),f==null||f(Me),z(!0),Qe(""),Te(null),J(null),ve(""),me(null)}catch(qe){const ct=(qe==null?void 0:qe.message)||"Failed to send message";Te(ct),g==null||g(ct),z(!1)}},Nt=b.useCallback(async pe=>{await B({attachments:[pe],payload:h},{checkpointId:U??void 0,checkpointNs:K??void 0}),v==null||v({file:pe})},[U,K,h,v,B]),Vt=b.useCallback((pe,ye,Me)=>{c&&($e.current=Le,J(pe),ve(ye),Qe(ye),Te(null),me({checkpointId:(Me==null?void 0:Me.checkpointId)??null,checkpointNs:(Me==null?void 0:Me.checkpointNs)??null}))},[Le,c,Qe]),Et=b.useCallback(()=>{J(null),ve(""),me(null),Te(null),Qe($e.current??Le),$e.current=null},[Le,Qe]),ze=b.useCallback((pe,ye,Me)=>{Vt(pe,ye,Me)},[Vt]),Ke=b.useCallback(pe=>{let ye=null;for(let ut=pe-1;ut>=0;ut--)if(k[ut].role==="user"){ye=k[ut];break}if(!ye)return;const Me=Array.isArray(ye.content)?ye.content:[],ct=Me.filter(ut=>(ut==null?void 0:ut.type)==="text").map(ut=>ut.text).join("")||(()=>{try{return JSON.stringify(Me,null,2)}catch{return String(Me)}})();ct&&B({text:ct,payload:h},{checkpointId:U??void 0,checkpointNs:K??void 0,edit:!0,originalMessageId:ye.id})},[k,B,U,K,h]),At=async pe=>{if(w){it(!0);try{if(!pe){await j(),requestAnimationFrame(()=>{var qe;(qe=yt.current)==null||qe.scrollToLatest()});return}const ye=D.find(qe=>qe.checkpointId===pe),Me=(ye==null?void 0:ye.checkpointNs)??null;await E(pe,Me),requestAnimationFrame(()=>{var qe;(qe=yt.current)==null||qe.scrollToTop()})}finally{it(!1)}}},Z=b.useCallback(async(pe,ye,Me)=>{await At(Me?null:pe)},[At]),ue=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${p.container||""}`,We=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${p.messagesArea||""}`,be=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${p.inputArea||""}`;return u.jsxs("div",{className:ue,children:[!!Y&&!_e&&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:Y}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>dt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${We}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(ml,{ref:yt,className:"h-full",style:{height:"100%"},messages:k,isStreaming:A,streamingAssistantId:P,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ct,enableMessageEditing:c,editingMessageId:te,onEdit:ze,onRegenerate:Ke,onCancelEdit:Et,emptyMessage:lt??void 0,isNavigatingCheckpoint:It,activeInterrupt:O,disableInterruptActions:M,onInterruptActionStart:$,onInterruptActionEnd:Q,showToolMessages:d,checkpointIndex:G,activeCheckpointId:U,onSelectCheckpoint:Z,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ee}),(q==="reconnecting"||q==="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(le.Loader2,{className:"h-3 w-3 animate-spin"}),q==="reconnecting"?"Reconnecting…":"Connecting…"]})}),q==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||It)&&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(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:be,children:[te&&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(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:Et,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),Ce&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Ce}),u.jsx(OS,{composerValue:Le,onComposerChange:St,onSend:on,onCancelEdit:Et,onStop:R,editingMessageId:te,editingInitialValue:ae,placeholder:te?"Edit your message...":t,isStreaming:A,disabled:X,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Nt,onError:g,customStyles:p,textareaClassName:p.textarea||"",allowEmptySend:!1,inputError:Ce})]})]})}var zp=1,tk=.9,nk=.8,rk=.17,gl=.1,xl=.999,ok=.9999,sk=.99,ik=/[\\\/_+.#"@\[\(\{&]/,ak=/[\\\/_+.#"@\[\(\{&]/g,lk=/[\s-]/,Hp=/[\s-]/g;function vl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?zp:sk;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,h,p,f,v;c>=0;)h=vl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=zp:ik.test(e.charAt(c-1))?(h*=nk,f=e.slice(o,c-1).match(ak),f&&o>0&&(h*=Math.pow(xl,f.length))):lk.test(e.charAt(c-1))?(h*=tk,v=e.slice(o,c-1).match(Hp),v&&o>0&&(h*=Math.pow(xl,v.length))):(h*=rk,o>0&&(h*=Math.pow(xl,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=ok)),(h<gl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(p=vl(e,t,n,r,c+1,s+2,i),p*gl>h&&(h=p*gl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Up(e){return e.toLowerCase().replace(Hp," ")}function ck(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,vl(e,t,Up(e),Up(t),0,0,{})}var Ao='[cmdk-group=""]',bl='[cmdk-group-items=""]',uk='[cmdk-group-heading=""]',Wp='[cmdk-item=""]',Vp=`${Wp}:not([aria-disabled="true"])`,wl="cmdk-item-select",Dr="data-value",dk=(e,t,n)=>ck(e,t,n),Kp=m.createContext(void 0),jo=()=>m.useContext(Kp),qp=m.createContext(void 0),yl=()=>m.useContext(qp),Gp=m.createContext(void 0),Yp=m.forwardRef((e,t)=>{let n=Lr(()=>{var P,O;return{search:"",value:(O=(P=e.value)!=null?P:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Xp(e),{label:l,children:c,value:d,onValueChange:h,filter:p,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=_t(),S=_t(),k=_t(),C=m.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),ur(()=>{T(6,G)},[]);let E=m.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,O,M)=>{var L,ee,z,$;if(!Object.is(n.current[P],O)){if(n.current[P]=O,P==="search")W(),D(),T(1,F);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Q=document.getElementById(k);Q?Q.focus():(L=document.getElementById(w))==null||L.focus()}if(T(7,()=>{var Q;n.current.selectedItemId=(Q=A())==null?void 0:Q.id,E.emit()}),M||T(5,G),((ee=a.current)==null?void 0:ee.value)!==void 0){let Q=O??"";($=(z=a.current).onValueChange)==null||$.call(z,Q);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=m.useMemo(()=>({value:(P,O,M)=>{var L;O!==((L=s.current.get(P))==null?void 0:L.value)&&(s.current.set(P,{value:O,keywords:M}),n.current.filtered.items.set(P,_(O,M)),T(2,()=>{D(),E.emit()}))},item:(P,O)=>(r.current.add(P),O&&(o.current.has(O)?o.current.get(O).add(P):o.current.set(O,new Set([P]))),T(3,()=>{W(),D(),n.current.value||F(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let M=A();T(4,()=>{W(),(M==null?void 0:M.getAttribute("id"))===P&&F(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function _(P,O){var M,L;let ee=(L=(M=a.current)==null?void 0:M.filter)!=null?L:dk;return P?ee(P,n.current.search,O):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(L=>{let ee=o.current.get(L),z=0;ee.forEach($=>{let Q=P.get($);z=Math.max(Q,z)}),O.push([L,z])});let M=C.current;Y().sort((L,ee)=>{var z,$;let Q=L.getAttribute("id"),X=ee.getAttribute("id");return((z=P.get(X))!=null?z:0)-(($=P.get(Q))!=null?$:0)}).forEach(L=>{let ee=L.closest(bl);ee?ee.appendChild(L.parentElement===ee?L:L.closest(`${bl} > *`)):M.appendChild(L.parentElement===M?L:L.closest(`${bl} > *`))}),O.sort((L,ee)=>ee[1]-L[1]).forEach(L=>{var ee;let z=(ee=C.current)==null?void 0:ee.querySelector(`${Ao}[${Dr}="${encodeURIComponent(L[0])}"]`);z==null||z.parentElement.appendChild(z)})}function F(){let P=Y().find(M=>M.getAttribute("aria-disabled")!=="true"),O=P==null?void 0:P.getAttribute(Dr);E.setState("value",O||void 0)}function W(){var P,O,M,L;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ee=0;for(let z of r.current){let $=(O=(P=s.current.get(z))==null?void 0:P.value)!=null?O:"",Q=(L=(M=s.current.get(z))==null?void 0:M.keywords)!=null?L:[],X=_($,Q);n.current.filtered.items.set(z,X),X>0&&ee++}for(let[z,$]of o.current)for(let Q of $)if(n.current.filtered.items.get(Q)>0){n.current.filtered.groups.add(z);break}n.current.filtered.count=ee}function G(){var P,O,M;let L=A();L&&(((P=L.parentElement)==null?void 0:P.firstChild)===L&&((M=(O=L.closest(Ao))==null?void 0:O.querySelector(uk))==null||M.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function A(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Wp}[aria-selected="true"]`)}function Y(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Vp))||[])}function q(P){let O=Y()[P];O&&E.setState("value",O.getAttribute(Dr))}function B(P){var O;let M=A(),L=Y(),ee=L.findIndex($=>$===M),z=L[ee+P];(O=a.current)!=null&&O.loop&&(z=ee+P<0?L[L.length-1]:ee+P===L.length?L[0]:L[ee+P]),z&&E.setState("value",z.getAttribute(Dr))}function R(P){let O=A(),M=O==null?void 0:O.closest(Ao),L;for(;M&&!L;)M=P>0?wk(M,Ao):yk(M,Ao),L=M==null?void 0:M.querySelector(Vp);L?E.setState("value",L.getAttribute(Dr)):B(P)}let I=()=>q(Y().length-1),U=P=>{P.preventDefault(),P.metaKey?I():P.altKey?R(1):B(1)},K=P=>{P.preventDefault(),P.metaKey?q(0):P.altKey?R(-1):B(-1)};return m.createElement(ge.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var O;(O=y.onKeyDown)==null||O.call(y,P);let M=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||M))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&U(P);break}case"ArrowDown":{U(P);break}case"p":case"k":{x&&P.ctrlKey&&K(P);break}case"ArrowUp":{K(P);break}case"Home":{P.preventDefault(),q(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let L=A();if(L){let ee=new Event(wl);L.dispatchEvent(ee)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:Tk},l),Qs(e,P=>m.createElement(qp.Provider,{value:E},m.createElement(Kp.Provider,{value:j},P))))}),fk=m.forwardRef((e,t)=>{var n,r;let o=_t(),s=m.useRef(null),i=m.useContext(Gp),a=jo(),l=Xp(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Jp(o,s,[e.value,e.children,s],e.keywords),h=yl(),p=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);m.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(wl,v),()=>T.removeEventListener(wl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return m.createElement(ge.div,{ref:On(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!p,"data-disabled":!!x,"data-selected":!!p,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),hk=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=m.useRef(null),l=m.useRef(null),c=_t(),d=jo(),h=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Jp(i,a,[e.value,e.heading,l]);let p=m.useMemo(()=>({id:i,forceMount:o}),[o]);return m.createElement(ge.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&m.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Qs(e,f=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},m.createElement(Gp.Provider,{value:p},f))))}),pk=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:m.createElement(ge.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),mk=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=yl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=jo();return m.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),m.createElement(ge.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)}})}),gk=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=m.useRef(null),i=m.useRef(null),a=Gn(c=>c.selectedItemId),l=jo();return m.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,p=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return p.observe(c),()=>{cancelAnimationFrame(h),p.unobserve(c)}}},[]),m.createElement(ge.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Qs(e,c=>m.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xk=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return m.createElement(Qa,{open:n,onOpenChange:r},m.createElement(el,{container:i},m.createElement(ko,{"cmdk-overlay":"",className:o}),m.createElement(Eo,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(Yp,{ref:t,...a}))))}),vk=m.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?m.createElement(ge.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),bk=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return m.createElement(ge.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qs(e,i=>m.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Yp,{List:gk,Item:fk,Input:mk,Group:hk,Separator:pk,Dialog:xk,Empty:vk,Loading:bk});function wk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function yk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Xp(e){let t=m.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?m.useEffect:m.useLayoutEffect;function Lr(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=yl(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function Jp(e,t,n,r=[]){let o=m.useRef(),s=jo();return ur(()=>{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(Dr,a),o.current=a}),o}var Sk=()=>{let[e,t]=m.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Ck(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&&m.isValidElement(t)?m.cloneElement(Ck(t),{ref:t.ref},n(t.props.children)):n(t)}var Tk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Sl=m.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Sl.displayName=Ut.displayName;const Cl=m.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.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})]}));Cl.displayName=Ut.Input.displayName;const Tl=m.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Tl.displayName=Ut.List.displayName;const kl=m.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));kl.displayName=Ut.Empty.displayName;const El=m.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));El.displayName=Ut.Group.displayName;const kk=m.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));kk.displayName=Ut.Separator.displayName;const Il=m.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));Il.displayName=Ut.Item.displayName;function Nl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ek(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Al="ScrollArea",[Zp,HN]=ln(Al),[Ik,rn]=Zp(Al),Qp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[c,d]=m.useState(null),[h,p]=m.useState(null),[f,v]=m.useState(null),[g,x]=m.useState(null),[y,w]=m.useState(0),[S,k]=m.useState(0),[C,T]=m.useState(!1),[E,j]=m.useState(!1),_=Oe(t,F=>l(F)),D=Zo(o);return u.jsx(Ik,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:p,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ge.div,{dir:D,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Qp.displayName=Al;var em="ScrollAreaViewport",tm=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(em,n),a=m.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(ge.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})})]})});tm.displayName=em;var En="ScrollAreaScrollbar",jl=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Nk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(nm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(_l,{...r,ref:t}):null});jl.displayName=En;var Nk=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.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(zt,{present:n||s,children:u.jsx(nm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ak=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=Ek("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const p=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",p),()=>c.removeEventListener("scroll",p)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(_l,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),nm=m.forwardRef((e,t)=>{const n=rn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.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 $r(n.viewport,l),$r(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(_l,{"data-state":s?"visible":"hidden",...o,ref:t})})}),_l=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(En,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=am(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function h(p,f){return Ok(p,i.current,a,f)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,f=lm(p,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=h(p,o.dir))}}):n==="vertical"?u.jsx(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,f=lm(p,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=h(p))}}):null}),jk=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),c=Oe(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(om,{"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,h)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),um(p,h)&&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)}})}})}),_k=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),c=Oe(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(om,{"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,h)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),um(p,h)&&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)}})}})}),[Pk,rm]=Zp(En),om=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...p}=e,f=rn(En,n),[v,g]=m.useState(null),x=Oe(t,_=>g(_)),y=m.useRef(null),w=m.useRef(""),S=f.viewport,k=r.content-r.viewport,C=pt(d),T=pt(l),E=ri(h,10);function j(_){if(y.current){const D=_.clientX-y.current.left,F=_.clientY-y.current.top;c({x:D,y:F})}}return m.useEffect(()=>{const _=D=>{const F=D.target;(v==null?void 0:v.contains(F))&&C(D,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,v,k,C]),m.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(Pk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(ge.div,{...p,ref:x,style:{position:"absolute",...p.style},onPointerDown:ie(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ie(e.onPointerMove,j),onPointerUp:ie(e.onPointerUp,_=>{const D=_.target;D.hasPointerCapture(_.pointerId)&&D.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",sm=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rm(ei,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(Rk,{ref:t,...r})})}),Rk=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(ei,n),i=rm(ei,n),{onThumbPositionChange:a}=i,l=Oe(t,h=>i.onThumbChange(h)),c=m.useRef(void 0),d=ri(()=>{c.current&&(c.current(),c.current=void 0)},100);return m.useEffect(()=>{const h=s.viewport;if(h){const p=()=>{if(d(),!c.current){const f=Dk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[s.viewport,d,a]),u.jsx(ge.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:ie(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});sm.displayName=ei;var Pl="ScrollAreaCorner",im=m.forwardRef((e,t)=>{const n=rn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Mk,{...e,ref:t}):null});im.displayName=Pl;var Mk=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Pl,n),[s,i]=m.useState(0),[a,l]=m.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ge.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 am(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=am(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ok(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,h=r==="ltr"?[0,d]:[d*-1,0];return cm([l,c],h)(e)}function lm(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=Nl(e,l);return cm([0,i],[0,a])(c)}function cm(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 um(e,t){return e>0&&e<t}var Dk=(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=pt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function $r(e,t){const n=pt(t);Tt(()=>{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 dm=Qp,Lk=tm,$k=im;const Rl=m.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(dm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Lk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(fm,{}),u.jsx($k,{})]}));Rl.displayName=dm.displayName;const fm=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(jl,{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(sm,{className:"relative flex-1 rounded-full bg-border"})}));fm.displayName=jl.displayName;const Ml=m.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}));Ml.displayName="Input";const Fk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Bk="bg-slate-700 border-slate-600 hover:bg-slate-600",zk="bg-slate-600 border-slate-500";function hm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:p,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??zk}`:`${x??Bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Fk} ${S}`,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:C=>C.stopPropagation(),children:[u.jsx(Ml,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.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(le.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Ze,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(po,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),p&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(le.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"})]})}const pm=25,mm="thread-manager-view",Hk=e=>e==="default"||e==="shared",Uk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(mm);if(Hk(e))return e}catch{}return null};function gm({defaultView:e}={}){const[t,n]=b.useState(()=>Uk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(mm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Wk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function oi({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:h,defaultView:p,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:_,actions:D,shareInFlight:F,shareStatus:W,clearShareStatus:G}=xr(),{createThread:A,deleteThread:Y,renameThread:q,shareThread:B}=D,{loadThread:R}=to(),I=i??T,[U,K]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(U.length>0),O=b.useRef(null),M=b.useRef(0),[L,ee]=b.useState(null),[z,$]=b.useState(""),[Q,X]=b.useState(!1),[te,J]=b.useState(!1),[ae,ve]=b.useState(null),[de,me]=b.useState(""),Ce=v&&v.length>0?v:Wk,Te=gm({defaultView:p}),_e=g??Te,dt=h??_e.view,lt=b.useCallback(Z=>{h||_e.setView(Z),f==null||f(Z)},[h,f,_e]),Be=Ce.find(Z=>Z.key===dt)??Ce[0],Fe=Z=>{ve(Z),me(""),J(!0)},Le=()=>{J(!1),ve(null),me(""),G()},Ye=b.useCallback(async Z=>{if(!(!ae||F)&&Z.id)try{await B(ae,Z.id),setTimeout(()=>Le(),600)}catch(ue){console.error("Failed to share thread:",ue)}},[Le,F,ae,B]),Re=b.useMemo(()=>{const Z=y??[],ue=de.trim().toLowerCase();return ue?S?Z.filter(We=>S(We,ue)):Z.filter(We=>`${We.label} ${We.secondaryLabel??""}`.toLowerCase().includes(ue)):Z},[y,de,S]),$e=dt==="shared",Qe=$e?C:U,It=$e?_:j,it=$e?"No shared conversations yet":"No conversations yet",yt=Z=>{const ue=Z.sharedAt?` • ${ze(Z.sharedAt)}`:"";return`Shared by ${Z.sharedByUserId}${ue}`},St=Z=>"sharedByUserId"in Z;b.useEffect(()=>{const Z=Array.isArray(k)?k:[];if(Z.length>0){P.current=!0,K(Z);return}j||(P.current=!1,K(Z))},[k,j]),b.useEffect(()=>{if(!O.current)return;const Z=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!Z)return;let ue=null,We=null;return ue=requestAnimationFrame(()=>{We=requestAnimationFrame(()=>{Z.scrollTop=M.current})}),()=>{ue!==null&&cancelAnimationFrame(ue),We!==null&&cancelAnimationFrame(We)}},[U]);const Ct=async Z=>{try{E(Z),await R(Z),a==null||a(Z),l==null||l(Z)}catch(ue){console.error("Failed to select thread:",ue)}},kt=async()=>{try{X(!0);const Z=await A();Z&&(c==null||c(Z),a==null||a(Z))}catch(Z){console.error("Failed to create thread:",Z)}finally{X(!1)}},on=async(Z,ue)=>{if(ue.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const We=O.current.querySelector("[data-radix-scroll-area-viewport]");We&&(M.current=We.scrollTop)}try{await Y(Z),d==null||d(Z)}catch(We){console.error("Failed to delete thread:",We)}}},Nt=(Z,ue)=>{ue.stopPropagation(),ee(Z.threadId),$(Z.title||`Thread ${Z.threadId.slice(0,8)}`)},Vt=async Z=>{if(z.trim())try{await q(Z,z.trim()),ee(null),$("")}catch(ue){console.error("Failed to update title:",ue)}},Et=()=>{ee(null),$("")},ze=Z=>{if(!Z)return"";try{const ue=new Date(Z),be=new Date().getTime()-ue.getTime(),pe=Math.floor(be/(1e3*60*60*24));return pe===0?ue.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe===1?"Yesterday":pe<7?`${pe} days ago`:ue.toLocaleDateString()}catch{return""}},Ke=Z=>Z.title||`Thread ${Z.threadId.slice(0,8)}`,At=Z=>{const ue=Ke(Z);return ue.length<=pm?ue:`${ue.slice(0,pm)}...`};return u.jsxs("div",{className:`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(Ze,{onClick:kt,disabled:Q||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Q?"Creating...":"New Chat",children:[u.jsx(le.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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Ze,{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:Be.label})}),u.jsx(po,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(Z=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:ue=>{ue.preventDefault(),lt(Z.key)},children:[u.jsx("span",{children:Z.label}),dt===Z.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},Z.key))})]})]})]}),u.jsx(Rl,{ref:O,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:It?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Qe.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.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:it})]}):Qe.slice().sort((Z,ue)=>new Date(ue.updatedAt||ue.createdAt||"").getTime()-new Date(Z.updatedAt||Z.createdAt||"").getTime()).map(Z=>u.jsx(hm,{thread:Z,isActive:I===Z.threadId,editingThreadId:L,editingTitle:z,onSelect:Ct,onStartEditing:Nt,onEditingTitleChange:ue=>$(ue),onSaveEditing:Vt,onCancelEditing:Et,onShare:()=>Fe(Z.threadId),onDelete:on,showEditTitle:r,showDeleteButton:n,formatDate:ze,getDisplayThreadTitle:At,secondaryLine:$e&&St(Z)?yt(Z):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Z.threadId))})}),u.jsx(tl,{open:te,onOpenChange:Z=>!Z&&Le(),children:u.jsxs(Hs,{className:"max-w-md p-0",children:[u.jsx(Us,{children:u.jsx(Ws,{children:"Share thread"})}),u.jsxs(Sl,{children:[u.jsx(Cl,{autoFocus:!0,value:de,onValueChange:Z=>me(Z),placeholder:"Search for recipients..."}),u.jsxs(Tl,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(le.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(kl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Re.length>0&&u.jsx(El,{heading:"Recipients",children:Re.map(Z=>u.jsx(Il,{onSelect:()=>Ye(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 Vk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(wr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(wr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function qk({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(le.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(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(oi,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Gk({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(wr,{...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(Ze,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Ze,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Ze,{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(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(qk,{placeholder:t,onMessageSent:r})})]})})}):null}function Yk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Ze,{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(le.Edit3,{size:16}),t??e]})}var Xk="Label",xm=m.forwardRef((e,t)=>u.jsx(ge.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())}}));xm.displayName=Xk;var vm=xm;const Jk=Hr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),bm=m.forwardRef(({className:e,...t},n)=>u.jsx(vm,{ref:n,className:oe(Jk(),e),...t}));bm.displayName=vm.displayName;function wm(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ym=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"}),Zk="VisuallyHidden",si=m.forwardRef((e,t)=>u.jsx(ge.span,{...e,ref:t,style:{...ym,...e.style}}));si.displayName=Zk;var Qk=si,eE=[" ","Enter","ArrowUp","ArrowDown"],tE=[" ","Enter"],dr="Select",[ii,ai,nE]=Jo(dr),[Fr,UN]=ln(dr,[nE,Ir]),li=Ir(),[rE,Yn]=Fr(dr),[oE,sE]=Fr(dr),Sm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:p,required:f,form:v}=e,g=li(t),[x,y]=m.useState(null),[w,S]=m.useState(null),[k,C]=m.useState(!1),T=Zo(c),[E,j]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[_,D]=Dn({prop:i,defaultProp:a,onChange:l,caller:dr}),F=m.useRef(null),W=x?v||!!x.closest("form"):!0,[G,A]=m.useState(new Set),Y=Array.from(G).map(q=>q.props.value).join(";");return u.jsx(ia,{...g,children:u.jsxs(rE,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:_t(),value:_,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:F,disabled:p,children:[u.jsx(ii.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(q=>{A(B=>new Set(B).add(q))},[]),onNativeOptionRemove:m.useCallback(q=>{A(B=>{const R=new Set(B);return R.delete(q),R})},[]),children:n})}),W?u.jsxs(Km,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:_,onChange:q=>D(q.target.value),disabled:p,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},Y):null]})})};Sm.displayName=dr;var Cm="SelectTrigger",Tm=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=li(n),i=Yn(Cm,n),a=i.disabled||r,l=Oe(t,i.onTriggerChange),c=ai(n),d=m.useRef("touch"),[h,p,f]=Gm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Ym(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(aa,{asChild:!0,...s,children:u.jsx(ge.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":qm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(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:ie(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&p(g.key),!(x&&g.key===" ")&&eE.includes(g.key)&&(v(),g.preventDefault())})})})});Tm.displayName=Cm;var km="SelectValue",Em=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(km,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Oe(t,l.onValueNodeChange);return Tt(()=>{c(d)},[c,d]),u.jsx(ge.span,{...a,ref:h,style:{pointerEvents:"none"},children:qm(l.value)?u.jsx(u.Fragment,{children:i}):s})});Em.displayName=km;var iE="SelectIcon",Im=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ge.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Im.displayName=iE;var aE="SelectPortal",Nm=e=>u.jsx(io,{asChild:!0,...e});Nm.displayName=aE;var fr="SelectContent",Am=m.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=m.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(u.jsx(jm,{scope:e.__scopeSelect,children:u.jsx(ii.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(_m,{...e,ref:t})});Am.displayName=fr;var pn=10,[jm,Xn]=Fr(fr),lE="SelectContentImpl",cE=qt.createSlot("SelectContent.RemoveScroll"),_m=m.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:h,collisionBoundary:p,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Yn(fr,n),[S,k]=m.useState(null),[C,T]=m.useState(null),E=Oe(t,z=>k(z)),[j,_]=m.useState(null),[D,F]=m.useState(null),W=ai(n),[G,A]=m.useState(!1),Y=m.useRef(!1);m.useEffect(()=>{if(S)return ha(S)},[S]),Wi();const q=m.useCallback(z=>{const[$,...Q]=W().map(J=>J.ref.current),[X]=Q.slice(-1),te=document.activeElement;for(const J of z)if(J===te||(J==null||J.scrollIntoView({block:"nearest"}),J===$&&C&&(C.scrollTop=0),J===X&&C&&(C.scrollTop=C.scrollHeight),J==null||J.focus(),document.activeElement!==te))return},[W,C]),B=m.useCallback(()=>q([j,S]),[q,j,S]);m.useEffect(()=>{G&&B()},[G,B]);const{onOpenChange:R,triggerPointerDownPosRef:I}=w;m.useEffect(()=>{if(S){let z={x:0,y:0};const $=X=>{var te,J;z={x:Math.abs(Math.round(X.pageX)-(((te=I.current)==null?void 0:te.x)??0)),y:Math.abs(Math.round(X.pageY)-(((J=I.current)==null?void 0:J.y)??0))}},Q=X=>{z.x<=10&&z.y<=10?X.preventDefault():S.contains(X.target)||R(!1),document.removeEventListener("pointermove",$),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",Q,{capture:!0})}}},[S,R,I]),m.useEffect(()=>{const z=()=>R(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[R]);const[U,K]=Gm(z=>{const $=W().filter(te=>!te.disabled),Q=$.find(te=>te.ref.current===document.activeElement),X=Ym($,z,Q);X&&setTimeout(()=>X.ref.current.focus())}),P=m.useCallback((z,$,Q)=>{const X=!Y.current&&!Q;(w.value!==void 0&&w.value===$||X)&&(_(z),X&&(Y.current=!0))},[w.value]),O=m.useCallback(()=>S==null?void 0:S.focus(),[S]),M=m.useCallback((z,$,Q)=>{const X=!Y.current&&!Q;(w.value!==void 0&&w.value===$||X)&&F(z)},[w.value]),L=r==="popper"?Ol:Pm,ee=L===Ol?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:p,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(jm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:j,onItemLeave:O,itemTextRefCallback:M,focusSelectedItem:B,selectedItemText:D,position:r,isPositioned:G,searchRef:U,children:u.jsx(vs,{as:cE,allowPinchZoom:!0,children:u.jsx(Qo,{asChild:!0,trapped:w.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:ie(o,z=>{var $;($=w.trigger)==null||$.focus({preventScroll:!0}),z.preventDefault()}),children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:z=>z.preventDefault(),...y,...ee,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,z=>{const $=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!$&&z.key.length===1&&K(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let X=W().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(z.key)&&(X=X.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const te=z.target,J=X.indexOf(te);X=X.slice(J+1)}setTimeout(()=>q(X)),z.preventDefault()}})})})})})})});_m.displayName=lE;var uE="SelectItemAlignedPosition",Pm=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=m.useState(null),[c,d]=m.useState(null),h=Oe(t,E=>d(E)),p=ai(n),f=m.useRef(!1),v=m.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const te=D.left-j.left,J=_.left-te,ae=E.left-J,ve=E.width+ae,de=Math.max(ve,j.width),me=window.innerWidth-pn,Ce=Nl(J,[pn,Math.max(pn,me-de)]);a.style.minWidth=ve+"px",a.style.left=Ce+"px"}else{const te=j.right-D.right,J=window.innerWidth-_.right-te,ae=window.innerWidth-E.right-J,ve=E.width+ae,de=Math.max(ve,j.width),me=window.innerWidth-pn,Ce=Nl(J,[pn,Math.max(pn,me-de)]);a.style.minWidth=ve+"px",a.style.right=Ce+"px"}const F=p(),W=window.innerHeight-pn*2,G=g.scrollHeight,A=window.getComputedStyle(c),Y=parseInt(A.borderTopWidth,10),q=parseInt(A.paddingTop,10),B=parseInt(A.borderBottomWidth,10),R=parseInt(A.paddingBottom,10),I=Y+q+G+R+B,U=Math.min(x.offsetHeight*5,I),K=window.getComputedStyle(g),P=parseInt(K.paddingTop,10),O=parseInt(K.paddingBottom,10),M=E.top+E.height/2-pn,L=W-M,ee=x.offsetHeight/2,z=x.offsetTop+ee,$=Y+q+z,Q=I-$;if($<=M){const te=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const J=c.clientHeight-g.offsetTop-g.offsetHeight,ae=Math.max(L,ee+(te?O:0)+J+B),ve=$+ae;a.style.height=ve+"px"}else{const te=F.length>0&&x===F[0].ref.current;a.style.top="0px";const ae=Math.max(M,Y+g.offsetTop+(te?P:0)+ee)+Q;a.style.height=ae+"px",g.scrollTop=$-M+g.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=W+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[p,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Tt(()=>S(),[S]);const[k,C]=m.useState();Tt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=m.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(fE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ge.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=uE;var dE="SelectPopperPosition",Ol=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=li(n);return u.jsx(la,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ol.displayName=dE;var[fE,Dl]=Fr(fr,{}),Ll="SelectViewport",Rm=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Ll,n),i=Dl(Ll,n),a=Oe(t,s.onViewportChange),l=m.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(ii.Slot,{scope:n,children:u.jsx(ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-pn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Rm.displayName=Ll;var Mm="SelectGroup",[hE,pE]=Fr(Mm),mE=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(hE,{scope:n,id:o,children:u.jsx(ge.div,{role:"group","aria-labelledby":o,...r,ref:t})})});mE.displayName=Mm;var Om="SelectLabel",Dm=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=pE(Om,n);return u.jsx(ge.div,{id:o.id,...r,ref:t})});Dm.displayName=Om;var ci="SelectItem",[gE,Lm]=Fr(ci),$m=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ci,n),l=Xn(ci,n),c=a.value===r,[d,h]=m.useState(s??""),[p,f]=m.useState(!1),v=Oe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=_t(),x=m.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(gE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:m.useCallback(w=>{h(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ii.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ge.div,{role:"option","aria-labelledby":g,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(tE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});$m.displayName=ci;var _o="SelectItemText",Fm=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(_o,n),a=Xn(_o,n),l=Lm(_o,n),c=sE(_o,n),[d,h]=m.useState(null),p=Oe(t,y=>h(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,v=m.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Tt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ge.span,{id:l.textId,...s,ref:p}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ur.createPortal(s.children,i.valueNode):null]})});Fm.displayName=_o;var Bm="SelectItemIndicator",zm=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Lm(Bm,n).isSelected?u.jsx(ge.span,{"aria-hidden":!0,...r,ref:t}):null});zm.displayName=Bm;var $l="SelectScrollUpButton",Hm=m.forwardRef((e,t)=>{const n=Xn($l,e.__scopeSelect),r=Dl($l,e.__scopeSelect),[o,s]=m.useState(!1),i=Oe(t,r.onScrollButtonChange);return Tt(()=>{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(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Hm.displayName=$l;var Fl="SelectScrollDownButton",Um=m.forwardRef((e,t)=>{const n=Xn(Fl,e.__scopeSelect),r=Dl(Fl,e.__scopeSelect),[o,s]=m.useState(!1),i=Oe(t,r.onScrollButtonChange);return Tt(()=>{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(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Um.displayName=Fl;var Wm=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=m.useRef(null),a=ai(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Tt(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(ge.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),xE="SelectSeparator",Vm=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ge.div,{"aria-hidden":!0,...r,ref:t})});Vm.displayName=xE;var Bl="SelectArrow",vE=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=li(n),s=Yn(Bl,n),i=Xn(Bl,n);return s.open&&i.position==="popper"?u.jsx(ca,{...o,...r,ref:t}):null});vE.displayName=Bl;var bE="SelectBubbleInput",Km=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Oe(r,o),i=wm(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(ge.select,{...n,style:{...ym,...n.style},ref:s,defaultValue:t})});Km.displayName=bE;function qm(e){return e===""||e===void 0}function Gm(e){const t=pt(e),n=m.useRef(""),r=m.useRef(0),o=m.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=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Ym(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=wE(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 wE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yE=Sm,Xm=Tm,SE=Em,CE=Im,TE=Nm,Jm=Am,kE=Rm,Zm=Dm,Qm=$m,EE=Fm,IE=zm,eg=Hm,tg=Um,ng=Vm;const NE=yE,AE=SE,rg=m.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Xm,{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(CE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));rg.displayName=Xm.displayName;const og=m.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=m.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));sg.displayName=tg.displayName;const ig=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(TE,{children:u.jsxs(Jm,{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(og,{}),u.jsx(kE,{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(sg,{})]})}));ig.displayName=Jm.displayName;const jE=m.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=Zm.displayName;const ag=m.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Qm,{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(IE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(EE,{children:t})]}));ag.displayName=Qm.displayName;const _E=m.forwardRef(({className:e,...t},n)=>u.jsx(ng,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));_E.displayName=ng.displayName;var PE="Separator",lg="horizontal",RE=["horizontal","vertical"],cg=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=lg,...o}=e,s=ME(r)?r:lg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ge.div,{"data-orientation":s,...a,...o,ref:t})});cg.displayName=PE;function ME(e){return RE.includes(e)}var ug=cg;const dg=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ug,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dg.displayName=ug.displayName;var ui="Switch",[OE,WN]=ln(ui),[DE,LE]=OE(ui),fg=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[p,f]=m.useState(null),v=Oe(t,S=>f(S)),g=m.useRef(!1),x=p?d||!!p.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ui});return u.jsxs(DE,{scope:n,checked:y,disabled:a,children:[u.jsx(ge.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":gg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(mg,{control:p,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});fg.displayName=ui;var hg="SwitchThumb",pg=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LE(hg,n);return u.jsx(ge.span,{"data-state":gg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pg.displayName=hg;var $E="SwitchBubbleInput",mg=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Oe(i,s),l=wm(n),c=yd(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.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}})});mg.displayName=$E;function gg(e){return e?"checked":"unchecked"}var xg=fg,FE=pg;const vg=m.forwardRef(({className:e,...t},n)=>u.jsx(xg,{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(FE,{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")})}));vg.displayName=xg.displayName;const BE=Qa,zE=mT,HE=el,bg=m.forwardRef(({className:e,...t},n)=>u.jsx(ko,{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}));bg.displayName=ko.displayName;const UE=Hr.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"}}),wg=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(HE,{children:[u.jsx(bg,{}),u.jsxs(Eo,{ref:o,className:oe(UE({side:e}),t),...r,children:[n,u.jsxs(ap,{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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wg.displayName=Eo.displayName;const yg=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});yg.displayName="SheetHeader";const Sg=m.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Sg.displayName=lr.displayName;const Cg=m.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Cg.displayName=zs.displayName;var[di,VN]=ln("Tooltip",[Ir]),fi=Ir(),Tg="TooltipProvider",WE=700,zl="tooltip.open",[VE,Hl]=di(Tg),kg=e=>{const{__scopeTooltip:t,delayDuration:n=WE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=m.useRef(!0),a=m.useRef(!1),l=m.useRef(0);return m.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(VE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:m.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};kg.displayName=Tg;var Po="Tooltip",[KE,hi]=di(Po),Eg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Hl(Po,e.__scopeTooltip),c=fi(t),[d,h]=m.useState(null),p=_t(),f=m.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=m.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(zl))):l.onClose(),s==null||s(E)},caller:Po}),S=m.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=m.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=m.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=m.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return m.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ia,{...c,children:u.jsx(KE,{scope:t,contentId:p,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:m.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:m.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};Eg.displayName=Po;var Ul="TooltipTrigger",Ig=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(Ul,n),s=Hl(Ul,n),i=fi(n),a=m.useRef(null),l=Oe(t,a,o.onTriggerChange),c=m.useRef(!1),d=m.useRef(!1),h=m.useCallback(()=>c.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(aa,{asChild:!0,...i,children:u.jsx(ge.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});Ig.displayName=Ul;var qE="TooltipPortal",[KN,GE]=di(qE,{forceMount:void 0}),Br="TooltipContent",Ng=m.forwardRef((e,t)=>{const n=GE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Br,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ag,{side:o,...s,ref:t}):u.jsx(YE,{side:o,...s,ref:t})})}),YE=m.forwardRef((e,t)=>{const n=hi(Br,e.__scopeTooltip),r=Hl(Br,e.__scopeTooltip),o=m.useRef(null),s=Oe(t,o),[i,a]=m.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,p=m.useCallback(()=>{a(null),h(!1)},[h]),f=m.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=eI(y,x.getBoundingClientRect()),S=tI(y,w),k=nI(g.getBoundingClientRect()),C=oI([...S,...k]);a(C),h(!0)},[h]);return m.useEffect(()=>()=>p(),[p]),m.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,p]),m.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)),S=!rI(y,i);w?p():S&&(p(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,p]),u.jsx(Ag,{...e,ref:s})}),[XE,JE]=di(Po,{isInside:!1}),ZE=qt.createSlottable("TooltipContent"),Ag=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=hi(Br,n),c=fi(n),{onClose:d}=l;return m.useEffect(()=>(document.addEventListener(zl,d),()=>document.removeEventListener(zl,d)),[d]),m.useEffect(()=>{if(l.trigger){const h=p=>{const f=p.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(la,{"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(ZE,{children:r}),u.jsx(XE,{scope:n,isInside:!0,children:u.jsx(Qk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Ng.displayName=Br;var jg="TooltipArrow",QE=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=fi(n);return JE(jg,n).isInside?null:u.jsx(ca,{...o,...r,ref:t})});QE.displayName=jg;function eI(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 tI(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 nI(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 rI(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,h=l.x,p=l.y;d>r!=p>r&&n<(h-c)*(r-d)/(p-d)+c&&(o=!o)}return o}function oI(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),sI(t)}function sI(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 iI=kg,aI=Eg,lI=Ig,_g=Ng;const cI=iI,uI=aI,dI=lI,Pg=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(_g,{ref:r,sideOffset:t,className:oe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Pg.displayName=_g.displayName;var Wl="ToastProvider",[Vl,fI,hI]=Jo("Toast"),[Rg,qN]=ln("Toast",[hI]),[pI,pi]=Rg(Wl),Mg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=m.useState(null),[c,d]=m.useState(0),h=m.useRef(!1),p=m.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Wl}\`. Expected non-empty \`string\`.`),u.jsx(Vl.Provider,{scope:t,children:u.jsx(pI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:m.useCallback(()=>d(f=>f+1),[]),onToastRemove:m.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:p,children:i})})};Mg.displayName=Wl;var Og="ToastViewport",mI=["F8"],Kl="toast.viewportPause",ql="toast.viewportResume",Dg=m.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=mI,label:o="Notifications ({hotkey})",...s}=e,i=pi(Og,n),a=fI(n),l=m.useRef(null),c=m.useRef(null),d=m.useRef(null),h=m.useRef(null),p=Oe(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;m.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),m.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(ql);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=m.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...NI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return m.useEffect(()=>{const x=h.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,_=w.shiftKey;if(w.target===x&&_){(C=c.current)==null||C.focus();return}const W=g({tabbingDirection:_?"backwards":"forwards"}),G=W.findIndex(A=>A===j);Xl(W.slice(G+1))?w.preventDefault():_?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Ub,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Gl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Xl(x)}}),u.jsx(Vl.Slot,{scope:n,children:u.jsx(ge.ol,{tabIndex:-1,...s,ref:p})}),v&&u.jsx(Gl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Xl(x)}})]})});Dg.displayName=Og;var Lg="ToastFocusProxy",Gl=m.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=pi(Lg,n);return u.jsx(si,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Gl.displayName=Lg;var Ro="Toast",gI="toast.swipeStart",xI="toast.swipeMove",vI="toast.swipeCancel",bI="toast.swipeEnd",$g=m.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:Ro});return u.jsx(zt,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:h}=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",`${h}px`)}),onSwipeCancel:ie(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:ie(e.onSwipeEnd,c=>{const{x:d,y:h}=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",`${h}px`),l(!1)})})})});$g.displayName=Ro;var[wI,yI]=Rg(Ro,{onClose(){}}),SI=m.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:p,onSwipeEnd:f,...v}=e,g=pi(Ro,n),[x,y]=m.useState(null),w=Oe(t,A=>y(A)),S=m.useRef(null),k=m.useRef(null),C=o||g.duration,T=m.useRef(0),E=m.useRef(C),j=m.useRef(0),{onToastAdd:_,onToastRemove:D}=g,F=pt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),W=m.useCallback(A=>{!A||A===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(F,A))},[F]);m.useEffect(()=>{const A=g.viewport;if(A){const Y=()=>{W(E.current),c==null||c()},q=()=>{const B=new Date().getTime()-T.current;E.current=E.current-B,window.clearTimeout(j.current),l==null||l()};return A.addEventListener(Kl,q),A.addEventListener(ql,Y),()=>{A.removeEventListener(Kl,q),A.removeEventListener(ql,Y)}}},[g.viewport,C,l,c,W]),m.useEffect(()=>{s&&!g.isClosePausedRef.current&&W(C)},[s,C,g.isClosePausedRef,W]),m.useEffect(()=>(_(),()=>D()),[_,D]);const G=m.useMemo(()=>x?Vg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(CI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(wI,{scope:n,onClose:F,children:Ur.createPortal(u.jsx(Vl.ItemSlot,{scope:n,children:u.jsx(Hb,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ge.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,A=>{A.key==="Escape"&&(a==null||a(A.nativeEvent),A.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ie(e.onPointerDown,A=>{A.button===0&&(S.current={x:A.clientX,y:A.clientY})}),onPointerMove:ie(e.onPointerMove,A=>{if(!S.current)return;const Y=A.clientX-S.current.x,q=A.clientY-S.current.y,B=!!k.current,R=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=R?I(0,Y):0,K=R?0:I(0,q),P=A.pointerType==="touch"?10:2,O={x:U,y:K},M={originalEvent:A,delta:O};B?(k.current=O,mi(xI,h,M,{discrete:!1})):Kg(O,g.swipeDirection,P)?(k.current=O,mi(gI,d,M,{discrete:!1}),A.target.setPointerCapture(A.pointerId)):(Math.abs(Y)>P||Math.abs(q)>P)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,A=>{const Y=k.current,q=A.target;if(q.hasPointerCapture(A.pointerId)&&q.releasePointerCapture(A.pointerId),k.current=null,S.current=null,Y){const B=A.currentTarget,R={originalEvent:A,delta:Y};Kg(Y,g.swipeDirection,g.swipeThreshold)?mi(bI,f,R,{discrete:!0}):mi(vI,p,R,{discrete:!0}),B.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),CI=e=>{const{__scopeToast:t,children:n,...r}=e,o=pi(Ro,t),[s,i]=m.useState(!1),[a,l]=m.useState(!1);return EI(()=>i(!0)),m.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(io,{asChild:!0,children:u.jsx(si,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},TI="ToastTitle",Fg=m.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});Fg.displayName=TI;var kI="ToastDescription",Bg=m.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});Bg.displayName=kI;var zg="ToastAction",Hg=m.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Wg,{altText:n,asChild:!0,children:u.jsx(Yl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${zg}\`. Expected non-empty \`string\`.`),null)});Hg.displayName=zg;var Ug="ToastClose",Yl=m.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=yI(Ug,n);return u.jsx(Wg,{asChild:!0,children:u.jsx(ge.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Yl.displayName=Ug;var Wg=m.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ge.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Vg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),II(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(...Vg(r))}}),t}function mi(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?zi(o,s):o.dispatchEvent(s)}var Kg=(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 EI(e=()=>{}){const t=pt(e);Tt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function II(e){return e.nodeType===e.ELEMENT_NODE}function NI(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 Xl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var AI=Mg,qg=Dg,Gg=$g,Yg=Fg,Xg=Bg,Jg=Hg,Zg=Yl;const jI=AI,Qg=m.forwardRef(({className:e,...t},n)=>u.jsx(qg,{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}));Qg.displayName=qg.displayName;const _I=Hr.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"}}),ex=m.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Gg,{ref:r,className:oe(_I({variant:t}),e),...n}));ex.displayName=Gg.displayName;const PI=m.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));PI.displayName=Jg.displayName;const tx=m.forwardRef(({className:e,...t},n)=>u.jsx(Zg,{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(le.X,{className:"h-4 w-4"})}));tx.displayName=Zg.displayName;const nx=m.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:oe("text-sm font-semibold",e),...t}));nx.displayName=Yg.displayName;const rx=m.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:oe("text-sm opacity-90",e),...t}));rx.displayName=Xg.displayName;function RI(){const{toasts:e}=ol();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(ex,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(nx,{children:n}),r&&u.jsx(rx,{children:r})]}),o,u.jsx(tx,{})]},t)}),u.jsx(Qg,{})]})}var MI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(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[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function p(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?p():f;d(v)}catch{}},OI=m.createContext(void 0),DI={setTheme:e=>{},themes:[]},LI=()=>{var e;return(e=m.useContext(OI))!=null?e:DI};m.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 m.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${MI.toString()})(${d})`}})});var $I=e=>{switch(e){case"success":return zI;case"info":return UI;case"warning":return HI;case"error":return WI;default:return null}},FI=Array(12).fill(0),BI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},FI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),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:"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"})),HI=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"})),UI=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"})),WI=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"})),VI=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"})),KI=()=>{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},Jl=1,qI=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:Jl++,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(YI(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)||Jl++;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}},Wt=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Jl++;return Wt.addToast({title:e,...t,id:n}),n},YI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",XI=GI,JI=()=>Wt.toasts,ZI=()=>Wt.getActiveToasts();Object.assign(XI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:JI,getToasts:ZI});function QI(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))}QI(`: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 gi(e){return e.label!==void 0}var eN=3,tN="32px",nN="16px",ox=4e3,rN=356,oN=14,sN=20,iN=200;function mn(...e){return e.filter(Boolean).join(" ")}function aN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var lN=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:p,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:_,cancelButtonStyle:D,actionButtonStyle:F,className:W="",descriptionClassName:G="",duration:A,position:Y,gap:q,loadingIcon:B,expandByDefault:R,classNames:I,icons:U,closeButtonAriaLabel:K="Close toast",pauseWhenPageIsHidden:P}=e,[O,M]=b.useState(null),[L,ee]=b.useState(null),[z,$]=b.useState(!1),[Q,X]=b.useState(!1),[te,J]=b.useState(!1),[ae,ve]=b.useState(!1),[de,me]=b.useState(!1),[Ce,Te]=b.useState(0),[_e,dt]=b.useState(0),lt=b.useRef(f.duration||A||ox),Be=b.useRef(null),Fe=b.useRef(null),Le=S===0,Ye=S+1<=y,Re=f.type,$e=f.dismissible!==!1,Qe=f.className||"",It=f.descriptionClassName||"",it=b.useMemo(()=>w.findIndex(be=>be.toastId===f.id)||0,[w,f.id]),yt=b.useMemo(()=>{var be;return(be=f.closeButton)!=null?be:j},[f.closeButton,j]),St=b.useMemo(()=>f.duration||A||ox,[f.duration,A]),Ct=b.useRef(0),kt=b.useRef(0),on=b.useRef(0),Nt=b.useRef(null),[Vt,Et]=Y.split("-"),ze=b.useMemo(()=>w.reduce((be,pe,ye)=>ye>=it?be:be+pe.height,0),[w,it]),Ke=KI(),At=f.invert||p,Z=Re==="loading";kt.current=b.useMemo(()=>it*q+ze,[it,ze]),b.useEffect(()=>{lt.current=St},[St]),b.useEffect(()=>{$(!0)},[]),b.useEffect(()=>{let be=Fe.current;if(be){let pe=be.getBoundingClientRect().height;return dt(pe),x(ye=>[{toastId:f.id,height:pe,position:f.position},...ye]),()=>x(ye=>ye.filter(Me=>Me.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!z)return;let be=Fe.current,pe=be.style.height;be.style.height="auto";let ye=be.getBoundingClientRect().height;be.style.height=pe,dt(ye),x(Me=>Me.find(qe=>qe.toastId===f.id)?Me.map(qe=>qe.toastId===f.id?{...qe,height:ye}:qe):[{toastId:f.id,height:ye,position:f.position},...Me])},[z,f.title,f.description,x,f.id]);let ue=b.useCallback(()=>{X(!0),Te(kt.current),x(be=>be.filter(pe=>pe.toastId!==f.id)),setTimeout(()=>{T(f)},iN)},[f,T,x,kt]);b.useEffect(()=>{if(f.promise&&Re==="loading"||f.duration===1/0||f.type==="loading")return;let be;return C||g||P&&Ke?(()=>{if(on.current<Ct.current){let pe=new Date().getTime()-Ct.current;lt.current=lt.current-pe}on.current=new Date().getTime()})():lt.current!==1/0&&(Ct.current=new Date().getTime(),be=setTimeout(()=>{var pe;(pe=f.onAutoClose)==null||pe.call(f,f),ue()},lt.current)),()=>clearTimeout(be)},[C,g,f,Re,P,Ke,ue]),b.useEffect(()=>{f.delete&&ue()},[ue,f.delete]);function We(){var be,pe,ye;return U!=null&&U.loading?b.createElement("div",{className:mn(I==null?void 0:I.loader,(be=f==null?void 0:f.classNames)==null?void 0:be.loader,"sonner-loader"),"data-visible":Re==="loading"},U.loading):B?b.createElement("div",{className:mn(I==null?void 0:I.loader,(pe=f==null?void 0:f.classNames)==null?void 0:pe.loader,"sonner-loader"),"data-visible":Re==="loading"},B):b.createElement(BI,{className:mn(I==null?void 0:I.loader,(ye=f==null?void 0:f.classNames)==null?void 0:ye.loader),visible:Re==="loading"})}return b.createElement("li",{tabIndex:0,ref:Fe,className:mn(W,Qe,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[Re],(n=f==null?void 0:f.classNames)==null?void 0:n[Re]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":z,"data-promise":!!f.promise,"data-swiped":de,"data-removed":Q,"data-visible":Ye,"data-y-position":Vt,"data-x-position":Et,"data-index":S,"data-front":Le,"data-swiping":te,"data-dismissible":$e,"data-type":Re,"data-invert":At,"data-swipe-out":ae,"data-swipe-direction":L,"data-expanded":!!(C||R&&z),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${Q?Ce:kt.current}px`,"--initial-height":R?"auto":`${_e}px`,..._,...f.style},onDragEnd:()=>{J(!1),M(null),Nt.current=null},onPointerDown:be=>{Z||!$e||(Be.current=new Date,Te(kt.current),be.target.setPointerCapture(be.pointerId),be.target.tagName!=="BUTTON"&&(J(!0),Nt.current={x:be.clientX,y:be.clientY}))},onPointerUp:()=>{var be,pe,ye,Me;if(ae||!$e)return;Nt.current=null;let qe=Number(((be=Fe.current)==null?void 0:be.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ct=Number(((pe=Fe.current)==null?void 0:pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((ye=Be.current)==null?void 0:ye.getTime()),Pe=O==="x"?qe:ct,gt=Math.abs(Pe)/ut;if(Math.abs(Pe)>=sN||gt>.11){Te(kt.current),(Me=f.onDismiss)==null||Me.call(f,f),ee(O==="x"?qe>0?"right":"left":ct>0?"down":"up"),ue(),ve(!0),me(!1);return}J(!1),M(null)},onPointerMove:be=>{var pe,ye,Me,qe;if(!Nt.current||!$e||((pe=window.getSelection())==null?void 0:pe.toString().length)>0)return;let ct=be.clientY-Nt.current.y,ut=be.clientX-Nt.current.x,Pe=(ye=e.swipeDirections)!=null?ye:aN(Y);!O&&(Math.abs(ut)>1||Math.abs(ct)>1)&&M(Math.abs(ut)>Math.abs(ct)?"x":"y");let gt={x:0,y:0};O==="y"?(Pe.includes("top")||Pe.includes("bottom"))&&(Pe.includes("top")&&ct<0||Pe.includes("bottom")&&ct>0)&&(gt.y=ct):O==="x"&&(Pe.includes("left")||Pe.includes("right"))&&(Pe.includes("left")&&ut<0||Pe.includes("right")&&ut>0)&&(gt.x=ut),(Math.abs(gt.x)>0||Math.abs(gt.y)>0)&&me(!0),(Me=Fe.current)==null||Me.style.setProperty("--swipe-amount-x",`${gt.x}px`),(qe=Fe.current)==null||qe.style.setProperty("--swipe-amount-y",`${gt.y}px`)}},yt&&!f.jsx?b.createElement("button",{"aria-label":K,"data-disabled":Z,"data-close-button":!0,onClick:Z||!$e?()=>{}:()=>{var be;ue(),(be=f.onDismiss)==null||be.call(f,f)},className:mn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=U==null?void 0:U.close)!=null?s:VI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,Re||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:mn(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||We():null,f.type!=="loading"?f.icon||(U==null?void 0:U[Re])||$I(Re):null):null,b.createElement("div",{"data-content":"",className:mn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:mn(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:mn(G,It,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&&gi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||D,onClick:be=>{var pe,ye;gi(f.cancel)&&$e&&((ye=(pe=f.cancel).onClick)==null||ye.call(pe,be),ue())},className:mn(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&&gi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||F,onClick:be=>{var pe,ye;gi(f.action)&&((ye=(pe=f.action).onClick)==null||ye.call(pe,be),!be.defaultPrevented&&ue())},className:mn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function sx(){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 cN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?nN:tN;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 uN=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:h,duration:p,style:f,visibleToasts:v=eN,toastOptions:g,dir:x=sx(),gap:y=oN,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[_,D]=b.useState([]),[F,W]=b.useState(!1),[G,A]=b.useState(!1),[Y,q]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),B=b.useRef(null),R=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),U=b.useRef(!1),K=b.useCallback(P=>{E(O=>{var M;return(M=O.find(L=>L.id===P.id))!=null&&M.delete||Wt.dismiss(P.id),O.filter(({id:L})=>L!==P.id)})},[]);return b.useEffect(()=>Wt.subscribe(P=>{if(P.dismiss){E(O=>O.map(M=>M.id===P.id?{...M,delete:!0}:M));return}setTimeout(()=>{Mo.flushSync(()=>{E(O=>{let M=O.findIndex(L=>L.id===P.id);return M!==-1?[...O.slice(0,M),{...O[M],...P},...O.slice(M+1)]:[P,...O]})})})}),[]),b.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:O})=>{q(O?"dark":"light")})}catch{P.addListener(({matches:M})=>{try{q(M?"dark":"light")}catch(L){console.error(L)}})}},[d]),b.useEffect(()=>{T.length<=1&&W(!1)},[T]),b.useEffect(()=>{let P=O=>{var M,L;o.every(ee=>O[ee]||O.code===ee)&&(W(!0),(M=B.current)==null||M.focus()),O.code==="Escape"&&(document.activeElement===B.current||(L=B.current)!=null&&L.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),b.useEffect(()=>{if(B.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,U.current=!1)}},[B.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,O)=>{var M;let[L,ee]=P.split("-");return T.length?b.createElement("ol",{key:P,dir:x==="auto"?sx():x,tabIndex:-1,ref:B,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":L,"data-lifted":F&&T.length>1&&!s,"data-x-position":ee,style:{"--front-toast-height":`${((M=_[0])==null?void 0:M.height)||0}px`,"--width":`${rN}px`,"--gap":`${y}px`,...f,...cN(l,c)},onBlur:z=>{U.current&&!z.currentTarget.contains(z.relatedTarget)&&(U.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:z=>{z.target instanceof HTMLElement&&z.target.dataset.dismissible==="false"||U.current||(U.current=!0,I.current=z.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{G||W(!1)},onDragEnd:()=>W(!1),onPointerDown:z=>{z.target instanceof HTMLElement&&z.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},T.filter(z=>!z.position&&O===0||z.position===P).map((z,$)=>{var Q,X;return b.createElement(lN,{key:z.id,icons:S,index:$,toast:z,defaultRichColors:h,duration:(Q=g==null?void 0:g.duration)!=null?Q:p,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(X=g==null?void 0:g.closeButton)!=null?X:i,interacting:G,position:P,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:K,toasts:T.filter(te=>te.position==z.position),heights:_.filter(te=>te.position==z.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:w,expanded:F,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const dN=({...e})=>{const{theme:t="system"}=LI();return u.jsx(uN,{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.Api=Kv,H.ApiClient=Vv,H.ApiProvider=ou,H.ArtifactRenderer=Ip,H.Badge=Fp,H.Button=Ze,H.Card=al,H.CardContent=dl,H.CardDescription=ul,H.CardHeader=ll,H.CardTitle=cl,H.ChatApi=Go,H.ChatApp=Vk,H.ChatInput=Vf,H.ChatInputRow=Kf,H.ChatInterface=Or,H.ChatProviders=wr,H.ChatWidget=Gk,H.Command=Sl,H.CommandEmpty=kl,H.CommandGroup=El,H.CommandInput=Cl,H.CommandItem=Il,H.CommandList=Tl,H.DEFAULT_TIMEOUT_MS=Zc,H.Dialog=tl,H.DialogContent=Hs,H.DialogHeader=Us,H.DialogTitle=Ws,H.DropdownMenu=Ts,H.DropdownMenuContent=po,H.DropdownMenuItem=Bn,H.DropdownMenuTrigger=ks,H.FileViewerModal=up,H.HISTORY_TIMEOUT_MS=Qc,H.Input=Ml,H.InterruptPartRenderer=Ap,H.Label=bm,H.MarkdownContent=qn,H.MessageComponent=Zs,H.MessageList=ml,H.MessageRow=pl,H.NewChatButton=Yk,H.PlotArtifact=Tp,H.ResearchTaskArtifact=Ep,H.SETTINGS_STORAGE_KEY=Bi,H.ScrollArea=Rl,H.Select=NE,H.SelectContent=ig,H.SelectItem=ag,H.SelectTrigger=rg,H.SelectValue=AE,H.Separator=dg,H.Sheet=BE,H.SheetContent=wg,H.SheetDescription=Cg,H.SheetHeader=yg,H.SheetTitle=Sg,H.SheetTrigger=zE,H.SimpleChat=Kk,H.SimpleJsonView=Js,H.Sonner=dN,H.StreamProgress=jp,H.Switch=vg,H.Textarea=Ea,H.ThinkingIndicator=_p,H.ThreadListItem=hm,H.ThreadManager=oi,H.ThreadStateProvider=Iu,H.ThreadsProvider=mu,H.TimelineColumn=Sx,H.Toaster=RI,H.ToolComponent=Lp,H.Tooltip=uI,H.TooltipContent=Pg,H.TooltipProvider=cI,H.TooltipTrigger=dI,H.UserTextContent=Pp,H.applySettings=Eb,H.buildCheckpointIndex=tc,H.buildCheckpointPreviewMap=dx,H.chatApiClient=Nn,H.del=Pi,H.downloadFileById=tu,H.extractConfigFields=vi,H.fileToBase64=su,H.get=Yt,H.getChatToken=Xc,H.getCheckpointForMessage=fx,H.getCurrentSettings=kb,H.getDefaultApiConfig=Du,H.getDefaultChatSettings=Lu,H.getFileContent=Mi,H.getFileInfo=Gv,H.getMessageAttemptInfo=nc,H.getMessageDomKey=hl,H.getPreviewForMessage=xi,H.httpClient=Gt,H.hydrateHistorySnapshots=Mn,H.isEnvelope=au,H.listFiles=nu,H.loadStoredSettings=$u,H.onChatTokenChanged=Jc,H.post=qo,H.processAttachments=iu,H.put=eu,H.readNumber=oc,H.readString=Rn,H.resolveChatBaseUrl=xn,H.saveSettings=Fu,H.setChatToken=Ko,H.toPlainObject=Pn,H.unwrap=Ot,H.useApi=Jr,H.useCheckpointIndex=rc,H.useFilePreview=Mp,H.useHasChatSession=Sb,H.useParsedMessageContent=Op,H.useShallowStableValue=Pu,H.useStream=Fi,H.useStreamingHook=Fi,H.useThreadHistoryState=Cu,H.useThreadManagerViewState=gm,H.useThreadState=to,H.useThreadStateUpdater=Eu,H.useThreads=xr,H.useThreadsState=hu,H.viewFileById=qv,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=gp(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=gp(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 yp{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 Sp{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 Kn{constructor(t){this.options=t||cr,this.options.renderer=this.options.renderer||new il,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new yp,this.slugger=new Sp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,m,h,v,g,x,y,w,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(h=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]&&(T=this.options.extensions.renderers[h.type].call({parser:this},h),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(h.type))){r+=T||"";continue}switch(h.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(h.tokens),h.depth,mp(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(h.text,h.lang,h.escaped);continue}case"table":{for(f="",d="",a=h.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(h.header[s].tokens),{header:!0,align:h.align[s]});for(f+=this.renderer.tablerow(d),m="",a=h.rows.length,s=0;s<a;s++){for(c=h.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:h.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(f,m);continue}case"blockquote":{m=this.parse(h.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=h.ordered,g=h.start,x=h.loose,a=h.items.length,m="",s=0;s<a;s++)w=h.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+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=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(m=h.tokens?this.parseInline(h.tokens):h.text;o+1<E&&t[o+1].type==="text";)h=t[++o],m+=`
|
|
127
|
+
`+(h.tokens?this.parseInline(h.tokens):h.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+h.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Xs{constructor(t){this.options=t||cr}preprocess(t){return t}postprocess(t){return t}}ix(Xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function FT(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>"+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 Cp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=FT(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(DT(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&&we.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(h){f=h}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;we.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,h){if(m)return c(m);h!=null&&h!==f.text&&(f.text=h,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(we.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&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return Cp(Vn.lex,Kn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},CT(we.defaults),we},we.getDefaults=dp,we.defaults=cr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.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=we.defaults.renderer||new il;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=we.defaults.tokenizer||new sl;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=we.defaults.hooks||new Xs;for(const s in n.hooks){const i=o[s];Xs.passThroughHooks.has(s)?o[s]=a=>{if(we.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=we.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}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=Cp(Vn.lexInline,Kn.parseInline),we.Parser=Kn,we.parser=Kn.parse,we.Renderer=il,we.TextRenderer=yp,we.Lexer=Vn,we.lexer=Vn.lex,we.Tokenizer=sl,we.Slugger=Sp,we.Hooks=Xs,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,Kn.parse,Vn.lex;function qn({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 we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(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 Tp({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})}})})]})}const kp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},BT=e=>{if(!e)return kp.processing;const t=e.toLowerCase().trim();return kp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},zT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Ep({artifact:e}){const t=BT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(le.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:zT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(qn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(le.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Ip({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>cb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Ep,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Tp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const al=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));al.displayName="Card";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));ll.displayName="CardHeader";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));cl.displayName="CardTitle";const ul=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));ul.displayName="CardDescription";const dl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));dl.displayName="CardContent";const Np=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));Np.displayName="CardFooter";function Ap({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(al,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ll,{className:"pb-3",children:[u.jsx(cl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ul,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(dl,{className:"pt-0 pb-3",children:a}),u.jsx(Np,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Ze,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Ze,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const HT="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 Js({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:HT,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:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function jp({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(le.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}function _p({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Pp({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(qn,{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(Ze,{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(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}const Mp={desirability:"from-[#ffd6e6] to-[#ffb7cf]",feasibility:"from-[#fff6ca] to-[#ffe58f]",viability:"from-[#d5f2cf] to-[#b3e7b4]",other:"from-[#dfe7ff] to-[#c4d6ff]"};function fl(e){return(e.type??"other").toLowerCase()}function UT({issues:e}){if(!e.length)return null;const t=b.useMemo(()=>{const n={};return e.forEach(r=>{const o=fl(r).toUpperCase();n[o]||(n[o]=[]),n[o].push(r)}),n},[e]);return u.jsxs("div",{className:"rounded-3xl border border-muted-foreground/30 bg-background/80 p-4 shadow-lg shadow-slate-900/5",children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-muted-foreground/20 pb-2",children:[u.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Issue Sticky Notes"}),u.jsxs("div",{className:"text-xs font-semibold text-muted-foreground",children:[e.length," total"]})]}),u.jsx("div",{className:"mt-4 flex w-full flex-col gap-6",children:Object.entries(t).map(([n,r])=>u.jsxs("details",{className:"w-full rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsxs("summary",{className:"cursor-pointer text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:[n," (",r.length,")"]}),u.jsx("div",{className:"mt-3 space-y-3",children:r.map((o,s)=>{const i=o.title||o.name||`Issue ${s+1}`,a=Mp[fl(o)]?fl(o):"other";return u.jsxs("div",{className:`relative overflow-hidden rounded-2xl border border-muted-foreground/30 bg-gradient-to-br p-4 text-sm font-medium text-foreground/90 shadow-[0_20px_30px_rgba(15,23,42,0.15)] ${Mp[a]}`,children:[u.jsx("div",{className:"text-base font-semibold text-foreground",children:i}),o.description?u.jsxs("details",{className:"mt-2 rounded-xl border border-border/40 bg-background/60 p-2 text-[12px] text-foreground/80",children:[u.jsx("summary",{className:"cursor-pointer font-semibold uppercase tracking-[0.3em] text-foreground/80",children:"View description"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-foreground/80",children:o.description})]}):null]},o.id??`${n}-${s}`)})})]},n))})]})}function Rp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ol(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(h=>{a(h),c(!0)},[]),m=b.useCallback(async(h,v,g)=>{var x,y;if(!t){h.preventDefault();return}if(o[g]){h.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){h.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";f({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){h.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await nu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");f({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Op(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:rb(r),toolMeta:Di(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:ob(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Dp="data:";function WT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Dp))continue;const s=o.slice(Dp.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qr(s);i&&typeof i=="object"&&t.push(i)}return t}function VT(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!="object")return null;const t=e.issues;if(Array.isArray(t))return t;if(t&&typeof t=="object"){const n=t.issues;if(Array.isArray(n))return n}return null}function KT(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 qT(e){return b.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>WT(c.text??""));if(!r.length){const c=t.map(f=>f.text??"").join(`
|
|
129
|
+
`),d=Qr(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=KT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=br(i),l=VT(a);return l&&l.length?{kind:"issues",value:a,issues:l,event:s}:a&&typeof a=="object"&&!Array.isArray(a)?{kind:"dict",value:a,data:a,event:s}:{kind:"generic",value:a,event:s}},[e])}function Lp({message:e,viewMode:t,isStreaming:n=!1}){Di(e).name;const o=e.artifact??null,s=qT(e),i=e.content.find(f=>f.type!=="tool_call"),a=f=>{if(f==null)return null;const m=typeof f=="string"?Qr(f)??f:f;if(m&&typeof m=="object")return u.jsx(Js,{data:m});const h=typeof m=="string"?m:(()=>{try{return vr(m)}catch{return String(m??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:h})},l=f=>{if(f==null)return null;const{content:m,isMarkdown:h}=nb(f);return h?u.jsx(qn,{content:m,className:"text-current"}):a(f)},c=f=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(Js,{data:f})]}),d=()=>{if((s==null?void 0:s.kind)==="generic")return l(s.value);if(!i)return null;if(i.type==="text"){const v=(i.text??"").trim();if(!v)return null;const g=br(v);return l(g)}const f=eo(i),m=br(f);return l(m)};return u.jsxs("div",{className:"space-y-2",children:[o&&u.jsx(Ip,{artifact:o,idx:0}),u.jsx(jp,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:(s==null?void 0:s.kind)==="issues"?u.jsx(UT,{issues:s.issues}):(s==null?void 0:s.kind)==="dict"?c(s.data):d()})]})}const GT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},hl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,pl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,activeInterrupt:m,disableInterruptActions:h,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=hl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,E=y??GT,j=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:_,attemptIndex:D,attempts:F}=b.useMemo(()=>nc(t.id,j,E),[t.id,j,E]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Zs,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:f,activeInterrupt:m,disableInterruptActions:h,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:_,attemptIndex:D,attemptMetas:F,onSelectCheckpoint:w})})});pl.displayName="MessageRow";function YT(e,t,n){const[r,o]=b.useState(e),s=b.useRef([]);return b.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const c=a.text??"",d=s.current[l];return n(c)?(s.current[l]=c,a):{...a,text:d??""}});o(i)},[e,t,n]),r}function XT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:h,handleFileClick:v,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,disableInterruptActions:w,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:_,activeInterruptValue:D,iconForeground:F}){const W=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(le.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),A=YT(s,(f??!0)&&d,$p),Y=b.useMemo(()=>A.filter(O=>O.type==="text"),[A]),q=b.useMemo(()=>Y.map(O=>O.text??"").join(""),[Y]),z=b.useMemo(()=>{if(!m)return null;const O=JT(q);return{stablePart:q.slice(0,O),tailPart:q.slice(O)}},[q,m]),M=b.useMemo(()=>{if(!z)return null;const{stablePart:O,tailPart:R}=z;return!O&&!R?null:u.jsxs("div",{className:"space-y-2",children:[O?u.jsx(qn,{content:O,allowHtml:!1}):null,R?u.jsx(qn,{content:R,allowHtml:!1}):null]})},[z]),I=b.useMemo(()=>{if(!m)return A;const O=[];let R=!1;for(const L of A){if(L.type==="text"){R||(O.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),R=!0);continue}O.push(L)}return O},[A,m]),U=m?I:A,K=b.useCallback(({part:O,i:R})=>{if(O.type==="text"){if(m)return null;const L=O.text??"",ee=L.trim(),B=Qr(ee);return B&&S!=="tool"?u.jsx(Js,{data:B},R):S==="user"&&k&&ee.length>C?u.jsx(Pp,{text:ee,expanded:T,onExpandedChange:E,previewLength:C,isCompact:j},R):u.jsx(qn,{content:L,allowHtml:!1},R)}if(O.type==="image_url"){const L=O;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:L.url,alt:L.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},R)}if(O.type==="file"){const L=O,ee=L.name||"file";return u.jsxs("a",{href:L.url,onClick:B=>v(B,L,R),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
130
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[R]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ee,g[R]?" (processing)":""]})]},R)}if(O.type==="interrupt"){const L=O,ee=Xo((L==null?void 0:L.id)??(L==null?void 0:L.interrupt_id)),B=!!(_&&ee&&ee===_),$=B?D??(L==null?void 0:L.value):L==null?void 0:L.value,Q=ee?{...L,id:ee,interrupt_id:ee}:L;return u.jsx(Ap,{interruptPart:Q,onApprove:x,onReject:y,disabled:w,isActive:B,payload:$},R)}return null},[_,D,w,v,x,y,j,T,S,k,g,C,m,E]),P=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return W();if(!t&&!P&&!d)return null;if(t)return n?u.jsx(Lp,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!h){const O=u.jsx("div",{className:"space-y-2",children:U.map((R,L)=>m&&ZT(R)?M?u.jsx("div",{className:"space-y-2",children:M},`streaming-md-${L}`):null:u.jsx(K,{part:R,i:L},L))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[O,u.jsx(_p,{className:F})]}):O}return null}function $p(e){return e?!(No(e,/```/g)||No(e,/`/g)||No(e,/\*\*/g)||No(e,/__/g)||No(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function No(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function JT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if($p(e.slice(0,t)))return t;return 0}function ZT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const QT=Hr.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 Fp({className:e,variant:t,...n}){return u.jsx("div",{className:oe(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:f,toolViewMode:m,toolMeta:h,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:oe("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Fp,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),v())},children:[u.jsx("span",{children:h.name??"Tool Output"}),h.toolCallId&&u.jsx("span",{className:"opacity-70",children:h.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(le.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:oe("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Ze,{variant:"ghost",size:"sm",onClick:g,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:oe(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),f==="user"&&x&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:x,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})}),f==="assistant"&&y&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Zs=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,customStyles:m={},streamingDebounceMs:h=300,renderStreamingMarkdown:v=!1,enableStreamingMarkdownBuffer:g,onEdit:x,onRegenerate:y,onCopy:w,activeInterrupt:S,disableInterruptActions:k=!1,onInterruptActionStart:C,onInterruptActionEnd:T,attemptCount:E=1,attemptIndex:j=0,onSelectCheckpoint:_,attemptMetas:D=[]}){const[F,W]=b.useState(!1),[G,A]=b.useState("preview"),[Y,q]=b.useState(!1),{currentThreadId:z}=xr(),{respondToInterrupt:M}=to(),I=l==="phone"||l==="half-screen",U=t.role,K=U==="tool",P=b.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!P,R=!(r&&U!=="user"),{uploadingFiles:L,handleFileClick:ee,fileViewerOpen:B,currentFileInfo:$,closeFileViewer:Q}=Rp({allowFileOpen:R,currentThreadId:z}),X=b.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[U]),te=Op(t,P),{contentParts:J,imageParts:ae,fileParts:ve,interruptParts:de,textContent:me,toolMeta:Ce,toolRaw:Te,isToolStreaming:_e}=te,dt=g??h!==0,lt=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),Be=Xo(lt),Fe=S==null?void 0:S.value,Le=b.useCallback(async()=>{const Z=K?Te:me;async function ue(We){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(We);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const be=new Blob([We],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":be})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ue(Z),W(!0),setTimeout(()=>W(!1),2e3),w==null||w(Z)}catch(We){console.error("Failed to copy:",We)}},[K,Te,me,w]),Ye=b.useCallback(()=>{if(!x||!t.id)return;const Z=(K?Te:me)??"",ue="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,Z,ue)},[x,t.id,K,Te,me,t]),Me=b.useCallback(()=>{y==null||y(n)},[y,n]),$e=b.useCallback(()=>{A(Z=>Z==="expanded"?"preview":"expanded")},[]),Qe=b.useCallback(()=>{const ue=oe(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",X);switch(U){case"user":return u.jsx(le.User,{className:ue});case"assistant":return u.jsx(le.Bot,{className:ue});case"tool":return u.jsx(le.Wrench,{className:ue});default:return u.jsx(le.Bot,{className:ue})}},[I,X,U]),It=b.useCallback(()=>{const Z="group relative mb-4 flex w-full";switch(U){case"user":return oe(Z,"justify-end");case"assistant":case"tool":case"system":return oe(Z,"justify-start");default:return Z}},[U]),it=b.useCallback(()=>{const Z=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(O)return oe(Z,"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(U){case"user":return oe(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return oe(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return oe(Z,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(Z,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[I,O,U]),yt=b.useCallback(async Z=>{if(k)return;const ue=Xo((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ue){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await M(ue,!0)}catch(We){console.error("Failed to approve interrupt:",We)}finally{T==null||T()}},[k,T,C,M]),St=b.useCallback(async Z=>{if(k)return;const ue=Xo((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ue){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await M(ue,!1)}catch(We){console.error("Failed to reject interrupt:",We)}finally{T==null||T()}},[k,T,C,M]),Ct=u.jsx(XT,{message:t,isToolMessage:K,showToolMessages:f,toolViewMode:G,isToolStreaming:_e,contentParts:J,textContent:me,imageParts:ae,fileParts:ve,interruptParts:de,isStreamingMessage:r,defaultMessage:P,enableStreamingMarkdownBuffer:dt,renderStreamingMarkdown:v,handleFileClick:ee,uploadingFiles:L,handleInterruptApprove:yt,handleInterruptReject:St,disableInterruptActions:k,messageRole:U,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:Y,setIsUserExpanded:q,isCompactLayout:I,activeInterruptId:Be,activeInterruptValue:Fe,iconForeground:X}),kt=b.useMemo(()=>P?"Assistant":sb(t),[P,t]),on=Qe(),Nt=U==="user"&&(E??1)>1&&typeof _=="function",Vt=(D==null?void 0:D.length)??0,Et=Vt>0&&j<Vt-1?D[j+1]:void 0,ze=Vt>0&&j>0?D[j-1]:void 0,Ke=b.useCallback(()=>{!Et||!_||_(Et.id,void 0,!!Et.isLatestAttempt)},[Et,_]),At=b.useCallback(()=>{!ze||!_||_(ze.id,void 0,!!ze.isLatestAttempt)},[ze,_]);return K&&!f?null:O&&P?u.jsx("div",{className:oe(It(),m.container),children:u.jsxs("div",{className:oe(it(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:oe("h-4 w-4",X)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(qn,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(It(),m.container),children:u.jsxs("div",{className:oe(it(),m.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:K,iconForeground:X,agentName:kt,messageIcon:on,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:U,toolViewMode:G,toolMeta:Ce,onToggleToolView:$e,onCopy:Le,onEdit:Ye,onRegenerate:Me,showCheckpointControls:Nt,attemptCount:E,attemptIndex:j,handleOlderAttemptSelect:Ke,handleNewerAttemptSelect:At,messageCreatedAt:t.createdAt,copied:F}),u.jsx("div",{className:"relative",children:Ct}),K&&G==="expanded"&&(Ce.toolCallId||Ce.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[Ce.name&&u.jsxs("div",{children:["Function: ",Ce.name]}),Ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ce.toolCallId]})]}),!(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",m.actions),children:[u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>Le(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Copy,{className:oe(F?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="user"&&x&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:Ye,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Edit,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&y&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:Me,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),$&&u.jsx(up,{isOpen:B,onClose:Q,fileId:$.id,fileName:$.name,mimeType:$.mimeType})]})},(e,t)=>{var l,c,d,f,m,h,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&xu(e.message)===xu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].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)===((h=t.customStyles)==null?void 0:h.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=vu(e.message),a=vu(t.message);return i.length===a.length});Zs.displayName="MessageComponent";const ml=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:m,emptyMessage:h,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_,createSyntheticThinkingMessage:D=!0,forceSyntheticThinking:F=!1},W)=>{const G=b.useRef(null),A=b.useRef(null),Y=b.useRef(!1),q=b.useRef(!1),z=b.useMemo(()=>w?e.some(X=>X.role==="default_message"?!1:Array.isArray(X==null?void 0:X.content)&&X.content.some(te=>te&&te.type==="interrupt"&&(te.id??te.interrupt_id)===w.id)):!1,[w,e]),M=b.useMemo(()=>{if(!w||z)return null;const X=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let te;const J=w.value;if(J&&typeof J=="object"&&!Array.isArray(J)){const ae=J.title;typeof ae=="string"&&ae.trim()&&(te=ae.trim())}return{id:`interrupt-${X}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:X,value:J,title:te}]}},[w,z]),I=b.useMemo(()=>M?[...e,M]:e,[e,M]),U=b.useMemo(()=>{const X=n&&I.some(J=>J.id===n);return D&&(t||F)&&!X&&I.length>0?[...I,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:I},[I,t,n,D,F]),K=b.useMemo(()=>T?U:U.filter(X=>(X==null?void 0:X.role)!=="tool"),[U,T]),P=b.useCallback(X=>{x&&x(!X),y&&y(X)},[x,y]),O=b.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),R=b.useMemo(()=>!v||g?!1:"auto",[v,g]),L=b.useMemo(()=>{if(typeof h!="string")return null;const X=h.trim();return!X||K&&K.length>0?null:{id:"default-message",role:"default_message",content:X,createdAt:new Date().toISOString()}},[h,K]),ee=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),B=()=>L?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Zs,{message:L,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:h??"No messages yet. Start a conversation!"}),$=K.length,Q=$>0;return b.useEffect(()=>{var X,te;if($===0){q.current=!1;return}if(!q.current)if(q.current=!0,G.current&&K.length>0){const J=K.length-1;(te=(X=G.current).scrollToIndex)==null||te.call(X,{index:J,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},[$,K.length]),b.useImperativeHandle(W,()=>({scrollToLatest:()=>{var X,te;if(G.current&&K.length>0){const J=K.length-1;(te=(X=G.current).scrollToIndex)==null||te.call(X,{index:J,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},scrollToTop:()=>{var X,te;G.current&&K.length>0?(te=(X=G.current).scrollToIndex)==null||te.call(X,{index:0,align:"start",behavior:"auto"}):A.current&&(A.current.scrollTop=0)}}),[K]),u.jsx("div",{className:ee,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Q?u.jsx(VC,{ref:X=>{G.current=X},scrollerRef:X=>{A.current=X instanceof HTMLDivElement?X:null},data:K,followOutput:R,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{O&&O()},atBottomStateChange:P,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(X,te)=>hl(te,X),itemContent:(X,te)=>u.jsx(pl,{message:te,index:X,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_})}):B()})})});ml.displayName="MessageList";const Bp={value:""};function Or({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,payloadExtras:f={},customStyles:m={},onMessageSent:h,onExcelUploadSuccess:v,onError:g,defaultMessage:x}){const{api:y}=Jr(),{currentThreadId:w}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:_,checkpoints:D,interrupt:F,metadata:W,checkpointIndex:G}=to(),{isStreaming:A,error:Y,connectionState:q,submit:z,stop:M}=Fi(),I=S??w??null,U=(_==null?void 0:_.id)??null,K=(_==null?void 0:_.namespace)??null,P=(W==null?void 0:W.assemblingMessageId)??null,O=F,[R,L]=b.useState(!1),[ee,B]=b.useState(!1);b.useEffect(()=>{O||L(!1)},[O]);const $=b.useCallback(()=>{L(!0)},[]),Q=b.useCallback(()=>{L(!1)},[]),X=!!O||R,[te,J]=b.useState(null),[ae,ve]=b.useState(""),[de,me]=b.useState(null),[Ce,Te]=b.useState(null),[_e,dt]=b.useState(!1),[lt,Be]=b.useState(null),Fe=b.useRef(!1),[Le,Ye]=b.useState(()=>Bp.value),Me=b.useRef(Le),$e=b.useRef(null),Qe=b.useCallback(pe=>{Bp.value=pe,Ye(pe)},[]),[It,it]=b.useState(!1),yt=b.useRef(null),St=b.useCallback(pe=>{Qe(pe)},[Qe]);b.useEffect(()=>{A||B(!1)},[A]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&B(!1)},[W==null?void 0:W.assemblingMessageId]);const[Ct,kt]=b.useState("desktop");b.useEffect(()=>{const pe=()=>{const ye=window.innerWidth;kt(ye<640?"phone":ye<1024?"tablet":"desktop")};return pe(),window.addEventListener("resize",pe),()=>window.removeEventListener("resize",pe)},[]),b.useEffect(()=>{Fe.current=!1},[I]),b.useEffect(()=>{Me.current=Le},[Le]),b.useEffect(()=>{if(!te){$e.current=null;return}$e.current===null&&($e.current=Me.current),Qe(ae??"")},[ae,te,Qe]),b.useEffect(()=>{if(x!==void 0){Be(x);return}(async()=>{if(!y.baseUrl){Be(null);return}try{const Re=(await y.getAgent("default")).uiDefaultMessage||"";Be(Re||null)}catch(ye){console.warn("Failed to fetch default message:",ye),Be(null)}})()},[y.baseUrl,x]),b.useEffect(()=>{Y&&!_e&&(g==null||g(Y))},[Y,_e,g]);const on=async(pe,ye)=>{const Re=pe.trim();if(!(!Re&&ye.length===0))try{const qe=te?(de==null?void 0:de.checkpointId)??U??void 0:U??void 0,ct=te?(de==null?void 0:de.checkpointNs)??K??void 0:K??void 0;await z({text:Re||"",attachments:ye,payload:f},{checkpointId:qe,checkpointNs:ct,edit:!!te,originalMessageId:te??void 0}),h==null||h(Re),B(!0),Qe(""),Te(null),J(null),ve(""),me(null)}catch(qe){const ct=(qe==null?void 0:qe.message)||"Failed to send message";Te(ct),g==null||g(ct),B(!1)}},Nt=b.useCallback(async pe=>{await z({attachments:[pe],payload:f},{checkpointId:U??void 0,checkpointNs:K??void 0}),v==null||v({file:pe})},[U,K,f,v,z]),Vt=b.useCallback((pe,ye,Re)=>{c&&($e.current=Le,J(pe),ve(ye),Qe(ye),Te(null),me({checkpointId:(Re==null?void 0:Re.checkpointId)??null,checkpointNs:(Re==null?void 0:Re.checkpointNs)??null}))},[Le,c,Qe]),Et=b.useCallback(()=>{J(null),ve(""),me(null),Te(null),Qe($e.current??Le),$e.current=null},[Le,Qe]),ze=b.useCallback((pe,ye,Re)=>{Vt(pe,ye,Re)},[Vt]),Ke=b.useCallback(pe=>{let ye=null;for(let ut=pe-1;ut>=0;ut--)if(k[ut].role==="user"){ye=k[ut];break}if(!ye)return;const Re=Array.isArray(ye.content)?ye.content:[],ct=Re.filter(ut=>(ut==null?void 0:ut.type)==="text").map(ut=>ut.text).join("")||(()=>{try{return JSON.stringify(Re,null,2)}catch{return String(Re)}})();ct&&z({text:ct,payload:f},{checkpointId:U??void 0,checkpointNs:K??void 0,edit:!0,originalMessageId:ye.id})},[k,z,U,K,f]),At=async pe=>{if(w){it(!0);try{if(!pe){await j(),requestAnimationFrame(()=>{var qe;(qe=yt.current)==null||qe.scrollToLatest()});return}const ye=D.find(qe=>qe.checkpointId===pe),Re=(ye==null?void 0:ye.checkpointNs)??null;await E(pe,Re),requestAnimationFrame(()=>{var qe;(qe=yt.current)==null||qe.scrollToTop()})}finally{it(!1)}}},Z=b.useCallback(async(pe,ye,Re)=>{await At(Re?null:pe)},[At]),ue=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,We=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,be=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ue,children:[!!Y&&!_e&&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:Y}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>dt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${We}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(ml,{ref:yt,className:"h-full",style:{height:"100%"},messages:k,isStreaming:A,streamingAssistantId:P,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ct,enableMessageEditing:c,editingMessageId:te,onEdit:ze,onRegenerate:Ke,onCancelEdit:Et,emptyMessage:lt??void 0,isNavigatingCheckpoint:It,activeInterrupt:O,disableInterruptActions:R,onInterruptActionStart:$,onInterruptActionEnd:Q,showToolMessages:d,checkpointIndex:G,activeCheckpointId:U,onSelectCheckpoint:Z,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ee}),(q==="reconnecting"||q==="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(le.Loader2,{className:"h-3 w-3 animate-spin"}),q==="reconnecting"?"Reconnecting…":"Connecting…"]})}),q==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||It)&&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(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:be,children:[te&&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(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:Et,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),Ce&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Ce}),u.jsx(OS,{composerValue:Le,onComposerChange:St,onSend:on,onCancelEdit:Et,onStop:M,editingMessageId:te,editingInitialValue:ae,placeholder:te?"Edit your message...":t,isStreaming:A,disabled:X,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Nt,onError:g,customStyles:m,textareaClassName:m.textarea||"",allowEmptySend:!1,inputError:Ce})]})]})}var zp=1,tk=.9,nk=.8,rk=.17,gl=.1,xl=.999,ok=.9999,sk=.99,ik=/[\\\/_+.#"@\[\(\{&]/,ak=/[\\\/_+.#"@\[\(\{&]/g,lk=/[\s-]/,Hp=/[\s-]/g;function vl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?zp:sk;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,h,v;c>=0;)f=vl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=zp:ik.test(e.charAt(c-1))?(f*=nk,h=e.slice(o,c-1).match(ak),h&&o>0&&(f*=Math.pow(xl,h.length))):lk.test(e.charAt(c-1))?(f*=tk,v=e.slice(o,c-1).match(Hp),v&&o>0&&(f*=Math.pow(xl,v.length))):(f*=rk,o>0&&(f*=Math.pow(xl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ok)),(f<gl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=vl(e,t,n,r,c+1,s+2,i),m*gl>f&&(f=m*gl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Up(e){return e.toLowerCase().replace(Hp," ")}function ck(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,vl(e,t,Up(e),Up(t),0,0,{})}var Ao='[cmdk-group=""]',bl='[cmdk-group-items=""]',uk='[cmdk-group-heading=""]',Wp='[cmdk-item=""]',Vp=`${Wp}:not([aria-disabled="true"])`,wl="cmdk-item-select",Dr="data-value",dk=(e,t,n)=>ck(e,t,n),Kp=p.createContext(void 0),jo=()=>p.useContext(Kp),qp=p.createContext(void 0),yl=()=>p.useContext(qp),Gp=p.createContext(void 0),Yp=p.forwardRef((e,t)=>{let n=Lr(()=>{var P,O;return{search:"",value:(O=(P=e.value)!=null?P:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Xp(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:h,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=_t(),S=_t(),k=_t(),C=p.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),ur(()=>{T(6,G)},[]);let E=p.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,O,R)=>{var L,ee,B,$;if(!Object.is(n.current[P],O)){if(n.current[P]=O,P==="search")W(),D(),T(1,F);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Q=document.getElementById(k);Q?Q.focus():(L=document.getElementById(w))==null||L.focus()}if(T(7,()=>{var Q;n.current.selectedItemId=(Q=A())==null?void 0:Q.id,E.emit()}),R||T(5,G),((ee=a.current)==null?void 0:ee.value)!==void 0){let Q=O??"";($=(B=a.current).onValueChange)==null||$.call(B,Q);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=p.useMemo(()=>({value:(P,O,R)=>{var L;O!==((L=s.current.get(P))==null?void 0:L.value)&&(s.current.set(P,{value:O,keywords:R}),n.current.filtered.items.set(P,_(O,R)),T(2,()=>{D(),E.emit()}))},item:(P,O)=>(r.current.add(P),O&&(o.current.has(O)?o.current.get(O).add(P):o.current.set(O,new Set([P]))),T(3,()=>{W(),D(),n.current.value||F(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let R=A();T(4,()=>{W(),(R==null?void 0:R.getAttribute("id"))===P&&F(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function _(P,O){var R,L;let ee=(L=(R=a.current)==null?void 0:R.filter)!=null?L:dk;return P?ee(P,n.current.search,O):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(L=>{let ee=o.current.get(L),B=0;ee.forEach($=>{let Q=P.get($);B=Math.max(Q,B)}),O.push([L,B])});let R=C.current;Y().sort((L,ee)=>{var B,$;let Q=L.getAttribute("id"),X=ee.getAttribute("id");return((B=P.get(X))!=null?B:0)-(($=P.get(Q))!=null?$:0)}).forEach(L=>{let ee=L.closest(bl);ee?ee.appendChild(L.parentElement===ee?L:L.closest(`${bl} > *`)):R.appendChild(L.parentElement===R?L:L.closest(`${bl} > *`))}),O.sort((L,ee)=>ee[1]-L[1]).forEach(L=>{var ee;let B=(ee=C.current)==null?void 0:ee.querySelector(`${Ao}[${Dr}="${encodeURIComponent(L[0])}"]`);B==null||B.parentElement.appendChild(B)})}function F(){let P=Y().find(R=>R.getAttribute("aria-disabled")!=="true"),O=P==null?void 0:P.getAttribute(Dr);E.setState("value",O||void 0)}function W(){var P,O,R,L;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ee=0;for(let B of r.current){let $=(O=(P=s.current.get(B))==null?void 0:P.value)!=null?O:"",Q=(L=(R=s.current.get(B))==null?void 0:R.keywords)!=null?L:[],X=_($,Q);n.current.filtered.items.set(B,X),X>0&&ee++}for(let[B,$]of o.current)for(let Q of $)if(n.current.filtered.items.get(Q)>0){n.current.filtered.groups.add(B);break}n.current.filtered.count=ee}function G(){var P,O,R;let L=A();L&&(((P=L.parentElement)==null?void 0:P.firstChild)===L&&((R=(O=L.closest(Ao))==null?void 0:O.querySelector(uk))==null||R.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function A(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Wp}[aria-selected="true"]`)}function Y(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Vp))||[])}function q(P){let O=Y()[P];O&&E.setState("value",O.getAttribute(Dr))}function z(P){var O;let R=A(),L=Y(),ee=L.findIndex($=>$===R),B=L[ee+P];(O=a.current)!=null&&O.loop&&(B=ee+P<0?L[L.length-1]:ee+P===L.length?L[0]:L[ee+P]),B&&E.setState("value",B.getAttribute(Dr))}function M(P){let O=A(),R=O==null?void 0:O.closest(Ao),L;for(;R&&!L;)R=P>0?wk(R,Ao):yk(R,Ao),L=R==null?void 0:R.querySelector(Vp);L?E.setState("value",L.getAttribute(Dr)):z(P)}let I=()=>q(Y().length-1),U=P=>{P.preventDefault(),P.metaKey?I():P.altKey?M(1):z(1)},K=P=>{P.preventDefault(),P.metaKey?q(0):P.altKey?M(-1):z(-1)};return p.createElement(ge.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var O;(O=y.onKeyDown)==null||O.call(y,P);let R=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||R))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&U(P);break}case"ArrowDown":{U(P);break}case"p":case"k":{x&&P.ctrlKey&&K(P);break}case"ArrowUp":{K(P);break}case"Home":{P.preventDefault(),q(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let L=A();if(L){let ee=new Event(wl);L.dispatchEvent(ee)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:Tk},l),Qs(e,P=>p.createElement(qp.Provider,{value:E},p.createElement(Kp.Provider,{value:j},P))))}),fk=p.forwardRef((e,t)=>{var n,r;let o=_t(),s=p.useRef(null),i=p.useContext(Gp),a=jo(),l=Xp(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Jp(o,s,[e.value,e.children,s],e.keywords),f=yl(),m=Gn(T=>T.value&&T.value===d.current),h=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(wl,v),()=>T.removeEventListener(wl,v)},[h,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){f.setState("value",d.current,!0)}if(!h)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(ge.div,{ref:On(s,t),...C,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)}),hk=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=p.useRef(null),l=p.useRef(null),c=_t(),d=jo(),f=Gn(h=>o||d.filter()===!1?!0:h.search?h.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Jp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ge.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Qs(e,h=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(Gp.Provider,{value:m},h))))}),pk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:p.createElement(ge.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),mk=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=yl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=jo();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ge.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)}})}),gk=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Gn(c=>c.selectedItemId),l=jo();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let h=c.offsetHeight;d.style.setProperty("--cmdk-list-height",h.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),p.createElement(ge.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Qs(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Qa,{open:n,onOpenChange:r},p.createElement(el,{container:i},p.createElement(ko,{"cmdk-overlay":"",className:o}),p.createElement(Eo,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Yp,{ref:t,...a}))))}),vk=p.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?p.createElement(ge.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),bk=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ge.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Yp,{List:gk,Item:fk,Input:mk,Group:hk,Separator:pk,Dialog:xk,Empty:vk,Loading:bk});function wk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function yk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Xp(e){let t=p.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Lr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=yl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Jp(e,t,n,r=[]){let o=p.useRef(),s=jo();return ur(()=>{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(Dr,a),o.current=a}),o}var Sk=()=>{let[e,t]=p.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Ck(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&&p.isValidElement(t)?p.cloneElement(Ck(t),{ref:t.ref},n(t.props.children)):n(t)}var Tk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Sl.displayName=Ut.displayName;const Cl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.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})]}));Cl.displayName=Ut.Input.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Tl.displayName=Ut.List.displayName;const kl=p.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));kl.displayName=Ut.Empty.displayName;const El=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));El.displayName=Ut.Group.displayName;const kk=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));kk.displayName=Ut.Separator.displayName;const Il=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));Il.displayName=Ut.Item.displayName;function Nl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ek(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Al="ScrollArea",[Zp,HN]=ln(Al),[Ik,rn]=Zp(Al),Qp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[f,m]=p.useState(null),[h,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,j]=p.useState(!1),_=Oe(t,F=>l(F)),D=Zo(o);return u.jsx(Ik,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:h,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ge.div,{dir:D,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Qp.displayName=Al;var em="ScrollAreaViewport",tm=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(em,n),a=p.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(ge.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})})]})});tm.displayName=em;var En="ScrollAreaScrollbar",jl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Nk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(nm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(_l,{...r,ref:t}):null});jl.displayName=En;var Nk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.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(zt,{present:n||s,children:u.jsx(nm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ak=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=Ek("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 p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const h=c[d];f!==h&&(l("SCROLL"),i()),f=h};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(_l,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),nm=p.forwardRef((e,t)=>{const n=rn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.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 $r(n.viewport,l),$r(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(_l,{"data-state":s?"visible":"hidden",...o,ref:t})})}),_l=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(En,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=am(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,h){return Ok(m,i.current,a,h)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,h=lm(m,a,o.dir);s.current.style.transform=`translate3d(${h}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(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,h=lm(m,a);s.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),jk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Oe(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(om,{"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),um(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)}})}})}),_k=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Oe(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(om,{"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),um(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)}})}})}),[Pk,rm]=Zp(En),om=p.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,h=rn(En,n),[v,g]=p.useState(null),x=Oe(t,_=>g(_)),y=p.useRef(null),w=p.useRef(""),S=h.viewport,k=r.content-r.viewport,C=pt(d),T=pt(l),E=ri(f,10);function j(_){if(y.current){const D=_.clientX-y.current.left,F=_.clientY-y.current.top;c({x:D,y:F})}}return p.useEffect(()=>{const _=D=>{const F=D.target;(v==null?void 0:v.contains(F))&&C(D,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),$r(v,E),$r(h.content,E),u.jsx(Pk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(ge.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ie(e.onPointerMove,j),onPointerUp:ie(e.onPointerUp,_=>{const D=_.target;D.hasPointerCapture(_.pointerId)&&D.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,h.viewport&&(h.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",sm=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rm(ei,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(Mk,{ref:t,...r})})}),Mk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(ei,n),i=rm(ei,n),{onThumbPositionChange:a}=i,l=Oe(t,f=>i.onThumbChange(f)),c=p.useRef(void 0),d=ri(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const h=Dk(f,a);c.current=h,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ge.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:ie(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),v=f.clientX-h.left,g=f.clientY-h.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});sm.displayName=ei;var Pl="ScrollAreaCorner",im=p.forwardRef((e,t)=>{const n=rn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Rk,{...e,ref:t}):null});im.displayName=Pl;var Rk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Pl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ge.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 am(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=am(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ok(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 cm([l,c],f)(e)}function lm(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=Nl(e,l);return cm([0,i],[0,a])(c)}function cm(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 um(e,t){return e>0&&e<t}var Dk=(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=pt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function $r(e,t){const n=pt(t);Tt(()=>{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 dm=Qp,Lk=tm,$k=im;const Ml=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(dm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Lk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(fm,{}),u.jsx($k,{})]}));Ml.displayName=dm.displayName;const fm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(jl,{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(sm,{className:"relative flex-1 rounded-full bg-border"})}));fm.displayName=jl.displayName;const Rl=p.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}));Rl.displayName="Input";const Fk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Bk="bg-slate-700 border-slate-600 hover:bg-slate-600",zk="bg-slate-600 border-slate-500";function hm({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:h,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??zk}`:`${x??Bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Fk} ${S}`,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:C=>C.stopPropagation(),children:[u.jsx(Rl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.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(le.Calendar,{size:10}),u.jsx("span",{children:h(e.updatedAt||e.createdAt)})]}),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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Ze,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(po,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(le.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"})]})}const pm=25,mm="thread-manager-view",Hk=e=>e==="default"||e==="shared",Uk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(mm);if(Hk(e))return e}catch{}return null};function gm({defaultView:e}={}){const[t,n]=b.useState(()=>Uk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(mm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Wk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function oi({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:h,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:_,actions:D,shareInFlight:F,shareStatus:W,clearShareStatus:G}=xr(),{createThread:A,deleteThread:Y,renameThread:q,shareThread:z}=D,{loadThread:M}=to(),I=i??T,[U,K]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(U.length>0),O=b.useRef(null),R=b.useRef(0),[L,ee]=b.useState(null),[B,$]=b.useState(""),[Q,X]=b.useState(!1),[te,J]=b.useState(!1),[ae,ve]=b.useState(null),[de,me]=b.useState(""),Ce=v&&v.length>0?v:Wk,Te=gm({defaultView:m}),_e=g??Te,dt=f??_e.view,lt=b.useCallback(Z=>{f||_e.setView(Z),h==null||h(Z)},[f,h,_e]),Be=Ce.find(Z=>Z.key===dt)??Ce[0],Fe=Z=>{ve(Z),me(""),J(!0)},Le=()=>{J(!1),ve(null),me(""),G()},Ye=b.useCallback(async Z=>{if(!(!ae||F)&&Z.id)try{await z(ae,Z.id),setTimeout(()=>Le(),600)}catch(ue){console.error("Failed to share thread:",ue)}},[Le,F,ae,z]),Me=b.useMemo(()=>{const Z=y??[],ue=de.trim().toLowerCase();return ue?S?Z.filter(We=>S(We,ue)):Z.filter(We=>`${We.label} ${We.secondaryLabel??""}`.toLowerCase().includes(ue)):Z},[y,de,S]),$e=dt==="shared",Qe=$e?C:U,It=$e?_:j,it=$e?"No shared conversations yet":"No conversations yet",yt=Z=>{const ue=Z.sharedAt?` • ${ze(Z.sharedAt)}`:"";return`Shared by ${Z.sharedByUserId}${ue}`},St=Z=>"sharedByUserId"in Z;b.useEffect(()=>{const Z=Array.isArray(k)?k:[];if(Z.length>0){P.current=!0,K(Z);return}j||(P.current=!1,K(Z))},[k,j]),b.useEffect(()=>{if(!O.current)return;const Z=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!Z)return;let ue=null,We=null;return ue=requestAnimationFrame(()=>{We=requestAnimationFrame(()=>{Z.scrollTop=R.current})}),()=>{ue!==null&&cancelAnimationFrame(ue),We!==null&&cancelAnimationFrame(We)}},[U]);const Ct=async Z=>{try{E(Z),await M(Z),a==null||a(Z),l==null||l(Z)}catch(ue){console.error("Failed to select thread:",ue)}},kt=async()=>{try{X(!0);const Z=await A();Z&&(c==null||c(Z),a==null||a(Z))}catch(Z){console.error("Failed to create thread:",Z)}finally{X(!1)}},on=async(Z,ue)=>{if(ue.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const We=O.current.querySelector("[data-radix-scroll-area-viewport]");We&&(R.current=We.scrollTop)}try{await Y(Z),d==null||d(Z)}catch(We){console.error("Failed to delete thread:",We)}}},Nt=(Z,ue)=>{ue.stopPropagation(),ee(Z.threadId),$(Z.title||`Thread ${Z.threadId.slice(0,8)}`)},Vt=async Z=>{if(B.trim())try{await q(Z,B.trim()),ee(null),$("")}catch(ue){console.error("Failed to update title:",ue)}},Et=()=>{ee(null),$("")},ze=Z=>{if(!Z)return"";try{const ue=new Date(Z),be=new Date().getTime()-ue.getTime(),pe=Math.floor(be/(1e3*60*60*24));return pe===0?ue.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe===1?"Yesterday":pe<7?`${pe} days ago`:ue.toLocaleDateString()}catch{return""}},Ke=Z=>Z.title||`Thread ${Z.threadId.slice(0,8)}`,At=Z=>{const ue=Ke(Z);return ue.length<=pm?ue:`${ue.slice(0,pm)}...`};return u.jsxs("div",{className:`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(Ze,{onClick:kt,disabled:Q||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Q?"Creating...":"New Chat",children:[u.jsx(le.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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Ze,{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:Be.label})}),u.jsx(po,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(Z=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:ue=>{ue.preventDefault(),lt(Z.key)},children:[u.jsx("span",{children:Z.label}),dt===Z.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},Z.key))})]})]})]}),u.jsx(Ml,{ref:O,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:It?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Qe.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.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:it})]}):Qe.slice().sort((Z,ue)=>new Date(ue.updatedAt||ue.createdAt||"").getTime()-new Date(Z.updatedAt||Z.createdAt||"").getTime()).map(Z=>u.jsx(hm,{thread:Z,isActive:I===Z.threadId,editingThreadId:L,editingTitle:B,onSelect:Ct,onStartEditing:Nt,onEditingTitleChange:ue=>$(ue),onSaveEditing:Vt,onCancelEditing:Et,onShare:()=>Fe(Z.threadId),onDelete:on,showEditTitle:r,showDeleteButton:n,formatDate:ze,getDisplayThreadTitle:At,secondaryLine:$e&&St(Z)?yt(Z):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Z.threadId))})}),u.jsx(tl,{open:te,onOpenChange:Z=>!Z&&Le(),children:u.jsxs(Hs,{className:"max-w-md p-0",children:[u.jsx(Us,{children:u.jsx(Ws,{children:"Share thread"})}),u.jsxs(Sl,{children:[u.jsx(Cl,{autoFocus:!0,value:de,onValueChange:Z=>me(Z),placeholder:"Search for recipients..."}),u.jsxs(Tl,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(le.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(kl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Me.length>0&&u.jsx(El,{heading:"Recipients",children:Me.map(Z=>u.jsx(Il,{onSelect:()=>Ye(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 Vk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(wr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(wr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function qk({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(le.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(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(oi,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Gk({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(wr,{...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(Ze,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Ze,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Ze,{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(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(qk,{placeholder:t,onMessageSent:r})})]})})}):null}function Yk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Ze,{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(le.Edit3,{size:16}),t??e]})}var Xk="Label",xm=p.forwardRef((e,t)=>u.jsx(ge.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())}}));xm.displayName=Xk;var vm=xm;const Jk=Hr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),bm=p.forwardRef(({className:e,...t},n)=>u.jsx(vm,{ref:n,className:oe(Jk(),e),...t}));bm.displayName=vm.displayName;function wm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ym=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"}),Zk="VisuallyHidden",si=p.forwardRef((e,t)=>u.jsx(ge.span,{...e,ref:t,style:{...ym,...e.style}}));si.displayName=Zk;var Qk=si,eE=[" ","Enter","ArrowUp","ArrowDown"],tE=[" ","Enter"],dr="Select",[ii,ai,nE]=Jo(dr),[Fr,UN]=ln(dr,[nE,Ir]),li=Ir(),[rE,Yn]=Fr(dr),[oE,sE]=Fr(dr),Sm=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:h,form:v}=e,g=li(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Zo(c),[E,j]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[_,D]=Dn({prop:i,defaultProp:a,onChange:l,caller:dr}),F=p.useRef(null),W=x?v||!!x.closest("form"):!0,[G,A]=p.useState(new Set),Y=Array.from(G).map(q=>q.props.value).join(";");return u.jsx(ia,{...g,children:u.jsxs(rE,{required:h,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:_t(),value:_,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(ii.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(q=>{A(z=>new Set(z).add(q))},[]),onNativeOptionRemove:p.useCallback(q=>{A(z=>{const M=new Set(z);return M.delete(q),M})},[]),children:n})}),W?u.jsxs(Km,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:q=>D(q.target.value),disabled:m,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},Y):null]})})};Sm.displayName=dr;var Cm="SelectTrigger",Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=li(n),i=Yn(Cm,n),a=i.disabled||r,l=Oe(t,i.onTriggerChange),c=ai(n),d=p.useRef("touch"),[f,m,h]=Gm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Ym(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),h()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(aa,{asChild:!0,...s,children:u.jsx(ge.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":qm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(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:ie(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&eE.includes(g.key)&&(v(),g.preventDefault())})})})});Tm.displayName=Cm;var km="SelectValue",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(km,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Oe(t,l.onValueNodeChange);return Tt(()=>{c(d)},[c,d]),u.jsx(ge.span,{...a,ref:f,style:{pointerEvents:"none"},children:qm(l.value)?u.jsx(u.Fragment,{children:i}):s})});Em.displayName=km;var iE="SelectIcon",Im=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ge.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Im.displayName=iE;var aE="SelectPortal",Nm=e=>u.jsx(io,{asChild:!0,...e});Nm.displayName=aE;var fr="SelectContent",Am=p.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=p.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(u.jsx(jm,{scope:e.__scopeSelect,children:u.jsx(ii.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(_m,{...e,ref:t})});Am.displayName=fr;var pn=10,[jm,Xn]=Fr(fr),lE="SelectContentImpl",cE=qt.createSlot("SelectContent.RemoveScroll"),_m=p.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:h,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Yn(fr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=Oe(t,B=>k(B)),[j,_]=p.useState(null),[D,F]=p.useState(null),W=ai(n),[G,A]=p.useState(!1),Y=p.useRef(!1);p.useEffect(()=>{if(S)return ha(S)},[S]),Wi();const q=p.useCallback(B=>{const[$,...Q]=W().map(J=>J.ref.current),[X]=Q.slice(-1),te=document.activeElement;for(const J of B)if(J===te||(J==null||J.scrollIntoView({block:"nearest"}),J===$&&C&&(C.scrollTop=0),J===X&&C&&(C.scrollTop=C.scrollHeight),J==null||J.focus(),document.activeElement!==te))return},[W,C]),z=p.useCallback(()=>q([j,S]),[q,j,S]);p.useEffect(()=>{G&&z()},[G,z]);const{onOpenChange:M,triggerPointerDownPosRef:I}=w;p.useEffect(()=>{if(S){let B={x:0,y:0};const $=X=>{var te,J;B={x:Math.abs(Math.round(X.pageX)-(((te=I.current)==null?void 0:te.x)??0)),y:Math.abs(Math.round(X.pageY)-(((J=I.current)==null?void 0:J.y)??0))}},Q=X=>{B.x<=10&&B.y<=10?X.preventDefault():S.contains(X.target)||M(!1),document.removeEventListener("pointermove",$),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",Q,{capture:!0})}}},[S,M,I]),p.useEffect(()=>{const B=()=>M(!1);return window.addEventListener("blur",B),window.addEventListener("resize",B),()=>{window.removeEventListener("blur",B),window.removeEventListener("resize",B)}},[M]);const[U,K]=Gm(B=>{const $=W().filter(te=>!te.disabled),Q=$.find(te=>te.ref.current===document.activeElement),X=Ym($,B,Q);X&&setTimeout(()=>X.ref.current.focus())}),P=p.useCallback((B,$,Q)=>{const X=!Y.current&&!Q;(w.value!==void 0&&w.value===$||X)&&(_(B),X&&(Y.current=!0))},[w.value]),O=p.useCallback(()=>S==null?void 0:S.focus(),[S]),R=p.useCallback((B,$,Q)=>{const X=!Y.current&&!Q;(w.value!==void 0&&w.value===$||X)&&F(B)},[w.value]),L=r==="popper"?Ol:Pm,ee=L===Ol?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(jm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:j,onItemLeave:O,itemTextRefCallback:R,focusSelectedItem:z,selectedItemText:D,position:r,isPositioned:G,searchRef:U,children:u.jsx(vs,{as:cE,allowPinchZoom:!0,children:u.jsx(Qo,{asChild:!0,trapped:w.open,onMountAutoFocus:B=>{B.preventDefault()},onUnmountAutoFocus:ie(o,B=>{var $;($=w.trigger)==null||$.focus({preventScroll:!0}),B.preventDefault()}),children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:B=>B.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:B=>B.preventDefault(),...y,...ee,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,B=>{const $=B.ctrlKey||B.altKey||B.metaKey;if(B.key==="Tab"&&B.preventDefault(),!$&&B.key.length===1&&K(B.key),["ArrowUp","ArrowDown","Home","End"].includes(B.key)){let X=W().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(B.key)&&(X=X.slice().reverse()),["ArrowUp","ArrowDown"].includes(B.key)){const te=B.target,J=X.indexOf(te);X=X.slice(J+1)}setTimeout(()=>q(X)),B.preventDefault()}})})})})})})});_m.displayName=lE;var uE="SelectItemAlignedPosition",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),f=Oe(t,E=>d(E)),m=ai(n),h=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const te=D.left-j.left,J=_.left-te,ae=E.left-J,ve=E.width+ae,de=Math.max(ve,j.width),me=window.innerWidth-pn,Ce=Nl(J,[pn,Math.max(pn,me-de)]);a.style.minWidth=ve+"px",a.style.left=Ce+"px"}else{const te=j.right-D.right,J=window.innerWidth-_.right-te,ae=window.innerWidth-E.right-J,ve=E.width+ae,de=Math.max(ve,j.width),me=window.innerWidth-pn,Ce=Nl(J,[pn,Math.max(pn,me-de)]);a.style.minWidth=ve+"px",a.style.right=Ce+"px"}const F=m(),W=window.innerHeight-pn*2,G=g.scrollHeight,A=window.getComputedStyle(c),Y=parseInt(A.borderTopWidth,10),q=parseInt(A.paddingTop,10),z=parseInt(A.borderBottomWidth,10),M=parseInt(A.paddingBottom,10),I=Y+q+G+M+z,U=Math.min(x.offsetHeight*5,I),K=window.getComputedStyle(g),P=parseInt(K.paddingTop,10),O=parseInt(K.paddingBottom,10),R=E.top+E.height/2-pn,L=W-R,ee=x.offsetHeight/2,B=x.offsetTop+ee,$=Y+q+B,Q=I-$;if($<=R){const te=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const J=c.clientHeight-g.offsetTop-g.offsetHeight,ae=Math.max(L,ee+(te?O:0)+J+z),ve=$+ae;a.style.height=ve+"px"}else{const te=F.length>0&&x===F[0].ref.current;a.style.top="0px";const ae=Math.max(R,Y+g.offsetTop+(te?P:0)+ee)+Q;a.style.height=ae+"px",g.scrollTop=$-R+g.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=W+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Tt(()=>S(),[S]);const[k,C]=p.useState();Tt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(fE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ge.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=uE;var dE="SelectPopperPosition",Ol=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=li(n);return u.jsx(la,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ol.displayName=dE;var[fE,Dl]=Fr(fr,{}),Ll="SelectViewport",Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Ll,n),i=Dl(Ll,n),a=Oe(t,s.onViewportChange),l=p.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(ii.Slot,{scope:n,children:u.jsx(ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const h=Math.abs(l.current-d.scrollTop);if(h>0){const v=window.innerHeight-pn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const w=y+h,S=Math.min(v,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Mm.displayName=Ll;var Rm="SelectGroup",[hE,pE]=Fr(Rm),mE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(hE,{scope:n,id:o,children:u.jsx(ge.div,{role:"group","aria-labelledby":o,...r,ref:t})})});mE.displayName=Rm;var Om="SelectLabel",Dm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=pE(Om,n);return u.jsx(ge.div,{id:o.id,...r,ref:t})});Dm.displayName=Om;var ci="SelectItem",[gE,Lm]=Fr(ci),$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ci,n),l=Xn(ci,n),c=a.value===r,[d,f]=p.useState(s??""),[m,h]=p.useState(!1),v=Oe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=_t(),x=p.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(gE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ii.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ge.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:ie(i.onFocus,()=>h(!0)),onBlur:ie(i.onBlur,()=>h(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(tE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});$m.displayName=ci;var _o="SelectItemText",Fm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(_o,n),a=Xn(_o,n),l=Lm(_o,n),c=sE(_o,n),[d,f]=p.useState(null),m=Oe(t,y=>f(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),h=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Tt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ge.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ur.createPortal(s.children,i.valueNode):null]})});Fm.displayName=_o;var Bm="SelectItemIndicator",zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Lm(Bm,n).isSelected?u.jsx(ge.span,{"aria-hidden":!0,...r,ref:t}):null});zm.displayName=Bm;var $l="SelectScrollUpButton",Hm=p.forwardRef((e,t)=>{const n=Xn($l,e.__scopeSelect),r=Dl($l,e.__scopeSelect),[o,s]=p.useState(!1),i=Oe(t,r.onScrollButtonChange);return Tt(()=>{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(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Hm.displayName=$l;var Fl="SelectScrollDownButton",Um=p.forwardRef((e,t)=>{const n=Xn(Fl,e.__scopeSelect),r=Dl(Fl,e.__scopeSelect),[o,s]=p.useState(!1),i=Oe(t,r.onScrollButtonChange);return Tt(()=>{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(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Um.displayName=Fl;var Wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=p.useRef(null),a=ai(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Tt(()=>{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(ge.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),xE="SelectSeparator",Vm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ge.div,{"aria-hidden":!0,...r,ref:t})});Vm.displayName=xE;var Bl="SelectArrow",vE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=li(n),s=Yn(Bl,n),i=Xn(Bl,n);return s.open&&i.position==="popper"?u.jsx(ca,{...o,...r,ref:t}):null});vE.displayName=Bl;var bE="SelectBubbleInput",Km=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Oe(r,o),i=wm(t);return p.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(ge.select,{...n,style:{...ym,...n.style},ref:s,defaultValue:t})});Km.displayName=bE;function qm(e){return e===""||e===void 0}function Gm(e){const t=pt(e),n=p.useRef(""),r=p.useRef(0),o=p.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=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Ym(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=wE(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 wE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yE=Sm,Xm=Tm,SE=Em,CE=Im,TE=Nm,Jm=Am,kE=Mm,Zm=Dm,Qm=$m,EE=Fm,IE=zm,eg=Hm,tg=Um,ng=Vm;const NE=yE,AE=SE,rg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Xm,{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(CE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));rg.displayName=Xm.displayName;const og=p.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=p.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));sg.displayName=tg.displayName;const ig=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(TE,{children:u.jsxs(Jm,{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(og,{}),u.jsx(kE,{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(sg,{})]})}));ig.displayName=Jm.displayName;const jE=p.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=Zm.displayName;const ag=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Qm,{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(IE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(EE,{children:t})]}));ag.displayName=Qm.displayName;const _E=p.forwardRef(({className:e,...t},n)=>u.jsx(ng,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));_E.displayName=ng.displayName;var PE="Separator",lg="horizontal",ME=["horizontal","vertical"],cg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=lg,...o}=e,s=RE(r)?r:lg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ge.div,{"data-orientation":s,...a,...o,ref:t})});cg.displayName=PE;function RE(e){return ME.includes(e)}var ug=cg;const dg=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ug,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dg.displayName=ug.displayName;var ui="Switch",[OE,WN]=ln(ui),[DE,LE]=OE(ui),fg=p.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,h]=p.useState(null),v=Oe(t,S=>h(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ui});return u.jsxs(DE,{scope:n,checked:y,disabled:a,children:[u.jsx(ge.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":gg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(mg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});fg.displayName=ui;var hg="SwitchThumb",pg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LE(hg,n);return u.jsx(ge.span,{"data-state":gg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pg.displayName=hg;var $E="SwitchBubbleInput",mg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Oe(i,s),l=wm(n),c=yd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&h){const v=new Event("click",{bubbles:r});h.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}})});mg.displayName=$E;function gg(e){return e?"checked":"unchecked"}var xg=fg,FE=pg;const vg=p.forwardRef(({className:e,...t},n)=>u.jsx(xg,{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(FE,{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")})}));vg.displayName=xg.displayName;const BE=Qa,zE=mT,HE=el,bg=p.forwardRef(({className:e,...t},n)=>u.jsx(ko,{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}));bg.displayName=ko.displayName;const UE=Hr.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"}}),wg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(HE,{children:[u.jsx(bg,{}),u.jsxs(Eo,{ref:o,className:oe(UE({side:e}),t),...r,children:[n,u.jsxs(ap,{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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wg.displayName=Eo.displayName;const yg=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});yg.displayName="SheetHeader";const Sg=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Sg.displayName=lr.displayName;const Cg=p.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Cg.displayName=zs.displayName;var[di,VN]=ln("Tooltip",[Ir]),fi=Ir(),Tg="TooltipProvider",WE=700,zl="tooltip.open",[VE,Hl]=di(Tg),kg=e=>{const{__scopeTooltip:t,delayDuration:n=WE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(VE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};kg.displayName=Tg;var Po="Tooltip",[KE,hi]=di(Po),Eg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Hl(Po,e.__scopeTooltip),c=fi(t),[d,f]=p.useState(null),m=_t(),h=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(zl))):l.onClose(),s==null||s(E)},caller:Po}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{x.current=!0,w(!0),h.current=0},g)},[g,w]);return p.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),u.jsx(ia,{...c,children:u.jsx(KE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(h.current),h.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};Eg.displayName=Po;var Ul="TooltipTrigger",Ig=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(Ul,n),s=Hl(Ul,n),i=fi(n),a=p.useRef(null),l=Oe(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),f=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(aa,{asChild:!0,...i,children:u.jsx(ge.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});Ig.displayName=Ul;var qE="TooltipPortal",[KN,GE]=di(qE,{forceMount:void 0}),Br="TooltipContent",Ng=p.forwardRef((e,t)=>{const n=GE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Br,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ag,{side:o,...s,ref:t}):u.jsx(YE,{side:o,...s,ref:t})})}),YE=p.forwardRef((e,t)=>{const n=hi(Br,e.__scopeTooltip),r=Hl(Br,e.__scopeTooltip),o=p.useRef(null),s=Oe(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=p.useCallback(()=>{a(null),f(!1)},[f]),h=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=eI(y,x.getBoundingClientRect()),S=tI(y,w),k=nI(g.getBoundingClientRect()),C=oI([...S,...k]);a(C),f(!0)},[f]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>h(x,d),g=x=>h(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,h,m]),p.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)),S=!rI(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Ag,{...e,ref:s})}),[XE,JE]=di(Po,{isInside:!1}),ZE=qt.createSlottable("TooltipContent"),Ag=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=hi(Br,n),c=fi(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(zl,d),()=>document.removeEventListener(zl,d)),[d]),p.useEffect(()=>{if(l.trigger){const f=m=>{const h=m.target;h!=null&&h.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(la,{"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(ZE,{children:r}),u.jsx(XE,{scope:n,isInside:!0,children:u.jsx(Qk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Ng.displayName=Br;var jg="TooltipArrow",QE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=fi(n);return JE(jg,n).isInside?null:u.jsx(ca,{...o,...r,ref:t})});QE.displayName=jg;function eI(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 tI(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 nI(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 rI(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 oI(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),sI(t)}function sI(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 iI=kg,aI=Eg,lI=Ig,_g=Ng;const cI=iI,uI=aI,dI=lI,Pg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(_g,{ref:r,sideOffset:t,className:oe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Pg.displayName=_g.displayName;var Wl="ToastProvider",[Vl,fI,hI]=Jo("Toast"),[Mg,qN]=ln("Toast",[hI]),[pI,pi]=Mg(Wl),Rg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),f=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Wl}\`. Expected non-empty \`string\`.`),u.jsx(Vl.Provider,{scope:t,children:u.jsx(pI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(h=>h+1),[]),onToastRemove:p.useCallback(()=>d(h=>h-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Rg.displayName=Wl;var Og="ToastViewport",mI=["F8"],Kl="toast.viewportPause",ql="toast.viewportResume",Dg=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=mI,label:o="Notifications ({hotkey})",...s}=e,i=pi(Og,n),a=fI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),f=p.useRef(null),m=Oe(t,f,i.onViewportChange),h=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=f.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(ql);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...NI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=f.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,_=w.shiftKey;if(w.target===x&&_){(C=c.current)==null||C.focus();return}const W=g({tabbingDirection:_?"backwards":"forwards"}),G=W.findIndex(A=>A===j);Xl(W.slice(G+1))?w.preventDefault():_?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Ub,{ref:l,role:"region","aria-label":o.replace("{hotkey}",h),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Gl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Xl(x)}}),u.jsx(Vl.Slot,{scope:n,children:u.jsx(ge.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Gl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Xl(x)}})]})});Dg.displayName=Og;var Lg="ToastFocusProxy",Gl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=pi(Lg,n);return u.jsx(si,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Gl.displayName=Lg;var Mo="Toast",gI="toast.swipeStart",xI="toast.swipeMove",vI="toast.swipeCancel",bI="toast.swipeEnd",$g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:Mo});return u.jsx(zt,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(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:ie(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:ie(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)})})})});$g.displayName=Mo;var[wI,yI]=Mg(Mo,{onClose(){}}),SI=p.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:h,...v}=e,g=pi(Mo,n),[x,y]=p.useState(null),w=Oe(t,A=>y(A)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),j=p.useRef(0),{onToastAdd:_,onToastRemove:D}=g,F=pt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),W=p.useCallback(A=>{!A||A===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(F,A))},[F]);p.useEffect(()=>{const A=g.viewport;if(A){const Y=()=>{W(E.current),c==null||c()},q=()=>{const z=new Date().getTime()-T.current;E.current=E.current-z,window.clearTimeout(j.current),l==null||l()};return A.addEventListener(Kl,q),A.addEventListener(ql,Y),()=>{A.removeEventListener(Kl,q),A.removeEventListener(ql,Y)}}},[g.viewport,C,l,c,W]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&W(C)},[s,C,g.isClosePausedRef,W]),p.useEffect(()=>(_(),()=>D()),[_,D]);const G=p.useMemo(()=>x?Vg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(CI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(wI,{scope:n,onClose:F,children:Ur.createPortal(u.jsx(Vl.ItemSlot,{scope:n,children:u.jsx(Hb,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ge.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,A=>{A.key==="Escape"&&(a==null||a(A.nativeEvent),A.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ie(e.onPointerDown,A=>{A.button===0&&(S.current={x:A.clientX,y:A.clientY})}),onPointerMove:ie(e.onPointerMove,A=>{if(!S.current)return;const Y=A.clientX-S.current.x,q=A.clientY-S.current.y,z=!!k.current,M=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=M?I(0,Y):0,K=M?0:I(0,q),P=A.pointerType==="touch"?10:2,O={x:U,y:K},R={originalEvent:A,delta:O};z?(k.current=O,mi(xI,f,R,{discrete:!1})):Kg(O,g.swipeDirection,P)?(k.current=O,mi(gI,d,R,{discrete:!1}),A.target.setPointerCapture(A.pointerId)):(Math.abs(Y)>P||Math.abs(q)>P)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,A=>{const Y=k.current,q=A.target;if(q.hasPointerCapture(A.pointerId)&&q.releasePointerCapture(A.pointerId),k.current=null,S.current=null,Y){const z=A.currentTarget,M={originalEvent:A,delta:Y};Kg(Y,g.swipeDirection,g.swipeThreshold)?mi(bI,h,M,{discrete:!0}):mi(vI,m,M,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),CI=e=>{const{__scopeToast:t,children:n,...r}=e,o=pi(Mo,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return EI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(io,{asChild:!0,children:u.jsx(si,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},TI="ToastTitle",Fg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});Fg.displayName=TI;var kI="ToastDescription",Bg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});Bg.displayName=kI;var zg="ToastAction",Hg=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Wg,{altText:n,asChild:!0,children:u.jsx(Yl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${zg}\`. Expected non-empty \`string\`.`),null)});Hg.displayName=zg;var Ug="ToastClose",Yl=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=yI(Ug,n);return u.jsx(Wg,{asChild:!0,children:u.jsx(ge.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Yl.displayName=Ug;var Wg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ge.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Vg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),II(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(...Vg(r))}}),t}function mi(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?zi(o,s):o.dispatchEvent(s)}var Kg=(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 EI(e=()=>{}){const t=pt(e);Tt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function II(e){return e.nodeType===e.ELEMENT_NODE}function NI(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 Xl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var AI=Rg,qg=Dg,Gg=$g,Yg=Fg,Xg=Bg,Jg=Hg,Zg=Yl;const jI=AI,Qg=p.forwardRef(({className:e,...t},n)=>u.jsx(qg,{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}));Qg.displayName=qg.displayName;const _I=Hr.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"}}),ex=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Gg,{ref:r,className:oe(_I({variant:t}),e),...n}));ex.displayName=Gg.displayName;const PI=p.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));PI.displayName=Jg.displayName;const tx=p.forwardRef(({className:e,...t},n)=>u.jsx(Zg,{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(le.X,{className:"h-4 w-4"})}));tx.displayName=Zg.displayName;const nx=p.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:oe("text-sm font-semibold",e),...t}));nx.displayName=Yg.displayName;const rx=p.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:oe("text-sm opacity-90",e),...t}));rx.displayName=Xg.displayName;function MI(){const{toasts:e}=ol();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(ex,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(nx,{children:n}),r&&u.jsx(rx,{children:r})]}),o,u.jsx(tx,{})]},t)}),u.jsx(Qg,{})]})}var RI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(h){(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[h]?s[h]:h)):l.setAttribute(v,h)}),f(h)}function f(h){a&&c.includes(h)&&(l.style.colorScheme=h)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let h=localStorage.getItem(t)||n,v=i&&h==="system"?m():h;d(v)}catch{}},OI=p.createContext(void 0),DI={setTheme:e=>{},themes:[]},LI=()=>{var e;return(e=p.useContext(OI))!=null?e:DI};p.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 p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${RI.toString()})(${d})`}})});var $I=e=>{switch(e){case"success":return zI;case"info":return UI;case"warning":return HI;case"error":return WI;default:return null}},FI=Array(12).fill(0),BI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},FI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),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:"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"})),HI=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"})),UI=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"})),WI=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"})),VI=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"})),KI=()=>{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},Jl=1,qI=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:Jl++,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(YI(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)||Jl++;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}},Wt=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Jl++;return Wt.addToast({title:e,...t,id:n}),n},YI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",XI=GI,JI=()=>Wt.toasts,ZI=()=>Wt.getActiveToasts();Object.assign(XI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:JI,getToasts:ZI});function QI(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))}QI(`: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 gi(e){return e.label!==void 0}var eN=3,tN="32px",nN="16px",ox=4e3,rN=356,oN=14,sN=20,iN=200;function mn(...e){return e.filter(Boolean).join(" ")}function aN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var lN=e=>{var t,n,r,o,s,i,a,l,c,d,f;let{invert:m,toast:h,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:_,cancelButtonStyle:D,actionButtonStyle:F,className:W="",descriptionClassName:G="",duration:A,position:Y,gap:q,loadingIcon:z,expandByDefault:M,classNames:I,icons:U,closeButtonAriaLabel:K="Close toast",pauseWhenPageIsHidden:P}=e,[O,R]=b.useState(null),[L,ee]=b.useState(null),[B,$]=b.useState(!1),[Q,X]=b.useState(!1),[te,J]=b.useState(!1),[ae,ve]=b.useState(!1),[de,me]=b.useState(!1),[Ce,Te]=b.useState(0),[_e,dt]=b.useState(0),lt=b.useRef(h.duration||A||ox),Be=b.useRef(null),Fe=b.useRef(null),Le=S===0,Ye=S+1<=y,Me=h.type,$e=h.dismissible!==!1,Qe=h.className||"",It=h.descriptionClassName||"",it=b.useMemo(()=>w.findIndex(be=>be.toastId===h.id)||0,[w,h.id]),yt=b.useMemo(()=>{var be;return(be=h.closeButton)!=null?be:j},[h.closeButton,j]),St=b.useMemo(()=>h.duration||A||ox,[h.duration,A]),Ct=b.useRef(0),kt=b.useRef(0),on=b.useRef(0),Nt=b.useRef(null),[Vt,Et]=Y.split("-"),ze=b.useMemo(()=>w.reduce((be,pe,ye)=>ye>=it?be:be+pe.height,0),[w,it]),Ke=KI(),At=h.invert||m,Z=Me==="loading";kt.current=b.useMemo(()=>it*q+ze,[it,ze]),b.useEffect(()=>{lt.current=St},[St]),b.useEffect(()=>{$(!0)},[]),b.useEffect(()=>{let be=Fe.current;if(be){let pe=be.getBoundingClientRect().height;return dt(pe),x(ye=>[{toastId:h.id,height:pe,position:h.position},...ye]),()=>x(ye=>ye.filter(Re=>Re.toastId!==h.id))}},[x,h.id]),b.useLayoutEffect(()=>{if(!B)return;let be=Fe.current,pe=be.style.height;be.style.height="auto";let ye=be.getBoundingClientRect().height;be.style.height=pe,dt(ye),x(Re=>Re.find(qe=>qe.toastId===h.id)?Re.map(qe=>qe.toastId===h.id?{...qe,height:ye}:qe):[{toastId:h.id,height:ye,position:h.position},...Re])},[B,h.title,h.description,x,h.id]);let ue=b.useCallback(()=>{X(!0),Te(kt.current),x(be=>be.filter(pe=>pe.toastId!==h.id)),setTimeout(()=>{T(h)},iN)},[h,T,x,kt]);b.useEffect(()=>{if(h.promise&&Me==="loading"||h.duration===1/0||h.type==="loading")return;let be;return C||g||P&&Ke?(()=>{if(on.current<Ct.current){let pe=new Date().getTime()-Ct.current;lt.current=lt.current-pe}on.current=new Date().getTime()})():lt.current!==1/0&&(Ct.current=new Date().getTime(),be=setTimeout(()=>{var pe;(pe=h.onAutoClose)==null||pe.call(h,h),ue()},lt.current)),()=>clearTimeout(be)},[C,g,h,Me,P,Ke,ue]),b.useEffect(()=>{h.delete&&ue()},[ue,h.delete]);function We(){var be,pe,ye;return U!=null&&U.loading?b.createElement("div",{className:mn(I==null?void 0:I.loader,(be=h==null?void 0:h.classNames)==null?void 0:be.loader,"sonner-loader"),"data-visible":Me==="loading"},U.loading):z?b.createElement("div",{className:mn(I==null?void 0:I.loader,(pe=h==null?void 0:h.classNames)==null?void 0:pe.loader,"sonner-loader"),"data-visible":Me==="loading"},z):b.createElement(BI,{className:mn(I==null?void 0:I.loader,(ye=h==null?void 0:h.classNames)==null?void 0:ye.loader),visible:Me==="loading"})}return b.createElement("li",{tabIndex:0,ref:Fe,className:mn(W,Qe,I==null?void 0:I.toast,(t=h==null?void 0:h.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Me],(n=h==null?void 0:h.classNames)==null?void 0:n[Me]),"data-sonner-toast":"","data-rich-colors":(r=h.richColors)!=null?r:E,"data-styled":!(h.jsx||h.unstyled||v),"data-mounted":B,"data-promise":!!h.promise,"data-swiped":de,"data-removed":Q,"data-visible":Ye,"data-y-position":Vt,"data-x-position":Et,"data-index":S,"data-front":Le,"data-swiping":te,"data-dismissible":$e,"data-type":Me,"data-invert":At,"data-swipe-out":ae,"data-swipe-direction":L,"data-expanded":!!(C||M&&B),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${Q?Ce:kt.current}px`,"--initial-height":M?"auto":`${_e}px`,..._,...h.style},onDragEnd:()=>{J(!1),R(null),Nt.current=null},onPointerDown:be=>{Z||!$e||(Be.current=new Date,Te(kt.current),be.target.setPointerCapture(be.pointerId),be.target.tagName!=="BUTTON"&&(J(!0),Nt.current={x:be.clientX,y:be.clientY}))},onPointerUp:()=>{var be,pe,ye,Re;if(ae||!$e)return;Nt.current=null;let qe=Number(((be=Fe.current)==null?void 0:be.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ct=Number(((pe=Fe.current)==null?void 0:pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((ye=Be.current)==null?void 0:ye.getTime()),Pe=O==="x"?qe:ct,gt=Math.abs(Pe)/ut;if(Math.abs(Pe)>=sN||gt>.11){Te(kt.current),(Re=h.onDismiss)==null||Re.call(h,h),ee(O==="x"?qe>0?"right":"left":ct>0?"down":"up"),ue(),ve(!0),me(!1);return}J(!1),R(null)},onPointerMove:be=>{var pe,ye,Re,qe;if(!Nt.current||!$e||((pe=window.getSelection())==null?void 0:pe.toString().length)>0)return;let ct=be.clientY-Nt.current.y,ut=be.clientX-Nt.current.x,Pe=(ye=e.swipeDirections)!=null?ye:aN(Y);!O&&(Math.abs(ut)>1||Math.abs(ct)>1)&&R(Math.abs(ut)>Math.abs(ct)?"x":"y");let gt={x:0,y:0};O==="y"?(Pe.includes("top")||Pe.includes("bottom"))&&(Pe.includes("top")&&ct<0||Pe.includes("bottom")&&ct>0)&&(gt.y=ct):O==="x"&&(Pe.includes("left")||Pe.includes("right"))&&(Pe.includes("left")&&ut<0||Pe.includes("right")&&ut>0)&&(gt.x=ut),(Math.abs(gt.x)>0||Math.abs(gt.y)>0)&&me(!0),(Re=Fe.current)==null||Re.style.setProperty("--swipe-amount-x",`${gt.x}px`),(qe=Fe.current)==null||qe.style.setProperty("--swipe-amount-y",`${gt.y}px`)}},yt&&!h.jsx?b.createElement("button",{"aria-label":K,"data-disabled":Z,"data-close-button":!0,onClick:Z||!$e?()=>{}:()=>{var be;ue(),(be=h.onDismiss)==null||be.call(h,h)},className:mn(I==null?void 0:I.closeButton,(o=h==null?void 0:h.classNames)==null?void 0:o.closeButton)},(s=U==null?void 0:U.close)!=null?s:VI):null,h.jsx||b.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:b.createElement(b.Fragment,null,Me||h.icon||h.promise?b.createElement("div",{"data-icon":"",className:mn(I==null?void 0:I.icon,(i=h==null?void 0:h.classNames)==null?void 0:i.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||We():null,h.type!=="loading"?h.icon||(U==null?void 0:U[Me])||$I(Me):null):null,b.createElement("div",{"data-content":"",className:mn(I==null?void 0:I.content,(a=h==null?void 0:h.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:mn(I==null?void 0:I.title,(l=h==null?void 0:h.classNames)==null?void 0:l.title)},typeof h.title=="function"?h.title():h.title),h.description?b.createElement("div",{"data-description":"",className:mn(G,It,I==null?void 0:I.description,(c=h==null?void 0:h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),b.isValidElement(h.cancel)?h.cancel:h.cancel&&gi(h.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||D,onClick:be=>{var pe,ye;gi(h.cancel)&&$e&&((ye=(pe=h.cancel).onClick)==null||ye.call(pe,be),ue())},className:mn(I==null?void 0:I.cancelButton,(d=h==null?void 0:h.classNames)==null?void 0:d.cancelButton)},h.cancel.label):null,b.isValidElement(h.action)?h.action:h.action&&gi(h.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||F,onClick:be=>{var pe,ye;gi(h.action)&&((ye=(pe=h.action).onClick)==null||ye.call(pe,be),!be.defaultPrevented&&ue())},className:mn(I==null?void 0:I.actionButton,(f=h==null?void 0:h.classNames)==null?void 0:f.actionButton)},h.action.label):null))};function sx(){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 cN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?nN:tN;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 uN=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:h,visibleToasts:v=eN,toastOptions:g,dir:x=sx(),gap:y=oN,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[_,D]=b.useState([]),[F,W]=b.useState(!1),[G,A]=b.useState(!1),[Y,q]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=b.useRef(null),M=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),U=b.useRef(!1),K=b.useCallback(P=>{E(O=>{var R;return(R=O.find(L=>L.id===P.id))!=null&&R.delete||Wt.dismiss(P.id),O.filter(({id:L})=>L!==P.id)})},[]);return b.useEffect(()=>Wt.subscribe(P=>{if(P.dismiss){E(O=>O.map(R=>R.id===P.id?{...R,delete:!0}:R));return}setTimeout(()=>{Ro.flushSync(()=>{E(O=>{let R=O.findIndex(L=>L.id===P.id);return R!==-1?[...O.slice(0,R),{...O[R],...P},...O.slice(R+1)]:[P,...O]})})})}),[]),b.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:O})=>{q(O?"dark":"light")})}catch{P.addListener(({matches:R})=>{try{q(R?"dark":"light")}catch(L){console.error(L)}})}},[d]),b.useEffect(()=>{T.length<=1&&W(!1)},[T]),b.useEffect(()=>{let P=O=>{var R,L;o.every(ee=>O[ee]||O.code===ee)&&(W(!0),(R=z.current)==null||R.focus()),O.code==="Escape"&&(document.activeElement===z.current||(L=z.current)!=null&&L.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),b.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,U.current=!1)}},[z.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${M}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,O)=>{var R;let[L,ee]=P.split("-");return T.length?b.createElement("ol",{key:P,dir:x==="auto"?sx():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":L,"data-lifted":F&&T.length>1&&!s,"data-x-position":ee,style:{"--front-toast-height":`${((R=_[0])==null?void 0:R.height)||0}px`,"--width":`${rN}px`,"--gap":`${y}px`,...h,...cN(l,c)},onBlur:B=>{U.current&&!B.currentTarget.contains(B.relatedTarget)&&(U.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||U.current||(U.current=!0,I.current=B.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{G||W(!1)},onDragEnd:()=>W(!1),onPointerDown:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},T.filter(B=>!B.position&&O===0||B.position===P).map((B,$)=>{var Q,X;return b.createElement(lN,{key:B.id,icons:S,index:$,toast:B,defaultRichColors:f,duration:(Q=g==null?void 0:g.duration)!=null?Q:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(X=g==null?void 0:g.closeButton)!=null?X:i,interacting:G,position:P,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:K,toasts:T.filter(te=>te.position==B.position),heights:_.filter(te=>te.position==B.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:w,expanded:F,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const dN=({...e})=>{const{theme:t="system"}=LI();return u.jsx(uN,{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.Api=Kv,H.ApiClient=Vv,H.ApiProvider=ou,H.ArtifactRenderer=Ip,H.Badge=Fp,H.Button=Ze,H.Card=al,H.CardContent=dl,H.CardDescription=ul,H.CardHeader=ll,H.CardTitle=cl,H.ChatApi=Go,H.ChatApp=Vk,H.ChatInput=Vf,H.ChatInputRow=Kf,H.ChatInterface=Or,H.ChatProviders=wr,H.ChatWidget=Gk,H.Command=Sl,H.CommandEmpty=kl,H.CommandGroup=El,H.CommandInput=Cl,H.CommandItem=Il,H.CommandList=Tl,H.DEFAULT_TIMEOUT_MS=Zc,H.Dialog=tl,H.DialogContent=Hs,H.DialogHeader=Us,H.DialogTitle=Ws,H.DropdownMenu=Ts,H.DropdownMenuContent=po,H.DropdownMenuItem=Bn,H.DropdownMenuTrigger=ks,H.FileViewerModal=up,H.HISTORY_TIMEOUT_MS=Qc,H.Input=Rl,H.InterruptPartRenderer=Ap,H.Label=bm,H.MarkdownContent=qn,H.MessageComponent=Zs,H.MessageList=ml,H.MessageRow=pl,H.NewChatButton=Yk,H.PlotArtifact=Tp,H.ResearchTaskArtifact=Ep,H.SETTINGS_STORAGE_KEY=Bi,H.ScrollArea=Ml,H.Select=NE,H.SelectContent=ig,H.SelectItem=ag,H.SelectTrigger=rg,H.SelectValue=AE,H.Separator=dg,H.Sheet=BE,H.SheetContent=wg,H.SheetDescription=Cg,H.SheetHeader=yg,H.SheetTitle=Sg,H.SheetTrigger=zE,H.SimpleChat=Kk,H.SimpleJsonView=Js,H.Sonner=dN,H.StreamProgress=jp,H.Switch=vg,H.Textarea=Ea,H.ThinkingIndicator=_p,H.ThreadListItem=hm,H.ThreadManager=oi,H.ThreadStateProvider=Iu,H.ThreadsProvider=mu,H.TimelineColumn=Sx,H.Toaster=MI,H.ToolComponent=Lp,H.Tooltip=uI,H.TooltipContent=Pg,H.TooltipProvider=cI,H.TooltipTrigger=dI,H.UserTextContent=Pp,H.applySettings=Eb,H.buildCheckpointIndex=tc,H.buildCheckpointPreviewMap=dx,H.chatApiClient=Nn,H.del=Pi,H.downloadFileById=tu,H.extractConfigFields=vi,H.fileToBase64=su,H.get=Yt,H.getChatToken=Xc,H.getCheckpointForMessage=fx,H.getCurrentSettings=kb,H.getDefaultApiConfig=Du,H.getDefaultChatSettings=Lu,H.getFileContent=Ri,H.getFileInfo=Gv,H.getMessageAttemptInfo=nc,H.getMessageDomKey=hl,H.getPreviewForMessage=xi,H.httpClient=Gt,H.hydrateHistorySnapshots=Rn,H.isEnvelope=au,H.listFiles=nu,H.loadStoredSettings=$u,H.onChatTokenChanged=Jc,H.post=qo,H.processAttachments=iu,H.put=eu,H.readNumber=oc,H.readString=Mn,H.resolveChatBaseUrl=xn,H.saveSettings=Fu,H.setChatToken=Ko,H.toPlainObject=Pn,H.unwrap=Ot,H.useApi=Jr,H.useCheckpointIndex=rc,H.useFilePreview=Rp,H.useHasChatSession=Sb,H.useParsedMessageContent=Op,H.useShallowStableValue=Pu,H.useStream=Fi,H.useStreamingHook=Fi,H.useThreadHistoryState=Cu,H.useThreadManagerViewState=gm,H.useThreadState=to,H.useThreadStateUpdater=Eu,H.useThreads=xr,H.useThreadsState=hu,H.viewFileById=qv,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|