teodor-new-chat-ui 4.3.487 → 4.3.488
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1855 -1853
- package/dist/index.umd.js +25 -25
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,Vt,Wr,
|
|
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,Vt,Wr,lx,cx,ue,Do){"use strict";var hN=Object.defineProperty;var mN=(H,w,Vt)=>w in H?hN(H,w,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):H[w]=Vt;var ix=(H,w,Vt)=>mN(H,typeof w!="symbol"?w+"":w,Vt);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),Vr=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,mr=!(((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(mr&&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 mr&&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"){mr&&console.debug("[historyUtils] skipping invalid raw interrupt entry",{entry:l,index:a});continue}const c=l,d=c.value??l;if(d==null){mr&&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 mr&&console.debug("[historyUtils] interrupt derived from raw entry",m),m}return mr&&console.debug("[historyUtils] no interrupt found in snapshot"),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
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var lc;function
|
|
9
|
+
*/var lc;function yx(){if(lc)return Kr;lc=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,f={},m=null,p=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:p,props:f,_owner:o.current}}return Kr.Fragment=n,Kr.jsx=i,Kr.jsxs=i,Kr}var qr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var cc;function
|
|
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 te=v&&N[v]||N[g];return typeof te=="function"?te:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var te=arguments.length,de=new Array(te>1?te-1:0),ke=1;ke<te;ke++)de[ke-1]=arguments[ke];C("error",N,de)}}function C(N,te,de){{var ke=y.ReactDebugCurrentFrame,Ze=ke.getStackAddendum();Ze!==""&&(te+="%s",de=de.concat([Ze]));var ot=de.map(function(Ve){return String(Ve)});ot.unshift("Warning: "+te),Function.prototype.apply.call(console[N],console,ot)}}var k=!1,S=!1,T=!1,E=!1,j=!1,R;R=Symbol.for("react.module.reference");function D(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||j||N===o||N===c||N===d||E||N===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===R||N.getModuleId!==void 0))}function $(N,te,de){var ke=N.displayName;if(ke)return ke;var Ze=te.displayName||te.name||"";return Ze!==""?de+"("+Ze+")":de}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 te=N;return U(te)+".Consumer";case i:var de=N;return U(de._context)+".Provider";case l:return $(N,N.render,"ForwardRef");case f:var ke=N.displayName||null;return ke!==null?ke:X(N.type)||"Memo";case m:{var Ze=N,ot=Ze._payload,Ve=Ze._init;try{return X(Ve(ot))}catch{return null}}}return null}var M=Object.assign,K=0,q,z,O,I,Y,J,P;function B(){}B.__reactDisabledLog=!0;function A(){{if(K===0){q=console.log,z=console.info,O=console.warn,I=console.error,Y=console.group,J=console.groupCollapsed,P=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})}K++}}function F(){{if(K--,K===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},N,{value:q}),info:M({},N,{value:z}),warn:M({},N,{value:O}),error:M({},N,{value:I}),group:M({},N,{value:Y}),groupCollapsed:M({},N,{value:J}),groupEnd:M({},N,{value:P})})}K<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var W=y.ReactCurrentDispatcher,L;function _(N,te,de){{if(L===void 0)try{throw Error()}catch(Ze){var ke=Ze.stack.trim().match(/\n( *(at )?)/);L=ke&&ke[1]||""}return`
|
|
18
18
|
`+L+N}}var G=!1,Z;{var oe=typeof WeakMap=="function"?WeakMap:Map;Z=new oe}function se(N,te){if(!N||G)return"";{var de=Z.get(N);if(de!==void 0)return de}var ke;G=!0;var Ze=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ot;ot=W.current,W.current=null,A();try{if(te){var Ve=function(){throw Error()};if(Object.defineProperty(Ve.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ve,[])}catch(Wt){ke=Wt}Reflect.construct(N,[],Ve)}else{try{Ve.call()}catch(Wt){ke=Wt}N.call(Ve.prototype)}}else{try{throw Error()}catch(Wt){ke=Wt}N()}}catch(Wt){if(Wt&&ke&&typeof Wt.stack=="string"){for(var Be=Wt.stack.split(`
|
|
19
19
|
`),Lt=ke.stack.split(`
|
|
20
20
|
`),bt=Be.length-1,Tt=Lt.length-1;bt>=1&&Tt>=0&&Be[bt]!==Lt[Tt];)Tt--;for(;bt>=1&&Tt>=0;bt--,Tt--)if(Be[bt]!==Lt[Tt]){if(bt!==1||Tt!==1)do if(bt--,Tt--,Tt<0||Be[bt]!==Lt[Tt]){var on=`
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+N+"`."}return""}}function tt(N){return""}var xe={};function ce(N){{var te=he();if(!te){var de=typeof N=="string"?N:N.displayName||N.name;de&&(te=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+de+">.")}return te}}function Ie(N,te){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var de=ce(te);if(xe[de])return;xe[de]=!0;var ke="";N&&N._owner&&N._owner!==Zt.current&&(ke=" It was passed a child from "+X(N._owner.type)+"."),We(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.',de,ke),We(null)}}function it(N,te){{if(typeof N!="object")return;if(St(N))for(var de=0;de<N.length;de++){var ke=N[de];ee(ke)&&Ie(ke,te)}else if(ee(N))N._store&&(N._store.validated=!0);else if(N){var Ze=x(N);if(typeof Ze=="function"&&Ze!==N.entries)for(var ot=Ze.call(N),Ve;!(Ve=ot.next()).done;)ee(Ve.value)&&Ie(Ve.value,te)}}}function Se(N){{var te=N.type;if(te==null||typeof te=="string")return;var de;if(typeof te=="function")de=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===f))de=te.propTypes;else return;if(de){var ke=X(te);ct(de,N.props,"prop",ke,N)}else if(te.PropTypes!==void 0&&!Ct){Ct=!0;var Ze=X(te);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ze||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ne(N){{for(var te=Object.keys(N.props),de=0;de<te.length;de++){var ke=te[de];if(ke!=="children"&&ke!=="key"){We(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),We(null);break}}N.ref!==null&&(We(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),We(null))}}var Fe={};function ve(N,te,de,ke,Ze,ot){{var Ve=D(N);if(!Ve){var Be="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Be+=" 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 Lt=tt();Lt?Be+=Lt:Be+=he();var bt;N===null?bt="null":St(N)?bt="array":N!==void 0&&N.$$typeof===t?(bt="<"+(X(N.type)||"Unknown")+" />",Be=" 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,Be)}var Tt=mn(N,te,de,Ze,ot);if(Tt==null)return Tt;if(Ve){var on=te.children;if(on!==void 0)if(ke)if(St(on)){for(var Ur=0;Ur<on.length;Ur++)it(on[Ur],N);Object.freeze&&Object.freeze(on)}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 it(on,N)}if(De.call(te,"key")){var pr=X(N),Wt=Object.keys(te).filter(function(
|
|
25
|
+
Check the top-level render call using <`+de+">.")}return te}}function Ie(N,te){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var de=ce(te);if(xe[de])return;xe[de]=!0;var ke="";N&&N._owner&&N._owner!==Zt.current&&(ke=" It was passed a child from "+X(N._owner.type)+"."),We(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.',de,ke),We(null)}}function it(N,te){{if(typeof N!="object")return;if(St(N))for(var de=0;de<N.length;de++){var ke=N[de];ee(ke)&&Ie(ke,te)}else if(ee(N))N._store&&(N._store.validated=!0);else if(N){var Ze=x(N);if(typeof Ze=="function"&&Ze!==N.entries)for(var ot=Ze.call(N),Ve;!(Ve=ot.next()).done;)ee(Ve.value)&&Ie(Ve.value,te)}}}function Se(N){{var te=N.type;if(te==null||typeof te=="string")return;var de;if(typeof te=="function")de=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===f))de=te.propTypes;else return;if(de){var ke=X(te);ct(de,N.props,"prop",ke,N)}else if(te.PropTypes!==void 0&&!Ct){Ct=!0;var Ze=X(te);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ze||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ne(N){{for(var te=Object.keys(N.props),de=0;de<te.length;de++){var ke=te[de];if(ke!=="children"&&ke!=="key"){We(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),We(null);break}}N.ref!==null&&(We(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),We(null))}}var Fe={};function ve(N,te,de,ke,Ze,ot){{var Ve=D(N);if(!Ve){var Be="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Be+=" 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 Lt=tt();Lt?Be+=Lt:Be+=he();var bt;N===null?bt="null":St(N)?bt="array":N!==void 0&&N.$$typeof===t?(bt="<"+(X(N.type)||"Unknown")+" />",Be=" 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,Be)}var Tt=mn(N,te,de,Ze,ot);if(Tt==null)return Tt;if(Ve){var on=te.children;if(on!==void 0)if(ke)if(St(on)){for(var Ur=0;Ur<on.length;Ur++)it(on[Ur],N);Object.freeze&&Object.freeze(on)}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 it(on,N)}if(De.call(te,"key")){var pr=X(N),Wt=Object.keys(te).filter(function(pN){return pN!=="key"}),ec=Wt.length>0?"{key: someKey, "+Wt.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[pr+ec]){var fN=Wt.length>0?"{"+Wt.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,dN,pr),Fe[pr+ec]=!0}}return N===r?Ne(Tt):Se(Tt),Tt}}function Qe(N,te,de){return ve(N,te,de,!0)}function Re(N,te,de){return ve(N,te,de,!1)}var ht=Re,In=Qe;qr.Fragment=r,qr.jsx=ht,qr.jsxs=In}()),qr}process.env.NODE_ENV==="production"?Si.exports=bx():Si.exports=yx();var u=Si.exports;const Sx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=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:Cx}=Object.prototype,{getPrototypeOf:Ci}=Object,{iterator:Lo,toStringTag:dc}=Symbol,$o=(e=>t=>{const n=Cx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),sn=e=>(e=e.toLowerCase(),t=>$o(t)===e),Fo=e=>t=>typeof t===e,{isArray:gr}=Array,xr=Fo("undefined");function Gr(e){return e!==null&&!xr(e)&&e.constructor!==null&&!xr(e.constructor)&&$t(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const fc=sn("ArrayBuffer");function Tx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&fc(e.buffer),t}const kx=Fo("string"),$t=Fo("function"),pc=Fo("number"),Yr=e=>e!==null&&typeof e=="object",Ex=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)},Ix=e=>{if(!Yr(e)||Gr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Nx=sn("Date"),Ax=sn("File"),jx=sn("Blob"),Px=sn("FileList"),_x=e=>Yr(e)&&$t(e.pipe),Rx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||$t(e.append)&&((t=$o(e))==="formdata"||t==="object"&&$t(e.toString)&&e.toString()==="[object FormData]"))},Mx=sn("URLSearchParams"),[Ox,Dx,Lx,$x]=["ReadableStream","Request","Response","Headers"].map(sn),Fx=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]),gr(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=>!xr(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):gr(o)?n[i]=o.slice():(!t||!xr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Xr(arguments[o],r);return n}const Bx=(e,t,n,{allOwnKeys:r}={})=>(Xr(t,(o,s)=>{n&&$t(o)?e[s]=uc(o,n):e[s]=o},{allOwnKeys:r}),e),zx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hx=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Ux=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&Ci(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wx=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Vx=e=>{if(!e)return null;if(gr(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},Kx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ci(Uint8Array)),qx=(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])}},Gx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yx=sn("HTMLFormElement"),Xx=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),Jx=sn("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)},Zx=e=>{xc(e,(t,n)=>{if($t(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if($t(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Qx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return gr(e)?r(e):r(String(e).split(t)),n},ev=()=>{},tv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nv(e){return!!(e&&$t(e.append)&&e[dc]==="FormData"&&e[Lo])}const rv=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=gr(r)?[]:{};return Xr(r,(i,a)=>{const l=n(i,o+1);!xr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ov=sn("AsyncFunction"),sv=e=>e&&(Yr(e)||$t(e))&&$t(e.then)&&$t(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",$t(Xn.postMessage)),iv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||vc,V={isArray:gr,isArrayBuffer:fc,isBuffer:Gr,isFormData:Rx,isArrayBufferView:Tx,isString:kx,isNumber:pc,isBoolean:Ex,isObject:Yr,isPlainObject:Bo,isEmptyObject:Ix,isReadableStream:Ox,isRequest:Dx,isResponse:Lx,isHeaders:$x,isUndefined:xr,isDate:Nx,isFile:Ax,isBlob:jx,isRegExp:Jx,isFunction:$t,isStream:_x,isURLSearchParams:Mx,isTypedArray:Kx,isFileList:Px,forEach:Xr,merge:Ti,extend:Bx,trim:Fx,stripBOM:zx,inherits:Hx,toFlatObject:Ux,kindOf:$o,kindOfTest:sn,endsWith:Wx,toArray:Vx,forEachEntry:qx,matchAll:Gx,isHTMLForm:Yx,hasOwnProperty:gc,hasOwnProp:gc,reduceDescriptors:xc,freezeMethods:Zx,toObjectSet:Qx,toCamelCase:Xx,noop:ev,toFiniteNumber:tv,findKey:hc,global:Xn,isContextDefined:mc,isSpecCompliantForm:nv,toJSONObject:rv,isAsyncFn:ov,isThenable:sv,setImmediate:vc,asap:iv,isIterable:e=>e!=null&&$t(e[Lo])};function Ae(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}V.inherits(Ae,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const wc=Ae.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(Ae,bc),Object.defineProperty(wc,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(wc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Ae.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const av=null;function ki(e){return V.isPlainObject(e)||V.isArray(e)}function yc(e){return V.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 lv(e){return V.isArray(e)&&!e.some(ki)}const cv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function zo(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!V.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!l&&V.isBlob(v))throw new Ae("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&lv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=yc(g),y.forEach(function(C,k){!(V.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(cv,{defaultVisitor:d,convertValue:c,isVisitable:ki});function p(v,g){if(!V.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),V.forEach(v,function(y,b){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(b)?b.trim():b,g,m))===!0&&p(y,g?g.concat(b):[b])}),f.pop()}}if(!V.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 uv(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||uv;V.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=V.isURLSearchParams(t)?t.toString():new 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){V.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ic={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dv={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,fv=Ii&&(!Ni||["ReactNative","NativeScript","NS"].indexOf(Ni.product)<0),pv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",hv=Ii&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ii,hasStandardBrowserEnv:fv,hasStandardBrowserWebWorkerEnv:pv,navigator:Ni,origin:hv},Symbol.toStringTag,{value:"Module"})),...dv};function mv(e,t){return zo(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function gv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xv(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function 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&&V.isArray(o)?o.length:i,l?(V.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!V.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&V.isArray(o[i])&&(o[i]=xv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(gv(r),o,n,0)}),n}return null}function vv(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Jr={transitional:Ic,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=V.isObject(t);if(s&&V.isHTMLForm(t)&&(t=new FormData(t)),V.isFormData(t))return o?JSON.stringify(Nc(t)):t;if(V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)||V.isReadableStream(t))return t;if(V.isArrayBufferView(t))return t.buffer;if(V.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return zo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),vv(t)):t}],transformResponse:[function(t){const n=this.transitional||Jr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(V.isResponse(t)||V.isReadableStream(t))return t;if(t&&V.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ae.from(a,Ae.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Jr.headers[e]={}});const wv=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),bv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
-
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&
|
|
32
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ac]=this[Ac]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Zr(i);r[a]||(Tv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Ft.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Ft);function ji(e,t){const n=this||Jr,r=t||n,o=Ft.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function jc(e){return!!(e&&e.__CANCEL__)}function vr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(vr,Ae,{__CANCEL__:!0});function Pc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function kv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ev(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(m*1e3/p):void 0}}function Iv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Uo=(e,t,n=3)=>{let r=0;const o=Ev(50,250);return Iv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},_c=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Rc=e=>(...t)=>V.asap(()=>e(...t)),Nv=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,Av=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];V.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),V.isString(r)&&i.push("path="+r),V.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function jv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Pv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Mc(e,t,n){let r=!jv(t);return e&&(r||n==!1)?Pv(e,t):t}const Oc=e=>e instanceof Ft?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,m){return V.isPlainObject(c)&&V.isPlainObject(d)?V.merge.call({caseless:m},c,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(c,d,f,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,m)}function s(c,d){if(!V.isUndefined(d))return r(void 0,d)}function i(c,d){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,f)=>o(Oc(c),Oc(d),f,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);V.isUndefined(m)&&f!==a||(n[d]=m)}),n}const Dc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ft.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)):""))),V.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Nt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Nv(t.url))){const l=o&&s&&Av.read(s);l&&i.set(o,l)}return t},_v=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Dc(e);let s=o.data;const i=Ft.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=Ft.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 Ae("Request aborted",Ae.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new Ae(S,Ae.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||Ic;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ae(k,S.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Uo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Uo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new vr(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=kv(o.url);if(b&&Nt.protocols.indexOf(b)===-1){r(new Ae("Unsupported protocol "+b+":",Ae.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Rv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Ae?d:new vr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>V.asap(a),l}},Mv=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Ov=async function*(e,t){for await(const n of Dv(e))yield*Mv(n,t)},Dv=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Lc=(e,t,n,r)=>{const o=Ov(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let f=d.byteLength;if(n){let m=s+=f;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},$c=64*1024,{isFunction:Wo}=V,Lv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Fc,TextEncoder:Bc}=V.global,zc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$v=e=>{e=V.merge.call({skipUndefined:!0},Lv,e);const{fetch:t,Request:n,Response:r}=e,o=t?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(Nt.origin,{body:new Fc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&zc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Ae(`Response type '${v}' is not supported`,Ae.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(Nt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(V.isArrayBufferView(v)||V.isArrayBuffer(v))return v.byteLength;if(V.isURLSearchParams(v)&&(v=v+""),V.isString(v))return(await l(v)).byteLength},p=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:j,withCredentials:R="same-origin",fetchOptions:D}=Dc(v),$=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Rv([b,C&&C.toAbortSignal()],k),X=null;const M=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let K;try{if(T&&c&&x!=="get"&&x!=="head"&&(K=await p(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(V.isFormData(y)&&(P=J.headers.get("content-type"))&&j.setContentType(P),J.body){const[B,A]=_c(K,Uo(Rc(T)));y=Lc(J.body,$c,B,A)}}V.isString(R)||(R=R?"include":"omit");const q=s&&"credentials"in n.prototype,z={...D,signal:U,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:q?R:void 0};X=s&&new n(g,z);let O=await(s?$(X,D):$(g,z));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&M)){const J={};["status","statusText","headers"].forEach(F=>{J[F]=O[F]});const P=V.toFiniteNumber(O.headers.get("content-length")),[B,A]=S&&_c(P,Uo(Rc(S),!0))||[];O=new r(Lc(O.body,$c,B,()=>{A&&A(),M&&M()}),J)}E=E||"text";let Y=await f[V.findKey(f,E)||"text"](O,v);return!I&&M&&M(),await new Promise((J,P)=>{Pc(J,P,{data:Y,headers:Ft.from(O.headers),status:O.status,statusText:O.statusText,config:v,request:X})})}catch(q){throw M&&M(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,v,X),{cause:q.cause||q}):Ae.from(q,q&&q.code,v,X)}}},Fv=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=Fv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:$v(t)),d=c;return c};Hc();const Pi={http:av,xhr:_v,fetch:{get:Hc}};V.forEach(Pi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Uc=e=>`- ${e}`,Bv=e=>V.isFunction(e)||e===null||e===!1,Wc={getAdapter:(e,t)=>{e=V.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Bv(r)&&(o=Pi[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${a}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
30
|
+
<%s key={someKey} {...props} />`,ec,pr,fN,pr),Fe[pr+ec]=!0}}return N===r?Ne(Tt):Se(Tt),Tt}}function Qe(N,te,de){return ve(N,te,de,!0)}function Re(N,te,de){return ve(N,te,de,!1)}var ht=Re,In=Qe;qr.Fragment=r,qr.jsx=ht,qr.jsxs=In}()),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)),sn=e=>(e=e.toLowerCase(),t=>$o(t)===e),Fo=e=>t=>typeof t===e,{isArray:gr}=Array,xr=Fo("undefined");function Gr(e){return e!==null&&!xr(e)&&e.constructor!==null&&!xr(e.constructor)&&$t(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const fc=sn("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"),$t=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=sn("Date"),jx=sn("File"),Px=sn("Blob"),_x=sn("FileList"),Rx=e=>Yr(e)&&$t(e.pipe),Mx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||$t(e.append)&&((t=$o(e))==="formdata"||t==="object"&&$t(e.toString)&&e.toString()==="[object FormData]"))},Ox=sn("URLSearchParams"),[Dx,Lx,$x,Fx]=["ReadableStream","Request","Response","Headers"].map(sn),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]),gr(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=>!xr(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):gr(o)?n[i]=o.slice():(!t||!xr(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&&$t(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(gr(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=sn("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=sn("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($t(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if($t(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 gr(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&&$t(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=gr(r)?[]:{};return Xr(r,(i,a)=>{const l=n(i,o+1);!xr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},sv=sn("AsyncFunction"),iv=e=>e&&(Yr(e)||$t(e))&&$t(e.then)&&$t(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",$t(Xn.postMessage)),av=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||vc,V={isArray:gr,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:xr,isDate:Ax,isFile:jx,isBlob:Px,isRegExp:Zx,isFunction:$t,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:sn,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&&$t(e[Lo])};function Ae(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}V.inherits(Ae,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const wc=Ae.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(Ae,bc),Object.defineProperty(wc,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(wc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Ae.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const lv=null;function ki(e){return V.isPlainObject(e)||V.isArray(e)}function yc(e){return V.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 V.isArray(e)&&!e.some(ki)}const uv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function zo(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!V.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!l&&V.isBlob(v))throw new Ae("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&cv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=yc(g),y.forEach(function(C,k){!(V.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(!V.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),V.forEach(v,function(y,b){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(b)?b.trim():b,g,m))===!0&&p(y,g?g.concat(b):[b])}),f.pop()}}if(!V.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;V.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=V.isURLSearchParams(t)?t.toString():new 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){V.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",Nt={...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 Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function xv(e){return V.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&&V.isArray(o)?o.length:i,l?(V.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!V.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&V.isArray(o[i])&&(o[i]=vv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(xv(r),o,n,0)}),n}return null}function wv(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Jr={transitional:Ic,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=V.isObject(t);if(s&&V.isHTMLForm(t)&&(t=new FormData(t)),V.isFormData(t))return o?JSON.stringify(Nc(t)):t;if(V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)||V.isReadableStream(t))return t;if(V.isArrayBufferView(t))return t.buffer;if(V.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return gv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return zo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),wv(t)):t}],transformResponse:[function(t){const n=this.transitional||Jr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(V.isResponse(t)||V.isReadableStream(t))return t;if(t&&V.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ae.from(a,Ae.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Jr.headers[e]={}});const bv=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),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:V.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(V.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!V.isString(t)){if(V.isString(r))return t.indexOf(r)!==-1;if(V.isRegExp(r))return r.test(t)}}function Tv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function kv(e,t){const n=V.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Ft=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=V.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)=>V.forEach(a,(c,d)=>s(c,d,l));if(V.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(V.isString(t)&&(t=t.trim())&&!Cv(t))i(yv(t),n);else if(V.isObject(t)&&V.isIterable(t)){let a={},l,c;for(const d of t){if(!V.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?V.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Zr(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Sv(o);if(V.isFunction(n))return n.call(this,o,r);if(V.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Zr(t),t){const r=V.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=V.findKey(r,i);a&&(!n||Ai(r,r[a],a,n))&&(delete r[a],o=!0)}}return V.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Ai(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return V.forEach(this,(o,s)=>{const i=V.findKey(r,s);if(i){n[i]=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 V.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&V.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
32
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ac]=this[Ac]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Zr(i);r[a]||(kv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Ft.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Ft);function ji(e,t){const n=this||Jr,r=t||n,o=Ft.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function jc(e){return!!(e&&e.__CANCEL__)}function vr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(vr,Ae,{__CANCEL__:!0});function Pc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function 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)=>V.asap(()=>e(...t)),Av=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,jv=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];V.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),V.isString(r)&&i.push("path="+r),V.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function 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 Ft?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,m){return V.isPlainObject(c)&&V.isPlainObject(d)?V.merge.call({caseless:m},c,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(c,d,f,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,m)}function s(c,d){if(!V.isUndefined(d))return r(void 0,d)}function i(c,d){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,f)=>o(Oc(c),Oc(d),f,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);V.isUndefined(m)&&f!==a||(n[d]=m)}),n}const Dc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ft.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)):""))),V.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Nt.hasStandardBrowserEnv&&(r&&V.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=Ft.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=Ft.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 Ae("Request aborted",Ae.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new Ae(S,Ae.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||Ic;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ae(k,S.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Uo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Uo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new vr(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&&Nt.protocols.indexOf(b)===-1){r(new Ae("Unsupported protocol "+b+":",Ae.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Mv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Ae?d:new vr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>V.asap(a),l}},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}=V,$v=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Fc,TextEncoder:Bc}=V.global,zc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fv=e=>{e=V.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(Nt.origin,{body:new Fc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&zc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Ae(`Response type '${v}' is not supported`,Ae.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(Nt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(V.isArrayBufferView(v)||V.isArrayBuffer(v))return v.byteLength;if(V.isURLSearchParams(v)&&(v=v+""),V.isString(v))return(await l(v)).byteLength},p=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:j,withCredentials:R="same-origin",fetchOptions:D}=Dc(v),$=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Mv([b,C&&C.toAbortSignal()],k),X=null;const M=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let K;try{if(T&&c&&x!=="get"&&x!=="head"&&(K=await p(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(V.isFormData(y)&&(P=J.headers.get("content-type"))&&j.setContentType(P),J.body){const[B,A]=_c(K,Uo(Rc(T)));y=Lc(J.body,$c,B,A)}}V.isString(R)||(R=R?"include":"omit");const q=s&&"credentials"in n.prototype,z={...D,signal:U,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:q?R:void 0};X=s&&new n(g,z);let O=await(s?$(X,D):$(g,z));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&M)){const J={};["status","statusText","headers"].forEach(F=>{J[F]=O[F]});const P=V.toFiniteNumber(O.headers.get("content-length")),[B,A]=S&&_c(P,Uo(Rc(S),!0))||[];O=new r(Lc(O.body,$c,B,()=>{A&&A(),M&&M()}),J)}E=E||"text";let Y=await f[V.findKey(f,E)||"text"](O,v);return!I&&M&&M(),await new Promise((J,P)=>{Pc(J,P,{data:Y,headers:Ft.from(O.headers),status:O.status,statusText:O.statusText,config:v,request:X})})}catch(q){throw M&&M(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,v,X),{cause:q.cause||q}):Ae.from(q,q&&q.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}};V.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=>V.isFunction(e)||e===null||e===!1,Wc={getAdapter:(e,t)=>{e=V.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!zv(r)&&(o=Pi[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${a}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Uc).join(`
|
|
34
|
-
`):" "+Uc(i[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Pi};function _i(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new vr(null,e)}function Vc(e){return _i(e),e.headers=Ft.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=Ft.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=Ft.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 Ae(o(i," has been removed"+(n?" in "+n:"")),Ae.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
|
|
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:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Ko.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ko.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ft.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)}};V.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}))}}),V.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 Hv=class ix{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 vr(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 ix(function(o){t=o}),cancel:t}}};function Uv(e){return function(n){return e.apply(null,n)}}function Wv(e){return V.isObject(e)&&e.isAxiosError===!0}const 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 V.extend(n,Zn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Gc(Jn(e,o))},n}const mt=Gc(Jr);mt.Axios=Zn,mt.CanceledError=vr,mt.CancelToken=Hv,mt.isCancel=jc,mt.VERSION=Kc,mt.toFormData=zo,mt.AxiosError=Ae,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=Uv,mt.isAxiosError=Wv,mt.mergeConfig=Jn,mt.AxiosHeaders=Ft,mt.formToJSON=e=>Nc(V.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=Wc.getAdapter,mt.HttpStatusCode=Ri,mt.default=mt;const{Axios:yN,AxiosError:SN,CanceledError:CN,isCancel:Yc,CancelToken:TN,VERSION:kN,all:EN,Cancel:IN,isAxiosError:NN,spread:AN,toFormData:jN,AxiosHeaders:PN,HttpStatusCode:_N,formToJSON:RN,getAdapter:MN,mergeConfig:ON}=mt,Xc=typeof window<"u"?window.__API_BASE_URL__:void 0,Jc=Xc?xn(Xc):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let 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,Kt=mt.create({...Jc?{baseURL:Jc}:{},timeout:eu,withCredentials:!0});Kt.interceptors.request.use(e=>(qo&&(e.headers.Authorization=`Bearer ${qo}`),e)),Kt.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 qt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Yo(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function nu(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Xo{get baseUrl(){const t=Kt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=xn(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 qt("/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Mt(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 Mt(r)}async updateThread(t,n){const r=await nu(`/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return Mt(n)}async shareThread(t,n){const r=await Yo(`/threads/${t}/share`,{shared_with_user_id:n});return Mt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await qt("/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Mt(n)}async getState(t){const n=await qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:tu,signal:t.signal});return Mt(n)}async cancelRun(t){const n=await Yo("/runs/cancel",{threadId:t});return Mt(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return Mt(r)}}const Nn=new Xo,Vv=Xo,Kv=Xo;async function Di(e,t){return await qt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function qv(e,t){const n=await 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 qt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Gv(e){return await qt(`/files/${e}`)}async function ou(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/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 Yv(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function 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=Xv(a,s);if(f===""?l="":f===s?l=s:l=f,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const 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 Xv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=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 Jv(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return eo(e,r,s)}return e}function hu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Zv(e={}){const t=w.useMemo(()=>xn(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),j=w.useRef(null),R=w.useRef(null),D=w.useRef(null),$=w.useRef(null),U=w.useRef({messageId:null,lastSeq:null,lastText:""}),X=w.useCallback(z=>{o(z)},[]),M=w.useCallback(()=>{m(""),v(null),d(null),R.current=null,D.current=null,$.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""}},[]),K=w.useCallback(()=>{var Y;console.debug("[use-chat] stop() invoked - aborting stream");const z=(Y=j.current)==null?void 0:Y.threadId,O=()=>{var J;(J=S.current)==null||J.abort(),S.current=null,j.current=null,l(!1),b(!1),E.current=0,x(0)};(z?Nn.cancelRun(z).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(O)},[]),q=w.useCallback((z,O,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),R.current=null,D.current=null,$.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""};const Y=new AbortController;S.current=Y;let J=null,P=null,B=!1;return j.current={threadId:z.threadId??null,headers:{}},(async()=>{var F,W,L,_,G,Z,oe,se,ie,le,ye,De,He,_e,$e,ct,ft,St;const A=Ke=>{var Ye;try{const Ue=JSON.parse(JSON.stringify(Ke));return(Ye=Ue==null?void 0:Ue.payload)!=null&&Ye.files_info&&Array.isArray(Ue.payload.files_info)&&(Ue.payload.files_info=Ue.payload.files_info.map(Le=>({...Le,data:Le!=null&&Le.data?`<base64 ${String(Le.data).length} chars>`:Le==null?void 0:Le.data}))),Ue}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const We=window.__AUTH_TOKEN__,Ct=((F=window.localStorage)==null?void 0:F.getItem("authToken"))||null;let ee=null;try{const tt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");tt&&(ee=((L=JSON.parse(tt))==null?void 0:L.apiKey)||null)}catch{}const he=We||Ct||ee||null;he&&(Ke={Authorization:`Bearer ${he}`})}}catch{}console.debug("[use-chat] POST",t+n,A(z));let Ye={};if(typeof window<"u")try{const qe=(_=window.localStorage)==null?void 0:_.getItem("authSessionId");qe&&(Ye={"X-Session-Id":qe})}catch{}const Ue={...Ke,...Ye,...s.current},Le={"Content-Type":"application/json",Accept:"text/event-stream",...Ue},je=await fetch(t+n,{method:"POST",headers:Le,body:JSON.stringify(z),signal:Y.signal,credentials:i});if(j.current&&(j.current.headers=Ue),!je.ok||!je.body){const qe=await je.text().catch(()=>"");console.debug("[use-chat] non-OK response",je.status,qe==null?void 0:qe.slice(0,500));const We=`stream ${je.status}${qe?": "+qe:""}`;throw(G=I==null?void 0:I.onConnectionError)==null||G.call(I,We),B=!0,J="error",P=We,new Error(We)}b(!0);const pt=je.body.getReader(),Rt=new TextDecoder;let et="",st=[];E.current=0,x(0);let vt=0,ut=null;const wt=()=>{if(st.length){const qe=st.join("");st=[],T.current&&m(We=>We+qe)}ut=null},rn=()=>{typeof window<"u"&&ut==null&&(ut=requestAnimationFrame(wt))};let It=Date.now();const mn=setInterval(()=>{var qe;if(Date.now()-It>18e5){const We="Stream idle timeout";d(We),J="error",P=We,Y.abort(),(qe=I==null?void 0:I.onError)==null||qe.call(I,We)}},5e3),Zt=1024*1024;try{const qe=je.headers.get("X-Thread-Id")||je.headers.get("x-thread-id"),We=je.headers.get("X-Thread-Created")||je.headers.get("x-thread-created"),Ct=qe??null,ee=String(We??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Ct}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:Ct,created:ee});;){const{value:he,done:tt}=await pt.read();if(tt)break;et+=Rt.decode(he,{stream:!0}),et.length>Zt&&(et="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=et.indexOf(`
|
|
34
|
+
`):" "+Uc(i[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Pi};function _i(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new vr(null,e)}function Vc(e){return _i(e),e.headers=Ft.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=Ft.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=Ft.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 Ae(o(i," has been removed"+(n?" in "+n:"")),Ae.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 Ae("options must be an object",Ae.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Ae("option "+s+" must be "+l,Ae.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ae("Unknown option "+s,Ae.ERR_BAD_OPTION)}}const Ko={assertOptions:Hv,validators:Vo},gn=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:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Ko.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ko.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ft.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)}};V.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}))}}),V.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 vr(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 V.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 V.extend(n,Zn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Gc(Jn(e,o))},n}const mt=Gc(Jr);mt.Axios=Zn,mt.CanceledError=vr,mt.CancelToken=Uv,mt.isCancel=jc,mt.VERSION=Kc,mt.toFormData=zo,mt.AxiosError=Ae,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=Wv,mt.isAxiosError=Vv,mt.mergeConfig=Jn,mt.AxiosHeaders=Ft,mt.formToJSON=e=>Nc(V.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=Wc.getAdapter,mt.HttpStatusCode=Ri,mt.default=mt;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}=mt,Xc=typeof window<"u"?window.__API_BASE_URL__:void 0,Jc=Xc?xn(Xc):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let 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,Kt=mt.create({...Jc?{baseURL:Jc}:{},timeout:eu,withCredentials:!0});Kt.interceptors.request.use(e=>(qo&&(e.headers.Authorization=`Bearer ${qo}`),e)),Kt.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 qt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Yo(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function nu(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Xo{get baseUrl(){const t=Kt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=xn(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 qt("/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Mt(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 Mt(r)}async updateThread(t,n){const r=await nu(`/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return Mt(n)}async shareThread(t,n){const r=await Yo(`/threads/${t}/share`,{shared_with_user_id:n});return Mt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await qt("/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Mt(n)}async getState(t){const n=await qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:tu,signal:t.signal});return Mt(n)}async cancelRun(t){const n=await Yo("/runs/cancel",{threadId:t});return Mt(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return Mt(r)}}const Nn=new Xo,Kv=Xo,qv=Xo;async function Di(e,t){return await qt(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 qt(`/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 qt(`/files/${e}`)}async function ou(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/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(()=>xn(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),j=w.useRef(null),R=w.useRef(null),D=w.useRef(null),$=w.useRef(null),U=w.useRef({messageId:null,lastSeq:null,lastText:""}),X=w.useCallback(z=>{o(z)},[]),M=w.useCallback(()=>{m(""),v(null),d(null),R.current=null,D.current=null,$.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""}},[]),K=w.useCallback(()=>{var Y;console.debug("[use-chat] stop() invoked - aborting stream");const z=(Y=j.current)==null?void 0:Y.threadId,O=()=>{var J;(J=S.current)==null||J.abort(),S.current=null,j.current=null,l(!1),b(!1),E.current=0,x(0)};(z?Nn.cancelRun(z).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(O)},[]),q=w.useCallback((z,O,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),R.current=null,D.current=null,$.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""};const Y=new AbortController;S.current=Y;let J=null,P=null,B=!1;return j.current={threadId:z.threadId??null,headers:{}},(async()=>{var F,W,L,_,G,Z,oe,se,ie,le,ye,De,He,_e,$e,ct,ft,St;const A=Ke=>{var Ye;try{const Ue=JSON.parse(JSON.stringify(Ke));return(Ye=Ue==null?void 0:Ue.payload)!=null&&Ye.files_info&&Array.isArray(Ue.payload.files_info)&&(Ue.payload.files_info=Ue.payload.files_info.map(Le=>({...Le,data:Le!=null&&Le.data?`<base64 ${String(Le.data).length} chars>`:Le==null?void 0:Le.data}))),Ue}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const We=window.__AUTH_TOKEN__,Ct=((F=window.localStorage)==null?void 0:F.getItem("authToken"))||null;let ee=null;try{const tt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");tt&&(ee=((L=JSON.parse(tt))==null?void 0:L.apiKey)||null)}catch{}const he=We||Ct||ee||null;he&&(Ke={Authorization:`Bearer ${he}`})}}catch{}console.debug("[use-chat] POST",t+n,A(z));let Ye={};if(typeof window<"u")try{const qe=(_=window.localStorage)==null?void 0:_.getItem("authSessionId");qe&&(Ye={"X-Session-Id":qe})}catch{}const Ue={...Ke,...Ye,...s.current},Le={"Content-Type":"application/json",Accept:"text/event-stream",...Ue},je=await fetch(t+n,{method:"POST",headers:Le,body:JSON.stringify(z),signal:Y.signal,credentials:i});if(j.current&&(j.current.headers=Ue),!je.ok||!je.body){const qe=await je.text().catch(()=>"");console.debug("[use-chat] non-OK response",je.status,qe==null?void 0:qe.slice(0,500));const We=`stream ${je.status}${qe?": "+qe:""}`;throw(G=I==null?void 0:I.onConnectionError)==null||G.call(I,We),B=!0,J="error",P=We,new Error(We)}b(!0);const pt=je.body.getReader(),Rt=new TextDecoder;let et="",st=[];E.current=0,x(0);let vt=0,ut=null;const wt=()=>{if(st.length){const qe=st.join("");st=[],T.current&&m(We=>We+qe)}ut=null},rn=()=>{typeof window<"u"&&ut==null&&(ut=requestAnimationFrame(wt))};let It=Date.now();const mn=setInterval(()=>{var qe;if(Date.now()-It>18e5){const We="Stream idle timeout";d(We),J="error",P=We,Y.abort(),(qe=I==null?void 0:I.onError)==null||qe.call(I,We)}},5e3),Zt=1024*1024;try{const qe=je.headers.get("X-Thread-Id")||je.headers.get("x-thread-id"),We=je.headers.get("X-Thread-Created")||je.headers.get("x-thread-created"),Ct=qe??null,ee=String(We??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Ct}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:Ct,created:ee});;){const{value:he,done:tt}=await pt.read();if(tt)break;et+=Rt.decode(he,{stream:!0}),et.length>Zt&&(et="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=et.indexOf(`
|
|
36
36
|
|
|
37
37
|
`))>=0;){const ce=et.slice(0,xe);et=et.slice(xe+2);const Ie=ce.split(/\r?\n/),it=[];for(const Re of Ie)if(!(!Re||Re.startsWith(":"))&&Re.startsWith("data:")){const ht=Re.slice(5);it.push(ht.startsWith(" ")?ht.slice(1):ht)}const Se=it.join(`
|
|
38
|
-
`);if(!Se)continue;let Ne;try{Ne=JSON.parse(Se)}catch{console.debug("[use-chat] malformed SSE:",Se.slice(0,200));continue}const Fe=cu(Ne)?Ne.data:Ne;if(!Fe){console.warn("[use-chat] dropped envelope event without payload",Ne);continue}const ve=Fe;It=Date.now();const Qe=ve.seq;if(Qe!==void 0){if(Qe<=vt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Qe,lastProcessedSeq:vt,type:ve.type});continue}vt>0&&Qe>vt+1&&((oe=I==null?void 0:I.onGap)==null||oe.call(I,{from:vt,to:Qe})),vt=Qe,E.current=Qe,x(Qe)}if(ve.type==="message.start"&&ve.role==="assistant"){const Re=hu(ve.model);U.current={messageId:ve.id,lastSeq:Qe??null,lastText:""},k({id:ve.id,role:"assistant",name:Re??void 0,model:ve.model,createdAt:new Date().toISOString(),content:[]})}if(ve.type==="checkpoint")R.current=ve.checkpointId??null,D.current=ve.checkpointNs??null,v(ve.checkpointId??null);else if(ve.type==="state_history"){$.current=ve;try{const ht=Yn(ve).latest;ht&&(R.current=ht.checkpointId??null,D.current=ht.checkpointNs??null,v(ht.checkpointId??null))}catch(Re){console.warn("[use-chat] Failed to hydrate state_history payload",Re)}}try{O==null||O(ve)}catch(Re){console.error("[use-chat] Error in onEvent callback:",Re,"for event:",ve.type)}if(ve.type==="message.delta"){k(ht=>{const In=U.current;if(!ht||In.messageId!==ht.id)return ht;const{newParts:N,newMeta:te,changed:de}=fu(ht.content??[],ve.delta,{lastSeq:In.lastSeq,lastText:In.lastText},Qe??null);return de?(U.current={...In,lastSeq:te.lastSeq??In.lastSeq,lastText:te.lastText??In.lastText},{...ht,content:N}):ht});const Re=ve.delta.filter(ht=>ht.type==="text").map(ht=>ht.text).join("");Re&&e.autoAppendAssistant!==!1&&(st.push(Re),rn())}else if(ve.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(se=I==null?void 0:I.onHeartbeat)==null||se.call(I,ve)}catch(Re){console.warn("[use-chat] heartbeat callback failed",Re)}}else if(ut!==null&&cancelAnimationFrame(ut),wt(),ve.type==="checkpoint")v(ve.checkpointId);else if(ve.type==="error"){const Re=ve;if(d(Re.message),J="error",P=Re.message,Re.error_type==="auth_error"||Re.code==="TOKEN_EXPIRED"||((ie=Re.message)==null?void 0:ie.includes("token"))||((le=Re.message)==null?void 0:le.includes("401"))||((ye=Re.message)==null?void 0:ye.includes("unauthorized"))||((De=Re.message)==null?void 0:De.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Re.message);try{(He=I==null?void 0:I.onAuthError)==null||He.call(I,Re.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}Y.abort()}}}}wt(),J===null&&!Y.signal.aborted&&(J="complete")}catch(qe){if(qe.name==="AbortError")J=J??"aborted";else{const We=qe.message||String(qe);J="error",P=We,d(We),(_e=I==null?void 0:I.onError)==null||_e.call(I,We)}}finally{try{await pt.cancel()}catch{}finally{($e=pt.releaseLock)==null||$e.call(pt)}ut!==null&&typeof window<"u"&&window.cancelAnimationFrame(ut),clearInterval(mn)}}catch(Ke){if(Ke.name==="AbortError")J=J??"aborted";else{const Ye=Ke.message||String(Ke);J="error",P=Ye,d(Ye),(ct=I==null?void 0:I.onError)==null||ct.call(I,Ye),B||((ft=I==null?void 0:I.onConnectionError)==null||ft.call(I,Ye),B=!0)}}finally{const Ke=E.current,Ye=R.current,Ue=D.current,Le=$.current,je=J??(Y.signal.aborted?"aborted":P?"error":"complete");try{(St=I==null?void 0:I.onClosed)==null||St.call(I,{reason:je,lastSeq:Ke,lastCheckpointId:Ye,lastCheckpointNs:Ue,lastStateHistory:Le,error:P})}catch(pt){console.warn("[use-chat] onClosed callback failed",pt)}l(!1),b(!1),S.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>Y.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var z;T.current=!1,(z=S.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:C,lastCheckpointId:p,lastSeq:g,connected:y,stream:q,stop:K,clear:M,setToken:X}}const Qv=["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 Qv){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 ew(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 j=w.useCallback(async()=>{d(!0),m(null);try{const O=await e.listThreads();i(O??[])}catch(O){const I=String(O);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),R=w.useCallback(async()=>{x(!0),y(null);try{const O=await e.listSharedThreads();v(O??[])}catch(O){const I=String(O);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{j()},[j]),w.useEffect(()=>{R()},[R]),w.useEffect(()=>{r==null||r(a)},[a,r]);const D=w.useCallback(async O=>{try{const I=await e.createThread(O);return l(I.threadId),await j(),I.threadId}catch(I){const Y=String(I);return n==null||n(Y),null}},[e,n,j]),$=w.useCallback(async O=>{const I=s;i(J=>J.filter(P=>P.threadId!==O));const Y=new AbortController;E.current.set(O,Y);try{await e.deleteThread(O),T.current===O&&(l(null),o==null||o())}catch(J){i(I);const P=String(J);n==null||n(P)}finally{E.current.delete(O)}},[e,o,n,s]),U=w.useCallback(async(O,I)=>{try{await e.updateThread(O,I),await j()}catch(Y){n==null||n(String(Y))}},[e,n,j]),X=w.useCallback(async(O,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(O,I),await R(),C("Shared successfully")}catch(Y){const J=ew(Y);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{S(!1)}},[e,n,R]),M=w.useCallback(async(O,I)=>{try{await e.unshareThread(O,I),await R()}catch(Y){const J=String(Y);throw n==null||n(J),Y}},[e,n,R]),K=w.useMemo(()=>({createThread:D,deleteThread:$,renameThread:U,refreshThreads:j,refreshSharedThreads:R,shareThread:X,unshareThread:M}),[D,$,U,j,R,X,M]),q=w.useCallback(O=>{if(!(O!=null&&O.threadId))return;const I={threadId:O.threadId,title:O.title||`Thread ${O.threadId.slice(0,8)}`,createdAt:O.createdAt||new Date().toISOString(),updatedAt:O.updatedAt||new Date().toISOString(),messageCount:O.messageCount??1};i(Y=>{let J=!1;const P=Y.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?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...Y])})},[]),z=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:K,addThreadFromEvent:q,shareInFlight:k,shareStatus:b,clearShareStatus:z}}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 wr(){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=tw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function tw(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 br(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 nw(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function rw(e){const t=br(e);return typeof e=="string"&&nw(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function yr(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 yr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?yr(e.content):e}function ow(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 Bi(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function sw(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 iw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function wu(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 aw(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function lw(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function cw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=aw(n),i=o?`data:${s};base64,${e}`:t,a=lw(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function uw(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 cw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function bu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const dw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function fw(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 yu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>yu(o,s),e):e}default:return e}}function pw(e=[]){const[t,n]=w.useReducer(fw,{...dw,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 yu(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 mw(e,t);if(t.type==="tool.progress")return gw(e,t);if(t.type==="tool.end")return xw(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=Jv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Yn(t),i=s.interrupt,a=s.latest,l=i===null?Yv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function zi(e){return e.call_id??e.id??null}function Su(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Cu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Hi(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Fi(r).toolCallId===t)return n}return-1}function hw(e){if(e==null)return[];const t=yr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=br(t??e);return n?[{type:"text",text:n}]:[]}function Tu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function mw(e,t){const n=zi(t),r=Hi(e.messages,n),o=t.name??t.tool??void 0,s=Su(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=Cu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function gw(e,t){const n=zi(t);if(!n)return e;const r=Hi(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=Tu(e.messages[r],o);return{...e,messages:eo(e.messages,r,a)}}function xw(e,t){const n=zi(t),r=Su(t);let o=e.messages,s=Hi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Cu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=hw(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=Tu(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 ku({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),j=w.useRef(null),R=w.useRef(null),D=w.useRef(null),$=w.useRef(null),U=w.useRef(new Map),X=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const M=w.useCallback(async A=>{var W,L;if(!A.threadId)return;const F=A.threadId;(W=A.onStart)==null||W.call(A),A.setLoading(!0);try{await A.action(F)}catch(_){if(!Yc(_)&&T.current===F){const Z=String(_);(L=A.handleError)==null||L.call(A,Z),n==null||n(Z)}throw _}finally{A.setLoading(!1)}},[n]),K=w.useCallback(async(A,F)=>{var Z;if(!A)return;const W=`${A}:${F??"latest"}`,L=U.current.get(W);if(L)return L;(Z=X.current)==null||Z.abort();const _=new AbortController;X.current=_;const G=M({threadId:A,setLoading:y,onStart:()=>S(null),handleError:oe=>S(oe),action:async oe=>{const se=await e.getStateHistory({threadId:oe,checkpointId:F??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:ie}=Yn(se),le=ie.find(ye=>ye.messages&&ye.messages.length>0)??(F?ie.find(ye=>ye.checkpointId===F):null)??ie[0];t((le==null?void 0:le.messages)??[],{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),f(se)}});U.current.set(W,G);try{await G}finally{U.current.delete(W),X.current===_&&(X.current=null)}return T.current===A&&($.current=W),G},[e,t,M]),q=w.useCallback(async(A,F)=>{D.current=A;try{await K(A,F)}catch(W){if(!Yc(W))throw W}finally{D.current===A&&(D.current=null)}},[K]),z=w.useCallback(A=>{j.current=A},[]),O=w.useCallback(A=>{R.current=A},[]),I=w.useCallback(A=>{const F=A.threadId??T.current;if(!F||T.current&&T.current!==F)return;const{checkpoints:W}=Yn(A);if(!W.length)return;const L=W.find(G=>G.messages&&G.messages.length>0)??W.find(G=>!!G.checkpointId)??W[0],_=R.current===F;!l&&!_&&t((L==null?void 0:L.messages)??[],{checkpointId:(L==null?void 0:L.checkpointId)??null,checkpointNs:(L==null?void 0:L.checkpointNs)??null}),f(A),$.current=`${F}:latest`,j.current=null,R.current===F&&(R.current=null)},[t,l]),Y=w.useCallback(async(A,F)=>{const W=T.current;await M({threadId:W,setLoading:C,action:async L=>{const _=await e.getStateHistory({threadId:L,checkpointId:A,checkpointNs:F??void 0});if(T.current!==L)return;const{checkpoints:G}=Yn(_),Z=G.find(oe=>oe.checkpointId===A&&(F?oe.checkpointNs===F:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:A,checkpointNs:F});return}f(_),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,M]),J=w.useCallback((A,F)=>{t(c(),{checkpointId:A??null,checkpointNs:F??null})},[c,t]),P=w.useCallback(async()=>{T.current&&await q(T.current)},[q]);w.useEffect(()=>{if(!a||!r||x||l)return;if(j.current===r){j.current=null,E.current=r;return}if(R.current===r){E.current=r;return}if(D.current===r){D.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let A;const F=`${r}:latest`;$.current!==F&&q(r,A)},[a,r,s,i,o,x,l,q]);const B=w.useCallback(()=>{f(null),y(!1),C(!1),S(null),j.current=null,R.current=null,E.current=null,$.current=null,D.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:q,navigateToCheckpoint:Y,setCurrentCheckpointId:J,returnToLatest:P,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:O,resetHistoryState:B}}const Eu=w.createContext(null),Iu=w.createContext(null);function ro(){const e=w.useContext(Eu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Nu(){const e=w.useContext(Iu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Au({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Qr(),{currentThreadId:l}=wr(),{state:c,seed:d,pushUser:f,onEvent:m}=pw(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:R,resetHistoryState:D}=ku({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])}),[$,U]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[X,M]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),D())},[l,d,D]);const K=w.useCallback(Y=>U(()=>Y),[]),q=w.useCallback(Y=>M(()=>Y),[]),z=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),O=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:z,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:$,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:$,respondToInterrupt:X,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:R,resetHistoryState:D,pushUser:f,onEvent:m}),[l,c,p,v,g,z,x,y,b,$,k,S,T,C,X,g.messagePreviews,E,j,R,D,f,m]),I=w.useMemo(()=>({registerClearThread:K,registerRespondToInterrupt:q}),[K,q]);return u.jsx(Iu.Provider,{value:I,children:u.jsx(Eu.Provider,{value:O,children:e})})}function ju(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 vw(e){const t=ju(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ju(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function ww(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 bw(e,t){const n=[...e].sort(ww);for(const r of n){if(r.messageId!==t)continue;const o=vw(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 Pu=w.createContext(null),_u=w.createContext(!1);function yw({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(()=>xn(f),[f]),{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=Zv({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(Au,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(_u.Provider,{value:!0,children:u.jsx(Sw,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function Sw({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}=wr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=ro(),{registerClearThread:E,registerRespondToInterrupt:j}=Nu(),R=w.useCallback(z=>{v(z),p.current!==z.threadId&&((z.created??!p.current)&&b(z.threadId),C(z.threadId),m(z.threadId))},[v,b,C,m,p]),D=w.useCallback(z=>{z.type==="thread_info"?R(z):z.type==="state_history"?y(z):z.type==="tool.end"?i==null||i(z):T(z)},[R,y,T,i]),$=w.useCallback(z=>{a(z,D,{onError:O=>{console.error("[StreamingProvider] Stream error:",O),r==null||r(O)},onAuthError:O=>{console.error("[StreamingProvider] Auth error:",O),o==null||o(O)},onConnectionError:O=>{console.error("[StreamingProvider] Connection error:",O),s==null||s(O)}})},[a,D,r,o,s]),U=w.useRef(g);w.useEffect(()=>{U.current=g},[g]);const X=w.useCallback(async(z,O,I)=>{const Y=p.current;if(!Y)throw new Error("No active thread to handle interrupt");const J=O?I??!0:!1,P=U.current,B={threadId:Y,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:J}};$(B)},[p,$]);w.useEffect(()=>{j(X)},[X,j]);const M=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(M)},[M,E]);const K=w.useCallback(async(z,O)=>{let I=p.current;const Y=(z==null?void 0:z.text)??"",J=(z==null?void 0:z.attachments)??[],P=(Y==null?void 0:Y.trim())??"",B={...(z==null?void 0:z.payload)??{}},A=Array.isArray(B.messages)?B.messages:void 0;A&&delete B.messages;const F=!!(A&&A.length);if(!I&&!P&&J.length===0&&!F)return;if(!I){const _e=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=`${_e}${$e}`,b(I),m(I)}const{contentParts:W,filesInfo:L}=await lu(J),_=[...W];P&&_.push({type:"text",text:Y});const G=O==null?void 0:O.originalMessageId,Z=!!(O!=null&&O.edit&&G),oe=!F&&_.length>0;let se=null;oe&&(se={id:Z?G:`msg-${Date.now()}`,role:"user",content:_,createdAt:new Date().toISOString()},Z?S(se,G):S(se));const ie=F?A:se?[se]:[],le={...B,...L.length?{files_info:L}:{}};ie.length?le.messages=ie:"messages"in le||(le.messages=[]);let ye=(O==null?void 0:O.checkpointId)??g.id??void 0,De=(O==null?void 0:O.checkpointNs)??g.namespace??void 0;if(Z&&G){const _e=bw(x,G);ye=_e.checkpointId,De=_e.checkpointNs??void 0}const He={threadId:I,payload:le,checkpointId:ye,checkpointNs:De,edit:!!(O!=null&&O.edit)};$(He)},[g,p,b,S,$,x]),q=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:K,send:K,stop:l,setAuthToken:f}),[c,d,K,l,f]);return u.jsx(Pu.Provider,{value:q,children:e})}function Ui(){const e=w.useContext(Pu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Cw(){return w.useContext(_u)}function Ru(e){return typeof e=="object"&&e!==null}function Tw(e,t){if(Object.is(e,t))return!0;if(!Ru(e)||!Ru(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 Mu(e){const t=w.useRef(e),n=w.useRef(e);return Tw(t.current,e)||(t.current=e,n.current=e),n.current}function Sr({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=Mu(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(yw,{...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 Cr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function kw(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Ou(){const e=[Cr("__API_BASE_URL__"),Cr("__CHAT_API_BASE_URL__"),Cr("__CHAT_API_URL__")];for(const t of e){const n=kw(t);if(n)return n}}function Du(){const e=[Cr("__API_AUTH_TOKEN__"),Cr("__CHAT_API_KEY__"),Cr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Lu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function $u(){const e={},t=Ou(),n=Du();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Fu(){const e=$u(),t=Nn.getAuthToken(),n=Ou();return{apiBaseUrl:Lu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Du()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Wi="chat-settings";function Bu(){try{const e=localStorage.getItem(Wi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function zu(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Wi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Ew(){const e=Fu(),t=Bu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Lu(Nn.baseUrl,r,e.apiBaseUrl)}}function Iw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),zu(e)}function ne(...e){return lx.twMerge(ax.clsx(e))}const Nw=Wr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Xe=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:ne(Nw({variant:t,size:n,className:e})),ref:s,...o})});Xe.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 Hu(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=Hu(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():Hu(e[o],null)}}}}function Me(...e){return h.useCallback(Mn(...e),e)}function Aw(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 an(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,jw(o,...t)]}function jw(...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 Et=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Pw=h[" useInsertionEffect ".trim().toString()]||Et;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=_w({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=Rw(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 _w({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Pw(()=>{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 Rw(e){return typeof e=="function"}var Mw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=Mw.reduce((e,t)=>{const n=Vt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Vi(e,t){e&&Vr.flushSync(()=>e.dispatchEvent(t))}function Zo(e){const t=e+"CollectionProvider",[n,r]=an(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=Vt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=Me(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Vt.createSlot(d),p=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=Me(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 Ow=h.createContext(void 0);function Qo(e){const t=h.useContext(Ow);return e||t||"ltr"}function gt(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 Dw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(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 Lw="DismissableLayer",Ki="dismissableLayer.update",$w="dismissableLayer.pointerDownOutside",Fw="dismissableLayer.focusOutside",Uu,Wu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Tr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Wu),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Me(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=zw(E=>{const j=E.target,R=[...c.branches].some(D=>D.contains(j));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Hw(E=>{const j=E.target;[...c.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Dw(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&&(Uu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Ku(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Uu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Ku())},[d,c]),h.useEffect(()=>{const E=()=>p({});return document.addEventListener(Ki,E),()=>document.removeEventListener(Ki,E)},[]),u.jsx(me.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)})});Tr.displayName=Lw;var Bw="DismissableLayerBranch",Vu=h.forwardRef((e,t)=>{const n=h.useContext(Wu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(me.div,{...e,ref:o})});Vu.displayName=Bw;function zw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){qu($w,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 Hw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&qu(Fw,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 Ku(){const e=new CustomEvent(Ki);document.dispatchEvent(e)}function qu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Vi(o,s):o.dispatchEvent(s)}var Uw=Tr,Ww=Vu,qi=0;function Gi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Gu()),document.body.insertAdjacentElement("beforeend",e[1]??Gu()),qi++,()=>{qi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qi--}},[])}function Gu(){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 Yi="focusScope.autoFocusOnMount",Xi="focusScope.autoFocusOnUnmount",Yu={bubbles:!1,cancelable:!0},Vw="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=gt(o),d=gt(s),f=h.useRef(null),m=Me(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){Zu.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Yi,Yu);a.addEventListener(Yi,c),a.dispatchEvent(y),y.defaultPrevented||(Kw(Jw(Xu(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Yi,c),setTimeout(()=>{const y=new CustomEvent(Xi,Yu);a.addEventListener(Xi,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Xi,d),Zu.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]=qw(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(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});es.displayName=Vw;function Kw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function qw(e){const t=Xu(e),n=Ju(t,e),r=Ju(t.reverse(),e);return[n,r]}function Xu(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 Ju(e,t){for(const n of e)if(!Gw(n,{upTo:t}))return n}function Gw(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 Yw(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&&Yw(e)&&t&&e.select()}}var Zu=Xw();function Xw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Qu(e,t),e.unshift(t)},remove(t){var n;e=Qu(e,t),(n=e[0])==null||n.resume()}}}function Qu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Jw(e){return e.filter(t=>t.tagName!=="A")}var Zw=h[" useId ".trim().toString()]||(()=>{}),Qw=0;function At(e){const[t,n]=h.useState(Zw());return Et(()=>{n(r=>r??String(Qw++))},[e]),t?`radix-${t}`:""}const eb=["top","right","bottom","left"],Ln=Math.min,Gt=Math.max,ts=Math.round,ns=Math.floor,vn=e=>({x:e,y:e}),tb={left:"right",right:"left",bottom:"top",top:"bottom"},nb={start:"end",end:"start"};function Ji(e,t,n){return Gt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function kr(e){return e.split("-")[1]}function Zi(e){return e==="x"?"y":"x"}function Qi(e){return e==="y"?"height":"width"}const rb=new Set(["top","bottom"]);function wn(e){return rb.has(jn(e))?"y":"x"}function ea(e){return Zi(wn(e))}function ob(e,t,n){n===void 0&&(n=!1);const r=kr(e),o=ea(e),s=Qi(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 sb(e){const t=rs(e);return[ta(e),t,ta(t)]}function ta(e){return e.replace(/start|end/g,t=>nb[t])}const ed=["left","right"],td=["right","left"],ib=["top","bottom"],ab=["bottom","top"];function lb(e,t,n){switch(e){case"top":case"bottom":return n?t?td:ed:t?ed:td;case"left":case"right":return t?ib:ab;default:return[]}}function cb(e,t,n,r){const o=kr(e);let s=lb(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ta)))),s}function rs(e){return e.replace(/left|right|bottom|top/g,t=>tb[t])}function ub(e){return{top:0,right:0,bottom:0,left:0,...e}}function nd(e){return typeof e!="number"?ub(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 rd(e,t,n){let{reference:r,floating:o}=e;const s=wn(t),i=ea(t),a=Qi(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(kr(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const db=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}=rd(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}=rd(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=nd(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 fb=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=nd(d),m={x:n,y:r},p=ea(o),v=Qi(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 j=k/2-S/2,R=E/2-g[v]/2-1,D=Ln(f[y],R),$=Ln(f[b],R),U=D,X=E-g[v]-$,M=E/2-g[v]/2+j,K=Ji(U,M,X),q=!l.arrow&&kr(o)!=null&&M!==K&&s.reference[v]/2-(M<U?D:$)-g[v]/2<0,z=q?M<U?M-U:M-X:0;return{[p]:m[p]+z,data:{[p]:K,centerOffset:M-K-z,...q&&{alignmentOffset:z}},reset:q}}}),pb=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=wn(a),C=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[rs(a)]:sb(a)),T=v!=="none";!m&&T&&S.push(...cb(a,g,v,k));const E=[a,...S],j=await so(t,x),R=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(j[y]),f){const M=ob(o,i,k);R.push(j[M[0]],j[M[1]])}if(D=[...D,{placement:o,overflows:R}],!R.every(M=>M<=0)){var $,U;const M=((($=s.flip)==null?void 0:$.index)||0)+1,K=E[M];if(K&&(!(f==="alignment"?b!==wn(K):!1)||D.every(O=>wn(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:M,overflows:D},reset:{placement:K}};let q=(U=D.filter(z=>z.overflows[0]<=0).sort((z,O)=>z.overflows[1]-O.overflows[1])[0])==null?void 0:U.placement;if(!q)switch(p){case"bestFit":{var X;const z=(X=D.filter(O=>{if(T){const I=wn(O.placement);return I===b||I==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(I=>I>0).reduce((I,Y)=>I+Y,0)]).sort((O,I)=>O[1]-I[1])[0])==null?void 0:X[0];z&&(q=z);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function od(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function sd(e){return eb.some(t=>e[t]>=0)}const hb=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=od(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:sd(i)}}}case"escaped":{const s=await so(t,{...o,altBoundary:!0}),i=od(s,n.floating);return{data:{escapedOffsets:i,escaped:sd(i)}}}default:return{}}}}},id=new Set(["left","top"]);async function mb(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=kr(n),l=wn(n)==="y",c=id.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 gb=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 mb(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}}}}},xb=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=wn(jn(o)),m=Zi(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=Ji(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=Ji(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}}}}}},vb=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=wn(o),m=Zi(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=id.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}}}},wb=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=kr(o),p=wn(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,j=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const D=Gt(d.left,0),$=Gt(d.right,0),U=Gt(d.top,0),X=Gt(d.bottom,0);p?j=v-2*(D!==0||$!==0?D+$:Gt(d.left,d.right)):E=g-2*(U!==0||X!==0?U+X:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function Er(e){return ad(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function bn(e){var t;return(t=(ad(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ad(e){return ss()?e instanceof Node||e instanceof Yt(e).Node:!1}function ln(e){return ss()?e instanceof Element||e instanceof Yt(e).Element:!1}function yn(e){return ss()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function ld(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const bb=new Set(["inline","contents"]);function io(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!bb.has(o)}const yb=new Set(["table","td","th"]);function Sb(e){return yb.has(Er(e))}const Cb=[":popover-open",":modal"];function is(e){return Cb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Tb=["transform","translate","scale","rotate","perspective"],kb=["transform","translate","scale","rotate","perspective","filter"],Eb=["paint","layout","strict","content"];function na(e){const t=ra(),n=ln(e)?cn(e):e;return Tb.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)||kb.some(r=>(n.willChange||"").includes(r))||Eb.some(r=>(n.contain||"").includes(r))}function Ib(e){let t=$n(e);for(;yn(t)&&!Ir(t);){if(na(t))return t;if(is(t))return null;t=$n(t)}return null}function ra(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Nb=new Set(["html","body","#document"]);function Ir(e){return Nb.has(Er(e))}function cn(e){return Yt(e).getComputedStyle(e)}function as(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ld(e)&&e.host||bn(e);return ld(t)?t.host:t}function cd(e){const t=$n(e);return Ir(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&io(t)?t:cd(t)}function ao(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=cd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=oa(i);return t.concat(i,i.visualViewport||[],io(o)?o:[],a&&n?ao(a):[])}return t.concat(o,ao(o,[],n))}function oa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ud(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function sa(e){return ln(e)?e:e.contextElement}function Nr(e){const t=sa(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ud(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 Ab=vn(0);function dd(e){const t=Yt(e);return!ra()||!t.visualViewport?Ab:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=sa(e);let i=vn(1);t&&(r?ln(r)&&(i=Nr(r)):i=Nr(e));const a=jb(s,n,r)?dd(s):vn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=Yt(s),p=r&&ln(r)?Yt(r):r;let v=m,g=oa(v);for(;g&&r&&p!==v;){const x=Nr(g),y=g.getBoundingClientRect(),b=cn(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=Yt(g),g=oa(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(bn(e)).left+n}function fd(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 Pb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=bn(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=vn(1);const d=vn(0),f=yn(r);if((f||!f&&!s)&&((Er(r)!=="body"||io(i))&&(l=as(r)),yn(r))){const p=Qn(r);c=Nr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?fd(i,l):vn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function _b(e){return Array.from(e.getClientRects())}function Rb(e){const t=bn(e),n=as(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ls(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const pd=25;function Mb(e,t){const n=Yt(e),r=bn(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=ra();(!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<=pd&&(s-=v)}else c<=pd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Ob=new Set(["absolute","fixed"]);function Db(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?Nr(e):vn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function hd(e,t,n){let r;if(t==="viewport")r=Mb(e,n);else if(t==="document")r=Rb(bn(e));else if(ln(t))r=Db(t,n);else{const o=dd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function md(e,t){const n=$n(e);return n===t||!ln(n)||Ir(n)?!1:cn(n).position==="fixed"||md(n,t)}function Lb(e,t){const n=t.get(e);if(n)return n;let r=ao(e,[],!1).filter(a=>ln(a)&&Er(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?$n(e):e;for(;ln(i)&&!Ir(i);){const a=cn(i),l=na(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Ob.has(o.position)||io(i)&&!l&&md(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function $b(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?is(t)?[]:Lb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=hd(t,d,o);return c.top=Gt(f.top,c.top),c.right=Ln(f.right,c.right),c.bottom=Ln(f.bottom,c.bottom),c.left=Gt(f.left,c.left),c},hd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Fb(e){const{width:t,height:n}=ud(e);return{width:t,height:n}}function Bb(e,t,n){const r=yn(t),o=bn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=ls(o)}if(r||!r&&!s)if((Er(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?fd(o,a):vn(0),f=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function ia(e){return cn(e).position==="static"}function gd(e,t){if(!yn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return bn(e)===n&&(n=n.ownerDocument.body),n}function xd(e,t){const n=Yt(e);if(is(e))return n;if(!yn(e)){let o=$n(e);for(;o&&!Ir(o);){if(ln(o)&&!ia(o))return o;o=$n(o)}return n}let r=gd(e,t);for(;r&&Sb(r)&&ia(r);)r=gd(r,t);return r&&Ir(r)&&ia(r)&&!na(r)?n:r||Ib(e)||n}const zb=async function(e){const t=this.getOffsetParent||xd,n=this.getDimensions,r=await n(e.floating);return{reference:Bb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Hb(e){return cn(e).direction==="rtl"}const Ub={convertOffsetParentRelativeRectToViewportRelativeRect:Pb,getDocumentElement:bn,getClippingRect:$b,getOffsetParent:xd,getElementRects:zb,getClientRects:_b,getDimensions:Fb,getScale:Nr,isElement:ln,isRTL:Hb};function vd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Wb(e,t){let n=null,r;const o=bn(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:Gt(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&&!vd(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 Vb(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=sa(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?Wb(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&&!vd(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 Kb=gb,qb=xb,Gb=pb,Yb=wb,Xb=hb,wd=fb,Jb=vb,Zb=(e,t,n)=>{const r=new Map,o={platform:Ub,...n},s={...o.platform,_c:r};return db(e,t,{...o,platform:s})};var Qb=typeof document<"u",ey=function(){},cs=Qb?w.useLayoutEffect:ey;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 bd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function yd(e,t){const n=bd(e);return Math.round(t*n)/n}function aa(e){const t=h.useRef(e);return cs(()=>{t.current=e}),t}function ty(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(O=>{O!==T.current&&(T.current=O,g(O))},[]),C=h.useCallback(O=>{O!==E.current&&(E.current=O,y(O))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),j=h.useRef(d),R=l!=null,D=aa(l),$=aa(o),U=aa(c),X=h.useCallback(()=>{if(!T.current||!E.current)return;const O={placement:t,strategy:n,middleware:m};$.current&&(O.platform=$.current),Zb(T.current,E.current,O).then(I=>{const Y={...I,isPositioned:U.current!==!1};M.current&&!us(j.current,Y)&&(j.current=Y,Vr.flushSync(()=>{f(Y)}))})},[m,t,n,$,U]);cs(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(O=>({...O,isPositioned:!1})))},[c]);const M=h.useRef(!1);cs(()=>(M.current=!0,()=>{M.current=!1}),[]),cs(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if(D.current)return D.current(k,S,X);X()}},[k,S,X,D,R]);const K=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),q=h.useMemo(()=>({reference:k,floating:S}),[k,S]),z=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!q.floating)return O;const I=yd(q.floating,d.x),Y=yd(q.floating,d.y);return a?{...O,transform:"translate("+I+"px, "+Y+"px)",...bd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:Y}},[n,a,q.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:X,refs:K,elements:q,floatingStyles:z}),[d,X,K,q,z])}const ny=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?wd({element:r.current,padding:o}).fn(n):{}:r?wd({element:r,padding:o}).fn(n):{}}}},ry=(e,t)=>({...Kb(e),options:[e,t]}),oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Jb(e),options:[e,t]}),iy=(e,t)=>({...Gb(e),options:[e,t]}),ay=(e,t)=>({...Yb(e),options:[e,t]}),ly=(e,t)=>({...Xb(e),options:[e,t]}),cy=(e,t)=>({...ny(e),options:[e,t]});var uy="Arrow",Sd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Sd.displayName=uy;var dy=Sd;function Cd(e){const[t,n]=h.useState(void 0);return Et(()=>{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 la="Popper",[Td,Ar]=an(la),[fy,kd]=Td(la),Ed=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(fy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ed.displayName=la;var Id="PopperAnchor",Nd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=kd(Id,n),i=h.useRef(null),a=Me(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Nd.displayName=Id;var ca="PopperContent",[py,hy]=Td(ca),Ad=h.forwardRef((e,t)=>{var L,_,G,Z,oe,se;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=kd(ca,n),[y,b]=h.useState(null),C=Me(t,ie=>b(ie)),[k,S]=h.useState(null),T=Cd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(c)?c:[c],U=$.length>0,X={padding:D,boundary:$.filter(gy),altBoundary:U},{refs:M,floatingStyles:K,placement:q,isPositioned:z,middlewareData:O}=ty({strategy:"fixed",placement:R,whileElementsMounted:(...ie)=>Vb(...ie,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[ry({mainAxis:o+j,alignmentAxis:i}),l&&oy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?sy():void 0,...X}),l&&iy({...X}),ay({...X,apply:({elements:ie,rects:le,availableWidth:ye,availableHeight:De})=>{const{width:He,height:_e}=le.reference,$e=ie.floating.style;$e.setProperty("--radix-popper-available-width",`${ye}px`),$e.setProperty("--radix-popper-available-height",`${De}px`),$e.setProperty("--radix-popper-anchor-width",`${He}px`),$e.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),k&&cy({element:k,padding:a}),xy({arrowWidth:E,arrowHeight:j}),m&&ly({strategy:"referenceHidden",...X})]}),[I,Y]=_d(q),J=gt(v);Et(()=>{z&&(J==null||J())},[z,J]);const P=(L=O.arrow)==null?void 0:L.x,B=(_=O.arrow)==null?void 0:_.y,A=((G=O.arrow)==null?void 0:G.centerOffset)!==0,[F,W]=h.useState();return Et(()=>{y&&W(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:z?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:F,"--radix-popper-transform-origin":[(Z=O.transformOrigin)==null?void 0:Z.x,(oe=O.transformOrigin)==null?void 0:oe.y].join(" "),...((se=O.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(py,{scope:n,placedSide:I,onArrowChange:S,arrowX:P,arrowY:B,shouldHideArrow:A,children:u.jsx(me.div,{"data-side":I,"data-align":Y,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Ad.displayName=ca;var jd="PopperArrow",my={top:"bottom",right:"left",bottom:"top",left:"right"},Pd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=hy(jd,r),i=my[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(dy,{...o,ref:n,style:{...o.style,display:"block"}})})});Pd.displayName=jd;function gy(e){return e!==null}var xy=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]=_d(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 _d(e){const[t,n="center"]=e.split("-");return[t,n]}var ua=Ed,da=Nd,fa=Ad,pa=Pd,vy="Portal",lo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Do.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});lo.displayName=vy;function wy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Bt=e=>{const{present:t,children:n}=e,r=by(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Me(r.ref,yy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Bt.displayName="Presence";function by(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=wy(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]),Et(()=>{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]),Et(()=>{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 yy(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 ha="rovingFocusGroup.onEntryFocus",Sy={bubbles:!1,cancelable:!0},co="RovingFocusGroup",[ma,Rd,Cy]=Zo(co),[Ty,Md]=an(co,[Cy]),[ky,Ey]=Ty(co),Od=h.forwardRef((e,t)=>u.jsx(ma.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ma.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Iy,{...e,ref:t})})}));Od.displayName=co;var Iy=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=Me(t,m),v=Qo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:co}),[y,b]=h.useState(!1),C=gt(c),k=Rd(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ha,C),()=>j.removeEventListener(ha,C)},[C]),u.jsx(ky,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(j=>x(j),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:h.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.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,j=>{const R=!S.current;if(j.target===j.currentTarget&&R&&!y){const D=new CustomEvent(ha,Sy);if(j.currentTarget.dispatchEvent(D),!D.defaultPrevented){const $=k().filter(q=>q.focusable),U=$.find(q=>q.active),X=$.find(q=>q.id===g),K=[U,X,...$].filter(Boolean).map(q=>q.ref.current);$d(K,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Dd="RovingFocusGroupItem",Ld=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=Ey(Dd,n),f=d.currentTabStopId===c,m=Rd(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(ma.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.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=jy(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?Py(C,k+1):C.slice(k+1)}setTimeout(()=>$d(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Ld.displayName=Dd;var Ny={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ay(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function jy(e,t,n){const r=Ay(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ny[r]}function $d(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Py(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _y=Od,Ry=Ld,My=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,fs=new WeakMap,ps={},ga=0,Fd=function(e){return e&&(e.host||Fd(e.parentNode))},Oy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Fd(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})},Dy=function(e,t,n,r){var o=Oy(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=(jr.get(m)||0)+1,x=(s.get(m)||0)+1;jr.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(),ga++,function(){i.forEach(function(f){var m=jr.get(f)-1,p=s.get(f)-1;jr.set(f,m),s.set(f,p),m||(fs.has(f)||f.removeAttribute(r),fs.delete(f)),p||f.removeAttribute(n)}),ga--,ga||(jr=new WeakMap,jr=new WeakMap,fs=new WeakMap,ps={})}},xa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=My(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Dy(r,o,n,"aria-hidden")):function(){return null}},Sn=function(){return Sn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Sn.apply(this,arguments)};function Bd(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 Ly(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",$y="with-scroll-bars-hidden",Fy="--removed-body-scroll-bar-size";function va(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function By(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 zy=typeof window<"u"?h.useLayoutEffect:h.useEffect,zd=new WeakMap;function Hy(e,t){var n=By(null,function(r){return e.forEach(function(o){return va(o,r)})});return zy(function(){var r=zd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||va(a,null)}),s.forEach(function(a){o.has(a)||va(a,i)})}zd.set(n,e)},[e]),n}function Uy(e){return e}function Wy(e,t){t===void 0&&(t=Uy);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 Vy(e){e===void 0&&(e={});var t=Wy(null);return t.options=Sn({async:!0,ssr:!1},e),t}var Hd=function(e){var t=e.sideCar,n=Bd(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,Sn({},n))};Hd.isSideCarExport=!0;function Ky(e,t){return e.useMedium(t),Hd}var Ud=Vy(),wa=function(){},gs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:wa,onWheelCapture:wa,onTouchMoveCapture:wa}),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=Bd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=Hy([n,t]),E=Sn(Sn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Ud,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),Sn(Sn({},E),{ref:T})):h.createElement(b,Sn({},E,{className:l,ref:T}),a))});gs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gs.classNames={fullWidth:ms,zeroRight:hs};var qy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Gy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=qy();return t&&e.setAttribute("nonce",t),e}function Yy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Xy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Gy())&&(Yy(t,n),Xy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zy=function(){var e=Jy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wd=function(){var e=Zy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Qy={left:0,top:0,right:0,gap:0},ba=function(e){return parseInt(e||"",10)||0},e0=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[ba(n),ba(r),ba(o)]},t0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Qy;var t=e0(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])}},n0=Wd(),Pr="data-scroll-locked",r0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
-
.`.concat(
|
|
38
|
+
`);if(!Se)continue;let Ne;try{Ne=JSON.parse(Se)}catch{console.debug("[use-chat] malformed SSE:",Se.slice(0,200));continue}const Fe=cu(Ne)?Ne.data:Ne;if(!Fe){console.warn("[use-chat] dropped envelope event without payload",Ne);continue}const ve=Fe;It=Date.now();const Qe=ve.seq;if(Qe!==void 0){if(Qe<=vt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Qe,lastProcessedSeq:vt,type:ve.type});continue}vt>0&&Qe>vt+1&&((oe=I==null?void 0:I.onGap)==null||oe.call(I,{from:vt,to:Qe})),vt=Qe,E.current=Qe,x(Qe)}if(ve.type==="message.start"&&ve.role==="assistant"){const Re=hu(ve.model);U.current={messageId:ve.id,lastSeq:Qe??null,lastText:""},k({id:ve.id,role:"assistant",name:Re??void 0,model:ve.model,createdAt:new Date().toISOString(),content:[]})}if(ve.type==="checkpoint")R.current=ve.checkpointId??null,D.current=ve.checkpointNs??null,v(ve.checkpointId??null);else if(ve.type==="state_history"){$.current=ve;try{const ht=Yn(ve).latest;ht&&(R.current=ht.checkpointId??null,D.current=ht.checkpointNs??null,v(ht.checkpointId??null))}catch(Re){console.warn("[use-chat] Failed to hydrate state_history payload",Re)}}try{O==null||O(ve)}catch(Re){console.error("[use-chat] Error in onEvent callback:",Re,"for event:",ve.type)}if(ve.type==="message.delta"){k(ht=>{const In=U.current;if(!ht||In.messageId!==ht.id)return ht;const{newParts:N,newMeta:te,changed:de}=fu(ht.content??[],ve.delta,{lastSeq:In.lastSeq,lastText:In.lastText},Qe??null);return de?(U.current={...In,lastSeq:te.lastSeq??In.lastSeq,lastText:te.lastText??In.lastText},{...ht,content:N}):ht});const Re=ve.delta.filter(ht=>ht.type==="text").map(ht=>ht.text).join("");Re&&e.autoAppendAssistant!==!1&&(st.push(Re),rn())}else if(ve.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(se=I==null?void 0:I.onHeartbeat)==null||se.call(I,ve)}catch(Re){console.warn("[use-chat] heartbeat callback failed",Re)}}else if(ut!==null&&cancelAnimationFrame(ut),wt(),ve.type==="checkpoint")v(ve.checkpointId);else if(ve.type==="error"){const Re=ve;if(d(Re.message),J="error",P=Re.message,Re.error_type==="auth_error"||Re.code==="TOKEN_EXPIRED"||((ie=Re.message)==null?void 0:ie.includes("token"))||((le=Re.message)==null?void 0:le.includes("401"))||((ye=Re.message)==null?void 0:ye.includes("unauthorized"))||((De=Re.message)==null?void 0:De.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Re.message);try{(He=I==null?void 0:I.onAuthError)==null||He.call(I,Re.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}Y.abort()}}}}wt(),J===null&&!Y.signal.aborted&&(J="complete")}catch(qe){if(qe.name==="AbortError")J=J??"aborted";else{const We=qe.message||String(qe);J="error",P=We,d(We),(_e=I==null?void 0:I.onError)==null||_e.call(I,We)}}finally{try{await pt.cancel()}catch{}finally{($e=pt.releaseLock)==null||$e.call(pt)}ut!==null&&typeof window<"u"&&window.cancelAnimationFrame(ut),clearInterval(mn)}}catch(Ke){if(Ke.name==="AbortError")J=J??"aborted";else{const Ye=Ke.message||String(Ke);J="error",P=Ye,d(Ye),(ct=I==null?void 0:I.onError)==null||ct.call(I,Ye),B||((ft=I==null?void 0:I.onConnectionError)==null||ft.call(I,Ye),B=!0)}}finally{const Ke=E.current,Ye=R.current,Ue=D.current,Le=$.current,je=J??(Y.signal.aborted?"aborted":P?"error":"complete");try{(St=I==null?void 0:I.onClosed)==null||St.call(I,{reason:je,lastSeq:Ke,lastCheckpointId:Ye,lastCheckpointNs:Ue,lastStateHistory:Le,error:P})}catch(pt){console.warn("[use-chat] onClosed callback failed",pt)}l(!1),b(!1),S.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>Y.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var z;T.current=!1,(z=S.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:C,lastCheckpointId:p,lastSeq:g,connected:y,stream:q,stop:K,clear:M,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 j=w.useCallback(async()=>{d(!0),m(null);try{const O=await e.listThreads();i(O??[])}catch(O){const I=String(O);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),R=w.useCallback(async()=>{x(!0),y(null);try{const O=await e.listSharedThreads();v(O??[])}catch(O){const I=String(O);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{j()},[j]),w.useEffect(()=>{R()},[R]),w.useEffect(()=>{r==null||r(a)},[a,r]);const D=w.useCallback(async O=>{try{const I=await e.createThread(O);return l(I.threadId),await j(),I.threadId}catch(I){const Y=String(I);return n==null||n(Y),null}},[e,n,j]),$=w.useCallback(async O=>{const I=s;i(J=>J.filter(P=>P.threadId!==O));const Y=new AbortController;E.current.set(O,Y);try{await e.deleteThread(O),T.current===O&&(l(null),o==null||o())}catch(J){i(I);const P=String(J);n==null||n(P)}finally{E.current.delete(O)}},[e,o,n,s]),U=w.useCallback(async(O,I)=>{try{await e.updateThread(O,I),await j()}catch(Y){n==null||n(String(Y))}},[e,n,j]),X=w.useCallback(async(O,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(O,I),await R(),C("Shared successfully")}catch(Y){const J=tw(Y);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{S(!1)}},[e,n,R]),M=w.useCallback(async(O,I)=>{try{await e.unshareThread(O,I),await R()}catch(Y){const J=String(Y);throw n==null||n(J),Y}},[e,n,R]),K=w.useMemo(()=>({createThread:D,deleteThread:$,renameThread:U,refreshThreads:j,refreshSharedThreads:R,shareThread:X,unshareThread:M}),[D,$,U,j,R,X,M]),q=w.useCallback(O=>{if(!(O!=null&&O.threadId))return;const I={threadId:O.threadId,title:O.title||`Thread ${O.threadId.slice(0,8)}`,createdAt:O.createdAt||new Date().toISOString(),updatedAt:O.updatedAt||new Date().toISOString(),messageCount:O.messageCount??1};i(Y=>{let J=!1;const P=Y.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?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...Y])})},[]),z=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:K,addThreadFromEvent:q,shareInFlight:k,shareStatus:b,clearShareStatus:z}}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 wr(){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 br(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=br(e);return typeof e=="string"&&rw(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function yr(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 yr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?yr(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 Bi(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 wu(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 bu(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 yu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>yu(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 yu(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 zi(e){return e.call_id??e.id??null}function Su(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Cu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Hi(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Fi(r).toolCallId===t)return n}return-1}function mw(e){if(e==null)return[];const t=yr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=br(t??e);return n?[{type:"text",text:n}]:[]}function Tu(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=zi(t),r=Hi(e.messages,n),o=t.name??t.tool??void 0,s=Su(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=Cu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function xw(e,t){const n=zi(t);if(!n)return e;const r=Hi(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=Tu(e.messages[r],o);return{...e,messages:eo(e.messages,r,a)}}function vw(e,t){const n=zi(t),r=Su(t);let o=e.messages,s=Hi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Cu(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=Tu(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 ku({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),j=w.useRef(null),R=w.useRef(null),D=w.useRef(null),$=w.useRef(null),U=w.useRef(new Map),X=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const M=w.useCallback(async A=>{var W,L;if(!A.threadId)return;const F=A.threadId;(W=A.onStart)==null||W.call(A),A.setLoading(!0);try{await A.action(F)}catch(_){if(!Yc(_)&&T.current===F){const Z=String(_);(L=A.handleError)==null||L.call(A,Z),n==null||n(Z)}throw _}finally{A.setLoading(!1)}},[n]),K=w.useCallback(async(A,F)=>{var Z;if(!A)return;const W=`${A}:${F??"latest"}`,L=U.current.get(W);if(L)return L;(Z=X.current)==null||Z.abort();const _=new AbortController;X.current=_;const G=M({threadId:A,setLoading:y,onStart:()=>S(null),handleError:oe=>S(oe),action:async oe=>{const se=await e.getStateHistory({threadId:oe,checkpointId:F??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:ie}=Yn(se),le=ie.find(ye=>ye.messages&&ye.messages.length>0)??(F?ie.find(ye=>ye.checkpointId===F):null)??ie[0];t((le==null?void 0:le.messages)??[],{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),f(se)}});U.current.set(W,G);try{await G}finally{U.current.delete(W),X.current===_&&(X.current=null)}return T.current===A&&($.current=W),G},[e,t,M]),q=w.useCallback(async(A,F)=>{D.current=A;try{await K(A,F)}catch(W){if(!Yc(W))throw W}finally{D.current===A&&(D.current=null)}},[K]),z=w.useCallback(A=>{j.current=A},[]),O=w.useCallback(A=>{R.current=A},[]),I=w.useCallback(A=>{const F=A.threadId??T.current;if(!F||T.current&&T.current!==F)return;const{checkpoints:W}=Yn(A);if(!W.length)return;const L=W.find(G=>G.messages&&G.messages.length>0)??W.find(G=>!!G.checkpointId)??W[0],_=R.current===F;!l&&!_&&t((L==null?void 0:L.messages)??[],{checkpointId:(L==null?void 0:L.checkpointId)??null,checkpointNs:(L==null?void 0:L.checkpointNs)??null}),f(A),$.current=`${F}:latest`,j.current=null,R.current===F&&(R.current=null)},[t,l]),Y=w.useCallback(async(A,F)=>{const W=T.current;await M({threadId:W,setLoading:C,action:async L=>{const _=await e.getStateHistory({threadId:L,checkpointId:A,checkpointNs:F??void 0});if(T.current!==L)return;const{checkpoints:G}=Yn(_),Z=G.find(oe=>oe.checkpointId===A&&(F?oe.checkpointNs===F:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:A,checkpointNs:F});return}f(_),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,M]),J=w.useCallback((A,F)=>{t(c(),{checkpointId:A??null,checkpointNs:F??null})},[c,t]),P=w.useCallback(async()=>{T.current&&await q(T.current)},[q]);w.useEffect(()=>{if(!a||!r||x||l)return;if(j.current===r){j.current=null,E.current=r;return}if(R.current===r){E.current=r;return}if(D.current===r){D.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let A;const F=`${r}:latest`;$.current!==F&&q(r,A)},[a,r,s,i,o,x,l,q]);const B=w.useCallback(()=>{f(null),y(!1),C(!1),S(null),j.current=null,R.current=null,E.current=null,$.current=null,D.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:q,navigateToCheckpoint:Y,setCurrentCheckpointId:J,returnToLatest:P,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:O,resetHistoryState:B}}const Eu=w.createContext(null),Iu=w.createContext(null);function ro(){const e=w.useContext(Eu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Nu(){const e=w.useContext(Iu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Au({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Qr(),{currentThreadId:l}=wr(),{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:j,markStreamPendingThread:R,resetHistoryState:D}=ku({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])}),[$,U]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[X,M]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),D())},[l,d,D]);const K=w.useCallback(Y=>U(()=>Y),[]),q=w.useCallback(Y=>M(()=>Y),[]),z=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),O=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:z,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:$,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:$,respondToInterrupt:X,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:R,resetHistoryState:D,pushUser:f,onEvent:m}),[l,c,p,v,g,z,x,y,b,$,k,S,T,C,X,g.messagePreviews,E,j,R,D,f,m]),I=w.useMemo(()=>({registerClearThread:K,registerRespondToInterrupt:q}),[K,q]);return u.jsx(Iu.Provider,{value:I,children:u.jsx(Eu.Provider,{value:O,children:e})})}function ju(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=ju(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ju(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 Pu=w.createContext(null),_u=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(()=>xn(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(Au,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(_u.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}=wr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=ro(),{registerClearThread:E,registerRespondToInterrupt:j}=Nu(),R=w.useCallback(z=>{v(z),p.current!==z.threadId&&((z.created??!p.current)&&b(z.threadId),C(z.threadId),m(z.threadId))},[v,b,C,m,p]),D=w.useCallback(z=>{z.type==="thread_info"?R(z):z.type==="state_history"?y(z):z.type==="tool.end"?i==null||i(z):T(z)},[R,y,T,i]),$=w.useCallback(z=>{a(z,D,{onError:O=>{console.error("[StreamingProvider] Stream error:",O),r==null||r(O)},onAuthError:O=>{console.error("[StreamingProvider] Auth error:",O),o==null||o(O)},onConnectionError:O=>{console.error("[StreamingProvider] Connection error:",O),s==null||s(O)}})},[a,D,r,o,s]),U=w.useRef(g);w.useEffect(()=>{U.current=g},[g]);const X=w.useCallback(async(z,O,I)=>{const Y=p.current;if(!Y)throw new Error("No active thread to handle interrupt");const J=O?I??!0:!1,P=U.current,B={threadId:Y,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:J}};$(B)},[p,$]);w.useEffect(()=>{j(X)},[X,j]);const M=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(M)},[M,E]);const K=w.useCallback(async(z,O)=>{let I=p.current;const Y=(z==null?void 0:z.text)??"",J=(z==null?void 0:z.attachments)??[],P=(Y==null?void 0:Y.trim())??"",B={...(z==null?void 0:z.payload)??{}},A=Array.isArray(B.messages)?B.messages:void 0;A&&delete B.messages;const F=!!(A&&A.length);if(!I&&!P&&J.length===0&&!F)return;if(!I){const _e=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=`${_e}${$e}`,b(I),m(I)}const{contentParts:W,filesInfo:L}=await lu(J),_=[...W];P&&_.push({type:"text",text:Y});const G=O==null?void 0:O.originalMessageId,Z=!!(O!=null&&O.edit&&G),oe=!F&&_.length>0;let se=null;oe&&(se={id:Z?G:`msg-${Date.now()}`,role:"user",content:_,createdAt:new Date().toISOString()},Z?S(se,G):S(se));const ie=F?A:se?[se]:[],le={...B,...L.length?{files_info:L}:{}};ie.length?le.messages=ie:"messages"in le||(le.messages=[]);let ye=(O==null?void 0:O.checkpointId)??g.id??void 0,De=(O==null?void 0:O.checkpointNs)??g.namespace??void 0;if(Z&&G){const _e=yw(x,G);ye=_e.checkpointId,De=_e.checkpointNs??void 0}const He={threadId:I,payload:le,checkpointId:ye,checkpointNs:De,edit:!!(O!=null&&O.edit)};$(He)},[g,p,b,S,$,x]),q=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:K,send:K,stop:l,setAuthToken:f}),[c,d,K,l,f]);return u.jsx(Pu.Provider,{value:q,children:e})}function Ui(){const e=w.useContext(Pu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Tw(){return w.useContext(_u)}function Ru(e){return typeof e=="object"&&e!==null}function kw(e,t){if(Object.is(e,t))return!0;if(!Ru(e)||!Ru(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 Mu(e){const t=w.useRef(e),n=w.useRef(e);return kw(t.current,e)||(t.current=e,n.current=e),n.current}function Sr({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=Mu(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 Cr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Ew(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Ou(){const e=[Cr("__API_BASE_URL__"),Cr("__CHAT_API_BASE_URL__"),Cr("__CHAT_API_URL__")];for(const t of e){const n=Ew(t);if(n)return n}}function Du(){const e=[Cr("__API_AUTH_TOKEN__"),Cr("__CHAT_API_KEY__"),Cr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Lu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function $u(){const e={},t=Ou(),n=Du();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Fu(){const e=$u(),t=Nn.getAuthToken(),n=Ou();return{apiBaseUrl:Lu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Du()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Wi="chat-settings";function Bu(){try{const e=localStorage.getItem(Wi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function zu(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Wi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Iw(){const e=Fu(),t=Bu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Lu(Nn.baseUrl,r,e.apiBaseUrl)}}function Nw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),zu(e)}function ne(...e){return cx.twMerge(lx.clsx(e))}const Aw=Wr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Xe=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:ne(Aw({variant:t,size:n,className:e})),ref:s,...o})});Xe.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 Hu(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=Hu(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():Hu(e[o],null)}}}}function Me(...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 an(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 Et=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},_w=h[" useInsertionEffect ".trim().toString()]||Et;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"],me=Ow.reduce((e,t)=>{const n=Vt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Vi(e,t){e&&Vr.flushSync(()=>e.dispatchEvent(t))}function Zo(e){const t=e+"CollectionProvider",[n,r]=an(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=Vt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=Me(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Vt.createSlot(d),p=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=Me(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 gt(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=gt(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",Ki="dismissableLayer.update",Fw="dismissableLayer.pointerDownOutside",Bw="dismissableLayer.focusOutside",Uu,Wu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Tr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Wu),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Me(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 j=E.target,R=[...c.branches].some(D=>D.contains(j));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Uw(E=>{const j=E.target;[...c.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return 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&&(Uu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Ku(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Uu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Ku())},[d,c]),h.useEffect(()=>{const E=()=>p({});return document.addEventListener(Ki,E),()=>document.removeEventListener(Ki,E)},[]),u.jsx(me.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)})});Tr.displayName=$w;var zw="DismissableLayerBranch",Vu=h.forwardRef((e,t)=>{const n=h.useContext(Wu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(me.div,{...e,ref:o})});Vu.displayName=zw;function Hw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){qu(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=gt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&qu(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 Ku(){const e=new CustomEvent(Ki);document.dispatchEvent(e)}function qu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Vi(o,s):o.dispatchEvent(s)}var Ww=Tr,Vw=Vu,qi=0;function Gi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Gu()),document.body.insertAdjacentElement("beforeend",e[1]??Gu()),qi++,()=>{qi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qi--}},[])}function Gu(){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 Yi="focusScope.autoFocusOnMount",Xi="focusScope.autoFocusOnUnmount",Yu={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=gt(o),d=gt(s),f=h.useRef(null),m=Me(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){Zu.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Yi,Yu);a.addEventListener(Yi,c),a.dispatchEvent(y),y.defaultPrevented||(qw(Zw(Xu(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Yi,c),setTimeout(()=>{const y=new CustomEvent(Xi,Yu);a.addEventListener(Xi,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Xi,d),Zu.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(me.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=Xu(e),n=Ju(t,e),r=Ju(t.reverse(),e);return[n,r]}function Xu(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 Ju(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 Zu=Jw();function Jw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Qu(e,t),e.unshift(t)},remove(t){var n;e=Qu(e,t),(n=e[0])==null||n.resume()}}}function Qu(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 At(e){const[t,n]=h.useState(Qw());return Et(()=>{n(r=>r??String(eb++))},[e]),t?`radix-${t}`:""}const tb=["top","right","bottom","left"],Ln=Math.min,Gt=Math.max,ts=Math.round,ns=Math.floor,vn=e=>({x:e,y:e}),nb={left:"right",right:"left",bottom:"top",top:"bottom"},rb={start:"end",end:"start"};function Ji(e,t,n){return Gt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function kr(e){return e.split("-")[1]}function Zi(e){return e==="x"?"y":"x"}function Qi(e){return e==="y"?"height":"width"}const ob=new Set(["top","bottom"]);function wn(e){return ob.has(jn(e))?"y":"x"}function ea(e){return Zi(wn(e))}function sb(e,t,n){n===void 0&&(n=!1);const r=kr(e),o=ea(e),s=Qi(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[ta(e),t,ta(t)]}function ta(e){return e.replace(/start|end/g,t=>rb[t])}const ed=["left","right"],td=["right","left"],ab=["top","bottom"],lb=["bottom","top"];function cb(e,t,n){switch(e){case"top":case"bottom":return n?t?td:ed:t?ed:td;case"left":case"right":return t?ab:lb;default:return[]}}function ub(e,t,n,r){const o=kr(e);let s=cb(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ta)))),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 nd(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 rd(e,t,n){let{reference:r,floating:o}=e;const s=wn(t),i=ea(t),a=Qi(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(kr(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}=rd(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}=rd(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=nd(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=nd(d),m={x:n,y:r},p=ea(o),v=Qi(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 j=k/2-S/2,R=E/2-g[v]/2-1,D=Ln(f[y],R),$=Ln(f[b],R),U=D,X=E-g[v]-$,M=E/2-g[v]/2+j,K=Ji(U,M,X),q=!l.arrow&&kr(o)!=null&&M!==K&&s.reference[v]/2-(M<U?D:$)-g[v]/2<0,z=q?M<U?M-U:M-X:0;return{[p]:m[p]+z,data:{[p]:K,centerOffset:M-K-z,...q&&{alignmentOffset:z}},reset:q}}}),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=wn(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],j=await so(t,x),R=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(j[y]),f){const M=sb(o,i,k);R.push(j[M[0]],j[M[1]])}if(D=[...D,{placement:o,overflows:R}],!R.every(M=>M<=0)){var $,U;const M=((($=s.flip)==null?void 0:$.index)||0)+1,K=E[M];if(K&&(!(f==="alignment"?b!==wn(K):!1)||D.every(O=>wn(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:M,overflows:D},reset:{placement:K}};let q=(U=D.filter(z=>z.overflows[0]<=0).sort((z,O)=>z.overflows[1]-O.overflows[1])[0])==null?void 0:U.placement;if(!q)switch(p){case"bestFit":{var X;const z=(X=D.filter(O=>{if(T){const I=wn(O.placement);return I===b||I==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(I=>I>0).reduce((I,Y)=>I+Y,0)]).sort((O,I)=>O[1]-I[1])[0])==null?void 0:X[0];z&&(q=z);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function od(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function sd(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=od(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:sd(i)}}}case"escaped":{const s=await so(t,{...o,altBoundary:!0}),i=od(s,n.floating);return{data:{escapedOffsets:i,escaped:sd(i)}}}default:return{}}}}},id=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=kr(n),l=wn(n)==="y",c=id.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=wn(jn(o)),m=Zi(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=Ji(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=Ji(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=wn(o),m=Zi(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=id.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=kr(o),p=wn(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,j=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const D=Gt(d.left,0),$=Gt(d.right,0),U=Gt(d.top,0),X=Gt(d.bottom,0);p?j=v-2*(D!==0||$!==0?D+$:Gt(d.left,d.right)):E=g-2*(U!==0||X!==0?U+X:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function Er(e){return ad(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function bn(e){var t;return(t=(ad(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ad(e){return ss()?e instanceof Node||e instanceof Yt(e).Node:!1}function ln(e){return ss()?e instanceof Element||e instanceof Yt(e).Element:!1}function yn(e){return ss()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function ld(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const yb=new Set(["inline","contents"]);function io(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(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(Er(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 na(e){const t=ra(),n=ln(e)?cn(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(;yn(t)&&!Ir(t);){if(na(t))return t;if(is(t))return null;t=$n(t)}return null}function ra(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ab=new Set(["html","body","#document"]);function Ir(e){return Ab.has(Er(e))}function cn(e){return Yt(e).getComputedStyle(e)}function as(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ld(e)&&e.host||bn(e);return ld(t)?t.host:t}function cd(e){const t=$n(e);return Ir(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&io(t)?t:cd(t)}function ao(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=cd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=oa(i);return t.concat(i,i.visualViewport||[],io(o)?o:[],a&&n?ao(a):[])}return t.concat(o,ao(o,[],n))}function oa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ud(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function sa(e){return ln(e)?e:e.contextElement}function Nr(e){const t=sa(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ud(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=vn(0);function dd(e){const t=Yt(e);return!ra()||!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!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=sa(e);let i=vn(1);t&&(r?ln(r)&&(i=Nr(r)):i=Nr(e));const a=Pb(s,n,r)?dd(s):vn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=Yt(s),p=r&&ln(r)?Yt(r):r;let v=m,g=oa(v);for(;g&&r&&p!==v;){const x=Nr(g),y=g.getBoundingClientRect(),b=cn(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=Yt(g),g=oa(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(bn(e)).left+n}function fd(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=bn(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=vn(1);const d=vn(0),f=yn(r);if((f||!f&&!s)&&((Er(r)!=="body"||io(i))&&(l=as(r)),yn(r))){const p=Qn(r);c=Nr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?fd(i,l):vn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function Rb(e){return Array.from(e.getClientRects())}function Mb(e){const t=bn(e),n=as(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ls(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const pd=25;function Ob(e,t){const n=Yt(e),r=bn(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=ra();(!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<=pd&&(s-=v)}else c<=pd&&(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=yn(e)?Nr(e):vn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function hd(e,t,n){let r;if(t==="viewport")r=Ob(e,n);else if(t==="document")r=Mb(bn(e));else if(ln(t))r=Lb(t,n);else{const o=dd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function md(e,t){const n=$n(e);return n===t||!ln(n)||Ir(n)?!1:cn(n).position==="fixed"||md(n,t)}function $b(e,t){const n=t.get(e);if(n)return n;let r=ao(e,[],!1).filter(a=>ln(a)&&Er(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?$n(e):e;for(;ln(i)&&!Ir(i);){const a=cn(i),l=na(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Db.has(o.position)||io(i)&&!l&&md(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=hd(t,d,o);return c.top=Gt(f.top,c.top),c.right=Ln(f.right,c.right),c.bottom=Ln(f.bottom,c.bottom),c.left=Gt(f.left,c.left),c},hd(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}=ud(e);return{width:t,height:n}}function zb(e,t,n){const r=yn(t),o=bn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=ls(o)}if(r||!r&&!s)if((Er(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?fd(o,a):vn(0),f=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function ia(e){return cn(e).position==="static"}function gd(e,t){if(!yn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return bn(e)===n&&(n=n.ownerDocument.body),n}function xd(e,t){const n=Yt(e);if(is(e))return n;if(!yn(e)){let o=$n(e);for(;o&&!Ir(o);){if(ln(o)&&!ia(o))return o;o=$n(o)}return n}let r=gd(e,t);for(;r&&Cb(r)&&ia(r);)r=gd(r,t);return r&&Ir(r)&&ia(r)&&!na(r)?n:r||Nb(e)||n}const Hb=async function(e){const t=this.getOffsetParent||xd,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 cn(e).direction==="rtl"}const Wb={convertOffsetParentRelativeRectToViewportRelativeRect:_b,getDocumentElement:bn,getClippingRect:Fb,getOffsetParent:xd,getElementRects:Hb,getClientRects:Rb,getDimensions:Bb,getScale:Nr,isElement:ln,isRTL:Ub};function vd(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=bn(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:Gt(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&&!vd(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=sa(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&&!vd(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,wd=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 bd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function yd(e,t){const n=bd(e);return Math.round(t*n)/n}function aa(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(O=>{O!==T.current&&(T.current=O,g(O))},[]),C=h.useCallback(O=>{O!==E.current&&(E.current=O,y(O))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),j=h.useRef(d),R=l!=null,D=aa(l),$=aa(o),U=aa(c),X=h.useCallback(()=>{if(!T.current||!E.current)return;const O={placement:t,strategy:n,middleware:m};$.current&&(O.platform=$.current),Qb(T.current,E.current,O).then(I=>{const Y={...I,isPositioned:U.current!==!1};M.current&&!us(j.current,Y)&&(j.current=Y,Vr.flushSync(()=>{f(Y)}))})},[m,t,n,$,U]);cs(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(O=>({...O,isPositioned:!1})))},[c]);const M=h.useRef(!1);cs(()=>(M.current=!0,()=>{M.current=!1}),[]),cs(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if(D.current)return D.current(k,S,X);X()}},[k,S,X,D,R]);const K=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),q=h.useMemo(()=>({reference:k,floating:S}),[k,S]),z=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!q.floating)return O;const I=yd(q.floating,d.x),Y=yd(q.floating,d.y);return a?{...O,transform:"translate("+I+"px, "+Y+"px)",...bd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:Y}},[n,a,q.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:X,refs:K,elements:q,floatingStyles:z}),[d,X,K,q,z])}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?wd({element:r.current,padding:o}).fn(n):{}:r?wd({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",Sd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Sd.displayName=dy;var fy=Sd;function Cd(e){const[t,n]=h.useState(void 0);return Et(()=>{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 la="Popper",[Td,Ar]=an(la),[py,kd]=Td(la),Ed=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(py,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ed.displayName=la;var Id="PopperAnchor",Nd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=kd(Id,n),i=h.useRef(null),a=Me(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Nd.displayName=Id;var ca="PopperContent",[hy,my]=Td(ca),Ad=h.forwardRef((e,t)=>{var L,_,G,Z,oe,se;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=kd(ca,n),[y,b]=h.useState(null),C=Me(t,ie=>b(ie)),[k,S]=h.useState(null),T=Cd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(c)?c:[c],U=$.length>0,X={padding:D,boundary:$.filter(xy),altBoundary:U},{refs:M,floatingStyles:K,placement:q,isPositioned:z,middlewareData:O}=ny({strategy:"fixed",placement:R,whileElementsMounted:(...ie)=>Kb(...ie,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[oy({mainAxis:o+j,alignmentAxis:i}),l&&sy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?iy():void 0,...X}),l&&ay({...X}),ly({...X,apply:({elements:ie,rects:le,availableWidth:ye,availableHeight:De})=>{const{width:He,height:_e}=le.reference,$e=ie.floating.style;$e.setProperty("--radix-popper-available-width",`${ye}px`),$e.setProperty("--radix-popper-available-height",`${De}px`),$e.setProperty("--radix-popper-anchor-width",`${He}px`),$e.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),k&&uy({element:k,padding:a}),vy({arrowWidth:E,arrowHeight:j}),m&&cy({strategy:"referenceHidden",...X})]}),[I,Y]=_d(q),J=gt(v);Et(()=>{z&&(J==null||J())},[z,J]);const P=(L=O.arrow)==null?void 0:L.x,B=(_=O.arrow)==null?void 0:_.y,A=((G=O.arrow)==null?void 0:G.centerOffset)!==0,[F,W]=h.useState();return Et(()=>{y&&W(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:z?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:F,"--radix-popper-transform-origin":[(Z=O.transformOrigin)==null?void 0:Z.x,(oe=O.transformOrigin)==null?void 0:oe.y].join(" "),...((se=O.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(hy,{scope:n,placedSide:I,onArrowChange:S,arrowX:P,arrowY:B,shouldHideArrow:A,children:u.jsx(me.div,{"data-side":I,"data-align":Y,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Ad.displayName=ca;var jd="PopperArrow",gy={top:"bottom",right:"left",bottom:"top",left:"right"},Pd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=my(jd,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"}})})});Pd.displayName=jd;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]=_d(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 _d(e){const[t,n="center"]=e.split("-");return[t,n]}var ua=Ed,da=Nd,fa=Ad,pa=Pd,wy="Portal",lo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Do.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});lo.displayName=wy;function by(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Bt=e=>{const{present:t,children:n}=e,r=yy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Me(r.ref,Sy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Bt.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]),Et(()=>{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]),Et(()=>{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 ha="rovingFocusGroup.onEntryFocus",Cy={bubbles:!1,cancelable:!0},co="RovingFocusGroup",[ma,Rd,Ty]=Zo(co),[ky,Md]=an(co,[Ty]),[Ey,Iy]=ky(co),Od=h.forwardRef((e,t)=>u.jsx(ma.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ma.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Ny,{...e,ref:t})})}));Od.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=Me(t,m),v=Qo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:co}),[y,b]=h.useState(!1),C=gt(c),k=Rd(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ha,C),()=>j.removeEventListener(ha,C)},[C]),u.jsx(Ey,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(j=>x(j),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:h.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.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,j=>{const R=!S.current;if(j.target===j.currentTarget&&R&&!y){const D=new CustomEvent(ha,Cy);if(j.currentTarget.dispatchEvent(D),!D.defaultPrevented){const $=k().filter(q=>q.focusable),U=$.find(q=>q.active),X=$.find(q=>q.id===g),K=[U,X,...$].filter(Boolean).map(q=>q.ref.current);$d(K,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Dd="RovingFocusGroupItem",Ld=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=Iy(Dd,n),f=d.currentTabStopId===c,m=Rd(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(ma.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.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(()=>$d(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Ld.displayName=Dd;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 $d(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=Od,My=Ld,Oy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,fs=new WeakMap,ps={},ga=0,Fd=function(e){return e&&(e.host||Fd(e.parentNode))},Dy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Fd(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=(jr.get(m)||0)+1,x=(s.get(m)||0)+1;jr.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(),ga++,function(){i.forEach(function(f){var m=jr.get(f)-1,p=s.get(f)-1;jr.set(f,m),s.set(f,p),m||(fs.has(f)||f.removeAttribute(r),fs.delete(f)),p||f.removeAttribute(n)}),ga--,ga||(jr=new WeakMap,jr=new WeakMap,fs=new WeakMap,ps={})}},xa=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}},Sn=function(){return Sn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Sn.apply(this,arguments)};function Bd(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 va(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,zd=new WeakMap;function Uy(e,t){var n=zy(null,function(r){return e.forEach(function(o){return va(o,r)})});return Hy(function(){var r=zd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||va(a,null)}),s.forEach(function(a){o.has(a)||va(a,i)})}zd.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=Sn({async:!0,ssr:!1},e),t}var Hd=function(e){var t=e.sideCar,n=Bd(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,Sn({},n))};Hd.isSideCarExport=!0;function qy(e,t){return e.useMedium(t),Hd}var Ud=Ky(),wa=function(){},gs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:wa,onWheelCapture:wa,onTouchMoveCapture:wa}),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=Bd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=Uy([n,t]),E=Sn(Sn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Ud,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),Sn(Sn({},E),{ref:T})):h.createElement(b,Sn({},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])}},Wd=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},ba=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[ba(n),ba(r),ba(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=Wd(),Pr="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
|
+
.`.concat(Fy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
43
43
|
}
|
|
@@ -71,19 +71,19 @@ React keys must be passed directly to JSX without using spread:
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
body[`).concat(Pr,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(By,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},Vd=function(){var e=parseInt(document.body.getAttribute(Pr)||"0",10);return isFinite(e)?e:0},
|
|
76
|
+
`)},Vd=function(){var e=parseInt(document.body.getAttribute(Pr)||"0",10);return isFinite(e)?e:0},s0=function(){h.useEffect(function(){return document.body.setAttribute(Pr,(Vd()+1).toString()),function(){var e=Vd()-1;e<=0?document.body.removeAttribute(Pr):document.body.setAttribute(Pr,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")})},ya=!1;if(typeof window<"u")try{var xs=Object.defineProperty({},"passive",{get:function(){return ya=!0,!0}});window.addEventListener("test",xs,xs),window.removeEventListener("test",xs,xs)}catch{ya=!1}var _r=ya?{passive:!1}:!1,a0=function(e){return e.tagName==="TEXTAREA"},Kd=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 Kd(e,"overflowY")},c0=function(e){return Kd(e,"overflowX")},qd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Gd(e,r);if(o){var s=Yd(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]},Gd=function(e,t){return e==="v"?l0(t):c0(t)},Yd=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=Yd(e,a),v=p[0],g=p[1],x=p[2],y=g-x-s*v;(v||y)&&Gd(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]},Xd=function(e){return[e.deltaX,e.deltaY]},Jd=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
|
-
`)},m0=0,Rr=[];function g0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(m0++)[0],s=h.useState(Wd)[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=Ly([e.lockRef.current],(e.shards||[]).map(Jd),!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 j=qd(E,T);if(!j)return!0;if(j?S=E:(S=E==="v"?"h":"v",j=qd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var R=r.current||S;return f0(R,x,g,R==="h"?C:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!Rr.length||Rr[Rr.length-1]!==s)){var y="deltaY"in x?Xd(x):vs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&p0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Jd).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:x0(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,Xd(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 Rr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,_r),document.addEventListener("touchmove",l,_r),document.addEventListener("touchstart",d,_r),function(){Rr=Rr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,_r),document.removeEventListener("touchmove",l,_r),document.removeEventListener("touchstart",d,_r)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:h0(o)}):null,p?h.createElement(s0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function x0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const v0=Ky(Ud,g0);var ws=h.forwardRef(function(e,t){return h.createElement(gs,Sn({},e,{ref:t,sideCar:v0}))});ws.classNames=gs.classNames;var Sa=["Enter"," "],w0=["ArrowDown","PageUp","Home"],Zd=["ArrowUp","PageDown","End"],b0=[...w0,...Zd],y0={ltr:[...Sa,"ArrowRight"],rtl:[...Sa,"ArrowLeft"]},S0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},uo="Menu",[fo,C0,T0]=Zo(uo),[er,Qd]=an(uo,[T0,Ar,Md]),bs=Ar(),ef=Md(),[k0,tr]=er(uo),[E0,po]=er(uo),tf=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=gt(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(ua,{...a,children:u.jsx(k0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(E0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};tf.displayName=uo;var I0="MenuAnchor",Ca=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(da,{...o,...r,ref:t})});Ca.displayName=I0;var Ta="MenuPortal",[N0,nf]=er(Ta,{forceMount:void 0}),rf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Ta,t);return u.jsx(N0,{scope:t,forceMount:n,children:u.jsx(Bt,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:r})})})};rf.displayName=Ta;var Qt="MenuContent",[A0,ka]=er(Qt),of=h.forwardRef((e,t)=>{const n=nf(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=po(Qt,e.__scopeMenu);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{present:r||s.open,children:u.jsx(fo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(j0,{...o,ref:t}):u.jsx(P0,{...o,ref:t})})})})}),j0=h.forwardRef((e,t)=>{const n=tr(Qt,e.__scopeMenu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return xa(s)},[]),u.jsx(Ea,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),P0=h.forwardRef((e,t)=>{const n=tr(Qt,e.__scopeMenu);return u.jsx(Ea,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),_0=Vt.createSlot("MenuContent.ScrollLock"),Ea=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(Qt,n),y=po(Qt,n),b=bs(n),C=ef(n),k=C0(n),[S,T]=h.useState(null),E=h.useRef(null),j=Me(t,E,x.onContentChange),R=h.useRef(0),D=h.useRef(""),$=h.useRef(0),U=h.useRef(null),X=h.useRef("right"),M=h.useRef(0),K=v?ws:h.Fragment,q=v?{as:_0,allowPinchZoom:!0}:void 0,z=I=>{var L,_;const Y=D.current+I,J=k().filter(G=>!G.disabled),P=document.activeElement,B=(L=J.find(G=>G.ref.current===P))==null?void 0:L.textValue,A=J.map(G=>G.textValue),F=W0(A,Y,B),W=(_=J.find(G=>G.textValue===F))==null?void 0:_.ref.current;(function G(Z){D.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>G(""),1e3))})(Y),W&&setTimeout(()=>W.focus())};h.useEffect(()=>()=>window.clearTimeout(R.current),[]),Gi();const O=h.useCallback(I=>{var J,P;return X.current===((J=U.current)==null?void 0:J.side)&&K0(I,(P=U.current)==null?void 0:P.area)},[]);return u.jsx(A0,{scope:n,searchRef:D,onItemEnter:h.useCallback(I=>{O(I)&&I.preventDefault()},[O]),onItemLeave:h.useCallback(I=>{var Y;O(I)||((Y=E.current)==null||Y.focus(),T(null))},[O]),onTriggerLeave:h.useCallback(I=>{O(I)&&I.preventDefault()},[O]),pointerGraceTimerRef:$,onPointerGraceIntentChange:h.useCallback(I=>{U.current=I},[]),children:u.jsx(K,{...q,children:u.jsx(es,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var Y;I.preventDefault(),(Y=E.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Tr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(_y,{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(fa,{role:"menu","aria-orientation":"vertical","data-state":Sf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,B=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!P&&B&&z(I.key));const A=E.current;if(I.target!==A||!b0.includes(I.key))return;I.preventDefault();const W=k().filter(L=>!L.disabled).map(L=>L.ref.current);Zd.includes(I.key)&&W.reverse(),H0(W)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(R.current),D.current="")}),onPointerMove:ae(e.onPointerMove,mo(I=>{const Y=I.target,J=M.current!==I.clientX;if(I.currentTarget.contains(Y)&&J){const P=I.clientX>M.current?"right":"left";X.current=P,M.current=I.clientX}}))})})})})})})});of.displayName=Qt;var R0="MenuGroup",Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});Ia.displayName=R0;var M0="MenuLabel",sf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});sf.displayName=M0;var ys="MenuItem",af="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=ka(ys,e.__scopeMenu),l=Me(t,s),c=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(af,{bubbles:!0,cancelable:!0});f.addEventListener(af,p=>r==null?void 0:r(p),{once:!0}),Vi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(lf,{...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===" "||Sa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ss.displayName=ys;var lf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ka(ys,n),a=ef(n),l=h.useRef(null),c=Me(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(Ry,{asChild:!0,...a,focusable:!r,children:u.jsx(me.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove: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))})})})}),O0="MenuCheckboxItem",cf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(hf,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ss,{role:"menuitemcheckbox","aria-checked":Cs(n)?"mixed":n,...o,ref:t,"data-state":Aa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(Cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cf.displayName=O0;var uf="MenuRadioGroup",[D0,L0]=er(uf,{value:void 0,onValueChange:()=>{}}),df=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=gt(r);return u.jsx(D0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ia,{...o,ref:t})})});df.displayName=uf;var ff="MenuRadioItem",pf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=L0(ff,e.__scopeMenu),s=n===o.value;return u.jsx(hf,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ss,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Aa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});pf.displayName=ff;var Na="MenuItemIndicator",[hf,$0]=er(Na,{checked:!1}),mf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=$0(Na,n);return u.jsx(Bt,{present:r||Cs(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":Aa(s.checked)})})});mf.displayName=Na;var F0="MenuSeparator",gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});gf.displayName=F0;var B0="MenuArrow",xf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(pa,{...o,...r,ref:t})});xf.displayName=B0;var z0="MenuSub",[DN,vf]=er(z0),ho="MenuSubTrigger",wf=h.forwardRef((e,t)=>{const n=tr(ho,e.__scopeMenu),r=po(ho,e.__scopeMenu),o=vf(ho,e.__scopeMenu),s=ka(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(Ca,{asChild:!0,...c,children:u.jsx(lf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Sf(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===" "||y0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});wf.displayName=ho;var bf="MenuSubContent",yf=h.forwardRef((e,t)=>{const n=nf(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=po(Qt,e.__scopeMenu),a=vf(bf,e.__scopeMenu),l=h.useRef(null),c=Me(t,l);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{present:r||s.open,children:u.jsx(fo.Slot,{scope:e.__scopeMenu,children:u.jsx(Ea,{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=S0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});yf.displayName=bf;function Sf(e){return e?"open":"closed"}function Cs(e){return e==="indeterminate"}function Aa(e){return Cs(e)?"indeterminate":e?"checked":"unchecked"}function H0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function U0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function W0(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=U0(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 V0(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 K0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return V0(n,t)}function mo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var q0=tf,G0=Ca,Y0=rf,X0=of,J0=Ia,Z0=sf,Q0=Ss,eS=cf,tS=df,nS=pf,rS=mf,oS=gf,sS=xf,iS=wf,aS=yf,Ts="DropdownMenu",[lS,LN]=an(Ts,[Qd]),Ot=Qd(),[cS,Cf]=lS(Ts),Tf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=h.useRef(null),[d,f]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Ts});return u.jsx(cS,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(q0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Tf.displayName=Ts;var kf="DropdownMenuTrigger",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Cf(kf,n),i=Ot(n);return u.jsx(G0,{asChild:!0,...i,children:u.jsx(me.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref: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())})})})});Ef.displayName=kf;var uS="DropdownMenuPortal",If=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(Y0,{...r,...n})};If.displayName=uS;var Nf="DropdownMenuContent",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Cf(Nf,n),s=Ot(n),i=h.useRef(!1);return u.jsx(X0,{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)"}})});Af.displayName=Nf;var dS="DropdownMenuGroup",fS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(J0,{...o,...r,ref:t})});fS.displayName=dS;var pS="DropdownMenuLabel",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Z0,{...o,...r,ref:t})});jf.displayName=pS;var hS="DropdownMenuItem",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=hS;var mS="DropdownMenuCheckboxItem",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});_f.displayName=mS;var gS="DropdownMenuRadioGroup",xS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});xS.displayName=gS;var vS="DropdownMenuRadioItem",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...o,...r,ref:t})});Rf.displayName=vS;var wS="DropdownMenuItemIndicator",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(rS,{...o,...r,ref:t})});Mf.displayName=wS;var bS="DropdownMenuSeparator",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(oS,{...o,...r,ref:t})});Of.displayName=bS;var yS="DropdownMenuArrow",SS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(sS,{...o,...r,ref:t})});SS.displayName=yS;var CS="DropdownMenuSubTrigger",Df=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(iS,{...o,...r,ref:t})});Df.displayName=CS;var TS="DropdownMenuSubContent",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(aS,{...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)"}})});Lf.displayName=TS;var kS=Tf,ES=Ef,IS=If,$f=Af,Ff=jf,Bf=Pf,zf=_f,Hf=Rf,Uf=Mf,Wf=Of,Vf=Df,Kf=Lf;const ks=kS,Es=ES,NS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Vf,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));NS.displayName=Vf.displayName;const AS=h.forwardRef(({className:e,...t},n)=>u.jsx(Kf,{ref:n,className:ne("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}));AS.displayName=Kf.displayName;const go=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(IS,{children:u.jsx($f,{ref:r,sideOffset:t,className:ne("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=$f.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Bf,{ref:r,className:ne("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=Bf.displayName;const jS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(zf,{ref:o,className:ne("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(Uf,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));jS.displayName=zf.displayName;const PS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hf,{ref:r,className:ne("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(Uf,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));PS.displayName=Hf.displayName;const _S=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Ff,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));_S.displayName=Ff.displayName;const RS=h.forwardRef(({className:e,...t},n)=>u.jsx(Wf,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));RS.displayName=Wf.displayName;const ja=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ne("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}));ja.displayName="Textarea";const MS=1e4;function qf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=MS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend: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),j=w.useRef(0),R=w.useRef(null),D=w.useRef("");w.useEffect(()=>{y||(C(e??""),R.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[$,U]=w.useState(null),X=w.useCallback(A=>A.length>s?`Message too long (${A.length}/${s} characters)`:null,[s]),M=w.useMemo(()=>g??X,[g,X]),K=w.useCallback(A=>{const F=M(A);return U(F),x==null||x(F),D.current=A,F},[M,x]),q=w.useCallback(()=>{const A=E.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);w.useEffect(()=>{q()},[q,k]),w.useEffect(()=>{if(!$)return;const A=(k??"").trim();D.current!==A&&K(A)},[k,$,K]);const z=w.useCallback((A,{fromUser:F})=>{y||C(A),F&&(a==null||a(A))},[y,a]),O=w.useCallback(async A=>{A&&A.preventDefault();const F=(k??"").trim();if(!F&&!p||K(F))return;const W=++j.current;R.current={id:W,shouldClear:!0},T(()=>{var L,_,G;try{const Z=l(F);Z&&typeof Z.then=="function"?Z.then(()=>{var oe,se;((oe=R.current)==null?void 0:oe.id)===W&&R.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((se=R.current)==null?void 0:se.id)===W&&(R.current=null)}).catch(()=>{var oe;((oe=R.current)==null?void 0:oe.id)===W&&(R.current=null)}):(((L=R.current)==null?void 0:L.id)===W&&R.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((_=R.current)==null?void 0:_.id)===W&&(R.current=null))}catch{((G=R.current)==null?void 0:G.id)===W&&(R.current=null)}})},[k,l,p,y,a,K]),I=w.useCallback(A=>{const F=A.target.value;z(F,{fromUser:!0}),R.current&&(R.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),$&&K(F.trim())},[z,K,$]),Y=w.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),O()):A.key==="Escape"&&t&&(A.preventDefault(),c==null||c())},[O,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:A=>void O(A),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ja,{ref:E,value:k,onChange:I,onKeyDown:Y,placeholder:t?"Edit your message...":n,className:B,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),u.jsx("div",{children:r?u.jsx(Xe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(Xe,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!p||S,children:u.jsx(ue.Send,{size:16})})})]})})}const OS=w.memo(qf);function Gf({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),[j,R]=w.useState(0),[D,$]=w.useState(!1),[U,X]=w.useState(null),[M,K]=w.useState(null),q=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(A=>A+1),R(A=>A+1)},[]),z=w.useCallback(A=>{C(F=>[...F,...A])},[]),O=w.useCallback(A=>{const F=Array.from(A.target.files||[]);z(F),A.target.value=""},[z]),I=w.useCallback(A=>{C(F=>{const W=F.filter((L,_)=>_!==A);return W.length===0&&q(),W})},[q]),Y=w.useCallback(async A=>{const F=(A.target.files||[])[0];if(F&&(X(null),K(null),!!v)){$(!0);try{await v(F),X(`Uploaded ${F.name} - processing through chat stream`)}catch(W){const L=W instanceof Error?W.message:"Failed to upload Excel file";K(L),g==null||g(L)}finally{$(!1),A.target.value="",q()}}},[v,g,q]),J=w.useMemo(()=>x||b.length>0,[x,b]),P=w.useCallback(async A=>{const W=await n(A,b);return b.length>0&&(C([]),q()),W},[n,q,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:O,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((A,F)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:A.name}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>I(F),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 ${A.name}`,children:u.jsx(ue.X,{size:12})})]},F))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Y,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),U&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:U}),M&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:M})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||p)&&u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Xe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:f.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(go,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var A;return(A=k.current)==null?void 0:A.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Fn,{onClick:()=>{var A;D||(A=S.current)==null||A.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(OS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:P,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:B,sendButtonClassName:f.sendButton})})]})]})}const DS=w.memo(Gf),Is=0,Bn=1,Mr=2,Yf=4;function Xf(e){return()=>e}function LS(e){e()}function Jf(e,t){return n=>e(t(n))}function Zf(e,t){return()=>e(t)}function $S(e,t){return n=>e(t,n)}function Pa(e){return e!==void 0}function FS(...e){return()=>{e.map(LS)}}function Or(){}function Ns(e,t){return t(e),e}function BS(e,t){return t(e)}function at(...e){return e}function Je(e,t){return e(Bn,t)}function Pe(e,t){e(Is,t)}function _a(e){e(Mr)}function xt(e){return e(Yf)}function ge(e,t){return Je(e,$S(t,Is))}function un(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function Qf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function ep(e,t){return e===t}function lt(e=ep){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Te(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Jf(t,e)}function Cn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=zS(...t);return(r,o)=>{switch(r){case Mr:_a(e);return;case Bn:return Je(e,n(o))}}}function Tn(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 Oe(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function zS(...e){return t=>e.reduceRight(BS,t)}function HS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),Or);case Mr: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 Yf:return t}return n(r,o)}}function jt(e,t){return Ns(re(t),n=>ge(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case Is:e.slice().forEach(r=>{r(n)});return;case Mr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return Ns(ze(),t=>ge(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:US(),singleton:n}}const US=()=>Symbol();function WS(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=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);Je(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case Mr:{_a(t);return}case Bn:return r===o&&i(n),Je(t,i)}}}function Ce(e,t=ep){return Q(e,lt(t))}function Ra(...e){return function(t,n){switch(t){case Mr:return;case Bn:return FS(...e.map(r=>Je(r,n)))}}}var zt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(zt||{});const VS={0:"debug",3:"error",1:"log",2:"warn"},KS=()=>typeof globalThis>"u"?window:globalThis,zn=Ge(()=>{const e=re(3);return{log:re((t,n,r=1)=>{var o;const s=(o=KS().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[VS[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 Ma(e,t,n).callbackRef}function Ma(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 qS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const f=GS(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?tp("column-gap",getComputedStyle(d).columnGap,o):tp("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ma(c,n,l)}function GS(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},zt.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 tp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}function np(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}=Ma(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 Dt=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 ge(Q(e,fe(({scrollTop:x})=>x)),t),ge(Q(e,fe(({scrollHeight:x})=>x)),i),ge(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 rp(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 nt(e){return e===xo}function vo(e,t){if(!nt(e))return t===e.k?e.v:t<e.k?vo(e.l,t):vo(e.r,t)}function dn(e,t,n="k"){if(nt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Jt(e,t,n){return nt(e)?ip(t,n,1):t===e.k?kt(e,{k:t,v:n}):t<e.k?ap(kt(e,{l:Jt(e.l,t,n)})):ap(kt(e,{r:Jt(e.r,t,n)}))}function Dr(){return xo}function As(e,t,n){if(nt(e))return[];const r=dn(e,t)[0];return YS(Da(e,r,n))}function Oa(e,t){if(nt(e))return xo;const{k:n,l:r,r:o}=e;if(t===n){if(nt(r))return o;if(nt(o))return r;{const[s,i]=sp(r);return js(kt(e,{k:s,l:op(r),v:i}))}}else return t<n?js(kt(e,{l:Oa(r,t)})):js(kt(e,{r:Oa(o,t)}))}function or(e){return nt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function Da(e,t,n){if(nt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Da(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Da(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(La(t))return lp(kt(e,{lvl:n-1}));if(!nt(t)&&!nt(t.r))return kt(t.r,{l:kt(t,{r:t.r.l}),lvl:n,r:kt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(La(e))return $a(kt(e,{lvl:n-1}));if(!nt(r)&&!nt(r.l)){const o=r.l,s=La(o)?r.lvl-1:r.lvl;return kt(o,{l:kt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:$a(kt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function kt(e,t){return ip(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 op(e){return nt(e.r)?e.l:js(kt(e,{r:op(e.r)}))}function La(e){return nt(e)||e.lvl>e.r.lvl}function sp(e){return nt(e.r)?[e.k,e.v]:sp(e.r)}function ip(e,t,n,r=xo,o=xo){return{k:e,l:r,lvl:n,r:o,v:t}}function ap(e){return $a(lp(e))}function lp(e){const{l:t}=e;return!nt(t)&&t.lvl===e.lvl?kt(t,{r:kt(e,{l:t.r})}):e}function $a(e){const{lvl:t,r:n}=e;return!nt(n)&&!nt(n.r)&&n.lvl===t&&n.r.lvl===t?kt(n,{l:kt(e,{r:n.l}),lvl:t+1}):e}function YS(e){return rp(e,({k:t,v:n})=>({index:t,value:n}))}function cp(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 Fa=Ge(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function up(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 XS(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!nt(e.groupOffsetTree)}function Ba({index:e},t){return t===e?0:t<e?-1:1}function JS(){return{groupIndices:[],groupOffsetTree:Dr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Dr()}}function ZS(e,t){let n=nt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),nt(e)){e=Jt(e,0,s);continue}const a=As(e,i-1,o+1);if(a.some(sC(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Oa(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=Jt(e,o+1,m));c&&(e=Jt(e,i,s))}return[e,n]}function QS(e){return typeof e.groupIndex<"u"}function eC({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}=up(t,e,Ba),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function dp(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function fp(e,t,n){if(QS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=dp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function tC(e,t,n,r=0){return r>0&&(t=Math.max(t,up(e,r,Ba).offset)),rp(XS(e,t,n,eC),oC)}function nC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,zt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&nt(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>Jt(Jt(v,g,m),g+1,p),i)}else[i,a]=ZS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=za(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>Jt(m,p,bo(p,f,o)),Dr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function rC(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 pp(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 za(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ps(o,t-1,Ba),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(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 oC(e){return{index:e.index,value:e}}function sC(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 iC={offsetHeight:"height",offsetWidth:"width"},kn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=jt(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,iC[T])),m=re(void 0),p=re(0),v=JS(),g=jt(Q(n,Oe(l,e,p),Tn(nC,v),lt()),v),x=jt(Q(l,lt(),Tn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),fe(({prev:S})=>S)),[]);ge(Q(l,Te(S=>S.length>0),Oe(g,p),fe(([S,T,E])=>{const j=S.reduce((R,D,$)=>Jt(R,D,bo(D,T.offsetTree,E)||$),Dr());return{...T,groupIndices:S,groupOffsetTree:j}})),g),ge(Q(r,Oe(g),Te(([S,{lastIndex:T}])=>S<T),fe(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),ge(c,d);const y=jt(Q(c,fe(S=>S===void 0)),!0);ge(Q(d,Te(S=>S!==void 0&&nt(xt(g).sizeTree)),fe(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Xt(Q(n,Oe(g),Tn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),fe(S=>S.changed)));Je(Q(a,Tn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),fe(S=>S.diff)),S=>{const{groupIndices:T}=xt(g);if(S>0)Pe(t,!0),Pe(s,S+pp(S,T));else if(S<0){const E=xt(x);E.length>0&&(S-=pp(-S,E)),Pe(i,S)}}),Je(Q(a,Oe(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},zt.ERROR)});const C=Xt(s);ge(Q(s,Oe(g),fe(([S,T])=>{const E=T.groupIndices.length>0,j=[],R=T.lastSize;if(E){const D=vo(T.sizeTree,0);let $=0,U=0;for(;$<S;){const M=T.groupIndices[U],K=T.groupIndices.length===U+1?1/0:T.groupIndices[U+1]-M-1;j.push({endIndex:M,size:D,startIndex:M}),j.push({endIndex:M+1+K-1,size:R,startIndex:M+1}),U++,$+=K+1}const X=or(T.sizeTree);return $!==S&&X.shift(),X.reduce((M,{k:K,v:q})=>{let z=M.ranges;return M.prevSize!==0&&(z=[...M.ranges,{endIndex:K+S-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:K+S,prevSize:q,ranges:z}},{prevIndex:S,prevSize:0,ranges:j}).ranges}return or(T.sizeTree).reduce((D,{k:$,v:U})=>({prevIndex:$+S,prevSize:U,ranges:[...D.ranges,{endIndex:$+S-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=Xt(Q(i,Oe(g,p),fe(([S,{offsetTree:T},E])=>{const j=-S;return bo(j,T,E)})));return ge(Q(i,Oe(g,p),fe(([S,T,E])=>{if(T.groupIndices.length>0){if(nt(T.sizeTree))return T;let j=Dr();const R=xt(x);let D=0,$=0,U=0;for(;D<-S;){U=R[$];const X=R[$+1]-U-1;$++,D+=X+1}if(j=or(T.sizeTree).reduce((X,{k:M,v:K})=>Jt(X,Math.max(0,M+S),K),j),D!==-S){const X=vo(T.sizeTree,U);j=Jt(j,0,X);const M=dn(T.sizeTree,-S+1)[1];j=Jt(j,1,M)}return{...T,sizeTree:j,...za(T.offsetTree,0,j,E)}}else{const j=or(T.sizeTree).reduce((R,{k:D,v:$})=>Jt(R,Math.max(0,D+S),$),Dr());return{...T,sizeTree:j,...za(T.offsetTree,0,j,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}},at(zn,Fa),{singleton:!0});function aC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const hp=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=Xt(Q(s,fe(aC)));return ge(Q(a,fe(l=>l.totalCount)),n),ge(Q(a,fe(l=>l.groupIndices)),e),ge(Q(yt(o,t,r),Te(([l,c])=>_s(c)),fe(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),lt(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},at(kn,Dt)),Un=Ge(([{log:e}])=>{const t=re(!1),n=Xt(Q(t,Te(r=>r),lt()));return Je(t,r=>{r&&xt(e)("props updated",{},zt.DEBUG)}),{didMount:n,propsReady:t}},at(zn),{singleton:!0}),lC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function mp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!lC)&&(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),Pe(l,!1)}return ge(Q(p,Oe(n,f,r,g,a,i,m),Oe(e,s,o),fe(([[k,S,T,E,j,R,D,$],U,X,M])=>{const K=mp(k),{align:q,behavior:z,offset:O}=K,I=E-1,Y=fp(K,S,I);let J=bo(Y,S.offsetTree,U)+R;q==="end"?(J+=X+dn(S.sizeTree,Y)[1]-T+M,Y===I&&(J+=D)):q==="center"?J+=(X+dn(S.sizeTree,Y)[1]-T+M)/2:J-=j,O&&(J+=O);const P=B=>{C(),B?($("retrying to scroll to",{location:k},zt.DEBUG),Pe(p,k)):(Pe(v,!0),$("list did not change, scroll successful",{},zt.DEBUG))};if(C(),z==="smooth"){let B=!1;b=Je(t,A=>{B=B||A}),x=un(d,()=>{P(B)})}else x=un(Q(t,cC(150)),P);return y=setTimeout(()=>{C()},1200),Pe(l,!0),$("scrolling from index to",{behavior:z,index:Y,top:J},zt.DEBUG),{behavior:z,top:J}})),c),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},at(kn,Dt,zn),{singleton:!0});function cC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ha(e,t){e==0?t():requestAnimationFrame(()=>{Ha(e-1,t)})}function Ua(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 ge(Q(i,Oe(l),Te(([d,f])=>!!f),Cn(!1)),a),ge(Q(i,Oe(l),Te(([d,f])=>!!f),Cn(!1)),c),Je(Q(yt(t,i),Oe(a,n,e,c),Te(([[,d],f,{sizeTree:m},p,v])=>d&&(!nt(m)||Pa(p))&&!f&&!v),Oe(l)),([,d])=>{un(o,()=>{Pe(c,!0)}),Ha(4,()=>{un(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},at(kn,Dt,yo,Un),{singleton:!0});function gp(e,t){return Math.abs(e-t)<1.01}const Co="up",To="down",uC="none",dC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},fC=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(fC),m=jt(Q(Ra(Q(Ce(o),nr(1),Cn(!0)),Q(Ce(o),nr(1),Cn(!1),Qf(100))),lt()),!1),p=jt(Q(Ra(Q(n,Cn(!0)),Q(n,Cn(!1),Qf(200))),lt()),!1);ge(Q(yt(Ce(o),Ce(f)),fe(([b,C])=>b<=C),lt()),a),ge(Q(a,Pn(50)),c);const v=Xt(Q(yt(r,Ce(s),Ce(t),Ce(e),Ce(d)),Tn((b,[{scrollHeight:C,scrollTop:k},S,T,E,j])=>{const R=k+S-C>-j,D={scrollHeight:C,scrollTop:k,viewportHeight:S};if(R){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:D}}let $;return D.scrollHeight>b.state.scrollHeight?$="SIZE_INCREASED":S<b.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:D}},dC),lt((b,C)=>b&&b.atBottom===C.atBottom))),g=jt(Q(r,Tn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(gp(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}),Te(b=>b.changed),fe(b=>b.jump)),0);ge(Q(v,fe(b=>b.atBottom)),i),ge(Q(i,Pn(50)),l);const x=re(To);ge(Q(r,fe(({scrollTop:b})=>b),lt(),Tn((b,C)=>xt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?Co:To,prevScrollTop:C},{direction:To,prevScrollTop:0}),fe(b=>b.direction)),x),ge(Q(r,Pn(50),Cn(uC)),x);const y=re(0);return ge(Q(m,Te(b=>!b),Cn(0)),y),ge(Q(o,Pn(100),Oe(m),Te(([b,C])=>!!C),Tn(([b,C],[k])=>[C,k],[0,0]),fe(([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}},at(Dt)),Rs="top",Ms="bottom",xp="none";function vp(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 wp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Wa=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=re(0),a=re(0),l=re(0),c=jt(Q(yt(Ce(r),Ce(o),Ce(n),Ce(s,wo),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),fe(([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=xp;const j=wp(C,Rs),R=wp(C,Ms);return p-=b,p+=m+y,v+=m+y,v-=b,p>d+S-j&&(E=Co),v<d-T+f+R&&(E=To),E!==xp?[Math.max(k-m-vp(g,Rs,E)-j,0),k-T-y+f+vp(g,Ms,E)+R]:null}),Te(d=>d!=null),lt(wo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},at(Dt),{singleton:!0});function pC(e,t,n){if(_s(t)){const r=dp(e,t);return[{index:dn(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 Va={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:yp(e,o,s),offsetBottom:v,offsetTop:c,top:p,topItems:yp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function bp(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=Ua(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 yp(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();ge(s.topItemsIndexes,g);const b=jt(Q(yt(p,v,Ce(l,wo),Ce(o),Ce(r),Ce(c),d,Ce(g),Ce(t),Ce(n),e),Te(([T,E,,j,,,,,,,R])=>{const D=R&&R.length!==j;return T&&!E&&!D}),fe(([,,[T,E],j,R,D,$,U,X,M,K])=>{const q=R,{offsetTree:z,sizeTree:O}=q,I=xt(x);if(j===0)return{...Va,totalCount:j};if(T===0&&E===0)return I===0?{...Va,totalCount:j}:bp(I,D,R,X,M,K||[]);if(nt(O))return I>0?null:Os(pC(Ua(D,j),q,K),[],j,M,q,X);const Y=[];if(U.length>0){const F=U[0],W=U[U.length-1];let L=0;for(const _ of As(O,F,W)){const G=_.value,Z=Math.max(_.start,F),oe=Math.min(_.end,W);for(let se=Z;se<=oe;se++)Y.push({data:K==null?void 0:K[se],index:se,offset:L,size:G}),L+=G}}if(!$)return Os([],Y,j,M,q,X);const J=U.length>0?U[U.length-1]+1:0,P=tC(z,T,E,J);if(P.length===0)return null;const B=j-1,A=Ns([],F=>{for(const W of P){const L=W.value;let _=L.offset,G=W.start;const Z=L.size;if(L.offset<T){G+=Math.floor((T-L.offset+M)/(Z+M));const se=G-W.start;_+=se*Z+se*M}G<J&&(_+=(J-G)*Z,G=J);const oe=Math.min(W.end,B);for(let se=G;se<=oe&&!(_>=E);se++)F.push({data:K==null?void 0:K[se],index:se,offset:_,size:Z}),_+=Z+M}});return Os(A,Y,j,M,q,X)}),Te(T=>T!==null),lt()),Va);ge(Q(e,Te(Pa),fe(T=>T==null?void 0:T.length)),o),ge(Q(b,fe(T=>T.topListHeight)),f),ge(f,a),ge(Q(b,fe(T=>[T.top,T.bottom])),i),ge(Q(b,fe(T=>T.items)),y);const C=Xt(Q(b,Te(({items:T})=>T.length>0),Oe(o,e),Te(([{items:T},E])=>T[T.length-1].originalIndex===E-1),fe(([,T,E])=>[T-1,E]),lt(wo),fe(([T])=>T))),k=Xt(Q(b,Pn(200),Te(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),fe(({items:T})=>T[0].index),lt())),S=Xt(Q(b,Te(({items:T})=>T.length>0),fe(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),lt(cp)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},at(kn,hp,Wa,So,yo,ko,Un,Fa),{singleton:!0}),Sp=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=jt(Q(yt(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return ge(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},at(Dt,sr),{singleton:!0}),hC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=jt(Q(yt(n,e,t),Te(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Pn(0),lt()),0);return{alignToBottom:n,paddingTopAddition:r}},at(Dt,Sp),{singleton:!0}),Cp=Ge(()=>({context:re(null)})),mC=({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,Tp=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 ge(Q(d,Oe(t,l,n,s,o,r,a),Oe(e),fe(([[f,m,p,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=mC,done:E,...j}=f,R=fp(f,m,v-1),D=bo(R,m.offsetTree,C)+g+x,$=D+dn(m.sizeTree,R)[1],U=b+x,X=b+p-y,M=T({itemBottom:$,itemTop:D,locationParams:{align:k,behavior:S,...j},viewportBottom:X,viewportTop:U});return M?E&&un(Q(i,Te(K=>!K),nr(xt(i)?1:2)),E):E&&E(),M}),Te(f=>f!==null)),c),{scrollIntoView:d}},at(kn,Dt,yo,sr,zn),{singleton:!0});function kp(e){return e?e==="smooth"?"smooth":"auto":!1}const gC=(e,t)=>typeof e=="function"?kp(e(t)):t&&kp(e),xC=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){Pe(i,{align:"end",behavior:S,index:"LAST"})}Je(Q(yt(Q(Ce(t),nr(1)),l),Oe(Ce(v),s,a,f),fe(([[S,T],E,j,R,D])=>{let $=T&&R,U="auto";return $&&(U=gC(E,j||D),$=$&&!!U),{followOutputBehavior:U,shouldFollow:$,totalCount:S}}),Te(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S)}):x=un(e,()=>{xt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S),x=null})});function b(S){const T=un(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(xt(d)("scrolling to bottom due to increased size",{},zt.DEBUG),y("auto"))});setTimeout(T,100)}Je(Q(yt(Ce(v),t,c),Te(([S,,T])=>S&&T),Tn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),Te(({refreshed:S})=>S),Oe(v,t)),([,S])=>{xt(a)&&b(S!==!1)}),Je(g,()=>{b(xt(v)!==!1)}),Je(yt(Ce(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=re(null),k=ze();return ge(Ra(Q(Ce(r),fe(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),Q(Ce(t))),k),Je(Q(yt(Q(k,nr(1)),l),Oe(Ce(C),a,f,m),fe(([[S,T],E,j,R,D])=>T&&j&&(E==null?void 0:E({context:D,totalCount:S,scrollingInProgress:R}))),Te(S=>!!S),Pn(0)),S=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Pe(p,S)}):x=un(e,()=>{xt(d)("scrolling into view",{}),Pe(p,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},at(kn,ko,yo,So,Un,zn,Dt,Cp,Tp)),vC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(Q(a,Oe(s),Te(([,l])=>l!==0),Oe(o,r,t,n,e),fe(([[,l],c,d,f,m,p=[]])=>bp(l,c,d,f,m,p))),i),{}),at(kn,So,sr,Un),{singleton:!0}),wC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return Je(Q(e,Oe(r),Te(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{un(Q(n,nr(1),Te(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},at(Un,Dt,sr),{singleton:!0}),Ep=Ge(([{scrollVelocity:e}])=>{const t=re(!1),n=ze(),r=re(!1);return ge(Q(e,Oe(r,t,n),Te(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),lt()),t),Je(Q(yt(t,e,n),Oe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},at(ko),{singleton:!0}),Ka=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=re(!1),i=re(void 0);return ge(Q(yt(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(Q(t,Oe(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},at(Dt)),bC=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 ge(a,f),ge(l,m),Je(Q(c,Oe(t,r,i,f,m,n)),([p,v,g,x,y,b,C])=>{const k=rC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,p({ranges:k,scrollTop:g})}),ge(Q(d,Te(Pa),fe(yC)),o),ge(Q(s,Oe(d),Te(([,p])=>p!==void 0),lt(),fe(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},at(kn,Dt,So,Un,Ka));function yC(e){return{align:"start",index:0,offset:e.scrollTop}}const SC=Ge(([{topItemsIndexes:e}])=>{const t=re(0);return ge(Q(t,Te(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},at(sr));function Ip(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const CC=Ip(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),TC=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=Xt(Q(l,Oe(i),Tn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},j])=>{const R=k+T;let D=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||(D=R-C,D!==0&&(D+=j))),[D,S,E,R]},[0,[],0,0]),Te(([y])=>y!==0),Oe(r,a,n,o,p,v),Te(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===Co),fe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},zt.DEBUG),y))));function x(y){y>0?(Pe(t,{behavior:"auto",top:-y}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-y}))}return Je(Q(g,Oe(e,s)),([y,b,C])=>{C&&CC()?Pe(e,b-y):x(-y)}),Je(Q(yt(jt(s,!1),e,v),Te(([y,b,C])=>!y&&!C&&b!==0),fe(([y,b])=>b),Pn(1)),x),ge(Q(f,fe(y=>({top:-y}))),t),Je(Q(c,Oe(m,d),fe(([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 j=vo(k,0);let R=0,D=0;for(;R<y;){R++,E+=j;let $=b.length===D+1?1/0:b[D+1]-b[D]-1;R+$>y&&(E-=j,$=y-R+1),R+=$,E+=T($),D++}return E}})),y=>{Pe(e,y),requestAnimationFrame(()=>{Pe(t,{top:y}),requestAnimationFrame(()=>{Pe(e,0),Pe(v,!1)})})}),{deviation:e}},at(Dt,ko,sr,kn,zn,Fa)),kC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),at(Wa,vC,Un,Ep,Sp,wC,hC,Ka,Tp,zn,Cp)),Np=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:j},R])=>(ge(k.rangeChanged,R.scrollSeekRangeChanged),ge(Q(R.windowViewportRect,fe(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,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,...R,...g,sizes:l,...x}),at(kn,So,Dt,bC,xC,sr,yo,TC,SC,hp,kC));function EC(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 Ap(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&&Pe(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Pe(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Pe(C,y[b])}x.propsReady&&Pe(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Pe(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=HS(x[t.events[b]]),y),{})}const f=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Ns(WS(e),E=>{l(E,C)})),[S]=w.useState(Zf(d,k));Ds(()=>{for(const E of i)E in C&&Je(S[E],C[E]);return()=>{Object.values(S).map(_a)}},[C,S,k]),Ds(()=>{l(k,C)}),w.useImperativeHandle(y,Xf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...EC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Pe(y[x],b)},[y,x])},p=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Je(y,C),[y]);return w.useSyncExternalStore(b,()=>xt(y),()=>xt(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(Zf(xt,y));return Ds(()=>Je(y,k=>{k!==b&&C(Xf(k))}),[y,b]),b},g=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ds(()=>Je(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const jp=w.createContext(void 0),Pp=w.createContext(void 0),_p=typeof document<"u"?w.useLayoutEffect:w.useEffect;function qa(e){return"self"in e}function IC(e){return"body"in e}function Rp(e,t,n,r=Or,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(IC(x)||qa(x)){const b=qa(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;qa(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)),gp(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 Ga="-webkit-sticky",Mp="sticky",Ya=Ip(()=>{if(typeof document>"u")return Mp;const e=document.createElement("div");return e.style.position=Ga,e.style.position===Ga?Ga:Mp});function Xa(e){return e}const NC=Ge(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(Xa),o=re("div"),s=re(Or),i=(a,l=null)=>jt(Q(n,fe(c=>c[a]),lt()),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")}}),AC=Ge(([e,t])=>({...e,...t}),at(Np,NC)),jC=({height:e})=>u.jsx("div",{style:{height:e}}),PC={overflowAnchor:"none",position:Ya(),zIndex:1},Op={overflowAnchor:"none"},_C={...Op,display:"inline-block",height:"100%"},Dp=w.memo(function({showTopList:e=!1}){const t=Ee("listState"),n=en("sizeRanges"),r=Ee("useWindowScroll"),o=Ee("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Ee("itemContent"),c=Ee("context"),d=Ee("groupContent"),f=Ee("trackItemSizes"),m=Ee("itemSize"),p=Ee("log"),v=en("gap"),g=Ee("horizontalDirection"),{callbackRef:x}=qS(n,m,f,e?Or:a,p,v,o,g,Ee("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Ja("deviation",M=>{y!==M&&b(M)});const C=Ee("EmptyPlaceholder"),k=Ee("ScrollSeekPlaceholder")||jC,S=Ee("ListComponent"),T=Ee("ItemComponent"),E=Ee("GroupComponent"),j=Ee("computeItemKey"),R=Ee("isSeeking"),D=Ee("groupIndices").length>0,$=Ee("alignToBottom"),U=Ee("initialItemFinalLocationReached"),X=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:$?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:$?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Pt(C,c)}):u.jsx(S,{...Pt(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:X,children:(e?t.topItems:t.items).map(M=>{const K=M.originalIndex,q=j(K+t.firstItemIndex,M.data,c);return R?w.createElement(k,{...Pt(k,c),height:M.size,index:M.index,key:q,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?w.createElement(E,{...Pt(E,c),"data-index":K,"data-item-index":M.index,"data-known-size":M.size,key:q,style:PC},d(M.index,c)):w.createElement(T,{...Pt(T,c),...DC(T,M.data),"data-index":K,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:q,style:g?_C:Op},D?l(M.index,M.groupIndex,M.data,c):l(M.index,M.data,c))})})}),RC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},MC={outline:"none",overflowX:"auto",position:"relative"},Ls=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),OC={position:Ya(),top:0,width:"100%",zIndex:1};function Pt(e,t){if(typeof e!="string")return{context:t}}function DC(e,t){return{item:typeof e=="string"?void 0:t}}const LC=w.memo(function(){const e=Ee("HeaderComponent"),t=en("headerHeight"),n=Ee("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),$C=w.memo(function(){const e=Ee("FooterComponent"),t=en("footerHeight"),n=Ee("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null});function Lp({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}=Rp(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?MC:RC,...o},tabIndex:0,...i,...Pt(l,s),children:r})})}function $p({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}=Rp(a,c,l,v,m);return _p(()=>{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,...Pt(l,s),children:r})})}const FC=({children:e})=>{const t=w.useContext(jp),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Ee("alignToBottom"),s=Ee("horizontalDirection"),i=w.useMemo(()=>Jf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ee("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})},BC=({children:e})=>{const t=w.useContext(jp),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Ee("customScrollParent"),s=np(n,o,Ee("skipAnimationFrameInResizeObserver")),i=Ee("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})},zC=({children:e})=>{const t=Ee("TopItemListComponent")||"div",n=Ee("headerHeight"),r={...OC,marginTop:`${n}px`},o=Ee("context");return u.jsx(t,{style:r,...Pt(t,o),children:e})},HC=w.memo(function(e){const t=Ee("useWindowScroll"),n=Ee("topItemsIndexes").length>0,r=Ee("customScrollParent"),o=Ee("context");return u.jsxs(r||t?VC:WC,{...e,context:o,children:[n&&u.jsx(zC,{children:u.jsx(Dp,{showTopList:!0})}),u.jsxs(r||t?BC:FC,{children:[u.jsx(LC,{}),u.jsx(Dp,{}),u.jsx($C,{})]})]})}),{Component:UC,useEmitter:Ja,useEmitterValue:Ee,usePublisher:en}=Ap(AC,{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"}},HC),WC=Lp({useEmitter:Ja,useEmitterValue:Ee,usePublisher:en}),VC=$p({useEmitter:Ja,useEmitterValue:Ee,usePublisher:en}),KC=UC;at(Np,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(Xa),a=re(Or),l=(c,d=null)=>jt(Q(s,fe(f=>f[c]),lt()),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")}})),Ya();const Fp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},qC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Bp,floor:$s,max:Eo,min:Za,round:zp}=Math;function Hp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function GC(e){return{...qC,items:e}}function Fs(e,t){return e&&e.width===t.width&&e.height===t.height}function YC(e,t){return e&&e.column===t.column&&e.row===t.row}const XC=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),j=re(Fp),R=re({height:0,width:0}),D=re({height:0,width:0}),$=ze(),U=ze(),X=re(0),M=re(null),K=re({column:0,row:0}),q=ze(),z=ze(),O=re(!1),I=re(0),Y=re(!0),J=re(!1),P=re(!1);Je(Q(v,Oe(I),Te(([_,G])=>!!G)),()=>{Pe(Y,!1)}),Je(Q(yt(v,Y,D,R,I,J),Te(([_,G,Z,oe,,se])=>_&&!G&&Z.height!==0&&oe.height!==0&&!se)),([,,,,_])=>{Pe(J,!0),Ha(1,()=>{Pe($,_)}),un(Q(c),()=>{Pe(t,[0,0]),Pe(Y,!0)})}),ge(Q(z,Te(_=>_!=null&&_.scrollTop>0),Cn(0)),E),Je(Q(v,Oe(z),Te(([,_])=>_!=null)),([,_])=>{_&&(Pe(R,_.viewport),Pe(D,_.item),Pe(K,_.gap),_.scrollTop>0&&(Pe(O,!0),un(Q(c,nr(1)),G=>{Pe(O,!1)}),Pe(l,{top:_.scrollTop})))}),ge(Q(R,fe(({height:_})=>_)),f),ge(Q(yt(Ce(R,Fs),Ce(D,Fs),Ce(K,(_,G)=>_&&_.column===G.column&&_.row===G.row),Ce(c)),fe(([_,G,Z,oe])=>({gap:Z,item:G,scrollTop:oe,viewport:_}))),q),ge(Q(yt(Ce(T),r,Ce(K,YC),Ce(D,Fs),Ce(R,Fs),Ce(M),Ce(E),Ce(O),Ce(Y),Ce(I)),Te(([,,,,,,,_])=>!_),fe(([_,[G,Z],oe,se,ie,le,ye,,De,He])=>{const{column:_e,row:$e}=oe,{height:ct,width:ft}=se,{width:St}=ie;if(ye===0&&(_===0||St===0))return Fp;if(ft===0){const st=Ua(He,_),vt=st+Math.max(ye-1,0);return GC(Hp(st,vt,le))}const Ke=Up(St,ft,_e);let Ye,Ue;De?G===0&&Z===0&&ye>0?(Ye=0,Ue=ye-1):(Ye=Ke*$s((G+$e)/(ct+$e)),Ue=Ke*Bp((Z+$e)/(ct+$e))-1,Ue=Za(_-1,Eo(Ue,Ke-1)),Ye=Za(Ue,Eo(0,Ye))):(Ye=0,Ue=-1);const Le=Hp(Ye,Ue,le),{bottom:je,top:pt}=Wp(ie,oe,se,Le),Rt=Bp(_/Ke),et=Rt*ct+(Rt-1)*$e-je;return{bottom:je,itemHeight:ct,items:Le,itemWidth:ft,offsetBottom:et,offsetTop:pt,top:pt}})),j),ge(Q(M,Te(_=>_!==null),fe(_=>_.length)),T),ge(Q(yt(R,D,j,K),Te(([_,G,{items:Z}])=>Z.length>0&&G.height!==0&&_.height!==0),fe(([_,G,{items:Z},oe])=>{const{bottom:se,top:ie}=Wp(_,oe,G,Z);return[ie,se]}),lt(wo)),t);const B=re(!1);ge(Q(c,Oe(B),fe(([_,G])=>G||_!==0)),B);const A=Xt(Q(yt(j,T),Te(([{items:_}])=>_.length>0),Oe(B),Te(([[_,G],Z])=>{const oe=_.items[_.items.length-1].index===G-1;return(Z||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===G)&&oe}),fe(([[,_]])=>_-1),lt())),F=Xt(Q(Ce(j),Te(({items:_})=>_.length>0&&_[0].index===0),Cn(0),lt())),W=Xt(Q(Ce(j),Oe(O),Te(([{items:_},G])=>_.length>0&&!G),fe(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),lt(cp),Pn(0)));ge(W,p.scrollSeekRangeChanged),ge(Q($,Oe(R,D,T,K),fe(([_,G,Z,oe,se])=>{const ie=mp(_),{align:le,behavior:ye,offset:De}=ie;let He=ie.index;He==="LAST"&&(He=oe-1),He=Eo(0,He,Za(oe-1,He));let _e=Qa(G,se,Z,He);return le==="end"?_e=zp(_e-G.height+Z.height):le==="center"&&(_e=zp(_e-G.height/2+Z.height/2)),De&&(_e+=De),{behavior:ye,top:_e}})),l);const L=jt(Q(j,fe(_=>_.offsetBottom+_.bottom)),0);return ge(Q(k,fe(_=>({height:_.visibleHeight,width:_.visibleWidth}))),R),{customScrollParent:x,data:M,deviation:X,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:l,scrollToIndex:$,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...p,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:L,...m,endReached:A,propsReady:g,rangeChanged:W,startReached:F,stateChanged:q,stateRestoreInProgress:O,...S}},at(Wa,Dt,ko,Ep,Un,Ka,zn));function Up(e,t,n){return Eo(1,$s((e+n)/($s(t)+n)))}function Wp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Qa(e,t,n,r[0].index);return{bottom:Qa(e,t,n,r[r.length-1].index)+o,top:s}}function Qa(e,t,n,r){const o=Up(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 JC=Ge(()=>{const e=re(f=>`Item ${f}`),t=re({}),n=re(null),r=re("virtuoso-grid-item"),o=re("virtuoso-grid-list"),s=re(Xa),i=re("div"),a=re(Or),l=(f,m=null)=>jt(Q(t,fe(p=>p[f]),lt()),m),c=re(!1),d=re(!1);return ge(Ce(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),ZC=Ge(([e,t])=>({...e,...t}),at(XC,JC)),QC=w.memo(function(){const e=dt("gridState"),t=dt("listClassName"),n=dt("itemClassName"),r=dt("itemContent"),o=dt("computeItemKey"),s=dt("isSeeking"),i=tn("scrollHeight"),a=dt("ItemComponent"),l=dt("ListComponent"),c=dt("ScrollSeekPlaceholder"),d=dt("context"),f=tn("itemDimensions"),m=tn("gap"),p=dt("log"),v=dt("stateRestoreInProgress"),g=tn("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:Kp("column-gap",getComputedStyle(y).columnGap,p),row:Kp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return _p(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Pt(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,{...Pt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Pt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),eT=w.memo(function(){const e=dt("HeaderComponent"),t=tn("headerHeight"),n=dt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=dt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),tT=w.memo(function(){const e=dt("FooterComponent"),t=tn("footerHeight"),n=dt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=dt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),nT=({children:e})=>{const t=w.useContext(Pp),n=tn("itemDimensions"),r=tn("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})},rT=({children:e})=>{const t=w.useContext(Pp),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=dt("customScrollParent"),s=np(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})},oT=w.memo(function({...e}){const t=dt("useWindowScroll"),n=dt("customScrollParent"),r=n||t?iT:sT,o=n||t?rT:nT,s=dt("context");return u.jsx(r,{...e,...Pt(r,s),children:u.jsxs(o,{children:[u.jsx(eT,{}),u.jsx(QC,{}),u.jsx(tT,{})]})})}),{useEmitter:Vp,useEmitterValue:dt,usePublisher:tn}=Ap(ZC,{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"}},oT),sT=Lp({useEmitter:Vp,useEmitterValue:dt,usePublisher:tn}),iT=$p({useEmitter:Vp,useEmitterValue:dt,usePublisher:tn});function Kp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Bs="Dialog",[qp,FN]=an(Bs),[aT,fn]=qp(Bs),Gp=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(aT,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Gp.displayName=Bs;var Yp="DialogTrigger",Xp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Yp,n),s=Me(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":nl(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Xp.displayName=Yp;var el="DialogPortal",[lT,Jp]=qp(el,{forceMount:void 0}),Zp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(el,t);return u.jsx(lT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Bt,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:i})}))})};Zp.displayName=el;var zs="DialogOverlay",Qp=h.forwardRef((e,t)=>{const n=Jp(zs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(zs,e.__scopeDialog);return s.modal?u.jsx(Bt,{present:r||s.open,children:u.jsx(uT,{...o,ref:t})}):null});Qp.displayName=zs;var cT=Vt.createSlot("DialogOverlay.RemoveScroll"),uT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(zs,n);return u.jsx(ws,{as:cT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":nl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",eh=h.forwardRef((e,t)=>{const n=Jp(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(ir,e.__scopeDialog);return u.jsx(Bt,{present:r||s.open,children:s.modal?u.jsx(dT,{...o,ref:t}):u.jsx(fT,{...o,ref:t})})});eh.displayName=ir;var dT=h.forwardRef((e,t)=>{const n=fn(ir,e.__scopeDialog),r=h.useRef(null),o=Me(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return xa(s)},[]),u.jsx(th,{...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())})}),fT=h.forwardRef((e,t)=>{const n=fn(ir,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(th,{...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()}})}),th=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(ir,n),l=h.useRef(null),c=Me(t,l);return Gi(),u.jsxs(u.Fragment,{children:[u.jsx(es,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Tr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":nl(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(pT,{titleId:a.titleId}),u.jsx(mT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),tl="DialogTitle",nh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(tl,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});nh.displayName=tl;var rh="DialogDescription",oh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(rh,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});oh.displayName=rh;var sh="DialogClose",ih=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(sh,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});ih.displayName=sh;function nl(e){return e?"open":"closed"}var ah="DialogTitleWarning",[BN,lh]=Aw(ah,{contentName:ir,titleName:tl,docsSlug:"dialog"}),pT=({titleId:e})=>{const t=lh(ah),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},g0=0,Rr=[];function x0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(g0++)[0],s=h.useState(Wd)[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(Jd),!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 j=qd(E,T);if(!j)return!0;if(j?S=E:(S=E==="v"?"h":"v",j=qd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var R=r.current||S;return p0(R,x,g,R==="h"?C:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!Rr.length||Rr[Rr.length-1]!==s)){var y="deltaY"in x?Xd(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(Jd).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,Xd(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 Rr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,_r),document.addEventListener("touchmove",l,_r),document.addEventListener("touchstart",d,_r),function(){Rr=Rr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,_r),document.removeEventListener("touchmove",l,_r),document.removeEventListener("touchstart",d,_r)}},[]);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(Ud,x0);var ws=h.forwardRef(function(e,t){return h.createElement(gs,Sn({},e,{ref:t,sideCar:w0}))});ws.classNames=gs.classNames;var Sa=["Enter"," "],b0=["ArrowDown","PageUp","Home"],Zd=["ArrowUp","PageDown","End"],y0=[...b0,...Zd],S0={ltr:[...Sa,"ArrowRight"],rtl:[...Sa,"ArrowLeft"]},C0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},uo="Menu",[fo,T0,k0]=Zo(uo),[er,Qd]=an(uo,[k0,Ar,Md]),bs=Ar(),ef=Md(),[E0,tr]=er(uo),[I0,po]=er(uo),tf=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=gt(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(ua,{...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})})})};tf.displayName=uo;var N0="MenuAnchor",Ca=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(da,{...o,...r,ref:t})});Ca.displayName=N0;var Ta="MenuPortal",[A0,nf]=er(Ta,{forceMount:void 0}),rf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Ta,t);return u.jsx(A0,{scope:t,forceMount:n,children:u.jsx(Bt,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:r})})})};rf.displayName=Ta;var Qt="MenuContent",[j0,ka]=er(Qt),of=h.forwardRef((e,t)=>{const n=nf(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=po(Qt,e.__scopeMenu);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{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(Qt,e.__scopeMenu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return xa(s)},[]),u.jsx(Ea,{...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(Qt,e.__scopeMenu);return u.jsx(Ea,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),R0=Vt.createSlot("MenuContent.ScrollLock"),Ea=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(Qt,n),y=po(Qt,n),b=bs(n),C=ef(n),k=T0(n),[S,T]=h.useState(null),E=h.useRef(null),j=Me(t,E,x.onContentChange),R=h.useRef(0),D=h.useRef(""),$=h.useRef(0),U=h.useRef(null),X=h.useRef("right"),M=h.useRef(0),K=v?ws:h.Fragment,q=v?{as:R0,allowPinchZoom:!0}:void 0,z=I=>{var L,_;const Y=D.current+I,J=k().filter(G=>!G.disabled),P=document.activeElement,B=(L=J.find(G=>G.ref.current===P))==null?void 0:L.textValue,A=J.map(G=>G.textValue),F=V0(A,Y,B),W=(_=J.find(G=>G.textValue===F))==null?void 0:_.ref.current;(function G(Z){D.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>G(""),1e3))})(Y),W&&setTimeout(()=>W.focus())};h.useEffect(()=>()=>window.clearTimeout(R.current),[]),Gi();const O=h.useCallback(I=>{var J,P;return X.current===((J=U.current)==null?void 0:J.side)&&q0(I,(P=U.current)==null?void 0:P.area)},[]);return u.jsx(j0,{scope:n,searchRef:D,onItemEnter:h.useCallback(I=>{O(I)&&I.preventDefault()},[O]),onItemLeave:h.useCallback(I=>{var Y;O(I)||((Y=E.current)==null||Y.focus(),T(null))},[O]),onTriggerLeave:h.useCallback(I=>{O(I)&&I.preventDefault()},[O]),pointerGraceTimerRef:$,onPointerGraceIntentChange:h.useCallback(I=>{U.current=I},[]),children:u.jsx(K,{...q,children:u.jsx(es,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var Y;I.preventDefault(),(Y=E.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Tr,{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(fa,{role:"menu","aria-orientation":"vertical","data-state":Sf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,B=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!P&&B&&z(I.key));const A=E.current;if(I.target!==A||!y0.includes(I.key))return;I.preventDefault();const W=k().filter(L=>!L.disabled).map(L=>L.ref.current);Zd.includes(I.key)&&W.reverse(),U0(W)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(R.current),D.current="")}),onPointerMove:ae(e.onPointerMove,mo(I=>{const Y=I.target,J=M.current!==I.clientX;if(I.currentTarget.contains(Y)&&J){const P=I.clientX>M.current?"right":"left";X.current=P,M.current=I.clientX}}))})})})})})})});of.displayName=Qt;var M0="MenuGroup",Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});Ia.displayName=M0;var O0="MenuLabel",sf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});sf.displayName=O0;var ys="MenuItem",af="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=ka(ys,e.__scopeMenu),l=Me(t,s),c=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(af,{bubbles:!0,cancelable:!0});f.addEventListener(af,p=>r==null?void 0:r(p),{once:!0}),Vi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(lf,{...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===" "||Sa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ss.displayName=ys;var lf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ka(ys,n),a=ef(n),l=h.useRef(null),c=Me(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(me.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",cf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(hf,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ss,{role:"menuitemcheckbox","aria-checked":Cs(n)?"mixed":n,...o,ref:t,"data-state":Aa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(Cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cf.displayName=D0;var uf="MenuRadioGroup",[L0,$0]=er(uf,{value:void 0,onValueChange:()=>{}}),df=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=gt(r);return u.jsx(L0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ia,{...o,ref:t})})});df.displayName=uf;var ff="MenuRadioItem",pf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=$0(ff,e.__scopeMenu),s=n===o.value;return u.jsx(hf,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ss,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Aa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});pf.displayName=ff;var Na="MenuItemIndicator",[hf,F0]=er(Na,{checked:!1}),mf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=F0(Na,n);return u.jsx(Bt,{present:r||Cs(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":Aa(s.checked)})})});mf.displayName=Na;var B0="MenuSeparator",gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});gf.displayName=B0;var z0="MenuArrow",xf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(pa,{...o,...r,ref:t})});xf.displayName=z0;var H0="MenuSub",[$N,vf]=er(H0),ho="MenuSubTrigger",wf=h.forwardRef((e,t)=>{const n=tr(ho,e.__scopeMenu),r=po(ho,e.__scopeMenu),o=vf(ho,e.__scopeMenu),s=ka(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(Ca,{asChild:!0,...c,children:u.jsx(lf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Sf(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())})})})});wf.displayName=ho;var bf="MenuSubContent",yf=h.forwardRef((e,t)=>{const n=nf(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=po(Qt,e.__scopeMenu),a=vf(bf,e.__scopeMenu),l=h.useRef(null),c=Me(t,l);return u.jsx(fo.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{present:r||s.open,children:u.jsx(fo.Slot,{scope:e.__scopeMenu,children:u.jsx(Ea,{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())})})})})})});yf.displayName=bf;function Sf(e){return e?"open":"closed"}function Cs(e){return e==="indeterminate"}function Aa(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=tf,Y0=Ca,X0=rf,J0=of,Z0=Ia,Q0=sf,eS=Ss,tS=cf,nS=df,rS=pf,oS=mf,sS=gf,iS=xf,aS=wf,lS=yf,Ts="DropdownMenu",[cS,FN]=an(Ts,[Qd]),Ot=Qd(),[uS,Cf]=cS(Ts),Tf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=h.useRef(null),[d,f]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Ts});return u.jsx(uS,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),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})})};Tf.displayName=Ts;var kf="DropdownMenuTrigger",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Cf(kf,n),i=Ot(n);return u.jsx(Y0,{asChild:!0,...i,children:u.jsx(me.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref: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())})})})});Ef.displayName=kf;var dS="DropdownMenuPortal",If=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(X0,{...r,...n})};If.displayName=dS;var Nf="DropdownMenuContent",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Cf(Nf,n),s=Ot(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)"}})});Af.displayName=Nf;var fS="DropdownMenuGroup",pS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Z0,{...o,...r,ref:t})});pS.displayName=fS;var hS="DropdownMenuLabel",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Q0,{...o,...r,ref:t})});jf.displayName=hS;var mS="DropdownMenuItem",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});Pf.displayName=mS;var gS="DropdownMenuCheckboxItem",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});_f.displayName=gS;var xS="DropdownMenuRadioGroup",vS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...o,...r,ref:t})});vS.displayName=xS;var wS="DropdownMenuRadioItem",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(rS,{...o,...r,ref:t})});Rf.displayName=wS;var bS="DropdownMenuItemIndicator",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(oS,{...o,...r,ref:t})});Mf.displayName=bS;var yS="DropdownMenuSeparator",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(sS,{...o,...r,ref:t})});Of.displayName=yS;var SS="DropdownMenuArrow",CS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(iS,{...o,...r,ref:t})});CS.displayName=SS;var TS="DropdownMenuSubTrigger",Df=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(aS,{...o,...r,ref:t})});Df.displayName=TS;var kS="DropdownMenuSubContent",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(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)"}})});Lf.displayName=kS;var ES=Tf,IS=Ef,NS=If,$f=Af,Ff=jf,Bf=Pf,zf=_f,Hf=Rf,Uf=Mf,Wf=Of,Vf=Df,Kf=Lf;const ks=ES,Es=IS,AS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Vf,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));AS.displayName=Vf.displayName;const jS=h.forwardRef(({className:e,...t},n)=>u.jsx(Kf,{ref:n,className:ne("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=Kf.displayName;const go=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(NS,{children:u.jsx($f,{ref:r,sideOffset:t,className:ne("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=$f.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Bf,{ref:r,className:ne("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=Bf.displayName;const PS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(zf,{ref:o,className:ne("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(Uf,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));PS.displayName=zf.displayName;const _S=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hf,{ref:r,className:ne("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(Uf,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));_S.displayName=Hf.displayName;const RS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Ff,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));RS.displayName=Ff.displayName;const MS=h.forwardRef(({className:e,...t},n)=>u.jsx(Wf,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));MS.displayName=Wf.displayName;const ja=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ne("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}));ja.displayName="Textarea";const OS=1e4;function qf({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),j=w.useRef(0),R=w.useRef(null),D=w.useRef("");w.useEffect(()=>{y||(C(e??""),R.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[$,U]=w.useState(null),X=w.useCallback(A=>A.length>s?`Message too long (${A.length}/${s} characters)`:null,[s]),M=w.useMemo(()=>g??X,[g,X]),K=w.useCallback(A=>{const F=M(A);return U(F),x==null||x(F),D.current=A,F},[M,x]),q=w.useCallback(()=>{const A=E.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);w.useEffect(()=>{q()},[q,k]),w.useEffect(()=>{if(!$)return;const A=(k??"").trim();D.current!==A&&K(A)},[k,$,K]);const z=w.useCallback((A,{fromUser:F})=>{y||C(A),F&&(a==null||a(A))},[y,a]),O=w.useCallback(async A=>{A&&A.preventDefault();const F=(k??"").trim();if(!F&&!p||K(F))return;const W=++j.current;R.current={id:W,shouldClear:!0},T(()=>{var L,_,G;try{const Z=l(F);Z&&typeof Z.then=="function"?Z.then(()=>{var oe,se;((oe=R.current)==null?void 0:oe.id)===W&&R.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((se=R.current)==null?void 0:se.id)===W&&(R.current=null)}).catch(()=>{var oe;((oe=R.current)==null?void 0:oe.id)===W&&(R.current=null)}):(((L=R.current)==null?void 0:L.id)===W&&R.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((_=R.current)==null?void 0:_.id)===W&&(R.current=null))}catch{((G=R.current)==null?void 0:G.id)===W&&(R.current=null)}})},[k,l,p,y,a,K]),I=w.useCallback(A=>{const F=A.target.value;z(F,{fromUser:!0}),R.current&&(R.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),$&&K(F.trim())},[z,K,$]),Y=w.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),O()):A.key==="Escape"&&t&&(A.preventDefault(),c==null||c())},[O,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:A=>void O(A),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ja,{ref:E,value:k,onChange:I,onKeyDown:Y,placeholder:t?"Edit your message...":n,className:B,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),u.jsx("div",{children:r?u.jsx(Xe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(Xe,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!p||S,children:u.jsx(ue.Send,{size:16})})})]})})}const DS=w.memo(qf);function Gf({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),[j,R]=w.useState(0),[D,$]=w.useState(!1),[U,X]=w.useState(null),[M,K]=w.useState(null),q=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(A=>A+1),R(A=>A+1)},[]),z=w.useCallback(A=>{C(F=>[...F,...A])},[]),O=w.useCallback(A=>{const F=Array.from(A.target.files||[]);z(F),A.target.value=""},[z]),I=w.useCallback(A=>{C(F=>{const W=F.filter((L,_)=>_!==A);return W.length===0&&q(),W})},[q]),Y=w.useCallback(async A=>{const F=(A.target.files||[])[0];if(F&&(X(null),K(null),!!v)){$(!0);try{await v(F),X(`Uploaded ${F.name} - processing through chat stream`)}catch(W){const L=W instanceof Error?W.message:"Failed to upload Excel file";K(L),g==null||g(L)}finally{$(!1),A.target.value="",q()}}},[v,g,q]),J=w.useMemo(()=>x||b.length>0,[x,b]),P=w.useCallback(async A=>{const W=await n(A,b);return b.length>0&&(C([]),q()),W},[n,q,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:O,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((A,F)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:A.name}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>I(F),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 ${A.name}`,children:u.jsx(ue.X,{size:12})})]},F))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Y,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),U&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:U}),M&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:M})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||p)&&u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Xe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:f.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(go,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var A;return(A=k.current)==null?void 0:A.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Fn,{onClick:()=>{var A;D||(A=S.current)==null||A.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(DS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:P,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:B,sendButtonClassName:f.sendButton})})]})]})}const LS=w.memo(Gf),Is=0,Bn=1,Mr=2,Yf=4;function Xf(e){return()=>e}function $S(e){e()}function Jf(e,t){return n=>e(t(n))}function Zf(e,t){return()=>e(t)}function FS(e,t){return n=>e(t,n)}function Pa(e){return e!==void 0}function BS(...e){return()=>{e.map($S)}}function Or(){}function Ns(e,t){return t(e),e}function zS(e,t){return t(e)}function at(...e){return e}function Je(e,t){return e(Bn,t)}function Pe(e,t){e(Is,t)}function _a(e){e(Mr)}function xt(e){return e(Yf)}function ge(e,t){return Je(e,FS(t,Is))}function un(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function Qf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function ep(e,t){return e===t}function lt(e=ep){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Te(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Jf(t,e)}function Cn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=HS(...t);return(r,o)=>{switch(r){case Mr:_a(e);return;case Bn:return Je(e,n(o))}}}function Tn(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 Oe(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function 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=Je(e,s),t):(r(),Or);case Mr: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 Yf:return t}return n(r,o)}}function jt(e,t){return Ns(re(t),n=>ge(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case Is:e.slice().forEach(r=>{r(n)});return;case Mr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return Ns(ze(),t=>ge(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 yt(...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);Je(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case Mr:{_a(t);return}case Bn:return r===o&&i(n),Je(t,i)}}}function Ce(e,t=ep){return Q(e,lt(t))}function Ra(...e){return function(t,n){switch(t){case Mr:return;case Bn:return BS(...e.map(r=>Je(r,n)))}}}var zt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(zt||{});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:xt(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 Ma(e,t,n).callbackRef}function Ma(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?tp("column-gap",getComputedStyle(d).columnGap,o):tp("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ma(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},zt.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 tp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}function np(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}=Ma(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 Dt=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 ge(Q(e,fe(({scrollTop:x})=>x)),t),ge(Q(e,fe(({scrollHeight:x})=>x)),i),ge(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 rp(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 nt(e){return e===xo}function vo(e,t){if(!nt(e))return t===e.k?e.v:t<e.k?vo(e.l,t):vo(e.r,t)}function dn(e,t,n="k"){if(nt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Jt(e,t,n){return nt(e)?ip(t,n,1):t===e.k?kt(e,{k:t,v:n}):t<e.k?ap(kt(e,{l:Jt(e.l,t,n)})):ap(kt(e,{r:Jt(e.r,t,n)}))}function Dr(){return xo}function As(e,t,n){if(nt(e))return[];const r=dn(e,t)[0];return XS(Da(e,r,n))}function Oa(e,t){if(nt(e))return xo;const{k:n,l:r,r:o}=e;if(t===n){if(nt(r))return o;if(nt(o))return r;{const[s,i]=sp(r);return js(kt(e,{k:s,l:op(r),v:i}))}}else return t<n?js(kt(e,{l:Oa(r,t)})):js(kt(e,{r:Oa(o,t)}))}function or(e){return nt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function Da(e,t,n){if(nt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Da(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Da(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(La(t))return lp(kt(e,{lvl:n-1}));if(!nt(t)&&!nt(t.r))return kt(t.r,{l:kt(t,{r:t.r.l}),lvl:n,r:kt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(La(e))return $a(kt(e,{lvl:n-1}));if(!nt(r)&&!nt(r.l)){const o=r.l,s=La(o)?r.lvl-1:r.lvl;return kt(o,{l:kt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:$a(kt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function kt(e,t){return ip(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 op(e){return nt(e.r)?e.l:js(kt(e,{r:op(e.r)}))}function La(e){return nt(e)||e.lvl>e.r.lvl}function sp(e){return nt(e.r)?[e.k,e.v]:sp(e.r)}function ip(e,t,n,r=xo,o=xo){return{k:e,l:r,lvl:n,r:o,v:t}}function ap(e){return $a(lp(e))}function lp(e){const{l:t}=e;return!nt(t)&&t.lvl===e.lvl?kt(t,{r:kt(e,{l:t.r})}):e}function $a(e){const{lvl:t,r:n}=e;return!nt(n)&&!nt(n.r)&&n.lvl===t&&n.r.lvl===t?kt(n,{l:kt(e,{r:n.l}),lvl:t+1}):e}function XS(e){return rp(e,({k:t,v:n})=>({index:t,value:n}))}function cp(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 Fa=Ge(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function up(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!nt(e.groupOffsetTree)}function Ba({index:e},t){return t===e?0:t<e?-1:1}function ZS(){return{groupIndices:[],groupOffsetTree:Dr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Dr()}}function QS(e,t){let n=nt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),nt(e)){e=Jt(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=Oa(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=Jt(e,o+1,m));c&&(e=Jt(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}=up(t,e,Ba),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function dp(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function fp(e,t,n){if(eC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=dp(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,up(e,r,Ba).offset)),rp(JS(e,t,n,tC),sC)}function rC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,zt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&nt(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>Jt(Jt(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}=za(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>Jt(m,p,bo(p,f,o)),Dr()),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 pp(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 za(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ps(o,t-1,Ba),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(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"},kn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=jt(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=jt(Q(n,Oe(l,e,p),Tn(rC,v),lt()),v),x=jt(Q(l,lt(),Tn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),fe(({prev:S})=>S)),[]);ge(Q(l,Te(S=>S.length>0),Oe(g,p),fe(([S,T,E])=>{const j=S.reduce((R,D,$)=>Jt(R,D,bo(D,T.offsetTree,E)||$),Dr());return{...T,groupIndices:S,groupOffsetTree:j}})),g),ge(Q(r,Oe(g),Te(([S,{lastIndex:T}])=>S<T),fe(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),ge(c,d);const y=jt(Q(c,fe(S=>S===void 0)),!0);ge(Q(d,Te(S=>S!==void 0&&nt(xt(g).sizeTree)),fe(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Xt(Q(n,Oe(g),Tn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),fe(S=>S.changed)));Je(Q(a,Tn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),fe(S=>S.diff)),S=>{const{groupIndices:T}=xt(g);if(S>0)Pe(t,!0),Pe(s,S+pp(S,T));else if(S<0){const E=xt(x);E.length>0&&(S-=pp(-S,E)),Pe(i,S)}}),Je(Q(a,Oe(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},zt.ERROR)});const C=Xt(s);ge(Q(s,Oe(g),fe(([S,T])=>{const E=T.groupIndices.length>0,j=[],R=T.lastSize;if(E){const D=vo(T.sizeTree,0);let $=0,U=0;for(;$<S;){const M=T.groupIndices[U],K=T.groupIndices.length===U+1?1/0:T.groupIndices[U+1]-M-1;j.push({endIndex:M,size:D,startIndex:M}),j.push({endIndex:M+1+K-1,size:R,startIndex:M+1}),U++,$+=K+1}const X=or(T.sizeTree);return $!==S&&X.shift(),X.reduce((M,{k:K,v:q})=>{let z=M.ranges;return M.prevSize!==0&&(z=[...M.ranges,{endIndex:K+S-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:K+S,prevSize:q,ranges:z}},{prevIndex:S,prevSize:0,ranges:j}).ranges}return or(T.sizeTree).reduce((D,{k:$,v:U})=>({prevIndex:$+S,prevSize:U,ranges:[...D.ranges,{endIndex:$+S-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=Xt(Q(i,Oe(g,p),fe(([S,{offsetTree:T},E])=>{const j=-S;return bo(j,T,E)})));return ge(Q(i,Oe(g,p),fe(([S,T,E])=>{if(T.groupIndices.length>0){if(nt(T.sizeTree))return T;let j=Dr();const R=xt(x);let D=0,$=0,U=0;for(;D<-S;){U=R[$];const X=R[$+1]-U-1;$++,D+=X+1}if(j=or(T.sizeTree).reduce((X,{k:M,v:K})=>Jt(X,Math.max(0,M+S),K),j),D!==-S){const X=vo(T.sizeTree,U);j=Jt(j,0,X);const M=dn(T.sizeTree,-S+1)[1];j=Jt(j,1,M)}return{...T,sizeTree:j,...za(T.offsetTree,0,j,E)}}else{const j=or(T.sizeTree).reduce((R,{k:D,v:$})=>Jt(R,Math.max(0,D+S),$),Dr());return{...T,sizeTree:j,...za(T.offsetTree,0,j,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}},at(zn,Fa),{singleton:!0});function lC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const hp=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=Xt(Q(s,fe(lC)));return ge(Q(a,fe(l=>l.totalCount)),n),ge(Q(a,fe(l=>l.groupIndices)),e),ge(Q(yt(o,t,r),Te(([l,c])=>_s(c)),fe(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),lt(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},at(kn,Dt)),Un=Ge(([{log:e}])=>{const t=re(!1),n=Xt(Q(t,Te(r=>r),lt()));return Je(t,r=>{r&&xt(e)("props updated",{},zt.DEBUG)}),{didMount:n,propsReady:t}},at(zn),{singleton:!0}),cC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function mp(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),Pe(l,!1)}return ge(Q(p,Oe(n,f,r,g,a,i,m),Oe(e,s,o),fe(([[k,S,T,E,j,R,D,$],U,X,M])=>{const K=mp(k),{align:q,behavior:z,offset:O}=K,I=E-1,Y=fp(K,S,I);let J=bo(Y,S.offsetTree,U)+R;q==="end"?(J+=X+dn(S.sizeTree,Y)[1]-T+M,Y===I&&(J+=D)):q==="center"?J+=(X+dn(S.sizeTree,Y)[1]-T+M)/2:J-=j,O&&(J+=O);const P=B=>{C(),B?($("retrying to scroll to",{location:k},zt.DEBUG),Pe(p,k)):(Pe(v,!0),$("list did not change, scroll successful",{},zt.DEBUG))};if(C(),z==="smooth"){let B=!1;b=Je(t,A=>{B=B||A}),x=un(d,()=>{P(B)})}else x=un(Q(t,uC(150)),P);return y=setTimeout(()=>{C()},1200),Pe(l,!0),$("scrolling from index to",{behavior:z,index:Y,top:J},zt.DEBUG),{behavior:z,top:J}})),c),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},at(kn,Dt,zn),{singleton:!0});function uC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ha(e,t){e==0?t():requestAnimationFrame(()=>{Ha(e-1,t)})}function Ua(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 ge(Q(i,Oe(l),Te(([d,f])=>!!f),Cn(!1)),a),ge(Q(i,Oe(l),Te(([d,f])=>!!f),Cn(!1)),c),Je(Q(yt(t,i),Oe(a,n,e,c),Te(([[,d],f,{sizeTree:m},p,v])=>d&&(!nt(m)||Pa(p))&&!f&&!v),Oe(l)),([,d])=>{un(o,()=>{Pe(c,!0)}),Ha(4,()=>{un(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},at(kn,Dt,yo,Un),{singleton:!0});function gp(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=jt(Q(Ra(Q(Ce(o),nr(1),Cn(!0)),Q(Ce(o),nr(1),Cn(!1),Qf(100))),lt()),!1),p=jt(Q(Ra(Q(n,Cn(!0)),Q(n,Cn(!1),Qf(200))),lt()),!1);ge(Q(yt(Ce(o),Ce(f)),fe(([b,C])=>b<=C),lt()),a),ge(Q(a,Pn(50)),c);const v=Xt(Q(yt(r,Ce(s),Ce(t),Ce(e),Ce(d)),Tn((b,[{scrollHeight:C,scrollTop:k},S,T,E,j])=>{const R=k+S-C>-j,D={scrollHeight:C,scrollTop:k,viewportHeight:S};if(R){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:D}}let $;return D.scrollHeight>b.state.scrollHeight?$="SIZE_INCREASED":S<b.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:D}},fC),lt((b,C)=>b&&b.atBottom===C.atBottom))),g=jt(Q(r,Tn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(gp(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}),Te(b=>b.changed),fe(b=>b.jump)),0);ge(Q(v,fe(b=>b.atBottom)),i),ge(Q(i,Pn(50)),l);const x=re(To);ge(Q(r,fe(({scrollTop:b})=>b),lt(),Tn((b,C)=>xt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?Co:To,prevScrollTop:C},{direction:To,prevScrollTop:0}),fe(b=>b.direction)),x),ge(Q(r,Pn(50),Cn(dC)),x);const y=re(0);return ge(Q(m,Te(b=>!b),Cn(0)),y),ge(Q(o,Pn(100),Oe(m),Te(([b,C])=>!!C),Tn(([b,C],[k])=>[C,k],[0,0]),fe(([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}},at(Dt)),Rs="top",Ms="bottom",xp="none";function vp(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 wp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Wa=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=re(0),a=re(0),l=re(0),c=jt(Q(yt(Ce(r),Ce(o),Ce(n),Ce(s,wo),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),fe(([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=xp;const j=wp(C,Rs),R=wp(C,Ms);return p-=b,p+=m+y,v+=m+y,v-=b,p>d+S-j&&(E=Co),v<d-T+f+R&&(E=To),E!==xp?[Math.max(k-m-vp(g,Rs,E)-j,0),k-T-y+f+vp(g,Ms,E)+R]:null}),Te(d=>d!=null),lt(wo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},at(Dt),{singleton:!0});function hC(e,t,n){if(_s(t)){const r=dp(e,t);return[{index:dn(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 Va={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:yp(e,o,s),offsetBottom:v,offsetTop:c,top:p,topItems:yp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function bp(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=Ua(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 yp(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();ge(s.topItemsIndexes,g);const b=jt(Q(yt(p,v,Ce(l,wo),Ce(o),Ce(r),Ce(c),d,Ce(g),Ce(t),Ce(n),e),Te(([T,E,,j,,,,,,,R])=>{const D=R&&R.length!==j;return T&&!E&&!D}),fe(([,,[T,E],j,R,D,$,U,X,M,K])=>{const q=R,{offsetTree:z,sizeTree:O}=q,I=xt(x);if(j===0)return{...Va,totalCount:j};if(T===0&&E===0)return I===0?{...Va,totalCount:j}:bp(I,D,R,X,M,K||[]);if(nt(O))return I>0?null:Os(hC(Ua(D,j),q,K),[],j,M,q,X);const Y=[];if(U.length>0){const F=U[0],W=U[U.length-1];let L=0;for(const _ of As(O,F,W)){const G=_.value,Z=Math.max(_.start,F),oe=Math.min(_.end,W);for(let se=Z;se<=oe;se++)Y.push({data:K==null?void 0:K[se],index:se,offset:L,size:G}),L+=G}}if(!$)return Os([],Y,j,M,q,X);const J=U.length>0?U[U.length-1]+1:0,P=nC(z,T,E,J);if(P.length===0)return null;const B=j-1,A=Ns([],F=>{for(const W of P){const L=W.value;let _=L.offset,G=W.start;const Z=L.size;if(L.offset<T){G+=Math.floor((T-L.offset+M)/(Z+M));const se=G-W.start;_+=se*Z+se*M}G<J&&(_+=(J-G)*Z,G=J);const oe=Math.min(W.end,B);for(let se=G;se<=oe&&!(_>=E);se++)F.push({data:K==null?void 0:K[se],index:se,offset:_,size:Z}),_+=Z+M}});return Os(A,Y,j,M,q,X)}),Te(T=>T!==null),lt()),Va);ge(Q(e,Te(Pa),fe(T=>T==null?void 0:T.length)),o),ge(Q(b,fe(T=>T.topListHeight)),f),ge(f,a),ge(Q(b,fe(T=>[T.top,T.bottom])),i),ge(Q(b,fe(T=>T.items)),y);const C=Xt(Q(b,Te(({items:T})=>T.length>0),Oe(o,e),Te(([{items:T},E])=>T[T.length-1].originalIndex===E-1),fe(([,T,E])=>[T-1,E]),lt(wo),fe(([T])=>T))),k=Xt(Q(b,Pn(200),Te(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),fe(({items:T})=>T[0].index),lt())),S=Xt(Q(b,Te(({items:T})=>T.length>0),fe(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),lt(cp)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},at(kn,hp,Wa,So,yo,ko,Un,Fa),{singleton:!0}),Sp=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=jt(Q(yt(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return ge(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},at(Dt,sr),{singleton:!0}),mC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=jt(Q(yt(n,e,t),Te(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Pn(0),lt()),0);return{alignToBottom:n,paddingTopAddition:r}},at(Dt,Sp),{singleton:!0}),Cp=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,Tp=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 ge(Q(d,Oe(t,l,n,s,o,r,a),Oe(e),fe(([[f,m,p,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=gC,done:E,...j}=f,R=fp(f,m,v-1),D=bo(R,m.offsetTree,C)+g+x,$=D+dn(m.sizeTree,R)[1],U=b+x,X=b+p-y,M=T({itemBottom:$,itemTop:D,locationParams:{align:k,behavior:S,...j},viewportBottom:X,viewportTop:U});return M?E&&un(Q(i,Te(K=>!K),nr(xt(i)?1:2)),E):E&&E(),M}),Te(f=>f!==null)),c),{scrollIntoView:d}},at(kn,Dt,yo,sr,zn),{singleton:!0});function kp(e){return e?e==="smooth"?"smooth":"auto":!1}const xC=(e,t)=>typeof e=="function"?kp(e(t)):t&&kp(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){Pe(i,{align:"end",behavior:S,index:"LAST"})}Je(Q(yt(Q(Ce(t),nr(1)),l),Oe(Ce(v),s,a,f),fe(([[S,T],E,j,R,D])=>{let $=T&&R,U="auto";return $&&(U=xC(E,j||D),$=$&&!!U),{followOutputBehavior:U,shouldFollow:$,totalCount:S}}),Te(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S)}):x=un(e,()=>{xt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S),x=null})});function b(S){const T=un(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(xt(d)("scrolling to bottom due to increased size",{},zt.DEBUG),y("auto"))});setTimeout(T,100)}Je(Q(yt(Ce(v),t,c),Te(([S,,T])=>S&&T),Tn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),Te(({refreshed:S})=>S),Oe(v,t)),([,S])=>{xt(a)&&b(S!==!1)}),Je(g,()=>{b(xt(v)!==!1)}),Je(yt(Ce(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=re(null),k=ze();return ge(Ra(Q(Ce(r),fe(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),Q(Ce(t))),k),Je(Q(yt(Q(k,nr(1)),l),Oe(Ce(C),a,f,m),fe(([[S,T],E,j,R,D])=>T&&j&&(E==null?void 0:E({context:D,totalCount:S,scrollingInProgress:R}))),Te(S=>!!S),Pn(0)),S=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Pe(p,S)}):x=un(e,()=>{xt(d)("scrolling into view",{}),Pe(p,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},at(kn,ko,yo,So,Un,zn,Dt,Cp,Tp)),wC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(Q(a,Oe(s),Te(([,l])=>l!==0),Oe(o,r,t,n,e),fe(([[,l],c,d,f,m,p=[]])=>bp(l,c,d,f,m,p))),i),{}),at(kn,So,sr,Un),{singleton:!0}),bC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return Je(Q(e,Oe(r),Te(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{un(Q(n,nr(1),Te(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},at(Un,Dt,sr),{singleton:!0}),Ep=Ge(([{scrollVelocity:e}])=>{const t=re(!1),n=ze(),r=re(!1);return ge(Q(e,Oe(r,t,n),Te(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),lt()),t),Je(Q(yt(t,e,n),Oe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},at(ko),{singleton:!0}),Ka=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=re(!1),i=re(void 0);return ge(Q(yt(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(Q(t,Oe(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},at(Dt)),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 ge(a,f),ge(l,m),Je(Q(c,Oe(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})}),ge(Q(d,Te(Pa),fe(SC)),o),ge(Q(s,Oe(d),Te(([,p])=>p!==void 0),lt(),fe(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},at(kn,Dt,So,Un,Ka));function SC(e){return{align:"start",index:0,offset:e.scrollTop}}const CC=Ge(([{topItemsIndexes:e}])=>{const t=re(0);return ge(Q(t,Te(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},at(sr));function Ip(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const TC=Ip(()=>/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=Xt(Q(l,Oe(i),Tn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},j])=>{const R=k+T;let D=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||(D=R-C,D!==0&&(D+=j))),[D,S,E,R]},[0,[],0,0]),Te(([y])=>y!==0),Oe(r,a,n,o,p,v),Te(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===Co),fe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},zt.DEBUG),y))));function x(y){y>0?(Pe(t,{behavior:"auto",top:-y}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-y}))}return Je(Q(g,Oe(e,s)),([y,b,C])=>{C&&TC()?Pe(e,b-y):x(-y)}),Je(Q(yt(jt(s,!1),e,v),Te(([y,b,C])=>!y&&!C&&b!==0),fe(([y,b])=>b),Pn(1)),x),ge(Q(f,fe(y=>({top:-y}))),t),Je(Q(c,Oe(m,d),fe(([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 j=vo(k,0);let R=0,D=0;for(;R<y;){R++,E+=j;let $=b.length===D+1?1/0:b[D+1]-b[D]-1;R+$>y&&(E-=j,$=y-R+1),R+=$,E+=T($),D++}return E}})),y=>{Pe(e,y),requestAnimationFrame(()=>{Pe(t,{top:y}),requestAnimationFrame(()=>{Pe(e,0),Pe(v,!1)})})}),{deviation:e}},at(Dt,ko,sr,kn,zn,Fa)),EC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),at(Wa,wC,Un,Ep,Sp,bC,mC,Ka,Tp,zn,Cp)),Np=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:j},R])=>(ge(k.rangeChanged,R.scrollSeekRangeChanged),ge(Q(R.windowViewportRect,fe(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,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,...R,...g,sizes:l,...x}),at(kn,So,Dt,yC,vC,sr,yo,kC,CC,hp,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 Ap(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&&Pe(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Pe(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Pe(C,y[b])}x.propsReady&&Pe(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Pe(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(Zf(d,k));Ds(()=>{for(const E of i)E in C&&Je(S[E],C[E]);return()=>{Object.values(S).map(_a)}},[C,S,k]),Ds(()=>{l(k,C)}),w.useImperativeHandle(y,Xf(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=>{Pe(y[x],b)},[y,x])},p=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Je(y,C),[y]);return w.useSyncExternalStore(b,()=>xt(y),()=>xt(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(Zf(xt,y));return Ds(()=>Je(y,k=>{k!==b&&C(Xf(k))}),[y,b]),b},g=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ds(()=>Je(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const jp=w.createContext(void 0),Pp=w.createContext(void 0),_p=typeof document<"u"?w.useLayoutEffect:w.useEffect;function qa(e){return"self"in e}function NC(e){return"body"in e}function Rp(e,t,n,r=Or,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)||qa(x)){const b=qa(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;qa(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)),gp(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 Ga="-webkit-sticky",Mp="sticky",Ya=Ip(()=>{if(typeof document>"u")return Mp;const e=document.createElement("div");return e.style.position=Ga,e.style.position===Ga?Ga:Mp});function Xa(e){return e}const AC=Ge(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(Xa),o=re("div"),s=re(Or),i=(a,l=null)=>jt(Q(n,fe(c=>c[a]),lt()),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}),at(Np,AC)),PC=({height:e})=>u.jsx("div",{style:{height:e}}),_C={overflowAnchor:"none",position:Ya(),zIndex:1},Op={overflowAnchor:"none"},RC={...Op,display:"inline-block",height:"100%"},Dp=w.memo(function({showTopList:e=!1}){const t=Ee("listState"),n=en("sizeRanges"),r=Ee("useWindowScroll"),o=Ee("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Ee("itemContent"),c=Ee("context"),d=Ee("groupContent"),f=Ee("trackItemSizes"),m=Ee("itemSize"),p=Ee("log"),v=en("gap"),g=Ee("horizontalDirection"),{callbackRef:x}=GS(n,m,f,e?Or:a,p,v,o,g,Ee("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Ja("deviation",M=>{y!==M&&b(M)});const C=Ee("EmptyPlaceholder"),k=Ee("ScrollSeekPlaceholder")||PC,S=Ee("ListComponent"),T=Ee("ItemComponent"),E=Ee("GroupComponent"),j=Ee("computeItemKey"),R=Ee("isSeeking"),D=Ee("groupIndices").length>0,$=Ee("alignToBottom"),U=Ee("initialItemFinalLocationReached"),X=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:$?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:$?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Pt(C,c)}):u.jsx(S,{...Pt(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:X,children:(e?t.topItems:t.items).map(M=>{const K=M.originalIndex,q=j(K+t.firstItemIndex,M.data,c);return R?w.createElement(k,{...Pt(k,c),height:M.size,index:M.index,key:q,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?w.createElement(E,{...Pt(E,c),"data-index":K,"data-item-index":M.index,"data-known-size":M.size,key:q,style:_C},d(M.index,c)):w.createElement(T,{...Pt(T,c),...LC(T,M.data),"data-index":K,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:q,style:g?RC:Op},D?l(M.index,M.groupIndex,M.data,c):l(M.index,M.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:Ya(),top:0,width:"100%",zIndex:1};function Pt(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=Ee("HeaderComponent"),t=en("headerHeight"),n=Ee("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),FC=w.memo(function(){const e=Ee("FooterComponent"),t=en("footerHeight"),n=Ee("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null});function Lp({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}=Rp(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,...Pt(l,s),children:r})})}function $p({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}=Rp(a,c,l,v,m);return _p(()=>{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,...Pt(l,s),children:r})})}const BC=({children:e})=>{const t=w.useContext(jp),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Ee("alignToBottom"),s=Ee("horizontalDirection"),i=w.useMemo(()=>Jf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ee("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(jp),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Ee("customScrollParent"),s=np(n,o,Ee("skipAnimationFrameInResizeObserver")),i=Ee("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=Ee("TopItemListComponent")||"div",n=Ee("headerHeight"),r={...DC,marginTop:`${n}px`},o=Ee("context");return u.jsx(t,{style:r,...Pt(t,o),children:e})},UC=w.memo(function(e){const t=Ee("useWindowScroll"),n=Ee("topItemsIndexes").length>0,r=Ee("customScrollParent"),o=Ee("context");return u.jsxs(r||t?KC:VC,{...e,context:o,children:[n&&u.jsx(HC,{children:u.jsx(Dp,{showTopList:!0})}),u.jsxs(r||t?zC:BC,{children:[u.jsx($C,{}),u.jsx(Dp,{}),u.jsx(FC,{})]})]})}),{Component:WC,useEmitter:Ja,useEmitterValue:Ee,usePublisher:en}=Ap(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=Lp({useEmitter:Ja,useEmitterValue:Ee,usePublisher:en}),KC=$p({useEmitter:Ja,useEmitterValue:Ee,usePublisher:en}),qC=WC;at(Np,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(Xa),a=re(Or),l=(c,d=null)=>jt(Q(s,fe(f=>f[c]),lt()),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")}})),Ya();const Fp={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:Bp,floor:$s,max:Eo,min:Za,round:zp}=Math;function Hp(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),j=re(Fp),R=re({height:0,width:0}),D=re({height:0,width:0}),$=ze(),U=ze(),X=re(0),M=re(null),K=re({column:0,row:0}),q=ze(),z=ze(),O=re(!1),I=re(0),Y=re(!0),J=re(!1),P=re(!1);Je(Q(v,Oe(I),Te(([_,G])=>!!G)),()=>{Pe(Y,!1)}),Je(Q(yt(v,Y,D,R,I,J),Te(([_,G,Z,oe,,se])=>_&&!G&&Z.height!==0&&oe.height!==0&&!se)),([,,,,_])=>{Pe(J,!0),Ha(1,()=>{Pe($,_)}),un(Q(c),()=>{Pe(t,[0,0]),Pe(Y,!0)})}),ge(Q(z,Te(_=>_!=null&&_.scrollTop>0),Cn(0)),E),Je(Q(v,Oe(z),Te(([,_])=>_!=null)),([,_])=>{_&&(Pe(R,_.viewport),Pe(D,_.item),Pe(K,_.gap),_.scrollTop>0&&(Pe(O,!0),un(Q(c,nr(1)),G=>{Pe(O,!1)}),Pe(l,{top:_.scrollTop})))}),ge(Q(R,fe(({height:_})=>_)),f),ge(Q(yt(Ce(R,Fs),Ce(D,Fs),Ce(K,(_,G)=>_&&_.column===G.column&&_.row===G.row),Ce(c)),fe(([_,G,Z,oe])=>({gap:Z,item:G,scrollTop:oe,viewport:_}))),q),ge(Q(yt(Ce(T),r,Ce(K,XC),Ce(D,Fs),Ce(R,Fs),Ce(M),Ce(E),Ce(O),Ce(Y),Ce(I)),Te(([,,,,,,,_])=>!_),fe(([_,[G,Z],oe,se,ie,le,ye,,De,He])=>{const{column:_e,row:$e}=oe,{height:ct,width:ft}=se,{width:St}=ie;if(ye===0&&(_===0||St===0))return Fp;if(ft===0){const st=Ua(He,_),vt=st+Math.max(ye-1,0);return YC(Hp(st,vt,le))}const Ke=Up(St,ft,_e);let Ye,Ue;De?G===0&&Z===0&&ye>0?(Ye=0,Ue=ye-1):(Ye=Ke*$s((G+$e)/(ct+$e)),Ue=Ke*Bp((Z+$e)/(ct+$e))-1,Ue=Za(_-1,Eo(Ue,Ke-1)),Ye=Za(Ue,Eo(0,Ye))):(Ye=0,Ue=-1);const Le=Hp(Ye,Ue,le),{bottom:je,top:pt}=Wp(ie,oe,se,Le),Rt=Bp(_/Ke),et=Rt*ct+(Rt-1)*$e-je;return{bottom:je,itemHeight:ct,items:Le,itemWidth:ft,offsetBottom:et,offsetTop:pt,top:pt}})),j),ge(Q(M,Te(_=>_!==null),fe(_=>_.length)),T),ge(Q(yt(R,D,j,K),Te(([_,G,{items:Z}])=>Z.length>0&&G.height!==0&&_.height!==0),fe(([_,G,{items:Z},oe])=>{const{bottom:se,top:ie}=Wp(_,oe,G,Z);return[ie,se]}),lt(wo)),t);const B=re(!1);ge(Q(c,Oe(B),fe(([_,G])=>G||_!==0)),B);const A=Xt(Q(yt(j,T),Te(([{items:_}])=>_.length>0),Oe(B),Te(([[_,G],Z])=>{const oe=_.items[_.items.length-1].index===G-1;return(Z||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===G)&&oe}),fe(([[,_]])=>_-1),lt())),F=Xt(Q(Ce(j),Te(({items:_})=>_.length>0&&_[0].index===0),Cn(0),lt())),W=Xt(Q(Ce(j),Oe(O),Te(([{items:_},G])=>_.length>0&&!G),fe(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),lt(cp),Pn(0)));ge(W,p.scrollSeekRangeChanged),ge(Q($,Oe(R,D,T,K),fe(([_,G,Z,oe,se])=>{const ie=mp(_),{align:le,behavior:ye,offset:De}=ie;let He=ie.index;He==="LAST"&&(He=oe-1),He=Eo(0,He,Za(oe-1,He));let _e=Qa(G,se,Z,He);return le==="end"?_e=zp(_e-G.height+Z.height):le==="center"&&(_e=zp(_e-G.height/2+Z.height/2)),De&&(_e+=De),{behavior:ye,top:_e}})),l);const L=jt(Q(j,fe(_=>_.offsetBottom+_.bottom)),0);return ge(Q(k,fe(_=>({height:_.visibleHeight,width:_.visibleWidth}))),R),{customScrollParent:x,data:M,deviation:X,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:l,scrollToIndex:$,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...p,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:L,...m,endReached:A,propsReady:g,rangeChanged:W,startReached:F,stateChanged:q,stateRestoreInProgress:O,...S}},at(Wa,Dt,ko,Ep,Un,Ka,zn));function Up(e,t,n){return Eo(1,$s((e+n)/($s(t)+n)))}function Wp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Qa(e,t,n,r[0].index);return{bottom:Qa(e,t,n,r[r.length-1].index)+o,top:s}}function Qa(e,t,n,r){const o=Up(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(Xa),i=re("div"),a=re(Or),l=(f,m=null)=>jt(Q(t,fe(p=>p[f]),lt()),m),c=re(!1),d=re(!1);return ge(Ce(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),QC=Ge(([e,t])=>({...e,...t}),at(JC,ZC)),eT=w.memo(function(){const e=dt("gridState"),t=dt("listClassName"),n=dt("itemClassName"),r=dt("itemContent"),o=dt("computeItemKey"),s=dt("isSeeking"),i=tn("scrollHeight"),a=dt("ItemComponent"),l=dt("ListComponent"),c=dt("ScrollSeekPlaceholder"),d=dt("context"),f=tn("itemDimensions"),m=tn("gap"),p=dt("log"),v=dt("stateRestoreInProgress"),g=tn("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:Kp("column-gap",getComputedStyle(y).columnGap,p),row:Kp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return _p(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Pt(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,{...Pt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Pt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),tT=w.memo(function(){const e=dt("HeaderComponent"),t=tn("headerHeight"),n=dt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=dt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),nT=w.memo(function(){const e=dt("FooterComponent"),t=tn("footerHeight"),n=dt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=dt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),rT=({children:e})=>{const t=w.useContext(Pp),n=tn("itemDimensions"),r=tn("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(Pp),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=dt("customScrollParent"),s=np(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=dt("useWindowScroll"),n=dt("customScrollParent"),r=n||t?aT:iT,o=n||t?oT:rT,s=dt("context");return u.jsx(r,{...e,...Pt(r,s),children:u.jsxs(o,{children:[u.jsx(tT,{}),u.jsx(eT,{}),u.jsx(nT,{})]})})}),{useEmitter:Vp,useEmitterValue:dt,usePublisher:tn}=Ap(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=Lp({useEmitter:Vp,useEmitterValue:dt,usePublisher:tn}),aT=$p({useEmitter:Vp,useEmitterValue:dt,usePublisher:tn});function Kp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Bs="Dialog",[qp,zN]=an(Bs),[lT,fn]=qp(Bs),Gp=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:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Gp.displayName=Bs;var Yp="DialogTrigger",Xp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Yp,n),s=Me(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":nl(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Xp.displayName=Yp;var el="DialogPortal",[cT,Jp]=qp(el,{forceMount:void 0}),Zp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(el,t);return u.jsx(cT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Bt,{present:n||s.open,children:u.jsx(lo,{asChild:!0,container:o,children:i})}))})};Zp.displayName=el;var zs="DialogOverlay",Qp=h.forwardRef((e,t)=>{const n=Jp(zs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(zs,e.__scopeDialog);return s.modal?u.jsx(Bt,{present:r||s.open,children:u.jsx(dT,{...o,ref:t})}):null});Qp.displayName=zs;var uT=Vt.createSlot("DialogOverlay.RemoveScroll"),dT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(zs,n);return u.jsx(ws,{as:uT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":nl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",eh=h.forwardRef((e,t)=>{const n=Jp(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(ir,e.__scopeDialog);return u.jsx(Bt,{present:r||s.open,children:s.modal?u.jsx(fT,{...o,ref:t}):u.jsx(pT,{...o,ref:t})})});eh.displayName=ir;var fT=h.forwardRef((e,t)=>{const n=fn(ir,e.__scopeDialog),r=h.useRef(null),o=Me(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return xa(s)},[]),u.jsx(th,{...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=fn(ir,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(th,{...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()}})}),th=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(ir,n),l=h.useRef(null),c=Me(t,l);return Gi(),u.jsxs(u.Fragment,{children:[u.jsx(es,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Tr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":nl(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})]})]})}),tl="DialogTitle",nh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(tl,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});nh.displayName=tl;var rh="DialogDescription",oh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(rh,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});oh.displayName=rh;var sh="DialogClose",ih=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(sh,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});ih.displayName=sh;function nl(e){return e?"open":"closed"}var ah="DialogTitleWarning",[HN,lh]=jw(ah,{contentName:ir,titleName:tl,docsSlug:"dialog"}),hT=({titleId:e})=>{const t=lh(ah),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},hT="DialogDescriptionWarning",mT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lh(hT).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},rl=Gp,gT=Xp,ol=Zp,Io=Qp,No=eh,ar=nh,Hs=oh,ch=ih;const sl=rl,xT=ol,uh=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{ref:n,className:ne("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}));uh.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(xT,{children:[u.jsx(uh,{}),u.jsxs(No,{ref:r,className:ne("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(ch,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Us.displayName=No.displayName;const Ws=({className:e,...t})=>u.jsx("div",{className:ne("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:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Vs.displayName=ar.displayName;const vT=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));vT.displayName=Hs.displayName;const wT=1,bT=1e6;let il=0;function yT(){return il=(il+1)%Number.MAX_SAFE_INTEGER,il.toString()}const al=new Map,dh=e=>{if(al.has(e))return;const t=setTimeout(()=>{al.delete(e),Ao({type:"REMOVE_TOAST",toastId:e})},bT);al.set(e,t)},ST=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,wT)};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?dh(n):e.toasts.forEach(r=>{dh(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=ST(qs,e),Ks.forEach(t=>{t(qs)})}function CT({...e}){const t=yT(),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 ll(){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:CT,dismiss:n=>Ao({type:"DISMISS_TOAST",toastId:n})}}function fh({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}=ll(),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(ue.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(Xe,{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(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):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(ue.Image,{className:"h-5 w-5"}):u.jsx(ue.FileText,{className:"h-5 w-5"});return u.jsx(sl,{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(Xe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Xe,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[u.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function ph(){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=ph();function TT(e){lr=e}const hh=/[&<>"']/,kT=new RegExp(hh.source,"g"),mh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ET=new RegExp(mh.source,"g"),IT={"&":"&","<":"<",">":">",'"':""","'":"'"},gh=e=>IT[e];function _t(e,t){if(t){if(hh.test(e))return e.replace(kT,gh)}else if(mh.test(e))return e.replace(ET,gh);return e}const NT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function xh(e){return e.replace(NT,(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 AT=/(^|[^\[])\^/g;function rt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(AT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const jT=/[^\w:]/g,PT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function vh(e,t,n){if(e){let r;try{r=decodeURIComponent(xh(n)).replace(jT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!PT.test(n)&&(n=OT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Gs={},_T=/^[^:]+:\/*[^/]*$/,RT=/^([^:]+:)[\s\S]*$/,MT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function OT(e,t){Gs[" "+e]||(_T.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(RT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(MT,"$1")+t:e+t}const Ys={exec:function(){}};function wh(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 DT(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 LT(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 bh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function yh(e,t,n,r){const o=t.href,s=t.title?_t(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:_t(i)}}function $T(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 {${lh(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},rl=Gp,xT=Xp,ol=Zp,Io=Qp,No=eh,ar=nh,Hs=oh,ch=ih;const sl=rl,vT=ol,uh=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{ref:n,className:ne("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}));uh.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(uh,{}),u.jsxs(No,{ref:r,className:ne("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(ch,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Us.displayName=No.displayName;const Ws=({className:e,...t})=>u.jsx("div",{className:ne("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:ne("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:ne("text-sm text-muted-foreground",e),...t}));wT.displayName=Hs.displayName;const bT=1,yT=1e6;let il=0;function ST(){return il=(il+1)%Number.MAX_SAFE_INTEGER,il.toString()}const al=new Map,dh=e=>{if(al.has(e))return;const t=setTimeout(()=>{al.delete(e),Ao({type:"REMOVE_TOAST",toastId:e})},yT);al.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?dh(n):e.toasts.forEach(r=>{dh(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 ll(){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 fh({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}=ll(),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(ue.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(Xe,{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(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):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(ue.Image,{className:"h-5 w-5"}):u.jsx(ue.FileText,{className:"h-5 w-5"});return u.jsx(sl,{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(Xe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Xe,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[u.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function ph(){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=ph();function kT(e){lr=e}const hh=/[&<>"']/,ET=new RegExp(hh.source,"g"),mh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,IT=new RegExp(mh.source,"g"),NT={"&":"&","<":"<",">":">",'"':""","'":"'"},gh=e=>NT[e];function _t(e,t){if(t){if(hh.test(e))return e.replace(ET,gh)}else if(mh.test(e))return e.replace(IT,gh);return e}const AT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function xh(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 rt(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 vh(e,t,n){if(e){let r;try{r=decodeURIComponent(xh(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 wh(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 bh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function yh(e,t,n,r){const o=t.href,s=t.title?_t(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:_t(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 cl{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
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o
|
|
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(`
|
|
87
87
|
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
|
|
88
88
|
`,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
89
89
|
`,t=t.substring(f.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),S=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
@@ -92,8 +92,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
92
92
|
`+f}!l&&!f.trim()&&(l=!0),r+=m+`
|
|
93
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]):_t(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:wh(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]=wh(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:_t(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]):_t(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=
|
|
96
|
-
]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={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])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=rt(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=rt(be._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=rt(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=rt(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=rt(pe.emStrong.rDelimUnd,"g").replace(/punct/g,pe._punctuation).getRegex(),pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,pe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,pe.autolink=rt(pe.autolink).replace("scheme",pe._scheme).replace("email",pe._email).getRegex(),pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,pe.tag=rt(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=rt(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=rt(pe.reflink).replace("label",pe._label).replace("ref",be._label).getRegex(),pe.nolink=rt(pe.nolink).replace("ref",be._label).getRegex(),pe.reflinkSearch=rt(pe.reflinkSearch,"g").replace("reflink",pe.reflink).replace("nolink",pe.nolink).getRegex(),pe.normal={...pe},pe.pedantic={...pe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:rt(pe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},pe.gfm.url=rt(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:rt(pe.br).replace("{2,}","*").getRegex(),text:rt(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function
|
|
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:_t(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]):_t(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)),yh(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 yh(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=_t(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=_t(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=_t(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=_t(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=_t(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]):_t(r[0]):r[0]:o=_t(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const be={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]+/};be._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,be._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,be.def=rt(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=rt(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=rt(be.list).replace(/bull/g,be.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+be.def.source+")").getRegex(),be._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",be._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,be.html=rt(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=rt(be._paragraph).replace("hr",be.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",be._tag).getRegex(),be.blockquote=rt(be.blockquote).replace("paragraph",be.paragraph).getRegex(),be.normal={...be},be.gfm={...be.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},be.gfm.table=rt(be.gfm.table).replace("hr",be.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",be._tag).getRegex(),be.gfm.paragraph=rt(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",be.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",be._tag).getRegex(),be.pedantic={...be.normal,html:rt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",be._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:rt(be.normal._paragraph).replace("hr",be.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={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])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=rt(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=rt(be._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=rt(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=rt(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=rt(pe.emStrong.rDelimUnd,"g").replace(/punct/g,pe._punctuation).getRegex(),pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,pe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,pe.autolink=rt(pe.autolink).replace("scheme",pe._scheme).replace("email",pe._email).getRegex(),pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,pe.tag=rt(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=rt(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=rt(pe.reflink).replace("label",pe._label).replace("ref",be._label).getRegex(),pe.nolink=rt(pe.nolink).replace("ref",be._label).getRegex(),pe.reflinkSearch=rt(pe.reflinkSearch,"g").replace("reflink",pe.reflink).replace("nolink",pe.nolink).getRegex(),pe.normal={...pe},pe.pedantic={...pe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:rt(pe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},pe.gfm.url=rt(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:rt(pe.br).replace("{2,}","*").getRegex(),text:rt(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function 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 Sh(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 cl,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:be.normal,inline:pe.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=pe.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=pe.breaks:n.inline=pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,inline:pe}}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+=`
|
|
@@ -103,7 +103,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
103
103
|
`+r.raw,o.text+=`
|
|
104
104
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+bh("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)+"["+bh("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,Sh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Sh))){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,
|
|
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)+"["+bh("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)+"["+bh("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,Sh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Sh))){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 ul{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
107
|
`,o?'<pre><code class="'+this.options.langPrefix+_t(o)+'">'+(r?t:_t(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:_t(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
@@ -124,8 +124,8 @@ ${t}</blockquote>
|
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
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=vh(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=vh(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 Ch{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 Th{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 ul,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ch,this.slugger=new Th}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,xh(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
|
-
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Js{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+_t(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 kh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=BT(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(LT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const c=function(f){let m;if(!f)try{r.walkTokens&&we.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(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;we.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(we.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return kh(Wn.lex,Vn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},TT(we.defaults),we},we.getDefaults=ph,we.defaults=lr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=we.defaults.renderer||new ul;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=we.defaults.tokenizer||new cl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=we.defaults.hooks||new Js;for(const s in n.hooks){const i=o[s];Js.passThroughHooks.has(s)?o[s]=a=>{if(we.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=we.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=kh(Wn.lexInline,Vn.parseInline),we.Parser=Vn,we.parser=Vn.parse,we.Renderer=ul,we.TextRenderer=Ch,we.Lexer=Wn,we.lexer=Wn.lex,we.Tokenizer=cl,we.Slugger=Th,we.Hooks=Js,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.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 we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=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:ne("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 Eh({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 Ih({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>uw(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Eh,{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 zT="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:zT,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:br(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:br(e)})}function Nh({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(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const dl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));dl.displayName="Card";const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));fl.displayName="CardHeader";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));pl.displayName="CardTitle";const hl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));hl.displayName="CardDescription";const Qs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));Qs.displayName="CardContent";const Ah=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Ah.displayName="CardFooter";const HT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function jh({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=HT(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=br(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(dl,{className:ne("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(fl,{className:"pb-3",children:[u.jsx(pl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(hl,{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(Xe,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(Qs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(Ah,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Xe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Xe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function 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:ne("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:ne("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:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Xe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Rh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ll(),[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:ow(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:sw(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Oh="data:";function UT(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 WT(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 VT(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 KT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>UT(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=
|
|
130
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[L]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[G,g[L]?" (processing)":""]})]},L)}if(W.type==="interrupt"){const _=W,G=Bi((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id)),Z=!!(D&&G&&G===D),oe=Z?$??(_==null?void 0:_.value):_==null?void 0:_.value,se=G?{..._,id:G,interrupt_id:G}:_;return u.jsx(jh,{interruptPart:se,onApprove:x,onReject:y,onSelectAlternative:b,disabled:C,isActive:Z,payload:oe},L)}return null},[D,$,C,v,x,y,b,R,E,k,S,g,T,m,j]),F=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return K();if(!t&&!F&&!d)return null;if(t)return n?u.jsx(Dh,{message:e,viewMode:r,isStreaming:o,toolRenderers:X,toolArtifactRenderers:M},e.id):null;if(!p){const W=u.jsx("div",{className:"space-y-2",children:B.map((L,_)=>m&&JT(L)?J?u.jsx("div",{className:"space-y-2",children:J},`streaming-md-${_}`):null:u.jsx(A,{part:L,i:_},_))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[W,u.jsx(Ph,{className:U})]}):W}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 XT(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 JT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const ZT=Wr.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:ne(ZT({variant:t}),e),...n})}function QT({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:f,toolViewMode:m,toolMeta:p,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:b,attemptCount:C,attemptIndex:k,handleOlderAttemptSelect:S,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:ne("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs($h,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),v())},children:[u.jsx("span",{children:p.name??"Tool Output"}),p.toolCallId&&u.jsx("span",{className:"opacity-70",children:p.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[b&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=C-1||S()},"aria-label":"Older attempt (back in time)",disabled:k>=C-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-k," / ",C]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:ne("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Xe,{variant:"ghost",size:"sm",onClick:g,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:ne(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),f==="user"&&x&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:ne(r,l?"h-3 w-3":"h-4 w-4")})}),f==="assistant"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:ne(r,l?"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,activeInterrupt:S,disableInterruptActions:T=!1,onInterruptActionStart:E,onInterruptActionEnd:j,attemptCount:R=1,attemptIndex:D=0,onSelectCheckpoint:$,attemptMetas:U=[]}){const[X,M]=w.useState(!1),[K,q]=w.useState("preview"),[z,O]=w.useState(!1),{currentThreadId:I}=wr(),{respondToInterrupt:Y}=ro(),J=l==="phone"||l==="half-screen",P=t.role,B=P==="tool",A=w.useMemo(()=>t.role==="default_message"?t:null,[t]),F=!!A,W=!(r&&P!=="user"),{uploadingFiles:L,handleFileClick:_,fileViewerOpen:G,currentFileInfo:Z,closeFileViewer:oe}=Rh({allowFileOpen:W,currentThreadId:I}),se=w.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[P]),ie=Mh(t,A),{contentParts:le,imageParts:ye,fileParts:De,interruptParts:He,textContent:_e,toolMeta:$e,toolRaw:ct,isToolStreaming:ft}=ie,St=y??g!==0,Ke=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),Ye=Bi(Ke),Ue=S==null?void 0:S.value,Le=w.useCallback(async()=>{const ce=B?ct:_e;async function Ie(it){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(it);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Se=new Blob([it],{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 Ie(ce),M(!0),setTimeout(()=>M(!1),2e3),k==null||k(ce)}catch(it){console.error("Failed to copy:",it)}},[B,ct,_e,k]),je=w.useCallback(()=>{if(!b||!t.id)return;const ce=(B?ct:_e)??"",Ie="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,ce,Ie)},[b,B,ct,_e,t]),pt=w.useCallback(()=>{C==null||C(n)},[C,n]),Rt=w.useCallback(()=>{q(ce=>ce==="expanded"?"preview":"expanded")},[]),et=w.useCallback(()=>{const Ie=ne(J?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",se);switch(P){case"user":return u.jsx(ue.User,{className:Ie});case"assistant":return u.jsx(ue.Bot,{className:Ie});case"tool":return u.jsx(ue.Wrench,{className:Ie});default:return u.jsx(ue.Bot,{className:Ie})}},[J,se,P]),st=w.useCallback(()=>{const ce="group relative mb-4 flex w-full";switch(P){case"user":return ne(ce,"justify-end");case"assistant":case"tool":case"system":return ne(ce,"justify-start");default:return ce}},[P]),vt=w.useCallback(()=>{const ce=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",J&&"px-3 py-2 text-sm");if(F)return ne(ce,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(P){case"user":return ne(ce,"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 ne(ce,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(ce,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(ce,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(ce,"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")}},[J,F,P]),ut=w.useCallback(async(ce,Ie,it)=>{if(T)return;const Se=Bi((ce==null?void 0:ce.id)??(ce==null?void 0:ce.interrupt_id));if(!Se){console.warn("Interrupt part missing id",ce);return}try{E==null||E(),await Y(Se,Ie,it)}catch(Ne){console.error("Failed to respond to interrupt:",Ne)}finally{j==null||j()}},[T,j,E,Y]),wt=w.useCallback(async ce=>{await ut(ce,!0)},[ut]),rn=w.useCallback(async ce=>{await ut(ce,!1)},[ut]),It=w.useCallback(async(ce,Ie)=>{await ut(ce,!0,Ie)},[ut]),mn=u.jsx(YT,{message:t,isToolMessage:B,showToolMessages:f,toolViewMode:K,isToolStreaming:ft,contentParts:le,textContent:_e,imageParts:ye,fileParts:De,interruptParts:He,isStreamingMessage:r,defaultMessage:A,enableStreamingMarkdownBuffer:St,renderStreamingMarkdown:x,handleFileClick:_,uploadingFiles:L,handleInterruptApprove:wt,handleInterruptReject:rn,handleInterruptAlternative:It,disableInterruptActions:T,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:z,setIsUserExpanded:O,isCompactLayout:J,activeInterruptId:Ye,activeInterruptValue:Ue,iconForeground:se,toolRenderers:m,toolArtifactRenderers:p}),Zt=w.useMemo(()=>A?"Assistant":iw(t),[A,t]),qe=et(),We=P==="user"&&(R??1)>1&&typeof $=="function",Ct=(U==null?void 0:U.length)??0,ee=Ct>0&&D<Ct-1?U[D+1]:void 0,he=Ct>0&&D>0?U[D-1]:void 0,tt=w.useCallback(()=>{!ee||!$||$(ee.id,void 0,!!ee.isLatestAttempt)},[ee,$]),xe=w.useCallback(()=>{!he||!$||$(he.id,void 0,!!he.isLatestAttempt)},[he,$]);return B&&!f?null:F&&A?u.jsx("div",{className:ne(st(),v.container),children:u.jsxs("div",{className:ne(vt(),v.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:ne("h-4 w-4",se)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:A.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(st(),v.container),children:u.jsxs("div",{className:ne(vt(),v.content),children:[u.jsx(QT,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:se,agentName:Zt,messageIcon:qe,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:J,showActions:s,isEditing:o,messageRole:P,toolViewMode:K,toolMeta:$e,onToggleToolView:Rt,onCopy:Le,onEdit:je,onRegenerate:pt,showCheckpointControls:We,attemptCount:R,attemptIndex:D,handleOlderAttemptSelect:tt,handleNewerAttemptSelect:xe,messageCreatedAt:t.createdAt,copied:X}),u.jsx("div",{className:"relative",children:mn}),B&&K==="expanded"&&($e.toolCallId||$e.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",J&&"text-xs"),children:[$e.name&&u.jsxs("div",{children:["Function: ",$e.name]}),$e.toolCallId&&u.jsxs("div",{children:["Call ID: ",$e.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Le(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:ne(X?"text-success":"text-current",J?"h-3 w-3":"h-4 w-4")})}),P==="user"&&b&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:je,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:ne("text-current",J?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&C&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:pt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:ne("text-current",J?"h-3 w-3":"h-4 w-4")})})]})]})}),Z&&u.jsx(fh,{isOpen:G,onClose:oe,fileId:Z.id,fileName:Z.name,mimeType:Z.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&wu(e.message)===wu(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=bu(e.message),a=bu(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,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T=!0,toolRenderers:E,toolArtifactRenderers:j,checkpointIndex:R,activeCheckpointId:D,onSelectCheckpoint:$,createSyntheticThinkingMessage:U=!0,forceSyntheticThinking:X=!1,getMessageCustomStyles:M},K)=>{const q=w.useRef(null),z=w.useRef(null),O=w.useRef(!1),I=w.useRef(!1),Y=w.useMemo(()=>b?e.some(ie=>ie.role==="default_message"?!1:Array.isArray(ie==null?void 0:ie.content)&&ie.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===b.id)):!1,[b,e]),J=w.useMemo(()=>{if(!b||Y)return null;const ie=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let le;const ye=b.value;if(ye&&typeof ye=="object"&&!Array.isArray(ye)){const De=ye.title;typeof De=="string"&&De.trim()&&(le=De.trim())}return{id:`interrupt-${ie}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:ie,value:ye,title:le}]}},[b,Y]),P=w.useMemo(()=>J?[...e,J]:e,[e,J]),B=w.useMemo(()=>{const ie=n&&P.some(ye=>ye.id===n);return U&&(t||X)&&!ie&&P.length>0?[...P,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:P},[P,t,n,U,X]),A=w.useMemo(()=>T?B:B.filter(ie=>(ie==null?void 0:ie.role)!=="tool"),[B,T]),F=w.useCallback(ie=>{x&&x(!ie),y&&y(ie)},[x,y]),W=w.useMemo(()=>{if(a)return async()=>{if(!O.current){O.current=!0;try{await a()}finally{O.current=!1}}}},[a]),L=w.useMemo(()=>!v||g?!1:"auto",[v,g]),_=w.useMemo(()=>{if(typeof p!="string")return null;const ie=p.trim();return!ie||A&&A.length>0?null:{id:"default-message",role:"default_message",content:ie,createdAt:new Date().toISOString()}},[p,A]),G=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),Z=()=>{if(_){const ie=M==null?void 0: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:_,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:ie})})})}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!"})},oe=A.length,se=oe>0;return w.useEffect(()=>{var ie,le;if(oe===0){I.current=!1;return}if(!I.current)if(I.current=!0,q.current&&A.length>0){const ye=A.length-1;(le=(ie=q.current).scrollToIndex)==null||le.call(ie,{index:ye,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[oe,A.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var ie,le;if(q.current&&A.length>0){const ye=A.length-1;(le=(ie=q.current).scrollToIndex)==null||le.call(ie,{index:ye,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var ie,le;q.current&&A.length>0?(le=(ie=q.current).scrollToIndex)==null||le.call(ie,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[A]),u.jsx("div",{className:G,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:se?u.jsx(KC,{ref:ie=>{q.current=ie},scrollerRef:ie=>{z.current=ie instanceof HTMLDivElement?ie:null},data:A,followOutput:L,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{W&&W()},atBottomStateChange:F,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(ie,le)=>ml(le,ie),itemContent:(ie,le)=>u.jsx(gl,{message:le,index:ie,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:C,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T,toolRenderers:E,toolArtifactRenderers:j,checkpointIndex:R,activeCheckpointId:D,onSelectCheckpoint:$,getMessageCustomStyles:M})}):Z()})})});xl.displayName="MessageList";const Fh={value:""};function Lr({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}=wr(),{threadId:E,messages:j,isLoading:R,navigateToCheckpoint:D,returnToLatest:$,checkpoint:U,checkpoints:X,interrupt:M,metadata:K,checkpointIndex:q}=ro(),{isStreaming:z,error:O,connectionState:I,submit:Y,stop:J}=Ui(),P=E??T??null,B=(U==null?void 0:U.id)??null,A=(U==null?void 0:U.namespace)??null,F=(K==null?void 0:K.assemblingMessageId)??null,W=M,[L,_]=w.useState(!1),[G,Z]=w.useState(!1);w.useEffect(()=>{W||_(!1)},[W]);const oe=w.useCallback(()=>{_(!0)},[]),se=w.useCallback(()=>{_(!1)},[]),ie=!!W||L,[le,ye]=w.useState(null),[De,He]=w.useState(""),[_e,$e]=w.useState(null),[ct,ft]=w.useState(null),[St,Ke]=w.useState(!1),[Ye,Ue]=w.useState(null),Le=w.useRef(!1),[je,pt]=w.useState(()=>Fh.value),Rt=w.useRef(je),et=w.useRef(null),st=w.useCallback(Se=>{Fh.value=Se,pt(Se)},[]),[vt,ut]=w.useState(!1),wt=w.useRef(null),rn=w.useCallback(Se=>{st(Se)},[st]);w.useEffect(()=>{z||Z(!1)},[z]),w.useEffect(()=>{K!=null&&K.assemblingMessageId&&Z(!1)},[K==null?void 0:K.assemblingMessageId]);const[It,mn]=w.useState("desktop");w.useEffect(()=>{const Se=()=>{const Ne=window.innerWidth;mn(Ne<640?"phone":Ne<1024?"tablet":"desktop")};return Se(),window.addEventListener("resize",Se),()=>window.removeEventListener("resize",Se)},[]),w.useEffect(()=>{Le.current=!1},[P]),w.useEffect(()=>{Rt.current=je},[je]),w.useEffect(()=>{if(!le){et.current=null;return}et.current===null&&(et.current=Rt.current),st(De??"")},[De,le,st]),w.useEffect(()=>{if(C!==void 0){Ue(C);return}(async()=>{if(!S){Ue(null);return}try{const Fe=(await k.getAgent("default")).uiDefaultMessage||"";Ue(Fe||null)}catch(Ne){console.warn("Failed to fetch default message:",Ne),Ue(null)}})()},[k,S,C]),w.useEffect(()=>{O&&!St&&(b==null||b(O))},[O,St,b]);const Zt=async(Se,Ne)=>{const Fe=Se.trim();if(!(!Fe&&Ne.length===0))try{const ve=le?(_e==null?void 0:_e.checkpointId)??B??void 0:B??void 0,Qe=le?(_e==null?void 0:_e.checkpointNs)??A??void 0:A??void 0;await Y({text:Fe||"",attachments:Ne,payload:p},{checkpointId:ve,checkpointNs:Qe,edit:!!le,originalMessageId:le??void 0}),x==null||x(Fe),Z(!0),st(""),ft(null),ye(null),He(""),$e(null)}catch(ve){const Qe=(ve==null?void 0:ve.message)||"Failed to send message";ft(Qe),b==null||b(Qe),Z(!1)}},qe=w.useCallback(async Se=>{await Y({attachments:[Se],payload:p},{checkpointId:B??void 0,checkpointNs:A??void 0}),y==null||y({file:Se})},[B,A,p,y,Y]),We=w.useCallback((Se,Ne,Fe)=>{c&&(et.current=je,ye(Se),He(Ne),st(Ne),ft(null),$e({checkpointId:(Fe==null?void 0:Fe.checkpointId)??null,checkpointNs:(Fe==null?void 0:Fe.checkpointNs)??null}))},[je,c,st]),Ct=w.useCallback(()=>{ye(null),He(""),$e(null),ft(null),st(et.current??je),et.current=null},[je,st]),ee=w.useCallback((Se,Ne,Fe)=>{We(Se,Ne,Fe)},[We]),he=w.useCallback(Se=>{let Ne=null;for(let Re=Se-1;Re>=0;Re--)if(j[Re].role==="user"){Ne=j[Re];break}if(!Ne)return;const Fe=Array.isArray(Ne.content)?Ne.content:[],Qe=Fe.filter(Re=>(Re==null?void 0:Re.type)==="text").map(Re=>Re.text).join("")||(()=>{try{return JSON.stringify(Fe,null,2)}catch{return String(Fe)}})();Qe&&Y({text:Qe,payload:p},{checkpointId:B??void 0,checkpointNs:A??void 0,edit:!0,originalMessageId:Ne.id})},[j,Y,B,A,p]),tt=w.useCallback(async Se=>{if(T){ut(!0);try{if(!Se){await $(),requestAnimationFrame(()=>{var ve;(ve=wt.current)==null||ve.scrollToLatest()});return}const Ne=X.find(ve=>ve.checkpointId===Se),Fe=(Ne==null?void 0:Ne.checkpointNs)??null;await D(Se,Fe),requestAnimationFrame(()=>{var ve;(ve=wt.current)==null||ve.scrollToTop()})}finally{ut(!1)}}},[X,T,wt,D,$]),xe=w.useCallback(async(Se,Ne,Fe)=>{await tt(Fe?null:Se)},[tt]),ce=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,Ie=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${v.messagesArea||""}`,it=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:ce,children:[!!O&&!St&&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:O}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Ke(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ie}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(xl,{ref:wt,className:"h-full",style:{height:"100%"},messages:j,isStreaming:z,streamingAssistantId:F,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:It,enableMessageEditing:c,editingMessageId:le,onEdit:ee,onRegenerate:he,onCancelEdit:Ct,emptyMessage:Ye??void 0,isNavigatingCheckpoint:vt,activeInterrupt:W,disableInterruptActions:L,onInterruptActionStart:oe,onInterruptActionEnd:se,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:q,activeCheckpointId:B,onSelectCheckpoint:xe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:G,getMessageCustomStyles:g}),(I==="reconnecting"||I==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),I==="reconnecting"?"Reconnecting…":"Connecting…"]})}),I==="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"}),R&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),vt&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:it,children:[le&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:Ct,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),ct&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ct}),u.jsx(DS,{composerValue:je,onComposerChange:rn,onSend:Zt,onCancelEdit:Ct,onStop:J,editingMessageId:le,editingInitialValue:De,placeholder:le?"Edit your message...":t,isStreaming:z,disabled:ie,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:qe,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:ct})]})]})}var Bh=1,ek=.9,tk=.8,nk=.17,vl=.1,wl=.999,rk=.9999,ok=.99,sk=/[\\\/_+.#"@\[\(\{&]/,ik=/[\\\/_+.#"@\[\(\{&]/g,ak=/[\s-]/,zh=/[\s-]/g;function bl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Bh:ok;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:sk.test(e.charAt(c-1))?(f*=tk,p=e.slice(o,c-1).match(ik),p&&o>0&&(f*=Math.pow(wl,p.length))):ak.test(e.charAt(c-1))?(f*=ek,v=e.slice(o,c-1).match(zh),v&&o>0&&(f*=Math.pow(wl,v.length))):(f*=nk,o>0&&(f*=Math.pow(wl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=rk)),(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 lk(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=""]',ck='[cmdk-group-heading=""]',Uh='[cmdk-item=""]',Wh=`${Uh}:not([aria-disabled="true"])`,Sl="cmdk-item-select",$r="data-value",uk=(e,t,n)=>lk(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=Fr(()=>{var P,B;return{search:"",value:(B=(P=e.value)!=null?P:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Fr(()=>new Set),o=Fr(()=>new Map),s=Fr(()=>new Map),i=Fr(()=>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=At(),C=At(),k=At(),S=h.useRef(null),T=yk();ur(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),ur(()=>{T(6,X)},[]);let E=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,B,A)=>{var F,W,L,_;if(!Object.is(n.current[P],B)){if(n.current[P]=B,P==="search")U(),D(),T(1,$);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(k);G?G.focus():(F=document.getElementById(b))==null||F.focus()}if(T(7,()=>{var G;n.current.selectedItemId=(G=M())==null?void 0:G.id,E.emit()}),A||T(5,X),((W=a.current)==null?void 0:W.value)!==void 0){let G=B??"";(_=(L=a.current).onValueChange)==null||_.call(L,G);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=h.useMemo(()=>({value:(P,B,A)=>{var F;B!==((F=s.current.get(P))==null?void 0:F.value)&&(s.current.set(P,{value:B,keywords:A}),n.current.filtered.items.set(P,R(B,A)),T(2,()=>{D(),E.emit()}))},item:(P,B)=>(r.current.add(P),B&&(o.current.has(B)?o.current.get(B).add(P):o.current.set(B,new Set([P]))),T(3,()=>{U(),D(),n.current.value||$(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let A=M();T(4,()=>{U(),(A==null?void 0:A.getAttribute("id"))===P&&$(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function R(P,B){var A,F;let W=(F=(A=a.current)==null?void 0:A.filter)!=null?F:uk;return P?W(P,n.current.search,B):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(F=>{let W=o.current.get(F),L=0;W.forEach(_=>{let G=P.get(_);L=Math.max(G,L)}),B.push([F,L])});let A=S.current;K().sort((F,W)=>{var L,_;let G=F.getAttribute("id"),Z=W.getAttribute("id");return((L=P.get(Z))!=null?L:0)-((_=P.get(G))!=null?_:0)}).forEach(F=>{let W=F.closest(yl);W?W.appendChild(F.parentElement===W?F:F.closest(`${yl} > *`)):A.appendChild(F.parentElement===A?F:F.closest(`${yl} > *`))}),B.sort((F,W)=>W[1]-F[1]).forEach(F=>{var W;let L=(W=S.current)==null?void 0:W.querySelector(`${Po}[${$r}="${encodeURIComponent(F[0])}"]`);L==null||L.parentElement.appendChild(L)})}function $(){let P=K().find(A=>A.getAttribute("aria-disabled")!=="true"),B=P==null?void 0:P.getAttribute($r);E.setState("value",B||void 0)}function U(){var P,B,A,F;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let W=0;for(let L of r.current){let _=(B=(P=s.current.get(L))==null?void 0:P.value)!=null?B:"",G=(F=(A=s.current.get(L))==null?void 0:A.keywords)!=null?F:[],Z=R(_,G);n.current.filtered.items.set(L,Z),Z>0&&W++}for(let[L,_]of o.current)for(let G of _)if(n.current.filtered.items.get(G)>0){n.current.filtered.groups.add(L);break}n.current.filtered.count=W}function X(){var P,B,A;let F=M();F&&(((P=F.parentElement)==null?void 0:P.firstChild)===F&&((A=(B=F.closest(Po))==null?void 0:B.querySelector(ck))==null||A.scrollIntoView({block:"nearest"})),F.scrollIntoView({block:"nearest"}))}function M(){var P;return(P=S.current)==null?void 0:P.querySelector(`${Uh}[aria-selected="true"]`)}function K(){var P;return Array.from(((P=S.current)==null?void 0:P.querySelectorAll(Wh))||[])}function q(P){let B=K()[P];B&&E.setState("value",B.getAttribute($r))}function z(P){var B;let A=M(),F=K(),W=F.findIndex(_=>_===A),L=F[W+P];(B=a.current)!=null&&B.loop&&(L=W+P<0?F[F.length-1]:W+P===F.length?F[0]:F[W+P]),L&&E.setState("value",L.getAttribute($r))}function O(P){let B=M(),A=B==null?void 0:B.closest(Po),F;for(;A&&!F;)A=P>0?wk(A,Po):bk(A,Po),F=A==null?void 0:A.querySelector(Wh);F?E.setState("value",F.getAttribute($r)):z(P)}let I=()=>q(K().length-1),Y=P=>{P.preventDefault(),P.metaKey?I():P.altKey?O(1):z(1)},J=P=>{P.preventDefault(),P.metaKey?q(0):P.altKey?O(-1):z(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var B;(B=y.onKeyDown)==null||B.call(y,P);let A=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||A))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&Y(P);break}case"ArrowDown":{Y(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),q(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let F=M();if(F){let W=new Event(Sl);F.dispatchEvent(W)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:Ck},l),ti(e,P=>h.createElement(Kh.Provider,{value:E},h.createElement(Vh.Provider,{value:j},P))))}),dk=h.forwardRef((e,t)=>{var n,r;let o=At(),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(me.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)}),fk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=h.useRef(null),l=h.useRef(null),c=At(),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(me.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))))}),pk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(me.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),hk=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(me.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),mk=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(me.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)))}),gk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(rl,{open:n,onOpenChange:r},h.createElement(ol,{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}))))}),xk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),vk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ti(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Ht=Object.assign(Gh,{List:mk,Item:dk,Input:hk,Group:fk,Separator:pk,Dialog:gk,Empty:xk,Loading:vk});function wk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function bk(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 Fr(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($r,a),o.current=a}),o}var yk=()=>{let[e,t]=h.useState(),n=Fr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Sk(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(Sk(t),{ref:t.ref},n(t.props.children)):n(t)}var Ck={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(Ht,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tl.displayName=Ht.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(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ht.Input,{ref:n,className:ne("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=Ht.Input.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));El.displayName=Ht.List.displayName;const Il=h.forwardRef((e,t)=>u.jsx(Ht.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Il.displayName=Ht.Empty.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Group,{ref:n,className:ne("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=Ht.Group.displayName;const Tk=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));Tk.displayName=Ht.Separator.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Item,{ref:n,className:ne("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=Ht.Item.displayName;function jl(e,[t,n]){return Math.min(n,Math.max(t,e))}function kk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Pl="ScrollArea",[Jh,zN]=an(Pl),[Ek,nn]=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,j]=h.useState(!1),R=Me(t,$=>l($)),D=Qo(o);return u.jsx(Ek,{scope:n,type:r,dir:D,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:j,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(me.div,{dir:D,...i,ref:R,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=nn(Qh,n),a=h.useRef(null),l=Me(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(me.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});em.displayName=Qh;var En="ScrollAreaScrollbar",_l=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Ik,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Nk,{...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=En;var Ik=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Bt,{present:n||s,children:u.jsx(tm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Nk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>l("SCROLL_END"),100),[a,l]=kk("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(Bt,{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=nn(En,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 Br(n.viewport,l),Br(n.content,l),u.jsx(Bt,{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=nn(En,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=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 Mk(m,i.current,a,p)}return n==="horizontal"?u.jsx(Ak,{...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(jk,{...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}),Ak=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(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)}})}})}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(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)}})}})}),[Pk,nm]=Jh(En),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=nn(En,n),[v,g]=h.useState(null),x=Me(t,R=>g(R)),y=h.useRef(null),b=h.useRef(""),C=p.viewport,k=r.content-r.viewport,S=gt(d),T=gt(l),E=si(f,10);function j(R){if(y.current){const D=R.clientX-y.current.left,$=R.clientY-y.current.top;c({x:D,y:$})}}return h.useEffect(()=>{const R=D=>{const $=D.target;(v==null?void 0:v.contains($))&&S(D,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Br(v,E),Br(p.content,E),u.jsx(Pk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:gt(s),onThumbPointerUp:gt(i),onThumbPositionChange:T,onThumbPointerDown:gt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(R))}),onPointerMove:ae(e.onPointerMove,j),onPointerUp:ae(e.onPointerUp,R=>{const D=R.target;D.hasPointerCapture(R.pointerId)&&D.releasePointerCapture(R.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(Bt,{present:n||o.hasThumb,children:u.jsx(_k,{ref:t,...r})})}),_k=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=nn(ni,n),i=nm(ni,n),{onThumbPositionChange:a}=i,l=Me(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=Ok(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture: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=nn(Ml,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Rk,{...e,ref:t}):null});sm.displayName=Ml;var Rk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=nn(Ml,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Br(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Br(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function 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 Mk(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 Ok=(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=gt(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 Br(e,t){const n=gt(t);Et(()=>{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,Dk=em,Lk=sm;const Ol=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(um,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(Dk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(dm,{}),u.jsx(Lk,{})]}));Ol.displayName=um.displayName;const dm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(_l,{ref:r,orientation:t,className:ne("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:ne("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 $k="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Fk="bg-slate-700 border-slate-600 hover:bg-slate-600",Bk="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??Bk}`:`${x??Fk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${$k} ${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(Xe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children: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(ue.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(Xe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.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(ue.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(ue.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(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const pm=25,hm="thread-manager-view",zk=e=>e==="default"||e==="shared",Hk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hm);if(zk(e))return e}catch{}return null};function mm({defaultView:e}={}){const[t,n]=w.useState(()=>Hk()??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 Uk=[{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:j,isLoadingSharedThreads:R,actions:D,shareInFlight:$,shareStatus:U,clearShareStatus:X}=wr(),{createThread:M,deleteThread:K,renameThread:q,shareThread:z}=D,{loadThread:O}=ro(),I=i??T,[Y,J]=w.useState(Array.isArray(k)?k:[]),P=w.useRef(Y.length>0),B=w.useRef(null),A=w.useRef(0),[F,W]=w.useState(null),[L,_]=w.useState(""),[G,Z]=w.useState(!1),[oe,se]=w.useState(!1),[ie,le]=w.useState(null),[ye,De]=w.useState(""),He=v&&v.length>0?v:Uk,_e=mm({defaultView:m}),$e=g??_e,ct=f??$e.view,ft=w.useCallback(ee=>{f||$e.setView(ee),p==null||p(ee)},[f,p,$e]),St=He.find(ee=>ee.key===ct)??He[0],Ke=ee=>{le(ee),De(""),se(!0)},Ye=()=>{se(!1),le(null),De(""),X()},Ue=w.useCallback(async ee=>{if(!(!ie||$)&&ee.id)try{await z(ie,ee.id),setTimeout(()=>Ye(),600)}catch(he){console.error("Failed to share thread:",he)}},[Ye,$,ie,z]),Le=w.useMemo(()=>{const ee=y??[],he=ye.trim().toLowerCase();return he?C?ee.filter(tt=>C(tt,he)):ee.filter(tt=>`${tt.label} ${tt.secondaryLabel??""}`.toLowerCase().includes(he)):ee},[y,ye,C]),je=ct==="shared",pt=je?S:Y,Rt=je?R:j,et=je?"No shared conversations yet":"No conversations yet",st=ee=>{const he=ee.sharedAt?` • ${qe(ee.sharedAt)}`:"";return`Shared by ${ee.sharedByUserId}${he}`},vt=ee=>"sharedByUserId"in ee;w.useEffect(()=>{const ee=Array.isArray(k)?k:[];if(ee.length>0){P.current=!0,J(ee);return}j||(P.current=!1,J(ee))},[k,j]),w.useEffect(()=>{if(!B.current)return;const ee=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!ee)return;let he=null,tt=null;return he=requestAnimationFrame(()=>{tt=requestAnimationFrame(()=>{ee.scrollTop=A.current})}),()=>{he!==null&&cancelAnimationFrame(he),tt!==null&&cancelAnimationFrame(tt)}},[Y]);const ut=async ee=>{try{E(ee),await O(ee),a==null||a(ee),l==null||l(ee)}catch(he){console.error("Failed to select thread:",he)}},wt=async()=>{try{Z(!0);const ee=await M();ee&&(c==null||c(ee),a==null||a(ee))}catch(ee){console.error("Failed to create thread:",ee)}finally{Z(!1)}},rn=async(ee,he)=>{if(he.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const tt=B.current.querySelector("[data-radix-scroll-area-viewport]");tt&&(A.current=tt.scrollTop)}try{await K(ee),d==null||d(ee)}catch(tt){console.error("Failed to delete thread:",tt)}}},It=(ee,he)=>{he.stopPropagation(),W(ee.threadId),_(ee.title||`Thread ${ee.threadId.slice(0,8)}`)},mn=async ee=>{if(L.trim())try{await q(ee,L.trim()),W(null),_("")}catch(he){console.error("Failed to update title:",he)}},Zt=()=>{W(null),_("")},qe=ee=>{if(!ee)return"";try{const he=new Date(ee),xe=new Date().getTime()-he.getTime(),ce=Math.floor(xe/(1e3*60*60*24));return ce===0?he.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ce===1?"Yesterday":ce<7?`${ce} days ago`:he.toLocaleDateString()}catch{return""}},We=ee=>ee.title||`Thread ${ee.threadId.slice(0,8)}`,Ct=ee=>{const he=We(ee);return he.length<=pm?he:`${he.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(Xe,{onClick:wt,disabled:G||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:G?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Xe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:St.label})}),u.jsx(go,{align:"start",sideOffset:6,className:"w-40",children:He.map(ee=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:he=>{he.preventDefault(),ft(ee.key)},children:[u.jsx("span",{children:ee.label}),ct===ee.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},ee.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:Rt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):pt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:et})]}):pt.slice().sort((ee,he)=>new Date(he.updatedAt||he.createdAt||"").getTime()-new Date(ee.updatedAt||ee.createdAt||"").getTime()).map(ee=>u.jsx(fm,{thread:ee,isActive:I===ee.threadId,editingThreadId:F,editingTitle:L,onSelect:ut,onStartEditing:It,onEditingTitleChange:he=>_(he),onSaveEditing:mn,onCancelEditing:Zt,onShare:()=>Ke(ee.threadId),onDelete:rn,showEditTitle:r,showDeleteButton:n,formatDate:qe,getDisplayThreadTitle:Ct,secondaryLine:je&&vt(ee)?st(ee):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ee.threadId))})}),u.jsx(sl,{open:oe,onOpenChange:ee=>!ee&&Ye(),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:ye,onValueChange:ee=>De(ee),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:[$&&u.jsx(ue.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(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Le.length>0&&u.jsx(Nl,{heading:"Recipients",children:Le.map(ee=>u.jsx(Al,{onSelect:()=>Ue(ee),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ee.label}),ee.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ee.secondaryLabel})]})},ee.id))})]})]})]})})]})}function Wk({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(Sr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Lr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Sr,{...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(Lr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Sr,{...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(Lr,{onError:s.onError,enableFileUpload:!0})})]})})}function Vk({apiConfig:e,className:t="",onError:n}){return u.jsx(Sr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Lr,{})})})}function Kk({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(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Lr,{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 qk({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(Sr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Kk,{placeholder:t,onMessageSent:r})})]})})}):null}function Gk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Xe,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var Yk="Label",gm=h.forwardRef((e,t)=>u.jsx(me.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));gm.displayName=Yk;var xm=gm;const Xk=Wr.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:ne(Xk(),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"}),Jk="VisuallyHidden",ai=h.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...bm,...e.style}}));ai.displayName=Jk;var Zk=ai,Qk=[" ","Enter","ArrowUp","ArrowDown"],eE=[" ","Enter"],dr="Select",[li,ci,tE]=Zo(dr),[zr,HN]=an(dr,[tE,Ar]),ui=Ar(),[nE,qn]=zr(dr),[rE,oE]=zr(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,j]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[R,D]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),$=h.useRef(null),U=x?v||!!x.closest("form"):!0,[X,M]=h.useState(new Set),K=Array.from(X).map(q=>q.props.value).join(";");return u.jsx(ua,{...g,children:u.jsxs(nE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:At(),value:R,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:$,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(rE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{M(z=>new Set(z).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{M(z=>{const O=new Set(z);return O.delete(q),O})},[]),children:n})}),U?u.jsxs(Vm,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:q=>D(q.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(X)]},K):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=Me(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(da,{asChild:!0,...s,children:u.jsx(me.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":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===" ")&&Qk.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=Me(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:f,style:{pointerEvents:"none"},children:Km(l.value)?u.jsx(u.Fragment,{children:i}):s})});km.displayName=Tm;var sE="SelectIcon",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Em.displayName=sE;var iE="SelectPortal",Im=e=>u.jsx(lo,{asChild:!0,...e});Im.displayName=iE;var fr="SelectContent",Nm=h.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=h.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Vr.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 pn=10,[Am,Gn]=zr(fr),aE="SelectContentImpl",lE=Vt.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=Me(t,L=>k(L)),[j,R]=h.useState(null),[D,$]=h.useState(null),U=ci(n),[X,M]=h.useState(!1),K=h.useRef(!1);h.useEffect(()=>{if(C)return xa(C)},[C]),Gi();const q=h.useCallback(L=>{const[_,...G]=U().map(se=>se.ref.current),[Z]=G.slice(-1),oe=document.activeElement;for(const se of L)if(se===oe||(se==null||se.scrollIntoView({block:"nearest"}),se===_&&S&&(S.scrollTop=0),se===Z&&S&&(S.scrollTop=S.scrollHeight),se==null||se.focus(),document.activeElement!==oe))return},[U,S]),z=h.useCallback(()=>q([j,C]),[q,j,C]);h.useEffect(()=>{X&&z()},[X,z]);const{onOpenChange:O,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let L={x:0,y:0};const _=Z=>{var oe,se;L={x:Math.abs(Math.round(Z.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((se=I.current)==null?void 0:se.y)??0))}},G=Z=>{L.x<=10&&L.y<=10?Z.preventDefault():C.contains(Z.target)||O(!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,O,I]),h.useEffect(()=>{const L=()=>O(!1);return window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{window.removeEventListener("blur",L),window.removeEventListener("resize",L)}},[O]);const[Y,J]=qm(L=>{const _=U().filter(oe=>!oe.disabled),G=_.find(oe=>oe.ref.current===document.activeElement),Z=Gm(_,L,G);Z&&setTimeout(()=>Z.ref.current.focus())}),P=h.useCallback((L,_,G)=>{const Z=!K.current&&!G;(b.value!==void 0&&b.value===_||Z)&&(R(L),Z&&(K.current=!0))},[b.value]),B=h.useCallback(()=>C==null?void 0:C.focus(),[C]),A=h.useCallback((L,_,G)=>{const Z=!K.current&&!G;(b.value!==void 0&&b.value===_||Z)&&$(L)},[b.value]),F=r==="popper"?Ll:Pm,W=F===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:P,selectedItem:j,onItemLeave:B,itemTextRefCallback:A,focusSelectedItem:z,selectedItemText:D,position:r,isPositioned:X,searchRef:Y,children:u.jsx(ws,{as:lE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:L=>{L.preventDefault()},onUnmountAutoFocus:ae(o,L=>{var _;(_=b.trigger)==null||_.focus({preventScroll:!0}),L.preventDefault()}),children:u.jsx(Tr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:L=>L.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(F,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:L=>L.preventDefault(),...y,...W,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,L=>{const _=L.ctrlKey||L.altKey||L.metaKey;if(L.key==="Tab"&&L.preventDefault(),!_&&L.key.length===1&&J(L.key),["ArrowUp","ArrowDown","Home","End"].includes(L.key)){let Z=U().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(L.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(L.key)){const oe=L.target,se=Z.indexOf(oe);Z=Z.slice(se+1)}setTimeout(()=>q(Z)),L.preventDefault()}})})})})})})});jm.displayName=aE;var cE="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=Me(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(),j=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const oe=D.left-j.left,se=R.left-oe,ie=E.left-se,le=E.width+ie,ye=Math.max(le,j.width),De=window.innerWidth-pn,He=jl(se,[pn,Math.max(pn,De-ye)]);a.style.minWidth=le+"px",a.style.left=He+"px"}else{const oe=j.right-D.right,se=window.innerWidth-R.right-oe,ie=window.innerWidth-E.right-se,le=E.width+ie,ye=Math.max(le,j.width),De=window.innerWidth-pn,He=jl(se,[pn,Math.max(pn,De-ye)]);a.style.minWidth=le+"px",a.style.right=He+"px"}const $=m(),U=window.innerHeight-pn*2,X=g.scrollHeight,M=window.getComputedStyle(c),K=parseInt(M.borderTopWidth,10),q=parseInt(M.paddingTop,10),z=parseInt(M.borderBottomWidth,10),O=parseInt(M.paddingBottom,10),I=K+q+X+O+z,Y=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),B=parseInt(J.paddingBottom,10),A=E.top+E.height/2-pn,F=U-A,W=x.offsetHeight/2,L=x.offsetTop+W,_=K+q+L,G=I-_;if(_<=A){const oe=$.length>0&&x===$[$.length-1].ref.current;a.style.bottom="0px";const se=c.clientHeight-g.offsetTop-g.offsetHeight,ie=Math.max(F,W+(oe?B:0)+se+z),le=_+ie;a.style.height=le+"px"}else{const oe=$.length>0&&x===$[0].ref.current;a.style.top="0px";const ie=Math.max(A,K+g.offsetTop+(oe?P:0)+W)+G;a.style.height=ie+"px",g.scrollTop=_-A+g.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=Y+"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]);Et(()=>C(),[C]);const[k,S]=h.useState();Et(()=>{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(dE,{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(me.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=cE;var uE="SelectPopperPosition",Ll=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=ui(n);return u.jsx(fa,{...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=uE;var[dE,$l]=zr(fr,{}),Fl="SelectViewport",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Fl,n),i=$l(Fl,n),a=Me(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(li.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll: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-pn*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",[fE,pE]=zr(Rm),hE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(fE,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});hE.displayName=Rm;var Mm="SelectLabel",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=pE(Mm,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});Om.displayName=Mm;var di="SelectItem",[mE,Dm]=zr(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=Me(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=At(),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(mE,{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(me.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref: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===" "||(eE.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=oE(Ro,n),[d,f]=h.useState(null),m=Me(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 Et(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Vr.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(me.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=Me(t,r.onScrollButtonChange);return Et(()=>{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=Me(t,r.onScrollButtonChange);return Et(()=>{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]),Et(()=>{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(me.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()})})}),gE="SelectSeparator",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Wm.displayName=gE;var Hl="SelectArrow",xE=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(pa,{...o,...r,ref:t}):null});xE.displayName=Hl;var vE="SelectBubbleInput",Vm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Me(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(me.select,{...n,style:{...bm,...n.style},ref:s,defaultValue:t})});Vm.displayName=vE;function Km(e){return e===""||e===void 0}function qm(e){const t=gt(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=wE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function wE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var bE=ym,Ym=Cm,yE=km,SE=Em,CE=Im,Xm=Nm,TE=_m,Jm=Om,Zm=Lm,kE=$m,EE=Bm,Qm=zm,eg=Hm,tg=Wm;const IE=bE,NE=yE,ng=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:ne("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(SE,{asChild:!0,children:u.jsx(ue.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:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));rg.displayName=Qm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.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(CE,{children:u.jsxs(Xm,{ref:o,className:ne("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(TE,{className:ne("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 AE=h.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));AE.displayName=Jm.displayName;const ig=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zm,{ref:r,className:ne("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(EE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(kE,{children:t})]}));ig.displayName=Zm.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));jE.displayName=tg.displayName;var PE="Separator",ag="horizontal",_E=["horizontal","vertical"],lg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ag,...o}=e,s=RE(r)?r:ag,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});lg.displayName=PE;function RE(e){return _E.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:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ug.displayName=cg.displayName;var fi="Switch",[ME,UN]=an(fi),[OE,DE]=ME(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=Me(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(OE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.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=DE(fg,n);return u.jsx(me.span,{"data-state":mg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pg.displayName=fg;var LE="SwitchBubbleInput",hg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Me(i,s),l=wm(n),c=Cd(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=LE;function mg(e){return e?"checked":"unchecked"}var gg=dg,$E=pg;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(gg,{className:ne("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($E,{className:ne("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 FE=rl,BE=gT,zE=ol,vg=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{className:ne("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 HE=Wr.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(zE,{children:[u.jsx(vg,{}),u.jsxs(No,{ref:o,className:ne(HE({side:e}),t),...r,children:[n,u.jsxs(ch,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wg.displayName=No.displayName;const bg=({className:e,...t})=>u.jsx("div",{className:ne("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:ne("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:ne("text-sm text-muted-foreground",e),...t}));Sg.displayName=Hs.displayName;var[pi,WN]=an("Tooltip",[Ar]),hi=Ar(),Cg="TooltipProvider",UE=700,Ul="tooltip.open",[WE,Wl]=pi(Cg),Tg=e=>{const{__scopeTooltip:t,delayDuration:n=UE,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(WE,{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",[VE,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=At(),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(ua,{...c,children:u.jsx(VE,{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=Me(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(da,{asChild:!0,...i,children:u.jsx(me.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 KE="TooltipPortal",[VN,qE]=pi(KE,{forceMount:void 0}),Hr="TooltipContent",Ig=h.forwardRef((e,t)=>{const n=qE(Hr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(Hr,e.__scopeTooltip);return u.jsx(Bt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ng,{side:o,...s,ref:t}):u.jsx(GE,{side:o,...s,ref:t})})}),GE=h.forwardRef((e,t)=>{const n=mi(Hr,e.__scopeTooltip),r=Wl(Hr,e.__scopeTooltip),o=h.useRef(null),s=Me(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=QE(y,x.getBoundingClientRect()),C=eI(y,b),k=tI(g.getBoundingClientRect()),S=rI([...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=!nI(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})}),[YE,XE]=pi(Mo,{isInside:!1}),JE=Vt.createSlottable("TooltipContent"),Ng=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(Hr,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(Tr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(fa,{"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(JE,{children:r}),u.jsx(YE,{scope:n,isInside:!0,children:u.jsx(Zk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Ig.displayName=Hr;var Ag="TooltipArrow",ZE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return XE(Ag,n).isInside?null:u.jsx(pa,{...o,...r,ref:t})});ZE.displayName=Ag;function QE(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 eI(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 tI(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 nI(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 rI(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),oI(t)}function oI(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 sI=Tg,iI=kg,aI=Eg,jg=Ig;const lI=sI,cI=iI,uI=aI,Pg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(jg,{ref:r,sideOffset:t,className:ne("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,dI,fI]=Zo("Toast"),[_g,KN]=an("Toast",[fI]),[pI,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(pI,{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",hI=["F8"],Gl="toast.viewportPause",Yl="toast.viewportResume",Og=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=hI,label:o="Notifications ({hotkey})",...s}=e,i=gi(Mg,n),a=dI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Me(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,...II(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 j=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(S=c.current)==null||S.focus();return}const U=g({tabbingDirection:R?"backwards":"forwards"}),X=U.findIndex(M=>M===j);Zl(U.slice(X+1))?b.preventDefault():R?(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(Ww,{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(me.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",mI="toast.swipeStart",gI="toast.swipeMove",xI="toast.swipeCancel",vI="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(Bt,{present:n||a,children:u.jsx(yI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:gt(e.onPause),onResume:gt(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[wI,bI]=_g(Oo,{onClose(){}}),yI=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=Me(t,M=>y(M)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),j=h.useRef(0),{onToastAdd:R,onToastRemove:D}=g,$=gt(()=>{var K;(x==null?void 0:x.contains(document.activeElement))&&((K=g.viewport)==null||K.focus()),i()}),U=h.useCallback(M=>{!M||M===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout($,M))},[$]);h.useEffect(()=>{const M=g.viewport;if(M){const K=()=>{U(E.current),c==null||c()},q=()=>{const z=new Date().getTime()-T.current;E.current=E.current-z,window.clearTimeout(j.current),l==null||l()};return M.addEventListener(Gl,q),M.addEventListener(Yl,K),()=>{M.removeEventListener(Gl,q),M.removeEventListener(Yl,K)}}},[g.viewport,S,l,c,U]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&U(S)},[s,S,g.isClosePausedRef,U]),h.useEffect(()=>(R(),()=>D()),[R,D]);const X=h.useMemo(()=>x?Wg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[X&&u.jsx(SI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:X}),u.jsx(wI,{scope:n,onClose:$,children:Vr.createPortal(u.jsx(ql.ItemSlot,{scope:n,children:u.jsx(Uw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:ae(e.onPointerDown,M=>{M.button===0&&(C.current={x:M.clientX,y:M.clientY})}),onPointerMove:ae(e.onPointerMove,M=>{if(!C.current)return;const K=M.clientX-C.current.x,q=M.clientY-C.current.y,z=!!k.current,O=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,Y=O?I(0,K):0,J=O?0:I(0,q),P=M.pointerType==="touch"?10:2,B={x:Y,y:J},A={originalEvent:M,delta:B};z?(k.current=B,xi(gI,f,A,{discrete:!1})):Vg(B,g.swipeDirection,P)?(k.current=B,xi(mI,d,A,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(K)>P||Math.abs(q)>P)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,M=>{const K=k.current,q=M.target;if(q.hasPointerCapture(M.pointerId)&&q.releasePointerCapture(M.pointerId),k.current=null,C.current=null,K){const z=M.currentTarget,O={originalEvent:M,delta:K};Vg(K,g.swipeDirection,g.swipeThreshold)?xi(vI,p,O,{discrete:!0}):xi(xI,m,O,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),SI=e=>{const{__scopeToast:t,children:n,...r}=e,o=gi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return kI(()=>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]})})})},CI="ToastTitle",$g=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});$g.displayName=CI;var TI="ToastDescription",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Fg.displayName=TI;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=bI(Hg,n);return u.jsx(Ug,{asChild:!0,children:u.jsx(me.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(me.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),EI(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?Vi(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 kI(e=()=>{}){const t=gt(e);Et(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function EI(e){return e.nodeType===e.ELEMENT_NODE}function II(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 NI=Rg,Kg=Og,qg=Lg,Gg=$g,Yg=Fg,Xg=zg,Jg=Jl;const AI=NI,Zg=h.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:ne("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 jI=Wr.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:ne(jI({variant:t}),e),...n}));Qg.displayName=qg.displayName;const PI=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));PI.displayName=Xg.displayName;const ex=h.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));ex.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:ne("text-sm font-semibold",e),...t}));tx.displayName=Gg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:ne("text-sm opacity-90",e),...t}));nx.displayName=Yg.displayName;function _I(){const{toasts:e}=ll();return u.jsxs(AI,{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 RI=(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{}},MI=h.createContext(void 0),OI={setTheme:e=>{},themes:[]},DI=()=>{var e;return(e=h.useContext(MI))!=null?e:OI};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:`(${RI.toString()})(${d})`}})});var LI=e=>{switch(e){case"success":return BI;case"info":return HI;case"warning":return zI;case"error":return UI;default:return null}},$I=Array(12).fill(0),FI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},$I.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),BI=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"})),zI=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"})),HI=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"})),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-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"})),WI=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"})),VI=()=>{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,KI=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(GI(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}},Ut=new KI,qI=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return Ut.addToast({title:e,...t,id:n}),n},GI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",YI=qI,XI=()=>Ut.toasts,JI=()=>Ut.getActiveToasts();Object.assign(YI,{success:Ut.success,info:Ut.info,warning:Ut.warning,error:Ut.error,custom:Ut.custom,message:Ut.message,promise:Ut.promise,dismiss:Ut.dismiss,loading:Ut.loading},{getHistory:XI,getToasts:JI});function ZI(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))}ZI(`: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 QI=3,eN="32px",tN="16px",rx=4e3,nN=356,rN=14,oN=20,sN=200;function hn(...e){return e.filter(Boolean).join(" ")}function iN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var aN=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:j,style:R,cancelButtonStyle:D,actionButtonStyle:$,className:U="",descriptionClassName:X="",duration:M,position:K,gap:q,loadingIcon:z,expandByDefault:O,classNames:I,icons:Y,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:P}=e,[B,A]=w.useState(null),[F,W]=w.useState(null),[L,_]=w.useState(!1),[G,Z]=w.useState(!1),[oe,se]=w.useState(!1),[ie,le]=w.useState(!1),[ye,De]=w.useState(!1),[He,_e]=w.useState(0),[$e,ct]=w.useState(0),ft=w.useRef(p.duration||M||rx),St=w.useRef(null),Ke=w.useRef(null),Ye=C===0,Ue=C+1<=y,Le=p.type,je=p.dismissible!==!1,pt=p.className||"",Rt=p.descriptionClassName||"",et=w.useMemo(()=>b.findIndex(xe=>xe.toastId===p.id)||0,[b,p.id]),st=w.useMemo(()=>{var xe;return(xe=p.closeButton)!=null?xe:j},[p.closeButton,j]),vt=w.useMemo(()=>p.duration||M||rx,[p.duration,M]),ut=w.useRef(0),wt=w.useRef(0),rn=w.useRef(0),It=w.useRef(null),[mn,Zt]=K.split("-"),qe=w.useMemo(()=>b.reduce((xe,ce,Ie)=>Ie>=et?xe:xe+ce.height,0),[b,et]),We=VI(),Ct=p.invert||m,ee=Le==="loading";wt.current=w.useMemo(()=>et*q+qe,[et,qe]),w.useEffect(()=>{ft.current=vt},[vt]),w.useEffect(()=>{_(!0)},[]),w.useEffect(()=>{let xe=Ke.current;if(xe){let ce=xe.getBoundingClientRect().height;return ct(ce),x(Ie=>[{toastId:p.id,height:ce,position:p.position},...Ie]),()=>x(Ie=>Ie.filter(it=>it.toastId!==p.id))}},[x,p.id]),w.useLayoutEffect(()=>{if(!L)return;let xe=Ke.current,ce=xe.style.height;xe.style.height="auto";let Ie=xe.getBoundingClientRect().height;xe.style.height=ce,ct(Ie),x(it=>it.find(Se=>Se.toastId===p.id)?it.map(Se=>Se.toastId===p.id?{...Se,height:Ie}:Se):[{toastId:p.id,height:Ie,position:p.position},...it])},[L,p.title,p.description,x,p.id]);let he=w.useCallback(()=>{Z(!0),_e(wt.current),x(xe=>xe.filter(ce=>ce.toastId!==p.id)),setTimeout(()=>{T(p)},sN)},[p,T,x,wt]);w.useEffect(()=>{if(p.promise&&Le==="loading"||p.duration===1/0||p.type==="loading")return;let xe;return S||g||P&&We?(()=>{if(rn.current<ut.current){let ce=new Date().getTime()-ut.current;ft.current=ft.current-ce}rn.current=new Date().getTime()})():ft.current!==1/0&&(ut.current=new Date().getTime(),xe=setTimeout(()=>{var ce;(ce=p.onAutoClose)==null||ce.call(p,p),he()},ft.current)),()=>clearTimeout(xe)},[S,g,p,Le,P,We,he]),w.useEffect(()=>{p.delete&&he()},[he,p.delete]);function tt(){var xe,ce,Ie;return Y!=null&&Y.loading?w.createElement("div",{className:hn(I==null?void 0:I.loader,(xe=p==null?void 0:p.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Le==="loading"},Y.loading):z?w.createElement("div",{className:hn(I==null?void 0:I.loader,(ce=p==null?void 0:p.classNames)==null?void 0:ce.loader,"sonner-loader"),"data-visible":Le==="loading"},z):w.createElement(FI,{className:hn(I==null?void 0:I.loader,(Ie=p==null?void 0:p.classNames)==null?void 0:Ie.loader),visible:Le==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ke,className:hn(U,pt,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[Le],(n=p==null?void 0:p.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":L,"data-promise":!!p.promise,"data-swiped":ye,"data-removed":G,"data-visible":Ue,"data-y-position":mn,"data-x-position":Zt,"data-index":C,"data-front":Ye,"data-swiping":oe,"data-dismissible":je,"data-type":Le,"data-invert":Ct,"data-swipe-out":ie,"data-swipe-direction":F,"data-expanded":!!(S||O&&L),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${G?He:wt.current}px`,"--initial-height":O?"auto":`${$e}px`,...R,...p.style},onDragEnd:()=>{se(!1),A(null),It.current=null},onPointerDown:xe=>{ee||!je||(St.current=new Date,_e(wt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(se(!0),It.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,ce,Ie,it;if(ie||!je)return;It.current=null;let Se=Number(((xe=Ke.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ne=Number(((ce=Ke.current)==null?void 0:ce.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Fe=new Date().getTime()-((Ie=St.current)==null?void 0:Ie.getTime()),ve=B==="x"?Se:Ne,Qe=Math.abs(ve)/Fe;if(Math.abs(ve)>=oN||Qe>.11){_e(wt.current),(it=p.onDismiss)==null||it.call(p,p),W(B==="x"?Se>0?"right":"left":Ne>0?"down":"up"),he(),le(!0),De(!1);return}se(!1),A(null)},onPointerMove:xe=>{var ce,Ie,it,Se;if(!It.current||!je||((ce=window.getSelection())==null?void 0:ce.toString().length)>0)return;let Ne=xe.clientY-It.current.y,Fe=xe.clientX-It.current.x,ve=(Ie=e.swipeDirections)!=null?Ie:iN(K);!B&&(Math.abs(Fe)>1||Math.abs(Ne)>1)&&A(Math.abs(Fe)>Math.abs(Ne)?"x":"y");let Qe={x:0,y:0};B==="y"?(ve.includes("top")||ve.includes("bottom"))&&(ve.includes("top")&&Ne<0||ve.includes("bottom")&&Ne>0)&&(Qe.y=Ne):B==="x"&&(ve.includes("left")||ve.includes("right"))&&(ve.includes("left")&&Fe<0||ve.includes("right")&&Fe>0)&&(Qe.x=Fe),(Math.abs(Qe.x)>0||Math.abs(Qe.y)>0)&&De(!0),(it=Ke.current)==null||it.style.setProperty("--swipe-amount-x",`${Qe.x}px`),(Se=Ke.current)==null||Se.style.setProperty("--swipe-amount-y",`${Qe.y}px`)}},st&&!p.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ee,"data-close-button":!0,onClick:ee||!je?()=>{}:()=>{var xe;he(),(xe=p.onDismiss)==null||xe.call(p,p)},className:hn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=Y==null?void 0:Y.close)!=null?s:WI):null,p.jsx||w.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:w.createElement(w.Fragment,null,Le||p.icon||p.promise?w.createElement("div",{"data-icon":"",className:hn(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||tt():null,p.type!=="loading"?p.icon||(Y==null?void 0:Y[Le])||LI(Le):null):null,w.createElement("div",{"data-content":"",className:hn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:hn(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:hn(X,Rt,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||D,onClick:xe=>{var ce,Ie;vi(p.cancel)&&je&&((Ie=(ce=p.cancel).onClick)==null||Ie.call(ce,xe),he())},className:hn(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||$,onClick:xe=>{var ce,Ie;vi(p.action)&&((Ie=(ce=p.action).onClick)==null||Ie.call(ce,xe),!xe.defaultPrevented&&he())},className:hn(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 lN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?tN:eN;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 cN=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=QI,toastOptions:g,dir:x=ox(),gap:y=rN,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),j=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[R,D]=w.useState([]),[$,U]=w.useState(!1),[X,M]=w.useState(!1),[K,q]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=w.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),Y=w.useRef(!1),J=w.useCallback(P=>{E(B=>{var A;return(A=B.find(F=>F.id===P.id))!=null&&A.delete||Ut.dismiss(P.id),B.filter(({id:F})=>F!==P.id)})},[]);return w.useEffect(()=>Ut.subscribe(P=>{if(P.dismiss){E(B=>B.map(A=>A.id===P.id?{...A,delete:!0}:A));return}setTimeout(()=>{Do.flushSync(()=>{E(B=>{let A=B.findIndex(F=>F.id===P.id);return A!==-1?[...B.slice(0,A),{...B[A],...P},...B.slice(A+1)]:[P,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:B})=>{q(B?"dark":"light")})}catch{P.addListener(({matches:A})=>{try{q(A?"dark":"light")}catch(F){console.error(F)}})}},[d]),w.useEffect(()=>{T.length<=1&&U(!1)},[T]),w.useEffect(()=>{let P=B=>{var A,F;o.every(W=>B[W]||B.code===W)&&(U(!0),(A=z.current)==null||A.focus()),B.code==="Escape"&&(document.activeElement===z.current||(F=z.current)!=null&&F.contains(document.activeElement))&&U(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),w.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,Y.current=!1)}},[z.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,B)=>{var A;let[F,W]=P.split("-");return T.length?w.createElement("ol",{key:P,dir:x==="auto"?ox():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":F,"data-lifted":$&&T.length>1&&!s,"data-x-position":W,style:{"--front-toast-height":`${((A=R[0])==null?void 0:A.height)||0}px`,"--width":`${nN}px`,"--gap":`${y}px`,...p,...lN(l,c)},onBlur:L=>{Y.current&&!L.currentTarget.contains(L.relatedTarget)&&(Y.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:L=>{L.target instanceof HTMLElement&&L.target.dataset.dismissible==="false"||Y.current||(Y.current=!0,I.current=L.relatedTarget)},onMouseEnter:()=>U(!0),onMouseMove:()=>U(!0),onMouseLeave:()=>{X||U(!1)},onDragEnd:()=>U(!1),onPointerDown:L=>{L.target instanceof HTMLElement&&L.target.dataset.dismissible==="false"||M(!0)},onPointerUp:()=>M(!1)},T.filter(L=>!L.position&&B===0||L.position===P).map((L,_)=>{var G,Z;return w.createElement(aN,{key:L.id,icons:C,index:_,toast:L,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:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:X,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(oe=>oe.position==L.position),heights:R.filter(oe=>oe.position==L.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:b,expanded:$,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const uN=({...e})=>{const{theme:t="system"}=DI();return u.jsx(cN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};H.Api=Kv,H.ApiClient=Vv,H.ApiProvider=iu,H.ArtifactRenderer=Ih,H.Badge=$h,H.Button=Xe,H.Card=dl,H.CardContent=Qs,H.CardDescription=hl,H.CardHeader=fl,H.CardTitle=pl,H.ChatApi=Xo,H.ChatApp=Wk,H.ChatInput=qf,H.ChatInputRow=Gf,H.ChatInterface=Lr,H.ChatProviders=Sr,H.ChatWidget=qk,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=sl,H.DialogContent=Us,H.DialogHeader=Ws,H.DialogTitle=Vs,H.DropdownMenu=ks,H.DropdownMenuContent=go,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=Es,H.FileViewerModal=fh,H.HISTORY_TIMEOUT_MS=tu,H.Input=Dl,H.InterruptPartRenderer=jh,H.Label=vm,H.MarkdownContent=cr,H.MessageComponent=ei,H.MessageList=xl,H.MessageRow=gl,H.NewChatButton=Gk,H.PlotArtifact=Eh,H.SETTINGS_STORAGE_KEY=Wi,H.ScrollArea=Ol,H.Select=IE,H.SelectContent=sg,H.SelectItem=ig,H.SelectTrigger=ng,H.SelectValue=NE,H.Separator=ug,H.Sheet=FE,H.SheetContent=wg,H.SheetDescription=Sg,H.SheetHeader=bg,H.SheetTitle=yg,H.SheetTrigger=BE,H.SimpleChat=Vk,H.SimpleJsonView=Zs,H.Sonner=uN,H.StreamProgress=Nh,H.Switch=xg,H.Textarea=ja,H.ThinkingIndicator=Ph,H.ThreadListItem=fm,H.ThreadManager=ii,H.ThreadStateProvider=Au,H.ThreadsProvider=xu,H.TimelineColumn=Sx,H.Toaster=_I,H.ToolComponent=Dh,H.Tooltip=cI,H.TooltipContent=Pg,H.TooltipProvider=lI,H.TooltipTrigger=uI,H.UserTextContent=_h,H.applySettings=Iw,H.buildCheckpointIndex=rc,H.buildCheckpointPreviewMap=ux,H.chatApiClient=Nn,H.del=Oi,H.downloadFileById=ru,H.extractConfigFields=yi,H.fileToBase64=au,H.get=qt,H.getChatToken=Zc,H.getCheckpointForMessage=dx,H.getCurrentSettings=Ew,H.getDefaultApiConfig=$u,H.getDefaultChatSettings=Fu,H.getFileContent=Li,H.getFileInfo=Gv,H.getMessageAttemptInfo=oc,H.getMessageDomKey=ml,H.getPreviewForMessage=bi,H.httpClient=Kt,H.hydrateHistorySnapshots=Yn,H.isEnvelope=cu,H.listFiles=ou,H.loadStoredSettings=Bu,H.onChatTokenChanged=Qc,H.post=Yo,H.processAttachments=lu,H.put=nu,H.readNumber=ic,H.readString=Rn,H.resolveChatBaseUrl=xn,H.saveSettings=zu,H.setChatToken=Go,H.toPlainObject=_n,H.unwrap=Mt,H.useApi=Qr,H.useCheckpointIndex=sc,H.useFilePreview=Rh,H.useHasChatSession=Cw,H.useParsedMessageContent=Mh,H.useShallowStableValue=Mu,H.useStream=Ui,H.useStreamingHook=Ui,H.useThreadHistoryState=ku,H.useThreadManagerViewState=mm,H.useThreadState=ro,H.useThreadStateUpdater=Nu,H.useThreads=wr,H.useThreadsState=mu,H.viewFileById=qv,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|
|
127
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class 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>"+_t(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 kh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.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&&we.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;we.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(we.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return kh(Wn.lex,Vn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},kT(we.defaults),we},we.getDefaults=ph,we.defaults=lr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=we.defaults.renderer||new ul;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=we.defaults.tokenizer||new cl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=we.defaults.hooks||new Js;for(const s in n.hooks){const i=o[s];Js.passThroughHooks.has(s)?o[s]=a=>{if(we.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=we.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=kh(Wn.lexInline,Vn.parseInline),we.Parser=Vn,we.parser=Vn.parse,we.Renderer=ul,we.TextRenderer=Ch,we.Lexer=Wn,we.lexer=Wn.lex,we.Tokenizer=cl,we.Slugger=Th,we.Hooks=Js,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.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 we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=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:ne("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 Eh({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 Ih({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(Eh,{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:br(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:br(e)})}function Nh({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(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const dl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));dl.displayName="Card";const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));fl.displayName="CardHeader";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));pl.displayName="CardTitle";const hl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));hl.displayName="CardDescription";const Qs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));Qs.displayName="CardContent";const Ah=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Ah.displayName="CardFooter";const UT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function jh({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=br(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(dl,{className:ne("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(fl,{className:"pb-3",children:[u.jsx(pl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(hl,{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(Xe,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(Qs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(Ah,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Xe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Xe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function 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:ne("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:ne("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:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Xe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Rh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ll(),[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=yr(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 br(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 j=yr(E);return d(j)}const k=no(l),S=yr(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(Ih,{artifact:i,idx:0})),u.jsx(Nh,{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,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:b,getMessageCustomStyles:C,toolRenderers:k,toolArtifactRenderers:S}){const T=ml(t,n),E=t.role==="default_message",R=!!t.__syntheticStreaming,D=y??GT,$=!E&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:U,attemptIndex:X,attempts:M}=w.useMemo(()=>oc(t.id,$,D),[t.id,$,D]),K=C==null?void 0:C(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":T,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ei,{message:t,messageIndex:n,isStreamingMessage:R||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:f,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:U,attemptIndex:X,attemptMetas:M,onSelectCheckpoint:b,customStyles:K,toolRenderers:k,toolArtifactRenderers:S})})});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,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:v,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,handleInterruptAlternative:b,disableInterruptActions:C,messageRole:k,truncateUserMessages:S,userMessagePreviewLength:T,isUserExpanded:E,setIsUserExpanded:j,isCompactLayout:R,activeInterruptId:D,activeInterruptValue:$,iconForeground:U,toolRenderers:X,toolArtifactRenderers:M}){const K=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),z=YT(s,(f??!0)&&d,Lh),O=w.useMemo(()=>z.filter(W=>W.type==="text"),[z]),I=w.useMemo(()=>O.map(W=>W.text??"").join(""),[O]),Y=w.useMemo(()=>{if(!m)return null;const W=JT(I);return{stablePart:I.slice(0,W),tailPart:I.slice(W)}},[I,m]),J=w.useMemo(()=>{if(!Y)return null;const{stablePart:W,tailPart:L}=Y;return!W&&!L?null:u.jsxs("div",{className:"space-y-2",children:[W?u.jsx(cr,{content:W,allowHtml:!1}):null,L?u.jsx(cr,{content:L,allowHtml:!1}):null]})},[Y]),P=w.useMemo(()=>{if(!m)return z;const W=[];let L=!1;for(const _ of z){if(_.type==="text"){L||(W.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),L=!0);continue}W.push(_)}return W},[z,m]),B=m?P:z,A=w.useCallback(({part:W,i:L})=>{if(W.type==="text"){if(m)return null;const _=W.text??"",G=_.trim(),Z=to(G);return Z&&k!=="tool"?u.jsx(Zs,{data:Z},L):k==="user"&&S&&G.length>T?u.jsx(_h,{text:G,expanded:E,onExpandedChange:j,previewLength:T,isCompact:R},L):u.jsx(cr,{content:_,allowHtml:!1},L)}if(W.type==="image_url"){const _=W;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:_.url,alt:_.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},L)}if(W.type==="file"){const _=W,G=_.name||"file";return u.jsxs("a",{href:_.url,onClick:Z=>v(Z,_,L),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[L]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[G,g[L]?" (processing)":""]})]},L)}if(W.type==="interrupt"){const _=W,G=Bi((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id)),Z=!!(D&&G&&G===D),oe=Z?$??(_==null?void 0:_.value):_==null?void 0:_.value,se=G?{..._,id:G,interrupt_id:G}:_;return u.jsx(jh,{interruptPart:se,onApprove:x,onReject:y,onSelectAlternative:b,disabled:C,isActive:Z,payload:oe},L)}return null},[D,$,C,v,x,y,b,R,E,k,S,g,T,m,j]),F=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return K();if(!t&&!F&&!d)return null;if(t)return n?u.jsx(Dh,{message:e,viewMode:r,isStreaming:o,toolRenderers:X,toolArtifactRenderers:M},e.id):null;if(!p){const W=u.jsx("div",{className:"space-y-2",children:B.map((L,_)=>m&&ZT(L)?J?u.jsx("div",{className:"space-y-2",children:J},`streaming-md-${_}`):null:u.jsx(A,{part:L,i:_},_))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[W,u.jsx(Ph,{className:U})]}):W}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=Wr.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:ne(QT({variant:t}),e),...n})}function ek({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:f,toolViewMode:m,toolMeta:p,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:b,attemptCount:C,attemptIndex:k,handleOlderAttemptSelect:S,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:ne("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs($h,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),v())},children:[u.jsx("span",{children:p.name??"Tool Output"}),p.toolCallId&&u.jsx("span",{className:"opacity-70",children:p.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[b&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=C-1||S()},"aria-label":"Older attempt (back in time)",disabled:k>=C-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-k," / ",C]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:ne("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Xe,{variant:"ghost",size:"sm",onClick:g,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:ne(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),f==="user"&&x&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:ne(r,l?"h-3 w-3":"h-4 w-4")})}),f==="assistant"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:ne(r,l?"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,activeInterrupt:S,disableInterruptActions:T=!1,onInterruptActionStart:E,onInterruptActionEnd:j,attemptCount:R=1,attemptIndex:D=0,onSelectCheckpoint:$,attemptMetas:U=[]}){const[X,M]=w.useState(!1),[K,q]=w.useState("preview"),[z,O]=w.useState(!1),{currentThreadId:I}=wr(),{respondToInterrupt:Y}=ro(),J=l==="phone"||l==="half-screen",P=t.role,B=P==="tool",A=w.useMemo(()=>t.role==="default_message"?t:null,[t]),F=!!A,W=!(r&&P!=="user"),{uploadingFiles:L,handleFileClick:_,fileViewerOpen:G,currentFileInfo:Z,closeFileViewer:oe}=Rh({allowFileOpen:W,currentThreadId:I}),se=w.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[P]),ie=Mh(t,A),{contentParts:le,imageParts:ye,fileParts:De,interruptParts:He,textContent:_e,toolMeta:$e,toolRaw:ct,isToolStreaming:ft}=ie,St=y??g!==0,Ke=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),Ye=Bi(Ke),Ue=S==null?void 0:S.value,Le=w.useCallback(async()=>{const ce=B?ct:_e;async function Ie(it){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(it);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Se=new Blob([it],{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 Ie(ce),M(!0),setTimeout(()=>M(!1),2e3),k==null||k(ce)}catch(it){console.error("Failed to copy:",it)}},[B,ct,_e,k]),je=w.useCallback(()=>{if(!b||!t.id)return;const ce=(B?ct:_e)??"",Ie="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,ce,Ie)},[b,B,ct,_e,t]),pt=w.useCallback(()=>{C==null||C(n)},[C,n]),Rt=w.useCallback(()=>{q(ce=>ce==="expanded"?"preview":"expanded")},[]),et=w.useCallback(()=>{const Ie=ne(J?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",se);switch(P){case"user":return u.jsx(ue.User,{className:Ie});case"assistant":return u.jsx(ue.Bot,{className:Ie});case"tool":return u.jsx(ue.Wrench,{className:Ie});default:return u.jsx(ue.Bot,{className:Ie})}},[J,se,P]),st=w.useCallback(()=>{const ce="group relative mb-4 flex w-full";switch(P){case"user":return ne(ce,"justify-end");case"assistant":case"tool":case"system":return ne(ce,"justify-start");default:return ce}},[P]),vt=w.useCallback(()=>{const ce=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",J&&"px-3 py-2 text-sm");if(F)return ne(ce,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(P){case"user":return ne(ce,"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 ne(ce,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(ce,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(ce,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(ce,"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")}},[J,F,P]),ut=w.useCallback(async(ce,Ie,it)=>{if(T)return;const Se=Bi((ce==null?void 0:ce.id)??(ce==null?void 0:ce.interrupt_id));if(!Se){console.warn("Interrupt part missing id",ce);return}try{E==null||E(),await Y(Se,Ie,it)}catch(Ne){console.error("Failed to respond to interrupt:",Ne)}finally{j==null||j()}},[T,j,E,Y]),wt=w.useCallback(async ce=>{await ut(ce,!0)},[ut]),rn=w.useCallback(async ce=>{await ut(ce,!1)},[ut]),It=w.useCallback(async(ce,Ie)=>{await ut(ce,!0,Ie)},[ut]),mn=u.jsx(XT,{message:t,isToolMessage:B,showToolMessages:f,toolViewMode:K,isToolStreaming:ft,contentParts:le,textContent:_e,imageParts:ye,fileParts:De,interruptParts:He,isStreamingMessage:r,defaultMessage:A,enableStreamingMarkdownBuffer:St,renderStreamingMarkdown:x,handleFileClick:_,uploadingFiles:L,handleInterruptApprove:wt,handleInterruptReject:rn,handleInterruptAlternative:It,disableInterruptActions:T,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:z,setIsUserExpanded:O,isCompactLayout:J,activeInterruptId:Ye,activeInterruptValue:Ue,iconForeground:se,toolRenderers:m,toolArtifactRenderers:p}),Zt=w.useMemo(()=>A?"Assistant":aw(t),[A,t]),qe=et(),We=P==="user"&&(R??1)>1&&typeof $=="function",Ct=(U==null?void 0:U.length)??0,ee=Ct>0&&D<Ct-1?U[D+1]:void 0,he=Ct>0&&D>0?U[D-1]:void 0,tt=w.useCallback(()=>{!ee||!$||$(ee.id,void 0,!!ee.isLatestAttempt)},[ee,$]),xe=w.useCallback(()=>{!he||!$||$(he.id,void 0,!!he.isLatestAttempt)},[he,$]);return B&&!f?null:F&&A?u.jsx("div",{className:ne(st(),v.container),children:u.jsxs("div",{className:ne(vt(),v.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:ne("h-4 w-4",se)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:A.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(st(),v.container),children:u.jsxs("div",{className:ne(vt(),v.content),children:[u.jsx(ek,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:se,agentName:Zt,messageIcon:qe,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:J,showActions:s,isEditing:o,messageRole:P,toolViewMode:K,toolMeta:$e,onToggleToolView:Rt,onCopy:Le,onEdit:je,onRegenerate:pt,showCheckpointControls:We,attemptCount:R,attemptIndex:D,handleOlderAttemptSelect:tt,handleNewerAttemptSelect:xe,messageCreatedAt:t.createdAt,copied:X}),u.jsx("div",{className:"relative",children:mn}),B&&K==="expanded"&&($e.toolCallId||$e.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",J&&"text-xs"),children:[$e.name&&u.jsxs("div",{children:["Function: ",$e.name]}),$e.toolCallId&&u.jsxs("div",{children:["Call ID: ",$e.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Le(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:ne(X?"text-success":"text-current",J?"h-3 w-3":"h-4 w-4")})}),P==="user"&&b&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:je,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:ne("text-current",J?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&C&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:pt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:ne("text-current",J?"h-3 w-3":"h-4 w-4")})})]})]})}),Z&&u.jsx(fh,{isOpen:G,onClose:oe,fileId:Z.id,fileName:Z.name,mimeType:Z.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&wu(e.message)===wu(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=bu(e.message),a=bu(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,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T=!0,toolRenderers:E,toolArtifactRenderers:j,checkpointIndex:R,activeCheckpointId:D,onSelectCheckpoint:$,createSyntheticThinkingMessage:U=!0,forceSyntheticThinking:X=!1,getMessageCustomStyles:M},K)=>{const q=w.useRef(null),z=w.useRef(null),O=w.useRef(!1),I=w.useRef(!1),Y=w.useMemo(()=>b?e.some(ie=>ie.role==="default_message"?!1:Array.isArray(ie==null?void 0:ie.content)&&ie.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===b.id)):!1,[b,e]),J=w.useMemo(()=>{if(!b||Y)return null;const ie=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let le;const ye=b.value;if(ye&&typeof ye=="object"&&!Array.isArray(ye)){const De=ye.title;typeof De=="string"&&De.trim()&&(le=De.trim())}return{id:`interrupt-${ie}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:ie,value:ye,title:le}]}},[b,Y]),P=w.useMemo(()=>J?[...e,J]:e,[e,J]),B=w.useMemo(()=>{const ie=n&&P.some(ye=>ye.id===n);return U&&(t||X)&&!ie&&P.length>0?[...P,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:P},[P,t,n,U,X]),A=w.useMemo(()=>T?B:B.filter(ie=>(ie==null?void 0:ie.role)!=="tool"),[B,T]),F=w.useCallback(ie=>{x&&x(!ie),y&&y(ie)},[x,y]),W=w.useMemo(()=>{if(a)return async()=>{if(!O.current){O.current=!0;try{await a()}finally{O.current=!1}}}},[a]),L=w.useMemo(()=>!v||g?!1:"auto",[v,g]),_=w.useMemo(()=>{if(typeof p!="string")return null;const ie=p.trim();return!ie||A&&A.length>0?null:{id:"default-message",role:"default_message",content:ie,createdAt:new Date().toISOString()}},[p,A]),G=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),Z=()=>{if(_){const ie=M==null?void 0: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:_,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:ie})})})}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!"})},oe=A.length,se=oe>0;return w.useEffect(()=>{var ie,le;if(oe===0){I.current=!1;return}if(!I.current)if(I.current=!0,q.current&&A.length>0){const ye=A.length-1;(le=(ie=q.current).scrollToIndex)==null||le.call(ie,{index:ye,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[oe,A.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var ie,le;if(q.current&&A.length>0){const ye=A.length-1;(le=(ie=q.current).scrollToIndex)==null||le.call(ie,{index:ye,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var ie,le;q.current&&A.length>0?(le=(ie=q.current).scrollToIndex)==null||le.call(ie,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[A]),u.jsx("div",{className:G,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:se?u.jsx(qC,{ref:ie=>{q.current=ie},scrollerRef:ie=>{z.current=ie instanceof HTMLDivElement?ie:null},data:A,followOutput:L,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{W&&W()},atBottomStateChange:F,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(ie,le)=>ml(le,ie),itemContent:(ie,le)=>u.jsx(gl,{message:le,index:ie,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:C,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T,toolRenderers:E,toolArtifactRenderers:j,checkpointIndex:R,activeCheckpointId:D,onSelectCheckpoint:$,getMessageCustomStyles:M})}):Z()})})});xl.displayName="MessageList";const Fh={value:""};function Lr({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}=wr(),{threadId:E,messages:j,isLoading:R,navigateToCheckpoint:D,returnToLatest:$,checkpoint:U,checkpoints:X,interrupt:M,metadata:K,checkpointIndex:q}=ro(),{isStreaming:z,error:O,connectionState:I,submit:Y,stop:J}=Ui(),P=E??T??null,B=(U==null?void 0:U.id)??null,A=(U==null?void 0:U.namespace)??null,F=(K==null?void 0:K.assemblingMessageId)??null,W=M,[L,_]=w.useState(!1),[G,Z]=w.useState(!1);w.useEffect(()=>{W||_(!1)},[W]);const oe=w.useCallback(()=>{_(!0)},[]),se=w.useCallback(()=>{_(!1)},[]),ie=!!W||L,[le,ye]=w.useState(null),[De,He]=w.useState(""),[_e,$e]=w.useState(null),[ct,ft]=w.useState(null),[St,Ke]=w.useState(!1),[Ye,Ue]=w.useState(null),Le=w.useRef(!1),[je,pt]=w.useState(()=>Fh.value),Rt=w.useRef(je),et=w.useRef(null),st=w.useCallback(Se=>{Fh.value=Se,pt(Se)},[]),[vt,ut]=w.useState(!1),wt=w.useRef(null),rn=w.useCallback(Se=>{st(Se)},[st]);w.useEffect(()=>{z||Z(!1)},[z]),w.useEffect(()=>{K!=null&&K.assemblingMessageId&&Z(!1)},[K==null?void 0:K.assemblingMessageId]);const[It,mn]=w.useState("desktop");w.useEffect(()=>{const Se=()=>{const Ne=window.innerWidth;mn(Ne<640?"phone":Ne<1024?"tablet":"desktop")};return Se(),window.addEventListener("resize",Se),()=>window.removeEventListener("resize",Se)},[]),w.useEffect(()=>{Le.current=!1},[P]),w.useEffect(()=>{Rt.current=je},[je]),w.useEffect(()=>{if(!le){et.current=null;return}et.current===null&&(et.current=Rt.current),st(De??"")},[De,le,st]),w.useEffect(()=>{if(C!==void 0){Ue(C);return}(async()=>{if(!S){Ue(null);return}try{const Fe=(await k.getAgent("default")).uiDefaultMessage||"";Ue(Fe||null)}catch(Ne){console.warn("Failed to fetch default message:",Ne),Ue(null)}})()},[k,S,C]),w.useEffect(()=>{O&&!St&&(b==null||b(O))},[O,St,b]);const Zt=async(Se,Ne)=>{const Fe=Se.trim();if(!(!Fe&&Ne.length===0))try{const ve=le?(_e==null?void 0:_e.checkpointId)??B??void 0:B??void 0,Qe=le?(_e==null?void 0:_e.checkpointNs)??A??void 0:A??void 0;await Y({text:Fe||"",attachments:Ne,payload:p},{checkpointId:ve,checkpointNs:Qe,edit:!!le,originalMessageId:le??void 0}),x==null||x(Fe),Z(!0),st(""),ft(null),ye(null),He(""),$e(null)}catch(ve){const Qe=(ve==null?void 0:ve.message)||"Failed to send message";ft(Qe),b==null||b(Qe),Z(!1)}},qe=w.useCallback(async Se=>{await Y({attachments:[Se],payload:p},{checkpointId:B??void 0,checkpointNs:A??void 0}),y==null||y({file:Se})},[B,A,p,y,Y]),We=w.useCallback((Se,Ne,Fe)=>{c&&(et.current=je,ye(Se),He(Ne),st(Ne),ft(null),$e({checkpointId:(Fe==null?void 0:Fe.checkpointId)??null,checkpointNs:(Fe==null?void 0:Fe.checkpointNs)??null}))},[je,c,st]),Ct=w.useCallback(()=>{ye(null),He(""),$e(null),ft(null),st(et.current??je),et.current=null},[je,st]),ee=w.useCallback((Se,Ne,Fe)=>{We(Se,Ne,Fe)},[We]),he=w.useCallback(Se=>{let Ne=null;for(let Re=Se-1;Re>=0;Re--)if(j[Re].role==="user"){Ne=j[Re];break}if(!Ne)return;const Fe=Array.isArray(Ne.content)?Ne.content:[],Qe=Fe.filter(Re=>(Re==null?void 0:Re.type)==="text").map(Re=>Re.text).join("")||(()=>{try{return JSON.stringify(Fe,null,2)}catch{return String(Fe)}})();Qe&&Y({text:Qe,payload:p},{checkpointId:B??void 0,checkpointNs:A??void 0,edit:!0,originalMessageId:Ne.id})},[j,Y,B,A,p]),tt=w.useCallback(async Se=>{if(T){ut(!0);try{if(!Se){await $(),requestAnimationFrame(()=>{var ve;(ve=wt.current)==null||ve.scrollToLatest()});return}const Ne=X.find(ve=>ve.checkpointId===Se),Fe=(Ne==null?void 0:Ne.checkpointNs)??null;await D(Se,Fe),requestAnimationFrame(()=>{var ve;(ve=wt.current)==null||ve.scrollToTop()})}finally{ut(!1)}}},[X,T,wt,D,$]),xe=w.useCallback(async(Se,Ne,Fe)=>{await tt(Fe?null:Se)},[tt]),ce=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,Ie=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${v.messagesArea||""}`,it=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:ce,children:[!!O&&!St&&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:O}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Ke(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ie}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(xl,{ref:wt,className:"h-full",style:{height:"100%"},messages:j,isStreaming:z,streamingAssistantId:F,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:It,enableMessageEditing:c,editingMessageId:le,onEdit:ee,onRegenerate:he,onCancelEdit:Ct,emptyMessage:Ye??void 0,isNavigatingCheckpoint:vt,activeInterrupt:W,disableInterruptActions:L,onInterruptActionStart:oe,onInterruptActionEnd:se,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:q,activeCheckpointId:B,onSelectCheckpoint:xe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:G,getMessageCustomStyles:g}),(I==="reconnecting"||I==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),I==="reconnecting"?"Reconnecting…":"Connecting…"]})}),I==="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"}),R&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),vt&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:it,children:[le&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:Ct,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),ct&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ct}),u.jsx(LS,{composerValue:je,onComposerChange:rn,onSend:Zt,onCancelEdit:Ct,onStop:J,editingMessageId:le,editingInitialValue:De,placeholder:le?"Edit your message...":t,isStreaming:z,disabled:ie,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:qe,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:ct})]})]})}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",$r="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=Fr(()=>{var P,B;return{search:"",value:(B=(P=e.value)!=null?P:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Fr(()=>new Set),o=Fr(()=>new Map),s=Fr(()=>new Map),i=Fr(()=>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=At(),C=At(),k=At(),S=h.useRef(null),T=Sk();ur(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),ur(()=>{T(6,X)},[]);let E=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,B,A)=>{var F,W,L,_;if(!Object.is(n.current[P],B)){if(n.current[P]=B,P==="search")U(),D(),T(1,$);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(k);G?G.focus():(F=document.getElementById(b))==null||F.focus()}if(T(7,()=>{var G;n.current.selectedItemId=(G=M())==null?void 0:G.id,E.emit()}),A||T(5,X),((W=a.current)==null?void 0:W.value)!==void 0){let G=B??"";(_=(L=a.current).onValueChange)==null||_.call(L,G);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=h.useMemo(()=>({value:(P,B,A)=>{var F;B!==((F=s.current.get(P))==null?void 0:F.value)&&(s.current.set(P,{value:B,keywords:A}),n.current.filtered.items.set(P,R(B,A)),T(2,()=>{D(),E.emit()}))},item:(P,B)=>(r.current.add(P),B&&(o.current.has(B)?o.current.get(B).add(P):o.current.set(B,new Set([P]))),T(3,()=>{U(),D(),n.current.value||$(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let A=M();T(4,()=>{U(),(A==null?void 0:A.getAttribute("id"))===P&&$(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function R(P,B){var A,F;let W=(F=(A=a.current)==null?void 0:A.filter)!=null?F:dk;return P?W(P,n.current.search,B):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(F=>{let W=o.current.get(F),L=0;W.forEach(_=>{let G=P.get(_);L=Math.max(G,L)}),B.push([F,L])});let A=S.current;K().sort((F,W)=>{var L,_;let G=F.getAttribute("id"),Z=W.getAttribute("id");return((L=P.get(Z))!=null?L:0)-((_=P.get(G))!=null?_:0)}).forEach(F=>{let W=F.closest(yl);W?W.appendChild(F.parentElement===W?F:F.closest(`${yl} > *`)):A.appendChild(F.parentElement===A?F:F.closest(`${yl} > *`))}),B.sort((F,W)=>W[1]-F[1]).forEach(F=>{var W;let L=(W=S.current)==null?void 0:W.querySelector(`${Po}[${$r}="${encodeURIComponent(F[0])}"]`);L==null||L.parentElement.appendChild(L)})}function $(){let P=K().find(A=>A.getAttribute("aria-disabled")!=="true"),B=P==null?void 0:P.getAttribute($r);E.setState("value",B||void 0)}function U(){var P,B,A,F;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let W=0;for(let L of r.current){let _=(B=(P=s.current.get(L))==null?void 0:P.value)!=null?B:"",G=(F=(A=s.current.get(L))==null?void 0:A.keywords)!=null?F:[],Z=R(_,G);n.current.filtered.items.set(L,Z),Z>0&&W++}for(let[L,_]of o.current)for(let G of _)if(n.current.filtered.items.get(G)>0){n.current.filtered.groups.add(L);break}n.current.filtered.count=W}function X(){var P,B,A;let F=M();F&&(((P=F.parentElement)==null?void 0:P.firstChild)===F&&((A=(B=F.closest(Po))==null?void 0:B.querySelector(uk))==null||A.scrollIntoView({block:"nearest"})),F.scrollIntoView({block:"nearest"}))}function M(){var P;return(P=S.current)==null?void 0:P.querySelector(`${Uh}[aria-selected="true"]`)}function K(){var P;return Array.from(((P=S.current)==null?void 0:P.querySelectorAll(Wh))||[])}function q(P){let B=K()[P];B&&E.setState("value",B.getAttribute($r))}function z(P){var B;let A=M(),F=K(),W=F.findIndex(_=>_===A),L=F[W+P];(B=a.current)!=null&&B.loop&&(L=W+P<0?F[F.length-1]:W+P===F.length?F[0]:F[W+P]),L&&E.setState("value",L.getAttribute($r))}function O(P){let B=M(),A=B==null?void 0:B.closest(Po),F;for(;A&&!F;)A=P>0?bk(A,Po):yk(A,Po),F=A==null?void 0:A.querySelector(Wh);F?E.setState("value",F.getAttribute($r)):z(P)}let I=()=>q(K().length-1),Y=P=>{P.preventDefault(),P.metaKey?I():P.altKey?O(1):z(1)},J=P=>{P.preventDefault(),P.metaKey?q(0):P.altKey?O(-1):z(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var B;(B=y.onKeyDown)==null||B.call(y,P);let A=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||A))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&Y(P);break}case"ArrowDown":{Y(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),q(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let F=M();if(F){let W=new Event(Sl);F.dispatchEvent(W)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:Tk},l),ti(e,P=>h.createElement(Kh.Provider,{value:E},h.createElement(Vh.Provider,{value:j},P))))}),fk=h.forwardRef((e,t)=>{var n,r;let o=At(),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(me.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=At(),a=h.useRef(null),l=h.useRef(null),c=At(),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(me.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(me.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(me.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),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(me.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(rl,{open:n,onOpenChange:r},h.createElement(ol,{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(me.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(me.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)))}),Ht=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 Fr(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($r,a),o.current=a}),o}var Sk=()=>{let[e,t]=h.useState(),n=Fr(()=>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(Ht,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tl.displayName=Ht.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(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ht.Input,{ref:n,className:ne("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=Ht.Input.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));El.displayName=Ht.List.displayName;const Il=h.forwardRef((e,t)=>u.jsx(Ht.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Il.displayName=Ht.Empty.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Group,{ref:n,className:ne("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=Ht.Group.displayName;const kk=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));kk.displayName=Ht.Separator.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Item,{ref:n,className:ne("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=Ht.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]=an(Pl),[Ik,nn]=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,j]=h.useState(!1),R=Me(t,$=>l($)),D=Qo(o);return u.jsx(Ik,{scope:n,type:r,dir:D,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:j,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(me.div,{dir:D,...i,ref:R,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=nn(Qh,n),a=h.useRef(null),l=Me(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(me.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});em.displayName=Qh;var En="ScrollAreaScrollbar",_l=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(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=En;var Nk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Bt,{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=nn(En,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(Bt,{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=nn(En,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 Br(n.viewport,l),Br(n.content,l),u.jsx(Bt,{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=nn(En,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=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=nn(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(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=nn(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(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(En),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=nn(En,n),[v,g]=h.useState(null),x=Me(t,R=>g(R)),y=h.useRef(null),b=h.useRef(""),C=p.viewport,k=r.content-r.viewport,S=gt(d),T=gt(l),E=si(f,10);function j(R){if(y.current){const D=R.clientX-y.current.left,$=R.clientY-y.current.top;c({x:D,y:$})}}return h.useEffect(()=>{const R=D=>{const $=D.target;(v==null?void 0:v.contains($))&&S(D,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Br(v,E),Br(p.content,E),u.jsx(_k,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:gt(s),onThumbPointerUp:gt(i),onThumbPositionChange:T,onThumbPointerDown:gt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(R))}),onPointerMove:ae(e.onPointerMove,j),onPointerUp:ae(e.onPointerUp,R=>{const D=R.target;D.hasPointerCapture(R.pointerId)&&D.releasePointerCapture(R.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(Bt,{present:n||o.hasThumb,children:u.jsx(Rk,{ref:t,...r})})}),Rk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=nn(ni,n),i=nm(ni,n),{onThumbPositionChange:a}=i,l=Me(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(me.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture: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=nn(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=nn(Ml,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Br(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Br(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function 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=gt(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 Br(e,t){const n=gt(t);Et(()=>{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:ne("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:ne("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:ne("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(Xe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children: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(ue.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(Xe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.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(ue.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(ue.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(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}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:j,isLoadingSharedThreads:R,actions:D,shareInFlight:$,shareStatus:U,clearShareStatus:X}=wr(),{createThread:M,deleteThread:K,renameThread:q,shareThread:z}=D,{loadThread:O}=ro(),I=i??T,[Y,J]=w.useState(Array.isArray(k)?k:[]),P=w.useRef(Y.length>0),B=w.useRef(null),A=w.useRef(0),[F,W]=w.useState(null),[L,_]=w.useState(""),[G,Z]=w.useState(!1),[oe,se]=w.useState(!1),[ie,le]=w.useState(null),[ye,De]=w.useState(""),He=v&&v.length>0?v:Wk,_e=mm({defaultView:m}),$e=g??_e,ct=f??$e.view,ft=w.useCallback(ee=>{f||$e.setView(ee),p==null||p(ee)},[f,p,$e]),St=He.find(ee=>ee.key===ct)??He[0],Ke=ee=>{le(ee),De(""),se(!0)},Ye=()=>{se(!1),le(null),De(""),X()},Ue=w.useCallback(async ee=>{if(!(!ie||$)&&ee.id)try{await z(ie,ee.id),setTimeout(()=>Ye(),600)}catch(he){console.error("Failed to share thread:",he)}},[Ye,$,ie,z]),Le=w.useMemo(()=>{const ee=y??[],he=ye.trim().toLowerCase();return he?C?ee.filter(tt=>C(tt,he)):ee.filter(tt=>`${tt.label} ${tt.secondaryLabel??""}`.toLowerCase().includes(he)):ee},[y,ye,C]),je=ct==="shared",pt=je?S:Y,Rt=je?R:j,et=je?"No shared conversations yet":"No conversations yet",st=ee=>{const he=ee.sharedAt?` • ${qe(ee.sharedAt)}`:"";return`Shared by ${ee.sharedByUserId}${he}`},vt=ee=>"sharedByUserId"in ee;w.useEffect(()=>{const ee=Array.isArray(k)?k:[];if(ee.length>0){P.current=!0,J(ee);return}j||(P.current=!1,J(ee))},[k,j]),w.useEffect(()=>{if(!B.current)return;const ee=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!ee)return;let he=null,tt=null;return he=requestAnimationFrame(()=>{tt=requestAnimationFrame(()=>{ee.scrollTop=A.current})}),()=>{he!==null&&cancelAnimationFrame(he),tt!==null&&cancelAnimationFrame(tt)}},[Y]);const ut=async ee=>{try{E(ee),await O(ee),a==null||a(ee),l==null||l(ee)}catch(he){console.error("Failed to select thread:",he)}},wt=async()=>{try{Z(!0);const ee=await M();ee&&(c==null||c(ee),a==null||a(ee))}catch(ee){console.error("Failed to create thread:",ee)}finally{Z(!1)}},rn=async(ee,he)=>{if(he.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const tt=B.current.querySelector("[data-radix-scroll-area-viewport]");tt&&(A.current=tt.scrollTop)}try{await K(ee),d==null||d(ee)}catch(tt){console.error("Failed to delete thread:",tt)}}},It=(ee,he)=>{he.stopPropagation(),W(ee.threadId),_(ee.title||`Thread ${ee.threadId.slice(0,8)}`)},mn=async ee=>{if(L.trim())try{await q(ee,L.trim()),W(null),_("")}catch(he){console.error("Failed to update title:",he)}},Zt=()=>{W(null),_("")},qe=ee=>{if(!ee)return"";try{const he=new Date(ee),xe=new Date().getTime()-he.getTime(),ce=Math.floor(xe/(1e3*60*60*24));return ce===0?he.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ce===1?"Yesterday":ce<7?`${ce} days ago`:he.toLocaleDateString()}catch{return""}},We=ee=>ee.title||`Thread ${ee.threadId.slice(0,8)}`,Ct=ee=>{const he=We(ee);return he.length<=pm?he:`${he.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(Xe,{onClick:wt,disabled:G||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:G?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Xe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:St.label})}),u.jsx(go,{align:"start",sideOffset:6,className:"w-40",children:He.map(ee=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:he=>{he.preventDefault(),ft(ee.key)},children:[u.jsx("span",{children:ee.label}),ct===ee.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},ee.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:Rt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):pt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:et})]}):pt.slice().sort((ee,he)=>new Date(he.updatedAt||he.createdAt||"").getTime()-new Date(ee.updatedAt||ee.createdAt||"").getTime()).map(ee=>u.jsx(fm,{thread:ee,isActive:I===ee.threadId,editingThreadId:F,editingTitle:L,onSelect:ut,onStartEditing:It,onEditingTitleChange:he=>_(he),onSaveEditing:mn,onCancelEditing:Zt,onShare:()=>Ke(ee.threadId),onDelete:rn,showEditTitle:r,showDeleteButton:n,formatDate:qe,getDisplayThreadTitle:Ct,secondaryLine:je&&vt(ee)?st(ee):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ee.threadId))})}),u.jsx(sl,{open:oe,onOpenChange:ee=>!ee&&Ye(),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:ye,onValueChange:ee=>De(ee),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:[$&&u.jsx(ue.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(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Le.length>0&&u.jsx(Nl,{heading:"Recipients",children:Le.map(ee=>u.jsx(Al,{onSelect:()=>Ue(ee),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ee.label}),ee.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ee.secondaryLabel})]})},ee.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(Sr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Lr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Sr,{...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(Lr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Sr,{...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(Lr,{onError:s.onError,enableFileUpload:!0})})]})})}function Kk({apiConfig:e,className:t="",onError:n}){return u.jsx(Sr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Lr,{})})})}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(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Lr,{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(Sr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.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(Xe,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var Xk="Label",gm=h.forwardRef((e,t)=>u.jsx(me.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));gm.displayName=Xk;var xm=gm;const Jk=Wr.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:ne(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(me.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),[zr,WN]=an(dr,[nE,Ar]),ui=Ar(),[rE,qn]=zr(dr),[oE,sE]=zr(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,j]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[R,D]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),$=h.useRef(null),U=x?v||!!x.closest("form"):!0,[X,M]=h.useState(new Set),K=Array.from(X).map(q=>q.props.value).join(";");return u.jsx(ua,{...g,children:u.jsxs(rE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:At(),value:R,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:$,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(oE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{M(z=>new Set(z).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{M(z=>{const O=new Set(z);return O.delete(q),O})},[]),children:n})}),U?u.jsxs(Vm,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:q=>D(q.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(X)]},K):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=Me(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(da,{asChild:!0,...s,children:u.jsx(me.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":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=Me(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(me.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(me.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(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Vr.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 pn=10,[Am,Gn]=zr(fr),lE="SelectContentImpl",cE=Vt.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=Me(t,L=>k(L)),[j,R]=h.useState(null),[D,$]=h.useState(null),U=ci(n),[X,M]=h.useState(!1),K=h.useRef(!1);h.useEffect(()=>{if(C)return xa(C)},[C]),Gi();const q=h.useCallback(L=>{const[_,...G]=U().map(se=>se.ref.current),[Z]=G.slice(-1),oe=document.activeElement;for(const se of L)if(se===oe||(se==null||se.scrollIntoView({block:"nearest"}),se===_&&S&&(S.scrollTop=0),se===Z&&S&&(S.scrollTop=S.scrollHeight),se==null||se.focus(),document.activeElement!==oe))return},[U,S]),z=h.useCallback(()=>q([j,C]),[q,j,C]);h.useEffect(()=>{X&&z()},[X,z]);const{onOpenChange:O,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let L={x:0,y:0};const _=Z=>{var oe,se;L={x:Math.abs(Math.round(Z.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((se=I.current)==null?void 0:se.y)??0))}},G=Z=>{L.x<=10&&L.y<=10?Z.preventDefault():C.contains(Z.target)||O(!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,O,I]),h.useEffect(()=>{const L=()=>O(!1);return window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{window.removeEventListener("blur",L),window.removeEventListener("resize",L)}},[O]);const[Y,J]=qm(L=>{const _=U().filter(oe=>!oe.disabled),G=_.find(oe=>oe.ref.current===document.activeElement),Z=Gm(_,L,G);Z&&setTimeout(()=>Z.ref.current.focus())}),P=h.useCallback((L,_,G)=>{const Z=!K.current&&!G;(b.value!==void 0&&b.value===_||Z)&&(R(L),Z&&(K.current=!0))},[b.value]),B=h.useCallback(()=>C==null?void 0:C.focus(),[C]),A=h.useCallback((L,_,G)=>{const Z=!K.current&&!G;(b.value!==void 0&&b.value===_||Z)&&$(L)},[b.value]),F=r==="popper"?Ll:Pm,W=F===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:P,selectedItem:j,onItemLeave:B,itemTextRefCallback:A,focusSelectedItem:z,selectedItemText:D,position:r,isPositioned:X,searchRef:Y,children:u.jsx(ws,{as:cE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:L=>{L.preventDefault()},onUnmountAutoFocus:ae(o,L=>{var _;(_=b.trigger)==null||_.focus({preventScroll:!0}),L.preventDefault()}),children:u.jsx(Tr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:L=>L.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(F,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:L=>L.preventDefault(),...y,...W,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,L=>{const _=L.ctrlKey||L.altKey||L.metaKey;if(L.key==="Tab"&&L.preventDefault(),!_&&L.key.length===1&&J(L.key),["ArrowUp","ArrowDown","Home","End"].includes(L.key)){let Z=U().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(L.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(L.key)){const oe=L.target,se=Z.indexOf(oe);Z=Z.slice(se+1)}setTimeout(()=>q(Z)),L.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=Me(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(),j=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const oe=D.left-j.left,se=R.left-oe,ie=E.left-se,le=E.width+ie,ye=Math.max(le,j.width),De=window.innerWidth-pn,He=jl(se,[pn,Math.max(pn,De-ye)]);a.style.minWidth=le+"px",a.style.left=He+"px"}else{const oe=j.right-D.right,se=window.innerWidth-R.right-oe,ie=window.innerWidth-E.right-se,le=E.width+ie,ye=Math.max(le,j.width),De=window.innerWidth-pn,He=jl(se,[pn,Math.max(pn,De-ye)]);a.style.minWidth=le+"px",a.style.right=He+"px"}const $=m(),U=window.innerHeight-pn*2,X=g.scrollHeight,M=window.getComputedStyle(c),K=parseInt(M.borderTopWidth,10),q=parseInt(M.paddingTop,10),z=parseInt(M.borderBottomWidth,10),O=parseInt(M.paddingBottom,10),I=K+q+X+O+z,Y=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),B=parseInt(J.paddingBottom,10),A=E.top+E.height/2-pn,F=U-A,W=x.offsetHeight/2,L=x.offsetTop+W,_=K+q+L,G=I-_;if(_<=A){const oe=$.length>0&&x===$[$.length-1].ref.current;a.style.bottom="0px";const se=c.clientHeight-g.offsetTop-g.offsetHeight,ie=Math.max(F,W+(oe?B:0)+se+z),le=_+ie;a.style.height=le+"px"}else{const oe=$.length>0&&x===$[0].ref.current;a.style.top="0px";const ie=Math.max(A,K+g.offsetTop+(oe?P:0)+W)+G;a.style.height=ie+"px",g.scrollTop=_-A+g.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=Y+"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]);Et(()=>C(),[C]);const[k,S]=h.useState();Et(()=>{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(me.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=pn,...s}=e,i=ui(n);return u.jsx(fa,{...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]=zr(fr,{}),Fl="SelectViewport",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Fl,n),i=$l(Fl,n),a=Me(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(li.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll: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-pn*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]=zr(Rm),mE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(pE,{scope:n,id:o,children:u.jsx(me.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(me.div,{id:o.id,...r,ref:t})});Om.displayName=Mm;var di="SelectItem",[gE,Dm]=zr(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=Me(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=At(),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(me.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref: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=Me(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 Et(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Vr.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(me.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=Me(t,r.onScrollButtonChange);return Et(()=>{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=Me(t,r.onScrollButtonChange);return Et(()=>{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]),Et(()=>{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(me.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(me.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(pa,{...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=Me(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(me.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=gt(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:ne("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(ue.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:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));rg.displayName=Qm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.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:ne("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:ne("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:ne("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:ne("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(ue.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:ne("-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(me.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:ne("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]=an(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=Me(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(me.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(me.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=Me(i,s),l=wm(n),c=Cd(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:ne("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:ne("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=rl,zE=xT,HE=ol,vg=h.forwardRef(({className:e,...t},n)=>u.jsx(Io,{className:ne("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=Wr.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:ne(UE({side:e}),t),...r,children:[n,u.jsxs(ch,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wg.displayName=No.displayName;const bg=({className:e,...t})=>u.jsx("div",{className:ne("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:ne("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:ne("text-sm text-muted-foreground",e),...t}));Sg.displayName=Hs.displayName;var[pi,KN]=an("Tooltip",[Ar]),hi=Ar(),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=At(),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(ua,{...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=Me(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(da,{asChild:!0,...i,children:u.jsx(me.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}),Hr="TooltipContent",Ig=h.forwardRef((e,t)=>{const n=GE(Hr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(Hr,e.__scopeTooltip);return u.jsx(Bt,{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(Hr,e.__scopeTooltip),r=Wl(Hr,e.__scopeTooltip),o=h.useRef(null),s=Me(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=Vt.createSlottable("TooltipContent"),Ng=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(Hr,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(Tr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(fa,{"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=Hr;var Ag="TooltipArrow",QE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return JE(Ag,n).isInside?null:u.jsx(pa,{...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:ne("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]=an("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=Me(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 j=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(S=c.current)==null||S.focus();return}const U=g({tabbingDirection:R?"backwards":"forwards"}),X=U.findIndex(M=>M===j);Zl(U.slice(X+1))?b.preventDefault():R?(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(me.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(Bt,{present:n||a,children:u.jsx(SI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:gt(e.onPause),onResume:gt(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=Me(t,M=>y(M)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),j=h.useRef(0),{onToastAdd:R,onToastRemove:D}=g,$=gt(()=>{var K;(x==null?void 0:x.contains(document.activeElement))&&((K=g.viewport)==null||K.focus()),i()}),U=h.useCallback(M=>{!M||M===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout($,M))},[$]);h.useEffect(()=>{const M=g.viewport;if(M){const K=()=>{U(E.current),c==null||c()},q=()=>{const z=new Date().getTime()-T.current;E.current=E.current-z,window.clearTimeout(j.current),l==null||l()};return M.addEventListener(Gl,q),M.addEventListener(Yl,K),()=>{M.removeEventListener(Gl,q),M.removeEventListener(Yl,K)}}},[g.viewport,S,l,c,U]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&U(S)},[s,S,g.isClosePausedRef,U]),h.useEffect(()=>(R(),()=>D()),[R,D]);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:$,children:Vr.createPortal(u.jsx(ql.ItemSlot,{scope:n,children:u.jsx(Ww,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:ae(e.onPointerDown,M=>{M.button===0&&(C.current={x:M.clientX,y:M.clientY})}),onPointerMove:ae(e.onPointerMove,M=>{if(!C.current)return;const K=M.clientX-C.current.x,q=M.clientY-C.current.y,z=!!k.current,O=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,Y=O?I(0,K):0,J=O?0:I(0,q),P=M.pointerType==="touch"?10:2,B={x:Y,y:J},A={originalEvent:M,delta:B};z?(k.current=B,xi(xI,f,A,{discrete:!1})):Vg(B,g.swipeDirection,P)?(k.current=B,xi(gI,d,A,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(K)>P||Math.abs(q)>P)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,M=>{const K=k.current,q=M.target;if(q.hasPointerCapture(M.pointerId)&&q.releasePointerCapture(M.pointerId),k.current=null,C.current=null,K){const z=M.currentTarget,O={originalEvent:M,delta:K};Vg(K,g.swipeDirection,g.swipeThreshold)?xi(wI,p,O,{discrete:!0}):xi(vI,m,O,{discrete:!0}),z.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(me.div,{...r,ref:t})});$g.displayName=TI;var kI="ToastDescription",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.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(me.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(me.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?Vi(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=gt(e);Et(()=>{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:ne("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=Wr.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:ne(PI({variant:t}),e),...n}));Qg.displayName=qg.displayName;const _I=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:ne("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:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));ex.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:ne("text-sm font-semibold",e),...t}));tx.displayName=Gg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:ne("text-sm opacity-90",e),...t}));nx.displayName=Yg.displayName;function RI(){const{toasts:e}=ll();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}},Ut=new qI,GI=(e,t)=>{let n=(t==null?void 0:t.id)||Ql++;return Ut.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=()=>Ut.toasts,ZI=()=>Ut.getActiveToasts();Object.assign(XI,{success:Ut.success,info:Ut.info,warning:Ut.warning,error:Ut.error,custom:Ut.custom,message:Ut.message,promise:Ut.promise,dismiss:Ut.dismiss,loading:Ut.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 hn(...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:j,style:R,cancelButtonStyle:D,actionButtonStyle:$,className:U="",descriptionClassName:X="",duration:M,position:K,gap:q,loadingIcon:z,expandByDefault:O,classNames:I,icons:Y,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:P}=e,[B,A]=w.useState(null),[F,W]=w.useState(null),[L,_]=w.useState(!1),[G,Z]=w.useState(!1),[oe,se]=w.useState(!1),[ie,le]=w.useState(!1),[ye,De]=w.useState(!1),[He,_e]=w.useState(0),[$e,ct]=w.useState(0),ft=w.useRef(p.duration||M||rx),St=w.useRef(null),Ke=w.useRef(null),Ye=C===0,Ue=C+1<=y,Le=p.type,je=p.dismissible!==!1,pt=p.className||"",Rt=p.descriptionClassName||"",et=w.useMemo(()=>b.findIndex(xe=>xe.toastId===p.id)||0,[b,p.id]),st=w.useMemo(()=>{var xe;return(xe=p.closeButton)!=null?xe:j},[p.closeButton,j]),vt=w.useMemo(()=>p.duration||M||rx,[p.duration,M]),ut=w.useRef(0),wt=w.useRef(0),rn=w.useRef(0),It=w.useRef(null),[mn,Zt]=K.split("-"),qe=w.useMemo(()=>b.reduce((xe,ce,Ie)=>Ie>=et?xe:xe+ce.height,0),[b,et]),We=KI(),Ct=p.invert||m,ee=Le==="loading";wt.current=w.useMemo(()=>et*q+qe,[et,qe]),w.useEffect(()=>{ft.current=vt},[vt]),w.useEffect(()=>{_(!0)},[]),w.useEffect(()=>{let xe=Ke.current;if(xe){let ce=xe.getBoundingClientRect().height;return ct(ce),x(Ie=>[{toastId:p.id,height:ce,position:p.position},...Ie]),()=>x(Ie=>Ie.filter(it=>it.toastId!==p.id))}},[x,p.id]),w.useLayoutEffect(()=>{if(!L)return;let xe=Ke.current,ce=xe.style.height;xe.style.height="auto";let Ie=xe.getBoundingClientRect().height;xe.style.height=ce,ct(Ie),x(it=>it.find(Se=>Se.toastId===p.id)?it.map(Se=>Se.toastId===p.id?{...Se,height:Ie}:Se):[{toastId:p.id,height:Ie,position:p.position},...it])},[L,p.title,p.description,x,p.id]);let he=w.useCallback(()=>{Z(!0),_e(wt.current),x(xe=>xe.filter(ce=>ce.toastId!==p.id)),setTimeout(()=>{T(p)},iN)},[p,T,x,wt]);w.useEffect(()=>{if(p.promise&&Le==="loading"||p.duration===1/0||p.type==="loading")return;let xe;return S||g||P&&We?(()=>{if(rn.current<ut.current){let ce=new Date().getTime()-ut.current;ft.current=ft.current-ce}rn.current=new Date().getTime()})():ft.current!==1/0&&(ut.current=new Date().getTime(),xe=setTimeout(()=>{var ce;(ce=p.onAutoClose)==null||ce.call(p,p),he()},ft.current)),()=>clearTimeout(xe)},[S,g,p,Le,P,We,he]),w.useEffect(()=>{p.delete&&he()},[he,p.delete]);function tt(){var xe,ce,Ie;return Y!=null&&Y.loading?w.createElement("div",{className:hn(I==null?void 0:I.loader,(xe=p==null?void 0:p.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Le==="loading"},Y.loading):z?w.createElement("div",{className:hn(I==null?void 0:I.loader,(ce=p==null?void 0:p.classNames)==null?void 0:ce.loader,"sonner-loader"),"data-visible":Le==="loading"},z):w.createElement(BI,{className:hn(I==null?void 0:I.loader,(Ie=p==null?void 0:p.classNames)==null?void 0:Ie.loader),visible:Le==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ke,className:hn(U,pt,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[Le],(n=p==null?void 0:p.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":L,"data-promise":!!p.promise,"data-swiped":ye,"data-removed":G,"data-visible":Ue,"data-y-position":mn,"data-x-position":Zt,"data-index":C,"data-front":Ye,"data-swiping":oe,"data-dismissible":je,"data-type":Le,"data-invert":Ct,"data-swipe-out":ie,"data-swipe-direction":F,"data-expanded":!!(S||O&&L),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${G?He:wt.current}px`,"--initial-height":O?"auto":`${$e}px`,...R,...p.style},onDragEnd:()=>{se(!1),A(null),It.current=null},onPointerDown:xe=>{ee||!je||(St.current=new Date,_e(wt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(se(!0),It.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,ce,Ie,it;if(ie||!je)return;It.current=null;let Se=Number(((xe=Ke.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ne=Number(((ce=Ke.current)==null?void 0:ce.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Fe=new Date().getTime()-((Ie=St.current)==null?void 0:Ie.getTime()),ve=B==="x"?Se:Ne,Qe=Math.abs(ve)/Fe;if(Math.abs(ve)>=sN||Qe>.11){_e(wt.current),(it=p.onDismiss)==null||it.call(p,p),W(B==="x"?Se>0?"right":"left":Ne>0?"down":"up"),he(),le(!0),De(!1);return}se(!1),A(null)},onPointerMove:xe=>{var ce,Ie,it,Se;if(!It.current||!je||((ce=window.getSelection())==null?void 0:ce.toString().length)>0)return;let Ne=xe.clientY-It.current.y,Fe=xe.clientX-It.current.x,ve=(Ie=e.swipeDirections)!=null?Ie:aN(K);!B&&(Math.abs(Fe)>1||Math.abs(Ne)>1)&&A(Math.abs(Fe)>Math.abs(Ne)?"x":"y");let Qe={x:0,y:0};B==="y"?(ve.includes("top")||ve.includes("bottom"))&&(ve.includes("top")&&Ne<0||ve.includes("bottom")&&Ne>0)&&(Qe.y=Ne):B==="x"&&(ve.includes("left")||ve.includes("right"))&&(ve.includes("left")&&Fe<0||ve.includes("right")&&Fe>0)&&(Qe.x=Fe),(Math.abs(Qe.x)>0||Math.abs(Qe.y)>0)&&De(!0),(it=Ke.current)==null||it.style.setProperty("--swipe-amount-x",`${Qe.x}px`),(Se=Ke.current)==null||Se.style.setProperty("--swipe-amount-y",`${Qe.y}px`)}},st&&!p.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ee,"data-close-button":!0,onClick:ee||!je?()=>{}:()=>{var xe;he(),(xe=p.onDismiss)==null||xe.call(p,p)},className:hn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=Y==null?void 0:Y.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,Le||p.icon||p.promise?w.createElement("div",{"data-icon":"",className:hn(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||tt():null,p.type!=="loading"?p.icon||(Y==null?void 0:Y[Le])||$I(Le):null):null,w.createElement("div",{"data-content":"",className:hn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:hn(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:hn(X,Rt,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||D,onClick:xe=>{var ce,Ie;vi(p.cancel)&&je&&((Ie=(ce=p.cancel).onClick)==null||Ie.call(ce,xe),he())},className:hn(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||$,onClick:xe=>{var ce,Ie;vi(p.action)&&((Ie=(ce=p.action).onClick)==null||Ie.call(ce,xe),!xe.defaultPrevented&&he())},className:hn(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([]),j=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[R,D]=w.useState([]),[$,U]=w.useState(!1),[X,M]=w.useState(!1),[K,q]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=w.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),Y=w.useRef(!1),J=w.useCallback(P=>{E(B=>{var A;return(A=B.find(F=>F.id===P.id))!=null&&A.delete||Ut.dismiss(P.id),B.filter(({id:F})=>F!==P.id)})},[]);return w.useEffect(()=>Ut.subscribe(P=>{if(P.dismiss){E(B=>B.map(A=>A.id===P.id?{...A,delete:!0}:A));return}setTimeout(()=>{Do.flushSync(()=>{E(B=>{let A=B.findIndex(F=>F.id===P.id);return A!==-1?[...B.slice(0,A),{...B[A],...P},...B.slice(A+1)]:[P,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:B})=>{q(B?"dark":"light")})}catch{P.addListener(({matches:A})=>{try{q(A?"dark":"light")}catch(F){console.error(F)}})}},[d]),w.useEffect(()=>{T.length<=1&&U(!1)},[T]),w.useEffect(()=>{let P=B=>{var A,F;o.every(W=>B[W]||B.code===W)&&(U(!0),(A=z.current)==null||A.focus()),B.code==="Escape"&&(document.activeElement===z.current||(F=z.current)!=null&&F.contains(document.activeElement))&&U(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),w.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,Y.current=!1)}},[z.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,B)=>{var A;let[F,W]=P.split("-");return T.length?w.createElement("ol",{key:P,dir:x==="auto"?ox():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":F,"data-lifted":$&&T.length>1&&!s,"data-x-position":W,style:{"--front-toast-height":`${((A=R[0])==null?void 0:A.height)||0}px`,"--width":`${rN}px`,"--gap":`${y}px`,...p,...cN(l,c)},onBlur:L=>{Y.current&&!L.currentTarget.contains(L.relatedTarget)&&(Y.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:L=>{L.target instanceof HTMLElement&&L.target.dataset.dismissible==="false"||Y.current||(Y.current=!0,I.current=L.relatedTarget)},onMouseEnter:()=>U(!0),onMouseMove:()=>U(!0),onMouseLeave:()=>{X||U(!1)},onDragEnd:()=>U(!1),onPointerDown:L=>{L.target instanceof HTMLElement&&L.target.dataset.dismissible==="false"||M(!0)},onPointerUp:()=>M(!1)},T.filter(L=>!L.position&&B===0||L.position===P).map((L,_)=>{var G,Z;return w.createElement(lN,{key:L.id,icons:C,index:_,toast:L,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:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:X,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(oe=>oe.position==L.position),heights:R.filter(oe=>oe.position==L.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:b,expanded:$,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=Ih,H.Badge=$h,H.Button=Xe,H.Card=dl,H.CardContent=Qs,H.CardDescription=hl,H.CardHeader=fl,H.CardTitle=pl,H.ChatApi=Xo,H.ChatApp=Vk,H.ChatInput=qf,H.ChatInputRow=Gf,H.ChatInterface=Lr,H.ChatProviders=Sr,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=sl,H.DialogContent=Us,H.DialogHeader=Ws,H.DialogTitle=Vs,H.DropdownMenu=ks,H.DropdownMenuContent=go,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=Es,H.FileViewerModal=fh,H.HISTORY_TIMEOUT_MS=tu,H.Input=Dl,H.InterruptPartRenderer=jh,H.Label=vm,H.MarkdownContent=cr,H.MessageComponent=ei,H.MessageList=xl,H.MessageRow=gl,H.NewChatButton=Yk,H.PlotArtifact=Eh,H.SETTINGS_STORAGE_KEY=Wi,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=Nh,H.Switch=xg,H.Textarea=ja,H.ThinkingIndicator=Ph,H.ThreadListItem=fm,H.ThreadManager=ii,H.ThreadStateProvider=Au,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=qt,H.getChatToken=Zc,H.getCheckpointForMessage=fx,H.getCurrentSettings=Iw,H.getDefaultApiConfig=$u,H.getDefaultChatSettings=Fu,H.getFileContent=Li,H.getFileInfo=Yv,H.getMessageAttemptInfo=oc,H.getMessageDomKey=ml,H.getPreviewForMessage=bi,H.httpClient=Kt,H.hydrateHistorySnapshots=Yn,H.isEnvelope=cu,H.listFiles=ou,H.loadStoredSettings=Bu,H.onChatTokenChanged=Qc,H.post=Yo,H.processAttachments=lu,H.put=nu,H.readNumber=ic,H.readString=Rn,H.resolveChatBaseUrl=xn,H.saveSettings=zu,H.setChatToken=Go,H.toPlainObject=_n,H.unwrap=Mt,H.useApi=Qr,H.useCheckpointIndex=sc,H.useFilePreview=Rh,H.useHasChatSession=Tw,H.useParsedMessageContent=Mh,H.useShallowStableValue=Mu,H.useStream=Ui,H.useStreamingHook=Ui,H.useThreadHistoryState=ku,H.useThreadManagerViewState=mm,H.useThreadState=ro,H.useThreadStateUpdater=Nu,H.useThreads=wr,H.useThreadsState=mu,H.viewFileById=Gv,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|