teodor-new-chat-ui 4.3.496 → 4.3.497
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.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(H,w){typeof exports=="object"&&typeof module<"u"?w(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"],w):(H=typeof globalThis<"u"?globalThis:H||self,w(H.NewChatUI={},H.React,H.reactSlot,H.classVarianceAuthority,H.clsx,H.tailwindMerge,H.LucideReact,H.ReactDOM))})(this,function(H,w,Gt,Ur,lx,cx,le,Do){"use strict";var hN=Object.defineProperty;var mN=(H,w,Gt)=>w in H?hN(H,w,{enumerable:!0,configurable:!0,writable:!0,value:Gt}):H[w]=Gt;var ix=(H,w,Gt)=>mN(H,typeof w!="symbol"?w+"":w,Gt);var sx;var wi=typeof document<"u"?document.currentScript:null;function tc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=tc(w),Wr=tc(Do),nc=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>nc?`${n.slice(0,nc-3)}…`:n:""}function bi(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=bi(o);s&&t.set(r.checkpointId,s)}}return t}function rc(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}`,p=d.metadata??{},v=typeof p.step=="number"?p.step:null,g=typeof p.source=="string"?p.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const T of b)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const C=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,S={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:C,parentConfig:k,userMessageId:x};if(o.push(S),f&&t.set(f,S),f&&y){const T=bi(y);T&&r.set(f,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:C,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 p=f.createdAt?Date.parse(f.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-p});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 p=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return p-v}),d):[]}}}function oc(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 sc(e){return w.useMemo(()=>rc(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Rn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function ic(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 yi(e){const t=_n(e);if(t)return _n(t.configurable)??t}const px={},hr=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:wi&&wi.tagName.toUpperCase()==="SCRIPT"&&wi.src||new URL("index.umd.js",document.baseURI).href}<"u"?px:void 0,Vr=!(((sx=hr==null?void 0:hr.VITE_DEBUG_HISTORY_INTERRUPTS)==null?void 0:sx.toLowerCase())==="false"||(hr==null?void 0:hr.VITE_DEBUG_HISTORY_INTERRUPTS)==="0");function Yn(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)=>ac(i.createdAt)-ac(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,T;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(E=>mx(E)).filter(E=>!!E),o=_n(e.metadata)??{},s=yi(e.config),i=_n(e.parent_config??e.parentConfig),a=yi(i),l=Rn(s,["checkpoint_id","checkpointId"]),c=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),f=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,p=_n(e.config),v=Array.isArray(e.tasks)?e.tasks.map(E=>({...E})):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:ic(o,["step"])??0,source:Rn(o,["source"])??null},b=r.map(E=>({...E,checkpointId:l??null})),C=(T=e.values)==null?void 0:T.interrupts,k=Array.isArray(e.interrupts)?e.interrupts:Array.isArray(C)?C:[];return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:f,nextCursorNs:m,interrupt:wx(r,k,t,l??null,c??null),metadata:y,config:p??null,parentConfig:i??null,next:g,tasks:v}}function mx(e){var s,i,a;if(!e||typeof e!="object")return null;const t=gx(e);if(!t)return null;const n=vx(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 gx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&xx(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 xx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function vx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function wx(e,t,n,r,o){const s=t.length,i=bx(e,n);if(Vr&&console.debug("[historyUtils] deriveInterruptFromSnapshot",{checkpointId:r,checkpointNs:o,fallbackIndex:n,messageCount:e.length,rawInterruptCount:s,messageInterrupt:i,rawInterrupts:t.slice(Math.max(0,s-3))}),i)return Vr&&console.debug("[historyUtils] interrupt found in messages",i),i;for(let a=s-1;a>=0;a-=1){const l=t[a];if(!l||typeof l!="object"){Vr&&console.debug("[historyUtils] skipping invalid raw interrupt entry",{entry:l,index:a});continue}const c=l,d=c.value??l;if(d==null){Vr&&console.debug("[historyUtils] skipping raw interrupt without value",{entry:l,index:a});continue}const m={id:typeof c.id=="string"&&c.id.trim()?c.id:`interrupt-${r??n}-${a}`,value:d};return Vr&&console.debug("[historyUtils] interrupt derived from raw entry",m),m}return null}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 ac(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var Si={exports:{}},Kr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -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 cc;function Sx(){return cc||(cc=1,process.env.NODE_ENV!=="production"&&function(){var e=w,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"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var
|
|
18
|
-
`+j+N}}var G=!1,Q;{var
|
|
17
|
+
*/var cc;function Sx(){return cc||(cc=1,process.env.NODE_ENV!=="production"&&function(){var e=w,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"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var Z=v&&N[v]||N[g];return typeof Z=="function"?Z:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var Z=arguments.length,re=new Array(Z>1?Z-1:0),ge=1;ge<Z;ge++)re[ge-1]=arguments[ge];C("error",N,re)}}function C(N,Z,re){{var ge=y.ReactDebugCurrentFrame,Ae=ge.getStackAddendum();Ae!==""&&(Z+="%s",re=re.concat([Ae]));var ot=re.map(function(We){return String(We)});ot.unshift("Warning: "+Z),Function.prototype.apply.call(console[N],console,ot)}}var k=!1,S=!1,T=!1,E=!1,A=!1,_;_=Symbol.for("react.module.reference");function L(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||A||N===o||N===c||N===d||E||N===p||k||S||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,Z,re){var ge=N.displayName;if(ge)return ge;var Ae=Z.displayName||Z.name||"";return Ae!==""?re+"("+Ae+")":re}function U(N){return N.displayName||"Context"}function X(N){if(N==null)return null;if(typeof N.tag=="number"&&b("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 Z=N;return U(Z)+".Consumer";case i:var re=N;return U(re._context)+".Provider";case l:return F(N,N.render,"ForwardRef");case f:var ge=N.displayName||null;return ge!==null?ge:X(N.type)||"Memo";case m:{var Ae=N,ot=Ae._payload,We=Ae._init;try{return X(We(ot))}catch{return null}}}return null}var O=Object.assign,Y=0,V,K,D,I,q,J,M;function B(){}B.__reactDisabledLog=!0;function P(){{if(Y===0){V=console.log,K=console.info,D=console.warn,I=console.error,q=console.group,J=console.groupCollapsed,M=console.groupEnd;var N={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}Y++}}function $(){{if(Y--,Y===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},N,{value:V}),info:O({},N,{value:K}),warn:O({},N,{value:D}),error:O({},N,{value:I}),group:O({},N,{value:q}),groupCollapsed:O({},N,{value:J}),groupEnd:O({},N,{value:M})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var z=y.ReactCurrentDispatcher,j;function R(N,Z,re){{if(j===void 0)try{throw Error()}catch(Ae){var ge=Ae.stack.trim().match(/\n( *(at )?)/);j=ge&&ge[1]||""}return`
|
|
18
|
+
`+j+N}}var G=!1,Q;{var se=typeof WeakMap=="function"?WeakMap:Map;Q=new se}function ie(N,Z){if(!N||G)return"";{var re=Q.get(N);if(re!==void 0)return re}var ge;G=!0;var Ae=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ot;ot=z.current,z.current=null,P();try{if(Z){var We=function(){throw Error()};if(Object.defineProperty(We.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(We,[])}catch(qt){ge=qt}Reflect.construct(N,[],We)}else{try{We.call()}catch(qt){ge=qt}N.call(We.prototype)}}else{try{throw Error()}catch(qt){ge=qt}N()}}catch(qt){if(qt&&ge&&typeof qt.stack=="string"){for(var Fe=qt.stack.split(`
|
|
19
19
|
`),Bt=ge.stack.split(`
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
20
|
+
`),bt=Fe.length-1,kt=Bt.length-1;bt>=1&&kt>=0&&Fe[bt]!==Bt[kt];)kt--;for(;bt>=1&&kt>=0;bt--,kt--)if(Fe[bt]!==Bt[kt]){if(bt!==1||kt!==1)do if(bt--,kt--,kt<0||Fe[bt]!==Bt[kt]){var sn=`
|
|
21
|
+
`+Fe[bt].replace(" at new "," at ");return N.displayName&&sn.includes("<anonymous>")&&(sn=sn.replace("<anonymous>",N.displayName)),typeof N=="function"&&Q.set(N,sn),sn}while(bt>=1&&kt>=0);break}}}finally{G=!1,z.current=ot,$(),Error.prepareStackTrace=Ae}var Hr=N?N.displayName||N.name:"",pr=Hr?R(Hr):"";return typeof N=="function"&&Q.set(N,pr),pr}function Se(N,Z,re){return ie(N,!1)}function xe(N){var Z=N.prototype;return!!(Z&&Z.isReactComponent)}function Oe(N,Z,re){if(N==null)return"";if(typeof N=="function")return ie(N,xe(N));if(typeof N=="string")return R(N);switch(N){case c:return R("Suspense");case d:return R("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return Se(N.render);case f:return Oe(N.type,Z,re);case m:{var ge=N,Ae=ge._payload,ot=ge._init;try{return Oe(ot(Ae),Z,re)}catch{}}}return""}var De=Object.prototype.hasOwnProperty,Ge={},Ye=y.ReactDebugCurrentFrame;function He(N){if(N){var Z=N._owner,re=Oe(N.type,N._source,Z?Z.type:null);Ye.setExtraStackFrame(re)}else Ye.setExtraStackFrame(null)}function st(N,Z,re,ge,Ae){{var ot=Function.call.bind(De);for(var We in N)if(ot(N,We)){var Fe=void 0;try{if(typeof N[We]!="function"){var Bt=Error((ge||"React class")+": "+re+" type `"+We+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[We]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Bt.name="Invariant Violation",Bt}Fe=N[We](Z,We,ge,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(bt){Fe=bt}Fe&&!(Fe instanceof Error)&&(He(Ae),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ge||"React class",re,We,typeof Fe),He(null)),Fe instanceof Error&&!(Fe.message in Ge)&&(Ge[Fe.message]=!0,He(Ae),b("Failed %s type: %s",re,Fe.message),He(null))}}}var Xe=Array.isArray;function St(N){return Xe(N)}function Le(N){{var Z=typeof Symbol=="function"&&Symbol.toStringTag,re=Z&&N[Symbol.toStringTag]||N.constructor.name||"Object";return re}}function Ve(N){try{return je(N),!1}catch{return!0}}function je(N){return""+N}function Ie(N){if(Ve(N))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Le(N)),je(N)}var Ne=y.ReactCurrentOwner,ut={key:!0,ref:!0,__self:!0,__source:!0},jt,ft;function At(N){if(De.call(N,"ref")){var Z=Object.getOwnPropertyDescriptor(N,"ref").get;if(Z&&Z.isReactWarning)return!1}return N.ref!==void 0}function pt(N){if(De.call(N,"key")){var Z=Object.getOwnPropertyDescriptor(N,"key").get;if(Z&&Z.isReactWarning)return!1}return N.key!==void 0}function Ct(N,Z){typeof N.ref=="string"&&Ne.current}function lt(N,Z){{var re=function(){jt||(jt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Z))};re.isReactWarning=!0,Object.defineProperty(N,"key",{get:re,configurable:!0})}}function gn(N,Z){{var re=function(){ft||(ft=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Z))};re.isReactWarning=!0,Object.defineProperty(N,"ref",{get:re,configurable:!0})}}var Tt=function(N,Z,re,ge,Ae,ot,We){var Fe={$$typeof:t,type:N,key:Z,ref:re,props:We,_owner:ot};return Fe._store={},Object.defineProperty(Fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ge}),Object.defineProperty(Fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ae}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function Dt(N,Z,re,ge,Ae){{var ot,We={},Fe=null,Bt=null;re!==void 0&&(Ie(re),Fe=""+re),pt(Z)&&(Ie(Z.key),Fe=""+Z.key),At(Z)&&(Bt=Z.ref,Ct(Z,Ae));for(ot in Z)De.call(Z,ot)&&!ut.hasOwnProperty(ot)&&(We[ot]=Z[ot]);if(N&&N.defaultProps){var bt=N.defaultProps;for(ot in bt)We[ot]===void 0&&(We[ot]=bt[ot])}if(Fe||Bt){var kt=typeof N=="function"?N.displayName||N.name||"Unknown":N;Fe&<(We,kt),Bt&&gn(We,kt)}return Tt(N,Fe,Bt,Ae,ge,Ne.current,We)}}var mt=y.ReactCurrentOwner,ze=y.ReactDebugCurrentFrame;function Ue(N){if(N){var Z=N._owner,re=Oe(N.type,N._source,Z?Z.type:null);ze.setExtraStackFrame(re)}else ze.setExtraStackFrame(null)}var It;It=!1;function ne(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function me(){{if(mt.current){var N=X(mt.current.type);if(N)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+N+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+N+"`."}return""}}function rt(N){return""}var de={};function Te(N){{var Z=me();if(!Z){var re=typeof N=="string"?N:N.displayName||N.name;re&&(Z=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+re+">.")}return Z}}function $e(N,Z){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var re=Te(Z);if(de[re])return;de[re]=!0;var ge="";N&&N._owner&&N._owner!==mt.current&&(ge=" It was passed a child from "+X(N._owner.type)+"."),Ue(N),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',re,ge),Ue(null)}}function ht(N,Z){{if(typeof N!="object")return;if(St(N))for(var re=0;re<N.length;re++){var ge=N[re];ne(ge)&&$e(ge,Z)}else if(ne(N))N._store&&(N._store.validated=!0);else if(N){var Ae=x(N);if(typeof Ae=="function"&&Ae!==N.entries)for(var ot=Ae.call(N),We;!(We=ot.next()).done;)ne(We.value)&&$e(We.value,Z)}}}function wt(N){{var Z=N.type;if(Z==null||typeof Z=="string")return;var re;if(typeof Z=="function")re=Z.propTypes;else if(typeof Z=="object"&&(Z.$$typeof===l||Z.$$typeof===f))re=Z.propTypes;else return;if(re){var ge=X(Z);st(re,N.props,"prop",ge,N)}else if(Z.PropTypes!==void 0&&!It){It=!0;var Ae=X(Z);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ae||"Unknown")}typeof Z.getDefaultProps=="function"&&!Z.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Pe(N){{for(var Z=Object.keys(N.props),re=0;re<Z.length;re++){var ge=Z[re];if(ge!=="children"&&ge!=="key"){Ue(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ge),Ue(null);break}}N.ref!==null&&(Ue(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var Ke={};function we(N,Z,re,ge,Ae,ot){{var We=L(N);if(!We){var Fe="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Fe+=" 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 Bt=rt();Bt?Fe+=Bt:Fe+=me();var bt;N===null?bt="null":St(N)?bt="array":N!==void 0&&N.$$typeof===t?(bt="<"+(X(N.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):bt=typeof N,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",bt,Fe)}var kt=Dt(N,Z,re,Ae,ot);if(kt==null)return kt;if(We){var sn=Z.children;if(sn!==void 0)if(ge)if(St(sn)){for(var Hr=0;Hr<sn.length;Hr++)ht(sn[Hr],N);Object.freeze&&Object.freeze(sn)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ht(sn,N)}if(De.call(Z,"key")){var pr=X(N),qt=Object.keys(Z).filter(function(pN){return pN!=="key"}),ec=qt.length>0?"{key: someKey, "+qt.join(": ..., ")+": ...}":"{key: someKey}";if(!Ke[pr+ec]){var fN=qt.length>0?"{"+qt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,ec,pr,fN,pr),ut[pr+ec]=!0}}return N===r?Ue(Ct):Ne(Ct),Ct}}function mt(N,J,se){return Se(N,J,se,!0)}function Xe(N,J,se){return Se(N,J,se,!1)}var dt=Xe,je=mt;qr.Fragment=r,qr.jsx=dt,qr.jsxs=je}()),qr}process.env.NODE_ENV==="production"?Si.exports=yx():Si.exports=Sx();var u=Si.exports;const Cx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=w.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(p=>{const v=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function uc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Tx}=Object.prototype,{getPrototypeOf:Ci}=Object,{iterator:Lo,toStringTag:dc}=Symbol,$o=(e=>t=>{const n=Tx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>$o(t)===e),Fo=e=>t=>typeof t===e,{isArray:mr}=Array,gr=Fo("undefined");function Gr(e){return e!==null&&!gr(e)&&e.constructor!==null&&!gr(e.constructor)&&zt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const fc=ln("ArrayBuffer");function kx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&fc(e.buffer),t}const Ex=Fo("string"),zt=Fo("function"),pc=Fo("number"),Yr=e=>e!==null&&typeof e=="object",Ix=e=>e===!0||e===!1,Bo=e=>{if($o(e)!=="object")return!1;const t=Ci(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(dc in e)&&!(Lo in e)},Nx=e=>{if(!Yr(e)||Gr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ax=ln("Date"),jx=ln("File"),Px=ln("Blob"),_x=ln("FileList"),Rx=e=>Yr(e)&&zt(e.pipe),Mx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||zt(e.append)&&((t=$o(e))==="formdata"||t==="object"&&zt(e.toString)&&e.toString()==="[object FormData]"))},Ox=ln("URLSearchParams"),[Dx,Lx,$x,Fx]=["ReadableStream","Request","Response","Headers"].map(ln),Bx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Xr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),mr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Gr(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 hc(e,t){if(Gr(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,mc=e=>!gr(e)&&e!==Xn;function Ti(){const{caseless:e,skipUndefined:t}=mc(this)&&this||{},n={},r=(o,s)=>{const i=e&&hc(n,s)||s;Bo(n[i])&&Bo(o)?n[i]=Ti(n[i],o):Bo(o)?n[i]=Ti({},o):mr(o)?n[i]=o.slice():(!t||!gr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Xr(arguments[o],r);return n}const zx=(e,t,n,{allOwnKeys:r}={})=>(Xr(t,(o,s)=>{n&&zt(o)?e[s]=uc(o,n):e[s]=o},{allOwnKeys:r}),e),Hx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ux=(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)},Wx=(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&&Ci(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Vx=(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},Kx=e=>{if(!e)return null;if(mr(e))return e;let t=e.length;if(!pc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},qx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ci(Uint8Array)),Gx=(e,t)=>{const r=(e&&e[Lo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Yx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Xx=ln("HTMLFormElement"),Jx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),gc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Zx=ln("RegExp"),xc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Xr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Qx=e=>{xc(e,(t,n)=>{if(zt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(zt(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+"'")})}})},ev=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return mr(e)?r(e):r(String(e).split(t)),n},tv=()=>{},nv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function rv(e){return!!(e&&zt(e.append)&&e[dc]==="FormData"&&e[Lo])}const ov=e=>{const t=new Array(10),n=(r,o)=>{if(Yr(r)){if(t.indexOf(r)>=0)return;if(Gr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=mr(r)?[]:{};return Xr(r,(i,a)=>{const l=n(i,o+1);!gr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},sv=ln("AsyncFunction"),iv=e=>e&&(Yr(e)||zt(e))&&zt(e.then)&&zt(e.catch),vc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",zt(Xn.postMessage)),av=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||vc,U={isArray:mr,isArrayBuffer:fc,isBuffer:Gr,isFormData:Mx,isArrayBufferView:kx,isString:Ex,isNumber:pc,isBoolean:Ix,isObject:Yr,isPlainObject:Bo,isEmptyObject:Nx,isReadableStream:Dx,isRequest:Lx,isResponse:$x,isHeaders:Fx,isUndefined:gr,isDate:Ax,isFile:jx,isBlob:Px,isRegExp:Zx,isFunction:zt,isStream:Rx,isURLSearchParams:Ox,isTypedArray:qx,isFileList:_x,forEach:Xr,merge:Ti,extend:zx,trim:Bx,stripBOM:Hx,inherits:Ux,toFlatObject:Wx,kindOf:$o,kindOfTest:ln,endsWith:Vx,toArray:Kx,forEachEntry:Gx,matchAll:Yx,isHTMLForm:Xx,hasOwnProperty:gc,hasOwnProp:gc,reduceDescriptors:xc,freezeMethods:Qx,toObjectSet:ev,toCamelCase:Jx,noop:tv,toFiniteNumber:nv,findKey:hc,global:Xn,isContextDefined:mc,isSpecCompliantForm:rv,toJSONObject:ov,isAsyncFn:sv,isThenable:iv,setImmediate:vc,asap:av,isIterable:e=>e!=null&&zt(e[Lo])};function Ee(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)}U.inherits(Ee,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:U.toJSONObject(this.config),code:this.code,status:this.status}}});const wc=Ee.prototype,bc={};["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=>{bc[e]={value:e}}),Object.defineProperties(Ee,bc),Object.defineProperty(wc,"isAxiosError",{value:!0}),Ee.from=(e,t,n,r,o,s)=>{const i=Object.create(wc);U.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 Ee.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 lv=null;function ki(e){return U.isPlainObject(e)||U.isArray(e)}function yc(e){return U.endsWith(e,"[]")?e.slice(0,-2):e}function Sc(e,t,n){return e?e.concat(t).map(function(o,s){return o=yc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function cv(e){return U.isArray(e)&&!e.some(ki)}const uv=U.toFlatObject(U,{},null,function(t){return/^is[A-Z]/.test(t)});function zo(e,t,n){if(!U.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=U.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!U.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&U.isSpecCompliantForm(t);if(!U.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(U.isDate(v))return v.toISOString();if(U.isBoolean(v))return v.toString();if(!l&&U.isBlob(v))throw new Ee("Blob is not supported. Use a Buffer instead.");return U.isArrayBuffer(v)||U.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(U.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(U.isArray(v)&&cv(v)||(U.isFileList(v)||U.endsWith(g,"[]"))&&(y=U.toArray(v)))return g=yc(g),y.forEach(function(C,k){!(U.isUndefined(C)||C===null)&&t.append(i===!0?Sc([g],k,s):i===null?g:g+"[]",c(C))}),!1}return ki(v)?!0:(t.append(Sc(x,g,s),c(v)),!1)}const f=[],m=Object.assign(uv,{defaultVisitor:d,convertValue:c,isVisitable:ki});function p(v,g){if(!U.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),U.forEach(v,function(y,b){(!(U.isUndefined(y)||y===null)&&o.call(t,y,U.isString(b)?b.trim():b,g,m))===!0&&p(y,g?g.concat(b):[b])}),f.pop()}}if(!U.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Cc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ei(e,t){this._pairs=[],e&&zo(e,this,t)}const Tc=Ei.prototype;Tc.append=function(t,n){this._pairs.push([t,n])},Tc.toString=function(t){const n=t?function(r){return t.call(this,r,Cc)}:Cc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function dv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kc(e,t,n){if(!t)return e;const r=n&&n.encode||dv;U.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=U.isURLSearchParams(t)?t.toString():new Ei(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Ec{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){U.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ic={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ei,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ii=typeof window<"u"&&typeof document<"u",Ni=typeof navigator=="object"&&navigator||void 0,pv=Ii&&(!Ni||["ReactNative","NativeScript","NS"].indexOf(Ni.product)<0),hv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",mv=Ii&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ii,hasStandardBrowserEnv:pv,hasStandardBrowserWebWorkerEnv:hv,navigator:Ni,origin:mv},Symbol.toStringTag,{value:"Module"})),...fv};function gv(e,t){return zo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&U.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function xv(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function vv(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 Nc(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&&U.isArray(o)?o.length:i,l?(U.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!U.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&U.isArray(o[i])&&(o[i]=vv(o[i])),!a)}if(U.isFormData(e)&&U.isFunction(e.entries)){const n={};return U.forEachEntry(e,(r,o)=>{t(xv(r),o,n,0)}),n}return null}function wv(e,t,n){if(U.isString(e))try{return(t||JSON.parse)(e),U.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Jr={transitional:Ic,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=U.isObject(t);if(s&&U.isHTMLForm(t)&&(t=new FormData(t)),U.isFormData(t))return o?JSON.stringify(Nc(t)):t;if(U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)||U.isReadableStream(t))return t;if(U.isArrayBufferView(t))return t.buffer;if(U.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 gv(t,this.formSerializer).toString();if((a=U.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return zo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),wv(t)):t}],transformResponse:[function(t){const n=this.transitional||Jr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(U.isResponse(t)||U.isReadableStream(t))return t;if(t&&U.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"?Ee.from(a,Ee.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};U.forEach(["delete","get","head","post","put","patch"],e=>{Jr.headers[e]={}});const bv=U.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"]),yv=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},Ac=Symbol("internals");function Zr(e){return e&&String(e).trim().toLowerCase()}function Ho(e){return e===!1||e==null?e:
|
|
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[Ac]=this[Ac]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Zr(i);r[a]||(kv(o,i),r[a]=!0)}return U.isArray(t)?t.forEach(s):s(t),this}};Ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),U.reduceDescriptors(Ht.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),U.freezeMethods(Ht);function ji(e,t){const n=this||Jr,r=t||n,o=Ht.from(r.headers);let s=r.data;return U.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function jc(e){return!!(e&&e.__CANCEL__)}function xr(e,t,n){Ee.call(this,e??"canceled",Ee.ERR_CANCELED,t,n),this.name="CanceledError"}U.inherits(xr,Ee,{__CANCEL__:!0});function Pc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ee("Request failed with status code "+n.status,[Ee.ERR_BAD_REQUEST,Ee.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ev(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Iv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(m*1e3/p):void 0}}function Nv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Uo=(e,t,n=3)=>{let r=0;const o=Iv(50,250);return Nv(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)},_c=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Rc=e=>(...t)=>U.asap(()=>e(...t)),Av=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,jv=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];U.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),U.isString(r)&&i.push("path="+r),U.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 Pv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _v(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Mc(e,t,n){let r=!Pv(t);return e&&(r||n==!1)?_v(e,t):t}const Oc=e=>e instanceof Ht?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,m){return U.isPlainObject(c)&&U.isPlainObject(d)?U.merge.call({caseless:m},c,d):U.isPlainObject(d)?U.merge({},d):U.isArray(d)?d.slice():d}function o(c,d,f,m){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,m)}function s(c,d){if(!U.isUndefined(d))return r(void 0,d)}function i(c,d){if(U.isUndefined(d)){if(!U.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(Oc(c),Oc(d),f,!0)};return U.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);U.isUndefined(m)&&f!==a||(n[d]=m)}),n}const Dc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ht.from(i),t.url=kc(Mc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),U.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(U.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(_t.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&Av(t.url))){const l=o&&s&&jv.read(s);l&&i.set(o,l)}return t},Rv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Dc(e);let s=o.data;const i=Ht.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,m,p,v;function g(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const C=Ht.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Pc(function(E){n(E),g()},function(E){r(E),g()},S),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 Ee("Request aborted",Ee.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new Ee(S,Ee.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 S=o.transitional||Ic;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ee(k,S.clarifyTimeoutError?Ee.ETIMEDOUT:Ee.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&U.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),U.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Uo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Uo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new xr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Ev(o.url);if(b&&_t.protocols.indexOf(b)===-1){r(new Ee("Unsupported protocol "+b+":",Ee.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 Ee?d:new xr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ee(`timeout ${t} of ms exceeded`,Ee.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=()=>U.asap(a),l}},Ov=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},Dv=async function*(e,t){for await(const n of Lv(e))yield*Ov(n,t)},Lv=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()}},Lc=(e,t,n,r)=>{const o=Dv(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})},$c=64*1024,{isFunction:Wo}=U,$v=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Fc,TextEncoder:Bc}=U.global,zc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fv=e=>{e=U.merge.call({skipUndefined:!0},$v,e);const{fetch:t,Request:n,Response:r}=e,o=t?Wo(t):typeof fetch=="function",s=Wo(n),i=Wo(r);if(!o)return!1;const a=o&&Wo(Fc),l=o&&(typeof Bc=="function"?(v=>g=>v.encode(g))(new Bc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&zc(()=>{let v=!1;const g=new n(_t.origin,{body:new Fc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&zc(()=>U.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 Ee(`Response type '${v}' is not supported`,Ee.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(U.isBlob(v))return v.size;if(U.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(U.isArrayBufferView(v)||U.isArrayBuffer(v))return v.byteLength;if(U.isURLSearchParams(v)&&(v=v+""),U.isString(v))return(await l(v)).byteLength},p=async(v,g)=>{const x=U.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:A,withCredentials:M="same-origin",fetchOptions:L}=Dc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let z=Mv([b,C&&C.toAbortSignal()],k),X=null;const O=z&&z.unsubscribe&&(()=>{z.unsubscribe()});let Y;try{if(T&&c&&x!=="get"&&x!=="head"&&(Y=await p(A,y))!==0){let Z=new n(g,{method:"POST",body:y,duplex:"half"}),R;if(U.isFormData(y)&&(R=Z.headers.get("content-type"))&&A.setContentType(R),Z.body){const[q,P]=_c(Y,Uo(Rc(T)));y=Lc(Z.body,$c,q,P)}}U.isString(M)||(M=M?"include":"omit");const W=s&&"credentials"in n.prototype,K={...L,signal:z,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:W?M:void 0};X=s&&new n(g,K);let D=await(s?F(X,L):F(g,K));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&O)){const Z={};["status","statusText","headers"].forEach($=>{Z[$]=D[$]});const R=U.toFiniteNumber(D.headers.get("content-length")),[q,P]=S&&_c(R,Uo(Rc(S),!0))||[];D=new r(Lc(D.body,$c,q,()=>{P&&P(),O&&O()}),Z)}E=E||"text";let V=await f[U.findKey(f,E)||"text"](D,v);return!I&&O&&O(),await new Promise((Z,R)=>{Pc(Z,R,{data:V,headers:Ht.from(D.headers),status:D.status,statusText:D.statusText,config:v,request:X})})}catch(W){throw O&&O(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Ee("Network Error",Ee.ERR_NETWORK,v,X),{cause:W.cause||W}):Ee.from(W,W&&W.code,v,X)}}},Bv=new Map,Hc=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=Bv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Fv(t)),d=c;return c};Hc();const Pi={http:lv,xhr:Rv,fetch:{get:Hc}};U.forEach(Pi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Uc=e=>`- ${e}`,zv=e=>U.isFunction(e)||e===null||e===!1,Wc={getAdapter:(e,t)=>{e=U.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,!zv(r)&&(o=Pi[(a=String(r)).toLowerCase()],o===void 0))throw new Ee(`Unknown adapter '${a}'`);if(o&&(U.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} />`,ec,pr,fN,pr),Ke[pr+ec]=!0}}return N===r?Pe(kt):wt(kt),kt}}function et(N,Z,re){return we(N,Z,re,!0)}function Je(N,Z,re){return we(N,Z,re,!1)}var dt=Je,_e=et;qr.Fragment=r,qr.jsx=dt,qr.jsxs=_e}()),qr}process.env.NODE_ENV==="production"?Si.exports=yx():Si.exports=Sx();var u=Si.exports;const Cx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=w.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(p=>{const v=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function uc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Tx}=Object.prototype,{getPrototypeOf:Ci}=Object,{iterator:Lo,toStringTag:dc}=Symbol,$o=(e=>t=>{const n=Tx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>$o(t)===e),Fo=e=>t=>typeof t===e,{isArray:mr}=Array,gr=Fo("undefined");function Gr(e){return e!==null&&!gr(e)&&e.constructor!==null&&!gr(e.constructor)&&zt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const fc=an("ArrayBuffer");function kx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&fc(e.buffer),t}const Ex=Fo("string"),zt=Fo("function"),pc=Fo("number"),Yr=e=>e!==null&&typeof e=="object",Ix=e=>e===!0||e===!1,Bo=e=>{if($o(e)!=="object")return!1;const t=Ci(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(dc in e)&&!(Lo in e)},Nx=e=>{if(!Yr(e)||Gr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ax=an("Date"),jx=an("File"),Px=an("Blob"),_x=an("FileList"),Rx=e=>Yr(e)&&zt(e.pipe),Mx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||zt(e.append)&&((t=$o(e))==="formdata"||t==="object"&&zt(e.toString)&&e.toString()==="[object FormData]"))},Ox=an("URLSearchParams"),[Dx,Lx,$x,Fx]=["ReadableStream","Request","Response","Headers"].map(an),Bx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Xr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),mr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Gr(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 hc(e,t){if(Gr(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,mc=e=>!gr(e)&&e!==Xn;function Ti(){const{caseless:e,skipUndefined:t}=mc(this)&&this||{},n={},r=(o,s)=>{const i=e&&hc(n,s)||s;Bo(n[i])&&Bo(o)?n[i]=Ti(n[i],o):Bo(o)?n[i]=Ti({},o):mr(o)?n[i]=o.slice():(!t||!gr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Xr(arguments[o],r);return n}const zx=(e,t,n,{allOwnKeys:r}={})=>(Xr(t,(o,s)=>{n&&zt(o)?e[s]=uc(o,n):e[s]=o},{allOwnKeys:r}),e),Hx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ux=(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)},Wx=(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&&Ci(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Vx=(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},Kx=e=>{if(!e)return null;if(mr(e))return e;let t=e.length;if(!pc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},qx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ci(Uint8Array)),Gx=(e,t)=>{const r=(e&&e[Lo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Yx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Xx=an("HTMLFormElement"),Jx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),gc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Zx=an("RegExp"),xc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Xr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Qx=e=>{xc(e,(t,n)=>{if(zt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(zt(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+"'")})}})},ev=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return mr(e)?r(e):r(String(e).split(t)),n},tv=()=>{},nv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function rv(e){return!!(e&&zt(e.append)&&e[dc]==="FormData"&&e[Lo])}const ov=e=>{const t=new Array(10),n=(r,o)=>{if(Yr(r)){if(t.indexOf(r)>=0)return;if(Gr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=mr(r)?[]:{};return Xr(r,(i,a)=>{const l=n(i,o+1);!gr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},sv=an("AsyncFunction"),iv=e=>e&&(Yr(e)||zt(e))&&zt(e.then)&&zt(e.catch),vc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",zt(Xn.postMessage)),av=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||vc,W={isArray:mr,isArrayBuffer:fc,isBuffer:Gr,isFormData:Mx,isArrayBufferView:kx,isString:Ex,isNumber:pc,isBoolean:Ix,isObject:Yr,isPlainObject:Bo,isEmptyObject:Nx,isReadableStream:Dx,isRequest:Lx,isResponse:$x,isHeaders:Fx,isUndefined:gr,isDate:Ax,isFile:jx,isBlob:Px,isRegExp:Zx,isFunction:zt,isStream:Rx,isURLSearchParams:Ox,isTypedArray:qx,isFileList:_x,forEach:Xr,merge:Ti,extend:zx,trim:Bx,stripBOM:Hx,inherits:Ux,toFlatObject:Wx,kindOf:$o,kindOfTest:an,endsWith:Vx,toArray:Kx,forEachEntry:Gx,matchAll:Yx,isHTMLForm:Xx,hasOwnProperty:gc,hasOwnProp:gc,reduceDescriptors:xc,freezeMethods:Qx,toObjectSet:ev,toCamelCase:Jx,noop:tv,toFiniteNumber:nv,findKey:hc,global:Xn,isContextDefined:mc,isSpecCompliantForm:rv,toJSONObject:ov,isAsyncFn:sv,isThenable:iv,setImmediate:vc,asap:av,isIterable:e=>e!=null&&zt(e[Lo])};function ke(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)}W.inherits(ke,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:W.toJSONObject(this.config),code:this.code,status:this.status}}});const wc=ke.prototype,bc={};["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=>{bc[e]={value:e}}),Object.defineProperties(ke,bc),Object.defineProperty(wc,"isAxiosError",{value:!0}),ke.from=(e,t,n,r,o,s)=>{const i=Object.create(wc);W.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 ke.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 lv=null;function ki(e){return W.isPlainObject(e)||W.isArray(e)}function yc(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function Sc(e,t,n){return e?e.concat(t).map(function(o,s){return o=yc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function cv(e){return W.isArray(e)&&!e.some(ki)}const uv=W.toFlatObject(W,{},null,function(t){return/^is[A-Z]/.test(t)});function zo(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!W.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(W.isDate(v))return v.toISOString();if(W.isBoolean(v))return v.toString();if(!l&&W.isBlob(v))throw new ke("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(v)||W.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(W.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(W.isArray(v)&&cv(v)||(W.isFileList(v)||W.endsWith(g,"[]"))&&(y=W.toArray(v)))return g=yc(g),y.forEach(function(C,k){!(W.isUndefined(C)||C===null)&&t.append(i===!0?Sc([g],k,s):i===null?g:g+"[]",c(C))}),!1}return ki(v)?!0:(t.append(Sc(x,g,s),c(v)),!1)}const f=[],m=Object.assign(uv,{defaultVisitor:d,convertValue:c,isVisitable:ki});function p(v,g){if(!W.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),W.forEach(v,function(y,b){(!(W.isUndefined(y)||y===null)&&o.call(t,y,W.isString(b)?b.trim():b,g,m))===!0&&p(y,g?g.concat(b):[b])}),f.pop()}}if(!W.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Cc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ei(e,t){this._pairs=[],e&&zo(e,this,t)}const Tc=Ei.prototype;Tc.append=function(t,n){this._pairs.push([t,n])},Tc.toString=function(t){const n=t?function(r){return t.call(this,r,Cc)}:Cc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function dv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kc(e,t,n){if(!t)return e;const r=n&&n.encode||dv;W.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=W.isURLSearchParams(t)?t.toString():new Ei(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Ec{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){W.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ic={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ei,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ii=typeof window<"u"&&typeof document<"u",Ni=typeof navigator=="object"&&navigator||void 0,pv=Ii&&(!Ni||["ReactNative","NativeScript","NS"].indexOf(Ni.product)<0),hv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",mv=Ii&&window.location.href||"http://localhost",Pt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ii,hasStandardBrowserEnv:pv,hasStandardBrowserWebWorkerEnv:hv,navigator:Ni,origin:mv},Symbol.toStringTag,{value:"Module"})),...fv};function gv(e,t){return zo(e,new Pt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Pt.isNode&&W.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function xv(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function vv(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 Nc(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&&W.isArray(o)?o.length:i,l?(W.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!W.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&W.isArray(o[i])&&(o[i]=vv(o[i])),!a)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(r,o)=>{t(xv(r),o,n,0)}),n}return null}function wv(e,t,n){if(W.isString(e))try{return(t||JSON.parse)(e),W.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Jr={transitional:Ic,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=W.isObject(t);if(s&&W.isHTMLForm(t)&&(t=new FormData(t)),W.isFormData(t))return o?JSON.stringify(Nc(t)):t;if(W.isArrayBuffer(t)||W.isBuffer(t)||W.isStream(t)||W.isFile(t)||W.isBlob(t)||W.isReadableStream(t))return t;if(W.isArrayBufferView(t))return t.buffer;if(W.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 gv(t,this.formSerializer).toString();if((a=W.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return zo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),wv(t)):t}],transformResponse:[function(t){const n=this.transitional||Jr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(W.isResponse(t)||W.isReadableStream(t))return t;if(t&&W.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"?ke.from(a,ke.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:Pt.classes.FormData,Blob:Pt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{Jr.headers[e]={}});const bv=W.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"]),yv=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},Ac=Symbol("internals");function Zr(e){return e&&String(e).trim().toLowerCase()}function Ho(e){return e===!1||e==null?e:W.isArray(e)?e.map(Ho):String(e)}function Sv(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 Cv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ai(e,t,n,r,o){if(W.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!W.isString(t)){if(W.isString(r))return t.indexOf(r)!==-1;if(W.isRegExp(r))return r.test(t)}}function Tv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function kv(e,t){const n=W.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 Ht=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Zr(l);if(!d)throw new Error("header name must be a non-empty string");const f=W.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=Ho(a))}const i=(a,l)=>W.forEach(a,(c,d)=>s(c,d,l));if(W.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(W.isString(t)&&(t=t.trim())&&!Cv(t))i(yv(t),n);else if(W.isObject(t)&&W.isIterable(t)){let a={},l,c;for(const d of t){if(!W.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?W.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=Zr(t),t){const r=W.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Sv(o);if(W.isFunction(n))return n.call(this,o,r);if(W.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Zr(t),t){const r=W.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ai(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Zr(i),i){const a=W.findKey(r,i);a&&(!n||Ai(r,r[a],a,n))&&(delete r[a],o=!0)}}return W.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||Ai(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return W.forEach(this,(o,s)=>{const i=W.findKey(r,s);if(i){n[i]=Ho(o),delete n[s];return}const a=t?Tv(s):String(s).trim();a!==s&&delete n[s],n[a]=Ho(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return W.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&W.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[Ac]=this[Ac]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Zr(i);r[a]||(kv(o,i),r[a]=!0)}return W.isArray(t)?t.forEach(s):s(t),this}};Ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Ht.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),W.freezeMethods(Ht);function ji(e,t){const n=this||Jr,r=t||n,o=Ht.from(r.headers);let s=r.data;return W.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function jc(e){return!!(e&&e.__CANCEL__)}function xr(e,t,n){ke.call(this,e??"canceled",ke.ERR_CANCELED,t,n),this.name="CanceledError"}W.inherits(xr,ke,{__CANCEL__:!0});function Pc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ke("Request failed with status code "+n.status,[ke.ERR_BAD_REQUEST,ke.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ev(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Iv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(m*1e3/p):void 0}}function Nv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Uo=(e,t,n=3)=>{let r=0;const o=Iv(50,250);return Nv(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)},_c=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Rc=e=>(...t)=>W.asap(()=>e(...t)),Av=Pt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pt.origin),Pt.navigator&&/(msie|trident)/i.test(Pt.navigator.userAgent)):()=>!0,jv=Pt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),W.isString(r)&&i.push("path="+r),W.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 Pv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _v(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Mc(e,t,n){let r=!Pv(t);return e&&(r||n==!1)?_v(e,t):t}const Oc=e=>e instanceof Ht?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,m){return W.isPlainObject(c)&&W.isPlainObject(d)?W.merge.call({caseless:m},c,d):W.isPlainObject(d)?W.merge({},d):W.isArray(d)?d.slice():d}function o(c,d,f,m){if(W.isUndefined(d)){if(!W.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,m)}function s(c,d){if(!W.isUndefined(d))return r(void 0,d)}function i(c,d){if(W.isUndefined(d)){if(!W.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(Oc(c),Oc(d),f,!0)};return W.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);W.isUndefined(m)&&f!==a||(n[d]=m)}),n}const Dc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ht.from(i),t.url=kc(Mc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(n)){if(Pt.hasStandardBrowserEnv||Pt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(W.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(Pt.hasStandardBrowserEnv&&(r&&W.isFunction(r)&&(r=r(t)),r||r!==!1&&Av(t.url))){const l=o&&s&&jv.read(s);l&&i.set(o,l)}return t},Rv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Dc(e);let s=o.data;const i=Ht.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,m,p,v;function g(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const C=Ht.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Pc(function(E){n(E),g()},function(E){r(E),g()},S),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 ke("Request aborted",ke.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new ke(S,ke.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 S=o.transitional||Ic;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new ke(k,S.clarifyTimeoutError?ke.ETIMEDOUT:ke.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&W.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),W.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Uo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Uo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new xr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Ev(o.url);if(b&&Pt.protocols.indexOf(b)===-1){r(new ke("Unsupported protocol "+b+":",ke.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 ke?d:new xr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new ke(`timeout ${t} of ms exceeded`,ke.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=()=>W.asap(a),l}},Ov=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},Dv=async function*(e,t){for await(const n of Lv(e))yield*Ov(n,t)},Lv=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()}},Lc=(e,t,n,r)=>{const o=Dv(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})},$c=64*1024,{isFunction:Wo}=W,$v=(({Request:e,Response:t})=>({Request:e,Response:t}))(W.global),{ReadableStream:Fc,TextEncoder:Bc}=W.global,zc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fv=e=>{e=W.merge.call({skipUndefined:!0},$v,e);const{fetch:t,Request:n,Response:r}=e,o=t?Wo(t):typeof fetch=="function",s=Wo(n),i=Wo(r);if(!o)return!1;const a=o&&Wo(Fc),l=o&&(typeof Bc=="function"?(v=>g=>v.encode(g))(new Bc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&zc(()=>{let v=!1;const g=new n(Pt.origin,{body:new Fc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&zc(()=>W.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 ke(`Response type '${v}' is not supported`,ke.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(W.isBlob(v))return v.size;if(W.isSpecCompliantForm(v))return(await new n(Pt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(W.isArrayBufferView(v)||W.isArrayBuffer(v))return v.byteLength;if(W.isURLSearchParams(v)&&(v=v+""),W.isString(v))return(await l(v)).byteLength},p=async(v,g)=>{const x=W.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:A,withCredentials:_="same-origin",fetchOptions:L}=Dc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Mv([b,C&&C.toAbortSignal()],k),X=null;const O=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let Y;try{if(T&&c&&x!=="get"&&x!=="head"&&(Y=await p(A,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),M;if(W.isFormData(y)&&(M=J.headers.get("content-type"))&&A.setContentType(M),J.body){const[B,P]=_c(Y,Uo(Rc(T)));y=Lc(J.body,$c,B,P)}}W.isString(_)||(_=_?"include":"omit");const V=s&&"credentials"in n.prototype,K={...L,signal:U,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:V?_:void 0};X=s&&new n(g,K);let D=await(s?F(X,L):F(g,K));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&O)){const J={};["status","statusText","headers"].forEach($=>{J[$]=D[$]});const M=W.toFiniteNumber(D.headers.get("content-length")),[B,P]=S&&_c(M,Uo(Rc(S),!0))||[];D=new r(Lc(D.body,$c,B,()=>{P&&P(),O&&O()}),J)}E=E||"text";let q=await f[W.findKey(f,E)||"text"](D,v);return!I&&O&&O(),await new Promise((J,M)=>{Pc(J,M,{data:q,headers:Ht.from(D.headers),status:D.status,statusText:D.statusText,config:v,request:X})})}catch(V){throw O&&O(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new ke("Network Error",ke.ERR_NETWORK,v,X),{cause:V.cause||V}):ke.from(V,V&&V.code,v,X)}}},Bv=new Map,Hc=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=Bv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Fv(t)),d=c;return c};Hc();const Pi={http:lv,xhr:Rv,fetch:{get:Hc}};W.forEach(Pi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Uc=e=>`- ${e}`,zv=e=>W.isFunction(e)||e===null||e===!1,Wc={getAdapter:(e,t)=>{e=W.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,!zv(r)&&(o=Pi[(a=String(r)).toLowerCase()],o===void 0))throw new ke(`Unknown adapter '${a}'`);if(o&&(W.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(Uc).join(`
|
|
34
|
-
`):" "+Uc(i[0]):"as no adapter specified";throw new
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ko.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(U.isFunction(o)?n.paramsSerializer={serialize:o}:Ko.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ko.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&U.merge(s.common,s[n.method]);s&&U.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ht.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=[Vc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let p=n;for(;f<m;){const v=a[f++],g=a[f++];try{p=v(p)}catch(x){g.call(this,x);break}}try{d=Vc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,m=c.length;f<m;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Mc(t.baseURL,t.url,t.allowAbsoluteUrls);return kc(n,t.params,t.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),U.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let Uv=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 xr(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 Wv(e){return function(n){return e.apply(null,n)}}function Vv(e){return U.isObject(e)&&e.isAxiosError===!0}const Ri={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(Ri).forEach(([e,t])=>{Ri[t]=e});function Gc(e){const t=new Zn(e),n=uc(Zn.prototype.request,t);return U.extend(n,Zn.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Gc(Jn(e,o))},n}const vt=Gc(Jr);vt.Axios=Zn,vt.CanceledError=xr,vt.CancelToken=Uv,vt.isCancel=jc,vt.VERSION=Kc,vt.toFormData=zo,vt.AxiosError=Ee,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=Wv,vt.isAxiosError=Vv,vt.mergeConfig=Jn,vt.AxiosHeaders=Ht,vt.formToJSON=e=>Nc(U.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Wc.getAdapter,vt.HttpStatusCode=Ri,vt.default=vt;const{Axios:CN,AxiosError:TN,CanceledError:kN,isCancel:Yc,CancelToken:EN,VERSION:IN,all:NN,Cancel:AN,isAxiosError:jN,spread:PN,toFormData:_N,AxiosHeaders:RN,HttpStatusCode:MN,formToJSON:ON,getAdapter:DN,mergeConfig:LN}=vt,Xc=typeof window<"u"?window.__API_BASE_URL__:void 0,Jc=Xc?vn(Xc):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let qo=null;const Mi=new Set;function Zc(){return qo}function Go(e){qo=e,Mi.forEach(t=>t(e))}function Qc(e){return Mi.add(e),()=>Mi.delete(e)}const eu=3e4,tu=9e4,Xt=vt.create({...Jc?{baseURL:Jc}:{},timeout:eu,withCredentials:!0});Xt.interceptors.request.use(e=>(qo&&(e.headers.Authorization=`Bearer ${qo}`),e)),Xt.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),Go(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 Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Yo(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function nu(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Xo{get baseUrl(){const t=Xt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Go(t.authToken)}getAuthToken(){return Zc()}setAuthToken(t){Go(t)}onTokenChange(t){return Qc(t)}async listThreads(){const t=await Jt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Yo("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await nu(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Yo(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Jt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:tu,signal:t.signal});return Lt(n)}async cancelRun(t){const n=await Yo("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return Lt(r)}}const Nn=new Xo,Kv=Xo,qv=Xo;async function Di(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Gv(e,t){const n=await Di(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Li(e,t){return await(await Di(`/files/${e}/view`,t)).text()}async function ru(e,t){const n=await Di(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/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 Yv(e){return await Jt(`/files/${e}`)}async function ou(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const su=w.createContext(null);function iu({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(su.Provider,{value:r,children:e})}async function au(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 lu(e=[]){const t=[],n=[];for(const r of e)try{const o=await au(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Qr(){const e=w.useContext(su);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function cu(e){return!!e&&typeof e=="object"&&"data"in e}function $i(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function eo(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xv(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 uu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function du(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function fu(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??du(e);let l="",c=e.slice();if(s){const f=Jv(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 p=m.text??"",v={...m,text:p+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function pu(e){return e.replace(/\s+/g," ").trim()}function Jv(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=pu(e),o=pu(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 Zv(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 eo(e,r,s)}return e}function hu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Qv(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[f,m]=w.useState(""),[p,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),A=w.useRef(null),M=w.useRef(null),L=w.useRef(null),F=w.useRef(null),z=w.useRef({messageId:null,lastSeq:null,lastText:""}),X=w.useCallback(K=>{o(K)},[]),O=w.useCallback(()=>{m(""),v(null),d(null),M.current=null,L.current=null,F.current=null,k(null),z.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=w.useCallback(()=>{var V;console.debug("[use-chat] stop() invoked - aborting stream");const K=(V=A.current)==null?void 0:V.threadId,D=()=>{var Z;(Z=S.current)==null||Z.abort(),S.current=null,A.current=null,l(!1),b(!1),E.current=0,x(0)};(K?Nn.cancelRun(K).catch(Z=>{console.warn("[use-chat] cancel run failed:",Z)}):Promise.resolve()).finally(D)},[]),W=w.useCallback((K,D,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),M.current=null,L.current=null,F.current=null,k(null),z.current={messageId:null,lastSeq:null,lastText:""};const V=new AbortController;S.current=V;let Z=null,R=null,q=!1;return A.current={threadId:K.threadId??null,headers:{}},(async()=>{var $,H,j,_,G,Q,oe,ae,ve,we,Re,Me,Ye,Le,$e,ft,Qe,gt;const P=He=>{var Oe;try{const De=JSON.parse(JSON.stringify(He));return(Oe=De==null?void 0:De.payload)!=null&&Oe.files_info&&Array.isArray(De.payload.files_info)&&(De.payload.files_info=De.payload.files_info.map(Ce=>({...Ce,data:Ce!=null&&Ce.data?`<base64 ${String(Ce.data).length} chars>`:Ce==null?void 0:Ce.data}))),De}catch{return He}};try{let He={};try{if(r)He={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ve=window.__AUTH_TOKEN__,Et=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let ne=null;try{const et=(H=window.localStorage)==null?void 0:H.getItem("chat-settings");et&&(ne=((j=JSON.parse(et))==null?void 0:j.apiKey)||null)}catch{}const me=Ve||Et||ne||null;me&&(He={Authorization:`Bearer ${me}`})}}catch{}console.debug("[use-chat] POST",t+n,P(K));let Oe={};if(typeof window<"u")try{const We=(_=window.localStorage)==null?void 0:_.getItem("authSessionId");We&&(Oe={"X-Session-Id":We})}catch{}const De={...He,...Oe,...s.current},Ce={"Content-Type":"application/json",Accept:"text/event-stream",...De},Fe=await fetch(t+n,{method:"POST",headers:Ce,body:JSON.stringify(K),signal:V.signal,credentials:i});if(A.current&&(A.current.headers=De),!Fe.ok||!Fe.body){const We=await Fe.text().catch(()=>"");console.debug("[use-chat] non-OK response",Fe.status,We==null?void 0:We.slice(0,500));const Ve=`stream ${Fe.status}${We?": "+We:""}`;throw(G=I==null?void 0:I.onConnectionError)==null||G.call(I,Ve),q=!0,Z="error",R=Ve,new Error(Ve)}b(!0);const at=Fe.body.getReader(),jt=new TextDecoder;let lt="",Nt=[];E.current=0,x(0);let pt=0,kt=null;const ct=()=>{if(Nt.length){const We=Nt.join("");Nt=[],T.current&&m(Ve=>Ve+We)}kt=null},qt=()=>{typeof window<"u"&&kt==null&&(kt=requestAnimationFrame(ct))};let At=Date.now();const Pt=setInterval(()=>{var We;if(Date.now()-At>18e5){const Ve="Stream idle timeout";d(Ve),Z="error",R=Ve,V.abort(),(We=I==null?void 0:I.onError)==null||We.call(I,Ve)}},5e3),xt=1024*1024;try{const We=Fe.headers.get("X-Thread-Id")||Fe.headers.get("x-thread-id"),Ve=Fe.headers.get("X-Thread-Created")||Fe.headers.get("x-thread-created"),Et=We??null,ne=String(Ve??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:Et}),(Q=I==null?void 0:I.onOpen)==null||Q.call(I,{threadId:Et,created:ne});;){const{value:me,done:et}=await at.read();if(et)break;lt+=jt.decode(me,{stream:!0}),lt.length>xt&&(lt="",console.warn("Stream buffer reset: exceeded 1MB"));let de;for(;(de=lt.indexOf(`
|
|
34
|
+
`):" "+Uc(i[0]):"as no adapter specified";throw new ke("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Pi};function _i(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xr(null,e)}function Vc(e){return _i(e),e.headers=Ht.from(e.headers),e.data=ji.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Wc.getAdapter(e.adapter||Jr.adapter,e)(e).then(function(r){return _i(e),r.data=ji.call(e,e.transformResponse,r),r.headers=Ht.from(r.headers),r},function(r){return jc(r)||(_i(e),r&&r.response&&(r.response.data=ji.call(e,e.transformResponse,r.response),r.response.headers=Ht.from(r.response.headers))),Promise.reject(r)})}const Kc="1.12.2",Vo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Vo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const qc={};Vo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Kc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new ke(o(i," has been removed"+(n?" in "+n:"")),ke.ERR_DEPRECATED);return n&&!qc[i]&&(qc[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}},Vo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Hv(e,t,n){if(typeof e!="object")throw new ke("options must be an object",ke.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 ke("option "+s+" must be "+l,ke.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new ke("Unknown option "+s,ke.ERR_BAD_OPTION)}}const Ko={assertOptions:Hv,validators:Vo},xn=Ko.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ec,response:new Ec}}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=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ko.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(W.isFunction(o)?n.paramsSerializer={serialize:o}:Ko.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ko.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&W.merge(s.common,s[n.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ht.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=[Vc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let p=n;for(;f<m;){const v=a[f++],g=a[f++];try{p=v(p)}catch(x){g.call(this,x);break}}try{d=Vc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,m=c.length;f<m;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Mc(t.baseURL,t.url,t.allowAbsoluteUrls);return kc(n,t.params,t.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),W.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let Uv=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 xr(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 Wv(e){return function(n){return e.apply(null,n)}}function Vv(e){return W.isObject(e)&&e.isAxiosError===!0}const Ri={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(Ri).forEach(([e,t])=>{Ri[t]=e});function Gc(e){const t=new Zn(e),n=uc(Zn.prototype.request,t);return W.extend(n,Zn.prototype,t,{allOwnKeys:!0}),W.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Gc(Jn(e,o))},n}const gt=Gc(Jr);gt.Axios=Zn,gt.CanceledError=xr,gt.CancelToken=Uv,gt.isCancel=jc,gt.VERSION=Kc,gt.toFormData=zo,gt.AxiosError=ke,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=Wv,gt.isAxiosError=Vv,gt.mergeConfig=Jn,gt.AxiosHeaders=Ht,gt.formToJSON=e=>Nc(W.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=Wc.getAdapter,gt.HttpStatusCode=Ri,gt.default=gt;const{Axios:CN,AxiosError:TN,CanceledError:kN,isCancel:Yc,CancelToken:EN,VERSION:IN,all:NN,Cancel:AN,isAxiosError:jN,spread:PN,toFormData:_N,AxiosHeaders:RN,HttpStatusCode:MN,formToJSON:ON,getAdapter:DN,mergeConfig:LN}=gt,Xc=typeof window<"u"?window.__API_BASE_URL__:void 0,Jc=Xc?vn(Xc):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let qo=null;const Mi=new Set;function Zc(){return qo}function Go(e){qo=e,Mi.forEach(t=>t(e))}function Qc(e){return Mi.add(e),()=>Mi.delete(e)}const eu=3e4,tu=9e4,Yt=gt.create({...Jc?{baseURL:Jc}:{},timeout:eu,withCredentials:!0});Yt.interceptors.request.use(e=>(qo&&(e.headers.Authorization=`Bearer ${qo}`),e)),Yt.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),Go(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 Xt(e,t){return Yt.defaults.baseURL?(await Yt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Yo(e,t,n){return Yt.defaults.baseURL?(await Yt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function nu(e,t,n){return Yt.defaults.baseURL?(await Yt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Yt.defaults.baseURL?(await Yt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Xo{get baseUrl(){const t=Yt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Yt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Go(t.authToken)}getAuthToken(){return Zc()}setAuthToken(t){Go(t)}onTokenChange(t){return Qc(t)}async listThreads(){const t=await Xt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Xt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Yo("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await nu(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Yo(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Xt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Xt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Xt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Xt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Xt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Xt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:tu,signal:t.signal});return Lt(n)}async cancelRun(t){const n=await Yo("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return Lt(r)}}const Nn=new Xo,Kv=Xo,qv=Xo;async function Di(e,t){return await Xt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Gv(e,t){const n=await Di(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Li(e,t){return await(await Di(`/files/${e}/view`,t)).text()}async function ru(e,t){const n=await Di(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Xt(`/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 Yv(e){return await Xt(`/files/${e}`)}async function ou(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Xt("/files",{params:r})}const su=w.createContext(null);function iu({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(su.Provider,{value:r,children:e})}async function au(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 lu(e=[]){const t=[],n=[];for(const r of e)try{const o=await au(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Qr(){const e=w.useContext(su);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function cu(e){return!!e&&typeof e=="object"&&"data"in e}function $i(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function eo(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xv(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 uu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function du(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function fu(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??du(e);let l="",c=e.slice();if(s){const f=Jv(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 p=m.text??"",v={...m,text:p+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function pu(e){return e.replace(/\s+/g," ").trim()}function Jv(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=pu(e),o=pu(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 Zv(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 eo(e,r,s)}return e}function hu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Qv(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[f,m]=w.useState(""),[p,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),A=w.useRef(null),_=w.useRef(null),L=w.useRef(null),F=w.useRef(null),U=w.useRef({messageId:null,lastSeq:null,lastText:""}),X=w.useCallback(K=>{o(K)},[]),O=w.useCallback(()=>{m(""),v(null),d(null),_.current=null,L.current=null,F.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=w.useCallback(()=>{var q;console.debug("[use-chat] stop() invoked - aborting stream");const K=(q=A.current)==null?void 0:q.threadId,D=()=>{var J;(J=S.current)==null||J.abort(),S.current=null,A.current=null,l(!1),b(!1),E.current=0,x(0)};(K?Nn.cancelRun(K).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(D)},[]),V=w.useCallback((K,D,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),_.current=null,L.current=null,F.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""};const q=new AbortController;S.current=q;let J=null,M=null,B=!1;return A.current={threadId:K.threadId??null,headers:{}},(async()=>{var $,z,j,R,G,Q,se,ie,Se,xe,Oe,De,Ge,Ye,He,st,Xe,St;const P=Le=>{var Ve;try{const je=JSON.parse(JSON.stringify(Le));return(Ve=je==null?void 0:je.payload)!=null&&Ve.files_info&&Array.isArray(je.payload.files_info)&&(je.payload.files_info=je.payload.files_info.map(Ie=>({...Ie,data:Ie!=null&&Ie.data?`<base64 ${String(Ie.data).length} chars>`:Ie==null?void 0:Ie.data}))),je}catch{return Le}};try{let Le={};try{if(r)Le={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ue=window.__AUTH_TOKEN__,It=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let ne=null;try{const rt=(z=window.localStorage)==null?void 0:z.getItem("chat-settings");rt&&(ne=((j=JSON.parse(rt))==null?void 0:j.apiKey)||null)}catch{}const me=Ue||It||ne||null;me&&(Le={Authorization:`Bearer ${me}`})}}catch{}console.debug("[use-chat] POST",t+n,P(K));let Ve={};if(typeof window<"u")try{const ze=(R=window.localStorage)==null?void 0:R.getItem("authSessionId");ze&&(Ve={"X-Session-Id":ze})}catch{}const je={...Le,...Ve,...s.current},Ie={"Content-Type":"application/json",Accept:"text/event-stream",...je},Ne=await fetch(t+n,{method:"POST",headers:Ie,body:JSON.stringify(K),signal:q.signal,credentials:i});if(A.current&&(A.current.headers=je),!Ne.ok||!Ne.body){const ze=await Ne.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ne.status,ze==null?void 0:ze.slice(0,500));const Ue=`stream ${Ne.status}${ze?": "+ze:""}`;throw(G=I==null?void 0:I.onConnectionError)==null||G.call(I,Ue),B=!0,J="error",M=Ue,new Error(Ue)}b(!0);const ut=Ne.body.getReader(),jt=new TextDecoder;let ft="",At=[];E.current=0,x(0);let pt=0,Ct=null;const lt=()=>{if(At.length){const ze=At.join("");At=[],T.current&&m(Ue=>Ue+ze)}Ct=null},gn=()=>{typeof window<"u"&&Ct==null&&(Ct=requestAnimationFrame(lt))};let Tt=Date.now();const Dt=setInterval(()=>{var ze;if(Date.now()-Tt>18e5){const Ue="Stream idle timeout";d(Ue),J="error",M=Ue,q.abort(),(ze=I==null?void 0:I.onError)==null||ze.call(I,Ue)}},5e3),mt=1024*1024;try{const ze=Ne.headers.get("X-Thread-Id")||Ne.headers.get("x-thread-id"),Ue=Ne.headers.get("X-Thread-Created")||Ne.headers.get("x-thread-created"),It=ze??null,ne=String(Ue??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:It}),(Q=I==null?void 0:I.onOpen)==null||Q.call(I,{threadId:It,created:ne});;){const{value:me,done:rt}=await ut.read();if(rt)break;ft+=jt.decode(me,{stream:!0}),ft.length>mt&&(ft="",console.warn("Stream buffer reset: exceeded 1MB"));let de;for(;(de=ft.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const
|
|
38
|
-
`);if(!Ne)continue;let Ue;try{Ue=JSON.parse(Ne)}catch{console.debug("[use-chat] malformed SSE:",Ne.slice(0,200));continue}const ut=cu(Ue)?Ue.data:Ue;if(!ut){console.warn("[use-chat] dropped envelope event without payload",Ue);continue}const Se=ut;At=Date.now();const mt=Se.seq;if(mt!==void 0){if(mt<=pt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:mt,lastProcessedSeq:pt,type:Se.type});continue}pt>0&&mt>pt+1&&((oe=I==null?void 0:I.onGap)==null||oe.call(I,{from:pt,to:mt})),pt=mt,E.current=mt,x(mt)}if(Se.type==="message.start"&&Se.role==="assistant"){const Xe=hu(Se.model);z.current={messageId:Se.id,lastSeq:mt??null,lastText:""},k({id:Se.id,role:"assistant",name:Xe??void 0,model:Se.model,createdAt:new Date().toISOString(),content:[]})}if(Se.type==="checkpoint")M.current=Se.checkpointId??null,L.current=Se.checkpointNs??null,v(Se.checkpointId??null);else if(Se.type==="state_history"){F.current=Se;try{const dt=Yn(Se).latest;dt&&(M.current=dt.checkpointId??null,L.current=dt.checkpointNs??null,v(dt.checkpointId??null))}catch(Xe){console.warn("[use-chat] Failed to hydrate state_history payload",Xe)}}try{D==null||D(Se)}catch(Xe){console.error("[use-chat] Error in onEvent callback:",Xe,"for event:",Se.type)}if(Se.type==="message.delta"){k(dt=>{const je=z.current;if(!dt||je.messageId!==dt.id)return dt;const{newParts:N,newMeta:J,changed:se}=fu(dt.content??[],Se.delta,{lastSeq:je.lastSeq,lastText:je.lastText},mt??null);return se?(z.current={...je,lastSeq:J.lastSeq??je.lastSeq,lastText:J.lastText??je.lastText},{...dt,content:N}):dt});const Xe=Se.delta.filter(dt=>dt.type==="text").map(dt=>dt.text).join("");Xe&&e.autoAppendAssistant!==!1&&(Nt.push(Xe),qt())}else if(Se.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ae=I==null?void 0:I.onHeartbeat)==null||ae.call(I,Se)}catch(Xe){console.warn("[use-chat] heartbeat callback failed",Xe)}}else if(kt!==null&&cancelAnimationFrame(kt),ct(),Se.type==="checkpoint")v(Se.checkpointId);else if(Se.type==="error"){const Xe=Se;if(d(Xe.message),Z="error",R=Xe.message,Xe.error_type==="auth_error"||Xe.code==="TOKEN_EXPIRED"||((ve=Xe.message)==null?void 0:ve.includes("token"))||((we=Xe.message)==null?void 0:we.includes("401"))||((Re=Xe.message)==null?void 0:Re.includes("unauthorized"))||((Me=Xe.message)==null?void 0:Me.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Xe.message);try{(Ye=I==null?void 0:I.onAuthError)==null||Ye.call(I,Xe.message)}catch(je){console.warn("[use-chat] onAuthError handler failed",je)}V.abort()}}}}ct(),Z===null&&!V.signal.aborted&&(Z="complete")}catch(We){if(We.name==="AbortError")Z=Z??"aborted";else{const Ve=We.message||String(We);Z="error",R=Ve,d(Ve),(Le=I==null?void 0:I.onError)==null||Le.call(I,Ve)}}finally{try{await at.cancel()}catch{}finally{($e=at.releaseLock)==null||$e.call(at)}kt!==null&&typeof window<"u"&&window.cancelAnimationFrame(kt),clearInterval(Pt)}}catch(He){if(He.name==="AbortError")Z=Z??"aborted";else{const Oe=He.message||String(He);Z="error",R=Oe,d(Oe),(ft=I==null?void 0:I.onError)==null||ft.call(I,Oe),q||((Qe=I==null?void 0:I.onConnectionError)==null||Qe.call(I,Oe),q=!0)}}finally{const He=E.current,Oe=M.current,De=L.current,Ce=F.current,Fe=Z??(V.signal.aborted?"aborted":R?"error":"complete");try{(gt=I==null?void 0:I.onClosed)==null||gt.call(I,{reason:Fe,lastSeq:He,lastCheckpointId:Oe,lastCheckpointNs:De,lastStateHistory:Ce,error:R})}catch(at){console.warn("[use-chat] onClosed callback failed",at)}l(!1),b(!1),S.current=null,E.current=0,x(0),A.current=null}})(),{close:()=>V.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var K;T.current=!1,(K=S.current)==null||K.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:C,lastCheckpointId:p,lastSeq:g,connected:y,stream:W,stop:Y,clear:O,setToken:X}}const ew=["detail","message","error","description","title"];function Jo(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=Jo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of ew){const r=Jo(t[n]);if(r)return r}if("errors"in t){const n=Jo(t.errors);if(n)return n}}return null}function tw(e){if(!e)return"Request failed";const t=e.response,n=Jo(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 mu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[f,m]=w.useState(null),[p,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const A=w.useCallback(async()=>{d(!0),m(null);try{const D=await e.listThreads();i(D??[])}catch(D){const I=String(D);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),M=w.useCallback(async()=>{x(!0),y(null);try{const D=await e.listSharedThreads();v(D??[])}catch(D){const I=String(D);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{A()},[A]),w.useEffect(()=>{M()},[M]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async D=>{try{const I=await e.createThread(D);return l(I.threadId),await A(),I.threadId}catch(I){const V=String(I);return n==null||n(V),null}},[e,n,A]),F=w.useCallback(async D=>{const I=s;i(Z=>Z.filter(R=>R.threadId!==D));const V=new AbortController;E.current.set(D,V);try{await e.deleteThread(D),T.current===D&&(l(null),o==null||o())}catch(Z){i(I);const R=String(Z);n==null||n(R)}finally{E.current.delete(D)}},[e,o,n,s]),z=w.useCallback(async(D,I)=>{try{await e.updateThread(D,I),await A()}catch(V){n==null||n(String(V))}},[e,n,A]),X=w.useCallback(async(D,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(D,I),await M(),C("Shared successfully")}catch(V){const Z=tw(V);throw n==null||n(Z),C(`Failed to share: ${Z}`),new Error(Z)}finally{S(!1)}},[e,n,M]),O=w.useCallback(async(D,I)=>{try{await e.unshareThread(D,I),await M()}catch(V){const Z=String(V);throw n==null||n(Z),V}},[e,n,M]),Y=w.useMemo(()=>({createThread:L,deleteThread:F,renameThread:z,refreshThreads:A,refreshSharedThreads:M,shareThread:X,unshareThread:O}),[L,F,z,A,M,X,O]),W=w.useCallback(D=>{if(!(D!=null&&D.threadId))return;const I={threadId:D.threadId,title:D.title||`Thread ${D.threadId.slice(0,8)}`,createdAt:D.createdAt||new Date().toISOString(),updatedAt:D.updatedAt||new Date().toISOString(),messageCount:D.messageCount??1};i(V=>{let Z=!1;const R=V.map(q=>q.threadId===I.threadId?(Z=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...q,title:I.title??q.title,updatedAt:I.updatedAt??q.updatedAt,messageCount:I.messageCount??q.messageCount}):q);return Z?R:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...V])})},[]),K=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:W,shareInFlight:k,shareStatus:b,clearShareStatus:K}}const gu=w.createContext(null);function xu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Qr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=mu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,f,m,p,g,x,y,v]);return u.jsx(gu.Provider,{value:b,children:e})}function vr(){const e=w.useContext(gu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function to(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=nw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function nw(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function vu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function no(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(no).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(vu(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=no(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 wr(e){if(typeof e=="string")return e;if(vu(e))return"";try{const t=no(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function rw(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function ow(e){const t=wr(e);return typeof e=="string"&&rw(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=to(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 sw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Fi(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 wu(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function iw(e){const t=r=>{try{const o=no(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 aw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function bu(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 lw(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function cw(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function uw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=lw(n),i=o?`data:${s};base64,${e}`:t,a=cw(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function dw(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 uw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function yu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const fw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function pw(e,t){var n;switch(t.type){case"reset":return{messages:$i(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=$i(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=$i(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Su(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Su(o,s),e):e}default:return e}}function hw(e=[]){const[t,n]=w.useReducer(pw,{...fw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.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 Su(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=hu(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 gw(e,t);if(t.type==="tool.progress")return xw(e,t);if(t.type==="tool.end")return vw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??uu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},f=d[s],m=f??{lastSeq:null,lastText:du(l.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof m.lastSeq=="number"&&p<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=fu(l.content,t.delta,m,p);if(!x)return e;const y={...l,content:v},b=eo(i,a,y),C=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,k=C?{...d,[s]:g}:c;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??uu(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=Zv(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=Yn(t),i=s.interrupt,a=s.latest,l=i===null?Xv(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 Bi(e){return e.call_id??e.id??null}function Cu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Tu(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 zi(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||Fi(r).toolCallId===t)return n}return-1}function mw(e){if(e==null)return[];const t=br(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=wr(t??e);return n?[{type:"text",text:n}]:[]}function ku(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function gw(e,t){const n=Bi(t),r=zi(e.messages,n),o=t.name??t.tool??void 0,s=Cu(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:eo(e.messages,r,d)}}const i=Tu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function xw(e,t){const n=Bi(t);if(!n)return e;const r=zi(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=ku(e.messages[r],o);return{...e,messages:eo(e.messages,r,a)}}function vw(e,t){const n=Bi(t),r=Cu(t);let o=e.messages,s=zi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Tu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=mw(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=ku(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:eo(o,s,p)}}function Eu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,f]=w.useState(null),p=w.useMemo(()=>Yn(d),[d]).checkpoints,v=sc(p),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),A=w.useRef(null),M=w.useRef(null),L=w.useRef(null),F=w.useRef(null),z=w.useRef(new Map),X=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const O=w.useCallback(async P=>{var H,j;if(!P.threadId)return;const $=P.threadId;(H=P.onStart)==null||H.call(P),P.setLoading(!0);try{await P.action($)}catch(_){if(!Yc(_)&&T.current===$){const Q=String(_);(j=P.handleError)==null||j.call(P,Q),n==null||n(Q)}throw _}finally{P.setLoading(!1)}},[n]),Y=w.useCallback(async(P,$)=>{var Q;if(!P)return;const H=`${P}:${$??"latest"}`,j=z.current.get(H);if(j)return j;(Q=X.current)==null||Q.abort();const _=new AbortController;X.current=_;const G=O({threadId:P,setLoading:y,onStart:()=>S(null),handleError:oe=>S(oe),action:async oe=>{const ae=await e.getStateHistory({threadId:oe,checkpointId:$??void 0,signal:_.signal});if(T.current!==oe){console.log(`[useThreadHistoryState] Thread changed during load (was ${oe}, now ${T.current}), discarding stale data`);return}const{checkpoints:ve}=Yn(ae),we=ve.find(Re=>Re.messages&&Re.messages.length>0)??($?ve.find(Re=>Re.checkpointId===$):null)??ve[0];t((we==null?void 0:we.messages)??[],{checkpointId:(we==null?void 0:we.checkpointId)??null,checkpointNs:(we==null?void 0:we.checkpointNs)??null,pendingInterrupt:(we==null?void 0:we.interrupt)??null}),f(ae)}});z.current.set(H,G);try{await G}finally{z.current.delete(H),X.current===_&&(X.current=null)}return T.current===P&&(F.current=H),G},[e,t,O]),W=w.useCallback(async(P,$)=>{L.current=P;try{await Y(P,$)}catch(H){if(!Yc(H))throw H}finally{L.current===P&&(L.current=null)}},[Y]),K=w.useCallback(P=>{A.current=P},[]),D=w.useCallback(P=>{M.current=P},[]),I=w.useCallback(P=>{const $=P.threadId??T.current;if(!$||T.current&&T.current!==$)return;const{checkpoints:H}=Yn(P);if(!H.length)return;const j=H.find(G=>G.messages&&G.messages.length>0)??H.find(G=>!!G.checkpointId)??H[0],_=M.current===$;!l&&!_&&t((j==null?void 0:j.messages)??[],{checkpointId:(j==null?void 0:j.checkpointId)??null,checkpointNs:(j==null?void 0:j.checkpointNs)??null,pendingInterrupt:(j==null?void 0:j.interrupt)??null}),f(P),F.current=`${$}:latest`,A.current=null,M.current===$&&(M.current=null)},[t,l]),V=w.useCallback(async(P,$)=>{const H=T.current;await O({threadId:H,setLoading:C,action:async j=>{const _=await e.getStateHistory({threadId:j,checkpointId:P,checkpointNs:$??void 0});if(T.current!==j)return;const{checkpoints:G}=Yn(_),Q=G.find(oe=>oe.checkpointId===P&&($?oe.checkpointNs===$:!0));if(!Q){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:P,checkpointNs:$});return}f(_),t(Q.messages??[],{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null})}}).catch(()=>{})},[e,t,O]),Z=w.useCallback((P,$)=>{t(c(),{checkpointId:P??null,checkpointNs:$??null})},[c,t]),R=w.useCallback(async()=>{T.current&&await W(T.current)},[W]);w.useEffect(()=>{if(!a||!r||x||l)return;if(A.current===r){A.current=null,E.current=r;return}if(M.current===r){E.current=r;return}if(L.current===r){L.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let P;const $=`${r}:latest`;F.current!==$&&W(r,P)},[a,r,s,i,o,x,l,W]);const q=w.useCallback(()=>{f(null),y(!1),C(!1),S(null),A.current=null,M.current=null,E.current=null,F.current=null,L.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:W,navigateToCheckpoint:V,setCurrentCheckpointId:Z,returnToLatest:R,handleStateHistoryEvent:I,markSkipNextLoad:K,markStreamPendingThread:D,resetHistoryState:q}}const Iu=w.createContext(null),Nu=w.createContext(null);function ro(){const e=w.useContext(Iu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Au(){const e=w.useContext(Nu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function ju({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Qr(),{currentThreadId:l}=vr(),{state:c,seed:d,pushUser:f,onEvent:m}=hw(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:M,resetHistoryState:L}=Eu({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[F,z]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[X,O]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),L())},[l,d,L]);const Y=w.useCallback(V=>z(()=>V),[]),W=w.useCallback(V=>O(()=>V),[]),K=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),D=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:p,checkpointIndex:g,timelineCheckpoints:v,metadata:K,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:F,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:F,respondToInterrupt:X,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:M,resetHistoryState:L,pushUser:f,onEvent:m}),[l,c,p,v,g,K,x,y,b,F,k,S,T,C,X,g.messagePreviews,E,A,M,L,f,m]),I=w.useMemo(()=>({registerClearThread:Y,registerRespondToInterrupt:W}),[Y,W]);return u.jsx(Nu.Provider,{value:I,children:u.jsx(Iu.Provider,{value:D,children:e})})}function Pu(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Rn(r,t)??null}function ww(e){const t=Pu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Pu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function bw(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 yw(e,t){const n=[...e].sort(bw);for(const r of n){if(r.messageId!==t)continue;const o=ww(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 _u=w.createContext(null),Ru=w.createContext(!1);function Sw({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}=Qr(),m=w.useMemo(()=>vn(f),[f]),{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=Qv({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(xu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(ju,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Ru.Provider,{value:!0,children:u.jsx(Cw,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function Cw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:v}=vr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=ro(),{registerClearThread:E,registerRespondToInterrupt:A}=Au(),M=w.useCallback(K=>{v(K),p.current!==K.threadId&&((K.created??!p.current)&&b(K.threadId),C(K.threadId),m(K.threadId))},[v,b,C,m,p]),L=w.useCallback(K=>{K.type==="thread_info"?M(K):K.type==="state_history"?y(K):K.type==="tool.end"?i==null||i(K):T(K)},[M,y,T,i]),F=w.useCallback(K=>{a(K,L,{onError:D=>{console.error("[StreamingProvider] Stream error:",D),r==null||r(D)},onAuthError:D=>{console.error("[StreamingProvider] Auth error:",D),o==null||o(D)},onConnectionError:D=>{console.error("[StreamingProvider] Connection error:",D),s==null||s(D)}})},[a,L,r,o,s]),z=w.useRef(g);w.useEffect(()=>{z.current=g},[g]);const X=w.useCallback(async(K,D,I)=>{const V=p.current;if(!V)throw new Error("No active thread to handle interrupt");const Z=K?D??!0:!1,R=z.current,q={threadId:V,checkpointId:R.id??void 0,checkpointNs:R.namespace??void 0,command:{kind:"resume",value:Z},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};F(q)},[p,F]);w.useEffect(()=>{A(X)},[X,A]);const O=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(O)},[O,E]);const Y=w.useCallback(async(K,D)=>{let I=p.current;const V=(K==null?void 0:K.text)??"",Z=(K==null?void 0:K.attachments)??[],R=(V==null?void 0:V.trim())??"",q={...(K==null?void 0:K.payload)??{}},P=Array.isArray(q.messages)?q.messages:void 0;P&&delete q.messages;const $=!!(P&&P.length);if(!I&&!R&&Z.length===0&&!$)return;if(!I){const Le=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=`${Le}${$e}`,b(I),m(I)}const{contentParts:H,filesInfo:j}=await lu(Z),_=[...H];R&&_.push({type:"text",text:V});const G=D==null?void 0:D.originalMessageId,Q=!!(D!=null&&D.edit&&G),oe=!$&&_.length>0;let ae=null;oe&&(ae={id:Q?G:`msg-${Date.now()}`,role:"user",content:_,createdAt:new Date().toISOString()},Q?S(ae,G):S(ae));const ve=$?P:ae?[ae]:[],we={...q,...j.length?{files_info:j}:{}};ve.length?we.messages=ve:"messages"in we||(we.messages=[]);let Re=(D==null?void 0:D.checkpointId)??g.id??void 0,Me=(D==null?void 0:D.checkpointNs)??g.namespace??void 0;if(Q&&G){const Le=yw(x,G);Re=Le.checkpointId,Me=Le.checkpointNs??void 0}const Ye={threadId:I,payload:we,checkpointId:Re,checkpointNs:Me,edit:!!(D!=null&&D.edit)};F(Ye)},[g,p,b,S,F,x]),W=w.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(_u.Provider,{value:W,children:e})}function Hi(){const e=w.useContext(_u);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Tw(){return w.useContext(Ru)}function Mu(e){return typeof e=="object"&&e!==null}function kw(e,t){if(Object.is(e,t))return!0;if(!Mu(e)||!Mu(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 Ou(e){const t=w.useRef(e),n=w.useRef(e);return kw(t.current,e)||(t.current=e,n.current=e),n.current}function yr({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=Ou(t),m=oo(a),p=oo(l),v=oo(i),g=oo(c),x=oo(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,v,g,x]);return u.jsx(iu,{apiConfig:f,children:u.jsx(Sw,{...y,children:e})})}function oo(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function Sr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Ew(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function Du(){const e=[Sr("__API_BASE_URL__"),Sr("__CHAT_API_BASE_URL__"),Sr("__CHAT_API_URL__")];for(const t of e){const n=Ew(t);if(n)return n}}function Lu(){const e=[Sr("__API_AUTH_TOKEN__"),Sr("__CHAT_API_KEY__"),Sr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function $u(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Fu(){const e={},t=Du(),n=Lu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Bu(){const e=Fu(),t=Nn.getAuthToken(),n=Du();return{apiBaseUrl:$u(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Lu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ui="chat-settings";function zu(){try{const e=localStorage.getItem(Ui);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Hu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Ui,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Iw(){const e=Bu(),t=zu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:$u(Nn.baseUrl,r,e.apiBaseUrl)}}function Nw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Hu(e)}function te(...e){return cx.twMerge(lx.clsx(e))}const Aw=Ur.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Je=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:te(Aw({variant:t,size:n,className:e})),ref:s,...o})});Je.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 Uu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Uu(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():Uu(e[o],null)}}}}function Pe(...e){return h.useCallback(Mn(...e),e)}function jw(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=f=>{var y;const{scope:m,children:p,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:p})};c.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Pw(o,...t)]}function Pw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},_w=h[" useInsertionEffect ".trim().toString()]||It;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Rw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var f;if(a){const m=Mw(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 Rw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return _w(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Mw(e){return typeof e=="function"}var Ow=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],fe=Ow.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Wi(e,t){e&&Wr.flushSync(()=>e.dispatchEvent(t))}function Zo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=Pe(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Yt.createSlot(d),p=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=Pe(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[f]:"",ref:S,children:b})});p.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},v,r]}var Dw=h.createContext(void 0);function Qo(e){const t=h.useContext(Dw);return e||t||"ltr"}function wt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Lw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var $w="DismissableLayer",Vi="dismissableLayer.update",Fw="dismissableLayer.pointerDownOutside",Bw="dismissableLayer.focusOutside",Wu,Vu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Cr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Vu),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Pe(t,E=>f(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=Hw(E=>{const A=E.target,M=[...c.branches].some(L=>L.contains(A));!k||M||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Uw(E=>{const A=E.target;[...c.branches].some(L=>L.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Lw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Wu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),qu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Wu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),qu())},[d,c]),h.useEffect(()=>{const E=()=>p({});return document.addEventListener(Vi,E),()=>document.removeEventListener(Vi,E)},[]),u.jsx(fe.div,{...l,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,S.onPointerDownCapture)})});Cr.displayName=$w;var zw="DismissableLayerBranch",Ku=h.forwardRef((e,t)=>{const n=h.useContext(Vu),r=h.useRef(null),o=Pe(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(fe.div,{...e,ref:o})});Ku.displayName=zw;function Hw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Gu(Fw,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 Uw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Gu(Bw,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 qu(){const e=new CustomEvent(Vi);document.dispatchEvent(e)}function Gu(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?Wi(o,s):o.dispatchEvent(s)}var Ww=Cr,Vw=Ku,Ki=0;function qi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Yu()),document.body.insertAdjacentElement("beforeend",e[1]??Yu()),Ki++,()=>{Ki===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ki--}},[])}function Yu(){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 Gi="focusScope.autoFocusOnMount",Yi="focusScope.autoFocusOnUnmount",Xu={bubbles:!1,cancelable:!0},Kw="FocusScope",es=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=wt(o),d=wt(s),f=h.useRef(null),m=Pe(t,g=>l(g)),p=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(p.paused||!a)return;const k=C.target;a.contains(k)?f.current=k:Dn(f.current,{select:!0})},x=function(C){if(p.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(f.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,p.paused]),h.useEffect(()=>{if(a){Qu.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Gi,Xu);a.addEventListener(Gi,c),a.dispatchEvent(y),y.defaultPrevented||(qw(Zw(Ju(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Gi,c),setTimeout(()=>{const y=new CustomEvent(Yi,Xu);a.addEventListener(Yi,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Yi,d),Qu.remove(p)},0)}}},[a,c,d,p]);const v=h.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[C,k]=Gw(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,p.paused]);return u.jsx(fe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});es.displayName=Kw;function qw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Gw(e){const t=Ju(e),n=Zu(t,e),r=Zu(t.reverse(),e);return[n,r]}function Ju(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Zu(e,t){for(const n of e)if(!Yw(n,{upTo:t}))return n}function Yw(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 Xw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Xw(e)&&t&&e.select()}}var Qu=Jw();function Jw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ed(e,t),e.unshift(t)},remove(t){var n;e=ed(e,t),(n=e[0])==null||n.resume()}}}function ed(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Zw(e){return e.filter(t=>t.tagName!=="A")}var Qw=h[" useId ".trim().toString()]||(()=>{}),eb=0;function Rt(e){const[t,n]=h.useState(Qw());return It(()=>{n(r=>r??String(eb++))},[e]),t?`radix-${t}`:""}const tb=["top","right","bottom","left"],Ln=Math.min,Zt=Math.max,ts=Math.round,ns=Math.floor,wn=e=>({x:e,y:e}),nb={left:"right",right:"left",bottom:"top",top:"bottom"},rb={start:"end",end:"start"};function Xi(e,t,n){return Zt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Tr(e){return e.split("-")[1]}function Ji(e){return e==="x"?"y":"x"}function Zi(e){return e==="y"?"height":"width"}const ob=new Set(["top","bottom"]);function bn(e){return ob.has(jn(e))?"y":"x"}function Qi(e){return Ji(bn(e))}function sb(e,t,n){n===void 0&&(n=!1);const r=Tr(e),o=Qi(e),s=Zi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=rs(i)),[i,rs(i)]}function ib(e){const t=rs(e);return[ea(e),t,ea(t)]}function ea(e){return e.replace(/start|end/g,t=>rb[t])}const td=["left","right"],nd=["right","left"],ab=["top","bottom"],lb=["bottom","top"];function cb(e,t,n){switch(e){case"top":case"bottom":return n?t?nd:td:t?td:nd;case"left":case"right":return t?ab:lb;default:return[]}}function ub(e,t,n,r){const o=Tr(e);let s=cb(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ea)))),s}function rs(e){return e.replace(/left|right|bottom|top/g,t=>nb[t])}function db(e){return{top:0,right:0,bottom:0,left:0,...e}}function rd(e){return typeof e!="number"?db(e):{top:e,right:e,bottom:e,left:e}}function os(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function od(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Qi(t),a=Zi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Tr(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const fb=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}=od(c,r,l),m=r,p={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,f=C??f,p={...p,[x]:{...p[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=od(c,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function so(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=An(t,e),v=rd(p),x=a[m?f==="floating"?"reference":"floating":f],y=os(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})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=os(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const pb=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=rd(d),m={x:n,y:r},p=Qi(o),v=Zi(p),g=await i.getDimensions(c),x=p==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[p]-m[p]-s.floating[v],S=m[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const A=k/2-S/2,M=E/2-g[v]/2-1,L=Ln(f[y],M),F=Ln(f[b],M),z=L,X=E-g[v]-F,O=E/2-g[v]/2+A,Y=Xi(z,O,X),W=!l.arrow&&Tr(o)!=null&&O!==Y&&s.reference[v]/2-(O<z?L:F)-g[v]/2<0,K=W?O<z?O-z:O-X:0;return{[p]:m[p]+K,data:{[p]:Y,centerOffset:O-Y-K,...W&&{alignmentOffset:K}},reset:W}}}),hb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),b=bn(a),C=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[rs(a)]:ib(a)),T=v!=="none";!m&&T&&S.push(...ub(a,g,v,k));const E=[a,...S],A=await so(t,x),M=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&M.push(A[y]),f){const O=sb(o,i,k);M.push(A[O[0]],A[O[1]])}if(L=[...L,{placement:o,overflows:M}],!M.every(O=>O<=0)){var F,z;const O=(((F=s.flip)==null?void 0:F.index)||0)+1,Y=E[O];if(Y&&(!(f==="alignment"?b!==bn(Y):!1)||L.every(D=>bn(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:O,overflows:L},reset:{placement:Y}};let W=(z=L.filter(K=>K.overflows[0]<=0).sort((K,D)=>K.overflows[1]-D.overflows[1])[0])==null?void 0:z.placement;if(!W)switch(p){case"bestFit":{var X;const K=(X=L.filter(D=>{if(T){const I=bn(D.placement);return I===b||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,V)=>I+V,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:X[0];K&&(W=K);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function sd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function id(e){return tb.some(t=>e[t]>=0)}const mb=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 so(t,{...o,elementContext:"reference"}),i=sd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:id(i)}}}case"escaped":{const s=await so(t,{...o,altBoundary:!0}),i=sd(s,n.floating);return{data:{escapedOffsets:i,escaped:id(i)}}}default:return{}}}}},ad=new Set(["left","top"]);async function gb(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=Tr(n),l=bn(n)==="y",c=ad.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:m*c}:{x:m*c,y:p*d}}const xb=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 gb(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}}}}},vb=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:b}=x;return{x:y,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await so(t,l),f=bn(jn(o)),m=Ji(f);let p=c[m],v=c[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=p+d[x],C=p-d[y];p=Xi(b,p,C)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=Xi(b,v,C)}const g=a.fn({...t,[m]:p,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},wb=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=Ji(f);let p=d[m],v=d[f];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;p<k?p=k:p>S&&(p=S)}if(c){var y,b;const C=m==="y"?"width":"height",k=ad.has(jn(o)),S=s.reference[f]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[f])||0)+(k?0:x.crossAxis),T=s.reference[f]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:p,[f]:v}}}},bb=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 so(t,c),f=jn(o),m=Tr(o),p=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 b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Zt(d.left,0),F=Zt(d.right,0),z=Zt(d.top,0),X=Zt(d.bottom,0);p?A=v-2*(L!==0||F!==0?L+F:Zt(d.left,d.right)):E=g-2*(z!==0||X!==0?z+X:Zt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const M=await i.getDimensions(a.floating);return v!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function kr(e){return ld(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(ld(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ld(e){return ss()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ss()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ss()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function cd(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const yb=new Set(["inline","contents"]);function io(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!yb.has(o)}const Sb=new Set(["table","td","th"]);function Cb(e){return Sb.has(kr(e))}const Tb=[":popover-open",":modal"];function is(e){return Tb.some(t=>{try{return e.matches(t)}catch{return!1}})}const kb=["transform","translate","scale","rotate","perspective"],Eb=["transform","translate","scale","rotate","perspective","filter"],Ib=["paint","layout","strict","content"];function ta(e){const t=na(),n=un(e)?dn(e):e;return kb.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)||Eb.some(r=>(n.willChange||"").includes(r))||Ib.some(r=>(n.contain||"").includes(r))}function Nb(e){let t=$n(e);for(;Sn(t)&&!Er(t);){if(ta(t))return t;if(is(t))return null;t=$n(t)}return null}function na(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ab=new Set(["html","body","#document"]);function Er(e){return Ab.has(kr(e))}function dn(e){return Qt(e).getComputedStyle(e)}function as(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(kr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||cd(e)&&e.host||yn(e);return cd(t)?t.host:t}function ud(e){const t=$n(e);return Er(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&io(t)?t:ud(t)}function ao(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ud(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=ra(i);return t.concat(i,i.visualViewport||[],io(o)?o:[],a&&n?ao(a):[])}return t.concat(o,ao(o,[],n))}function ra(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function oa(e){return un(e)?e:e.contextElement}function Ir(e){const t=oa(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=dd(t);let i=(s?ts(n.width):n.width)/r,a=(s?ts(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const jb=wn(0);function fd(e){const t=Qt(e);return!na()||!t.visualViewport?jb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=oa(e);let i=wn(1);t&&(r?un(r)&&(i=Ir(r)):i=Ir(e));const a=Pb(s,n,r)?fd(s):wn(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=Qt(s),p=r&&un(r)?Qt(r):r;let v=m,g=ra(v);for(;g&&r&&p!==v;){const x=Ir(g),y=g.getBoundingClientRect(),b=dn(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,f*=x.y,l+=C,c+=k,v=Qt(g),g=ra(v)}}return os({width:d,height:f,x:l,y:c})}function ls(e,t){const n=as(e).scrollLeft;return t?t.left+n:Qn(yn(e)).left+n}function pd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ls(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function _b(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),f=Sn(r);if((f||!f&&!s)&&((kr(r)!=="body"||io(i))&&(l=as(r)),Sn(r))){const p=Qn(r);c=Ir(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?pd(i,l):wn(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 Rb(e){return Array.from(e.getClientRects())}function Mb(e){const t=yn(e),n=as(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ls(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const hd=25;function Ob(e,t){const n=Qt(e),r=yn(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=na();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ls(r);if(c<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=hd&&(s-=v)}else c<=hd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Db=new Set(["absolute","fixed"]);function Lb(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Ir(e):wn(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 md(e,t,n){let r;if(t==="viewport")r=Ob(e,n);else if(t==="document")r=Mb(yn(e));else if(un(t))r=Lb(t,n);else{const o=fd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function gd(e,t){const n=$n(e);return n===t||!un(n)||Er(n)?!1:dn(n).position==="fixed"||gd(n,t)}function $b(e,t){const n=t.get(e);if(n)return n;let r=ao(e,[],!1).filter(a=>un(a)&&kr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?$n(e):e;for(;un(i)&&!Er(i);){const a=dn(i),l=ta(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Db.has(o.position)||io(i)&&!l&&gd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function Fb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?is(t)?[]:$b(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=md(t,d,o);return c.top=Zt(f.top,c.top),c.right=Ln(f.right,c.right),c.bottom=Ln(f.bottom,c.bottom),c.left=Zt(f.left,c.left),c},md(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Bb(e){const{width:t,height:n}=dd(e);return{width:t,height:n}}function zb(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ls(o)}if(r||!r&&!s)if((kr(t)!=="body"||io(o))&&(a=as(t)),r){const p=Qn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?pd(o,a):wn(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 sa(e){return dn(e).position==="static"}function xd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function vd(e,t){const n=Qt(e);if(is(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Er(o);){if(un(o)&&!sa(o))return o;o=$n(o)}return n}let r=xd(e,t);for(;r&&Cb(r)&&sa(r);)r=xd(r,t);return r&&Er(r)&&sa(r)&&!ta(r)?n:r||Nb(e)||n}const Hb=async function(e){const t=this.getOffsetParent||vd,n=this.getDimensions,r=await n(e.floating);return{reference:zb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ub(e){return dn(e).direction==="rtl"}const Wb={convertOffsetParentRelativeRectToViewportRelativeRect:_b,getDocumentElement:yn,getClippingRect:Fb,getOffsetParent:vd,getElementRects:Hb,getClientRects:Rb,getDimensions:Bb,getScale:Ir,isElement:un,isRTL:Ub};function wd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:m,height:p}=c;if(a||t(),!m||!p)return;const v=ns(f),g=ns(o.clientWidth-(d+m)),x=ns(o.clientHeight-(f+p)),y=ns(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,Ln(1,l))||1};let k=!0;function S(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&&!wd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function Kb(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=oa(e),d=o||s?[...c?ao(c):[],...ao(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?Vb(c,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let v,g=l?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!wd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const qb=xb,Gb=vb,Yb=hb,Xb=bb,Jb=mb,bd=pb,Zb=wb,Qb=(e,t,n)=>{const r=new Map,o={platform:Wb,...n},s={...o.platform,_c:r};return fb(e,t,{...o,platform:s})};var ey=typeof document<"u",ty=function(){},cs=ey?w.useLayoutEffect:ty;function us(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!us(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function yd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Sd(e,t){const n=yd(e);return Math.round(t*n)/n}function ia(e){const t=h.useRef(e);return cs(()=>{t.current=e}),t}function ny(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);us(m,r)||p(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(D=>{D!==T.current&&(T.current=D,g(D))},[]),C=h.useCallback(D=>{D!==E.current&&(E.current=D,y(D))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),A=h.useRef(d),M=l!=null,L=ia(l),F=ia(o),z=ia(c),X=h.useCallback(()=>{if(!T.current||!E.current)return;const D={placement:t,strategy:n,middleware:m};F.current&&(D.platform=F.current),Qb(T.current,E.current,D).then(I=>{const V={...I,isPositioned:z.current!==!1};O.current&&!us(A.current,V)&&(A.current=V,Wr.flushSync(()=>{f(V)}))})},[m,t,n,F,z]);cs(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[c]);const O=h.useRef(!1);cs(()=>(O.current=!0,()=>{O.current=!1}),[]),cs(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if(L.current)return L.current(k,S,X);X()}},[k,S,X,L,M]);const Y=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),W=h.useMemo(()=>({reference:k,floating:S}),[k,S]),K=h.useMemo(()=>{const D={position:n,left:0,top:0};if(!W.floating)return D;const I=Sd(W.floating,d.x),V=Sd(W.floating,d.y);return a?{...D,transform:"translate("+I+"px, "+V+"px)",...yd(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:V}},[n,a,W.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:X,refs:Y,elements:W,floatingStyles:K}),[d,X,Y,W,K])}const ry=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?bd({element:r.current,padding:o}).fn(n):{}:r?bd({element:r,padding:o}).fn(n):{}}}},oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Gb(e),options:[e,t]}),iy=(e,t)=>({...Zb(e),options:[e,t]}),ay=(e,t)=>({...Yb(e),options:[e,t]}),ly=(e,t)=>({...Xb(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...ry(e),options:[e,t]});var dy="Arrow",Cd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(fe.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"})})});Cd.displayName=dy;var fy=Cd;function Td(e){const[t,n]=h.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var aa="Popper",[kd,Nr]=cn(aa),[py,Ed]=kd(aa),Id=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(py,{scope:t,anchor:r,onAnchorChange:o,children:n})};Id.displayName=aa;var Nd="PopperAnchor",Ad=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ed(Nd,n),i=h.useRef(null),a=Pe(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(fe.div,{...o,ref:a})});Ad.displayName=Nd;var la="PopperContent",[hy,my]=kd(la),jd=h.forwardRef((e,t)=>{var j,_,G,Q,oe,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=Ed(la,n),[y,b]=h.useState(null),C=Pe(t,ve=>b(ve)),[k,S]=h.useState(null),T=Td(k),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,M=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],z=F.length>0,X={padding:L,boundary:F.filter(xy),altBoundary:z},{refs:O,floatingStyles:Y,placement:W,isPositioned:K,middlewareData:D}=ny({strategy:"fixed",placement:M,whileElementsMounted:(...ve)=>Kb(...ve,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[oy({mainAxis:o+A,alignmentAxis:i}),l&&sy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?iy():void 0,...X}),l&&ay({...X}),ly({...X,apply:({elements:ve,rects:we,availableWidth:Re,availableHeight:Me})=>{const{width:Ye,height:Le}=we.reference,$e=ve.floating.style;$e.setProperty("--radix-popper-available-width",`${Re}px`),$e.setProperty("--radix-popper-available-height",`${Me}px`),$e.setProperty("--radix-popper-anchor-width",`${Ye}px`),$e.setProperty("--radix-popper-anchor-height",`${Le}px`)}}),k&&uy({element:k,padding:a}),vy({arrowWidth:E,arrowHeight:A}),m&&cy({strategy:"referenceHidden",...X})]}),[I,V]=Rd(W),Z=wt(v);It(()=>{K&&(Z==null||Z())},[K,Z]);const R=(j=D.arrow)==null?void 0:j.x,q=(_=D.arrow)==null?void 0:_.y,P=((G=D.arrow)==null?void 0:G.centerOffset)!==0,[$,H]=h.useState();return It(()=>{y&&H(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:K?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Q=D.transformOrigin)==null?void 0:Q.x,(oe=D.transformOrigin)==null?void 0:oe.y].join(" "),...((ae=D.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(hy,{scope:n,placedSide:I,onArrowChange:S,arrowX:R,arrowY:q,shouldHideArrow:P,children:u.jsx(fe.div,{"data-side":I,"data-align":V,...g,ref:C,style:{...g.style,animation:K?void 0:"none"}})})})});jd.displayName=la;var Pd="PopperArrow",gy={top:"bottom",right:"left",bottom:"top",left:"right"},_d=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=my(Pd,r),i=gy[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(fy,{...o,ref:n,style:{...o.style,display:"block"}})})});_d.displayName=Pd;function xy(e){return e!==null}var vy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;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]=Rd(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?f:`${m}px`,g=`${-l}px`):c==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?f:`${p}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:v,y:g}}}});function Rd(e){const[t,n="center"]=e.split("-");return[t,n]}var ca=Id,ua=Ad,da=jd,fa=_d,wy="Portal",lo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Do.createPortal(u.jsx(fe.div,{...r,ref:t}),i):null});lo.displayName=wy;function by(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=yy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Pe(r.ref,Sy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function yy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=by(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ds(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,p=ds(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const g=ds(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=p=>{p.target===t&&(s.current=ds(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ds(e){return(e==null?void 0:e.animationName)||"none"}function Sy(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 pa="rovingFocusGroup.onEntryFocus",Cy={bubbles:!1,cancelable:!0},co="RovingFocusGroup",[ha,Md,Ty]=Zo(co),[ky,Od]=cn(co,[Ty]),[Ey,Iy]=ky(co),Dd=h.forwardRef((e,t)=>u.jsx(ha.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ha.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Ny,{...e,ref:t})})}));Dd.displayName=co;var Ny=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,m=h.useRef(null),p=Pe(t,m),v=Qo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:co}),[y,b]=h.useState(!1),C=wt(c),k=Md(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(pa,C),()=>A.removeEventListener(pa,C)},[C]),u.jsx(Ey,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>E(A=>A-1),[]),children:u.jsx(fe.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{S.current=!0}),onFocus:ie(e.onFocus,A=>{const M=!S.current;if(A.target===A.currentTarget&&M&&!y){const L=new CustomEvent(pa,Cy);if(A.currentTarget.dispatchEvent(L),!L.defaultPrevented){const F=k().filter(W=>W.focusable),z=F.find(W=>W.active),X=F.find(W=>W.id===g),Y=[z,X,...F].filter(Boolean).map(W=>W.ref.current);Fd(Y,d)}}S.current=!1}),onBlur:ie(e.onBlur,()=>b(!1))})})}),Ld="RovingFocusGroupItem",$d=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Rt(),c=s||l,d=Iy(Ld,n),f=d.currentTabStopId===c,m=Md(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(ha.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(fe.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=Py(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?_y(C,k+1):C.slice(k+1)}setTimeout(()=>Fd(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});$d.displayName=Ld;var Ay={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Py(e,t,n){const r=jy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ay[r]}function Fd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function _y(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ry=Dd,My=$d,Oy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ar=new WeakMap,fs=new WeakMap,ps={},ma=0,Bd=function(e){return e&&(e.host||Bd(e.parentNode))},Dy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Bd(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})},Ly=function(e,t,n,r){var o=Dy(t,Array.isArray(e)?e:[e]);ps[n]||(ps[n]=new WeakMap);var s=ps[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 p=m.getAttribute(r),v=p!==null&&p!=="false",g=(Ar.get(m)||0)+1,x=(s.get(m)||0)+1;Ar.set(m,g),s.set(m,x),i.push(m),g===1&&v&&fs.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(),ma++,function(){i.forEach(function(f){var m=Ar.get(f)-1,p=s.get(f)-1;Ar.set(f,m),s.set(f,p),m||(fs.has(f)||f.removeAttribute(r),fs.delete(f)),p||f.removeAttribute(n)}),ma--,ma||(Ar=new WeakMap,Ar=new WeakMap,fs=new WeakMap,ps={})}},ga=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Oy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ly(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.apply(this,arguments)};function zd(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 $y(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",ms="width-before-scroll-bar",Fy="with-scroll-bars-hidden",By="--removed-body-scroll-bar-size";function xa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function zy(e,t){var n=w.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 Hy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Hd=new WeakMap;function Uy(e,t){var n=zy(null,function(r){return e.forEach(function(o){return xa(o,r)})});return Hy(function(){var r=Hd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||xa(a,null)}),s.forEach(function(a){o.has(a)||xa(a,i)})}Hd.set(n,e)},[e]),n}function Wy(e){return e}function Vy(e,t){t===void 0&&(t=Wy);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 Ky(e){e===void 0&&(e={});var t=Vy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Ud=function(e){var t=e.sideCar,n=zd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,Cn({},n))};Ud.isSideCarExport=!0;function qy(e,t){return e.useMedium(t),Ud}var Wd=Ky(),va=function(){},gs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:va,onWheelCapture:va,onTouchMoveCapture:va}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,k=zd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=Uy([n,t]),E=Cn(Cn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Wd,removeScrollBar:c,shards:f,noRelative:p,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},E),{ref:T})):h.createElement(b,Cn({},E,{className:l,ref:T}),a))});gs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gs.classNames={fullWidth:ms,zeroRight:hs};var Gy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Yy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Gy();return t&&e.setAttribute("nonce",t),e}function Xy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Jy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Zy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Yy())&&(Xy(t,n),Jy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Qy=function(){var e=Zy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Vd=function(){var e=Qy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},e0={left:0,top:0,right:0,gap:0},wa=function(e){return parseInt(e||"",10)||0},t0=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[wa(n),wa(r),wa(o)]},n0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return e0;var t=t0(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])}},r0=Vd(),jr="data-scroll-locked",o0=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 Te=ft.slice(0,de);ft=ft.slice(de+2);const $e=Te.split(/\r?\n/),ht=[];for(const Je of $e)if(!(!Je||Je.startsWith(":"))&&Je.startsWith("data:")){const dt=Je.slice(5);ht.push(dt.startsWith(" ")?dt.slice(1):dt)}const wt=ht.join(`
|
|
38
|
+
`);if(!wt)continue;let Pe;try{Pe=JSON.parse(wt)}catch{console.debug("[use-chat] malformed SSE:",wt.slice(0,200));continue}const Ke=cu(Pe)?Pe.data:Pe;if(!Ke){console.warn("[use-chat] dropped envelope event without payload",Pe);continue}const we=Ke;Tt=Date.now();const et=we.seq;if(et!==void 0){if(et<=pt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:et,lastProcessedSeq:pt,type:we.type});continue}pt>0&&et>pt+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:pt,to:et})),pt=et,E.current=et,x(et)}if(we.type==="message.start"&&we.role==="assistant"){const Je=hu(we.model);U.current={messageId:we.id,lastSeq:et??null,lastText:""},k({id:we.id,role:"assistant",name:Je??void 0,model:we.model,createdAt:new Date().toISOString(),content:[]})}if(we.type==="checkpoint")_.current=we.checkpointId??null,L.current=we.checkpointNs??null,v(we.checkpointId??null);else if(we.type==="state_history"){F.current=we;try{const dt=Yn(we).latest;dt&&(_.current=dt.checkpointId??null,L.current=dt.checkpointNs??null,v(dt.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{D==null||D(we)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",we.type)}if(we.type==="message.delta"){k(dt=>{const _e=U.current;if(!dt||_e.messageId!==dt.id)return dt;const{newParts:N,newMeta:Z,changed:re}=fu(dt.content??[],we.delta,{lastSeq:_e.lastSeq,lastText:_e.lastText},et??null);return re?(U.current={..._e,lastSeq:Z.lastSeq??_e.lastSeq,lastText:Z.lastText??_e.lastText},{...dt,content:N}):dt});const Je=we.delta.filter(dt=>dt.type==="text").map(dt=>dt.text).join("");Je&&e.autoAppendAssistant!==!1&&(At.push(Je),gn())}else if(we.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ie=I==null?void 0:I.onHeartbeat)==null||ie.call(I,we)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(Ct!==null&&cancelAnimationFrame(Ct),lt(),we.type==="checkpoint")v(we.checkpointId);else if(we.type==="error"){const Je=we;if(d(Je.message),J="error",M=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((Se=Je.message)==null?void 0:Se.includes("token"))||((xe=Je.message)==null?void 0:xe.includes("401"))||((Oe=Je.message)==null?void 0:Oe.includes("unauthorized"))||((De=Je.message)==null?void 0:De.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(Ge=I==null?void 0:I.onAuthError)==null||Ge.call(I,Je.message)}catch(_e){console.warn("[use-chat] onAuthError handler failed",_e)}q.abort()}}}}lt(),J===null&&!q.signal.aborted&&(J="complete")}catch(ze){if(ze.name==="AbortError")J=J??"aborted";else{const Ue=ze.message||String(ze);J="error",M=Ue,d(Ue),(Ye=I==null?void 0:I.onError)==null||Ye.call(I,Ue)}}finally{try{await ut.cancel()}catch{}finally{(He=ut.releaseLock)==null||He.call(ut)}Ct!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ct),clearInterval(Dt)}}catch(Le){if(Le.name==="AbortError")J=J??"aborted";else{const Ve=Le.message||String(Le);J="error",M=Ve,d(Ve),(st=I==null?void 0:I.onError)==null||st.call(I,Ve),B||((Xe=I==null?void 0:I.onConnectionError)==null||Xe.call(I,Ve),B=!0)}}finally{const Le=E.current,Ve=_.current,je=L.current,Ie=F.current,Ne=J??(q.signal.aborted?"aborted":M?"error":"complete");try{(St=I==null?void 0:I.onClosed)==null||St.call(I,{reason:Ne,lastSeq:Le,lastCheckpointId:Ve,lastCheckpointNs:je,lastStateHistory:Ie,error:M})}catch(ut){console.warn("[use-chat] onClosed callback failed",ut)}l(!1),b(!1),S.current=null,E.current=0,x(0),A.current=null}})(),{close:()=>q.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var K;T.current=!1,(K=S.current)==null||K.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:C,lastCheckpointId:p,lastSeq:g,connected:y,stream:V,stop:Y,clear:O,setToken:X}}const ew=["detail","message","error","description","title"];function Jo(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=Jo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of ew){const r=Jo(t[n]);if(r)return r}if("errors"in t){const n=Jo(t.errors);if(n)return n}}return null}function tw(e){if(!e)return"Request failed";const t=e.response,n=Jo(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 mu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[f,m]=w.useState(null),[p,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const A=w.useCallback(async()=>{d(!0),m(null);try{const D=await e.listThreads();i(D??[])}catch(D){const I=String(D);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=w.useCallback(async()=>{x(!0),y(null);try{const D=await e.listSharedThreads();v(D??[])}catch(D){const I=String(D);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{A()},[A]),w.useEffect(()=>{_()},[_]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async D=>{try{const I=await e.createThread(D);return l(I.threadId),await A(),I.threadId}catch(I){const q=String(I);return n==null||n(q),null}},[e,n,A]),F=w.useCallback(async D=>{const I=s;i(J=>J.filter(M=>M.threadId!==D));const q=new AbortController;E.current.set(D,q);try{await e.deleteThread(D),T.current===D&&(l(null),o==null||o())}catch(J){i(I);const M=String(J);n==null||n(M)}finally{E.current.delete(D)}},[e,o,n,s]),U=w.useCallback(async(D,I)=>{try{await e.updateThread(D,I),await A()}catch(q){n==null||n(String(q))}},[e,n,A]),X=w.useCallback(async(D,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(D,I),await _(),C("Shared successfully")}catch(q){const J=tw(q);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{S(!1)}},[e,n,_]),O=w.useCallback(async(D,I)=>{try{await e.unshareThread(D,I),await _()}catch(q){const J=String(q);throw n==null||n(J),q}},[e,n,_]),Y=w.useMemo(()=>({createThread:L,deleteThread:F,renameThread:U,refreshThreads:A,refreshSharedThreads:_,shareThread:X,unshareThread:O}),[L,F,U,A,_,X,O]),V=w.useCallback(D=>{if(!(D!=null&&D.threadId))return;const I={threadId:D.threadId,title:D.title||`Thread ${D.threadId.slice(0,8)}`,createdAt:D.createdAt||new Date().toISOString(),updatedAt:D.updatedAt||new Date().toISOString(),messageCount:D.messageCount??1};i(q=>{let J=!1;const M=q.map(B=>B.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...B,title:I.title??B.title,updatedAt:I.updatedAt??B.updatedAt,messageCount:I.messageCount??B.messageCount}):B);return J?M:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...q])})},[]),K=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:V,shareInFlight:k,shareStatus:b,clearShareStatus:K}}const gu=w.createContext(null);function xu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Qr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=mu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,f,m,p,g,x,y,v]);return u.jsx(gu.Provider,{value:b,children:e})}function vr(){const e=w.useContext(gu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function to(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=nw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function nw(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function vu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function no(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(no).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(vu(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=no(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 wr(e){if(typeof e=="string")return e;if(vu(e))return"";try{const t=no(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function rw(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function ow(e){const t=wr(e);return typeof e=="string"&&rw(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=to(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 sw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Fi(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 wu(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function iw(e){const t=r=>{try{const o=no(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 aw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function bu(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 lw(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function cw(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function uw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=lw(n),i=o?`data:${s};base64,${e}`:t,a=cw(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function dw(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 uw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function yu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const fw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function pw(e,t){var n;switch(t.type){case"reset":return{messages:$i(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=$i(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=$i(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Su(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Su(o,s),e):e}default:return e}}function hw(e=[]){const[t,n]=w.useReducer(pw,{...fw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.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 Su(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=hu(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 gw(e,t);if(t.type==="tool.progress")return xw(e,t);if(t.type==="tool.end")return vw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??uu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},f=d[s],m=f??{lastSeq:null,lastText:du(l.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof m.lastSeq=="number"&&p<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=fu(l.content,t.delta,m,p);if(!x)return e;const y={...l,content:v},b=eo(i,a,y),C=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,k=C?{...d,[s]:g}:c;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??uu(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=Zv(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=Yn(t),i=s.interrupt,a=s.latest,l=i===null?Xv(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 Bi(e){return e.call_id??e.id??null}function Cu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Tu(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 zi(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||Fi(r).toolCallId===t)return n}return-1}function mw(e){if(e==null)return[];const t=br(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=wr(t??e);return n?[{type:"text",text:n}]:[]}function ku(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function gw(e,t){const n=Bi(t),r=zi(e.messages,n),o=t.name??t.tool??void 0,s=Cu(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:eo(e.messages,r,d)}}const i=Tu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function xw(e,t){const n=Bi(t);if(!n)return e;const r=zi(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=ku(e.messages[r],o);return{...e,messages:eo(e.messages,r,a)}}function vw(e,t){const n=Bi(t),r=Cu(t);let o=e.messages,s=zi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Tu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=mw(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=ku(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:eo(o,s,p)}}function Eu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,f]=w.useState(null),p=w.useMemo(()=>Yn(d),[d]).checkpoints,v=sc(p),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),A=w.useRef(null),_=w.useRef(null),L=w.useRef(null),F=w.useRef(null),U=w.useRef(new Map),X=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const O=w.useCallback(async P=>{var z,j;if(!P.threadId)return;const $=P.threadId;(z=P.onStart)==null||z.call(P),P.setLoading(!0);try{await P.action($)}catch(R){if(!Yc(R)&&T.current===$){const Q=String(R);(j=P.handleError)==null||j.call(P,Q),n==null||n(Q)}throw R}finally{P.setLoading(!1)}},[n]),Y=w.useCallback(async(P,$)=>{var Q;if(!P)return;const z=`${P}:${$??"latest"}`,j=U.current.get(z);if(j)return j;(Q=X.current)==null||Q.abort();const R=new AbortController;X.current=R;const G=O({threadId:P,setLoading:y,onStart:()=>S(null),handleError:se=>S(se),action:async se=>{const ie=await e.getStateHistory({threadId:se,checkpointId:$??void 0,signal:R.signal});if(T.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${T.current}), discarding stale data`);return}const{checkpoints:Se}=Yn(ie),xe=Se.find(Oe=>Oe.messages&&Oe.messages.length>0)??($?Se.find(Oe=>Oe.checkpointId===$):null)??Se[0];t((xe==null?void 0:xe.messages)??[],{checkpointId:(xe==null?void 0:xe.checkpointId)??null,checkpointNs:(xe==null?void 0:xe.checkpointNs)??null,pendingInterrupt:(xe==null?void 0:xe.interrupt)??null}),f(ie)}});U.current.set(z,G);try{await G}finally{U.current.delete(z),X.current===R&&(X.current=null)}return T.current===P&&(F.current=z),G},[e,t,O]),V=w.useCallback(async(P,$)=>{L.current=P;try{await Y(P,$)}catch(z){if(!Yc(z))throw z}finally{L.current===P&&(L.current=null)}},[Y]),K=w.useCallback(P=>{A.current=P},[]),D=w.useCallback(P=>{_.current=P},[]),I=w.useCallback(P=>{const $=P.threadId??T.current;if(!$||T.current&&T.current!==$)return;const{checkpoints:z}=Yn(P);if(!z.length)return;const j=z.find(G=>G.messages&&G.messages.length>0)??z.find(G=>!!G.checkpointId)??z[0],R=_.current===$;!l&&!R&&t((j==null?void 0:j.messages)??[],{checkpointId:(j==null?void 0:j.checkpointId)??null,checkpointNs:(j==null?void 0:j.checkpointNs)??null,pendingInterrupt:(j==null?void 0:j.interrupt)??null}),f(P),F.current=`${$}:latest`,A.current=null,_.current===$&&(_.current=null)},[t,l]),q=w.useCallback(async(P,$)=>{const z=T.current;await O({threadId:z,setLoading:C,action:async j=>{const R=await e.getStateHistory({threadId:j,checkpointId:P,checkpointNs:$??void 0});if(T.current!==j)return;const{checkpoints:G}=Yn(R),Q=G.find(se=>se.checkpointId===P&&($?se.checkpointNs===$:!0));if(!Q){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:P,checkpointNs:$});return}f(R),t(Q.messages??[],{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null})}}).catch(()=>{})},[e,t,O]),J=w.useCallback((P,$)=>{t(c(),{checkpointId:P??null,checkpointNs:$??null})},[c,t]),M=w.useCallback(async()=>{T.current&&await V(T.current)},[V]);w.useEffect(()=>{if(!a||!r||x||l)return;if(A.current===r){A.current=null,E.current=r;return}if(_.current===r){E.current=r;return}if(L.current===r){L.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let P;const $=`${r}:latest`;F.current!==$&&V(r,P)},[a,r,s,i,o,x,l,V]);const B=w.useCallback(()=>{f(null),y(!1),C(!1),S(null),A.current=null,_.current=null,E.current=null,F.current=null,L.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:V,navigateToCheckpoint:q,setCurrentCheckpointId:J,returnToLatest:M,handleStateHistoryEvent:I,markSkipNextLoad:K,markStreamPendingThread:D,resetHistoryState:B}}const Iu=w.createContext(null),Nu=w.createContext(null);function ro(){const e=w.useContext(Iu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Au(){const e=w.useContext(Nu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function ju({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Qr(),{currentThreadId:l}=vr(),{state:c,seed:d,pushUser:f,onEvent:m}=hw(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:_,resetHistoryState:L}=Eu({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[F,U]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[X,O]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),L())},[l,d,L]);const Y=w.useCallback(q=>U(()=>q),[]),V=w.useCallback(q=>O(()=>q),[]),K=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),D=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:p,checkpointIndex:g,timelineCheckpoints:v,metadata:K,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:F,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:F,respondToInterrupt:X,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:_,resetHistoryState:L,pushUser:f,onEvent:m}),[l,c,p,v,g,K,x,y,b,F,k,S,T,C,X,g.messagePreviews,E,A,_,L,f,m]),I=w.useMemo(()=>({registerClearThread:Y,registerRespondToInterrupt:V}),[Y,V]);return u.jsx(Nu.Provider,{value:I,children:u.jsx(Iu.Provider,{value:D,children:e})})}function Pu(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Rn(r,t)??null}function ww(e){const t=Pu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Pu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function bw(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 yw(e,t){const n=[...e].sort(bw);for(const r of n){if(r.messageId!==t)continue;const o=ww(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 _u=w.createContext(null),Ru=w.createContext(!1);function Sw({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}=Qr(),m=w.useMemo(()=>vn(f),[f]),{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=Qv({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(xu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(ju,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Ru.Provider,{value:!0,children:u.jsx(Cw,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function Cw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:v}=vr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=ro(),{registerClearThread:E,registerRespondToInterrupt:A}=Au(),_=w.useCallback(K=>{v(K),p.current!==K.threadId&&((K.created??!p.current)&&b(K.threadId),C(K.threadId),m(K.threadId))},[v,b,C,m,p]),L=w.useCallback(K=>{K.type==="thread_info"?_(K):K.type==="state_history"?y(K):K.type==="tool.end"?i==null||i(K):T(K)},[_,y,T,i]),F=w.useCallback(K=>{a(K,L,{onError:D=>{console.error("[StreamingProvider] Stream error:",D),r==null||r(D)},onAuthError:D=>{console.error("[StreamingProvider] Auth error:",D),o==null||o(D)},onConnectionError:D=>{console.error("[StreamingProvider] Connection error:",D),s==null||s(D)}})},[a,L,r,o,s]),U=w.useRef(g);w.useEffect(()=>{U.current=g},[g]);const X=w.useCallback(async(K,D,I)=>{const q=p.current;if(!q)throw new Error("No active thread to handle interrupt");const J=K?D??!0:!1,M=U.current,B={threadId:q,checkpointId:M.id??void 0,checkpointNs:M.namespace??void 0,command:{kind:"resume",value:J},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};F(B)},[p,F]);w.useEffect(()=>{A(X)},[X,A]);const O=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(O)},[O,E]);const Y=w.useCallback(async(K,D)=>{let I=p.current;const q=(K==null?void 0:K.text)??"",J=(K==null?void 0:K.attachments)??[],M=(q==null?void 0:q.trim())??"",B={...(K==null?void 0:K.payload)??{}},P=Array.isArray(B.messages)?B.messages:void 0;P&&delete B.messages;const $=!!(P&&P.length);if(!I&&!M&&J.length===0&&!$)return;if(!I){const Ye=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),He=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ye}${He}`,b(I),m(I)}const{contentParts:z,filesInfo:j}=await lu(J),R=[...z];M&&R.push({type:"text",text:q});const G=D==null?void 0:D.originalMessageId,Q=!!(D!=null&&D.edit&&G),se=!$&&R.length>0;let ie=null;se&&(ie={id:Q?G:`msg-${Date.now()}`,role:"user",content:R,createdAt:new Date().toISOString()},Q?S(ie,G):S(ie));const Se=$?P:ie?[ie]:[],xe={...B,...j.length?{files_info:j}:{}};Se.length?xe.messages=Se:"messages"in xe||(xe.messages=[]);let Oe=(D==null?void 0:D.checkpointId)??g.id??void 0,De=(D==null?void 0:D.checkpointNs)??g.namespace??void 0;if(Q&&G){const Ye=yw(x,G);Oe=Ye.checkpointId,De=Ye.checkpointNs??void 0}const Ge={threadId:I,payload:xe,checkpointId:Oe,checkpointNs:De,edit:!!(D!=null&&D.edit)};F(Ge)},[g,p,b,S,F,x]),V=w.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(_u.Provider,{value:V,children:e})}function Hi(){const e=w.useContext(_u);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Tw(){return w.useContext(Ru)}function Mu(e){return typeof e=="object"&&e!==null}function kw(e,t){if(Object.is(e,t))return!0;if(!Mu(e)||!Mu(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 Ou(e){const t=w.useRef(e),n=w.useRef(e);return kw(t.current,e)||(t.current=e,n.current=e),n.current}function yr({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=Ou(t),m=oo(a),p=oo(l),v=oo(i),g=oo(c),x=oo(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,v,g,x]);return u.jsx(iu,{apiConfig:f,children:u.jsx(Sw,{...y,children:e})})}function oo(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function Sr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Ew(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function Du(){const e=[Sr("__API_BASE_URL__"),Sr("__CHAT_API_BASE_URL__"),Sr("__CHAT_API_URL__")];for(const t of e){const n=Ew(t);if(n)return n}}function Lu(){const e=[Sr("__API_AUTH_TOKEN__"),Sr("__CHAT_API_KEY__"),Sr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function $u(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Fu(){const e={},t=Du(),n=Lu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Bu(){const e=Fu(),t=Nn.getAuthToken(),n=Du();return{apiBaseUrl:$u(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Lu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ui="chat-settings";function zu(){try{const e=localStorage.getItem(Ui);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Hu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Ui,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Iw(){const e=Bu(),t=zu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:$u(Nn.baseUrl,r,e.apiBaseUrl)}}function Nw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Hu(e)}function te(...e){return cx.twMerge(lx.clsx(e))}const Aw=Ur.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ze=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Gt.Slot:"button";return u.jsx(i,{className:te(Aw({variant:t,size:n,className:e})),ref:s,...o})});Ze.displayName="Button";function ae(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 Uu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Uu(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():Uu(e[o],null)}}}}function Re(...e){return h.useCallback(Mn(...e),e)}function jw(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function ln(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=f=>{var y;const{scope:m,children:p,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:p})};c.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Pw(o,...t)]}function Pw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Nt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},_w=h[" useInsertionEffect ".trim().toString()]||Nt;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Rw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var f;if(a){const m=Mw(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 Rw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return _w(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Mw(e){return typeof e=="function"}var Ow=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],fe=Ow.reduce((e,t)=>{const n=Gt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Wi(e,t){e&&Wr.flushSync(()=>e.dispatchEvent(t))}function Zo(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,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Gt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=Re(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Gt.createSlot(d),p=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=Re(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[f]:"",ref:S,children:b})});p.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},v,r]}var Dw=h.createContext(void 0);function Qo(e){const t=h.useContext(Dw);return e||t||"ltr"}function xt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Lw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var $w="DismissableLayer",Vi="dismissableLayer.update",Fw="dismissableLayer.pointerDownOutside",Bw="dismissableLayer.focusOutside",Wu,Vu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Cr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Vu),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Re(t,E=>f(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=Hw(E=>{const A=E.target,_=[...c.branches].some(L=>L.contains(A));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Uw(E=>{const A=E.target;[...c.branches].some(L=>L.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Lw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Wu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),qu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Wu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),qu())},[d,c]),h.useEffect(()=>{const E=()=>p({});return document.addEventListener(Vi,E),()=>document.removeEventListener(Vi,E)},[]),u.jsx(fe.div,{...l,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,S.onPointerDownCapture)})});Cr.displayName=$w;var zw="DismissableLayerBranch",Ku=h.forwardRef((e,t)=>{const n=h.useContext(Vu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(fe.div,{...e,ref:o})});Ku.displayName=zw;function Hw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Gu(Fw,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 Uw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Gu(Bw,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 qu(){const e=new CustomEvent(Vi);document.dispatchEvent(e)}function Gu(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?Wi(o,s):o.dispatchEvent(s)}var Ww=Cr,Vw=Ku,Ki=0;function qi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Yu()),document.body.insertAdjacentElement("beforeend",e[1]??Yu()),Ki++,()=>{Ki===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ki--}},[])}function Yu(){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 Gi="focusScope.autoFocusOnMount",Yi="focusScope.autoFocusOnUnmount",Xu={bubbles:!1,cancelable:!0},Kw="FocusScope",es=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=xt(o),d=xt(s),f=h.useRef(null),m=Re(t,g=>l(g)),p=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(p.paused||!a)return;const k=C.target;a.contains(k)?f.current=k:Dn(f.current,{select:!0})},x=function(C){if(p.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(f.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,p.paused]),h.useEffect(()=>{if(a){Qu.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Gi,Xu);a.addEventListener(Gi,c),a.dispatchEvent(y),y.defaultPrevented||(qw(Zw(Ju(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Gi,c),setTimeout(()=>{const y=new CustomEvent(Yi,Xu);a.addEventListener(Yi,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Yi,d),Qu.remove(p)},0)}}},[a,c,d,p]);const v=h.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[C,k]=Gw(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,p.paused]);return u.jsx(fe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});es.displayName=Kw;function qw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Gw(e){const t=Ju(e),n=Zu(t,e),r=Zu(t.reverse(),e);return[n,r]}function Ju(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Zu(e,t){for(const n of e)if(!Yw(n,{upTo:t}))return n}function Yw(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 Xw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Xw(e)&&t&&e.select()}}var Qu=Jw();function Jw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ed(e,t),e.unshift(t)},remove(t){var n;e=ed(e,t),(n=e[0])==null||n.resume()}}}function ed(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Zw(e){return e.filter(t=>t.tagName!=="A")}var Qw=h[" useId ".trim().toString()]||(()=>{}),eb=0;function _t(e){const[t,n]=h.useState(Qw());return Nt(()=>{n(r=>r??String(eb++))},[e]),t?`radix-${t}`:""}const tb=["top","right","bottom","left"],Ln=Math.min,Jt=Math.max,ts=Math.round,ns=Math.floor,wn=e=>({x:e,y:e}),nb={left:"right",right:"left",bottom:"top",top:"bottom"},rb={start:"end",end:"start"};function Xi(e,t,n){return Jt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Tr(e){return e.split("-")[1]}function Ji(e){return e==="x"?"y":"x"}function Zi(e){return e==="y"?"height":"width"}const ob=new Set(["top","bottom"]);function bn(e){return ob.has(jn(e))?"y":"x"}function Qi(e){return Ji(bn(e))}function sb(e,t,n){n===void 0&&(n=!1);const r=Tr(e),o=Qi(e),s=Zi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=rs(i)),[i,rs(i)]}function ib(e){const t=rs(e);return[ea(e),t,ea(t)]}function ea(e){return e.replace(/start|end/g,t=>rb[t])}const td=["left","right"],nd=["right","left"],ab=["top","bottom"],lb=["bottom","top"];function cb(e,t,n){switch(e){case"top":case"bottom":return n?t?nd:td:t?td:nd;case"left":case"right":return t?ab:lb;default:return[]}}function ub(e,t,n,r){const o=Tr(e);let s=cb(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ea)))),s}function rs(e){return e.replace(/left|right|bottom|top/g,t=>nb[t])}function db(e){return{top:0,right:0,bottom:0,left:0,...e}}function rd(e){return typeof e!="number"?db(e):{top:e,right:e,bottom:e,left:e}}function os(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function od(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Qi(t),a=Zi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Tr(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const fb=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}=od(c,r,l),m=r,p={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,f=C??f,p={...p,[x]:{...p[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=od(c,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function so(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=An(t,e),v=rd(p),x=a[m?f==="floating"?"reference":"floating":f],y=os(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})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=os(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const pb=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=rd(d),m={x:n,y:r},p=Qi(o),v=Zi(p),g=await i.getDimensions(c),x=p==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[p]-m[p]-s.floating[v],S=m[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const A=k/2-S/2,_=E/2-g[v]/2-1,L=Ln(f[y],_),F=Ln(f[b],_),U=L,X=E-g[v]-F,O=E/2-g[v]/2+A,Y=Xi(U,O,X),V=!l.arrow&&Tr(o)!=null&&O!==Y&&s.reference[v]/2-(O<U?L:F)-g[v]/2<0,K=V?O<U?O-U:O-X:0;return{[p]:m[p]+K,data:{[p]:Y,centerOffset:O-Y-K,...V&&{alignmentOffset:K}},reset:V}}}),hb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),b=bn(a),C=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[rs(a)]:ib(a)),T=v!=="none";!m&&T&&S.push(...ub(a,g,v,k));const E=[a,...S],A=await so(t,x),_=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(A[y]),f){const O=sb(o,i,k);_.push(A[O[0]],A[O[1]])}if(L=[...L,{placement:o,overflows:_}],!_.every(O=>O<=0)){var F,U;const O=(((F=s.flip)==null?void 0:F.index)||0)+1,Y=E[O];if(Y&&(!(f==="alignment"?b!==bn(Y):!1)||L.every(D=>bn(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:O,overflows:L},reset:{placement:Y}};let V=(U=L.filter(K=>K.overflows[0]<=0).sort((K,D)=>K.overflows[1]-D.overflows[1])[0])==null?void 0:U.placement;if(!V)switch(p){case"bestFit":{var X;const K=(X=L.filter(D=>{if(T){const I=bn(D.placement);return I===b||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,q)=>I+q,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:X[0];K&&(V=K);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function sd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function id(e){return tb.some(t=>e[t]>=0)}const mb=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 so(t,{...o,elementContext:"reference"}),i=sd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:id(i)}}}case"escaped":{const s=await so(t,{...o,altBoundary:!0}),i=sd(s,n.floating);return{data:{escapedOffsets:i,escaped:id(i)}}}default:return{}}}}},ad=new Set(["left","top"]);async function gb(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=Tr(n),l=bn(n)==="y",c=ad.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:m*c}:{x:m*c,y:p*d}}const xb=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 gb(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}}}}},vb=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:b}=x;return{x:y,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await so(t,l),f=bn(jn(o)),m=Ji(f);let p=c[m],v=c[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=p+d[x],C=p-d[y];p=Xi(b,p,C)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=Xi(b,v,C)}const g=a.fn({...t,[m]:p,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},wb=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=Ji(f);let p=d[m],v=d[f];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;p<k?p=k:p>S&&(p=S)}if(c){var y,b;const C=m==="y"?"width":"height",k=ad.has(jn(o)),S=s.reference[f]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[f])||0)+(k?0:x.crossAxis),T=s.reference[f]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:p,[f]:v}}}},bb=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 so(t,c),f=jn(o),m=Tr(o),p=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 b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Jt(d.left,0),F=Jt(d.right,0),U=Jt(d.top,0),X=Jt(d.bottom,0);p?A=v-2*(L!==0||F!==0?L+F:Jt(d.left,d.right)):E=g-2*(U!==0||X!==0?U+X:Jt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const _=await i.getDimensions(a.floating);return v!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function kr(e){return ld(e)?(e.nodeName||"").toLowerCase():"#document"}function Zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(ld(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ld(e){return ss()?e instanceof Node||e instanceof Zt(e).Node:!1}function cn(e){return ss()?e instanceof Element||e instanceof Zt(e).Element:!1}function Sn(e){return ss()?e instanceof HTMLElement||e instanceof Zt(e).HTMLElement:!1}function cd(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Zt(e).ShadowRoot}const yb=new Set(["inline","contents"]);function io(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=un(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!yb.has(o)}const Sb=new Set(["table","td","th"]);function Cb(e){return Sb.has(kr(e))}const Tb=[":popover-open",":modal"];function is(e){return Tb.some(t=>{try{return e.matches(t)}catch{return!1}})}const kb=["transform","translate","scale","rotate","perspective"],Eb=["transform","translate","scale","rotate","perspective","filter"],Ib=["paint","layout","strict","content"];function ta(e){const t=na(),n=cn(e)?un(e):e;return kb.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)||Eb.some(r=>(n.willChange||"").includes(r))||Ib.some(r=>(n.contain||"").includes(r))}function Nb(e){let t=$n(e);for(;Sn(t)&&!Er(t);){if(ta(t))return t;if(is(t))return null;t=$n(t)}return null}function na(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ab=new Set(["html","body","#document"]);function Er(e){return Ab.has(kr(e))}function un(e){return Zt(e).getComputedStyle(e)}function as(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(kr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||cd(e)&&e.host||yn(e);return cd(t)?t.host:t}function ud(e){const t=$n(e);return Er(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&io(t)?t:ud(t)}function ao(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ud(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Zt(o);if(s){const a=ra(i);return t.concat(i,i.visualViewport||[],io(o)?o:[],a&&n?ao(a):[])}return t.concat(o,ao(o,[],n))}function ra(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dd(e){const t=un(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function oa(e){return cn(e)?e:e.contextElement}function Ir(e){const t=oa(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=dd(t);let i=(s?ts(n.width):n.width)/r,a=(s?ts(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const jb=wn(0);function fd(e){const t=Zt(e);return!na()||!t.visualViewport?jb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Zt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=oa(e);let i=wn(1);t&&(r?cn(r)&&(i=Ir(r)):i=Ir(e));const a=Pb(s,n,r)?fd(s):wn(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=Zt(s),p=r&&cn(r)?Zt(r):r;let v=m,g=ra(v);for(;g&&r&&p!==v;){const x=Ir(g),y=g.getBoundingClientRect(),b=un(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,f*=x.y,l+=C,c+=k,v=Zt(g),g=ra(v)}}return os({width:d,height:f,x:l,y:c})}function ls(e,t){const n=as(e).scrollLeft;return t?t.left+n:Qn(yn(e)).left+n}function pd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ls(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function _b(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),f=Sn(r);if((f||!f&&!s)&&((kr(r)!=="body"||io(i))&&(l=as(r)),Sn(r))){const p=Qn(r);c=Ir(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?pd(i,l):wn(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 Rb(e){return Array.from(e.getClientRects())}function Mb(e){const t=yn(e),n=as(e),r=e.ownerDocument.body,o=Jt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Jt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ls(e);const a=-n.scrollTop;return un(r).direction==="rtl"&&(i+=Jt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const hd=25;function Ob(e,t){const n=Zt(e),r=yn(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=na();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ls(r);if(c<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=hd&&(s-=v)}else c<=hd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Db=new Set(["absolute","fixed"]);function Lb(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Ir(e):wn(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 md(e,t,n){let r;if(t==="viewport")r=Ob(e,n);else if(t==="document")r=Mb(yn(e));else if(cn(t))r=Lb(t,n);else{const o=fd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function gd(e,t){const n=$n(e);return n===t||!cn(n)||Er(n)?!1:un(n).position==="fixed"||gd(n,t)}function $b(e,t){const n=t.get(e);if(n)return n;let r=ao(e,[],!1).filter(a=>cn(a)&&kr(a)!=="body"),o=null;const s=un(e).position==="fixed";let i=s?$n(e):e;for(;cn(i)&&!Er(i);){const a=un(i),l=ta(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Db.has(o.position)||io(i)&&!l&&gd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function Fb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?is(t)?[]:$b(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=md(t,d,o);return c.top=Jt(f.top,c.top),c.right=Ln(f.right,c.right),c.bottom=Ln(f.bottom,c.bottom),c.left=Jt(f.left,c.left),c},md(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Bb(e){const{width:t,height:n}=dd(e);return{width:t,height:n}}function zb(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ls(o)}if(r||!r&&!s)if((kr(t)!=="body"||io(o))&&(a=as(t)),r){const p=Qn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?pd(o,a):wn(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 sa(e){return un(e).position==="static"}function xd(e,t){if(!Sn(e)||un(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function vd(e,t){const n=Zt(e);if(is(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Er(o);){if(cn(o)&&!sa(o))return o;o=$n(o)}return n}let r=xd(e,t);for(;r&&Cb(r)&&sa(r);)r=xd(r,t);return r&&Er(r)&&sa(r)&&!ta(r)?n:r||Nb(e)||n}const Hb=async function(e){const t=this.getOffsetParent||vd,n=this.getDimensions,r=await n(e.floating);return{reference:zb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ub(e){return un(e).direction==="rtl"}const Wb={convertOffsetParentRelativeRectToViewportRelativeRect:_b,getDocumentElement:yn,getClippingRect:Fb,getOffsetParent:vd,getElementRects:Hb,getClientRects:Rb,getDimensions:Bb,getScale:Ir,isElement:cn,isRTL:Ub};function wd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:m,height:p}=c;if(a||t(),!m||!p)return;const v=ns(f),g=ns(o.clientWidth-(d+m)),x=ns(o.clientHeight-(f+p)),y=ns(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Jt(0,Ln(1,l))||1};let k=!0;function S(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&&!wd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function Kb(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=oa(e),d=o||s?[...c?ao(c):[],...ao(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?Vb(c,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let v,g=l?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!wd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const qb=xb,Gb=vb,Yb=hb,Xb=bb,Jb=mb,bd=pb,Zb=wb,Qb=(e,t,n)=>{const r=new Map,o={platform:Wb,...n},s={...o.platform,_c:r};return fb(e,t,{...o,platform:s})};var ey=typeof document<"u",ty=function(){},cs=ey?w.useLayoutEffect:ty;function us(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!us(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function yd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Sd(e,t){const n=yd(e);return Math.round(t*n)/n}function ia(e){const t=h.useRef(e);return cs(()=>{t.current=e}),t}function ny(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);us(m,r)||p(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(D=>{D!==T.current&&(T.current=D,g(D))},[]),C=h.useCallback(D=>{D!==E.current&&(E.current=D,y(D))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),A=h.useRef(d),_=l!=null,L=ia(l),F=ia(o),U=ia(c),X=h.useCallback(()=>{if(!T.current||!E.current)return;const D={placement:t,strategy:n,middleware:m};F.current&&(D.platform=F.current),Qb(T.current,E.current,D).then(I=>{const q={...I,isPositioned:U.current!==!1};O.current&&!us(A.current,q)&&(A.current=q,Wr.flushSync(()=>{f(q)}))})},[m,t,n,F,U]);cs(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[c]);const O=h.useRef(!1);cs(()=>(O.current=!0,()=>{O.current=!1}),[]),cs(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if(L.current)return L.current(k,S,X);X()}},[k,S,X,L,_]);const Y=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),V=h.useMemo(()=>({reference:k,floating:S}),[k,S]),K=h.useMemo(()=>{const D={position:n,left:0,top:0};if(!V.floating)return D;const I=Sd(V.floating,d.x),q=Sd(V.floating,d.y);return a?{...D,transform:"translate("+I+"px, "+q+"px)",...yd(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:q}},[n,a,V.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:X,refs:Y,elements:V,floatingStyles:K}),[d,X,Y,V,K])}const ry=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?bd({element:r.current,padding:o}).fn(n):{}:r?bd({element:r,padding:o}).fn(n):{}}}},oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Gb(e),options:[e,t]}),iy=(e,t)=>({...Zb(e),options:[e,t]}),ay=(e,t)=>({...Yb(e),options:[e,t]}),ly=(e,t)=>({...Xb(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...ry(e),options:[e,t]});var dy="Arrow",Cd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(fe.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"})})});Cd.displayName=dy;var fy=Cd;function Td(e){const[t,n]=h.useState(void 0);return Nt(()=>{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 aa="Popper",[kd,Nr]=ln(aa),[py,Ed]=kd(aa),Id=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(py,{scope:t,anchor:r,onAnchorChange:o,children:n})};Id.displayName=aa;var Nd="PopperAnchor",Ad=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ed(Nd,n),i=h.useRef(null),a=Re(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(fe.div,{...o,ref:a})});Ad.displayName=Nd;var la="PopperContent",[hy,my]=kd(la),jd=h.forwardRef((e,t)=>{var j,R,G,Q,se,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=Ed(la,n),[y,b]=h.useState(null),C=Re(t,Se=>b(Se)),[k,S]=h.useState(null),T=Td(k),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],U=F.length>0,X={padding:L,boundary:F.filter(xy),altBoundary:U},{refs:O,floatingStyles:Y,placement:V,isPositioned:K,middlewareData:D}=ny({strategy:"fixed",placement:_,whileElementsMounted:(...Se)=>Kb(...Se,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[oy({mainAxis:o+A,alignmentAxis:i}),l&&sy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?iy():void 0,...X}),l&&ay({...X}),ly({...X,apply:({elements:Se,rects:xe,availableWidth:Oe,availableHeight:De})=>{const{width:Ge,height:Ye}=xe.reference,He=Se.floating.style;He.setProperty("--radix-popper-available-width",`${Oe}px`),He.setProperty("--radix-popper-available-height",`${De}px`),He.setProperty("--radix-popper-anchor-width",`${Ge}px`),He.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),k&&uy({element:k,padding:a}),vy({arrowWidth:E,arrowHeight:A}),m&&cy({strategy:"referenceHidden",...X})]}),[I,q]=Rd(V),J=xt(v);Nt(()=>{K&&(J==null||J())},[K,J]);const M=(j=D.arrow)==null?void 0:j.x,B=(R=D.arrow)==null?void 0:R.y,P=((G=D.arrow)==null?void 0:G.centerOffset)!==0,[$,z]=h.useState();return Nt(()=>{y&&z(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:K?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Q=D.transformOrigin)==null?void 0:Q.x,(se=D.transformOrigin)==null?void 0:se.y].join(" "),...((ie=D.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(hy,{scope:n,placedSide:I,onArrowChange:S,arrowX:M,arrowY:B,shouldHideArrow:P,children:u.jsx(fe.div,{"data-side":I,"data-align":q,...g,ref:C,style:{...g.style,animation:K?void 0:"none"}})})})});jd.displayName=la;var Pd="PopperArrow",gy={top:"bottom",right:"left",bottom:"top",left:"right"},_d=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=my(Pd,r),i=gy[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(fy,{...o,ref:n,style:{...o.style,display:"block"}})})});_d.displayName=Pd;function xy(e){return e!==null}var vy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;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]=Rd(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?f:`${m}px`,g=`${-l}px`):c==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?f:`${p}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:v,y:g}}}});function Rd(e){const[t,n="center"]=e.split("-");return[t,n]}var ca=Id,ua=Ad,da=jd,fa=_d,wy="Portal",lo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);Nt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Do.createPortal(u.jsx(fe.div,{...r,ref:t}),i):null});lo.displayName=wy;function by(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=yy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Re(r.ref,Sy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function yy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=by(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ds(r.current);s.current=a==="mounted"?c:"none"},[a]),Nt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,p=ds(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Nt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const g=ds(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=p=>{p.target===t&&(s.current=ds(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ds(e){return(e==null?void 0:e.animationName)||"none"}function Sy(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 pa="rovingFocusGroup.onEntryFocus",Cy={bubbles:!1,cancelable:!0},co="RovingFocusGroup",[ha,Md,Ty]=Zo(co),[ky,Od]=ln(co,[Ty]),[Ey,Iy]=ky(co),Dd=h.forwardRef((e,t)=>u.jsx(ha.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ha.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Ny,{...e,ref:t})})}));Dd.displayName=co;var Ny=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,m=h.useRef(null),p=Re(t,m),v=Qo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:co}),[y,b]=h.useState(!1),C=xt(c),k=Md(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(pa,C),()=>A.removeEventListener(pa,C)},[C]),u.jsx(Ey,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>E(A=>A-1),[]),children:u.jsx(fe.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,A=>{const _=!S.current;if(A.target===A.currentTarget&&_&&!y){const L=new CustomEvent(pa,Cy);if(A.currentTarget.dispatchEvent(L),!L.defaultPrevented){const F=k().filter(V=>V.focusable),U=F.find(V=>V.active),X=F.find(V=>V.id===g),Y=[U,X,...F].filter(Boolean).map(V=>V.ref.current);Fd(Y,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Ld="RovingFocusGroupItem",$d=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_t(),c=s||l,d=Iy(Ld,n),f=d.currentTabStopId===c,m=Md(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(ha.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(fe.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Py(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?_y(C,k+1):C.slice(k+1)}setTimeout(()=>Fd(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});$d.displayName=Ld;var Ay={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Py(e,t,n){const r=jy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ay[r]}function Fd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function _y(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ry=Dd,My=$d,Oy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ar=new WeakMap,fs=new WeakMap,ps={},ma=0,Bd=function(e){return e&&(e.host||Bd(e.parentNode))},Dy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Bd(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})},Ly=function(e,t,n,r){var o=Dy(t,Array.isArray(e)?e:[e]);ps[n]||(ps[n]=new WeakMap);var s=ps[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 p=m.getAttribute(r),v=p!==null&&p!=="false",g=(Ar.get(m)||0)+1,x=(s.get(m)||0)+1;Ar.set(m,g),s.set(m,x),i.push(m),g===1&&v&&fs.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(),ma++,function(){i.forEach(function(f){var m=Ar.get(f)-1,p=s.get(f)-1;Ar.set(f,m),s.set(f,p),m||(fs.has(f)||f.removeAttribute(r),fs.delete(f)),p||f.removeAttribute(n)}),ma--,ma||(Ar=new WeakMap,Ar=new WeakMap,fs=new WeakMap,ps={})}},ga=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Oy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ly(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.apply(this,arguments)};function zd(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 $y(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",ms="width-before-scroll-bar",Fy="with-scroll-bars-hidden",By="--removed-body-scroll-bar-size";function xa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function zy(e,t){var n=w.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 Hy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Hd=new WeakMap;function Uy(e,t){var n=zy(null,function(r){return e.forEach(function(o){return xa(o,r)})});return Hy(function(){var r=Hd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||xa(a,null)}),s.forEach(function(a){o.has(a)||xa(a,i)})}Hd.set(n,e)},[e]),n}function Wy(e){return e}function Vy(e,t){t===void 0&&(t=Wy);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 Ky(e){e===void 0&&(e={});var t=Vy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Ud=function(e){var t=e.sideCar,n=zd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,Cn({},n))};Ud.isSideCarExport=!0;function qy(e,t){return e.useMedium(t),Ud}var Wd=Ky(),va=function(){},gs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:va,onWheelCapture:va,onTouchMoveCapture:va}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,k=zd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=Uy([n,t]),E=Cn(Cn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Wd,removeScrollBar:c,shards:f,noRelative:p,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},E),{ref:T})):h.createElement(b,Cn({},E,{className:l,ref:T}),a))});gs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gs.classNames={fullWidth:ms,zeroRight:hs};var Gy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Yy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Gy();return t&&e.setAttribute("nonce",t),e}function Xy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Jy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Zy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Yy())&&(Xy(t,n),Jy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Qy=function(){var e=Zy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Vd=function(){var e=Qy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},e0={left:0,top:0,right:0,gap:0},wa=function(e){return parseInt(e||"",10)||0},t0=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[wa(n),wa(r),wa(o)]},n0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return e0;var t=t0(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])}},r0=Vd(),jr="data-scroll-locked",o0=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(Fy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -76,11 +76,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
76
76
|
`)},Kd=function(){var e=parseInt(document.body.getAttribute(jr)||"0",10);return isFinite(e)?e:0},s0=function(){h.useEffect(function(){return document.body.setAttribute(jr,(Kd()+1).toString()),function(){var e=Kd()-1;e<=0?document.body.removeAttribute(jr):document.body.setAttribute(jr,e.toString())}},[])},i0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;s0();var s=h.useMemo(function(){return n0(o)},[o]);return h.createElement(r0,{styles:o0(s,!t,o,n?"":"!important")})},ba=!1;if(typeof window<"u")try{var xs=Object.defineProperty({},"passive",{get:function(){return ba=!0,!0}});window.addEventListener("test",xs,xs),window.removeEventListener("test",xs,xs)}catch{ba=!1}var Pr=ba?{passive:!1}:!1,a0=function(e){return e.tagName==="TEXTAREA"},qd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!a0(e)&&n[t]==="visible")},l0=function(e){return qd(e,"overflowY")},c0=function(e){return qd(e,"overflowX")},Gd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Yd(e,r);if(o){var s=Xd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},u0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},d0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Yd=function(e,t){return e==="v"?l0(t):c0(t)},Xd=function(e,t){return e==="v"?u0(t):d0(t)},f0=function(e,t){return e==="h"&&t==="rtl"?-1:1},p0=function(e,t,n,r,o){var s=f0(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 p=Xd(e,a),v=p[0],g=p[1],x=p[2],y=g-x-s*v;(v||y)&&Yd(e,a)&&(f+=y,m+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(m)<1)&&(c=!0),c},vs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Jd=function(e){return[e.deltaX,e.deltaY]},Zd=function(e){return e&&"current"in e?e.current:e},h0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},m0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},g0=0,_r=[];function x0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(g0++)[0],s=h.useState(Vd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=$y([e.lockRef.current],(e.shards||[]).map(Zd),!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=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=vs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var A=Gd(E,T);if(!A)return!0;if(A?S=E:(S=E==="v"?"h":"v",A=Gd(E,T)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var M=r.current||S;return p0(M,x,g,M==="h"?C:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!_r.length||_r[_r.length-1]!==s)){var y="deltaY"in x?Jd(x):vs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&h0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Zd).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:v0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=h.useCallback(function(g){n.current=vs(g),r.current=void 0},[]),f=h.useCallback(function(g){c(g.type,Jd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,vs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return _r.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Pr),document.addEventListener("touchmove",l,Pr),document.addEventListener("touchstart",d,Pr),function(){_r=_r.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:m0(o)}):null,p?h.createElement(i0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function v0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const w0=qy(Wd,x0);var ws=h.forwardRef(function(e,t){return h.createElement(gs,Cn({},e,{ref:t,sideCar:w0}))});ws.classNames=gs.classNames;var ya=["Enter"," "],b0=["ArrowDown","PageUp","Home"],Qd=["ArrowUp","PageDown","End"],y0=[...b0,...Qd],S0={ltr:[...ya,"ArrowRight"],rtl:[...ya,"ArrowLeft"]},C0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},uo="Menu",[fo,T0,k0]=Zo(uo),[er,ef]=cn(uo,[k0,Nr,Od]),bs=Nr(),tf=Od(),[E0,tr]=er(uo),[I0,po]=er(uo),nf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=bs(t),[l,c]=h.useState(null),d=h.useRef(!1),f=wt(s),m=Qo(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ca,{...a,children:u.jsx(E0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(I0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};nf.displayName=uo;var N0="MenuAnchor",Sa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ua,{...o,...r,ref:t})});Sa.displayName=N0;var Ca="MenuPortal",[A0,rf]=er(Ca,{forceMount:void 0}),of=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Ca,t);return u.jsx(A0,{scope:t,forceMount:n,children:u.jsx(Ut,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:r})})})};of.displayName=Ca;var nn="MenuContent",[j0,Ta]=er(nn),sf=h.forwardRef((e,t)=>{const n=rf(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=po(nn,e.__scopeMenu);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(fo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(P0,{...o,ref:t}):u.jsx(_0,{...o,ref:t})})})})}),P0=h.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=h.useRef(null),o=Pe(t,r);return h.useEffect(()=>{const s=r.current;if(s)return ga(s)},[]),u.jsx(ka,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),_0=h.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(ka,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),R0=Yt.createSlot("MenuContent.ScrollLock"),ka=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:v,...g}=e,x=tr(nn,n),y=po(nn,n),b=bs(n),C=tf(n),k=T0(n),[S,T]=h.useState(null),E=h.useRef(null),A=Pe(t,E,x.onContentChange),M=h.useRef(0),L=h.useRef(""),F=h.useRef(0),z=h.useRef(null),X=h.useRef("right"),O=h.useRef(0),Y=v?ws:h.Fragment,W=v?{as:R0,allowPinchZoom:!0}:void 0,K=I=>{var j,_;const V=L.current+I,Z=k().filter(G=>!G.disabled),R=document.activeElement,q=(j=Z.find(G=>G.ref.current===R))==null?void 0:j.textValue,P=Z.map(G=>G.textValue),$=V0(P,V,q),H=(_=Z.find(G=>G.textValue===$))==null?void 0:_.ref.current;(function G(Q){L.current=Q,window.clearTimeout(M.current),Q!==""&&(M.current=window.setTimeout(()=>G(""),1e3))})(V),H&&setTimeout(()=>H.focus())};h.useEffect(()=>()=>window.clearTimeout(M.current),[]),qi();const D=h.useCallback(I=>{var Z,R;return X.current===((Z=z.current)==null?void 0:Z.side)&&q0(I,(R=z.current)==null?void 0:R.area)},[]);return u.jsx(j0,{scope:n,searchRef:L,onItemEnter:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),onItemLeave:h.useCallback(I=>{var V;D(I)||((V=E.current)==null||V.focus(),T(null))},[D]),onTriggerLeave:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),pointerGraceTimerRef:F,onPointerGraceIntentChange:h.useCallback(I=>{z.current=I},[]),children:u.jsx(Y,{...W,children:u.jsx(es,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var V;I.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(Ry,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(da,{role:"menu","aria-orientation":"vertical","data-state":Cf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const Z=I.target.closest("[data-radix-menu-content]")===I.currentTarget,R=I.ctrlKey||I.altKey||I.metaKey,q=I.key.length===1;Z&&(I.key==="Tab"&&I.preventDefault(),!R&&q&&K(I.key));const P=E.current;if(I.target!==P||!y0.includes(I.key))return;I.preventDefault();const H=k().filter(j=>!j.disabled).map(j=>j.ref.current);Qd.includes(I.key)&&H.reverse(),U0(H)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ie(e.onPointerMove,mo(I=>{const V=I.target,Z=O.current!==I.clientX;if(I.currentTarget.contains(V)&&Z){const R=I.clientX>O.current?"right":"left";X.current=R,O.current=I.clientX}}))})})})})})})});sf.displayName=nn;var M0="MenuGroup",Ea=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"group",...r,ref:t})});Ea.displayName=M0;var O0="MenuLabel",af=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});af.displayName=O0;var ys="MenuItem",lf="menu.itemSelect",Ss=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=po(ys,e.__scopeMenu),a=Ta(ys,e.__scopeMenu),l=Pe(t,s),c=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(lf,{bubbles:!0,cancelable:!0});f.addEventListener(lf,p=>r==null?void 0:r(p),{once:!0}),Wi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(cf,{...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===" "||ya.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ss.displayName=ys;var cf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ta(ys,n),a=tf(n),l=h.useRef(null),c=Pe(t,l),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),u.jsx(fo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(My,{asChild:!0,...a,focusable:!r,children:u.jsx(fe.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,mo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,mo(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>f(!0)),onBlur:ie(e.onBlur,()=>f(!1))})})})}),D0="MenuCheckboxItem",uf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(mf,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ss,{role:"menuitemcheckbox","aria-checked":Cs(n)?"mixed":n,...o,ref:t,"data-state":Na(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(Cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});uf.displayName=D0;var df="MenuRadioGroup",[L0,$0]=er(df,{value:void 0,onValueChange:()=>{}}),ff=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=wt(r);return u.jsx(L0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ea,{...o,ref:t})})});ff.displayName=df;var pf="MenuRadioItem",hf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=$0(pf,e.__scopeMenu),s=n===o.value;return u.jsx(mf,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ss,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Na(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});hf.displayName=pf;var Ia="MenuItemIndicator",[mf,F0]=er(Ia,{checked:!1}),gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=F0(Ia,n);return u.jsx(Ut,{present:r||Cs(s.checked)||s.checked===!0,children:u.jsx(fe.span,{...o,ref:t,"data-state":Na(s.checked)})})});gf.displayName=Ia;var B0="MenuSeparator",xf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});xf.displayName=B0;var z0="MenuArrow",vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(fa,{...o,...r,ref:t})});vf.displayName=z0;var H0="MenuSub",[$N,wf]=er(H0),ho="MenuSubTrigger",bf=h.forwardRef((e,t)=>{const n=tr(ho,e.__scopeMenu),r=po(ho,e.__scopeMenu),o=wf(ho,e.__scopeMenu),s=Ta(ho,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Sa,{asChild:!0,...c,children:u.jsx(cf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Cf(n.open),...e,ref:Mn(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,mo(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,mo(f=>{var p,v;d();const m=(p=n.content)==null?void 0:p.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,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 p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||S0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});bf.displayName=ho;var yf="MenuSubContent",Sf=h.forwardRef((e,t)=>{const n=rf(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=po(nn,e.__scopeMenu),a=wf(yf,e.__scopeMenu),l=h.useRef(null),c=Pe(t,l);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(fo.Slot,{scope:e.__scopeMenu,children:u.jsx(ka,{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 p;const f=d.currentTarget.contains(d.target),m=C0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Sf.displayName=yf;function Cf(e){return e?"open":"closed"}function Cs(e){return e==="indeterminate"}function Na(e){return Cs(e)?"indeterminate":e?"checked":"unchecked"}function U0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function W0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function V0(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=W0(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 K0(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 q0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return K0(n,t)}function mo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var G0=nf,Y0=Sa,X0=of,J0=sf,Z0=Ea,Q0=af,eS=Ss,tS=uf,nS=ff,rS=hf,oS=gf,sS=xf,iS=vf,aS=bf,lS=Sf,Ts="DropdownMenu",[cS,FN]=cn(Ts,[ef]),$t=ef(),[uS,Tf]=cS(Ts),kf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=h.useRef(null),[d,f]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Ts});return u.jsx(uS,{scope:t,triggerId:Rt(),triggerRef:c,contentId:Rt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(G0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};kf.displayName=Ts;var Ef="DropdownMenuTrigger",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Tf(Ef,n),i=$t(n);return u.jsx(Y0,{asChild:!0,...i,children:u.jsx(fe.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:Mn(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())})})})});If.displayName=Ef;var dS="DropdownMenuPortal",Nf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(X0,{...r,...n})};Nf.displayName=dS;var Af="DropdownMenuContent",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tf(Af,n),s=$t(n),i=h.useRef(!1);return u.jsx(J0,{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)"}})});jf.displayName=Af;var fS="DropdownMenuGroup",pS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});pS.displayName=fS;var hS="DropdownMenuLabel",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=hS;var mS="DropdownMenuItem",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(eS,{...o,...r,ref:t})});_f.displayName=mS;var gS="DropdownMenuCheckboxItem",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(tS,{...o,...r,ref:t})});Rf.displayName=gS;var xS="DropdownMenuRadioGroup",vS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(nS,{...o,...r,ref:t})});vS.displayName=xS;var wS="DropdownMenuRadioItem",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(rS,{...o,...r,ref:t})});Mf.displayName=wS;var bS="DropdownMenuItemIndicator",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(oS,{...o,...r,ref:t})});Of.displayName=bS;var yS="DropdownMenuSeparator",Df=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(sS,{...o,...r,ref:t})});Df.displayName=yS;var SS="DropdownMenuArrow",CS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(iS,{...o,...r,ref:t})});CS.displayName=SS;var TS="DropdownMenuSubTrigger",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(aS,{...o,...r,ref:t})});Lf.displayName=TS;var kS="DropdownMenuSubContent",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(lS,{...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)"}})});$f.displayName=kS;var ES=kf,IS=If,NS=Nf,Ff=jf,Bf=Pf,zf=_f,Hf=Rf,Uf=Mf,Wf=Of,Vf=Df,Kf=Lf,qf=$f;const ks=ES,Es=IS,AS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Kf,{ref:o,className:te("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"})]}));AS.displayName=Kf.displayName;const jS=h.forwardRef(({className:e,...t},n)=>u.jsx(qf,{ref:n,className:te("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}));jS.displayName=qf.displayName;const go=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(NS,{children:u.jsx(Ff,{ref:r,sideOffset:t,className:te("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})}));go.displayName=Ff.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(zf,{ref:r,className:te("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}));Fn.displayName=zf.displayName;const PS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Hf,{ref:o,className:te("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(Wf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));PS.displayName=Hf.displayName;const _S=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Uf,{ref:r,className:te("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(Wf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));_S.displayName=Uf.displayName;const RS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Bf,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));RS.displayName=Bf.displayName;const MS=h.forwardRef(({className:e,...t},n)=>u.jsx(Vf,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));MS.displayName=Vf.displayName;const Aa=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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}));Aa.displayName="Textarea";const OS=1e4;function Gf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=OS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),A=w.useRef(0),M=w.useRef(null),L=w.useRef("");w.useEffect(()=>{y||(C(e??""),M.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,z]=w.useState(null),X=w.useCallback(P=>P.length>s?`Message too long (${P.length}/${s} characters)`:null,[s]),O=w.useMemo(()=>g??X,[g,X]),Y=w.useCallback(P=>{const $=O(P);return z($),x==null||x($),L.current=P,$},[O,x]),W=w.useCallback(()=>{const P=E.current;P&&(P.style.height="auto",P.style.height=`${P.scrollHeight}px`)},[]);w.useEffect(()=>{W()},[W,k]),w.useEffect(()=>{if(!F)return;const P=(k??"").trim();L.current!==P&&Y(P)},[k,F,Y]);const K=w.useCallback((P,{fromUser:$})=>{y||C(P),$&&(a==null||a(P))},[y,a]),D=w.useCallback(async P=>{P&&P.preventDefault();const $=(k??"").trim();if(!$&&!p||Y($))return;const H=++A.current;M.current={id:H,shouldClear:!0},T(()=>{var j,_,G;try{const Q=l($);Q&&typeof Q.then=="function"?Q.then(()=>{var oe,ae;((oe=M.current)==null?void 0:oe.id)===H&&M.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((ae=M.current)==null?void 0:ae.id)===H&&(M.current=null)}).catch(()=>{var oe;((oe=M.current)==null?void 0:oe.id)===H&&(M.current=null)}):(((j=M.current)==null?void 0:j.id)===H&&M.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((_=M.current)==null?void 0:_.id)===H&&(M.current=null))}catch{((G=M.current)==null?void 0:G.id)===H&&(M.current=null)}})},[k,l,p,y,a,Y]),I=w.useCallback(P=>{const $=P.target.value;K($,{fromUser:!0}),M.current&&(M.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&Y($.trim())},[K,Y,F]),V=w.useCallback(P=>{P.key==="Enter"&&!P.shiftKey?(P.preventDefault(),D()):P.key==="Escape"&&t&&(P.preventDefault(),c==null||c())},[D,t,c]),q=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:P=>void D(P),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Aa,{ref:E,value:k,onChange:I,onKeyDown:V,placeholder:t?"Edit your message...":n,className:q,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(Je,{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(Je,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!p||S,children:u.jsx(le.Send,{size:16})})})]})})}const DS=w.memo(Gf);function Yf({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[A,M]=w.useState(0),[L,F]=w.useState(!1),[z,X]=w.useState(null),[O,Y]=w.useState(null),W=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(P=>P+1),M(P=>P+1)},[]),K=w.useCallback(P=>{C($=>[...$,...P])},[]),D=w.useCallback(P=>{const $=Array.from(P.target.files||[]);K($),P.target.value=""},[K]),I=w.useCallback(P=>{C($=>{const H=$.filter((j,_)=>_!==P);return H.length===0&&W(),H})},[W]),V=w.useCallback(async P=>{const $=(P.target.files||[])[0];if($&&(X(null),Y(null),!!v)){F(!0);try{await v($),X(`Uploaded ${$.name} - processing through chat stream`)}catch(H){const j=H instanceof Error?H.message:"Failed to upload Excel file";Y(j),g==null||g(j)}finally{F(!1),P.target.value="",W()}}},[v,g,W]),Z=w.useMemo(()=>x||b.length>0,[x,b]),R=w.useCallback(async P=>{const H=await n(P,b);return b.length>0&&(C([]),W()),H},[n,W,b]),q=`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||p)&&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:D,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((P,$)=>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:P.name}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>I($),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 ${P.name}`,children:u.jsx(le.X,{size:12})})]},$))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:V,className:"hidden"},A),L&&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..."]}),z&&!L&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:z}),O&&!L&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:O})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||p)&&u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{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(go,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var P;return(P=k.current)==null?void 0:P.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Fn,{onClick:()=>{var P;L||(P=S.current)==null||P.click()},className:`cursor-pointer ${L?"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(DS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:R,onCancelEdit:r,onStop:o,allowEmptySend:Z,textareaClassName:q,sendButtonClassName:f.sendButton})})]})]})}const LS=w.memo(Yf),Is=0,Bn=1,Rr=2,Xf=4;function Jf(e){return()=>e}function $S(e){e()}function Zf(e,t){return n=>e(t(n))}function Qf(e,t){return()=>e(t)}function FS(e,t){return n=>e(t,n)}function ja(e){return e!==void 0}function BS(...e){return()=>{e.map($S)}}function Mr(){}function Ns(e,t){return t(e),e}function zS(e,t){return t(e)}function ot(...e){return e}function Ze(e,t){return e(Bn,t)}function Ie(e,t){e(Is,t)}function Pa(e){e(Rr)}function bt(e){return e(Xf)}function pe(e,t){return Ze(e,FS(t,Is))}function fn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function ep(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function tp(e,t){return e===t}function st(e=tp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Zf(t,e)}function Tn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=HS(...t);return(r,o)=>{switch(r){case Rr:Pa(e);return;case Bn:return Ze(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function Pn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function _e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function HS(...e){return t=>e.reduceRight(zS,t)}function US(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Mr);case Rr:r(),n=null;return}}}function re(e){let t=e;const n=ze();return(r,o)=>{switch(r){case Is:t=o;break;case Bn:{o(t);break}case Xf:return t}return n(r,o)}}function Mt(e,t){return Ns(re(t),n=>pe(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case Is:e.slice().forEach(r=>{r(n)});return;case Rr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return Ns(ze(),t=>pe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:WS(),singleton:n}}const WS=()=>Symbol();function VS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function St(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&Ie(t,n)})}),function(s,i){switch(s){case Rr:{Pa(t);return}case Bn:return r===o&&i(n),Ze(t,i)}}}function be(e,t=tp){return ee(e,st(t))}function _a(...e){return function(t,n){switch(t){case Rr:return;case Bn:return BS(...e.map(r=>Ze(r,n)))}}}var Wt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Wt||{});const KS={0:"debug",3:"error",1:"log",2:"warn"},qS=()=>typeof globalThis>"u"?window:globalThis,zn=Ge(()=>{const e=re(3);return{log:re((t,n,r=1)=>{var o;const s=(o=qS().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[KS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return Ra(e,t,n).callbackRef}function Ra(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.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 GS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const f=YS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const p=m.lastElementChild.dataset.viewportType==="window";let v;p&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?np("column-gap",getComputedStyle(d).columnGap,o):np("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ra(c,n,l)}function YS(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},Wt.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 np(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}function rp(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,m;if(t){const p=t.getBoundingClientRect(),v=c.top-p.top;m=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ra(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=Ge(()=>{const e=ze(),t=ze(),n=re(0),r=ze(),o=re(0),s=ze(),i=ze(),a=re(0),l=re(0),c=re(0),d=re(0),f=ze(),m=ze(),p=re(!1),v=re(!1),g=re(!1);return pe(ee(e,ce(({scrollTop:x})=>x)),t),pe(ee(e,ce(({scrollHeight:x})=>x)),i),pe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),xo={lvl:0};function op(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===xo}function vo(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?vo(e.l,t):vo(e.r,t)}function pn(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=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function tn(e,t,n){return tt(e)?ap(t,n,1):t===e.k?Tt(e,{k:t,v:n}):t<e.k?lp(Tt(e,{l:tn(e.l,t,n)})):lp(Tt(e,{r:tn(e.r,t,n)}))}function Or(){return xo}function As(e,t,n){if(tt(e))return[];const r=pn(e,t)[0];return XS(Oa(e,r,n))}function Ma(e,t){if(tt(e))return xo;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=ip(r);return js(Tt(e,{k:s,l:sp(r),v:i}))}}else return t<n?js(Tt(e,{l:Ma(r,t)})):js(Tt(e,{r:Ma(o,t)}))}function or(e){return tt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function Oa(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(Oa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Oa(s,t,n))),a}function js(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(Da(t))return cp(Tt(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return Tt(t.r,{l:Tt(t,{r:t.r.l}),lvl:n,r:Tt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Da(e))return La(Tt(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=Da(o)?r.lvl-1:r.lvl;return Tt(o,{l:Tt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:La(Tt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Tt(e,t){return ap(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 sp(e){return tt(e.r)?e.l:js(Tt(e,{r:sp(e.r)}))}function Da(e){return tt(e)||e.lvl>e.r.lvl}function ip(e){return tt(e.r)?[e.k,e.v]:ip(e.r)}function ap(e,t,n,r=xo,o=xo){return{k:e,l:r,lvl:n,r:o,v:t}}function lp(e){return La(cp(e))}function cp(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?Tt(t,{r:Tt(e,{l:t.r})}):e}function La(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?Tt(n,{l:Tt(e,{r:n.l}),lvl:t+1}):e}function XS(e){return op(e,({k:t,v:n})=>({index:t,value:n}))}function up(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function wo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const $a=Ge(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function dp(e,t,n){return e[Ps(e,t,n)]}function Ps(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 JS(e,t,n,r){const o=Ps(e,t,r),s=Ps(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function _s(e){return!tt(e.groupOffsetTree)}function Fa({index:e},t){return t===e?0:t<e?-1:1}function ZS(){return{groupIndices:[],groupOffsetTree:Or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Or()}}function QS(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=tn(e,0,s);continue}const a=As(e,i-1,o+1);if(a.some(iC(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Ma(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function eC(e){return typeof e.groupIndex<"u"}function tC({offset:e},t){return t===e?0:t<e?-1:1}function bo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=dp(t,e,Fa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function fp(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function pp(e,t,n){if(eC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=fp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function nC(e,t,n,r=0){return r>0&&(t=Math.max(t,dp(e,r,Fa).offset)),op(JS(e,t,n,tC),sC)}function rC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Wt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&tt(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,p),i)}else[i,a]=QS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=Ba(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>tn(m,p,bo(p,f,o)),Or()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function oC(e){return or(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 hp(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 Ba(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ps(o,t-1,Fa),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of As(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 sC(e){return{index:e.index,value:e}}function iC(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 aC={offsetHeight:"height",offsetWidth:"width"},En=Ge(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Mt(r,0),s=ze(),i=ze(),a=re(0),l=re([]),c=re(void 0),d=re(void 0),f=re((S,T)=>Hn(S,aC[T])),m=re(void 0),p=re(0),v=ZS(),g=Mt(ee(n,_e(l,e,p),kn(rC,v),st()),v),x=Mt(ee(l,st(),kn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ce(({prev:S})=>S)),[]);pe(ee(l,ye(S=>S.length>0),_e(g,p),ce(([S,T,E])=>{const A=S.reduce((M,L,F)=>tn(M,L,bo(L,T.offsetTree,E)||F),Or());return{...T,groupIndices:S,groupOffsetTree:A}})),g),pe(ee(r,_e(g),ye(([S,{lastIndex:T}])=>S<T),ce(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),pe(c,d);const y=Mt(ee(c,ce(S=>S===void 0)),!0);pe(ee(d,ye(S=>S!==void 0&&tt(bt(g).sizeTree)),ce(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=en(ee(n,_e(g),kn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ce(S=>S.changed)));Ze(ee(a,kn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ce(S=>S.diff)),S=>{const{groupIndices:T}=bt(g);if(S>0)Ie(t,!0),Ie(s,S+hp(S,T));else if(S<0){const E=bt(x);E.length>0&&(S-=hp(-S,E)),Ie(i,S)}}),Ze(ee(a,_e(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Wt.ERROR)});const C=en(s);pe(ee(s,_e(g),ce(([S,T])=>{const E=T.groupIndices.length>0,A=[],M=T.lastSize;if(E){const L=vo(T.sizeTree,0);let F=0,z=0;for(;F<S;){const O=T.groupIndices[z],Y=T.groupIndices.length===z+1?1/0:T.groupIndices[z+1]-O-1;A.push({endIndex:O,size:L,startIndex:O}),A.push({endIndex:O+1+Y-1,size:M,startIndex:O+1}),z++,F+=Y+1}const X=or(T.sizeTree);return F!==S&&X.shift(),X.reduce((O,{k:Y,v:W})=>{let K=O.ranges;return O.prevSize!==0&&(K=[...O.ranges,{endIndex:Y+S-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:Y+S,prevSize:W,ranges:K}},{prevIndex:S,prevSize:0,ranges:A}).ranges}return or(T.sizeTree).reduce((L,{k:F,v:z})=>({prevIndex:F+S,prevSize:z,ranges:[...L.ranges,{endIndex:F+S-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:M,ranges:[]}).ranges})),n);const k=en(ee(i,_e(g,p),ce(([S,{offsetTree:T},E])=>{const A=-S;return bo(A,T,E)})));return pe(ee(i,_e(g,p),ce(([S,T,E])=>{if(T.groupIndices.length>0){if(tt(T.sizeTree))return T;let A=Or();const M=bt(x);let L=0,F=0,z=0;for(;L<-S;){z=M[F];const X=M[F+1]-z-1;F++,L+=X+1}if(A=or(T.sizeTree).reduce((X,{k:O,v:Y})=>tn(X,Math.max(0,O+S),Y),A),L!==-S){const X=vo(T.sizeTree,z);A=tn(A,0,X);const O=pn(T.sizeTree,-S+1)[1];A=tn(A,1,O)}return{...T,sizeTree:A,...Ba(T.offsetTree,0,A,E)}}else{const A=or(T.sizeTree).reduce((M,{k:L,v:F})=>tn(M,Math.max(0,L+S),F),Or());return{...T,sizeTree:A,...Ba(T.offsetTree,0,A,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ot(zn,$a),{singleton:!0});function lC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const mp=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=en(ee(s,ce(lC)));return pe(ee(a,ce(l=>l.totalCount)),n),pe(ee(a,ce(l=>l.groupIndices)),e),pe(ee(St(o,t,r),ye(([l,c])=>_s(c)),ce(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(En,Ft)),Un=Ge(([{log:e}])=>{const t=re(!1),n=en(ee(t,ye(r=>r),st()));return Ze(t,r=>{r&&bt(e)("props updated",{},Wt.DEBUG)}),{didMount:n,propsReady:t}},ot(zn),{singleton:!0}),cC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function gp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!cC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const yo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=ze(),v=ze(),g=re(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Ie(l,!1)}return pe(ee(p,_e(n,f,r,g,a,i,m),_e(e,s,o),ce(([[k,S,T,E,A,M,L,F],z,X,O])=>{const Y=gp(k),{align:W,behavior:K,offset:D}=Y,I=E-1,V=pp(Y,S,I);let Z=bo(V,S.offsetTree,z)+M;W==="end"?(Z+=X+pn(S.sizeTree,V)[1]-T+O,V===I&&(Z+=L)):W==="center"?Z+=(X+pn(S.sizeTree,V)[1]-T+O)/2:Z-=A,D&&(Z+=D);const R=q=>{C(),q?(F("retrying to scroll to",{location:k},Wt.DEBUG),Ie(p,k)):(Ie(v,!0),F("list did not change, scroll successful",{},Wt.DEBUG))};if(C(),K==="smooth"){let q=!1;b=Ze(t,P=>{q=q||P}),x=fn(d,()=>{R(q)})}else x=fn(ee(t,uC(150)),R);return y=setTimeout(()=>{C()},1200),Ie(l,!0),F("scrolling from index to",{behavior:K,index:V,top:Z},Wt.DEBUG),{behavior:K,top:Z}})),c),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},ot(En,Ft,zn),{singleton:!0});function uC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function za(e,t){e==0?t():requestAnimationFrame(()=>{za(e-1,t)})}function Ha(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const So=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=re(!0),l=re(0),c=re(!0);return pe(ee(i,_e(l),ye(([d,f])=>!!f),Tn(!1)),a),pe(ee(i,_e(l),ye(([d,f])=>!!f),Tn(!1)),c),Ze(ee(St(t,i),_e(a,n,e,c),ye(([[,d],f,{sizeTree:m},p,v])=>d&&(!tt(m)||ja(p))&&!f&&!v),_e(l)),([,d])=>{fn(o,()=>{Ie(c,!0)}),za(4,()=>{fn(r,()=>{Ie(a,!0)}),Ie(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(En,Ft,yo,Un),{singleton:!0});function xp(e,t){return Math.abs(e-t)<1.01}const Co="up",To="down",dC="none",fC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},pC=0,ko=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=re(!1),a=re(!0),l=ze(),c=ze(),d=re(4),f=re(pC),m=Mt(ee(_a(ee(be(o),nr(1),Tn(!0)),ee(be(o),nr(1),Tn(!1),ep(100))),st()),!1),p=Mt(ee(_a(ee(n,Tn(!0)),ee(n,Tn(!1),ep(200))),st()),!1);pe(ee(St(be(o),be(f)),ce(([b,C])=>b<=C),st()),a),pe(ee(a,Pn(50)),c);const v=en(ee(St(r,be(s),be(t),be(e),be(d)),kn((b,[{scrollHeight:C,scrollTop:k},S,T,E,A])=>{const M=k+S-C>-A,L={scrollHeight:C,scrollTop:k,viewportHeight:S};if(M){let z,X;return k>b.state.scrollTop?(z="SCROLLED_DOWN",X=b.state.scrollTop-k):(z="SIZE_DECREASED",X=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:X,state:L}}let F;return L.scrollHeight>b.state.scrollHeight?F="SIZE_INCREASED":S<b.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:L}},fC),st((b,C)=>b&&b.atBottom===C.atBottom))),g=Mt(ee(r,kn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(xp(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(b=>b.changed),ce(b=>b.jump)),0);pe(ee(v,ce(b=>b.atBottom)),i),pe(ee(i,Pn(50)),l);const x=re(To);pe(ee(r,ce(({scrollTop:b})=>b),st(),kn((b,C)=>bt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?Co:To,prevScrollTop:C},{direction:To,prevScrollTop:0}),ce(b=>b.direction)),x),pe(ee(r,Pn(50),Tn(dC)),x);const y=re(0);return pe(ee(m,ye(b=>!b),Tn(0)),y),pe(ee(o,Pn(100),_e(m),ye(([b,C])=>!!C),kn(([b,C],[k])=>[C,k],[0,0]),ce(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ot(Ft)),Rs="top",Ms="bottom",vp="none";function wp(e,t,n){return typeof e=="number"?n===Co&&t===Rs||n===To&&t===Ms?e:0:n===Co?t===Rs?e.main:e.reverse:t===Ms?e.main:e.reverse}function bp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ua=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=re(0),a=re(0),l=re(0),c=Mt(ee(St(be(r),be(o),be(n),be(s,wo),be(l),be(i),be(t),be(e),be(a)),ce(([d,f,m,[p,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=vp;const A=bp(C,Rs),M=bp(C,Ms);return p-=b,p+=m+y,v+=m+y,v-=b,p>d+S-A&&(E=Co),v<d-T+f+M&&(E=To),E!==vp?[Math.max(k-m-wp(g,Rs,E)-A,0),k-T-y+f+wp(g,Ms,E)+M]:null}),ye(d=>d!=null),st(wo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ot(Ft),{singleton:!0});function hC(e,t,n){if(_s(t)){const r=fp(e,t);return[{index:pn(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 Wa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Os(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const f=n-i,m=a+f*l+(f-1)*r,p=c,v=m-d;return{bottom:d,firstItemIndex:s,items:Sp(e,o,s),offsetBottom:v,offsetTop:c,top:p,topItems:Sp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function yp(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=Ha(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Os(c,[],a,o,n,r)}function Sp(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=As(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 sr=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:v}])=>{const g=re([]),x=re(0),y=ze();pe(s.topItemsIndexes,g);const b=Mt(ee(St(p,v,be(l,wo),be(o),be(r),be(c),d,be(g),be(t),be(n),e),ye(([T,E,,A,,,,,,,M])=>{const L=M&&M.length!==A;return T&&!E&&!L}),ce(([,,[T,E],A,M,L,F,z,X,O,Y])=>{const W=M,{offsetTree:K,sizeTree:D}=W,I=bt(x);if(A===0)return{...Wa,totalCount:A};if(T===0&&E===0)return I===0?{...Wa,totalCount:A}:yp(I,L,M,X,O,Y||[]);if(tt(D))return I>0?null:Os(hC(Ha(L,A),W,Y),[],A,O,W,X);const V=[];if(z.length>0){const $=z[0],H=z[z.length-1];let j=0;for(const _ of As(D,$,H)){const G=_.value,Q=Math.max(_.start,$),oe=Math.min(_.end,H);for(let ae=Q;ae<=oe;ae++)V.push({data:Y==null?void 0:Y[ae],index:ae,offset:j,size:G}),j+=G}}if(!F)return Os([],V,A,O,W,X);const Z=z.length>0?z[z.length-1]+1:0,R=nC(K,T,E,Z);if(R.length===0)return null;const q=A-1,P=Ns([],$=>{for(const H of R){const j=H.value;let _=j.offset,G=H.start;const Q=j.size;if(j.offset<T){G+=Math.floor((T-j.offset+O)/(Q+O));const ae=G-H.start;_+=ae*Q+ae*O}G<Z&&(_+=(Z-G)*Q,G=Z);const oe=Math.min(H.end,q);for(let ae=G;ae<=oe&&!(_>=E);ae++)$.push({data:Y==null?void 0:Y[ae],index:ae,offset:_,size:Q}),_+=Q+O}});return Os(P,V,A,O,W,X)}),ye(T=>T!==null),st()),Wa);pe(ee(e,ye(ja),ce(T=>T==null?void 0:T.length)),o),pe(ee(b,ce(T=>T.topListHeight)),f),pe(f,a),pe(ee(b,ce(T=>[T.top,T.bottom])),i),pe(ee(b,ce(T=>T.items)),y);const C=en(ee(b,ye(({items:T})=>T.length>0),_e(o,e),ye(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ce(([,T,E])=>[T-1,E]),st(wo),ce(([T])=>T))),k=en(ee(b,Pn(200),ye(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ce(({items:T})=>T[0].index),st())),S=en(ee(b,ye(({items:T})=>T.length>0),ce(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),st(up)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},ot(En,mp,Ua,So,yo,ko,Un,$a),{singleton:!0}),Cp=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=Mt(ee(St(n,e,r,t,o),ce(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return pe(be(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(Ft,sr),{singleton:!0}),mC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=Mt(ee(St(n,e,t),ye(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),Pn(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(Ft,Cp),{singleton:!0}),Tp=Ge(()=>({context:re(null)})),gC=({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,kp=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=ze();return pe(ee(d,_e(t,l,n,s,o,r,a),_e(e),ce(([[f,m,p,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=gC,done:E,...A}=f,M=pp(f,m,v-1),L=bo(M,m.offsetTree,C)+g+x,F=L+pn(m.sizeTree,M)[1],z=b+x,X=b+p-y,O=T({itemBottom:F,itemTop:L,locationParams:{align:k,behavior:S,...A},viewportBottom:X,viewportTop:z});return O?E&&fn(ee(i,ye(Y=>!Y),nr(bt(i)?1:2)),E):E&&E(),O}),ye(f=>f!==null)),c),{scrollIntoView:d}},ot(En,Ft,yo,sr,zn),{singleton:!0});function Ep(e){return e?e==="smooth"?"smooth":"auto":!1}const xC=(e,t)=>typeof e=="function"?Ep(e(t)):t&&Ep(e),vC=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const v=re(!1),g=ze();let x=null;function y(S){Ie(i,{align:"end",behavior:S,index:"LAST"})}Ze(ee(St(ee(be(t),nr(1)),l),_e(be(v),s,a,f),ce(([[S,T],E,A,M,L])=>{let F=T&&M,z="auto";return F&&(z=xC(E,A||L),F=F&&!!z),{followOutputBehavior:z,shouldFollow:F,totalCount:S}}),ye(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S)}):x=fn(e,()=>{bt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S),x=null})});function b(S){const T=fn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(bt(d)("scrolling to bottom due to increased size",{},Wt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(ee(St(be(v),t,c),ye(([S,,T])=>S&&T),kn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),ye(({refreshed:S})=>S),_e(v,t)),([,S])=>{bt(a)&&b(S!==!1)}),Ze(g,()=>{b(bt(v)!==!1)}),Ze(St(be(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=re(null),k=ze();return pe(_a(ee(be(r),ce(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),ee(be(t))),k),Ze(ee(St(ee(k,nr(1)),l),_e(be(C),a,f,m),ce(([[S,T],E,A,M,L])=>T&&A&&(E==null?void 0:E({context:L,totalCount:S,scrollingInProgress:M}))),ye(S=>!!S),Pn(0)),S=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),Ie(p,S)}):x=fn(e,()=>{bt(d)("scrolling into view",{}),Ie(p,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},ot(En,ko,yo,So,Un,zn,Ft,Tp,kp)),wC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(pe(ee(a,_e(s),ye(([,l])=>l!==0),_e(o,r,t,n,e),ce(([[,l],c,d,f,m,p=[]])=>yp(l,c,d,f,m,p))),i),{}),ot(En,So,sr,Un),{singleton:!0}),bC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return Ze(ee(e,_e(r),ye(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{fn(ee(n,nr(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ie(t,o)})})}),{initialScrollTop:r}},ot(Un,Ft,sr),{singleton:!0}),Ip=Ge(([{scrollVelocity:e}])=>{const t=re(!1),n=ze(),r=re(!1);return pe(ee(e,_e(r,t,n),ye(([o,s])=>!!s),ce(([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),Ze(ee(St(t,e,n),_e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ot(ko),{singleton:!0}),Va=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=re(!1),i=re(void 0);return pe(ee(St(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),pe(ee(t,_e(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(Ft)),yC=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ze(),d=re(void 0),f=re(null),m=re(null);return pe(a,f),pe(l,m),Ze(ee(c,_e(t,r,i,f,m,n)),([p,v,g,x,y,b,C])=>{const k=oC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,p({ranges:k,scrollTop:g})}),pe(ee(d,ye(ja),ce(SC)),o),pe(ee(s,_e(d),ye(([,p])=>p!==void 0),st(),ce(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},ot(En,Ft,So,Un,Va));function SC(e){return{align:"start",index:0,offset:e.scrollTop}}const CC=Ge(([{topItemsIndexes:e}])=>{const t=re(0);return pe(ee(t,ye(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(sr));function Np(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const TC=Np(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),kC=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:v}])=>{const g=en(ee(l,_e(i),kn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},A])=>{const M=k+T;let L=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||(L=M-C,L!==0&&(L+=A))),[L,S,E,M]},[0,[],0,0]),ye(([y])=>y!==0),_e(r,a,n,o,p,v),ye(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===Co),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Wt.DEBUG),y))));function x(y){y>0?(Ie(t,{behavior:"auto",top:-y}),Ie(e,0)):(Ie(e,0),Ie(t,{behavior:"auto",top:-y}))}return Ze(ee(g,_e(e,s)),([y,b,C])=>{C&&TC()?Ie(e,b-y):x(-y)}),Ze(ee(St(Mt(s,!1),e,v),ye(([y,b,C])=>!y&&!C&&b!==0),ce(([y,b])=>b),Pn(1)),x),pe(ee(f,ce(y=>({top:-y}))),t),Ze(ee(c,_e(m,d),ce(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const A=vo(k,0);let M=0,L=0;for(;M<y;){M++,E+=A;let F=b.length===L+1?1/0:b[L+1]-b[L]-1;M+F>y&&(E-=A,F=y-M+1),M+=F,E+=T(F),L++}return E}})),y=>{Ie(e,y),requestAnimationFrame(()=>{Ie(t,{top:y}),requestAnimationFrame(()=>{Ie(e,0),Ie(v,!1)})})}),{deviation:e}},ot(Ft,ko,sr,En,zn,$a)),EC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ot(Ua,wC,Un,Ip,Cp,bC,mC,Va,kp,zn,Tp)),Ap=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:A},M])=>(pe(k.rangeChanged,M.scrollSeekRangeChanged),pe(ee(M.windowViewportRect,ce(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:c,trackItemSizes:f,...k,...M,...g,sizes:l,...x}),ot(En,So,Ft,yC,vC,sr,yo,kC,CC,mp,EC));function IC(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 Ds=typeof document<"u"?w.useLayoutEffect:w.useEffect;function jp(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=w.createContext({});function l(x,y){x.propsReady&&Ie(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Ie(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Ie(C,y[b])}x.propsReady&&Ie(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Ie(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=US(x[t.events[b]]),y),{})}const f=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Ns(VS(e),E=>{l(E,C)})),[S]=w.useState(Qf(d,k));Ds(()=>{for(const E of i)E in C&&Ze(S[E],C[E]);return()=>{Object.values(S).map(Pa)}},[C,S,k]),Ds(()=>{l(k,C)}),w.useImperativeHandle(y,Jf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...IC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Ie(y[x],b)},[y,x])},p=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Ze(y,C),[y]);return w.useSyncExternalStore(b,()=>bt(y),()=>bt(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(Qf(bt,y));return Ds(()=>Ze(y,k=>{k!==b&&C(Jf(k))}),[y,b]),b},g=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ds(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Pp=w.createContext(void 0),_p=w.createContext(void 0),Rp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ka(e){return"self"in e}function NC(e){return"body"in e}function Mp(e,t,n,r=Mr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let p,v,g;const x=m.target;if(NC(x)||Ka(x)){const b=Ka(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Do.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ka(p)?(x=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(x=p[s?"scrollWidth":"scrollHeight"],g=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),xp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),p.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const qa="-webkit-sticky",Op="sticky",Ga=Np(()=>{if(typeof document>"u")return Op;const e=document.createElement("div");return e.style.position=qa,e.style.position===qa?qa:Op});function Ya(e){return e}const AC=Ge(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(Ya),o=re("div"),s=re(Mr),i=(a,l=null)=>Mt(ee(n,ce(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")}}),jC=Ge(([e,t])=>({...e,...t}),ot(Ap,AC)),PC=({height:e})=>u.jsx("div",{style:{height:e}}),_C={overflowAnchor:"none",position:Ga(),zIndex:1},Dp={overflowAnchor:"none"},RC={...Dp,display:"inline-block",height:"100%"},Lp=w.memo(function({showTopList:e=!1}){const t=Te("listState"),n=rn("sizeRanges"),r=Te("useWindowScroll"),o=Te("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Te("itemContent"),c=Te("context"),d=Te("groupContent"),f=Te("trackItemSizes"),m=Te("itemSize"),p=Te("log"),v=rn("gap"),g=Te("horizontalDirection"),{callbackRef:x}=GS(n,m,f,e?Mr:a,p,v,o,g,Te("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Xa("deviation",O=>{y!==O&&b(O)});const C=Te("EmptyPlaceholder"),k=Te("ScrollSeekPlaceholder")||PC,S=Te("ListComponent"),T=Te("ItemComponent"),E=Te("GroupComponent"),A=Te("computeItemKey"),M=Te("isSeeking"),L=Te("groupIndices").length>0,F=Te("alignToBottom"),z=Te("initialItemFinalLocationReached"),X=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},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Ot(C,c)}):u.jsx(S,{...Ot(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:X,children:(e?t.topItems:t.items).map(O=>{const Y=O.originalIndex,W=A(Y+t.firstItemIndex,O.data,c);return M?w.createElement(k,{...Ot(k,c),height:O.size,index:O.index,key:W,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?w.createElement(E,{...Ot(E,c),"data-index":Y,"data-item-index":O.index,"data-known-size":O.size,key:W,style:_C},d(O.index,c)):w.createElement(T,{...Ot(T,c),...LC(T,O.data),"data-index":Y,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:W,style:g?RC:Dp},L?l(O.index,O.groupIndex,O.data,c):l(O.index,O.data,c))})})}),MC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},OC={outline:"none",overflowX:"auto",position:"relative"},Ls=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),DC={position:Ga(),top:0,width:"100%",zIndex:1};function Ot(e,t){if(typeof e!="string")return{context:t}}function LC(e,t){return{item:typeof e=="string"?void 0:t}}const $C=w.memo(function(){const e=Te("HeaderComponent"),t=rn("headerHeight"),n=Te("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),FC=w.memo(function(){const e=Te("FooterComponent"),t=rn("footerHeight"),n=Te("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null});function $p({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:v}=Mp(a,c,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?OC:MC,...o},tabIndex:0,...i,...Ot(l,s),children:r})})}function Fp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),m=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Mp(a,c,l,v,m);return Rp(()=>{var b;return x.current=m||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Ot(l,s),children:r})})}const BC=({children:e})=>{const t=w.useContext(Pp),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Te("alignToBottom"),s=Te("horizontalDirection"),i=w.useMemo(()=>Zf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=rr(i,!0,Te("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ls(o),children:e})},zC=({children:e})=>{const t=w.useContext(Pp),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Te("customScrollParent"),s=rp(n,o,Te("skipAnimationFrameInResizeObserver")),i=Te("alignToBottom");return w.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:Ls(i),children:e})},HC=({children:e})=>{const t=Te("TopItemListComponent")||"div",n=Te("headerHeight"),r={...DC,marginTop:`${n}px`},o=Te("context");return u.jsx(t,{style:r,...Ot(t,o),children:e})},UC=w.memo(function(e){const t=Te("useWindowScroll"),n=Te("topItemsIndexes").length>0,r=Te("customScrollParent"),o=Te("context");return u.jsxs(r||t?KC:VC,{...e,context:o,children:[n&&u.jsx(HC,{children:u.jsx(Lp,{showTopList:!0})}),u.jsxs(r||t?zC:BC,{children:[u.jsx($C,{}),u.jsx(Lp,{}),u.jsx(FC,{})]})]})}),{Component:WC,useEmitter:Xa,useEmitterValue:Te,usePublisher:rn}=jp(jC,{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"}},UC),VC=$p({useEmitter:Xa,useEmitterValue:Te,usePublisher:rn}),KC=Fp({useEmitter:Xa,useEmitterValue:Te,usePublisher:rn}),qC=WC;ot(Ap,Ge(()=>{const e=re(c=>u.jsxs("td",{children:["Item $",c]})),t=re(null),n=re(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=re(null),o=re(null),s=re({}),i=re(Ya),a=re(Mr),l=(c,d=null)=>Mt(ee(s,ce(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")}})),Ga();const Bp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},GC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:zp,floor:$s,max:Eo,min:Ja,round:Hp}=Math;function Up(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function YC(e){return{...GC,items:e}}function Fs(e,t){return e&&e.width===t.width&&e.height===t.height}function XC(e,t){return e&&e.column===t.column&&e.row===t.row}const JC=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=re(0),E=re(0),A=re(Bp),M=re({height:0,width:0}),L=re({height:0,width:0}),F=ze(),z=ze(),X=re(0),O=re(null),Y=re({column:0,row:0}),W=ze(),K=ze(),D=re(!1),I=re(0),V=re(!0),Z=re(!1),R=re(!1);Ze(ee(v,_e(I),ye(([_,G])=>!!G)),()=>{Ie(V,!1)}),Ze(ee(St(v,V,L,M,I,Z),ye(([_,G,Q,oe,,ae])=>_&&!G&&Q.height!==0&&oe.height!==0&&!ae)),([,,,,_])=>{Ie(Z,!0),za(1,()=>{Ie(F,_)}),fn(ee(c),()=>{Ie(t,[0,0]),Ie(V,!0)})}),pe(ee(K,ye(_=>_!=null&&_.scrollTop>0),Tn(0)),E),Ze(ee(v,_e(K),ye(([,_])=>_!=null)),([,_])=>{_&&(Ie(M,_.viewport),Ie(L,_.item),Ie(Y,_.gap),_.scrollTop>0&&(Ie(D,!0),fn(ee(c,nr(1)),G=>{Ie(D,!1)}),Ie(l,{top:_.scrollTop})))}),pe(ee(M,ce(({height:_})=>_)),f),pe(ee(St(be(M,Fs),be(L,Fs),be(Y,(_,G)=>_&&_.column===G.column&&_.row===G.row),be(c)),ce(([_,G,Q,oe])=>({gap:Q,item:G,scrollTop:oe,viewport:_}))),W),pe(ee(St(be(T),r,be(Y,XC),be(L,Fs),be(M,Fs),be(O),be(E),be(D),be(V),be(I)),ye(([,,,,,,,_])=>!_),ce(([_,[G,Q],oe,ae,ve,we,Re,,Me,Ye])=>{const{column:Le,row:$e}=oe,{height:ft,width:Qe}=ae,{width:gt}=ve;if(Re===0&&(_===0||gt===0))return Bp;if(Qe===0){const Nt=Ha(Ye,_),pt=Nt+Math.max(Re-1,0);return YC(Up(Nt,pt,we))}const He=Wp(gt,Qe,Le);let Oe,De;Me?G===0&&Q===0&&Re>0?(Oe=0,De=Re-1):(Oe=He*$s((G+$e)/(ft+$e)),De=He*zp((Q+$e)/(ft+$e))-1,De=Ja(_-1,Eo(De,He-1)),Oe=Ja(De,Eo(0,Oe))):(Oe=0,De=-1);const Ce=Up(Oe,De,we),{bottom:Fe,top:at}=Vp(ve,oe,ae,Ce),jt=zp(_/He),lt=jt*ft+(jt-1)*$e-Fe;return{bottom:Fe,itemHeight:ft,items:Ce,itemWidth:Qe,offsetBottom:lt,offsetTop:at,top:at}})),A),pe(ee(O,ye(_=>_!==null),ce(_=>_.length)),T),pe(ee(St(M,L,A,Y),ye(([_,G,{items:Q}])=>Q.length>0&&G.height!==0&&_.height!==0),ce(([_,G,{items:Q},oe])=>{const{bottom:ae,top:ve}=Vp(_,oe,G,Q);return[ve,ae]}),st(wo)),t);const q=re(!1);pe(ee(c,_e(q),ce(([_,G])=>G||_!==0)),q);const P=en(ee(St(A,T),ye(([{items:_}])=>_.length>0),_e(q),ye(([[_,G],Q])=>{const oe=_.items[_.items.length-1].index===G-1;return(Q||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===G)&&oe}),ce(([[,_]])=>_-1),st())),$=en(ee(be(A),ye(({items:_})=>_.length>0&&_[0].index===0),Tn(0),st())),H=en(ee(be(A),_e(D),ye(([{items:_},G])=>_.length>0&&!G),ce(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),st(up),Pn(0)));pe(H,p.scrollSeekRangeChanged),pe(ee(F,_e(M,L,T,Y),ce(([_,G,Q,oe,ae])=>{const ve=gp(_),{align:we,behavior:Re,offset:Me}=ve;let Ye=ve.index;Ye==="LAST"&&(Ye=oe-1),Ye=Eo(0,Ye,Ja(oe-1,Ye));let Le=Za(G,ae,Q,Ye);return we==="end"?Le=Hp(Le-G.height+Q.height):we==="center"&&(Le=Hp(Le-G.height/2+Q.height/2)),Me&&(Le+=Me),{behavior:Re,top:Le}})),l);const j=Mt(ee(A,ce(_=>_.offsetBottom+_.bottom)),0);return pe(ee(k,ce(_=>({height:_.visibleHeight,width:_.visibleWidth}))),M),{customScrollParent:x,data:O,deviation:X,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:K,scrollBy:i,scrollContainerState:a,scrollHeight:z,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:M,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...p,gridState:A,horizontalDirection:R,initialTopMostItemIndex:I,totalListHeight:j,...m,endReached:P,propsReady:g,rangeChanged:H,startReached:$,stateChanged:W,stateRestoreInProgress:D,...S}},ot(Ua,Ft,ko,Ip,Un,Va,zn));function Wp(e,t,n){return Eo(1,$s((e+n)/($s(t)+n)))}function Vp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Za(e,t,n,r[0].index);return{bottom:Za(e,t,n,r[r.length-1].index)+o,top:s}}function Za(e,t,n,r){const o=Wp(e.width,n.width,t.column),s=$s(r/o),i=s*n.height+Eo(0,s-1)*t.row;return i>0?i+t.row:i}const ZC=Ge(()=>{const e=re(f=>`Item ${f}`),t=re({}),n=re(null),r=re("virtuoso-grid-item"),o=re("virtuoso-grid-list"),s=re(Ya),i=re("div"),a=re(Mr),l=(f,m=null)=>Mt(ee(t,ce(p=>p[f]),st()),m),c=re(!1),d=re(!1);return pe(be(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")}}),QC=Ge(([e,t])=>({...e,...t}),ot(JC,ZC)),eT=w.memo(function(){const e=it("gridState"),t=it("listClassName"),n=it("itemClassName"),r=it("itemContent"),o=it("computeItemKey"),s=it("isSeeking"),i=on("scrollHeight"),a=it("ItemComponent"),l=it("ListComponent"),c=it("ScrollSeekPlaceholder"),d=it("context"),f=on("itemDimensions"),m=on("gap"),p=it("log"),v=it("stateRestoreInProgress"),g=on("reportReadyState"),x=rr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();f({height:k,width:S})}m({column:qp("column-gap",getComputedStyle(y).columnGap,p),row:qp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Rp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Ot(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{...Ot(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Ot(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),tT=w.memo(function(){const e=it("HeaderComponent"),t=on("headerHeight"),n=it("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),nT=w.memo(function(){const e=it("FooterComponent"),t=on("footerHeight"),n=it("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),rT=({children:e})=>{const t=w.useContext(_p),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.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:Ls(!1),children:e})},oT=({children:e})=>{const t=w.useContext(_p),n=on("windowViewportRect"),r=on("itemDimensions"),o=it("customScrollParent"),s=rp(n,o,!1);return w.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:Ls(!1),children:e})},sT=w.memo(function({...e}){const t=it("useWindowScroll"),n=it("customScrollParent"),r=n||t?aT:iT,o=n||t?oT:rT,s=it("context");return u.jsx(r,{...e,...Ot(r,s),children:u.jsxs(o,{children:[u.jsx(tT,{}),u.jsx(eT,{}),u.jsx(nT,{})]})})}),{useEmitter:Kp,useEmitterValue:it,usePublisher:on}=jp(QC,{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"}},sT),iT=$p({useEmitter:Kp,useEmitterValue:it,usePublisher:on}),aT=Fp({useEmitter:Kp,useEmitterValue:it,usePublisher:on});function qp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Bs="Dialog",[Gp,zN]=cn(Bs),[lT,hn]=Gp(Bs),Yp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Bs});return u.jsx(lT,{scope:t,triggerRef:a,contentRef:l,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Yp.displayName=Bs;var Xp="DialogTrigger",Jp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Xp,n),s=Pe(t,o.triggerRef);return u.jsx(fe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":tl(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});Jp.displayName=Xp;var Qa="DialogPortal",[cT,Zp]=Gp(Qa,{forceMount:void 0}),Qp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Qa,t);return u.jsx(cT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ut,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:i})}))})};Qp.displayName=Qa;var zs="DialogOverlay",eh=h.forwardRef((e,t)=>{const n=Zp(zs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(zs,e.__scopeDialog);return s.modal?u.jsx(Ut,{present:r||s.open,children:u.jsx(dT,{...o,ref:t})}):null});eh.displayName=zs;var uT=Yt.createSlot("DialogOverlay.RemoveScroll"),dT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(zs,n);return u.jsx(ws,{as:uT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(fe.div,{"data-state":tl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",th=h.forwardRef((e,t)=>{const n=Zp(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ir,e.__scopeDialog);return u.jsx(Ut,{present:r||s.open,children:s.modal?u.jsx(fT,{...o,ref:t}):u.jsx(pT,{...o,ref:t})})});th.displayName=ir;var fT=h.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=h.useRef(null),o=Pe(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return ga(s)},[]),u.jsx(nh,{...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())})}),pT=h.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(nh,{...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()}})}),nh=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ir,n),l=h.useRef(null),c=Pe(t,l);return qi(),u.jsxs(u.Fragment,{children:[u.jsx(es,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Cr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":tl(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(hT,{titleId:a.titleId}),u.jsx(gT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),el="DialogTitle",rh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(el,n);return u.jsx(fe.h2,{id:o.titleId,...r,ref:t})});rh.displayName=el;var oh="DialogDescription",sh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(oh,n);return u.jsx(fe.p,{id:o.descriptionId,...r,ref:t})});sh.displayName=oh;var ih="DialogClose",ah=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ih,n);return u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});ah.displayName=ih;function tl(e){return e?"open":"closed"}var lh="DialogTitleWarning",[HN,ch]=jw(lh,{contentName:ir,titleName:el,docsSlug:"dialog"}),hT=({titleId:e})=>{const t=ch(lh),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},g0=0,_r=[];function x0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(g0++)[0],s=h.useState(Vd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=$y([e.lockRef.current],(e.shards||[]).map(Zd),!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=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=vs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var A=Gd(E,T);if(!A)return!0;if(A?S=E:(S=E==="v"?"h":"v",A=Gd(E,T)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var _=r.current||S;return p0(_,x,g,_==="h"?C:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!_r.length||_r[_r.length-1]!==s)){var y="deltaY"in x?Jd(x):vs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&h0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Zd).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:v0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=h.useCallback(function(g){n.current=vs(g),r.current=void 0},[]),f=h.useCallback(function(g){c(g.type,Jd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,vs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return _r.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Pr),document.addEventListener("touchmove",l,Pr),document.addEventListener("touchstart",d,Pr),function(){_r=_r.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:m0(o)}):null,p?h.createElement(i0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function v0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const w0=qy(Wd,x0);var ws=h.forwardRef(function(e,t){return h.createElement(gs,Cn({},e,{ref:t,sideCar:w0}))});ws.classNames=gs.classNames;var ya=["Enter"," "],b0=["ArrowDown","PageUp","Home"],Qd=["ArrowUp","PageDown","End"],y0=[...b0,...Qd],S0={ltr:[...ya,"ArrowRight"],rtl:[...ya,"ArrowLeft"]},C0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},uo="Menu",[fo,T0,k0]=Zo(uo),[er,ef]=ln(uo,[k0,Nr,Od]),bs=Nr(),tf=Od(),[E0,tr]=er(uo),[I0,po]=er(uo),nf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=bs(t),[l,c]=h.useState(null),d=h.useRef(!1),f=xt(s),m=Qo(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ca,{...a,children:u.jsx(E0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(I0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};nf.displayName=uo;var N0="MenuAnchor",Sa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ua,{...o,...r,ref:t})});Sa.displayName=N0;var Ca="MenuPortal",[A0,rf]=er(Ca,{forceMount:void 0}),of=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Ca,t);return u.jsx(A0,{scope:t,forceMount:n,children:u.jsx(Ut,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:r})})})};of.displayName=Ca;var tn="MenuContent",[j0,Ta]=er(tn),sf=h.forwardRef((e,t)=>{const n=rf(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(tn,e.__scopeMenu),i=po(tn,e.__scopeMenu);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(fo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(P0,{...o,ref:t}):u.jsx(_0,{...o,ref:t})})})})}),P0=h.forwardRef((e,t)=>{const n=tr(tn,e.__scopeMenu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return ga(s)},[]),u.jsx(ka,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),_0=h.forwardRef((e,t)=>{const n=tr(tn,e.__scopeMenu);return u.jsx(ka,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),R0=Gt.createSlot("MenuContent.ScrollLock"),ka=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:v,...g}=e,x=tr(tn,n),y=po(tn,n),b=bs(n),C=tf(n),k=T0(n),[S,T]=h.useState(null),E=h.useRef(null),A=Re(t,E,x.onContentChange),_=h.useRef(0),L=h.useRef(""),F=h.useRef(0),U=h.useRef(null),X=h.useRef("right"),O=h.useRef(0),Y=v?ws:h.Fragment,V=v?{as:R0,allowPinchZoom:!0}:void 0,K=I=>{var j,R;const q=L.current+I,J=k().filter(G=>!G.disabled),M=document.activeElement,B=(j=J.find(G=>G.ref.current===M))==null?void 0:j.textValue,P=J.map(G=>G.textValue),$=V0(P,q,B),z=(R=J.find(G=>G.textValue===$))==null?void 0:R.ref.current;(function G(Q){L.current=Q,window.clearTimeout(_.current),Q!==""&&(_.current=window.setTimeout(()=>G(""),1e3))})(q),z&&setTimeout(()=>z.focus())};h.useEffect(()=>()=>window.clearTimeout(_.current),[]),qi();const D=h.useCallback(I=>{var J,M;return X.current===((J=U.current)==null?void 0:J.side)&&q0(I,(M=U.current)==null?void 0:M.area)},[]);return u.jsx(j0,{scope:n,searchRef:L,onItemEnter:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),onItemLeave:h.useCallback(I=>{var q;D(I)||((q=E.current)==null||q.focus(),T(null))},[D]),onTriggerLeave:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),pointerGraceTimerRef:F,onPointerGraceIntentChange:h.useCallback(I=>{U.current=I},[]),children:u.jsx(Y,{...V,children:u.jsx(es,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var q;I.preventDefault(),(q=E.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(Ry,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ae(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(da,{role:"menu","aria-orientation":"vertical","data-state":Cf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,M=I.ctrlKey||I.altKey||I.metaKey,B=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!M&&B&&K(I.key));const P=E.current;if(I.target!==P||!y0.includes(I.key))return;I.preventDefault();const z=k().filter(j=>!j.disabled).map(j=>j.ref.current);Qd.includes(I.key)&&z.reverse(),U0(z)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),L.current="")}),onPointerMove:ae(e.onPointerMove,mo(I=>{const q=I.target,J=O.current!==I.clientX;if(I.currentTarget.contains(q)&&J){const M=I.clientX>O.current?"right":"left";X.current=M,O.current=I.clientX}}))})})})})})})});sf.displayName=tn;var M0="MenuGroup",Ea=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"group",...r,ref:t})});Ea.displayName=M0;var O0="MenuLabel",af=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});af.displayName=O0;var ys="MenuItem",lf="menu.itemSelect",Ss=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=po(ys,e.__scopeMenu),a=Ta(ys,e.__scopeMenu),l=Re(t,s),c=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(lf,{bubbles:!0,cancelable:!0});f.addEventListener(lf,p=>r==null?void 0:r(p),{once:!0}),Wi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(cf,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),c.current=!0},onPointerUp:ae(e.onPointerUp,f=>{var m;c.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||ya.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ss.displayName=ys;var cf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ta(ys,n),a=tf(n),l=h.useRef(null),c=Re(t,l),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),u.jsx(fo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(My,{asChild:!0,...a,focusable:!r,children:u.jsx(fe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(e.onPointerMove,mo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,mo(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>f(!0)),onBlur:ae(e.onBlur,()=>f(!1))})})})}),D0="MenuCheckboxItem",uf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(mf,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ss,{role:"menuitemcheckbox","aria-checked":Cs(n)?"mixed":n,...o,ref:t,"data-state":Na(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(Cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});uf.displayName=D0;var df="MenuRadioGroup",[L0,$0]=er(df,{value:void 0,onValueChange:()=>{}}),ff=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=xt(r);return u.jsx(L0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ea,{...o,ref:t})})});ff.displayName=df;var pf="MenuRadioItem",hf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=$0(pf,e.__scopeMenu),s=n===o.value;return u.jsx(mf,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ss,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Na(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});hf.displayName=pf;var Ia="MenuItemIndicator",[mf,F0]=er(Ia,{checked:!1}),gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=F0(Ia,n);return u.jsx(Ut,{present:r||Cs(s.checked)||s.checked===!0,children:u.jsx(fe.span,{...o,ref:t,"data-state":Na(s.checked)})})});gf.displayName=Ia;var B0="MenuSeparator",xf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});xf.displayName=B0;var z0="MenuArrow",vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(fa,{...o,...r,ref:t})});vf.displayName=z0;var H0="MenuSub",[$N,wf]=er(H0),ho="MenuSubTrigger",bf=h.forwardRef((e,t)=>{const n=tr(ho,e.__scopeMenu),r=po(ho,e.__scopeMenu),o=wf(ho,e.__scopeMenu),s=Ta(ho,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Sa,{asChild:!0,...c,children:u.jsx(cf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Cf(n.open),...e,ref:Mn(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:ae(e.onPointerMove,mo(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,mo(f=>{var p,v;d();const m=(p=n.content)==null?void 0:p.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,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:ae(e.onKeyDown,f=>{var p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||S0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});bf.displayName=ho;var yf="MenuSubContent",Sf=h.forwardRef((e,t)=>{const n=rf(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(tn,e.__scopeMenu),i=po(tn,e.__scopeMenu),a=wf(yf,e.__scopeMenu),l=h.useRef(null),c=Re(t,l);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(fo.Slot,{scope:e.__scopeMenu,children:u.jsx(ka,{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:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),m=C0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Sf.displayName=yf;function Cf(e){return e?"open":"closed"}function Cs(e){return e==="indeterminate"}function Na(e){return Cs(e)?"indeterminate":e?"checked":"unchecked"}function U0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function W0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function V0(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=W0(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 K0(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 q0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return K0(n,t)}function mo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var G0=nf,Y0=Sa,X0=of,J0=sf,Z0=Ea,Q0=af,eS=Ss,tS=uf,nS=ff,rS=hf,oS=gf,sS=xf,iS=vf,aS=bf,lS=Sf,Ts="DropdownMenu",[cS,FN]=ln(Ts,[ef]),$t=ef(),[uS,Tf]=cS(Ts),kf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=h.useRef(null),[d,f]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Ts});return u.jsx(uS,{scope:t,triggerId:_t(),triggerRef:c,contentId:_t(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(G0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};kf.displayName=Ts;var Ef="DropdownMenuTrigger",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Tf(Ef,n),i=$t(n);return u.jsx(Y0,{asChild:!0,...i,children:u.jsx(fe.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:Mn(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});If.displayName=Ef;var dS="DropdownMenuPortal",Nf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(X0,{...r,...n})};Nf.displayName=dS;var Af="DropdownMenuContent",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tf(Af,n),s=$t(n),i=h.useRef(!1);return u.jsx(J0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(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)"}})});jf.displayName=Af;var fS="DropdownMenuGroup",pS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});pS.displayName=fS;var hS="DropdownMenuLabel",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=hS;var mS="DropdownMenuItem",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(eS,{...o,...r,ref:t})});_f.displayName=mS;var gS="DropdownMenuCheckboxItem",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(tS,{...o,...r,ref:t})});Rf.displayName=gS;var xS="DropdownMenuRadioGroup",vS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(nS,{...o,...r,ref:t})});vS.displayName=xS;var wS="DropdownMenuRadioItem",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(rS,{...o,...r,ref:t})});Mf.displayName=wS;var bS="DropdownMenuItemIndicator",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(oS,{...o,...r,ref:t})});Of.displayName=bS;var yS="DropdownMenuSeparator",Df=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(sS,{...o,...r,ref:t})});Df.displayName=yS;var SS="DropdownMenuArrow",CS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(iS,{...o,...r,ref:t})});CS.displayName=SS;var TS="DropdownMenuSubTrigger",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(aS,{...o,...r,ref:t})});Lf.displayName=TS;var kS="DropdownMenuSubContent",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(lS,{...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)"}})});$f.displayName=kS;var ES=kf,IS=If,NS=Nf,Ff=jf,Bf=Pf,zf=_f,Hf=Rf,Uf=Mf,Wf=Of,Vf=Df,Kf=Lf,qf=$f;const ks=ES,Es=IS,AS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Kf,{ref:o,className:te("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"})]}));AS.displayName=Kf.displayName;const jS=h.forwardRef(({className:e,...t},n)=>u.jsx(qf,{ref:n,className:te("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}));jS.displayName=qf.displayName;const go=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(NS,{children:u.jsx(Ff,{ref:r,sideOffset:t,className:te("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})}));go.displayName=Ff.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(zf,{ref:r,className:te("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}));Fn.displayName=zf.displayName;const PS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Hf,{ref:o,className:te("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(Wf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));PS.displayName=Hf.displayName;const _S=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Uf,{ref:r,className:te("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(Wf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));_S.displayName=Uf.displayName;const RS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Bf,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));RS.displayName=Bf.displayName;const MS=h.forwardRef(({className:e,...t},n)=>u.jsx(Vf,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));MS.displayName=Vf.displayName;const Aa=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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}));Aa.displayName="Textarea";const OS=1e4;function Gf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=OS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),A=w.useRef(0),_=w.useRef(null),L=w.useRef("");w.useEffect(()=>{y||(C(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,U]=w.useState(null),X=w.useCallback(P=>P.length>s?`Message too long (${P.length}/${s} characters)`:null,[s]),O=w.useMemo(()=>g??X,[g,X]),Y=w.useCallback(P=>{const $=O(P);return U($),x==null||x($),L.current=P,$},[O,x]),V=w.useCallback(()=>{const P=E.current;P&&(P.style.height="auto",P.style.height=`${P.scrollHeight}px`)},[]);w.useEffect(()=>{V()},[V,k]),w.useEffect(()=>{if(!F)return;const P=(k??"").trim();L.current!==P&&Y(P)},[k,F,Y]);const K=w.useCallback((P,{fromUser:$})=>{y||C(P),$&&(a==null||a(P))},[y,a]),D=w.useCallback(async P=>{P&&P.preventDefault();const $=(k??"").trim();if(!$&&!p||Y($))return;const z=++A.current;_.current={id:z,shouldClear:!0},T(()=>{var j,R,G;try{const Q=l($);Q&&typeof Q.then=="function"?Q.then(()=>{var se,ie;((se=_.current)==null?void 0:se.id)===z&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((ie=_.current)==null?void 0:ie.id)===z&&(_.current=null)}).catch(()=>{var se;((se=_.current)==null?void 0:se.id)===z&&(_.current=null)}):(((j=_.current)==null?void 0:j.id)===z&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((R=_.current)==null?void 0:R.id)===z&&(_.current=null))}catch{((G=_.current)==null?void 0:G.id)===z&&(_.current=null)}})},[k,l,p,y,a,Y]),I=w.useCallback(P=>{const $=P.target.value;K($,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&Y($.trim())},[K,Y,F]),q=w.useCallback(P=>{P.key==="Enter"&&!P.shiftKey?(P.preventDefault(),D()):P.key==="Escape"&&t&&(P.preventDefault(),c==null||c())},[D,t,c]),B=`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:P=>void D(P),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Aa,{ref:E,value:k,onChange:I,onKeyDown:q,placeholder:t?"Edit your message...":n,className:B,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()&&!p||S,children:u.jsx(le.Send,{size:16})})})]})})}const DS=w.memo(Gf);function Yf({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[A,_]=w.useState(0),[L,F]=w.useState(!1),[U,X]=w.useState(null),[O,Y]=w.useState(null),V=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(P=>P+1),_(P=>P+1)},[]),K=w.useCallback(P=>{C($=>[...$,...P])},[]),D=w.useCallback(P=>{const $=Array.from(P.target.files||[]);K($),P.target.value=""},[K]),I=w.useCallback(P=>{C($=>{const z=$.filter((j,R)=>R!==P);return z.length===0&&V(),z})},[V]),q=w.useCallback(async P=>{const $=(P.target.files||[])[0];if($&&(X(null),Y(null),!!v)){F(!0);try{await v($),X(`Uploaded ${$.name} - processing through chat stream`)}catch(z){const j=z instanceof Error?z.message:"Failed to upload Excel file";Y(j),g==null||g(j)}finally{F(!1),P.target.value="",V()}}},[v,g,V]),J=w.useMemo(()=>x||b.length>0,[x,b]),M=w.useCallback(async P=>{const z=await n(P,b);return b.length>0&&(C([]),V()),z},[n,V,b]),B=`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||p)&&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:D,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((P,$)=>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:P.name}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>I($),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 ${P.name}`,children:u.jsx(le.X,{size:12})})]},$))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:q,className:"hidden"},A),L&&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..."]}),U&&!L&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:U}),O&&!L&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:O})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||p)&&u.jsxs(ks,{children:[u.jsx(Es,{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(go,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var P;return(P=k.current)==null?void 0:P.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Fn,{onClick:()=>{var P;L||(P=S.current)==null||P.click()},className:`cursor-pointer ${L?"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(DS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:M,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:B,sendButtonClassName:f.sendButton})})]})]})}const LS=w.memo(Yf),Is=0,Bn=1,Rr=2,Xf=4;function Jf(e){return()=>e}function $S(e){e()}function Zf(e,t){return n=>e(t(n))}function Qf(e,t){return()=>e(t)}function FS(e,t){return n=>e(t,n)}function ja(e){return e!==void 0}function BS(...e){return()=>{e.map($S)}}function Mr(){}function Ns(e,t){return t(e),e}function zS(e,t){return t(e)}function it(...e){return e}function Qe(e,t){return e(Bn,t)}function Ee(e,t){e(Is,t)}function Pa(e){e(Rr)}function vt(e){return e(Xf)}function pe(e,t){return Qe(e,FS(t,Is))}function dn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function ep(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function tp(e,t){return e===t}function at(e=tp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Zf(t,e)}function Tn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=HS(...t);return(r,o)=>{switch(r){case Rr:Pa(e);return;case Bn:return Qe(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function Pn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Me(...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);Qe(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 HS(...e){return t=>e.reduceRight(zS,t)}function US(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),Mr);case Rr:r(),n=null;return}}}function oe(e){let t=e;const n=Be();return(r,o)=>{switch(r){case Is:t=o;break;case Bn:{o(t);break}case Xf:return t}return n(r,o)}}function Rt(e,t){return Ns(oe(t),n=>pe(e,n))}function Be(){const e=[];return(t,n)=>{switch(t){case Is:e.slice().forEach(r=>{r(n)});return;case Rr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Qt(e){return Ns(Be(),t=>pe(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:WS(),singleton:n}}const WS=()=>Symbol();function VS(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 yt(...e){const t=Be(),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);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Ee(t,n)})}),function(s,i){switch(s){case Rr:{Pa(t);return}case Bn:return r===o&&i(n),Qe(t,i)}}}function be(e,t=tp){return ee(e,at(t))}function _a(...e){return function(t,n){switch(t){case Rr:return;case Bn:return BS(...e.map(r=>Qe(r,n)))}}}var Wt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Wt||{});const KS={0:"debug",3:"error",1:"log",2:"warn"},qS=()=>typeof globalThis>"u"?window:globalThis,zn=qe(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=qS().VIRTUOSO_LOG_LEVEL)!=null?o:vt(e);r>=s&&console[KS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return Ra(e,t,n).callbackRef}function Ra(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.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 GS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const f=YS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const p=m.lastElementChild.dataset.viewportType==="window";let v;p&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?np("column-gap",getComputedStyle(d).columnGap,o):np("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ra(c,n,l)}function YS(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},Wt.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 np(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}function rp(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,m;if(t){const p=t.getBoundingClientRect(),v=c.top-p.top;m=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ra(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=qe(()=>{const e=Be(),t=Be(),n=oe(0),r=Be(),o=oe(0),s=Be(),i=Be(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),f=Be(),m=Be(),p=oe(!1),v=oe(!1),g=oe(!1);return pe(ee(e,ce(({scrollTop:x})=>x)),t),pe(ee(e,ce(({scrollHeight:x})=>x)),i),pe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),xo={lvl:0};function op(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===xo}function vo(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?vo(e.l,t):vo(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 en(e,t,n){return tt(e)?ap(t,n,1):t===e.k?Et(e,{k:t,v:n}):t<e.k?lp(Et(e,{l:en(e.l,t,n)})):lp(Et(e,{r:en(e.r,t,n)}))}function Or(){return xo}function As(e,t,n){if(tt(e))return[];const r=fn(e,t)[0];return XS(Oa(e,r,n))}function Ma(e,t){if(tt(e))return xo;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=ip(r);return js(Et(e,{k:s,l:sp(r),v:i}))}}else return t<n?js(Et(e,{l:Ma(r,t)})):js(Et(e,{r:Ma(o,t)}))}function or(e){return tt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function Oa(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(Oa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Oa(s,t,n))),a}function js(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(Da(t))return cp(Et(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return Et(t.r,{l:Et(t,{r:t.r.l}),lvl:n,r:Et(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Da(e))return La(Et(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=Da(o)?r.lvl-1:r.lvl;return Et(o,{l:Et(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:La(Et(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Et(e,t){return ap(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 sp(e){return tt(e.r)?e.l:js(Et(e,{r:sp(e.r)}))}function Da(e){return tt(e)||e.lvl>e.r.lvl}function ip(e){return tt(e.r)?[e.k,e.v]:ip(e.r)}function ap(e,t,n,r=xo,o=xo){return{k:e,l:r,lvl:n,r:o,v:t}}function lp(e){return La(cp(e))}function cp(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?Et(t,{r:Et(e,{l:t.r})}):e}function La(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?Et(n,{l:Et(e,{r:n.l}),lvl:t+1}):e}function XS(e){return op(e,({k:t,v:n})=>({index:t,value:n}))}function up(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function wo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const $a=qe(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function dp(e,t,n){return e[Ps(e,t,n)]}function Ps(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 JS(e,t,n,r){const o=Ps(e,t,r),s=Ps(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function _s(e){return!tt(e.groupOffsetTree)}function Fa({index:e},t){return t===e?0:t<e?-1:1}function ZS(){return{groupIndices:[],groupOffsetTree:Or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Or()}}function QS(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=en(e,0,s);continue}const a=As(e,i-1,o+1);if(a.some(iC(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Ma(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=en(e,o+1,m));c&&(e=en(e,i,s))}return[e,n]}function eC(e){return typeof e.groupIndex<"u"}function tC({offset:e},t){return t===e?0:t<e?-1:1}function bo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=dp(t,e,Fa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function fp(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function pp(e,t,n){if(eC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=fp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function nC(e,t,n,r=0){return r>0&&(t=Math.max(t,dp(e,r,Fa).offset)),op(JS(e,t,n,tC),sC)}function rC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Wt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&tt(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>en(en(v,g,m),g+1,p),i)}else[i,a]=QS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=Ba(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>en(m,p,bo(p,f,o)),Or()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function oC(e){return or(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 hp(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 Ba(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ps(o,t-1,Fa),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 As(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 sC(e){return{index:e.index,value:e}}function iC(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 aC={offsetHeight:"height",offsetWidth:"width"},En=qe(([{log:e},{recalcInProgress:t}])=>{const n=Be(),r=Be(),o=Rt(r,0),s=Be(),i=Be(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),f=oe((S,T)=>Hn(S,aC[T])),m=oe(void 0),p=oe(0),v=ZS(),g=Rt(ee(n,Me(l,e,p),kn(rC,v),at()),v),x=Rt(ee(l,at(),kn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ce(({prev:S})=>S)),[]);pe(ee(l,ye(S=>S.length>0),Me(g,p),ce(([S,T,E])=>{const A=S.reduce((_,L,F)=>en(_,L,bo(L,T.offsetTree,E)||F),Or());return{...T,groupIndices:S,groupOffsetTree:A}})),g),pe(ee(r,Me(g),ye(([S,{lastIndex:T}])=>S<T),ce(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),pe(c,d);const y=Rt(ee(c,ce(S=>S===void 0)),!0);pe(ee(d,ye(S=>S!==void 0&&tt(vt(g).sizeTree)),ce(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Qt(ee(n,Me(g),kn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ce(S=>S.changed)));Qe(ee(a,kn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ce(S=>S.diff)),S=>{const{groupIndices:T}=vt(g);if(S>0)Ee(t,!0),Ee(s,S+hp(S,T));else if(S<0){const E=vt(x);E.length>0&&(S-=hp(-S,E)),Ee(i,S)}}),Qe(ee(a,Me(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Wt.ERROR)});const C=Qt(s);pe(ee(s,Me(g),ce(([S,T])=>{const E=T.groupIndices.length>0,A=[],_=T.lastSize;if(E){const L=vo(T.sizeTree,0);let F=0,U=0;for(;F<S;){const O=T.groupIndices[U],Y=T.groupIndices.length===U+1?1/0:T.groupIndices[U+1]-O-1;A.push({endIndex:O,size:L,startIndex:O}),A.push({endIndex:O+1+Y-1,size:_,startIndex:O+1}),U++,F+=Y+1}const X=or(T.sizeTree);return F!==S&&X.shift(),X.reduce((O,{k:Y,v:V})=>{let K=O.ranges;return O.prevSize!==0&&(K=[...O.ranges,{endIndex:Y+S-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:Y+S,prevSize:V,ranges:K}},{prevIndex:S,prevSize:0,ranges:A}).ranges}return or(T.sizeTree).reduce((L,{k:F,v:U})=>({prevIndex:F+S,prevSize:U,ranges:[...L.ranges,{endIndex:F+S-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Qt(ee(i,Me(g,p),ce(([S,{offsetTree:T},E])=>{const A=-S;return bo(A,T,E)})));return pe(ee(i,Me(g,p),ce(([S,T,E])=>{if(T.groupIndices.length>0){if(tt(T.sizeTree))return T;let A=Or();const _=vt(x);let L=0,F=0,U=0;for(;L<-S;){U=_[F];const X=_[F+1]-U-1;F++,L+=X+1}if(A=or(T.sizeTree).reduce((X,{k:O,v:Y})=>en(X,Math.max(0,O+S),Y),A),L!==-S){const X=vo(T.sizeTree,U);A=en(A,0,X);const O=fn(T.sizeTree,-S+1)[1];A=en(A,1,O)}return{...T,sizeTree:A,...Ba(T.offsetTree,0,A,E)}}else{const A=or(T.sizeTree).reduce((_,{k:L,v:F})=>en(_,Math.max(0,L+S),F),Or());return{...T,sizeTree:A,...Ba(T.offsetTree,0,A,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(zn,$a),{singleton:!0});function lC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const mp=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Be(),i=Be(),a=Qt(ee(s,ce(lC)));return pe(ee(a,ce(l=>l.totalCount)),n),pe(ee(a,ce(l=>l.groupIndices)),e),pe(ee(yt(o,t,r),ye(([l,c])=>_s(c)),ce(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(En,Ft)),Un=qe(([{log:e}])=>{const t=oe(!1),n=Qt(ee(t,ye(r=>r),at()));return Qe(t,r=>{r&&vt(e)("props updated",{},Wt.DEBUG)}),{didMount:n,propsReady:t}},it(zn),{singleton:!0}),cC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function gp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!cC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const yo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=Be(),v=Be(),g=oe(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Ee(l,!1)}return pe(ee(p,Me(n,f,r,g,a,i,m),Me(e,s,o),ce(([[k,S,T,E,A,_,L,F],U,X,O])=>{const Y=gp(k),{align:V,behavior:K,offset:D}=Y,I=E-1,q=pp(Y,S,I);let J=bo(q,S.offsetTree,U)+_;V==="end"?(J+=X+fn(S.sizeTree,q)[1]-T+O,q===I&&(J+=L)):V==="center"?J+=(X+fn(S.sizeTree,q)[1]-T+O)/2:J-=A,D&&(J+=D);const M=B=>{C(),B?(F("retrying to scroll to",{location:k},Wt.DEBUG),Ee(p,k)):(Ee(v,!0),F("list did not change, scroll successful",{},Wt.DEBUG))};if(C(),K==="smooth"){let B=!1;b=Qe(t,P=>{B=B||P}),x=dn(d,()=>{M(B)})}else x=dn(ee(t,uC(150)),M);return y=setTimeout(()=>{C()},1200),Ee(l,!0),F("scrolling from index to",{behavior:K,index:q,top:J},Wt.DEBUG),{behavior:K,top:J}})),c),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},it(En,Ft,zn),{singleton:!0});function uC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function za(e,t){e==0?t():requestAnimationFrame(()=>{za(e-1,t)})}function Ha(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const So=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return pe(ee(i,Me(l),ye(([d,f])=>!!f),Tn(!1)),a),pe(ee(i,Me(l),ye(([d,f])=>!!f),Tn(!1)),c),Qe(ee(yt(t,i),Me(a,n,e,c),ye(([[,d],f,{sizeTree:m},p,v])=>d&&(!tt(m)||ja(p))&&!f&&!v),Me(l)),([,d])=>{dn(o,()=>{Ee(c,!0)}),za(4,()=>{dn(r,()=>{Ee(a,!0)}),Ee(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(En,Ft,yo,Un),{singleton:!0});function xp(e,t){return Math.abs(e-t)<1.01}const Co="up",To="down",dC="none",fC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},pC=0,ko=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=Be(),c=Be(),d=oe(4),f=oe(pC),m=Rt(ee(_a(ee(be(o),nr(1),Tn(!0)),ee(be(o),nr(1),Tn(!1),ep(100))),at()),!1),p=Rt(ee(_a(ee(n,Tn(!0)),ee(n,Tn(!1),ep(200))),at()),!1);pe(ee(yt(be(o),be(f)),ce(([b,C])=>b<=C),at()),a),pe(ee(a,Pn(50)),c);const v=Qt(ee(yt(r,be(s),be(t),be(e),be(d)),kn((b,[{scrollHeight:C,scrollTop:k},S,T,E,A])=>{const _=k+S-C>-A,L={scrollHeight:C,scrollTop:k,viewportHeight:S};if(_){let U,X;return k>b.state.scrollTop?(U="SCROLLED_DOWN",X=b.state.scrollTop-k):(U="SIZE_DECREASED",X=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:U,scrollTopDelta:X,state:L}}let F;return L.scrollHeight>b.state.scrollHeight?F="SIZE_INCREASED":S<b.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:L}},fC),at((b,C)=>b&&b.atBottom===C.atBottom))),g=Rt(ee(r,kn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(xp(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(b=>b.changed),ce(b=>b.jump)),0);pe(ee(v,ce(b=>b.atBottom)),i),pe(ee(i,Pn(50)),l);const x=oe(To);pe(ee(r,ce(({scrollTop:b})=>b),at(),kn((b,C)=>vt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?Co:To,prevScrollTop:C},{direction:To,prevScrollTop:0}),ce(b=>b.direction)),x),pe(ee(r,Pn(50),Tn(dC)),x);const y=oe(0);return pe(ee(m,ye(b=>!b),Tn(0)),y),pe(ee(o,Pn(100),Me(m),ye(([b,C])=>!!C),kn(([b,C],[k])=>[C,k],[0,0]),ce(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},it(Ft)),Rs="top",Ms="bottom",vp="none";function wp(e,t,n){return typeof e=="number"?n===Co&&t===Rs||n===To&&t===Ms?e:0:n===Co?t===Rs?e.main:e.reverse:t===Ms?e.main:e.reverse}function bp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ua=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Be(),i=oe(0),a=oe(0),l=oe(0),c=Rt(ee(yt(be(r),be(o),be(n),be(s,wo),be(l),be(i),be(t),be(e),be(a)),ce(([d,f,m,[p,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=vp;const A=bp(C,Rs),_=bp(C,Ms);return p-=b,p+=m+y,v+=m+y,v-=b,p>d+S-A&&(E=Co),v<d-T+f+_&&(E=To),E!==vp?[Math.max(k-m-wp(g,Rs,E)-A,0),k-T-y+f+wp(g,Ms,E)+_]:null}),ye(d=>d!=null),at(wo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Ft),{singleton:!0});function hC(e,t,n){if(_s(t)){const r=fp(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 Wa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Os(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const f=n-i,m=a+f*l+(f-1)*r,p=c,v=m-d;return{bottom:d,firstItemIndex:s,items:Sp(e,o,s),offsetBottom:v,offsetTop:c,top:p,topItems:Sp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function yp(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=Ha(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Os(c,[],a,o,n,r)}function Sp(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=As(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 sr=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=Be();pe(s.topItemsIndexes,g);const b=Rt(ee(yt(p,v,be(l,wo),be(o),be(r),be(c),d,be(g),be(t),be(n),e),ye(([T,E,,A,,,,,,,_])=>{const L=_&&_.length!==A;return T&&!E&&!L}),ce(([,,[T,E],A,_,L,F,U,X,O,Y])=>{const V=_,{offsetTree:K,sizeTree:D}=V,I=vt(x);if(A===0)return{...Wa,totalCount:A};if(T===0&&E===0)return I===0?{...Wa,totalCount:A}:yp(I,L,_,X,O,Y||[]);if(tt(D))return I>0?null:Os(hC(Ha(L,A),V,Y),[],A,O,V,X);const q=[];if(U.length>0){const $=U[0],z=U[U.length-1];let j=0;for(const R of As(D,$,z)){const G=R.value,Q=Math.max(R.start,$),se=Math.min(R.end,z);for(let ie=Q;ie<=se;ie++)q.push({data:Y==null?void 0:Y[ie],index:ie,offset:j,size:G}),j+=G}}if(!F)return Os([],q,A,O,V,X);const J=U.length>0?U[U.length-1]+1:0,M=nC(K,T,E,J);if(M.length===0)return null;const B=A-1,P=Ns([],$=>{for(const z of M){const j=z.value;let R=j.offset,G=z.start;const Q=j.size;if(j.offset<T){G+=Math.floor((T-j.offset+O)/(Q+O));const ie=G-z.start;R+=ie*Q+ie*O}G<J&&(R+=(J-G)*Q,G=J);const se=Math.min(z.end,B);for(let ie=G;ie<=se&&!(R>=E);ie++)$.push({data:Y==null?void 0:Y[ie],index:ie,offset:R,size:Q}),R+=Q+O}});return Os(P,q,A,O,V,X)}),ye(T=>T!==null),at()),Wa);pe(ee(e,ye(ja),ce(T=>T==null?void 0:T.length)),o),pe(ee(b,ce(T=>T.topListHeight)),f),pe(f,a),pe(ee(b,ce(T=>[T.top,T.bottom])),i),pe(ee(b,ce(T=>T.items)),y);const C=Qt(ee(b,ye(({items:T})=>T.length>0),Me(o,e),ye(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ce(([,T,E])=>[T-1,E]),at(wo),ce(([T])=>T))),k=Qt(ee(b,Pn(200),ye(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ce(({items:T})=>T[0].index),at())),S=Qt(ee(b,ye(({items:T})=>T.length>0),ce(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),at(up)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},it(En,mp,Ua,So,yo,ko,Un,$a),{singleton:!0}),Cp=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Be(),i=Rt(ee(yt(n,e,r,t,o),ce(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return pe(be(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Ft,sr),{singleton:!0}),mC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Rt(ee(yt(n,e,t),ye(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),Pn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Ft,Cp),{singleton:!0}),Tp=qe(()=>({context:oe(null)})),gC=({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,kp=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Be();return pe(ee(d,Me(t,l,n,s,o,r,a),Me(e),ce(([[f,m,p,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=gC,done:E,...A}=f,_=pp(f,m,v-1),L=bo(_,m.offsetTree,C)+g+x,F=L+fn(m.sizeTree,_)[1],U=b+x,X=b+p-y,O=T({itemBottom:F,itemTop:L,locationParams:{align:k,behavior:S,...A},viewportBottom:X,viewportTop:U});return O?E&&dn(ee(i,ye(Y=>!Y),nr(vt(i)?1:2)),E):E&&E(),O}),ye(f=>f!==null)),c),{scrollIntoView:d}},it(En,Ft,yo,sr,zn),{singleton:!0});function Ep(e){return e?e==="smooth"?"smooth":"auto":!1}const xC=(e,t)=>typeof e=="function"?Ep(e(t)):t&&Ep(e),vC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const v=oe(!1),g=Be();let x=null;function y(S){Ee(i,{align:"end",behavior:S,index:"LAST"})}Qe(ee(yt(ee(be(t),nr(1)),l),Me(be(v),s,a,f),ce(([[S,T],E,A,_,L])=>{let F=T&&_,U="auto";return F&&(U=xC(E,A||L),F=F&&!!U),{followOutputBehavior:U,shouldFollow:F,totalCount:S}}),ye(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),vt(n)?requestAnimationFrame(()=>{vt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S)}):x=dn(e,()=>{vt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S),x=null})});function b(S){const T=dn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(vt(d)("scrolling to bottom due to increased size",{},Wt.DEBUG),y("auto"))});setTimeout(T,100)}Qe(ee(yt(be(v),t,c),ye(([S,,T])=>S&&T),kn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),ye(({refreshed:S})=>S),Me(v,t)),([,S])=>{vt(a)&&b(S!==!1)}),Qe(g,()=>{b(vt(v)!==!1)}),Qe(yt(be(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=oe(null),k=Be();return pe(_a(ee(be(r),ce(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),ee(be(t))),k),Qe(ee(yt(ee(k,nr(1)),l),Me(be(C),a,f,m),ce(([[S,T],E,A,_,L])=>T&&A&&(E==null?void 0:E({context:L,totalCount:S,scrollingInProgress:_}))),ye(S=>!!S),Pn(0)),S=>{x&&(x(),x=null),vt(n)?requestAnimationFrame(()=>{vt(d)("scrolling into view",{}),Ee(p,S)}):x=dn(e,()=>{vt(d)("scrolling into view",{}),Ee(p,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},it(En,ko,yo,So,Un,zn,Ft,Tp,kp)),wC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(pe(ee(a,Me(s),ye(([,l])=>l!==0),Me(o,r,t,n,e),ce(([[,l],c,d,f,m,p=[]])=>yp(l,c,d,f,m,p))),i),{}),it(En,So,sr,Un),{singleton:!0}),bC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Qe(ee(e,Me(r),ye(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{dn(ee(n,nr(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ee(t,o)})})}),{initialScrollTop:r}},it(Un,Ft,sr),{singleton:!0}),Ip=qe(([{scrollVelocity:e}])=>{const t=oe(!1),n=Be(),r=oe(!1);return pe(ee(e,Me(r,t,n),ye(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Qe(ee(yt(t,e,n),Me(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(ko),{singleton:!0}),Va=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Be(),r=Be(),o=Be(),s=oe(!1),i=oe(void 0);return pe(ee(yt(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),pe(ee(t,Me(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Ft)),yC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Be(),d=oe(void 0),f=oe(null),m=oe(null);return pe(a,f),pe(l,m),Qe(ee(c,Me(t,r,i,f,m,n)),([p,v,g,x,y,b,C])=>{const k=oC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,p({ranges:k,scrollTop:g})}),pe(ee(d,ye(ja),ce(SC)),o),pe(ee(s,Me(d),ye(([,p])=>p!==void 0),at(),ce(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},it(En,Ft,So,Un,Va));function SC(e){return{align:"start",index:0,offset:e.scrollTop}}const CC=qe(([{topItemsIndexes:e}])=>{const t=oe(0);return pe(ee(t,ye(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(sr));function Np(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const TC=Np(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),kC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:v}])=>{const g=Qt(ee(l,Me(i),kn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},A])=>{const _=k+T;let L=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||(L=_-C,L!==0&&(L+=A))),[L,S,E,_]},[0,[],0,0]),ye(([y])=>y!==0),Me(r,a,n,o,p,v),ye(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===Co),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Wt.DEBUG),y))));function x(y){y>0?(Ee(t,{behavior:"auto",top:-y}),Ee(e,0)):(Ee(e,0),Ee(t,{behavior:"auto",top:-y}))}return Qe(ee(g,Me(e,s)),([y,b,C])=>{C&&TC()?Ee(e,b-y):x(-y)}),Qe(ee(yt(Rt(s,!1),e,v),ye(([y,b,C])=>!y&&!C&&b!==0),ce(([y,b])=>b),Pn(1)),x),pe(ee(f,ce(y=>({top:-y}))),t),Qe(ee(c,Me(m,d),ce(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const A=vo(k,0);let _=0,L=0;for(;_<y;){_++,E+=A;let F=b.length===L+1?1/0:b[L+1]-b[L]-1;_+F>y&&(E-=A,F=y-_+1),_+=F,E+=T(F),L++}return E}})),y=>{Ee(e,y),requestAnimationFrame(()=>{Ee(t,{top:y}),requestAnimationFrame(()=>{Ee(e,0),Ee(v,!1)})})}),{deviation:e}},it(Ft,ko,sr,En,zn,$a)),EC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it(Ua,wC,Un,Ip,Cp,bC,mC,Va,kp,zn,Tp)),Ap=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:A},_])=>(pe(k.rangeChanged,_.scrollSeekRangeChanged),pe(ee(_.windowViewportRect,ce(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:c,trackItemSizes:f,...k,..._,...g,sizes:l,...x}),it(En,So,Ft,yC,vC,sr,yo,kC,CC,mp,EC));function IC(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 Ds=typeof document<"u"?w.useLayoutEffect:w.useEffect;function jp(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=w.createContext({});function l(x,y){x.propsReady&&Ee(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Ee(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Ee(C,y[b])}x.propsReady&&Ee(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Ee(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=US(x[t.events[b]]),y),{})}const f=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Ns(VS(e),E=>{l(E,C)})),[S]=w.useState(Qf(d,k));Ds(()=>{for(const E of i)E in C&&Qe(S[E],C[E]);return()=>{Object.values(S).map(Pa)}},[C,S,k]),Ds(()=>{l(k,C)}),w.useImperativeHandle(y,Jf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...IC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Ee(y[x],b)},[y,x])},p=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Qe(y,C),[y]);return w.useSyncExternalStore(b,()=>vt(y),()=>vt(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(Qf(vt,y));return Ds(()=>Qe(y,k=>{k!==b&&C(Jf(k))}),[y,b]),b},g=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ds(()=>Qe(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Pp=w.createContext(void 0),_p=w.createContext(void 0),Rp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ka(e){return"self"in e}function NC(e){return"body"in e}function Mp(e,t,n,r=Mr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let p,v,g;const x=m.target;if(NC(x)||Ka(x)){const b=Ka(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Do.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ka(p)?(x=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(x=p[s?"scrollWidth":"scrollHeight"],g=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),xp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),p.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const qa="-webkit-sticky",Op="sticky",Ga=Np(()=>{if(typeof document>"u")return Op;const e=document.createElement("div");return e.style.position=qa,e.style.position===qa?qa:Op});function Ya(e){return e}const AC=qe(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Ya),o=oe("div"),s=oe(Mr),i=(a,l=null)=>Rt(ee(n,ce(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),jC=qe(([e,t])=>({...e,...t}),it(Ap,AC)),PC=({height:e})=>u.jsx("div",{style:{height:e}}),_C={overflowAnchor:"none",position:Ga(),zIndex:1},Dp={overflowAnchor:"none"},RC={...Dp,display:"inline-block",height:"100%"},Lp=w.memo(function({showTopList:e=!1}){const t=Ce("listState"),n=nn("sizeRanges"),r=Ce("useWindowScroll"),o=Ce("customScrollParent"),s=nn("windowScrollContainerState"),i=nn("scrollContainerState"),a=o||r?s:i,l=Ce("itemContent"),c=Ce("context"),d=Ce("groupContent"),f=Ce("trackItemSizes"),m=Ce("itemSize"),p=Ce("log"),v=nn("gap"),g=Ce("horizontalDirection"),{callbackRef:x}=GS(n,m,f,e?Mr:a,p,v,o,g,Ce("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Xa("deviation",O=>{y!==O&&b(O)});const C=Ce("EmptyPlaceholder"),k=Ce("ScrollSeekPlaceholder")||PC,S=Ce("ListComponent"),T=Ce("ItemComponent"),E=Ce("GroupComponent"),A=Ce("computeItemKey"),_=Ce("isSeeking"),L=Ce("groupIndices").length>0,F=Ce("alignToBottom"),U=Ce("initialItemFinalLocationReached"),X=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},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Mt(C,c)}):u.jsx(S,{...Mt(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:X,children:(e?t.topItems:t.items).map(O=>{const Y=O.originalIndex,V=A(Y+t.firstItemIndex,O.data,c);return _?w.createElement(k,{...Mt(k,c),height:O.size,index:O.index,key:V,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?w.createElement(E,{...Mt(E,c),"data-index":Y,"data-item-index":O.index,"data-known-size":O.size,key:V,style:_C},d(O.index,c)):w.createElement(T,{...Mt(T,c),...LC(T,O.data),"data-index":Y,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:V,style:g?RC:Dp},L?l(O.index,O.groupIndex,O.data,c):l(O.index,O.data,c))})})}),MC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},OC={outline:"none",overflowX:"auto",position:"relative"},Ls=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),DC={position:Ga(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function LC(e,t){return{item:typeof e=="string"?void 0:t}}const $C=w.memo(function(){const e=Ce("HeaderComponent"),t=nn("headerHeight"),n=Ce("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),FC=w.memo(function(){const e=Ce("FooterComponent"),t=nn("footerHeight"),n=Ce("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function $p({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:v}=Mp(a,c,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?OC:MC,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Fp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),m=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Mp(a,c,l,v,m);return Rp(()=>{var b;return x.current=m||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(l,s),children:r})})}const BC=({children:e})=>{const t=w.useContext(Pp),n=nn("viewportHeight"),r=nn("fixedItemHeight"),o=Ce("alignToBottom"),s=Ce("horizontalDirection"),i=w.useMemo(()=>Zf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ce("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ls(o),children:e})},zC=({children:e})=>{const t=w.useContext(Pp),n=nn("windowViewportRect"),r=nn("fixedItemHeight"),o=Ce("customScrollParent"),s=rp(n,o,Ce("skipAnimationFrameInResizeObserver")),i=Ce("alignToBottom");return w.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:Ls(i),children:e})},HC=({children:e})=>{const t=Ce("TopItemListComponent")||"div",n=Ce("headerHeight"),r={...DC,marginTop:`${n}px`},o=Ce("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},UC=w.memo(function(e){const t=Ce("useWindowScroll"),n=Ce("topItemsIndexes").length>0,r=Ce("customScrollParent"),o=Ce("context");return u.jsxs(r||t?KC:VC,{...e,context:o,children:[n&&u.jsx(HC,{children:u.jsx(Lp,{showTopList:!0})}),u.jsxs(r||t?zC:BC,{children:[u.jsx($C,{}),u.jsx(Lp,{}),u.jsx(FC,{})]})]})}),{Component:WC,useEmitter:Xa,useEmitterValue:Ce,usePublisher:nn}=jp(jC,{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"}},UC),VC=$p({useEmitter:Xa,useEmitterValue:Ce,usePublisher:nn}),KC=Fp({useEmitter:Xa,useEmitterValue:Ce,usePublisher:nn}),qC=WC;it(Ap,qe(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Ya),a=oe(Mr),l=(c,d=null)=>Rt(ee(s,ce(f=>f[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Ga();const Bp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},GC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:zp,floor:$s,max:Eo,min:Ja,round:Hp}=Math;function Up(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function YC(e){return{...GC,items:e}}function Fs(e,t){return e&&e.width===t.width&&e.height===t.height}function XC(e,t){return e&&e.column===t.column&&e.row===t.row}const JC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=oe(0),E=oe(0),A=oe(Bp),_=oe({height:0,width:0}),L=oe({height:0,width:0}),F=Be(),U=Be(),X=oe(0),O=oe(null),Y=oe({column:0,row:0}),V=Be(),K=Be(),D=oe(!1),I=oe(0),q=oe(!0),J=oe(!1),M=oe(!1);Qe(ee(v,Me(I),ye(([R,G])=>!!G)),()=>{Ee(q,!1)}),Qe(ee(yt(v,q,L,_,I,J),ye(([R,G,Q,se,,ie])=>R&&!G&&Q.height!==0&&se.height!==0&&!ie)),([,,,,R])=>{Ee(J,!0),za(1,()=>{Ee(F,R)}),dn(ee(c),()=>{Ee(t,[0,0]),Ee(q,!0)})}),pe(ee(K,ye(R=>R!=null&&R.scrollTop>0),Tn(0)),E),Qe(ee(v,Me(K),ye(([,R])=>R!=null)),([,R])=>{R&&(Ee(_,R.viewport),Ee(L,R.item),Ee(Y,R.gap),R.scrollTop>0&&(Ee(D,!0),dn(ee(c,nr(1)),G=>{Ee(D,!1)}),Ee(l,{top:R.scrollTop})))}),pe(ee(_,ce(({height:R})=>R)),f),pe(ee(yt(be(_,Fs),be(L,Fs),be(Y,(R,G)=>R&&R.column===G.column&&R.row===G.row),be(c)),ce(([R,G,Q,se])=>({gap:Q,item:G,scrollTop:se,viewport:R}))),V),pe(ee(yt(be(T),r,be(Y,XC),be(L,Fs),be(_,Fs),be(O),be(E),be(D),be(q),be(I)),ye(([,,,,,,,R])=>!R),ce(([R,[G,Q],se,ie,Se,xe,Oe,,De,Ge])=>{const{column:Ye,row:He}=se,{height:st,width:Xe}=ie,{width:St}=Se;if(Oe===0&&(R===0||St===0))return Bp;if(Xe===0){const At=Ha(Ge,R),pt=At+Math.max(Oe-1,0);return YC(Up(At,pt,xe))}const Le=Wp(St,Xe,Ye);let Ve,je;De?G===0&&Q===0&&Oe>0?(Ve=0,je=Oe-1):(Ve=Le*$s((G+He)/(st+He)),je=Le*zp((Q+He)/(st+He))-1,je=Ja(R-1,Eo(je,Le-1)),Ve=Ja(je,Eo(0,Ve))):(Ve=0,je=-1);const Ie=Up(Ve,je,xe),{bottom:Ne,top:ut}=Vp(Se,se,ie,Ie),jt=zp(R/Le),ft=jt*st+(jt-1)*He-Ne;return{bottom:Ne,itemHeight:st,items:Ie,itemWidth:Xe,offsetBottom:ft,offsetTop:ut,top:ut}})),A),pe(ee(O,ye(R=>R!==null),ce(R=>R.length)),T),pe(ee(yt(_,L,A,Y),ye(([R,G,{items:Q}])=>Q.length>0&&G.height!==0&&R.height!==0),ce(([R,G,{items:Q},se])=>{const{bottom:ie,top:Se}=Vp(R,se,G,Q);return[Se,ie]}),at(wo)),t);const B=oe(!1);pe(ee(c,Me(B),ce(([R,G])=>G||R!==0)),B);const P=Qt(ee(yt(A,T),ye(([{items:R}])=>R.length>0),Me(B),ye(([[R,G],Q])=>{const se=R.items[R.items.length-1].index===G-1;return(Q||R.bottom>0&&R.itemHeight>0&&R.offsetBottom===0&&R.items.length===G)&&se}),ce(([[,R]])=>R-1),at())),$=Qt(ee(be(A),ye(({items:R})=>R.length>0&&R[0].index===0),Tn(0),at())),z=Qt(ee(be(A),Me(D),ye(([{items:R},G])=>R.length>0&&!G),ce(([{items:R}])=>({endIndex:R[R.length-1].index,startIndex:R[0].index})),at(up),Pn(0)));pe(z,p.scrollSeekRangeChanged),pe(ee(F,Me(_,L,T,Y),ce(([R,G,Q,se,ie])=>{const Se=gp(R),{align:xe,behavior:Oe,offset:De}=Se;let Ge=Se.index;Ge==="LAST"&&(Ge=se-1),Ge=Eo(0,Ge,Ja(se-1,Ge));let Ye=Za(G,ie,Q,Ge);return xe==="end"?Ye=Hp(Ye-G.height+Q.height):xe==="center"&&(Ye=Hp(Ye-G.height/2+Q.height/2)),De&&(Ye+=De),{behavior:Oe,top:Ye}})),l);const j=Rt(ee(A,ce(R=>R.offsetBottom+R.bottom)),0);return pe(ee(k,ce(R=>({height:R.visibleHeight,width:R.visibleWidth}))),_),{customScrollParent:x,data:O,deviation:X,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:K,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...p,gridState:A,horizontalDirection:M,initialTopMostItemIndex:I,totalListHeight:j,...m,endReached:P,propsReady:g,rangeChanged:z,startReached:$,stateChanged:V,stateRestoreInProgress:D,...S}},it(Ua,Ft,ko,Ip,Un,Va,zn));function Wp(e,t,n){return Eo(1,$s((e+n)/($s(t)+n)))}function Vp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Za(e,t,n,r[0].index);return{bottom:Za(e,t,n,r[r.length-1].index)+o,top:s}}function Za(e,t,n,r){const o=Wp(e.width,n.width,t.column),s=$s(r/o),i=s*n.height+Eo(0,s-1)*t.row;return i>0?i+t.row:i}const ZC=qe(()=>{const e=oe(f=>`Item ${f}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Ya),i=oe("div"),a=oe(Mr),l=(f,m=null)=>Rt(ee(t,ce(p=>p[f]),at()),m),c=oe(!1),d=oe(!1);return pe(be(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")}}),QC=qe(([e,t])=>({...e,...t}),it(JC,ZC)),eT=w.memo(function(){const e=ct("gridState"),t=ct("listClassName"),n=ct("itemClassName"),r=ct("itemContent"),o=ct("computeItemKey"),s=ct("isSeeking"),i=rn("scrollHeight"),a=ct("ItemComponent"),l=ct("ListComponent"),c=ct("ScrollSeekPlaceholder"),d=ct("context"),f=rn("itemDimensions"),m=rn("gap"),p=ct("log"),v=ct("stateRestoreInProgress"),g=rn("reportReadyState"),x=rr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();f({height:k,width:S})}m({column:qp("column-gap",getComputedStyle(y).columnGap,p),row:qp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Rp(()=>{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 b=o(y.index,y.data,d);return s?u.jsx(c,{...Mt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),tT=w.memo(function(){const e=ct("HeaderComponent"),t=rn("headerHeight"),n=ct("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),nT=w.memo(function(){const e=ct("FooterComponent"),t=rn("footerHeight"),n=ct("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),rT=({children:e})=>{const t=w.useContext(_p),n=rn("itemDimensions"),r=rn("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.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:Ls(!1),children:e})},oT=({children:e})=>{const t=w.useContext(_p),n=rn("windowViewportRect"),r=rn("itemDimensions"),o=ct("customScrollParent"),s=rp(n,o,!1);return w.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:Ls(!1),children:e})},sT=w.memo(function({...e}){const t=ct("useWindowScroll"),n=ct("customScrollParent"),r=n||t?aT:iT,o=n||t?oT:rT,s=ct("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(tT,{}),u.jsx(eT,{}),u.jsx(nT,{})]})})}),{useEmitter:Kp,useEmitterValue:ct,usePublisher:rn}=jp(QC,{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"}},sT),iT=$p({useEmitter:Kp,useEmitterValue:ct,usePublisher:rn}),aT=Fp({useEmitter:Kp,useEmitterValue:ct,usePublisher:rn});function qp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Bs="Dialog",[Gp,zN]=ln(Bs),[lT,pn]=Gp(Bs),Yp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Bs});return u.jsx(lT,{scope:t,triggerRef:a,contentRef:l,contentId:_t(),titleId:_t(),descriptionId:_t(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Yp.displayName=Bs;var Xp="DialogTrigger",Jp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Xp,n),s=Re(t,o.triggerRef);return u.jsx(fe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":tl(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Jp.displayName=Xp;var Qa="DialogPortal",[cT,Zp]=Gp(Qa,{forceMount:void 0}),Qp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=pn(Qa,t);return u.jsx(cT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ut,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:i})}))})};Qp.displayName=Qa;var zs="DialogOverlay",eh=h.forwardRef((e,t)=>{const n=Zp(zs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(zs,e.__scopeDialog);return s.modal?u.jsx(Ut,{present:r||s.open,children:u.jsx(dT,{...o,ref:t})}):null});eh.displayName=zs;var uT=Gt.createSlot("DialogOverlay.RemoveScroll"),dT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(zs,n);return u.jsx(ws,{as:uT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(fe.div,{"data-state":tl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",th=h.forwardRef((e,t)=>{const n=Zp(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(ir,e.__scopeDialog);return u.jsx(Ut,{present:r||s.open,children:s.modal?u.jsx(fT,{...o,ref:t}):u.jsx(pT,{...o,ref:t})})});th.displayName=ir;var fT=h.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=h.useRef(null),o=Re(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return ga(s)},[]),u.jsx(nh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),pT=h.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(nh,{...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()}})}),nh=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=pn(ir,n),l=h.useRef(null),c=Re(t,l);return qi(),u.jsxs(u.Fragment,{children:[u.jsx(es,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Cr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":tl(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(hT,{titleId:a.titleId}),u.jsx(gT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),el="DialogTitle",rh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(el,n);return u.jsx(fe.h2,{id:o.titleId,...r,ref:t})});rh.displayName=el;var oh="DialogDescription",sh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(oh,n);return u.jsx(fe.p,{id:o.descriptionId,...r,ref:t})});sh.displayName=oh;var ih="DialogClose",ah=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(ih,n);return u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});ah.displayName=ih;function tl(e){return e?"open":"closed"}var lh="DialogTitleWarning",[HN,ch]=jw(lh,{contentName:ir,titleName:el,docsSlug:"dialog"}),hT=({titleId:e})=>{const t=ch(lh),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},mT="DialogDescriptionWarning",gT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ch(mT).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},nl=Yp,xT=Jp,rl=Qp,Io=eh,No=th,ar=rh,Hs=sh,uh=ah;const ol=nl,vT=rl,dh=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{ref:n,className:te("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}));dh.displayName=Io.displayName;const Us=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===ar||(c==null?void 0:c.displayName)===ar.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(vT,{children:[u.jsx(dh,{}),u.jsxs(No,{ref:r,className:te("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(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(uh,{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"})]})]})]})});Us.displayName=No.displayName;const Ws=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ws.displayName="DialogHeader";const Vs=h.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Vs.displayName=ar.displayName;const wT=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));wT.displayName=Hs.displayName;const bT=1,yT=1e6;let sl=0;function ST(){return sl=(sl+1)%Number.MAX_SAFE_INTEGER,sl.toString()}const il=new Map,fh=e=>{if(il.has(e))return;const t=setTimeout(()=>{il.delete(e),Ao({type:"REMOVE_TOAST",toastId:e})},yT);il.set(e,t)},CT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,bT)};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?fh(n):e.toasts.forEach(r=>{fh(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)}}},Ks=[];let qs={toasts:[]};function Ao(e){qs=CT(qs,e),Ks.forEach(t=>{t(qs)})}function TT({...e}){const t=ST(),n=o=>Ao({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ao({type:"DISMISS_TOAST",toastId:t});return Ao({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function al(){const[e,t]=h.useState(qs);return h.useEffect(()=>(Ks.push(t),()=>{const n=Ks.indexOf(t);n>-1&&Ks.splice(n,1)}),[e]),{...e,toast:TT,dismiss:n=>Ao({type:"DISMISS_TOAST",toastId:n})}}function ph({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:f}=al(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Li(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]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const p=async()=>{if(n)try{await ru(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 Li(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}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(Je,{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(ol,{open:e,onOpenChange:t,children:u.jsxs(Us,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ws,{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(Vs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Je,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Je,{variant:"outline",size:"sm",onClick:p,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 hh(){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 lr=hh();function kT(e){lr=e}const mh=/[&<>"']/,ET=new RegExp(mh.source,"g"),gh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,IT=new RegExp(gh.source,"g"),NT={"&":"&","<":"<",">":">",'"':""","'":"'"},xh=e=>NT[e];function Dt(e,t){if(t){if(mh.test(e))return e.replace(ET,xh)}else if(gh.test(e))return e.replace(IT,xh);return e}const AT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function vh(e){return e.replace(AT,(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 jT=/(^|[^\[])\^/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(jT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const PT=/[^\w:]/g,_T=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function wh(e,t,n){if(e){let r;try{r=decodeURIComponent(vh(n)).replace(PT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!_T.test(n)&&(n=DT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Gs={},RT=/^[^:]+:\/*[^/]*$/,MT=/^([^:]+:)[\s\S]*$/,OT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function DT(e,t){Gs[" "+e]||(RT.test(e)?Gs[" "+e]=e+"/":Gs[" "+e]=Xs(e,"/",!0)),e=Gs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(MT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(OT,"$1")+t:e+t}const Ys={exec:function(){}};function bh(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 Xs(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 LT(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 $T(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 yh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Sh(e,t,n,r){const o=t.href,s=t.title?Dt(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:Dt(i)}}function FT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},mT="DialogDescriptionWarning",gT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ch(mT).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},nl=Yp,xT=Jp,rl=Qp,Io=eh,No=th,ar=rh,Hs=sh,uh=ah;const ol=nl,vT=rl,dh=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{ref:n,className:te("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}));dh.displayName=Io.displayName;const Us=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===ar||(c==null?void 0:c.displayName)===ar.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(vT,{children:[u.jsx(dh,{}),u.jsxs(No,{ref:r,className:te("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(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(uh,{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"})]})]})]})});Us.displayName=No.displayName;const Ws=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ws.displayName="DialogHeader";const Vs=h.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Vs.displayName=ar.displayName;const wT=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));wT.displayName=Hs.displayName;const bT=1,yT=1e6;let sl=0;function ST(){return sl=(sl+1)%Number.MAX_SAFE_INTEGER,sl.toString()}const il=new Map,fh=e=>{if(il.has(e))return;const t=setTimeout(()=>{il.delete(e),Ao({type:"REMOVE_TOAST",toastId:e})},yT);il.set(e,t)},CT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,bT)};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?fh(n):e.toasts.forEach(r=>{fh(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)}}},Ks=[];let qs={toasts:[]};function Ao(e){qs=CT(qs,e),Ks.forEach(t=>{t(qs)})}function TT({...e}){const t=ST(),n=o=>Ao({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ao({type:"DISMISS_TOAST",toastId:t});return Ao({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function al(){const[e,t]=h.useState(qs);return h.useEffect(()=>(Ks.push(t),()=>{const n=Ks.indexOf(t);n>-1&&Ks.splice(n,1)}),[e]),{...e,toast:TT,dismiss:n=>Ao({type:"DISMISS_TOAST",toastId:n})}}function ph({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:f}=al(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Li(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]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const p=async()=>{if(n)try{await ru(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 Li(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}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(ol,{open:e,onOpenChange:t,children:u.jsxs(Us,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ws,{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(Vs,{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:p,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 hh(){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 lr=hh();function kT(e){lr=e}const mh=/[&<>"']/,ET=new RegExp(mh.source,"g"),gh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,IT=new RegExp(gh.source,"g"),NT={"&":"&","<":"<",">":">",'"':""","'":"'"},xh=e=>NT[e];function Ot(e,t){if(t){if(mh.test(e))return e.replace(ET,xh)}else if(gh.test(e))return e.replace(IT,xh);return e}const AT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function vh(e){return e.replace(AT,(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 jT=/(^|[^\[])\^/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(jT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const PT=/[^\w:]/g,_T=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function wh(e,t,n){if(e){let r;try{r=decodeURIComponent(vh(n)).replace(PT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!_T.test(n)&&(n=DT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Gs={},RT=/^[^:]+:\/*[^/]*$/,MT=/^([^:]+:)[\s\S]*$/,OT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function DT(e,t){Gs[" "+e]||(RT.test(e)?Gs[" "+e]=e+"/":Gs[" "+e]=Xs(e,"/",!0)),e=Gs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(MT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(OT,"$1")+t:e+t}const Ys={exec:function(){}};function bh(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 Xs(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 LT(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 $T(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 yh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Sh(e,t,n,r){const o=t.href,s=t.title?Ot(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:Ot(i)}}function FT(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 ll{constructor(t){this.options=t||lr}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:Xs(r,`
|
|
86
86
|
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=FT(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=Xs(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,p,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 b=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
@@ -90,10 +90,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
90
90
|
`,1)[0],f=m,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||E.test(f)||k.test(f)||S.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
91
91
|
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||S.test(d))break;p+=`
|
|
92
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(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),S=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=S}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):
|
|
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(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),S=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=S}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Ot(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:bh(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]=bh(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:
|
|
96
|
-
]`).replace("lheading",
|
|
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:Ot(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]):Ot(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=Xs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=LT(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)),Sh(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 Sh(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 p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ot(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=Ot(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ot(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=Ot(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=Ot(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]):Ot(r[0]):r[0]:o=Ot(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={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:Ys,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=nt(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=nt(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=nt(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._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",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=nt(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=nt(ve._paragraph).replace("hr",ve.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",ve._tag).getRegex(),ve.blockquote=nt(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=nt(ve.gfm.table).replace("hr",ve.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",ve._tag).getRegex(),ve.gfm.paragraph=nt(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.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",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:nt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._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:Ys,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:nt(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ys,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:Ys,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=nt(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=nt(ve._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=nt(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=nt(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=nt(ue.emStrong.rDelimUnd,"g").replace(/punct/g,ue._punctuation).getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._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])?)+(?![-_])/,ue.autolink=nt(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=nt(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=nt(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=nt(ue.reflink).replace("label",ue._label).replace("ref",ve._label).getRegex(),ue.nolink=nt(ue.nolink).replace("ref",ve._label).getRegex(),ue.reflinkSearch=nt(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal={...ue},ue.pedantic={...ue.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",ue._label).getRegex(),reflink:nt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:nt(ue.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ue.gfm.url=nt(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:nt(ue.br).replace("{2,}","*").getRegex(),text:nt(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function BT(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 Ch(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 Wn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lr,this.options.tokenizer=this.options.tokenizer||new ll,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:ve.normal,inline:ue.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:ue}}static lex(t,n){return new Wn(n).lex(t)}static lexInline(t,n){return new Wn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
97
97
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
@@ -104,8 +104,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
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
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)+"["+yh("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)+"["+yh("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,Ch)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Ch))){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(p){m=p.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,BT)){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 cl{constructor(t){this.options=t||lr}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+
|
|
108
|
-
`:"<pre><code>"+(r?t:
|
|
107
|
+
`,o?'<pre><code class="'+this.options.langPrefix+Ot(o)+'">'+(r?t:Ot(t,!0))+`</code></pre>
|
|
108
|
+
`:"<pre><code>"+(r?t:Ot(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}>
|
|
@@ -125,7 +125,7 @@ ${t}</tr>
|
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
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=wh(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=wh(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 Th{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 kh{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 Vn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new cl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Th,this.slugger=new kh}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,m,p,v,g,x,y,b,C,k,S,T;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,vh(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),m="",a=p.rows.length,s=0;s<a;s++){for(c=p.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:p.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(f,m);continue}case"blockquote":{m=this.parse(p.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=p.ordered,g=p.start,x=p.loose,a=p.items.length,m="",s=0;s<a;s++)b=p.items[s],C=b.checked,k=b.task,y="",b.task&&(S=this.renderer.checkbox(C),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=S+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=S+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:S}):y+=S),y+=this.parse(b.tokens,x),m+=this.renderer.listitem(y,k,C);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(m=p.tokens?this.parseInline(p.tokens):p.text;o+1<E&&t[o+1].type==="text";)p=t[++o],m+=`
|
|
127
127
|
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Js{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}ix(Js,"passThroughHooks",new Set(["preprocess","postprocess"]));function zT(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>"+Dt(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 Eh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...he.defaults,...s};const i=zT(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($T(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&&he.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;he.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return c(m);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(he.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&&he.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function he(e,t,n){return Eh(Wn.lex,Vn.parse)(e,t,n)}he.options=he.setOptions=function(e){return he.defaults={...he.defaults,...e},kT(he.defaults),he},he.getDefaults=hh,he.defaults=lr,he.use=function(...e){const t=he.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=he.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=he.defaults.renderer||new cl;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=he.defaults.tokenizer||new ll;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=he.defaults.hooks||new Js;for(const s in n.hooks){const i=o[s];Js.passThroughHooks.has(s)?o[s]=a=>{if(he.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=he.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}}he.setOptions(r)})},he.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(he,r)),r.type){case"table":{for(const o of r.header)n=n.concat(he.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(he.walkTokens(s.tokens,t));break}case"list":{n=n.concat(he.walkTokens(r.items,t));break}default:he.defaults.extensions&&he.defaults.extensions.childTokens&&he.defaults.extensions.childTokens[r.type]?he.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(he.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(he.walkTokens(r.tokens,t)))}return n},he.parseInline=Eh(Wn.lexInline,Vn.parseInline),he.Parser=Vn,he.parser=Vn.parse,he.Renderer=cl,he.TextRenderer=Th,he.Lexer=Wn,he.lexer=Wn.lex,he.Tokenizer=ll,he.Slugger=kh,he.Hooks=Js,he.parse=he,he.options,he.setOptions,he.use,he.walkTokens,he.parseInline,Vn.parse,Wn.lex;function cr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.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 he.parse=="function"?he.parse(i):he(i)}return typeof he.parse=="function"?he.parse(e):he(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=w.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:te("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 Ih({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Nh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>dw(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Ih,{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 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 Zs({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:wr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:wr(e)})}function Ah({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.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}const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ul.displayName="Card";const dl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));dl.displayName="CardHeader";const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));fl.displayName="CardTitle";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));pl.displayName="CardDescription";const Qs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));Qs.displayName="CardContent";const jh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));jh.displayName="CardFooter";const UT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function hl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=UT(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const f=wr(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:f})}return u.jsxs(ul,{className:te("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(dl,{className:"pb-3",children:[u.jsx(fl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(pl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(Qs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(f=>u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(Qs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(jh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function Ph({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function _h({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:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(cr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Je,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(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)"]})})]})}function Rh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=al(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),f=w.useCallback(p=>{a(p),c(!0)},[]),m=w.useCallback(async(p,v,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){p.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";f({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){p.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await ou(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.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(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.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(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Mh(e,t){return w.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:sw(r),toolMeta:Fi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:iw(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Oh="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(Oh))continue;const s=o.slice(Oh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=to(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 w.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=to(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 Dh({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o}){var C;const s=Fi(e),i=e.artifact??null,a=qT(e),l=e.content.find(k=>k.type!=="tool_call"),c=k=>{if(k==null)return null;const S=typeof k=="string"?to(k)??k:k;if(S&&typeof S=="object")return u.jsx(Zs,{data:S});const T=typeof S=="string"?S:(()=>{try{return wr(S)}catch{return String(S??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:T})},d=k=>{if(k==null)return null;const{content:S,isMarkdown:T}=ow(k);return T?u.jsx(cr,{content:S,className:"text-current"}):c(k)},f=k=>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(Zs,{data:k})]}),m=()=>{if((a==null?void 0:a.kind)==="generic")return d(a.value);if(!l)return null;if(l.type==="text"){const E=(l.text??"").trim();if(!E)return null;const A=br(E);return d(A)}const k=no(l),S=br(k);return d(S)},p=()=>(a==null?void 0:a.kind)==="dict"?f(a.data):m(),g=(()=>{if(r){if(s.name){const k=r[s.name];if(k)return k}if(a!=null&&a.kind){const k=r[a.kind];if(k)return k}return r.default}})(),x=(g==null?void 0:g({message:e,toolMeta:s,toolPayload:a,viewMode:t,isStreaming:n}))??null,b=((C=(()=>{if(!o)return;const k=i==null?void 0:i.type;if(typeof k=="string"){const S=o[k];if(S)return S}return o.default})())==null?void 0:C({artifact:i,message:e,toolPayload:a,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[i&&(b??u.jsx(Nh,{artifact:i,idx:0})),u.jsx(Ah,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:x??p()})]})}const GT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},ml=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,gl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,toolRenderers:x,toolArtifactRenderers:y}){const b=ml(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming,T=p??GT,E=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:A,attemptIndex:
|
|
130
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[j]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[G,g[j]?" (processing)":""]})]},j)}return null},[v,S,C,x,y,g,b,m,k]),$=i.trim().length>0||a.length>0||l.length>0||q.length>0;if(!t&&l.length>0&&!d)return O();if(!t&&!$&&!d)return null;if(t){if(!n)return null;if(X&&c){const H=c.value,j=!z,_=M??(()=>{}),G=L??(()=>{});return u.jsx(hl,{interruptPart:c,payload:H,onApprove:_,onReject:G,onSelectAlternative:F,disabled:z,isActive:j})}return u.jsx(Dh,{message:e,viewMode:r,isStreaming:o,toolRenderers:E,toolArtifactRenderers:A},e.id)}if(!p){const H=u.jsx("div",{className:"space-y-2",children:q.map((j,_)=>m&&ZT(j)?V?u.jsx("div",{className:"space-y-2",children:V},`streaming-md-${_}`):null:u.jsx(P,{part:j,i:_},_))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[H,u.jsx(Ph,{className:T})]}):H}return null}function Lh(e){return e?!(jo(e,/```/g)||jo(e,/`/g)||jo(e,/\*\*/g)||jo(e,/__/g)||jo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function jo(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(Lh(e.slice(0,t)))return t;return 0}function ZT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const QT=Ur.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 $h({className:e,variant:t,...n}){return u.jsx("div",{className:te(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:f,messageRole:m,toolViewMode:p,toolMeta:v,onToggleToolView:g,onCopy:x,onEdit:y,onRegenerate:b,showCheckpointControls:C,attemptCount:k,attemptIndex:S,handleOlderAttemptSelect:T,handleNewerAttemptSelect:E,messageCreatedAt:A,copied:M}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:te("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs($h,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",o,"border border-current/40",c&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":p==="expanded",onClick:g,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),g())},children:[u.jsx("span",{children:v.name??"Tool Output"}),v.toolCallId&&u.jsx("span",{className:"opacity-70",children:v.toolCallId.slice(0,8)}),p==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:v.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[C&&k>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S<k-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=k-1||T()},"aria-label":"Older attempt (back in time)",disabled:S>=k-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:[k-S," / ",k]})}),u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||E()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&A&&u.jsx("time",{className:te("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(A).toISOString(),title:new Date(A).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(A))}),d&&!f&&u.jsxs("div",{className:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:te("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:te(M?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:te("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:te(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:b,className:te("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:te(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ei=w.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,toolRenderers:m,toolArtifactRenderers:p,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:C,onCopy:k,attemptCount:S=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:A=[]}){const[M,L]=w.useState(!1),[F,z]=w.useState("preview"),[X,O]=w.useState(!1),{currentThreadId:Y}=vr(),{respondToInterrupt:W}=ro(),[K,D]=w.useState(!1),I=l==="phone"||l==="half-screen",V=t.role,Z=V==="interrupt",R=V==="tool"||Z,P=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,$=w.useMemo(()=>t.role==="default_message"?t:null,[t]),H=!!$,j=!(r&&V!=="user"),{uploadingFiles:_,handleFileClick:G,fileViewerOpen:Q,currentFileInfo:oe,closeFileViewer:ae}=Rh({allowFileOpen:j,currentThreadId:Y}),ve=w.useMemo(()=>{switch(V){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[V]),we=Mh(t,$),{contentParts:Re,imageParts:Me,fileParts:Ye,textContent:Le,toolMeta:$e,toolRaw:ft,isToolStreaming:Qe,interruptParts:gt}=we,He=y??g!==0,Oe=w.useMemo(()=>gt.length?gt[0]:null,[gt]),De=w.useCallback(async()=>{const Ne=R?ft:Le;async function Ue(ut){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ut);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Se=new Blob([ut],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Se})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Ue(Ne),L(!0),setTimeout(()=>L(!1),2e3),k==null||k(Ne)}catch(ut){console.error("Failed to copy:",ut)}},[R,ft,Le,k]),Ce=w.useCallback(async(Ne,Ue)=>{if(!Oe)return;if(!wu(Oe.id)){console.warn("Interrupt part missing id",Oe);return}D(!0);try{await W(Ne,Ue)}catch(Se){console.error("Failed to respond to interrupt:",Se)}finally{D(!1)}},[Oe,W]),Fe=w.useCallback(()=>Ce(!0),[Ce]),at=w.useCallback(()=>Ce(!1),[Ce]),jt=w.useCallback((Ne,Ue)=>{if(!Ue)return;const ut={alternativeId:Ue.id??Ue.label??void 0,alternativeLabel:Ue.label};Ce(!0,ut)},[Ce]),lt=w.useCallback(()=>{if(!b||!t.id)return;const Ne=(R?ft:Le)??"",Ue="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,Ne,Ue)},[b,R,ft,Le,t]),Nt=w.useCallback(()=>{C==null||C(n)},[C,n]),pt=!Z&&P,kt=w.useCallback(()=>{pt&&z(Ne=>Ne==="expanded"?"preview":"expanded")},[pt]),qt=Z||P?"expanded":F,At=w.useCallback(()=>{const Ue=te(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ve);switch(V){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});case"interrupt":return u.jsx(le.Bot,{className:Ue});default:return u.jsx(le.Bot,{className:Ue})}},[I,ve,V]),Pt=w.useCallback(()=>{const Ne="group relative mb-4 flex w-full";switch(V){case"user":return te(Ne,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return te(Ne,"justify-start");default:return Ne}},[V]),xt=w.useCallback(()=>{const Ne=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(H)return te(Ne,"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(V){case"user":return te(Ne,"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 te(Ne,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":case"interrupt":return te(Ne,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(Ne,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(Ne,"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,H,V]),We=(f||Z)&&P,Ve=u.jsx(XT,{message:t,isToolMessage:R,showToolMessages:We,toolViewMode:qt,isToolStreaming:Qe,contentParts:Re,textContent:Le,imageParts:Me,fileParts:Ye,isStreamingMessage:r,defaultMessage:$,enableStreamingMarkdownBuffer:He,renderStreamingMarkdown:x,handleFileClick:G,uploadingFiles:_,messageRole:V,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:X,setIsUserExpanded:O,isCompactLayout:I,iconForeground:ve,toolRenderers:m,toolArtifactRenderers:p,interruptPart:Oe,handleInterruptApprove:Fe,handleInterruptReject:at,handleInterruptAlternative:jt,disableInterruptActions:K,isInterruptMessage:Z}),Et=w.useMemo(()=>$?"Assistant":aw(t),[$,t]),ne=At(),me=V==="user"&&(S??1)>1&&typeof E=="function",et=(A==null?void 0:A.length)??0,de=et>0&&T<et-1?A[T+1]:void 0,ke=et>0&&T>0?A[T-1]:void 0,Ke=w.useCallback(()=>{!de||!E||E(de.id,void 0,!!de.isLatestAttempt)},[de,E]),ht=w.useCallback(()=>{!ke||!E||E(ke.id,void 0,!!ke.isLatestAttempt)},[ke,E]);return R&&!f?null:H&&$?u.jsx("div",{className:te(Pt(),v.container),children:u.jsxs("div",{className:te(xt(),v.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:te("h-4 w-4",ve)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:$.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(Pt(),v.container),children:u.jsxs("div",{className:te(xt(),v.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:R,iconForeground:ve,agentName:Et,messageIcon:ne,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:V,toolViewMode:qt,isInterruptMessage:Z,toolMeta:$e,onToggleToolView:kt,onCopy:De,onEdit:lt,onRegenerate:Nt,showCheckpointControls:me,attemptCount:S,attemptIndex:T,handleOlderAttemptSelect:Ke,handleNewerAttemptSelect:ht,messageCreatedAt:t.createdAt,copied:M}),u.jsx("div",{className:"relative",children:Ve}),R&&qt==="expanded"&&($e.toolCallId||$e.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[$e.name&&u.jsxs("div",{children:["Function: ",$e.name]}),$e.toolCallId&&u.jsxs("div",{children:["Call ID: ",$e.toolCallId]})]}),!(i||a||R)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>De(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Copy,{className:te(M?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),V==="user"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:lt,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Edit,{className:te("text-current",I?"h-3 w-3":"h-4 w-4")})}),V==="assistant"&&C&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Nt,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:te("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&u.jsx(ph,{isOpen:Q,onClose:ae,fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&bu(e.message)===bu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=yu(e.message),a=yu(t.message);return i.length===a.length});ei.displayName="MessageComponent";const xl=w.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:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:M=!1,getMessageCustomStyles:L},F)=>{const z=w.useRef(null),X=w.useRef(null),O=w.useRef(!1),Y=w.useRef(!1),W=e,K=w.useMemo(()=>{const j=n&&W.some(G=>G.id===n);return A&&(t||M)&&!j&&W.length>0?[...W,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:W},[W,t,n,A,M]),D=w.useMemo(()=>b?K:K.filter(j=>(j==null?void 0:j.role)!=="tool"),[K,b]),I=w.useCallback(j=>{x&&x(!j),y&&y(j)},[x,y]),V=w.useMemo(()=>{if(a)return async()=>{if(!O.current){O.current=!0;try{await a()}finally{O.current=!1}}}},[a]),Z=w.useMemo(()=>!v||g?!1:"auto",[v,g]),R=w.useMemo(()=>{if(typeof p!="string")return null;const j=p.trim();return!j||D&&D.length>0?null:{id:"default-message",role:"default_message",content:j,createdAt:new Date().toISOString()}},[p,D]),q=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),P=()=>{if(R){const j=L==null?void 0:L(R);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ei,{message:R,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:j})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},$=D.length,H=$>0;return w.useEffect(()=>{var j,_;if($===0){Y.current=!1;return}if(!Y.current)if(Y.current=!0,z.current&&D.length>0){const G=D.length-1;(_=(j=z.current).scrollToIndex)==null||_.call(j,{index:G,align:"end",behavior:"auto"})}else X.current&&(X.current.scrollTop=X.current.scrollHeight)},[$,D.length]),w.useImperativeHandle(F,()=>({scrollToLatest:()=>{var j,_;if(z.current&&D.length>0){const G=D.length-1;(_=(j=z.current).scrollToIndex)==null||_.call(j,{index:G,align:"end",behavior:"auto"})}else X.current&&(X.current.scrollTop=X.current.scrollHeight)},scrollToTop:()=>{var j,_;z.current&&D.length>0?(_=(j=z.current).scrollToIndex)==null||_.call(j,{index:0,align:"start",behavior:"auto"}):X.current&&(X.current.scrollTop=0)}}),[D]),u.jsx("div",{className:q,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:H?u.jsx(qC,{ref:j=>{z.current=j},scrollerRef:j=>{X.current=j instanceof HTMLDivElement?j:null},data:D,followOutput:Z,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{V&&V()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(j,_)=>ml(_,j),itemContent:(j,_)=>u.jsx(gl,{message:_,index:j,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:b,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,getMessageCustomStyles:L})}):P()})})});xl.displayName="MessageList";const Fh={value:""};function Dr({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,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=Qr(),S=k.baseUrl,{currentThreadId:T}=vr(),{threadId:E,messages:A,isLoading:M,navigateToCheckpoint:L,returnToLatest:F,checkpoint:z,checkpoints:X,interrupt:O,metadata:Y,checkpointIndex:W,respondToInterrupt:K}=ro(),{isStreaming:D,error:I,connectionState:V,submit:Z,stop:R}=Hi(),q=E??T??null,P=(z==null?void 0:z.id)??null,$=(z==null?void 0:z.namespace)??null,H=(Y==null?void 0:Y.assemblingMessageId)??null,j=O,_=j?wu(j.id):null,G=_!==null?{type:"interrupt",id:_}:null,[Q,oe]=w.useState(!1),[ae,ve]=w.useState(!1);w.useEffect(()=>{j||oe(!1)},[j]);const we=w.useCallback(()=>{oe(!0)},[]),Re=w.useCallback(()=>{oe(!1)},[]),Me=w.useCallback(async(je,N)=>{if(!_){console.warn("Interrupt response skipped: missing interrupt id");return}try{we(),await K(je,N)}catch(J){console.error("Failed to respond to interrupt:",J)}finally{Re()}},[Re,we,K]),Ye=w.useCallback(()=>Me(!0),[Me]),Le=w.useCallback(()=>Me(!1),[Me]),$e=w.useCallback((je,N)=>Me(!0,N),[Me]),ft=!!j||Q,[Qe,gt]=w.useState(null),[He,Oe]=w.useState(""),[De,Ce]=w.useState(null),[Fe,at]=w.useState(null),[jt,lt]=w.useState(!1),[Nt,pt]=w.useState(null),kt=w.useRef(!1),[ct,qt]=w.useState(()=>Fh.value),At=w.useRef(ct),Pt=w.useRef(null),xt=w.useCallback(je=>{Fh.value=je,qt(je)},[]),[We,Ve]=w.useState(!1),Et=w.useRef(null),ne=w.useCallback(je=>{xt(je)},[xt]);w.useEffect(()=>{D||ve(!1)},[D]),w.useEffect(()=>{Y!=null&&Y.assemblingMessageId&&ve(!1)},[Y==null?void 0:Y.assemblingMessageId]);const[me,et]=w.useState("desktop");w.useEffect(()=>{const je=()=>{const N=window.innerWidth;et(N<640?"phone":N<1024?"tablet":"desktop")};return je(),window.addEventListener("resize",je),()=>window.removeEventListener("resize",je)},[]),w.useEffect(()=>{kt.current=!1},[q]),w.useEffect(()=>{At.current=ct},[ct]),w.useEffect(()=>{if(!Qe){Pt.current=null;return}Pt.current===null&&(Pt.current=At.current),xt(He??"")},[He,Qe,xt]),w.useEffect(()=>{if(C!==void 0){pt(C);return}(async()=>{if(!S){pt(null);return}try{const J=(await k.getAgent("default")).uiDefaultMessage||"";pt(J||null)}catch(N){console.warn("Failed to fetch default message:",N),pt(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!jt&&(b==null||b(I))},[I,jt,b]);const de=async(je,N)=>{const J=je.trim();if(!(!J&&N.length===0))try{const se=Qe?(De==null?void 0:De.checkpointId)??P??void 0:P??void 0,ge=Qe?(De==null?void 0:De.checkpointNs)??$??void 0:$??void 0;await Z({text:J||"",attachments:N,payload:p},{checkpointId:se,checkpointNs:ge,edit:!!Qe,originalMessageId:Qe??void 0}),x==null||x(J),ve(!0),xt(""),at(null),gt(null),Oe(""),Ce(null)}catch(se){const ge=(se==null?void 0:se.message)||"Failed to send message";at(ge),b==null||b(ge),ve(!1)}},ke=w.useCallback(async je=>{await Z({attachments:[je],payload:p},{checkpointId:P??void 0,checkpointNs:$??void 0}),y==null||y({file:je})},[P,$,p,y,Z]),Ke=w.useCallback((je,N,J)=>{c&&(Pt.current=ct,gt(je),Oe(N),xt(N),at(null),Ce({checkpointId:(J==null?void 0:J.checkpointId)??null,checkpointNs:(J==null?void 0:J.checkpointNs)??null}))},[ct,c,xt]),ht=w.useCallback(()=>{gt(null),Oe(""),Ce(null),at(null),xt(Pt.current??ct),Pt.current=null},[ct,xt]),Ne=w.useCallback((je,N,J)=>{Ke(je,N,J)},[Ke]),Ue=w.useCallback(je=>{let N=null;for(let Ae=je-1;Ae>=0;Ae--)if(A[Ae].role==="user"){N=A[Ae];break}if(!N)return;const J=Array.isArray(N.content)?N.content:[],ge=J.filter(Ae=>(Ae==null?void 0:Ae.type)==="text").map(Ae=>Ae.text).join("")||(()=>{try{return JSON.stringify(J,null,2)}catch{return String(J)}})();ge&&Z({text:ge,payload:p},{checkpointId:P??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:N.id})},[A,Z,P,$,p]),ut=w.useCallback(async je=>{if(T){Ve(!0);try{if(!je){await F(),requestAnimationFrame(()=>{var se;(se=Et.current)==null||se.scrollToLatest()});return}const N=X.find(se=>se.checkpointId===je),J=(N==null?void 0:N.checkpointNs)??null;await L(je,J),requestAnimationFrame(()=>{var se;(se=Et.current)==null||se.scrollToTop()})}finally{Ve(!1)}}},[X,T,Et,L,F]),Se=w.useCallback(async(je,N,J)=>{await ut(J?null:je)},[ut]),mt=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,Xe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${j?"pb-32":""} bg-transparent ${v.messagesArea||""}`,dt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:mt,children:[!!I&&!jt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>lt(!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 ${Xe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(xl,{ref:Et,className:"h-full",style:{height:"100%"},messages:A,isStreaming:D,streamingAssistantId:H,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:me,enableMessageEditing:c,editingMessageId:Qe,onEdit:Ne,onRegenerate:Ue,onCancelEdit:ht,emptyMessage:Nt??void 0,isNavigatingCheckpoint:We,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:W,activeCheckpointId:P,onSelectCheckpoint:Se,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae,getMessageCustomStyles:g}),(V==="reconnecting"||V==="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"}),V==="reconnecting"?"Reconnecting…":"Connecting…"]})}),V==="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"}),M&&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…"})]}),We&&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…"})]}),j&&G&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(hl,{interruptPart:G,onApprove:Ye,onReject:Le,onSelectAlternative:$e,disabled:Q,isActive:!0,payload:j.value})})})]}),u.jsxs("div",{className:dt,children:[Qe&&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(Je,{variant:"ghost",size:"sm",onClick:ht,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),Fe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Fe}),u.jsx(LS,{composerValue:ct,onComposerChange:ne,onSend:de,onCancelEdit:ht,onStop:R,editingMessageId:Qe,editingInitialValue:He,placeholder:Qe?"Edit your message...":t,isStreaming:D,disabled:ft,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:ke,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:Fe})]})]})}var Bh=1,tk=.9,nk=.8,rk=.17,vl=.1,wl=.999,ok=.9999,sk=.99,ik=/[\\\/_+.#"@\[\(\{&]/,ak=/[\\\/_+.#"@\[\(\{&]/g,lk=/[\s-]/,zh=/[\s-]/g;function bl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Bh: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,p,v;c>=0;)f=bl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Bh:ik.test(e.charAt(c-1))?(f*=nk,p=e.slice(o,c-1).match(ak),p&&o>0&&(f*=Math.pow(wl,p.length))):lk.test(e.charAt(c-1))?(f*=tk,v=e.slice(o,c-1).match(zh),v&&o>0&&(f*=Math.pow(wl,v.length))):(f*=rk,o>0&&(f*=Math.pow(wl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ok)),(f<vl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=bl(e,t,n,r,c+1,s+2,i),m*vl>f&&(f=m*vl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Hh(e){return e.toLowerCase().replace(zh," ")}function ck(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,bl(e,t,Hh(e),Hh(t),0,0,{})}var Po='[cmdk-group=""]',yl='[cmdk-group-items=""]',uk='[cmdk-group-heading=""]',Uh='[cmdk-item=""]',Wh=`${Uh}:not([aria-disabled="true"])`,Sl="cmdk-item-select",Lr="data-value",dk=(e,t,n)=>ck(e,t,n),Vh=h.createContext(void 0),_o=()=>h.useContext(Vh),Kh=h.createContext(void 0),Cl=()=>h.useContext(Kh),qh=h.createContext(void 0),Gh=h.forwardRef((e,t)=>{let n=$r(()=>{var R,q;return{search:"",value:(q=(R=e.value)!=null?R:e.defaultValue)!=null?q:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=$r(()=>new Set),o=$r(()=>new Map),s=$r(()=>new Map),i=$r(()=>new Set),a=Yh(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=Rt(),C=Rt(),k=Rt(),S=h.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),ur(()=>{T(6,X)},[]);let E=h.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,q,P)=>{var $,H,j,_;if(!Object.is(n.current[R],q)){if(n.current[R]=q,R==="search")z(),L(),T(1,F);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(k);G?G.focus():($=document.getElementById(b))==null||$.focus()}if(T(7,()=>{var G;n.current.selectedItemId=(G=O())==null?void 0:G.id,E.emit()}),P||T(5,X),((H=a.current)==null?void 0:H.value)!==void 0){let G=q??"";(_=(j=a.current).onValueChange)==null||_.call(j,G);return}}E.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),A=h.useMemo(()=>({value:(R,q,P)=>{var $;q!==(($=s.current.get(R))==null?void 0:$.value)&&(s.current.set(R,{value:q,keywords:P}),n.current.filtered.items.set(R,M(q,P)),T(2,()=>{L(),E.emit()}))},item:(R,q)=>(r.current.add(R),q&&(o.current.has(q)?o.current.get(q).add(R):o.current.set(q,new Set([R]))),T(3,()=>{z(),L(),n.current.value||F(),E.emit()}),()=>{s.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let P=O();T(4,()=>{z(),(P==null?void 0:P.getAttribute("id"))===R&&F(),E.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{s.current.delete(R),o.current.delete(R)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function M(R,q){var P,$;let H=($=(P=a.current)==null?void 0:P.filter)!=null?$:dk;return R?H(R,n.current.search,q):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,q=[];n.current.filtered.groups.forEach($=>{let H=o.current.get($),j=0;H.forEach(_=>{let G=R.get(_);j=Math.max(G,j)}),q.push([$,j])});let P=S.current;Y().sort(($,H)=>{var j,_;let G=$.getAttribute("id"),Q=H.getAttribute("id");return((j=R.get(Q))!=null?j:0)-((_=R.get(G))!=null?_:0)}).forEach($=>{let H=$.closest(yl);H?H.appendChild($.parentElement===H?$:$.closest(`${yl} > *`)):P.appendChild($.parentElement===P?$:$.closest(`${yl} > *`))}),q.sort(($,H)=>H[1]-$[1]).forEach($=>{var H;let j=(H=S.current)==null?void 0:H.querySelector(`${Po}[${Lr}="${encodeURIComponent($[0])}"]`);j==null||j.parentElement.appendChild(j)})}function F(){let R=Y().find(P=>P.getAttribute("aria-disabled")!=="true"),q=R==null?void 0:R.getAttribute(Lr);E.setState("value",q||void 0)}function z(){var R,q,P,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let H=0;for(let j of r.current){let _=(q=(R=s.current.get(j))==null?void 0:R.value)!=null?q:"",G=($=(P=s.current.get(j))==null?void 0:P.keywords)!=null?$:[],Q=M(_,G);n.current.filtered.items.set(j,Q),Q>0&&H++}for(let[j,_]of o.current)for(let G of _)if(n.current.filtered.items.get(G)>0){n.current.filtered.groups.add(j);break}n.current.filtered.count=H}function X(){var R,q,P;let $=O();$&&(((R=$.parentElement)==null?void 0:R.firstChild)===$&&((P=(q=$.closest(Po))==null?void 0:q.querySelector(uk))==null||P.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function O(){var R;return(R=S.current)==null?void 0:R.querySelector(`${Uh}[aria-selected="true"]`)}function Y(){var R;return Array.from(((R=S.current)==null?void 0:R.querySelectorAll(Wh))||[])}function W(R){let q=Y()[R];q&&E.setState("value",q.getAttribute(Lr))}function K(R){var q;let P=O(),$=Y(),H=$.findIndex(_=>_===P),j=$[H+R];(q=a.current)!=null&&q.loop&&(j=H+R<0?$[$.length-1]:H+R===$.length?$[0]:$[H+R]),j&&E.setState("value",j.getAttribute(Lr))}function D(R){let q=O(),P=q==null?void 0:q.closest(Po),$;for(;P&&!$;)P=R>0?bk(P,Po):yk(P,Po),$=P==null?void 0:P.querySelector(Wh);$?E.setState("value",$.getAttribute(Lr)):K(R)}let I=()=>W(Y().length-1),V=R=>{R.preventDefault(),R.metaKey?I():R.altKey?D(1):K(1)},Z=R=>{R.preventDefault(),R.metaKey?W(0):R.altKey?D(-1):K(-1)};return h.createElement(fe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var q;(q=y.onKeyDown)==null||q.call(y,R);let P=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||P))switch(R.key){case"n":case"j":{x&&R.ctrlKey&&V(R);break}case"ArrowDown":{V(R);break}case"p":case"k":{x&&R.ctrlKey&&Z(R);break}case"ArrowUp":{Z(R);break}case"Home":{R.preventDefault(),W(0);break}case"End":{R.preventDefault(),I();break}case"Enter":{R.preventDefault();let $=O();if($){let H=new Event(Sl);$.dispatchEvent(H)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:Tk},l),ti(e,R=>h.createElement(Kh.Provider,{value:E},h.createElement(Vh.Provider,{value:A},R))))}),fk=h.forwardRef((e,t)=>{var n,r;let o=Rt(),s=h.useRef(null),i=h.useContext(qh),a=_o(),l=Yh(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=Xh(o,s,[e.value,e.children,s],e.keywords),f=Cl(),m=Kn(T=>T.value&&T.value===d.current),p=Kn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Sl,v),()=>T.removeEventListener(Sl,v)},[p,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(!p)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(fe.div,{ref:Mn(s,t),...S,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)}),pk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Rt(),a=h.useRef(null),l=h.useRef(null),c=Rt(),d=_o(),f=Kn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Xh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(fe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ti(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(qh.Provider,{value:m},p))))}),hk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(fe.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),mk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Cl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(fe.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=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),h.createElement(fe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ti(e,c=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(nl,{open:n,onOpenChange:r},h.createElement(rl,{container:i},h.createElement(Io,{"cmdk-overlay":"",className:o}),h.createElement(No,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Gh,{ref:t,...a}))))}),vk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(fe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),wk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(fe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ti(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Vt=Object.assign(Gh,{List:gk,Item:fk,Input:mk,Group:pk,Separator:hk,Dialog:xk,Empty:vk,Loading:wk});function bk(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 Yh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function $r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Cl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Xh(e,t,n,r=[]){let o=h.useRef(),s=_o();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(Lr,a),o.current=a}),o}var Sk=()=>{let[e,t]=h.useState(),n=$r(()=>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 ti({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.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 Tl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tl.displayName=Vt.displayName;const kl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Vt.Input,{ref:n,className:te("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));kl.displayName=Vt.Input.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));El.displayName=Vt.List.displayName;const Il=h.forwardRef((e,t)=>u.jsx(Vt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Il.displayName=Vt.Empty.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Group,{ref:n,className:te("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Nl.displayName=Vt.Group.displayName;const kk=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));kk.displayName=Vt.Separator.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Item,{ref:n,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Al.displayName=Vt.Item.displayName;function jl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ek(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Pl="ScrollArea",[Jh,UN]=cn(Pl),[Ik,sn]=Jh(Pl),Zh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,A]=h.useState(!1),M=Pe(t,F=>l(F)),L=Qo(o);return u.jsx(Ik,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(fe.div,{dir:L,...i,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Zh.displayName=Pl;var Qh="ScrollAreaViewport",em=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(Qh,n),a=h.useRef(null),l=Pe(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(fe.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})})]})});em.displayName=Qh;var In="ScrollAreaScrollbar",_l=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Nk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(tm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Rl,{...r,ref:t}):null});_l.displayName=In;var Nk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ut,{present:n||s,children:u.jsx(tm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ut,{present:n||a!=="hidden",children:u.jsx(Rl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),tm=h.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Fr(n.viewport,l),Fr(n.content,l),u.jsx(Ut,{present:r||s,children:u.jsx(Rl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Rl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=im(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function f(m,p){return Ok(m,i.current,a,p)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=am(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(Pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=am(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Pe(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"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":oi(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),cm(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:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),Pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Pe(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"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":oi(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),cm(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:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[_k,nm]=Jh(In),rm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,p=sn(In,n),[v,g]=h.useState(null),x=Pe(t,M=>g(M)),y=h.useRef(null),b=h.useRef(""),C=p.viewport,k=r.content-r.viewport,S=wt(d),T=wt(l),E=si(f,10);function A(M){if(y.current){const L=M.clientX-y.current.left,F=M.clientY-y.current.top;c({x:L,y:F})}}return h.useEffect(()=>{const M=L=>{const F=L.target;(v==null?void 0:v.contains(F))&&S(L,k)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Fr(v,E),Fr(p.content,E),u.jsx(_k,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:wt(s),onThumbPointerUp:wt(i),onThumbPositionChange:T,onThumbPointerDown:wt(a),children:u.jsx(fe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(M))}),onPointerMove:ie(e.onPointerMove,A),onPointerUp:ie(e.onPointerUp,M=>{const L=M.target;L.hasPointerCapture(M.pointerId)&&L.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",om=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nm(ni,e.__scopeScrollArea);return u.jsx(Ut,{present:n||o.hasThumb,children:u.jsx(Rk,{ref:t,...r})})}),Rk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(ni,n),i=nm(ni,n),{onThumbPositionChange:a}=i,l=Pe(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=si(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const p=Dk(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(fe.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 p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});om.displayName=ni;var Ml="ScrollAreaCorner",sm=h.forwardRef((e,t)=>{const n=sn(Ml,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Mk,{...e,ref:t}):null});sm.displayName=Ml;var Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(Ml,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Fr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Fr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(fe.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 ri(e){return e?parseInt(e,10):0}function im(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=im(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=oi(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 lm([l,c],f)(e)}function am(e,t,n="ltr"){const r=oi(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=jl(e,l);return lm([0,i],[0,a])(c)}function lm(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 cm(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 si(e,t){const n=wt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Fr(e,t){const n=wt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var um=Zh,Lk=em,$k=sm;const Ol=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(um,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(Lk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(dm,{}),u.jsx($k,{})]}));Ol.displayName=um.displayName;const dm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(_l,{ref:r,orientation:t,className:te("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(om,{className:"relative flex-1 rounded-full bg-border"})}));dm.displayName=_l.displayName;const Dl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Dl.displayName="Input";const 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 fm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??zk}`:`${x??Bk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Fk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(Dl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Je,{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:p(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(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(go,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},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,hm="thread-manager-view",Hk=e=>e==="default"||e==="shared",Uk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hm);if(Hk(e))return e}catch{}return null};function mm({defaultView:e}={}){const[t,n]=w.useState(()=>Uk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(hm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Wk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ii({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:M,actions:L,shareInFlight:F,shareStatus:z,clearShareStatus:X}=vr(),{createThread:O,deleteThread:Y,renameThread:W,shareThread:K}=L,{loadThread:D}=ro(),I=i??T,[V,Z]=w.useState(Array.isArray(k)?k:[]),R=w.useRef(V.length>0),q=w.useRef(null),P=w.useRef(0),[$,H]=w.useState(null),[j,_]=w.useState(""),[G,Q]=w.useState(!1),[oe,ae]=w.useState(!1),[ve,we]=w.useState(null),[Re,Me]=w.useState(""),Ye=v&&v.length>0?v:Wk,Le=mm({defaultView:m}),$e=g??Le,ft=f??$e.view,Qe=w.useCallback(ne=>{f||$e.setView(ne),p==null||p(ne)},[f,p,$e]),gt=Ye.find(ne=>ne.key===ft)??Ye[0],He=ne=>{we(ne),Me(""),ae(!0)},Oe=()=>{ae(!1),we(null),Me(""),X()},De=w.useCallback(async ne=>{if(!(!ve||F)&&ne.id)try{await K(ve,ne.id),setTimeout(()=>Oe(),600)}catch(me){console.error("Failed to share thread:",me)}},[Oe,F,ve,K]),Ce=w.useMemo(()=>{const ne=y??[],me=Re.trim().toLowerCase();return me?C?ne.filter(et=>C(et,me)):ne.filter(et=>`${et.label} ${et.secondaryLabel??""}`.toLowerCase().includes(me)):ne},[y,Re,C]),Fe=ft==="shared",at=Fe?S:V,jt=Fe?M:A,lt=Fe?"No shared conversations yet":"No conversations yet",Nt=ne=>{const me=ne.sharedAt?` • ${We(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${me}`},pt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){R.current=!0,Z(ne);return}A||(R.current=!1,Z(ne))},[k,A]),w.useEffect(()=>{if(!q.current)return;const ne=q.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let me=null,et=null;return me=requestAnimationFrame(()=>{et=requestAnimationFrame(()=>{ne.scrollTop=P.current})}),()=>{me!==null&&cancelAnimationFrame(me),et!==null&&cancelAnimationFrame(et)}},[V]);const kt=async ne=>{try{E(ne),await D(ne),a==null||a(ne),l==null||l(ne)}catch(me){console.error("Failed to select thread:",me)}},ct=async()=>{try{Q(!0);const ne=await O();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{Q(!1)}},qt=async(ne,me)=>{if(me.stopPropagation(),!!confirm("Delete this thread?")){if(q.current){const et=q.current.querySelector("[data-radix-scroll-area-viewport]");et&&(P.current=et.scrollTop)}try{await Y(ne),d==null||d(ne)}catch(et){console.error("Failed to delete thread:",et)}}},At=(ne,me)=>{me.stopPropagation(),H(ne.threadId),_(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},Pt=async ne=>{if(j.trim())try{await W(ne,j.trim()),H(null),_("")}catch(me){console.error("Failed to update title:",me)}},xt=()=>{H(null),_("")},We=ne=>{if(!ne)return"";try{const me=new Date(ne),de=new Date().getTime()-me.getTime(),ke=Math.floor(de/(1e3*60*60*24));return ke===0?me.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:me.toLocaleDateString()}catch{return""}},Ve=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,Et=ne=>{const me=Ve(ne);return me.length<=pm?me:`${me.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(Je,{onClick:ct,disabled:G||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:G?"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(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:gt.label})}),u.jsx(go,{align:"start",sideOffset:6,className:"w-40",children:Ye.map(ne=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:me=>{me.preventDefault(),Qe(ne.key)},children:[u.jsx("span",{children:ne.label}),ft===ne.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(Ol,{ref:q,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:jt?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…"})]}):at.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:lt})]}):at.slice().sort((ne,me)=>new Date(me.updatedAt||me.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(fm,{thread:ne,isActive:I===ne.threadId,editingThreadId:$,editingTitle:j,onSelect:kt,onStartEditing:At,onEditingTitleChange:me=>_(me),onSaveEditing:Pt,onCancelEditing:xt,onShare:()=>He(ne.threadId),onDelete:qt,showEditTitle:r,showDeleteButton:n,formatDate:We,getDisplayThreadTitle:Et,secondaryLine:Fe&&pt(ne)?Nt(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(ol,{open:oe,onOpenChange:ne=>!ne&&Oe(),children:u.jsxs(Us,{className:"max-w-md p-0",children:[u.jsx(Ws,{children:u.jsx(Vs,{children:"Share thread"})}),u.jsxs(Tl,{children:[u.jsx(kl,{autoFocus:!0,value:Re,onValueChange:ne=>Me(ne),placeholder:"Search for recipients..."}),u.jsxs(El,{children:[z&&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:z.startsWith("Failed")?"text-red-500":z.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:z})]}),u.jsx(Il,{children:b?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"}),Ce.length>0&&u.jsx(Nl,{heading:"Recipients",children:Ce.map(ne=>u.jsx(Al,{onSelect:()=>De(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.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=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(yr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Dr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(yr,{...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(ii,{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(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(yr,{...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(ii,{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(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(yr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Dr,{})})})}function qk({placeholder:e,onMessageSent:t}){const[n,r]=w.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(Dr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ii,{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]=w.useState(!1);return n?u.jsx(yr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(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(Je,{variant:r,size:o,className:te("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",gm=h.forwardRef((e,t)=>u.jsx(fe.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())}}));gm.displayName=Xk;var xm=gm;const Jk=Ur.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),vm=h.forwardRef(({className:e,...t},n)=>u.jsx(xm,{ref:n,className:te(Jk(),e),...t}));vm.displayName=xm.displayName;function wm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var bm=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",ai=h.forwardRef((e,t)=>u.jsx(fe.span,{...e,ref:t,style:{...bm,...e.style}}));ai.displayName=Zk;var Qk=ai,eE=[" ","Enter","ArrowUp","ArrowDown"],tE=[" ","Enter"],dr="Select",[li,ci,nE]=Zo(dr),[Br,WN]=cn(dr,[nE,Nr]),ui=Nr(),[rE,qn]=Br(dr),[oE,sE]=Br(dr),ym=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=ui(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=Qo(c),[E,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[M,L]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),F=h.useRef(null),z=x?v||!!x.closest("form"):!0,[X,O]=h.useState(new Set),Y=Array.from(X).map(W=>W.props.value).join(";");return u.jsx(ca,{...g,children:u.jsxs(rE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:Rt(),value:M,onValueChange:L,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(W=>{O(K=>new Set(K).add(W))},[]),onNativeOptionRemove:h.useCallback(W=>{O(K=>{const D=new Set(K);return D.delete(W),D})},[]),children:n})}),z?u.jsxs(Vm,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:M,onChange:W=>L(W.target.value),disabled:m,form:v,children:[M===void 0?u.jsx("option",{value:""}):null,Array.from(X)]},Y):null]})})};ym.displayName=dr;var Sm="SelectTrigger",Cm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ui(n),i=qn(Sm,n),a=i.disabled||r,l=Pe(t,i.onTriggerChange),c=ci(n),d=h.useRef("touch"),[f,m,p]=qm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=Gm(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ua,{asChild:!0,...s,children:u.jsx(fe.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":Km(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())})})})});Cm.displayName=Sm;var Tm="SelectValue",km=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(Tm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Pe(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(fe.span,{...a,ref:f,style:{pointerEvents:"none"},children:Km(l.value)?u.jsx(u.Fragment,{children:i}):s})});km.displayName=Tm;var iE="SelectIcon",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(fe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Em.displayName=iE;var aE="SelectPortal",Im=e=>u.jsx(lo,{asChild:!0,...e});Im.displayName=aE;var fr="SelectContent",Nm=h.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Wr.createPortal(u.jsx(Am,{scope:e.__scopeSelect,children:u.jsx(li.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(jm,{...e,ref:t})});Nm.displayName=fr;var mn=10,[Am,Gn]=Br(fr),lE="SelectContentImpl",cE=Yt.createSlot("SelectContent.RemoveScroll"),jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(fr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=Pe(t,j=>k(j)),[A,M]=h.useState(null),[L,F]=h.useState(null),z=ci(n),[X,O]=h.useState(!1),Y=h.useRef(!1);h.useEffect(()=>{if(C)return ga(C)},[C]),qi();const W=h.useCallback(j=>{const[_,...G]=z().map(ae=>ae.ref.current),[Q]=G.slice(-1),oe=document.activeElement;for(const ae of j)if(ae===oe||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===_&&S&&(S.scrollTop=0),ae===Q&&S&&(S.scrollTop=S.scrollHeight),ae==null||ae.focus(),document.activeElement!==oe))return},[z,S]),K=h.useCallback(()=>W([A,C]),[W,A,C]);h.useEffect(()=>{X&&K()},[X,K]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let j={x:0,y:0};const _=Q=>{var oe,ae;j={x:Math.abs(Math.round(Q.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ae=I.current)==null?void 0:ae.y)??0))}},G=Q=>{j.x<=10&&j.y<=10?Q.preventDefault():C.contains(Q.target)||D(!1),document.removeEventListener("pointermove",_),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",G,{capture:!0})}}},[C,D,I]),h.useEffect(()=>{const j=()=>D(!1);return window.addEventListener("blur",j),window.addEventListener("resize",j),()=>{window.removeEventListener("blur",j),window.removeEventListener("resize",j)}},[D]);const[V,Z]=qm(j=>{const _=z().filter(oe=>!oe.disabled),G=_.find(oe=>oe.ref.current===document.activeElement),Q=Gm(_,j,G);Q&&setTimeout(()=>Q.ref.current.focus())}),R=h.useCallback((j,_,G)=>{const Q=!Y.current&&!G;(b.value!==void 0&&b.value===_||Q)&&(M(j),Q&&(Y.current=!0))},[b.value]),q=h.useCallback(()=>C==null?void 0:C.focus(),[C]),P=h.useCallback((j,_,G)=>{const Q=!Y.current&&!G;(b.value!==void 0&&b.value===_||Q)&&F(j)},[b.value]),$=r==="popper"?Ll:Pm,H=$===Ll?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Am,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:R,selectedItem:A,onItemLeave:q,itemTextRefCallback:P,focusSelectedItem:K,selectedItemText:L,position:r,isPositioned:X,searchRef:V,children:u.jsx(ws,{as:cE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:j=>{j.preventDefault()},onUnmountAutoFocus:ie(o,j=>{var _;(_=b.trigger)==null||_.focus({preventScroll:!0}),j.preventDefault()}),children:u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:j=>j.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:j=>j.preventDefault(),...y,...H,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,j=>{const _=j.ctrlKey||j.altKey||j.metaKey;if(j.key==="Tab"&&j.preventDefault(),!_&&j.key.length===1&&Z(j.key),["ArrowUp","ArrowDown","Home","End"].includes(j.key)){let Q=z().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(j.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(j.key)){const oe=j.target,ae=Q.indexOf(oe);Q=Q.slice(ae+1)}setTimeout(()=>W(Q)),j.preventDefault()}})})})})})})});jm.displayName=lE;var uE="SelectItemAlignedPosition",Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(fr,n),i=Gn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),f=Pe(t,E=>d(E)),m=ci(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const oe=L.left-A.left,ae=M.left-oe,ve=E.left-ae,we=E.width+ve,Re=Math.max(we,A.width),Me=window.innerWidth-mn,Ye=jl(ae,[mn,Math.max(mn,Me-Re)]);a.style.minWidth=we+"px",a.style.left=Ye+"px"}else{const oe=A.right-L.right,ae=window.innerWidth-M.right-oe,ve=window.innerWidth-E.right-ae,we=E.width+ve,Re=Math.max(we,A.width),Me=window.innerWidth-mn,Ye=jl(ae,[mn,Math.max(mn,Me-Re)]);a.style.minWidth=we+"px",a.style.right=Ye+"px"}const F=m(),z=window.innerHeight-mn*2,X=g.scrollHeight,O=window.getComputedStyle(c),Y=parseInt(O.borderTopWidth,10),W=parseInt(O.paddingTop,10),K=parseInt(O.borderBottomWidth,10),D=parseInt(O.paddingBottom,10),I=Y+W+X+D+K,V=Math.min(x.offsetHeight*5,I),Z=window.getComputedStyle(g),R=parseInt(Z.paddingTop,10),q=parseInt(Z.paddingBottom,10),P=E.top+E.height/2-mn,$=z-P,H=x.offsetHeight/2,j=x.offsetTop+H,_=Y+W+j,G=I-_;if(_<=P){const oe=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-g.offsetTop-g.offsetHeight,ve=Math.max($,H+(oe?q:0)+ae+K),we=_+ve;a.style.height=we+"px"}else{const oe=F.length>0&&x===F[0].ref.current;a.style.top="0px";const ve=Math.max(P,Y+g.offsetTop+(oe?R:0)+H)+G;a.style.height=ve+"px",g.scrollTop=_-P+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>C(),[C]);const[k,S]=h.useState();It(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(fE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(fe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=uE;var dE="SelectPopperPosition",Ll=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ui(n);return u.jsx(da,{...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)"}})});Ll.displayName=dE;var[fE,$l]=Br(fr,{}),Fl="SelectViewport",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Fl,n),i=$l(Fl,n),a=Pe(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(li.Slot,{scope:n,children:u.jsx(fe.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 p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const b=y+p,C=Math.min(v,b),k=b-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});_m.displayName=Fl;var Rm="SelectGroup",[pE,hE]=Br(Rm),mE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Rt();return u.jsx(pE,{scope:n,id:o,children:u.jsx(fe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});mE.displayName=Rm;var Mm="SelectLabel",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hE(Mm,n);return u.jsx(fe.div,{id:o.id,...r,ref:t})});Om.displayName=Mm;var di="SelectItem",[gE,Dm]=Br(di),Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(di,n),l=Gn(di,n),c=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Pe(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=Rt(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(gE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{f(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(li.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(fe.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,()=>p(!0)),onBlur:ie(i.onBlur,()=>p(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ie(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ie(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(tE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Lm.displayName=di;var Ro="SelectItemText",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Ro,n),a=Gn(Ro,n),l=Dm(Ro,n),c=sE(Ro,n),[d,f]=h.useState(null),m=Pe(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(fe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Wr.createPortal(s.children,i.valueNode):null]})});$m.displayName=Ro;var Fm="SelectItemIndicator",Bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Dm(Fm,n).isSelected?u.jsx(fe.span,{"aria-hidden":!0,...r,ref:t}):null});Bm.displayName=Fm;var Bl="SelectScrollUpButton",zm=h.forwardRef((e,t)=>{const n=Gn(Bl,e.__scopeSelect),r=$l(Bl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});zm.displayName=Bl;var zl="SelectScrollDownButton",Hm=h.forwardRef((e,t)=>{const n=Gn(zl,e.__scopeSelect),r=$l(zl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Hm.displayName=zl;var Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=ci(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(fe.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",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(fe.div,{"aria-hidden":!0,...r,ref:t})});Wm.displayName=xE;var Hl="SelectArrow",vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ui(n),s=qn(Hl,n),i=Gn(Hl,n);return s.open&&i.position==="popper"?u.jsx(fa,{...o,...r,ref:t}):null});vE.displayName=Hl;var wE="SelectBubbleInput",Vm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Pe(r,o),i=wm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(fe.select,{...n,style:{...bm,...n.style},ref:s,defaultValue:t})});Vm.displayName=wE;function Km(e){return e===""||e===void 0}function qm(e){const t=wt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Gm(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=bE(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 bE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yE=ym,Ym=Cm,SE=km,CE=Em,TE=Im,Xm=Nm,kE=_m,Jm=Om,Zm=Lm,EE=$m,IE=Bm,Qm=zm,eg=Hm,tg=Wm;const NE=yE,AE=SE,ng=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:te("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"})})]}));ng.displayName=Ym.displayName;const rg=h.forwardRef(({className:e,...t},n)=>u.jsx(Qm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));rg.displayName=Qm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(TE,{children:u.jsxs(Xm,{ref:o,className:te("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(rg,{}),u.jsx(kE,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(og,{})]})}));sg.displayName=Xm.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=Jm.displayName;const ig=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zm,{ref:r,className:te("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})]}));ig.displayName=Zm.displayName;const PE=h.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));PE.displayName=tg.displayName;var _E="Separator",ag="horizontal",RE=["horizontal","vertical"],lg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ag,...o}=e,s=ME(r)?r:ag,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(fe.div,{"data-orientation":s,...a,...o,ref:t})});lg.displayName=_E;function ME(e){return RE.includes(e)}var cg=lg;const ug=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(cg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ug.displayName=cg.displayName;var fi="Switch",[OE,VN]=cn(fi),[DE,LE]=OE(fi),dg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,p]=h.useState(null),v=Pe(t,C=>p(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:fi});return u.jsxs(DE,{scope:n,checked:y,disabled:a,children:[u.jsx(fe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":mg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ie(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(hg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});dg.displayName=fi;var fg="SwitchThumb",pg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LE(fg,n);return u.jsx(fe.span,{"data-state":mg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pg.displayName=fg;var $E="SwitchBubbleInput",hg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Pe(i,s),l=wm(n),c=Td(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});hg.displayName=$E;function mg(e){return e?"checked":"unchecked"}var gg=dg,FE=pg;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(gg,{className:te("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:te("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")})}));xg.displayName=gg.displayName;const BE=nl,zE=xT,HE=rl,vg=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{className:te("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}));vg.displayName=Io.displayName;const UE=Ur.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=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(HE,{children:[u.jsx(vg,{}),u.jsxs(No,{ref:o,className:te(UE({side:e}),t),...r,children:[n,u.jsxs(uh,{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=No.displayName;const bg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});bg.displayName="SheetHeader";const yg=h.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));yg.displayName=ar.displayName;const Sg=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));Sg.displayName=Hs.displayName;var[pi,KN]=cn("Tooltip",[Nr]),hi=Nr(),Cg="TooltipProvider",WE=700,Ul="tooltip.open",[VE,Wl]=pi(Cg),Tg=e=>{const{__scopeTooltip:t,delayDuration:n=WE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(VE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Tg.displayName=Cg;var Mo="Tooltip",[KE,mi]=pi(Mo),kg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Wl(Mo,e.__scopeTooltip),c=hi(t),[d,f]=h.useState(null),m=Rt(),p=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Ul))):l.onClose(),s==null||s(E)},caller:Mo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,b(!0),p.current=0},g)},[g,b]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ca,{...c,children:u.jsx(KE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(p.current),p.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};kg.displayName=Mo;var Vl="TooltipTrigger",Eg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mi(Vl,n),s=Wl(Vl,n),i=hi(n),a=h.useRef(null),l=Pe(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(ua,{asChild:!0,...i,children:u.jsx(fe.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)})})});Eg.displayName=Vl;var qE="TooltipPortal",[qN,GE]=pi(qE,{forceMount:void 0}),zr="TooltipContent",Ig=h.forwardRef((e,t)=>{const n=GE(zr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(zr,e.__scopeTooltip);return u.jsx(Ut,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ng,{side:o,...s,ref:t}):u.jsx(YE,{side:o,...s,ref:t})})}),YE=h.forwardRef((e,t)=>{const n=mi(zr,e.__scopeTooltip),r=Wl(zr,e.__scopeTooltip),o=h.useRef(null),s=Pe(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=eI(y,x.getBoundingClientRect()),C=tI(y,b),k=nI(g.getBoundingClientRect()),S=oI([...C,...k]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!rI(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Ng,{...e,ref:s})}),[XE,JE]=pi(Mo,{isInside:!1}),ZE=Yt.createSlottable("TooltipContent"),Ng=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(zr,n),c=hi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Ul,d),()=>document.removeEventListener(Ul,d)),[d]),h.useEffect(()=>{if(l.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(da,{"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})})]})})});Ig.displayName=zr;var Ag="TooltipArrow",QE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return JE(Ag,n).isInside?null:u.jsx(fa,{...o,...r,ref:t})});QE.displayName=Ag;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=Tg,aI=kg,lI=Eg,jg=Ig;const cI=iI,uI=aI,dI=lI,Pg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(jg,{ref:r,sideOffset:t,className:te("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=jg.displayName;var Kl="ToastProvider",[ql,fI,pI]=Zo("Toast"),[_g,GN]=cn("Toast",[pI]),[hI,gi]=_g(Kl),Rg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Kl}\`. Expected non-empty \`string\`.`),u.jsx(ql.Provider,{scope:t,children:u.jsx(hI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Rg.displayName=Kl;var Mg="ToastViewport",mI=["F8"],Gl="toast.viewportPause",Yl="toast.viewportResume",Og=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=mI,label:o="Notifications ({hotkey})",...s}=e,i=gi(Mg,n),a=fI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Pe(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=f.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Gl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Yl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...NI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const A=document.activeElement,M=b.shiftKey;if(b.target===x&&M){(S=c.current)==null||S.focus();return}const z=g({tabbingDirection:M?"backwards":"forwards"}),X=z.findIndex(O=>O===A);Zl(z.slice(X+1))?b.preventDefault():M?(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(Vw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Xl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Zl(x)}}),u.jsx(ql.Slot,{scope:n,children:u.jsx(fe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Xl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Zl(x)}})]})});Og.displayName=Mg;var Dg="ToastFocusProxy",Xl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=gi(Dg,n);return u.jsx(ai,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Xl.displayName=Dg;var Oo="Toast",gI="toast.swipeStart",xI="toast.swipeMove",vI="toast.swipeCancel",wI="toast.swipeEnd",Lg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Oo});return u.jsx(Ut,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:wt(e.onPause),onResume:wt(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)})})})});Lg.displayName=Oo;var[bI,yI]=_g(Oo,{onClose(){}}),SI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=gi(Oo,n),[x,y]=h.useState(null),b=Pe(t,O=>y(O)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),A=h.useRef(0),{onToastAdd:M,onToastRemove:L}=g,F=wt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),z=h.useCallback(O=>{!O||O===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(F,O))},[F]);h.useEffect(()=>{const O=g.viewport;if(O){const Y=()=>{z(E.current),c==null||c()},W=()=>{const K=new Date().getTime()-T.current;E.current=E.current-K,window.clearTimeout(A.current),l==null||l()};return O.addEventListener(Gl,W),O.addEventListener(Yl,Y),()=>{O.removeEventListener(Gl,W),O.removeEventListener(Yl,Y)}}},[g.viewport,S,l,c,z]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&z(S)},[s,S,g.isClosePausedRef,z]),h.useEffect(()=>(M(),()=>L()),[M,L]);const X=h.useMemo(()=>x?Wg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[X&&u.jsx(CI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:X}),u.jsx(bI,{scope:n,onClose:F,children:Wr.createPortal(u.jsx(ql.ItemSlot,{scope:n,children:u.jsx(Ww,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(fe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,O=>{O.key==="Escape"&&(a==null||a(O.nativeEvent),O.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ie(e.onPointerDown,O=>{O.button===0&&(C.current={x:O.clientX,y:O.clientY})}),onPointerMove:ie(e.onPointerMove,O=>{if(!C.current)return;const Y=O.clientX-C.current.x,W=O.clientY-C.current.y,K=!!k.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,V=D?I(0,Y):0,Z=D?0:I(0,W),R=O.pointerType==="touch"?10:2,q={x:V,y:Z},P={originalEvent:O,delta:q};K?(k.current=q,xi(xI,f,P,{discrete:!1})):Vg(q,g.swipeDirection,R)?(k.current=q,xi(gI,d,P,{discrete:!1}),O.target.setPointerCapture(O.pointerId)):(Math.abs(Y)>R||Math.abs(W)>R)&&(C.current=null)}),onPointerUp:ie(e.onPointerUp,O=>{const Y=k.current,W=O.target;if(W.hasPointerCapture(O.pointerId)&&W.releasePointerCapture(O.pointerId),k.current=null,C.current=null,Y){const K=O.currentTarget,D={originalEvent:O,delta:Y};Vg(Y,g.swipeDirection,g.swipeThreshold)?xi(wI,p,D,{discrete:!0}):xi(vI,m,D,{discrete:!0}),K.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),CI=e=>{const{__scopeToast:t,children:n,...r}=e,o=gi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return EI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(lo,{asChild:!0,children:u.jsx(ai,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},TI="ToastTitle",$g=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});$g.displayName=TI;var kI="ToastDescription",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});Fg.displayName=kI;var Bg="ToastAction",zg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Ug,{altText:n,asChild:!0,children:u.jsx(Jl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Bg}\`. Expected non-empty \`string\`.`),null)});zg.displayName=Bg;var Hg="ToastClose",Jl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=yI(Hg,n);return u.jsx(Ug,{asChild:!0,children:u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Jl.displayName=Hg;var Ug=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(fe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Wg(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(...Wg(r))}}),t}function xi(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?Wi(o,s):o.dispatchEvent(s)}var Vg=(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=wt(e);It(()=>{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 Zl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var AI=Rg,Kg=Og,qg=Lg,Gg=$g,Yg=Fg,Xg=zg,Jg=Jl;const jI=AI,Zg=h.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:te("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Zg.displayName=Kg.displayName;const PI=Ur.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"}}),Qg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(qg,{ref:r,className:te(PI({variant:t}),e),...n}));Qg.displayName=qg.displayName;const _I=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:te("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}));_I.displayName=Xg.displayName;const ex=h.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:te("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"})}));ex.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:te("text-sm font-semibold",e),...t}));tx.displayName=Gg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:te("text-sm opacity-90",e),...t}));nx.displayName=Yg.displayName;function RI(){const{toasts:e}=al();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(tx,{children:n}),r&&u.jsx(nx,{children:r})]}),o,u.jsx(ex,{})]},t)}),u.jsx(Zg,{})]})}var MI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[p]?s[p]:p)):l.setAttribute(v,p)}),f(p)}function f(p){a&&c.includes(p)&&(l.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},OI=h.createContext(void 0),DI={setTheme:e=>{},themes:[]},LI=()=>{var e;return(e=h.useContext(OI))!=null?e:DI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${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})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},FI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),zI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.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=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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=w.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"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),KI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Ql=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:Ql++,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],w.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)||Ql++;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}},Kt=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return Kt.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=()=>Kt.toasts,ZI=()=>Kt.getActiveToasts();Object.assign(XI,{success:Kt.success,info:Kt.info,warning:Kt.warning,error:Kt.error,custom:Kt.custom,message:Kt.message,promise:Kt.promise,dismiss:Kt.dismiss,loading:Kt.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 vi(e){return e.label!==void 0}var eN=3,tN="32px",nN="16px",rx=4e3,rN=356,oN=14,sN=20,iN=200;function gn(...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:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:A,style:M,cancelButtonStyle:L,actionButtonStyle:F,className:z="",descriptionClassName:X="",duration:O,position:Y,gap:W,loadingIcon:K,expandByDefault:D,classNames:I,icons:V,closeButtonAriaLabel:Z="Close toast",pauseWhenPageIsHidden:R}=e,[q,P]=w.useState(null),[$,H]=w.useState(null),[j,_]=w.useState(!1),[G,Q]=w.useState(!1),[oe,ae]=w.useState(!1),[ve,we]=w.useState(!1),[Re,Me]=w.useState(!1),[Ye,Le]=w.useState(0),[$e,ft]=w.useState(0),Qe=w.useRef(p.duration||O||rx),gt=w.useRef(null),He=w.useRef(null),Oe=C===0,De=C+1<=y,Ce=p.type,Fe=p.dismissible!==!1,at=p.className||"",jt=p.descriptionClassName||"",lt=w.useMemo(()=>b.findIndex(de=>de.toastId===p.id)||0,[b,p.id]),Nt=w.useMemo(()=>{var de;return(de=p.closeButton)!=null?de:A},[p.closeButton,A]),pt=w.useMemo(()=>p.duration||O||rx,[p.duration,O]),kt=w.useRef(0),ct=w.useRef(0),qt=w.useRef(0),At=w.useRef(null),[Pt,xt]=Y.split("-"),We=w.useMemo(()=>b.reduce((de,ke,Ke)=>Ke>=lt?de:de+ke.height,0),[b,lt]),Ve=KI(),Et=p.invert||m,ne=Ce==="loading";ct.current=w.useMemo(()=>lt*W+We,[lt,We]),w.useEffect(()=>{Qe.current=pt},[pt]),w.useEffect(()=>{_(!0)},[]),w.useEffect(()=>{let de=He.current;if(de){let ke=de.getBoundingClientRect().height;return ft(ke),x(Ke=>[{toastId:p.id,height:ke,position:p.position},...Ke]),()=>x(Ke=>Ke.filter(ht=>ht.toastId!==p.id))}},[x,p.id]),w.useLayoutEffect(()=>{if(!j)return;let de=He.current,ke=de.style.height;de.style.height="auto";let Ke=de.getBoundingClientRect().height;de.style.height=ke,ft(Ke),x(ht=>ht.find(Ne=>Ne.toastId===p.id)?ht.map(Ne=>Ne.toastId===p.id?{...Ne,height:Ke}:Ne):[{toastId:p.id,height:Ke,position:p.position},...ht])},[j,p.title,p.description,x,p.id]);let me=w.useCallback(()=>{Q(!0),Le(ct.current),x(de=>de.filter(ke=>ke.toastId!==p.id)),setTimeout(()=>{T(p)},iN)},[p,T,x,ct]);w.useEffect(()=>{if(p.promise&&Ce==="loading"||p.duration===1/0||p.type==="loading")return;let de;return S||g||R&&Ve?(()=>{if(qt.current<kt.current){let ke=new Date().getTime()-kt.current;Qe.current=Qe.current-ke}qt.current=new Date().getTime()})():Qe.current!==1/0&&(kt.current=new Date().getTime(),de=setTimeout(()=>{var ke;(ke=p.onAutoClose)==null||ke.call(p,p),me()},Qe.current)),()=>clearTimeout(de)},[S,g,p,Ce,R,Ve,me]),w.useEffect(()=>{p.delete&&me()},[me,p.delete]);function et(){var de,ke,Ke;return V!=null&&V.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(de=p==null?void 0:p.classNames)==null?void 0:de.loader,"sonner-loader"),"data-visible":Ce==="loading"},V.loading):K?w.createElement("div",{className:gn(I==null?void 0:I.loader,(ke=p==null?void 0:p.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Ce==="loading"},K):w.createElement(BI,{className:gn(I==null?void 0:I.loader,(Ke=p==null?void 0:p.classNames)==null?void 0:Ke.loader),visible:Ce==="loading"})}return w.createElement("li",{tabIndex:0,ref:He,className:gn(z,at,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Ce],(n=p==null?void 0:p.classNames)==null?void 0:n[Ce]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":j,"data-promise":!!p.promise,"data-swiped":Re,"data-removed":G,"data-visible":De,"data-y-position":Pt,"data-x-position":xt,"data-index":C,"data-front":Oe,"data-swiping":oe,"data-dismissible":Fe,"data-type":Ce,"data-invert":Et,"data-swipe-out":ve,"data-swipe-direction":$,"data-expanded":!!(S||D&&j),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${G?Ye:ct.current}px`,"--initial-height":D?"auto":`${$e}px`,...M,...p.style},onDragEnd:()=>{ae(!1),P(null),At.current=null},onPointerDown:de=>{ne||!Fe||(gt.current=new Date,Le(ct.current),de.target.setPointerCapture(de.pointerId),de.target.tagName!=="BUTTON"&&(ae(!0),At.current={x:de.clientX,y:de.clientY}))},onPointerUp:()=>{var de,ke,Ke,ht;if(ve||!Fe)return;At.current=null;let Ne=Number(((de=He.current)==null?void 0:de.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ue=Number(((ke=He.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((Ke=gt.current)==null?void 0:Ke.getTime()),Se=q==="x"?Ne:Ue,mt=Math.abs(Se)/ut;if(Math.abs(Se)>=sN||mt>.11){Le(ct.current),(ht=p.onDismiss)==null||ht.call(p,p),H(q==="x"?Ne>0?"right":"left":Ue>0?"down":"up"),me(),we(!0),Me(!1);return}ae(!1),P(null)},onPointerMove:de=>{var ke,Ke,ht,Ne;if(!At.current||!Fe||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let Ue=de.clientY-At.current.y,ut=de.clientX-At.current.x,Se=(Ke=e.swipeDirections)!=null?Ke:aN(Y);!q&&(Math.abs(ut)>1||Math.abs(Ue)>1)&&P(Math.abs(ut)>Math.abs(Ue)?"x":"y");let mt={x:0,y:0};q==="y"?(Se.includes("top")||Se.includes("bottom"))&&(Se.includes("top")&&Ue<0||Se.includes("bottom")&&Ue>0)&&(mt.y=Ue):q==="x"&&(Se.includes("left")||Se.includes("right"))&&(Se.includes("left")&&ut<0||Se.includes("right")&&ut>0)&&(mt.x=ut),(Math.abs(mt.x)>0||Math.abs(mt.y)>0)&&Me(!0),(ht=He.current)==null||ht.style.setProperty("--swipe-amount-x",`${mt.x}px`),(Ne=He.current)==null||Ne.style.setProperty("--swipe-amount-y",`${mt.y}px`)}},Nt&&!p.jsx?w.createElement("button",{"aria-label":Z,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Fe?()=>{}:()=>{var de;me(),(de=p.onDismiss)==null||de.call(p,p)},className:gn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=V==null?void 0:V.close)!=null?s:VI):null,p.jsx||w.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:w.createElement(w.Fragment,null,Ce||p.icon||p.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||et():null,p.type!=="loading"?p.icon||(V==null?void 0:V[Ce])||$I(Ce):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?w.createElement("div",{"data-description":"",className:gn(X,jt,I==null?void 0:I.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),w.isValidElement(p.cancel)?p.cancel:p.cancel&&vi(p.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||L,onClick:de=>{var ke,Ke;vi(p.cancel)&&Fe&&((Ke=(ke=p.cancel).onClick)==null||Ke.call(ke,de),me())},className:gn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,w.isValidElement(p.action)?p.action:p.action&&vi(p.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||F,onClick:de=>{var ke,Ke;vi(p.action)&&((Ke=(ke=p.action).onClick)==null||Ke.call(ke,de),!de.defaultPrevented&&me())},className:gn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function ox(){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=w.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:f,duration:m,style:p,visibleToasts:v=eN,toastOptions:g,dir:x=ox(),gap:y=oN,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(R=>R.position).map(R=>R.position)))),[T,r]),[M,L]=w.useState([]),[F,z]=w.useState(!1),[X,O]=w.useState(!1),[Y,W]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),K=w.useRef(null),D=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),V=w.useRef(!1),Z=w.useCallback(R=>{E(q=>{var P;return(P=q.find($=>$.id===R.id))!=null&&P.delete||Kt.dismiss(R.id),q.filter(({id:$})=>$!==R.id)})},[]);return w.useEffect(()=>Kt.subscribe(R=>{if(R.dismiss){E(q=>q.map(P=>P.id===R.id?{...P,delete:!0}:P));return}setTimeout(()=>{Do.flushSync(()=>{E(q=>{let P=q.findIndex($=>$.id===R.id);return P!==-1?[...q.slice(0,P),{...q[P],...R},...q.slice(P+1)]:[R,...q]})})})}),[]),w.useEffect(()=>{if(d!=="system"){W(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?W("dark"):W("light")),typeof window>"u")return;let R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:q})=>{W(q?"dark":"light")})}catch{R.addListener(({matches:P})=>{try{W(P?"dark":"light")}catch($){console.error($)}})}},[d]),w.useEffect(()=>{T.length<=1&&z(!1)},[T]),w.useEffect(()=>{let R=q=>{var P,$;o.every(H=>q[H]||q.code===H)&&(z(!0),(P=K.current)==null||P.focus()),q.code==="Escape"&&(document.activeElement===K.current||($=K.current)!=null&&$.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[o]),w.useEffect(()=>{if(K.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,V.current=!1)}},[K.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((R,q)=>{var P;let[$,H]=R.split("-");return T.length?w.createElement("ol",{key:R,dir:x==="auto"?ox():x,tabIndex:-1,ref:K,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":$,"data-lifted":F&&T.length>1&&!s,"data-x-position":H,style:{"--front-toast-height":`${((P=M[0])==null?void 0:P.height)||0}px`,"--width":`${rN}px`,"--gap":`${y}px`,...p,...cN(l,c)},onBlur:j=>{V.current&&!j.currentTarget.contains(j.relatedTarget)&&(V.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:j=>{j.target instanceof HTMLElement&&j.target.dataset.dismissible==="false"||V.current||(V.current=!0,I.current=j.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{X||z(!1)},onDragEnd:()=>z(!1),onPointerDown:j=>{j.target instanceof HTMLElement&&j.target.dataset.dismissible==="false"||O(!0)},onPointerUp:()=>O(!1)},T.filter(j=>!j.position&&q===0||j.position===R).map((j,_)=>{var G,Q;return w.createElement(lN,{key:j.id,icons:C,index:_,toast:j,defaultRichColors:f,duration:(G=g==null?void 0:g.duration)!=null?G:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:X,position:R,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:Z,toasts:T.filter(oe=>oe.position==j.position),heights:M.filter(oe=>oe.position==j.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:F,pauseWhenPageIsHidden:S,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})};B.Api=qv,B.ApiClient=Kv,B.ApiProvider=iu,B.ArtifactRenderer=Nh,B.Badge=$h,B.Button=Je,B.Card=ul,B.CardContent=Qs,B.CardDescription=pl,B.CardHeader=dl,B.CardTitle=fl,B.ChatApi=Xo,B.ChatApp=Vk,B.ChatInput=Gf,B.ChatInputRow=Yf,B.ChatInterface=Dr,B.ChatProviders=yr,B.ChatWidget=Gk,B.Command=Tl,B.CommandEmpty=Il,B.CommandGroup=Nl,B.CommandInput=kl,B.CommandItem=Al,B.CommandList=El,B.DEFAULT_TIMEOUT_MS=eu,B.Dialog=ol,B.DialogContent=Us,B.DialogHeader=Ws,B.DialogTitle=Vs,B.DropdownMenu=ks,B.DropdownMenuContent=go,B.DropdownMenuItem=Fn,B.DropdownMenuTrigger=Es,B.FileViewerModal=ph,B.HISTORY_TIMEOUT_MS=tu,B.Input=Dl,B.InterruptPartRenderer=hl,B.Label=vm,B.MarkdownContent=cr,B.MessageComponent=ei,B.MessageList=xl,B.MessageRow=gl,B.NewChatButton=Yk,B.PlotArtifact=Ih,B.SETTINGS_STORAGE_KEY=Ui,B.ScrollArea=Ol,B.Select=NE,B.SelectContent=sg,B.SelectItem=ig,B.SelectTrigger=ng,B.SelectValue=AE,B.Separator=ug,B.Sheet=BE,B.SheetContent=wg,B.SheetDescription=Sg,B.SheetHeader=bg,B.SheetTitle=yg,B.SheetTrigger=zE,B.SimpleChat=Kk,B.SimpleJsonView=Zs,B.Sonner=dN,B.StreamProgress=Ah,B.Switch=xg,B.Textarea=Aa,B.ThinkingIndicator=Ph,B.ThreadListItem=fm,B.ThreadManager=ii,B.ThreadStateProvider=ju,B.ThreadsProvider=xu,B.TimelineColumn=Cx,B.Toaster=RI,B.ToolComponent=Dh,B.Tooltip=uI,B.TooltipContent=Pg,B.TooltipProvider=cI,B.TooltipTrigger=dI,B.UserTextContent=_h,B.applySettings=Nw,B.buildCheckpointIndex=rc,B.buildCheckpointPreviewMap=dx,B.chatApiClient=Nn,B.del=Oi,B.downloadFileById=ru,B.extractConfigFields=yi,B.fileToBase64=au,B.get=Jt,B.getChatToken=Zc,B.getCheckpointForMessage=fx,B.getCurrentSettings=Iw,B.getDefaultApiConfig=Fu,B.getDefaultChatSettings=Bu,B.getFileContent=Li,B.getFileInfo=Yv,B.getMessageAttemptInfo=oc,B.getMessageDomKey=ml,B.getPreviewForMessage=bi,B.httpClient=Xt,B.hydrateHistorySnapshots=Yn,B.isEnvelope=cu,B.listFiles=ou,B.loadStoredSettings=zu,B.onChatTokenChanged=Qc,B.post=Yo,B.processAttachments=lu,B.put=nu,B.readNumber=ic,B.readString=Rn,B.resolveChatBaseUrl=vn,B.saveSettings=Hu,B.setChatToken=Go,B.toPlainObject=_n,B.unwrap=Lt,B.useApi=Qr,B.useCheckpointIndex=sc,B.useFilePreview=Rh,B.useHasChatSession=Tw,B.useParsedMessageContent=Mh,B.useShallowStableValue=Ou,B.useStream=Hi,B.useStreamingHook=Hi,B.useThreadHistoryState=Eu,B.useThreadManagerViewState=mm,B.useThreadState=ro,B.useThreadStateUpdater=Au,B.useThreads=vr,B.useThreadsState=mu,B.viewFileById=Gv,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(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 Eh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...he.defaults,...s};const i=zT(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($T(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&&he.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;he.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return c(m);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(he.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&&he.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function he(e,t,n){return Eh(Wn.lex,Vn.parse)(e,t,n)}he.options=he.setOptions=function(e){return he.defaults={...he.defaults,...e},kT(he.defaults),he},he.getDefaults=hh,he.defaults=lr,he.use=function(...e){const t=he.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=he.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=he.defaults.renderer||new cl;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=he.defaults.tokenizer||new ll;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=he.defaults.hooks||new Js;for(const s in n.hooks){const i=o[s];Js.passThroughHooks.has(s)?o[s]=a=>{if(he.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=he.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}}he.setOptions(r)})},he.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(he,r)),r.type){case"table":{for(const o of r.header)n=n.concat(he.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(he.walkTokens(s.tokens,t));break}case"list":{n=n.concat(he.walkTokens(r.items,t));break}default:he.defaults.extensions&&he.defaults.extensions.childTokens&&he.defaults.extensions.childTokens[r.type]?he.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(he.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(he.walkTokens(r.tokens,t)))}return n},he.parseInline=Eh(Wn.lexInline,Vn.parseInline),he.Parser=Vn,he.parser=Vn.parse,he.Renderer=cl,he.TextRenderer=Th,he.Lexer=Wn,he.lexer=Wn.lex,he.Tokenizer=ll,he.Slugger=kh,he.Hooks=Js,he.parse=he,he.options,he.setOptions,he.use,he.walkTokens,he.parseInline,Vn.parse,Wn.lex;function cr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.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 he.parse=="function"?he.parse(i):he(i)}return typeof he.parse=="function"?he.parse(e):he(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=w.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:te("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 Ih({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Nh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>dw(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Ih,{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 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 Zs({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:wr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:wr(e)})}function Ah({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.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}const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ul.displayName="Card";const dl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));dl.displayName="CardHeader";const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));fl.displayName="CardTitle";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));pl.displayName="CardDescription";const Qs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));Qs.displayName="CardContent";const jh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));jh.displayName="CardFooter";const UT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function hl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=UT(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const f=wr(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:f})}return u.jsxs(ul,{className:te("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(dl,{className:"pb-3",children:[u.jsx(fl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(pl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(Qs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(f=>u.jsx(Ze,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(Qs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(jh,{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:o||!s,children:"Reject"}),u.jsx(Ze,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function Ph({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function _h({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:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(cr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("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)"]})})]})}function Rh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=al(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),f=w.useCallback(p=>{a(p),c(!0)},[]),m=w.useCallback(async(p,v,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){p.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";f({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){p.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await ou(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.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(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.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(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Mh(e,t){return w.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:sw(r),toolMeta:Fi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:iw(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Oh="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(Oh))continue;const s=o.slice(Oh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=to(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 w.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=to(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 Dh({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o}){var C;const s=Fi(e),i=e.artifact??null,a=qT(e),l=e.content.find(k=>k.type!=="tool_call"),c=k=>{if(k==null)return null;const S=typeof k=="string"?to(k)??k:k;if(S&&typeof S=="object")return u.jsx(Zs,{data:S});const T=typeof S=="string"?S:(()=>{try{return wr(S)}catch{return String(S??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:T})},d=k=>{if(k==null)return null;const{content:S,isMarkdown:T}=ow(k);return T?u.jsx(cr,{content:S,className:"text-current"}):c(k)},f=k=>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(Zs,{data:k})]}),m=()=>{if((a==null?void 0:a.kind)==="generic")return d(a.value);if(!l)return null;if(l.type==="text"){const E=(l.text??"").trim();if(!E)return null;const A=br(E);return d(A)}const k=no(l),S=br(k);return d(S)},p=()=>(a==null?void 0:a.kind)==="dict"?f(a.data):m(),g=(()=>{if(r){if(s.name){const k=r[s.name];if(k)return k}if(a!=null&&a.kind){const k=r[a.kind];if(k)return k}return r.default}})(),x=(g==null?void 0:g({message:e,toolMeta:s,toolPayload:a,viewMode:t,isStreaming:n}))??null,b=((C=(()=>{if(!o)return;const k=i==null?void 0:i.type;if(typeof k=="string"){const S=o[k];if(S)return S}return o.default})())==null?void 0:C({artifact:i,message:e,toolPayload:a,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[i&&(b??u.jsx(Nh,{artifact:i,idx:0})),u.jsx(Ah,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:x??p()})]})}const GT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},ml=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,gl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,toolRenderers:x,toolArtifactRenderers:y}){const b=ml(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming,T=p??GT,E=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:A,attemptIndex:_,attempts:L}=w.useMemo(()=>oc(t.id,E,T),[t.id,E,T]),F=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":b,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ei,{message:t,messageIndex:n,isStreamingMessage:S||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,showToolMessages:m,attemptCount:A,attemptIndex:_,attemptMetas:L,onSelectCheckpoint:v,customStyles:F,toolRenderers:x,toolArtifactRenderers:y})})});gl.displayName="MessageRow";function YT(e,t,n){const[r,o]=w.useState(e),s=w.useRef([]);return w.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,interruptPart:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:v,uploadingFiles:g,messageRole:x,truncateUserMessages:y,userMessagePreviewLength:b,isUserExpanded:C,setIsUserExpanded:k,isCompactLayout:S,iconForeground:T,toolRenderers:E,toolArtifactRenderers:A,handleInterruptApprove:_,handleInterruptReject:L,handleInterruptAlternative:F,disableInterruptActions:U,isInterruptMessage:X}){const O=w.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"})]}),[]),V=YT(s,(f??!0)&&d,Lh),K=w.useMemo(()=>V.filter(z=>z.type==="text"),[V]),D=w.useMemo(()=>K.map(z=>z.text??"").join(""),[K]),I=w.useMemo(()=>{if(!m)return null;const z=JT(D);return{stablePart:D.slice(0,z),tailPart:D.slice(z)}},[D,m]),q=w.useMemo(()=>{if(!I)return null;const{stablePart:z,tailPart:j}=I;return!z&&!j?null:u.jsxs("div",{className:"space-y-2",children:[z?u.jsx(cr,{content:z,allowHtml:!1}):null,j?u.jsx(cr,{content:j,allowHtml:!1}):null]})},[I]),J=w.useMemo(()=>{if(!m)return V;const z=[];let j=!1;for(const R of V){if(R.type==="text"){j||(z.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),j=!0);continue}z.push(R)}return z},[V,m]),B=(m?J:V).filter(z=>z.type!=="interrupt"),P=w.useCallback(({part:z,i:j})=>{if(z.type==="text"){if(m)return null;const R=z.text??"",G=R.trim(),Q=to(G);return Q&&x!=="tool"?u.jsx(Zs,{data:Q},j):x==="user"&&y&&G.length>b?u.jsx(_h,{text:G,expanded:C,onExpandedChange:k,previewLength:b,isCompact:S},j):u.jsx(cr,{content:R,allowHtml:!1},j)}if(z.type==="image_url"){const R=z;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:R.url,alt:R.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},j)}if(z.type==="file"){const R=z,G=R.name||"file";return u.jsxs("a",{href:R.url,onClick:Q=>v(Q,R,j),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[j]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[G,g[j]?" (processing)":""]})]},j)}return null},[v,S,C,x,y,g,b,m,k]),$=i.trim().length>0||a.length>0||l.length>0||B.length>0;if(!t&&l.length>0&&!d)return O();if(!t&&!$&&!d)return null;if(t){if(!n)return null;if(X&&c){const z=c.value,j=!U,R=_??(()=>{}),G=L??(()=>{});return u.jsx(hl,{interruptPart:c,payload:z,onApprove:R,onReject:G,onSelectAlternative:F,disabled:U,isActive:j})}return u.jsx(Dh,{message:e,viewMode:r,isStreaming:o,toolRenderers:E,toolArtifactRenderers:A},e.id)}if(!p){const z=u.jsx("div",{className:"space-y-2",children:B.map((j,R)=>m&&ZT(j)?q?u.jsx("div",{className:"space-y-2",children:q},`streaming-md-${R}`):null:u.jsx(P,{part:j,i:R},R))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[z,u.jsx(Ph,{className:T})]}):z}return null}function Lh(e){return e?!(jo(e,/```/g)||jo(e,/`/g)||jo(e,/\*\*/g)||jo(e,/__/g)||jo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function jo(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(Lh(e.slice(0,t)))return t;return 0}function ZT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const QT=Ur.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 $h({className:e,variant:t,...n}){return u.jsx("div",{className:te(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:f,messageRole:m,toolViewMode:p,toolMeta:v,onToggleToolView:g,onCopy:x,onEdit:y,onRegenerate:b,showCheckpointControls:C,attemptCount:k,attemptIndex:S,handleOlderAttemptSelect:T,handleNewerAttemptSelect:E,messageCreatedAt:A,copied:_}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:te("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs($h,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",o,"border border-current/40",c&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":p==="expanded",onClick:g,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),g())},children:[u.jsx("span",{children:v.name??"Tool Output"}),v.toolCallId&&u.jsx("span",{className:"opacity-70",children:v.toolCallId.slice(0,8)}),p==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:v.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[C&&k>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S<k-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=k-1||T()},"aria-label":"Older attempt (back in time)",disabled:S>=k-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:[k-S," / ",k]})}),u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||E()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&A&&u.jsx("time",{className:te("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(A).toISOString(),title:new Date(A).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(A))}),d&&!f&&u.jsxs("div",{className:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Ze,{variant:"ghost",size:"sm",onClick:x,className:te("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:te(_?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&y&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:y,className:te("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:te(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&b&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:b,className:te("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:te(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ei=w.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,toolRenderers:m,toolArtifactRenderers:p,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:C,onCopy:k,getInterruptOptions:S,attemptCount:T=1,attemptIndex:E=0,onSelectCheckpoint:A,attemptMetas:_=[]}){const[L,F]=w.useState(!1),[U,X]=w.useState("preview"),[O,Y]=w.useState(!1),{currentThreadId:V}=vr(),{respondToInterrupt:K}=ro(),[D,I]=w.useState(!1),q=l==="phone"||l==="half-screen",J=t.role,M=J==="interrupt",B=J==="tool"||M,$=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,z=w.useMemo(()=>t.role==="default_message"?t:null,[t]),j=!!z,R=!(r&&J!=="user"),{uploadingFiles:G,handleFileClick:Q,fileViewerOpen:se,currentFileInfo:ie,closeFileViewer:Se}=Rh({allowFileOpen:R,currentThreadId:V}),xe=w.useMemo(()=>{switch(J){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[J]),Oe=Mh(t,z),{contentParts:De,imageParts:Ge,fileParts:Ye,textContent:He,toolMeta:st,toolRaw:Xe,isToolStreaming:St,interruptParts:Le}=Oe,Ve=y??g!==0,je=w.useMemo(()=>Le.length?Le[0]:null,[Le]),Ie=w.useCallback(async()=>{const Pe=B?Xe:He;async function Ke(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 et=new Blob([we],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":et})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Ke(Pe),F(!0),setTimeout(()=>F(!1),2e3),k==null||k(Pe)}catch(we){console.error("Failed to copy:",we)}},[B,Xe,He,k]),Ne=w.useCallback(async(Pe,Ke)=>{if(!je)return;if(!wu(je.id)){console.warn("Interrupt part missing id",je);return}I(!0);try{const et=S==null?void 0:S(t);await K(Pe,Ke,et)}catch(et){console.error("Failed to respond to interrupt:",et)}finally{I(!1)}},[je,K]),ut=w.useCallback(()=>Ne(!0),[Ne]),jt=w.useCallback(()=>Ne(!1),[Ne]),ft=w.useCallback((Pe,Ke)=>{if(!Ke)return;const we={alternativeId:Ke.id??Ke.label??void 0,alternativeLabel:Ke.label};Ne(!0,we)},[Ne]),At=w.useCallback(()=>{if(!b||!t.id)return;const Pe=(B?Xe:He)??"",Ke="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,Pe,Ke)},[b,B,Xe,He,t]),pt=w.useCallback(()=>{C==null||C(n)},[C,n]),Ct=!M&&$,lt=w.useCallback(()=>{Ct&&X(Pe=>Pe==="expanded"?"preview":"expanded")},[Ct]),Tt=M||$?"expanded":U,Dt=w.useCallback(()=>{const Ke=te(q?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",xe);switch(J){case"user":return u.jsx(le.User,{className:Ke});case"assistant":return u.jsx(le.Bot,{className:Ke});case"tool":return u.jsx(le.Wrench,{className:Ke});case"interrupt":return u.jsx(le.Bot,{className:Ke});default:return u.jsx(le.Bot,{className:Ke})}},[q,xe,J]),mt=w.useCallback(()=>{const Pe="group relative mb-4 flex w-full";switch(J){case"user":return te(Pe,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return te(Pe,"justify-start");default:return Pe}},[J]),ze=w.useCallback(()=>{const Pe=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",q&&"px-3 py-2 text-sm");if(j)return te(Pe,"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(J){case"user":return te(Pe,"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 te(Pe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":case"interrupt":return te(Pe,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(Pe,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(Pe,"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")}},[q,j,J]),Ue=(f||M)&&$,It=u.jsx(XT,{message:t,isToolMessage:B,showToolMessages:Ue,toolViewMode:Tt,isToolStreaming:St,contentParts:De,textContent:He,imageParts:Ge,fileParts:Ye,isStreamingMessage:r,defaultMessage:z,enableStreamingMarkdownBuffer:Ve,renderStreamingMarkdown:x,handleFileClick:Q,uploadingFiles:G,messageRole:J,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:O,setIsUserExpanded:Y,isCompactLayout:q,iconForeground:xe,toolRenderers:m,toolArtifactRenderers:p,interruptPart:je,handleInterruptApprove:ut,handleInterruptReject:jt,handleInterruptAlternative:ft,disableInterruptActions:D,isInterruptMessage:M}),ne=w.useMemo(()=>z?"Assistant":aw(t),[z,t]),me=Dt(),rt=J==="user"&&(T??1)>1&&typeof A=="function",de=(_==null?void 0:_.length)??0,Te=de>0&&E<de-1?_[E+1]:void 0,$e=de>0&&E>0?_[E-1]:void 0,ht=w.useCallback(()=>{!Te||!A||A(Te.id,void 0,!!Te.isLatestAttempt)},[Te,A]),wt=w.useCallback(()=>{!$e||!A||A($e.id,void 0,!!$e.isLatestAttempt)},[$e,A]);return B&&!f?null:j&&z?u.jsx("div",{className:te(mt(),v.container),children:u.jsxs("div",{className:te(ze(),v.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:te("h-4 w-4",xe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:z.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(mt(),v.container),children:u.jsxs("div",{className:te(ze(),v.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:xe,agentName:ne,messageIcon:me,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:q,showActions:s,isEditing:o,messageRole:J,toolViewMode:Tt,isInterruptMessage:M,toolMeta:st,onToggleToolView:lt,onCopy:Ie,onEdit:At,onRegenerate:pt,showCheckpointControls:rt,attemptCount:T,attemptIndex:E,handleOlderAttemptSelect:ht,handleNewerAttemptSelect:wt,messageCreatedAt:t.createdAt,copied:L}),u.jsx("div",{className:"relative",children:It}),B&&Tt==="expanded"&&(st.toolCallId||st.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",q&&"text-xs"),children:[st.name&&u.jsxs("div",{children:["Function: ",st.name]}),st.toolCallId&&u.jsxs("div",{children:["Call ID: ",st.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>Ie(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:u.jsx(le.Copy,{className:te(L?"text-success":"text-current",q?"h-3 w-3":"h-4 w-4")})}),J==="user"&&b&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:At,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:u.jsx(le.Edit,{className:te("text-current",q?"h-3 w-3":"h-4 w-4")})}),J==="assistant"&&C&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:pt,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:te("text-current",q?"h-3 w-3":"h-4 w-4")})})]})]})}),ie&&u.jsx(ph,{isOpen:se,onClose:Se,fileId:ie.id,fileName:ie.name,mimeType:ie.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&bu(e.message)===bu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=yu(e.message),a=yu(t.message);return i.length===a.length});ei.displayName="MessageComponent";const xl=w.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:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:_=!1,getMessageCustomStyles:L},F)=>{const U=w.useRef(null),X=w.useRef(null),O=w.useRef(!1),Y=w.useRef(!1),V=e,K=w.useMemo(()=>{const j=n&&V.some(G=>G.id===n);return A&&(t||_)&&!j&&V.length>0?[...V,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:V},[V,t,n,A,_]),D=w.useMemo(()=>b?K:K.filter(j=>(j==null?void 0:j.role)!=="tool"),[K,b]),I=w.useCallback(j=>{x&&x(!j),y&&y(j)},[x,y]),q=w.useMemo(()=>{if(a)return async()=>{if(!O.current){O.current=!0;try{await a()}finally{O.current=!1}}}},[a]),J=w.useMemo(()=>!v||g?!1:"auto",[v,g]),M=w.useMemo(()=>{if(typeof p!="string")return null;const j=p.trim();return!j||D&&D.length>0?null:{id:"default-message",role:"default_message",content:j,createdAt:new Date().toISOString()}},[p,D]),B=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),P=()=>{if(M){const j=L==null?void 0:L(M);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ei,{message:M,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:j})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},$=D.length,z=$>0;return w.useEffect(()=>{var j,R;if($===0){Y.current=!1;return}if(!Y.current)if(Y.current=!0,U.current&&D.length>0){const G=D.length-1;(R=(j=U.current).scrollToIndex)==null||R.call(j,{index:G,align:"end",behavior:"auto"})}else X.current&&(X.current.scrollTop=X.current.scrollHeight)},[$,D.length]),w.useImperativeHandle(F,()=>({scrollToLatest:()=>{var j,R;if(U.current&&D.length>0){const G=D.length-1;(R=(j=U.current).scrollToIndex)==null||R.call(j,{index:G,align:"end",behavior:"auto"})}else X.current&&(X.current.scrollTop=X.current.scrollHeight)},scrollToTop:()=>{var j,R;U.current&&D.length>0?(R=(j=U.current).scrollToIndex)==null||R.call(j,{index:0,align:"start",behavior:"auto"}):X.current&&(X.current.scrollTop=0)}}),[D]),u.jsx("div",{className:B,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:z?u.jsx(qC,{ref:j=>{U.current=j},scrollerRef:j=>{X.current=j instanceof HTMLDivElement?j:null},data:D,followOutput:J,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{q&&q()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(j,R)=>ml(R,j),itemContent:(j,R)=>u.jsx(gl,{message:R,index:j,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:b,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,getMessageCustomStyles:L})}):P()})})});xl.displayName="MessageList";const Fh={value:""};function Dr({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,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=Qr(),S=k.baseUrl,{currentThreadId:T}=vr(),{threadId:E,messages:A,isLoading:_,navigateToCheckpoint:L,returnToLatest:F,checkpoint:U,checkpoints:X,interrupt:O,metadata:Y,checkpointIndex:V,respondToInterrupt:K}=ro(),{isStreaming:D,error:I,connectionState:q,submit:J,stop:M}=Hi(),B=E??T??null,P=(U==null?void 0:U.id)??null,$=(U==null?void 0:U.namespace)??null,z=(Y==null?void 0:Y.assemblingMessageId)??null,j=O,R=j?wu(j.id):null,G=R!==null?{type:"interrupt",id:R}:null,[Q,se]=w.useState(!1),[ie,Se]=w.useState(!1);w.useEffect(()=>{j||se(!1)},[j]);const xe=w.useCallback(()=>{se(!0)},[]),Oe=w.useCallback(()=>{se(!1)},[]),De=w.useCallback(async(_e,N,Z)=>{try{xe(),await K(_e,N,Z)}catch(re){console.error("Failed to respond to interrupt:",re)}finally{Oe()}},[Oe,xe,K]),Ge=w.useCallback(()=>De(!0),[De]),Ye=w.useCallback(()=>De(!1),[De]),He=w.useCallback((_e,N)=>De(!0,N),[De]),st=!!j||Q,[Xe,St]=w.useState(null),[Le,Ve]=w.useState(""),[je,Ie]=w.useState(null),[Ne,ut]=w.useState(null),[jt,ft]=w.useState(!1),[At,pt]=w.useState(null),Ct=w.useRef(!1),[lt,gn]=w.useState(()=>Fh.value),Tt=w.useRef(lt),Dt=w.useRef(null),mt=w.useCallback(_e=>{Fh.value=_e,gn(_e)},[]),[ze,Ue]=w.useState(!1),It=w.useRef(null),ne=w.useCallback(_e=>{mt(_e)},[mt]);w.useEffect(()=>{D||Se(!1)},[D]),w.useEffect(()=>{Y!=null&&Y.assemblingMessageId&&Se(!1)},[Y==null?void 0:Y.assemblingMessageId]);const[me,rt]=w.useState("desktop");w.useEffect(()=>{const _e=()=>{const N=window.innerWidth;rt(N<640?"phone":N<1024?"tablet":"desktop")};return _e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)},[]),w.useEffect(()=>{Ct.current=!1},[B]),w.useEffect(()=>{Tt.current=lt},[lt]),w.useEffect(()=>{if(!Xe){Dt.current=null;return}Dt.current===null&&(Dt.current=Tt.current),mt(Le??"")},[Le,Xe,mt]),w.useEffect(()=>{if(C!==void 0){pt(C);return}(async()=>{if(!S){pt(null);return}try{const Z=(await k.getAgent("default")).uiDefaultMessage||"";pt(Z||null)}catch(N){console.warn("Failed to fetch default message:",N),pt(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!jt&&(b==null||b(I))},[I,jt,b]);const de=async(_e,N)=>{const Z=_e.trim();if(!(!Z&&N.length===0))try{const re=Xe?(je==null?void 0:je.checkpointId)??P??void 0:P??void 0,ge=Xe?(je==null?void 0:je.checkpointNs)??$??void 0:$??void 0;await J({text:Z||"",attachments:N,payload:p},{checkpointId:re,checkpointNs:ge,edit:!!Xe,originalMessageId:Xe??void 0}),x==null||x(Z),Se(!0),mt(""),ut(null),St(null),Ve(""),Ie(null)}catch(re){const ge=(re==null?void 0:re.message)||"Failed to send message";ut(ge),b==null||b(ge),Se(!1)}},Te=w.useCallback(async _e=>{await J({attachments:[_e],payload:p},{checkpointId:P??void 0,checkpointNs:$??void 0}),y==null||y({file:_e})},[P,$,p,y,J]),$e=w.useCallback((_e,N,Z)=>{c&&(Dt.current=lt,St(_e),Ve(N),mt(N),ut(null),Ie({checkpointId:(Z==null?void 0:Z.checkpointId)??null,checkpointNs:(Z==null?void 0:Z.checkpointNs)??null}))},[lt,c,mt]),ht=w.useCallback(()=>{St(null),Ve(""),Ie(null),ut(null),mt(Dt.current??lt),Dt.current=null},[lt,mt]),wt=w.useCallback((_e,N,Z)=>{$e(_e,N,Z)},[$e]),Pe=w.useCallback(_e=>{let N=null;for(let Ae=_e-1;Ae>=0;Ae--)if(A[Ae].role==="user"){N=A[Ae];break}if(!N)return;const Z=Array.isArray(N.content)?N.content:[],ge=Z.filter(Ae=>(Ae==null?void 0:Ae.type)==="text").map(Ae=>Ae.text).join("")||(()=>{try{return JSON.stringify(Z,null,2)}catch{return String(Z)}})();ge&&J({text:ge,payload:p},{checkpointId:P??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:N.id})},[A,J,P,$,p]),Ke=w.useCallback(async _e=>{if(T){Ue(!0);try{if(!_e){await F(),requestAnimationFrame(()=>{var re;(re=It.current)==null||re.scrollToLatest()});return}const N=X.find(re=>re.checkpointId===_e),Z=(N==null?void 0:N.checkpointNs)??null;await L(_e,Z),requestAnimationFrame(()=>{var re;(re=It.current)==null||re.scrollToTop()})}finally{Ue(!1)}}},[X,T,It,L,F]),we=w.useCallback(async(_e,N,Z)=>{await Ke(Z?null:_e)},[Ke]),et=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,Je=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${j?"pb-32":""} bg-transparent ${v.messagesArea||""}`,dt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:et,children:[!!I&&!jt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>ft(!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 ${Je}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(xl,{ref:It,className:"h-full",style:{height:"100%"},messages:A,isStreaming:D,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:me,enableMessageEditing:c,editingMessageId:Xe,onEdit:wt,onRegenerate:Pe,onCancelEdit:ht,emptyMessage:At??void 0,isNavigatingCheckpoint:ze,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:V,activeCheckpointId:P,onSelectCheckpoint:we,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ie,getMessageCustomStyles:g}),(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"}),_&&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…"})]}),ze&&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…"})]}),j&&G&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(hl,{interruptPart:G,onApprove:Ge,onReject:Ye,onSelectAlternative:He,disabled:Q,isActive:!0,payload:j.value})})})]}),u.jsxs("div",{className:dt,children:[Xe&&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:ht,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),Ne&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Ne}),u.jsx(LS,{composerValue:lt,onComposerChange:ne,onSend:de,onCancelEdit:ht,onStop:M,editingMessageId:Xe,editingInitialValue:Le,placeholder:Xe?"Edit your message...":t,isStreaming:D,disabled:st,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Te,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:Ne})]})]})}var Bh=1,tk=.9,nk=.8,rk=.17,vl=.1,wl=.999,ok=.9999,sk=.99,ik=/[\\\/_+.#"@\[\(\{&]/,ak=/[\\\/_+.#"@\[\(\{&]/g,lk=/[\s-]/,zh=/[\s-]/g;function bl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Bh: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,p,v;c>=0;)f=bl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Bh:ik.test(e.charAt(c-1))?(f*=nk,p=e.slice(o,c-1).match(ak),p&&o>0&&(f*=Math.pow(wl,p.length))):lk.test(e.charAt(c-1))?(f*=tk,v=e.slice(o,c-1).match(zh),v&&o>0&&(f*=Math.pow(wl,v.length))):(f*=rk,o>0&&(f*=Math.pow(wl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ok)),(f<vl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=bl(e,t,n,r,c+1,s+2,i),m*vl>f&&(f=m*vl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Hh(e){return e.toLowerCase().replace(zh," ")}function ck(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,bl(e,t,Hh(e),Hh(t),0,0,{})}var Po='[cmdk-group=""]',yl='[cmdk-group-items=""]',uk='[cmdk-group-heading=""]',Uh='[cmdk-item=""]',Wh=`${Uh}:not([aria-disabled="true"])`,Sl="cmdk-item-select",Lr="data-value",dk=(e,t,n)=>ck(e,t,n),Vh=h.createContext(void 0),_o=()=>h.useContext(Vh),Kh=h.createContext(void 0),Cl=()=>h.useContext(Kh),qh=h.createContext(void 0),Gh=h.forwardRef((e,t)=>{let n=$r(()=>{var M,B;return{search:"",value:(B=(M=e.value)!=null?M:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=$r(()=>new Set),o=$r(()=>new Map),s=$r(()=>new Map),i=$r(()=>new Set),a=Yh(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),C=_t(),k=_t(),S=h.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,E.emit()}},[d]),ur(()=>{T(6,X)},[]);let E=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,B,P)=>{var $,z,j,R;if(!Object.is(n.current[M],B)){if(n.current[M]=B,M==="search")U(),L(),T(1,F);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(k);G?G.focus():($=document.getElementById(b))==null||$.focus()}if(T(7,()=>{var G;n.current.selectedItemId=(G=O())==null?void 0:G.id,E.emit()}),P||T(5,X),((z=a.current)==null?void 0:z.value)!==void 0){let G=B??"";(R=(j=a.current).onValueChange)==null||R.call(j,G);return}}E.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=h.useMemo(()=>({value:(M,B,P)=>{var $;B!==(($=s.current.get(M))==null?void 0:$.value)&&(s.current.set(M,{value:B,keywords:P}),n.current.filtered.items.set(M,_(B,P)),T(2,()=>{L(),E.emit()}))},item:(M,B)=>(r.current.add(M),B&&(o.current.has(B)?o.current.get(B).add(M):o.current.set(B,new Set([M]))),T(3,()=>{U(),L(),n.current.value||F(),E.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let P=O();T(4,()=>{U(),(P==null?void 0:P.getAttribute("id"))===M&&F(),E.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function _(M,B){var P,$;let z=($=(P=a.current)==null?void 0:P.filter)!=null?$:dk;return M?z(M,n.current.search,B):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,B=[];n.current.filtered.groups.forEach($=>{let z=o.current.get($),j=0;z.forEach(R=>{let G=M.get(R);j=Math.max(G,j)}),B.push([$,j])});let P=S.current;Y().sort(($,z)=>{var j,R;let G=$.getAttribute("id"),Q=z.getAttribute("id");return((j=M.get(Q))!=null?j:0)-((R=M.get(G))!=null?R:0)}).forEach($=>{let z=$.closest(yl);z?z.appendChild($.parentElement===z?$:$.closest(`${yl} > *`)):P.appendChild($.parentElement===P?$:$.closest(`${yl} > *`))}),B.sort(($,z)=>z[1]-$[1]).forEach($=>{var z;let j=(z=S.current)==null?void 0:z.querySelector(`${Po}[${Lr}="${encodeURIComponent($[0])}"]`);j==null||j.parentElement.appendChild(j)})}function F(){let M=Y().find(P=>P.getAttribute("aria-disabled")!=="true"),B=M==null?void 0:M.getAttribute(Lr);E.setState("value",B||void 0)}function U(){var M,B,P,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let z=0;for(let j of r.current){let R=(B=(M=s.current.get(j))==null?void 0:M.value)!=null?B:"",G=($=(P=s.current.get(j))==null?void 0:P.keywords)!=null?$:[],Q=_(R,G);n.current.filtered.items.set(j,Q),Q>0&&z++}for(let[j,R]of o.current)for(let G of R)if(n.current.filtered.items.get(G)>0){n.current.filtered.groups.add(j);break}n.current.filtered.count=z}function X(){var M,B,P;let $=O();$&&(((M=$.parentElement)==null?void 0:M.firstChild)===$&&((P=(B=$.closest(Po))==null?void 0:B.querySelector(uk))==null||P.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function O(){var M;return(M=S.current)==null?void 0:M.querySelector(`${Uh}[aria-selected="true"]`)}function Y(){var M;return Array.from(((M=S.current)==null?void 0:M.querySelectorAll(Wh))||[])}function V(M){let B=Y()[M];B&&E.setState("value",B.getAttribute(Lr))}function K(M){var B;let P=O(),$=Y(),z=$.findIndex(R=>R===P),j=$[z+M];(B=a.current)!=null&&B.loop&&(j=z+M<0?$[$.length-1]:z+M===$.length?$[0]:$[z+M]),j&&E.setState("value",j.getAttribute(Lr))}function D(M){let B=O(),P=B==null?void 0:B.closest(Po),$;for(;P&&!$;)P=M>0?bk(P,Po):yk(P,Po),$=P==null?void 0:P.querySelector(Wh);$?E.setState("value",$.getAttribute(Lr)):K(M)}let I=()=>V(Y().length-1),q=M=>{M.preventDefault(),M.metaKey?I():M.altKey?D(1):K(1)},J=M=>{M.preventDefault(),M.metaKey?V(0):M.altKey?D(-1):K(-1)};return h.createElement(fe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:M=>{var B;(B=y.onKeyDown)==null||B.call(y,M);let P=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||P))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&q(M);break}case"ArrowDown":{q(M);break}case"p":case"k":{x&&M.ctrlKey&&J(M);break}case"ArrowUp":{J(M);break}case"Home":{M.preventDefault(),V(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let $=O();if($){let z=new Event(Sl);$.dispatchEvent(z)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:Tk},l),ti(e,M=>h.createElement(Kh.Provider,{value:E},h.createElement(Vh.Provider,{value:A},M))))}),fk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(qh),a=_o(),l=Yh(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=Xh(o,s,[e.value,e.children,s],e.keywords),f=Cl(),m=Kn(T=>T.value&&T.value===d.current),p=Kn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Sl,v),()=>T.removeEventListener(Sl,v)},[p,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(!p)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(fe.div,{ref:Mn(s,t),...S,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)}),pk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),l=h.useRef(null),c=_t(),d=_o(),f=Kn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Xh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(fe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ti(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(qh.Provider,{value:m},p))))}),hk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(fe.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),mk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Cl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(fe.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=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),h.createElement(fe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ti(e,c=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),xk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(nl,{open:n,onOpenChange:r},h.createElement(rl,{container:i},h.createElement(Io,{"cmdk-overlay":"",className:o}),h.createElement(No,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Gh,{ref:t,...a}))))}),vk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(fe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),wk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(fe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ti(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Vt=Object.assign(Gh,{List:gk,Item:fk,Input:mk,Group:pk,Separator:hk,Dialog:xk,Empty:vk,Loading:wk});function bk(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 Yh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function $r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Cl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Xh(e,t,n,r=[]){let o=h.useRef(),s=_o();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(Lr,a),o.current=a}),o}var Sk=()=>{let[e,t]=h.useState(),n=$r(()=>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 ti({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.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 Tl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tl.displayName=Vt.displayName;const kl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Vt.Input,{ref:n,className:te("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));kl.displayName=Vt.Input.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));El.displayName=Vt.List.displayName;const Il=h.forwardRef((e,t)=>u.jsx(Vt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Il.displayName=Vt.Empty.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Group,{ref:n,className:te("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Nl.displayName=Vt.Group.displayName;const kk=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));kk.displayName=Vt.Separator.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Item,{ref:n,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Al.displayName=Vt.Item.displayName;function jl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ek(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Pl="ScrollArea",[Jh,UN]=ln(Pl),[Ik,on]=Jh(Pl),Zh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,A]=h.useState(!1),_=Re(t,F=>l(F)),L=Qo(o);return u.jsx(Ik,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(fe.div,{dir:L,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Zh.displayName=Pl;var Qh="ScrollAreaViewport",em=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=on(Qh,n),a=h.useRef(null),l=Re(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(fe.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})})]})});em.displayName=Qh;var In="ScrollAreaScrollbar",_l=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Nk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(tm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Rl,{...r,ref:t}):null});_l.displayName=In;var Nk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ut,{present:n||s,children:u.jsx(tm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ut,{present:n||a!=="hidden",children:u.jsx(Rl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),tm=h.forwardRef((e,t)=>{const n=on(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Fr(n.viewport,l),Fr(n.content,l),u.jsx(Ut,{present:r||s,children:u.jsx(Rl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Rl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=on(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=im(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function f(m,p){return Ok(m,i.current,a,p)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=am(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(Pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=am(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Re(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"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":oi(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),cm(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:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),Pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Re(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(rm,{"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":oi(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),cm(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:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[_k,nm]=Jh(In),rm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,p=on(In,n),[v,g]=h.useState(null),x=Re(t,_=>g(_)),y=h.useRef(null),b=h.useRef(""),C=p.viewport,k=r.content-r.viewport,S=xt(d),T=xt(l),E=si(f,10);function A(_){if(y.current){const L=_.clientX-y.current.left,F=_.clientY-y.current.top;c({x:L,y:F})}}return h.useEffect(()=>{const _=L=>{const F=L.target;(v==null?void 0:v.contains(F))&&S(L,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Fr(v,E),Fr(p.content,E),u.jsx(_k,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:xt(s),onThumbPointerUp:xt(i),onThumbPositionChange:T,onThumbPointerDown:xt(a),children:u.jsx(fe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(_))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,_=>{const L=_.target;L.hasPointerCapture(_.pointerId)&&L.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",om=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nm(ni,e.__scopeScrollArea);return u.jsx(Ut,{present:n||o.hasThumb,children:u.jsx(Rk,{ref:t,...r})})}),Rk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=on(ni,n),i=nm(ni,n),{onThumbPositionChange:a}=i,l=Re(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=si(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const p=Dk(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(fe.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:ae(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});om.displayName=ni;var Ml="ScrollAreaCorner",sm=h.forwardRef((e,t)=>{const n=on(Ml,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Mk,{...e,ref:t}):null});sm.displayName=Ml;var Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=on(Ml,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Fr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Fr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(fe.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 ri(e){return e?parseInt(e,10):0}function im(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=im(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=oi(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 lm([l,c],f)(e)}function am(e,t,n="ltr"){const r=oi(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=jl(e,l);return lm([0,i],[0,a])(c)}function lm(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 cm(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 si(e,t){const n=xt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Fr(e,t){const n=xt(t);Nt(()=>{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 um=Zh,Lk=em,$k=sm;const Ol=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(um,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(Lk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(dm,{}),u.jsx($k,{})]}));Ol.displayName=um.displayName;const dm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(_l,{ref:r,orientation:t,className:te("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(om,{className:"relative flex-1 rounded-full bg-border"})}));dm.displayName=_l.displayName;const Dl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Dl.displayName="Input";const 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 fm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??zk}`:`${x??Bk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Fk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(Dl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(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:p(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(ks,{children:[u.jsx(Es,{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(go,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},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,hm="thread-manager-view",Hk=e=>e==="default"||e==="shared",Uk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hm);if(Hk(e))return e}catch{}return null};function mm({defaultView:e}={}){const[t,n]=w.useState(()=>Uk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(hm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Wk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ii({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:_,actions:L,shareInFlight:F,shareStatus:U,clearShareStatus:X}=vr(),{createThread:O,deleteThread:Y,renameThread:V,shareThread:K}=L,{loadThread:D}=ro(),I=i??T,[q,J]=w.useState(Array.isArray(k)?k:[]),M=w.useRef(q.length>0),B=w.useRef(null),P=w.useRef(0),[$,z]=w.useState(null),[j,R]=w.useState(""),[G,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(null),[Oe,De]=w.useState(""),Ge=v&&v.length>0?v:Wk,Ye=mm({defaultView:m}),He=g??Ye,st=f??He.view,Xe=w.useCallback(ne=>{f||He.setView(ne),p==null||p(ne)},[f,p,He]),St=Ge.find(ne=>ne.key===st)??Ge[0],Le=ne=>{xe(ne),De(""),ie(!0)},Ve=()=>{ie(!1),xe(null),De(""),X()},je=w.useCallback(async ne=>{if(!(!Se||F)&&ne.id)try{await K(Se,ne.id),setTimeout(()=>Ve(),600)}catch(me){console.error("Failed to share thread:",me)}},[Ve,F,Se,K]),Ie=w.useMemo(()=>{const ne=y??[],me=Oe.trim().toLowerCase();return me?C?ne.filter(rt=>C(rt,me)):ne.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(me)):ne},[y,Oe,C]),Ne=st==="shared",ut=Ne?S:q,jt=Ne?_:A,ft=Ne?"No shared conversations yet":"No conversations yet",At=ne=>{const me=ne.sharedAt?` • ${ze(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${me}`},pt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){M.current=!0,J(ne);return}A||(M.current=!1,J(ne))},[k,A]),w.useEffect(()=>{if(!B.current)return;const ne=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let me=null,rt=null;return me=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{ne.scrollTop=P.current})}),()=>{me!==null&&cancelAnimationFrame(me),rt!==null&&cancelAnimationFrame(rt)}},[q]);const Ct=async ne=>{try{E(ne),await D(ne),a==null||a(ne),l==null||l(ne)}catch(me){console.error("Failed to select thread:",me)}},lt=async()=>{try{Q(!0);const ne=await O();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{Q(!1)}},gn=async(ne,me)=>{if(me.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const rt=B.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(P.current=rt.scrollTop)}try{await Y(ne),d==null||d(ne)}catch(rt){console.error("Failed to delete thread:",rt)}}},Tt=(ne,me)=>{me.stopPropagation(),z(ne.threadId),R(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},Dt=async ne=>{if(j.trim())try{await V(ne,j.trim()),z(null),R("")}catch(me){console.error("Failed to update title:",me)}},mt=()=>{z(null),R("")},ze=ne=>{if(!ne)return"";try{const me=new Date(ne),de=new Date().getTime()-me.getTime(),Te=Math.floor(de/(1e3*60*60*24));return Te===0?me.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Te===1?"Yesterday":Te<7?`${Te} days ago`:me.toLocaleDateString()}catch{return""}},Ue=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,It=ne=>{const me=Ue(ne);return me.length<=pm?me:`${me.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:lt,disabled:G||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:G?"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(ks,{children:[u.jsx(Es,{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:St.label})}),u.jsx(go,{align:"start",sideOffset:6,className:"w-40",children:Ge.map(ne=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:me=>{me.preventDefault(),Xe(ne.key)},children:[u.jsx("span",{children:ne.label}),st===ne.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(Ol,{ref:B,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:jt?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…"})]}):ut.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:ft})]}):ut.slice().sort((ne,me)=>new Date(me.updatedAt||me.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(fm,{thread:ne,isActive:I===ne.threadId,editingThreadId:$,editingTitle:j,onSelect:Ct,onStartEditing:Tt,onEditingTitleChange:me=>R(me),onSaveEditing:Dt,onCancelEditing:mt,onShare:()=>Le(ne.threadId),onDelete:gn,showEditTitle:r,showDeleteButton:n,formatDate:ze,getDisplayThreadTitle:It,secondaryLine:Ne&&pt(ne)?At(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(ol,{open:se,onOpenChange:ne=>!ne&&Ve(),children:u.jsxs(Us,{className:"max-w-md p-0",children:[u.jsx(Ws,{children:u.jsx(Vs,{children:"Share thread"})}),u.jsxs(Tl,{children:[u.jsx(kl,{autoFocus:!0,value:Oe,onValueChange:ne=>De(ne),placeholder:"Search for recipients..."}),u.jsxs(El,{children:[U&&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:U.startsWith("Failed")?"text-red-500":U.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:U})]}),u.jsx(Il,{children:b?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"}),Ie.length>0&&u.jsx(Nl,{heading:"Recipients",children:Ie.map(ne=>u.jsx(Al,{onSelect:()=>je(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.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=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(yr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Dr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(yr,{...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(ii,{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(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(yr,{...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(ii,{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(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(yr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Dr,{})})})}function qk({placeholder:e,onMessageSent:t}){const[n,r]=w.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(Dr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ii,{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]=w.useState(!1);return n?u.jsx(yr,{...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:te("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",gm=h.forwardRef((e,t)=>u.jsx(fe.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())}}));gm.displayName=Xk;var xm=gm;const Jk=Ur.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),vm=h.forwardRef(({className:e,...t},n)=>u.jsx(xm,{ref:n,className:te(Jk(),e),...t}));vm.displayName=xm.displayName;function wm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var bm=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",ai=h.forwardRef((e,t)=>u.jsx(fe.span,{...e,ref:t,style:{...bm,...e.style}}));ai.displayName=Zk;var Qk=ai,eE=[" ","Enter","ArrowUp","ArrowDown"],tE=[" ","Enter"],dr="Select",[li,ci,nE]=Zo(dr),[Br,WN]=ln(dr,[nE,Nr]),ui=Nr(),[rE,qn]=Br(dr),[oE,sE]=Br(dr),ym=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=ui(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=Qo(c),[E,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[_,L]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),F=h.useRef(null),U=x?v||!!x.closest("form"):!0,[X,O]=h.useState(new Set),Y=Array.from(X).map(V=>V.props.value).join(";");return u.jsx(ca,{...g,children:u.jsxs(rE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:_t(),value:_,onValueChange:L,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(V=>{O(K=>new Set(K).add(V))},[]),onNativeOptionRemove:h.useCallback(V=>{O(K=>{const D=new Set(K);return D.delete(V),D})},[]),children:n})}),U?u.jsxs(Vm,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:V=>L(V.target.value),disabled:m,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(X)]},Y):null]})})};ym.displayName=dr;var Sm="SelectTrigger",Cm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ui(n),i=qn(Sm,n),a=i.disabled||r,l=Re(t,i.onTriggerChange),c=ci(n),d=h.useRef("touch"),[f,m,p]=qm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=Gm(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ua,{asChild:!0,...s,children:u.jsx(fe.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":Km(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(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:ae(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())})})})});Cm.displayName=Sm;var Tm="SelectValue",km=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(Tm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Re(t,l.onValueNodeChange);return Nt(()=>{c(d)},[c,d]),u.jsx(fe.span,{...a,ref:f,style:{pointerEvents:"none"},children:Km(l.value)?u.jsx(u.Fragment,{children:i}):s})});km.displayName=Tm;var iE="SelectIcon",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(fe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Em.displayName=iE;var aE="SelectPortal",Im=e=>u.jsx(lo,{asChild:!0,...e});Im.displayName=aE;var fr="SelectContent",Nm=h.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=h.useState();if(Nt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Wr.createPortal(u.jsx(Am,{scope:e.__scopeSelect,children:u.jsx(li.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(jm,{...e,ref:t})});Nm.displayName=fr;var hn=10,[Am,Gn]=Br(fr),lE="SelectContentImpl",cE=Gt.createSlot("SelectContent.RemoveScroll"),jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(fr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=Re(t,j=>k(j)),[A,_]=h.useState(null),[L,F]=h.useState(null),U=ci(n),[X,O]=h.useState(!1),Y=h.useRef(!1);h.useEffect(()=>{if(C)return ga(C)},[C]),qi();const V=h.useCallback(j=>{const[R,...G]=U().map(ie=>ie.ref.current),[Q]=G.slice(-1),se=document.activeElement;for(const ie of j)if(ie===se||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===R&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==se))return},[U,S]),K=h.useCallback(()=>V([A,C]),[V,A,C]);h.useEffect(()=>{X&&K()},[X,K]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let j={x:0,y:0};const R=Q=>{var se,ie;j={x:Math.abs(Math.round(Q.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},G=Q=>{j.x<=10&&j.y<=10?Q.preventDefault():C.contains(Q.target)||D(!1),document.removeEventListener("pointermove",R),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",R),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",G,{capture:!0})}}},[C,D,I]),h.useEffect(()=>{const j=()=>D(!1);return window.addEventListener("blur",j),window.addEventListener("resize",j),()=>{window.removeEventListener("blur",j),window.removeEventListener("resize",j)}},[D]);const[q,J]=qm(j=>{const R=U().filter(se=>!se.disabled),G=R.find(se=>se.ref.current===document.activeElement),Q=Gm(R,j,G);Q&&setTimeout(()=>Q.ref.current.focus())}),M=h.useCallback((j,R,G)=>{const Q=!Y.current&&!G;(b.value!==void 0&&b.value===R||Q)&&(_(j),Q&&(Y.current=!0))},[b.value]),B=h.useCallback(()=>C==null?void 0:C.focus(),[C]),P=h.useCallback((j,R,G)=>{const Q=!Y.current&&!G;(b.value!==void 0&&b.value===R||Q)&&F(j)},[b.value]),$=r==="popper"?Ll:Pm,z=$===Ll?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Am,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:M,selectedItem:A,onItemLeave:B,itemTextRefCallback:P,focusSelectedItem:K,selectedItemText:L,position:r,isPositioned:X,searchRef:q,children:u.jsx(ws,{as:cE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:j=>{j.preventDefault()},onUnmountAutoFocus:ae(o,j=>{var R;(R=b.trigger)==null||R.focus({preventScroll:!0}),j.preventDefault()}),children:u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:j=>j.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:j=>j.preventDefault(),...y,...z,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,j=>{const R=j.ctrlKey||j.altKey||j.metaKey;if(j.key==="Tab"&&j.preventDefault(),!R&&j.key.length===1&&J(j.key),["ArrowUp","ArrowDown","Home","End"].includes(j.key)){let Q=U().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(j.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(j.key)){const se=j.target,ie=Q.indexOf(se);Q=Q.slice(ie+1)}setTimeout(()=>V(Q)),j.preventDefault()}})})})})})})});jm.displayName=lE;var uE="SelectItemAlignedPosition",Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(fr,n),i=Gn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),f=Re(t,E=>d(E)),m=ci(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=L.left-A.left,ie=_.left-se,Se=E.left-ie,xe=E.width+Se,Oe=Math.max(xe,A.width),De=window.innerWidth-hn,Ge=jl(ie,[hn,Math.max(hn,De-Oe)]);a.style.minWidth=xe+"px",a.style.left=Ge+"px"}else{const se=A.right-L.right,ie=window.innerWidth-_.right-se,Se=window.innerWidth-E.right-ie,xe=E.width+Se,Oe=Math.max(xe,A.width),De=window.innerWidth-hn,Ge=jl(ie,[hn,Math.max(hn,De-Oe)]);a.style.minWidth=xe+"px",a.style.right=Ge+"px"}const F=m(),U=window.innerHeight-hn*2,X=g.scrollHeight,O=window.getComputedStyle(c),Y=parseInt(O.borderTopWidth,10),V=parseInt(O.paddingTop,10),K=parseInt(O.borderBottomWidth,10),D=parseInt(O.paddingBottom,10),I=Y+V+X+D+K,q=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),M=parseInt(J.paddingTop,10),B=parseInt(J.paddingBottom,10),P=E.top+E.height/2-hn,$=U-P,z=x.offsetHeight/2,j=x.offsetTop+z,R=Y+V+j,G=I-R;if(R<=P){const se=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const ie=c.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max($,z+(se?B:0)+ie+K),xe=R+Se;a.style.height=xe+"px"}else{const se=F.length>0&&x===F[0].ref.current;a.style.top="0px";const Se=Math.max(P,Y+g.offsetTop+(se?M:0)+z)+G;a.style.height=Se+"px",g.scrollTop=R-P+g.offsetTop}a.style.margin=`${hn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Nt(()=>C(),[C]);const[k,S]=h.useState();Nt(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(fE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(fe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=uE;var dE="SelectPopperPosition",Ll=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=hn,...s}=e,i=ui(n);return u.jsx(da,{...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)"}})});Ll.displayName=dE;var[fE,$l]=Br(fr,{}),Fl="SelectViewport",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Fl,n),i=$l(Fl,n),a=Re(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(li.Slot,{scope:n,children:u.jsx(fe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-hn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const b=y+p,C=Math.min(v,b),k=b-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});_m.displayName=Fl;var Rm="SelectGroup",[pE,hE]=Br(Rm),mE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(pE,{scope:n,id:o,children:u.jsx(fe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});mE.displayName=Rm;var Mm="SelectLabel",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hE(Mm,n);return u.jsx(fe.div,{id:o.id,...r,ref:t})});Om.displayName=Mm;var di="SelectItem",[gE,Dm]=Br(di),Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(di,n),l=Gn(di,n),c=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Re(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(gE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{f(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(li.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(fe.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:ae(i.onFocus,()=>p(!0)),onBlur:ae(i.onBlur,()=>p(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(tE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Lm.displayName=di;var Ro="SelectItemText",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Ro,n),a=Gn(Ro,n),l=Dm(Ro,n),c=sE(Ro,n),[d,f]=h.useState(null),m=Re(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Nt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(fe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Wr.createPortal(s.children,i.valueNode):null]})});$m.displayName=Ro;var Fm="SelectItemIndicator",Bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Dm(Fm,n).isSelected?u.jsx(fe.span,{"aria-hidden":!0,...r,ref:t}):null});Bm.displayName=Fm;var Bl="SelectScrollUpButton",zm=h.forwardRef((e,t)=>{const n=Gn(Bl,e.__scopeSelect),r=$l(Bl,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return Nt(()=>{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(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});zm.displayName=Bl;var zl="SelectScrollDownButton",Hm=h.forwardRef((e,t)=>{const n=Gn(zl,e.__scopeSelect),r=$l(zl,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return Nt(()=>{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(Um,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Hm.displayName=zl;var Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=ci(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),Nt(()=>{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(fe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),xE="SelectSeparator",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(fe.div,{"aria-hidden":!0,...r,ref:t})});Wm.displayName=xE;var Hl="SelectArrow",vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ui(n),s=qn(Hl,n),i=Gn(Hl,n);return s.open&&i.position==="popper"?u.jsx(fa,{...o,...r,ref:t}):null});vE.displayName=Hl;var wE="SelectBubbleInput",Vm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Re(r,o),i=wm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(fe.select,{...n,style:{...bm,...n.style},ref:s,defaultValue:t})});Vm.displayName=wE;function Km(e){return e===""||e===void 0}function qm(e){const t=xt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Gm(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=bE(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 bE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yE=ym,Ym=Cm,SE=km,CE=Em,TE=Im,Xm=Nm,kE=_m,Jm=Om,Zm=Lm,EE=$m,IE=Bm,Qm=zm,eg=Hm,tg=Wm;const NE=yE,AE=SE,ng=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:te("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"})})]}));ng.displayName=Ym.displayName;const rg=h.forwardRef(({className:e,...t},n)=>u.jsx(Qm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));rg.displayName=Qm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(TE,{children:u.jsxs(Xm,{ref:o,className:te("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(rg,{}),u.jsx(kE,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(og,{})]})}));sg.displayName=Xm.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=Jm.displayName;const ig=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zm,{ref:r,className:te("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})]}));ig.displayName=Zm.displayName;const PE=h.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));PE.displayName=tg.displayName;var _E="Separator",ag="horizontal",RE=["horizontal","vertical"],lg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ag,...o}=e,s=ME(r)?r:ag,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(fe.div,{"data-orientation":s,...a,...o,ref:t})});lg.displayName=_E;function ME(e){return RE.includes(e)}var cg=lg;const ug=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(cg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ug.displayName=cg.displayName;var fi="Switch",[OE,VN]=ln(fi),[DE,LE]=OE(fi),dg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,p]=h.useState(null),v=Re(t,C=>p(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:fi});return u.jsxs(DE,{scope:n,checked:y,disabled:a,children:[u.jsx(fe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":mg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ae(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(hg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});dg.displayName=fi;var fg="SwitchThumb",pg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LE(fg,n);return u.jsx(fe.span,{"data-state":mg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pg.displayName=fg;var $E="SwitchBubbleInput",hg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Re(i,s),l=wm(n),c=Td(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});hg.displayName=$E;function mg(e){return e?"checked":"unchecked"}var gg=dg,FE=pg;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(gg,{className:te("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:te("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")})}));xg.displayName=gg.displayName;const BE=nl,zE=xT,HE=rl,vg=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{className:te("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}));vg.displayName=Io.displayName;const UE=Ur.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=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(HE,{children:[u.jsx(vg,{}),u.jsxs(No,{ref:o,className:te(UE({side:e}),t),...r,children:[n,u.jsxs(uh,{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=No.displayName;const bg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});bg.displayName="SheetHeader";const yg=h.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));yg.displayName=ar.displayName;const Sg=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));Sg.displayName=Hs.displayName;var[pi,KN]=ln("Tooltip",[Nr]),hi=Nr(),Cg="TooltipProvider",WE=700,Ul="tooltip.open",[VE,Wl]=pi(Cg),Tg=e=>{const{__scopeTooltip:t,delayDuration:n=WE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(VE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Tg.displayName=Cg;var Mo="Tooltip",[KE,mi]=pi(Mo),kg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Wl(Mo,e.__scopeTooltip),c=hi(t),[d,f]=h.useState(null),m=_t(),p=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Ul))):l.onClose(),s==null||s(E)},caller:Mo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,b(!0),p.current=0},g)},[g,b]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ca,{...c,children:u.jsx(KE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(p.current),p.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};kg.displayName=Mo;var Vl="TooltipTrigger",Eg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mi(Vl,n),s=Wl(Vl,n),i=hi(n),a=h.useRef(null),l=Re(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(ua,{asChild:!0,...i,children:u.jsx(fe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Eg.displayName=Vl;var qE="TooltipPortal",[qN,GE]=pi(qE,{forceMount:void 0}),zr="TooltipContent",Ig=h.forwardRef((e,t)=>{const n=GE(zr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(zr,e.__scopeTooltip);return u.jsx(Ut,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ng,{side:o,...s,ref:t}):u.jsx(YE,{side:o,...s,ref:t})})}),YE=h.forwardRef((e,t)=>{const n=mi(zr,e.__scopeTooltip),r=Wl(zr,e.__scopeTooltip),o=h.useRef(null),s=Re(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=eI(y,x.getBoundingClientRect()),C=tI(y,b),k=nI(g.getBoundingClientRect()),S=oI([...C,...k]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!rI(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Ng,{...e,ref:s})}),[XE,JE]=pi(Mo,{isInside:!1}),ZE=Gt.createSlottable("TooltipContent"),Ng=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(zr,n),c=hi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Ul,d),()=>document.removeEventListener(Ul,d)),[d]),h.useEffect(()=>{if(l.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(da,{"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})})]})})});Ig.displayName=zr;var Ag="TooltipArrow",QE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return JE(Ag,n).isInside?null:u.jsx(fa,{...o,...r,ref:t})});QE.displayName=Ag;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=Tg,aI=kg,lI=Eg,jg=Ig;const cI=iI,uI=aI,dI=lI,Pg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(jg,{ref:r,sideOffset:t,className:te("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=jg.displayName;var Kl="ToastProvider",[ql,fI,pI]=Zo("Toast"),[_g,GN]=ln("Toast",[pI]),[hI,gi]=_g(Kl),Rg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Kl}\`. Expected non-empty \`string\`.`),u.jsx(ql.Provider,{scope:t,children:u.jsx(hI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Rg.displayName=Kl;var Mg="ToastViewport",mI=["F8"],Gl="toast.viewportPause",Yl="toast.viewportResume",Og=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=mI,label:o="Notifications ({hotkey})",...s}=e,i=gi(Mg,n),a=fI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Re(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=f.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Gl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Yl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...NI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const A=document.activeElement,_=b.shiftKey;if(b.target===x&&_){(S=c.current)==null||S.focus();return}const U=g({tabbingDirection:_?"backwards":"forwards"}),X=U.findIndex(O=>O===A);Zl(U.slice(X+1))?b.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(Vw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Xl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Zl(x)}}),u.jsx(ql.Slot,{scope:n,children:u.jsx(fe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Xl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Zl(x)}})]})});Og.displayName=Mg;var Dg="ToastFocusProxy",Xl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=gi(Dg,n);return u.jsx(ai,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Xl.displayName=Dg;var Oo="Toast",gI="toast.swipeStart",xI="toast.swipeMove",vI="toast.swipeCancel",wI="toast.swipeEnd",Lg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Oo});return u.jsx(Ut,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:xt(e.onPause),onResume:xt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(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:ae(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:ae(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)})})})});Lg.displayName=Oo;var[bI,yI]=_g(Oo,{onClose(){}}),SI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=gi(Oo,n),[x,y]=h.useState(null),b=Re(t,O=>y(O)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),A=h.useRef(0),{onToastAdd:_,onToastRemove:L}=g,F=xt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),U=h.useCallback(O=>{!O||O===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(F,O))},[F]);h.useEffect(()=>{const O=g.viewport;if(O){const Y=()=>{U(E.current),c==null||c()},V=()=>{const K=new Date().getTime()-T.current;E.current=E.current-K,window.clearTimeout(A.current),l==null||l()};return O.addEventListener(Gl,V),O.addEventListener(Yl,Y),()=>{O.removeEventListener(Gl,V),O.removeEventListener(Yl,Y)}}},[g.viewport,S,l,c,U]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&U(S)},[s,S,g.isClosePausedRef,U]),h.useEffect(()=>(_(),()=>L()),[_,L]);const X=h.useMemo(()=>x?Wg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[X&&u.jsx(CI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:X}),u.jsx(bI,{scope:n,onClose:F,children:Wr.createPortal(u.jsx(ql.ItemSlot,{scope:n,children:u.jsx(Ww,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(fe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,O=>{O.key==="Escape"&&(a==null||a(O.nativeEvent),O.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ae(e.onPointerDown,O=>{O.button===0&&(C.current={x:O.clientX,y:O.clientY})}),onPointerMove:ae(e.onPointerMove,O=>{if(!C.current)return;const Y=O.clientX-C.current.x,V=O.clientY-C.current.y,K=!!k.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=D?I(0,Y):0,J=D?0:I(0,V),M=O.pointerType==="touch"?10:2,B={x:q,y:J},P={originalEvent:O,delta:B};K?(k.current=B,xi(xI,f,P,{discrete:!1})):Vg(B,g.swipeDirection,M)?(k.current=B,xi(gI,d,P,{discrete:!1}),O.target.setPointerCapture(O.pointerId)):(Math.abs(Y)>M||Math.abs(V)>M)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,O=>{const Y=k.current,V=O.target;if(V.hasPointerCapture(O.pointerId)&&V.releasePointerCapture(O.pointerId),k.current=null,C.current=null,Y){const K=O.currentTarget,D={originalEvent:O,delta:Y};Vg(Y,g.swipeDirection,g.swipeThreshold)?xi(wI,p,D,{discrete:!0}):xi(vI,m,D,{discrete:!0}),K.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),CI=e=>{const{__scopeToast:t,children:n,...r}=e,o=gi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return EI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(lo,{asChild:!0,children:u.jsx(ai,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},TI="ToastTitle",$g=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});$g.displayName=TI;var kI="ToastDescription",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});Fg.displayName=kI;var Bg="ToastAction",zg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Ug,{altText:n,asChild:!0,children:u.jsx(Jl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Bg}\`. Expected non-empty \`string\`.`),null)});zg.displayName=Bg;var Hg="ToastClose",Jl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=yI(Hg,n);return u.jsx(Ug,{asChild:!0,children:u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Jl.displayName=Hg;var Ug=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(fe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Wg(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(...Wg(r))}}),t}function xi(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?Wi(o,s):o.dispatchEvent(s)}var Vg=(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=xt(e);Nt(()=>{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 Zl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var AI=Rg,Kg=Og,qg=Lg,Gg=$g,Yg=Fg,Xg=zg,Jg=Jl;const jI=AI,Zg=h.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:te("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Zg.displayName=Kg.displayName;const PI=Ur.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"}}),Qg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(qg,{ref:r,className:te(PI({variant:t}),e),...n}));Qg.displayName=qg.displayName;const _I=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:te("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}));_I.displayName=Xg.displayName;const ex=h.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:te("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"})}));ex.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:te("text-sm font-semibold",e),...t}));tx.displayName=Gg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:te("text-sm opacity-90",e),...t}));nx.displayName=Yg.displayName;function RI(){const{toasts:e}=al();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(tx,{children:n}),r&&u.jsx(nx,{children:r})]}),o,u.jsx(ex,{})]},t)}),u.jsx(Zg,{})]})}var MI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[p]?s[p]:p)):l.setAttribute(v,p)}),f(p)}function f(p){a&&c.includes(p)&&(l.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},OI=h.createContext(void 0),DI={setTheme:e=>{},themes:[]},LI=()=>{var e;return(e=h.useContext(OI))!=null?e:DI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${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})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},FI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),zI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.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=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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=w.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"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),KI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Ql=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:Ql++,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],w.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)||Ql++;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}},Kt=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return Kt.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=()=>Kt.toasts,ZI=()=>Kt.getActiveToasts();Object.assign(XI,{success:Kt.success,info:Kt.info,warning:Kt.warning,error:Kt.error,custom:Kt.custom,message:Kt.message,promise:Kt.promise,dismiss:Kt.dismiss,loading:Kt.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 vi(e){return e.label!==void 0}var eN=3,tN="32px",nN="16px",rx=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:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:A,style:_,cancelButtonStyle:L,actionButtonStyle:F,className:U="",descriptionClassName:X="",duration:O,position:Y,gap:V,loadingIcon:K,expandByDefault:D,classNames:I,icons:q,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:M}=e,[B,P]=w.useState(null),[$,z]=w.useState(null),[j,R]=w.useState(!1),[G,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(!1),[Oe,De]=w.useState(!1),[Ge,Ye]=w.useState(0),[He,st]=w.useState(0),Xe=w.useRef(p.duration||O||rx),St=w.useRef(null),Le=w.useRef(null),Ve=C===0,je=C+1<=y,Ie=p.type,Ne=p.dismissible!==!1,ut=p.className||"",jt=p.descriptionClassName||"",ft=w.useMemo(()=>b.findIndex(de=>de.toastId===p.id)||0,[b,p.id]),At=w.useMemo(()=>{var de;return(de=p.closeButton)!=null?de:A},[p.closeButton,A]),pt=w.useMemo(()=>p.duration||O||rx,[p.duration,O]),Ct=w.useRef(0),lt=w.useRef(0),gn=w.useRef(0),Tt=w.useRef(null),[Dt,mt]=Y.split("-"),ze=w.useMemo(()=>b.reduce((de,Te,$e)=>$e>=ft?de:de+Te.height,0),[b,ft]),Ue=KI(),It=p.invert||m,ne=Ie==="loading";lt.current=w.useMemo(()=>ft*V+ze,[ft,ze]),w.useEffect(()=>{Xe.current=pt},[pt]),w.useEffect(()=>{R(!0)},[]),w.useEffect(()=>{let de=Le.current;if(de){let Te=de.getBoundingClientRect().height;return st(Te),x($e=>[{toastId:p.id,height:Te,position:p.position},...$e]),()=>x($e=>$e.filter(ht=>ht.toastId!==p.id))}},[x,p.id]),w.useLayoutEffect(()=>{if(!j)return;let de=Le.current,Te=de.style.height;de.style.height="auto";let $e=de.getBoundingClientRect().height;de.style.height=Te,st($e),x(ht=>ht.find(wt=>wt.toastId===p.id)?ht.map(wt=>wt.toastId===p.id?{...wt,height:$e}:wt):[{toastId:p.id,height:$e,position:p.position},...ht])},[j,p.title,p.description,x,p.id]);let me=w.useCallback(()=>{Q(!0),Ye(lt.current),x(de=>de.filter(Te=>Te.toastId!==p.id)),setTimeout(()=>{T(p)},iN)},[p,T,x,lt]);w.useEffect(()=>{if(p.promise&&Ie==="loading"||p.duration===1/0||p.type==="loading")return;let de;return S||g||M&&Ue?(()=>{if(gn.current<Ct.current){let Te=new Date().getTime()-Ct.current;Xe.current=Xe.current-Te}gn.current=new Date().getTime()})():Xe.current!==1/0&&(Ct.current=new Date().getTime(),de=setTimeout(()=>{var Te;(Te=p.onAutoClose)==null||Te.call(p,p),me()},Xe.current)),()=>clearTimeout(de)},[S,g,p,Ie,M,Ue,me]),w.useEffect(()=>{p.delete&&me()},[me,p.delete]);function rt(){var de,Te,$e;return q!=null&&q.loading?w.createElement("div",{className:mn(I==null?void 0:I.loader,(de=p==null?void 0:p.classNames)==null?void 0:de.loader,"sonner-loader"),"data-visible":Ie==="loading"},q.loading):K?w.createElement("div",{className:mn(I==null?void 0:I.loader,(Te=p==null?void 0:p.classNames)==null?void 0:Te.loader,"sonner-loader"),"data-visible":Ie==="loading"},K):w.createElement(BI,{className:mn(I==null?void 0:I.loader,($e=p==null?void 0:p.classNames)==null?void 0:$e.loader),visible:Ie==="loading"})}return w.createElement("li",{tabIndex:0,ref:Le,className:mn(U,ut,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Ie],(n=p==null?void 0:p.classNames)==null?void 0:n[Ie]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":j,"data-promise":!!p.promise,"data-swiped":Oe,"data-removed":G,"data-visible":je,"data-y-position":Dt,"data-x-position":mt,"data-index":C,"data-front":Ve,"data-swiping":se,"data-dismissible":Ne,"data-type":Ie,"data-invert":It,"data-swipe-out":Se,"data-swipe-direction":$,"data-expanded":!!(S||D&&j),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${G?Ge:lt.current}px`,"--initial-height":D?"auto":`${He}px`,..._,...p.style},onDragEnd:()=>{ie(!1),P(null),Tt.current=null},onPointerDown:de=>{ne||!Ne||(St.current=new Date,Ye(lt.current),de.target.setPointerCapture(de.pointerId),de.target.tagName!=="BUTTON"&&(ie(!0),Tt.current={x:de.clientX,y:de.clientY}))},onPointerUp:()=>{var de,Te,$e,ht;if(Se||!Ne)return;Tt.current=null;let wt=Number(((de=Le.current)==null?void 0:de.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Pe=Number(((Te=Le.current)==null?void 0:Te.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ke=new Date().getTime()-(($e=St.current)==null?void 0:$e.getTime()),we=B==="x"?wt:Pe,et=Math.abs(we)/Ke;if(Math.abs(we)>=sN||et>.11){Ye(lt.current),(ht=p.onDismiss)==null||ht.call(p,p),z(B==="x"?wt>0?"right":"left":Pe>0?"down":"up"),me(),xe(!0),De(!1);return}ie(!1),P(null)},onPointerMove:de=>{var Te,$e,ht,wt;if(!Tt.current||!Ne||((Te=window.getSelection())==null?void 0:Te.toString().length)>0)return;let Pe=de.clientY-Tt.current.y,Ke=de.clientX-Tt.current.x,we=($e=e.swipeDirections)!=null?$e:aN(Y);!B&&(Math.abs(Ke)>1||Math.abs(Pe)>1)&&P(Math.abs(Ke)>Math.abs(Pe)?"x":"y");let et={x:0,y:0};B==="y"?(we.includes("top")||we.includes("bottom"))&&(we.includes("top")&&Pe<0||we.includes("bottom")&&Pe>0)&&(et.y=Pe):B==="x"&&(we.includes("left")||we.includes("right"))&&(we.includes("left")&&Ke<0||we.includes("right")&&Ke>0)&&(et.x=Ke),(Math.abs(et.x)>0||Math.abs(et.y)>0)&&De(!0),(ht=Le.current)==null||ht.style.setProperty("--swipe-amount-x",`${et.x}px`),(wt=Le.current)==null||wt.style.setProperty("--swipe-amount-y",`${et.y}px`)}},At&&!p.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Ne?()=>{}:()=>{var de;me(),(de=p.onDismiss)==null||de.call(p,p)},className:mn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:VI):null,p.jsx||w.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:w.createElement(w.Fragment,null,Ie||p.icon||p.promise?w.createElement("div",{"data-icon":"",className:mn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||rt():null,p.type!=="loading"?p.icon||(q==null?void 0:q[Ie])||$I(Ie):null):null,w.createElement("div",{"data-content":"",className:mn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:mn(I==null?void 0:I.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?w.createElement("div",{"data-description":"",className:mn(X,jt,I==null?void 0:I.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),w.isValidElement(p.cancel)?p.cancel:p.cancel&&vi(p.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||L,onClick:de=>{var Te,$e;vi(p.cancel)&&Ne&&(($e=(Te=p.cancel).onClick)==null||$e.call(Te,de),me())},className:mn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,w.isValidElement(p.action)?p.action:p.action&&vi(p.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||F,onClick:de=>{var Te,$e;vi(p.action)&&(($e=(Te=p.action).onClick)==null||$e.call(Te,de),!de.defaultPrevented&&me())},className:mn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function ox(){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=w.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:f,duration:m,style:p,visibleToasts:v=eN,toastOptions:g,dir:x=ox(),gap:y=oN,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(M=>M.position).map(M=>M.position)))),[T,r]),[_,L]=w.useState([]),[F,U]=w.useState(!1),[X,O]=w.useState(!1),[Y,V]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),K=w.useRef(null),D=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),q=w.useRef(!1),J=w.useCallback(M=>{E(B=>{var P;return(P=B.find($=>$.id===M.id))!=null&&P.delete||Kt.dismiss(M.id),B.filter(({id:$})=>$!==M.id)})},[]);return w.useEffect(()=>Kt.subscribe(M=>{if(M.dismiss){E(B=>B.map(P=>P.id===M.id?{...P,delete:!0}:P));return}setTimeout(()=>{Do.flushSync(()=>{E(B=>{let P=B.findIndex($=>$.id===M.id);return P!==-1?[...B.slice(0,P),{...B[P],...M},...B.slice(P+1)]:[M,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){V(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?V("dark"):V("light")),typeof window>"u")return;let M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:B})=>{V(B?"dark":"light")})}catch{M.addListener(({matches:P})=>{try{V(P?"dark":"light")}catch($){console.error($)}})}},[d]),w.useEffect(()=>{T.length<=1&&U(!1)},[T]),w.useEffect(()=>{let M=B=>{var P,$;o.every(z=>B[z]||B.code===z)&&(U(!0),(P=K.current)==null||P.focus()),B.code==="Escape"&&(document.activeElement===K.current||($=K.current)!=null&&$.contains(document.activeElement))&&U(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[o]),w.useEffect(()=>{if(K.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,q.current=!1)}},[K.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((M,B)=>{var P;let[$,z]=M.split("-");return T.length?w.createElement("ol",{key:M,dir:x==="auto"?ox():x,tabIndex:-1,ref:K,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":$,"data-lifted":F&&T.length>1&&!s,"data-x-position":z,style:{"--front-toast-height":`${((P=_[0])==null?void 0:P.height)||0}px`,"--width":`${rN}px`,"--gap":`${y}px`,...p,...cN(l,c)},onBlur:j=>{q.current&&!j.currentTarget.contains(j.relatedTarget)&&(q.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:j=>{j.target instanceof HTMLElement&&j.target.dataset.dismissible==="false"||q.current||(q.current=!0,I.current=j.relatedTarget)},onMouseEnter:()=>U(!0),onMouseMove:()=>U(!0),onMouseLeave:()=>{X||U(!1)},onDragEnd:()=>U(!1),onPointerDown:j=>{j.target instanceof HTMLElement&&j.target.dataset.dismissible==="false"||O(!0)},onPointerUp:()=>O(!1)},T.filter(j=>!j.position&&B===0||j.position===M).map((j,R)=>{var G,Q;return w.createElement(lN,{key:j.id,icons:C,index:R,toast:j,defaultRichColors:f,duration:(G=g==null?void 0:g.duration)!=null?G:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:X,position:M,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(se=>se.position==j.position),heights:_.filter(se=>se.position==j.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:F,pauseWhenPageIsHidden:S,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=qv,H.ApiClient=Kv,H.ApiProvider=iu,H.ArtifactRenderer=Nh,H.Badge=$h,H.Button=Ze,H.Card=ul,H.CardContent=Qs,H.CardDescription=pl,H.CardHeader=dl,H.CardTitle=fl,H.ChatApi=Xo,H.ChatApp=Vk,H.ChatInput=Gf,H.ChatInputRow=Yf,H.ChatInterface=Dr,H.ChatProviders=yr,H.ChatWidget=Gk,H.Command=Tl,H.CommandEmpty=Il,H.CommandGroup=Nl,H.CommandInput=kl,H.CommandItem=Al,H.CommandList=El,H.DEFAULT_TIMEOUT_MS=eu,H.Dialog=ol,H.DialogContent=Us,H.DialogHeader=Ws,H.DialogTitle=Vs,H.DropdownMenu=ks,H.DropdownMenuContent=go,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=Es,H.FileViewerModal=ph,H.HISTORY_TIMEOUT_MS=tu,H.Input=Dl,H.InterruptPartRenderer=hl,H.Label=vm,H.MarkdownContent=cr,H.MessageComponent=ei,H.MessageList=xl,H.MessageRow=gl,H.NewChatButton=Yk,H.PlotArtifact=Ih,H.SETTINGS_STORAGE_KEY=Ui,H.ScrollArea=Ol,H.Select=NE,H.SelectContent=sg,H.SelectItem=ig,H.SelectTrigger=ng,H.SelectValue=AE,H.Separator=ug,H.Sheet=BE,H.SheetContent=wg,H.SheetDescription=Sg,H.SheetHeader=bg,H.SheetTitle=yg,H.SheetTrigger=zE,H.SimpleChat=Kk,H.SimpleJsonView=Zs,H.Sonner=dN,H.StreamProgress=Ah,H.Switch=xg,H.Textarea=Aa,H.ThinkingIndicator=Ph,H.ThreadListItem=fm,H.ThreadManager=ii,H.ThreadStateProvider=ju,H.ThreadsProvider=xu,H.TimelineColumn=Cx,H.Toaster=RI,H.ToolComponent=Dh,H.Tooltip=uI,H.TooltipContent=Pg,H.TooltipProvider=cI,H.TooltipTrigger=dI,H.UserTextContent=_h,H.applySettings=Nw,H.buildCheckpointIndex=rc,H.buildCheckpointPreviewMap=dx,H.chatApiClient=Nn,H.del=Oi,H.downloadFileById=ru,H.extractConfigFields=yi,H.fileToBase64=au,H.get=Xt,H.getChatToken=Zc,H.getCheckpointForMessage=fx,H.getCurrentSettings=Iw,H.getDefaultApiConfig=Fu,H.getDefaultChatSettings=Bu,H.getFileContent=Li,H.getFileInfo=Yv,H.getMessageAttemptInfo=oc,H.getMessageDomKey=ml,H.getPreviewForMessage=bi,H.httpClient=Yt,H.hydrateHistorySnapshots=Yn,H.isEnvelope=cu,H.listFiles=ou,H.loadStoredSettings=zu,H.onChatTokenChanged=Qc,H.post=Yo,H.processAttachments=lu,H.put=nu,H.readNumber=ic,H.readString=Rn,H.resolveChatBaseUrl=vn,H.saveSettings=Hu,H.setChatToken=Go,H.toPlainObject=_n,H.unwrap=Lt,H.useApi=Qr,H.useCheckpointIndex=sc,H.useFilePreview=Rh,H.useHasChatSession=Tw,H.useParsedMessageContent=Mh,H.useShallowStableValue=Ou,H.useStream=Hi,H.useStreamingHook=Hi,H.useThreadHistoryState=Eu,H.useThreadManagerViewState=mm,H.useThreadState=ro,H.useThreadStateUpdater=Au,H.useThreads=vr,H.useThreadsState=mu,H.viewFileById=Gv,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|