teodor-new-chat-ui 4.3.442 → 4.3.443
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/messaging/components/message/MessageList.d.ts +2 -0
- package/dist/index.esm.js +2049 -2043
- package/dist/index.umd.js +19 -19
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(F,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("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],w):(F=typeof globalThis<"u"?globalThis:F||self,w(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,w,Yt,zr,tx,nx,Po,
|
|
1
|
+
(function(F,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("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],w):(F=typeof globalThis<"u"?globalThis:F||self,w(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,w,Yt,zr,tx,nx,Po,de){"use strict";var GI=Object.defineProperty;var YI=(F,w,Yt)=>w in F?GI(F,w,{enumerable:!0,configurable:!0,writable:!0,value:Yt}):F[w]=Yt;var Qg=(F,w,Yt)=>YI(F,typeof w!="symbol"?w+"":w,Yt);function Jl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Jl(w),Hr=Jl(Po),Zl=120;function rx(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>Zl?`${n.slice(0,Zl-3)}…`:n:""}function pi(e){return rx(e.content)||""}function ox(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=pi(o);s&&t.set(r.checkpointId,s)}}return t}function Ql(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],h=d.checkpointId,m=h??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.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 S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:x};if(o.push(C),h&&t.set(h,C),h&&y){const T=pi(y);T&&r.set(h,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((h,m)=>{const f=h.createdAt?Date.parse(h.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let h=0;h<c.length;h++){const m=c[h];m.attemptCount=d,m.attemptIndex=h,m.isLatestAttempt=h===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 h of t.values())h.userMessageId===c&&d.push(h);return d.length?(d.sort((h,m)=>{const f=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function ec(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 sx(e,t){return e?t.getCheckpoint(e)??null:null}function tc(e){return w.useMemo(()=>Ql(e),[e])}function Pn(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Mn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function nc(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 mi(e){const t=Pn(e);if(t)return Pn(t.configurable)??t}function Rn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>ix(s,i)).filter(s=>!!s)].sort((s,i)=>rc(i.createdAt)-rc(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 ix(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>ax(k)).filter(k=>!!k),o=Pn(e.metadata)??{},s=mi(e.config),i=Pn(e.parent_config??e.parentConfig),a=mi(i),l=Mn(s,["checkpoint_id","checkpointId"]),c=Mn(s,["checkpoint_ns","checkpointNs"]),d=Mn(a,["checkpoint_id","checkpointId"]),h=Mn(a,["checkpoint_id","checkpointId"])??null,m=Mn(a,["checkpoint_ns","checkpointNs"])??null,f=Pn(e.config),v=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:nc(o,["step"])??0,source:Mn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:h,nextCursorNs:m,interrupt:dx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function ax(e){var s,i,a;if(!e||typeof e!="object")return null;const t=lx(e);if(!t)return null;const n=ux(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 lx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&cx(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 cx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function ux(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function dx(e,t){return fx(e,t)}function fx(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 rc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var gi={exports:{}},Ur={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -14,29 +14,29 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var sc;function px(){return sc||(sc=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"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var Q=v&&A[v]||A[g];return typeof Q=="function"?Q:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var Q=arguments.length,
|
|
18
|
-
`+
|
|
17
|
+
*/var sc;function px(){return sc||(sc=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"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var Q=v&&A[v]||A[g];return typeof Q=="function"?Q:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var Q=arguments.length,fe=new Array(Q>1?Q-1:0),Ie=1;Ie<Q;Ie++)fe[Ie-1]=arguments[Ie];S("error",A,fe)}}function S(A,Q,fe){{var Ie=y.ReactDebugCurrentFrame,Ye=Ie.getStackAddendum();Ye!==""&&(Q+="%s",fe=fe.concat([Ye]));var tt=fe.map(function(Ue){return String(Ue)});tt.unshift("Warning: "+Q),Function.prototype.apply.call(console[A],console,tt)}}var k=!1,C=!1,T=!1,E=!1,j=!1,M;M=Symbol.for("react.module.reference");function L(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||j||A===o||A===c||A===d||E||A===f||k||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===h||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===M||A.getModuleId!==void 0))}function H(A,Q,fe){var Ie=A.displayName;if(Ie)return Ie;var Ye=Q.displayName||Q.name||"";return Ye!==""?fe+"("+Ye+")":fe}function B(A){return A.displayName||"Context"}function q(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){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 A=="object")switch(A.$$typeof){case a:var Q=A;return B(Q)+".Consumer";case i:var fe=A;return B(fe._context)+".Provider";case l:return H(A,A.render,"ForwardRef");case h:var Ie=A.displayName||null;return Ie!==null?Ie:q(A.type)||"Memo";case m:{var Ye=A,tt=Ye._payload,Ue=Ye._init;try{return q(Ue(tt))}catch{return null}}}return null}var N=Object.assign,z=0,$,R,P,I,V,J,_;function O(){}O.__reactDisabledLog=!0;function K(){{if(z===0){$=console.log,R=console.info,P=console.warn,I=console.error,V=console.group,J=console.groupCollapsed,_=console.groupEnd;var A={configurable:!0,enumerable:!0,value:O,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}z++}}function Y(){{if(z--,z===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},A,{value:$}),info:N({},A,{value:R}),warn:N({},A,{value:P}),error:N({},A,{value:I}),group:N({},A,{value:V}),groupCollapsed:N({},A,{value:J}),groupEnd:N({},A,{value:_})})}z<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=y.ReactCurrentDispatcher,W;function D(A,Q,fe){{if(W===void 0)try{throw Error()}catch(Ye){var Ie=Ye.stack.trim().match(/\n( *(at )?)/);W=Ie&&Ie[1]||""}return`
|
|
18
|
+
`+W+A}}var X=!1,oe;{var G=typeof WeakMap=="function"?WeakMap:Map;oe=new G}function Z(A,Q){if(!A||X)return"";{var fe=oe.get(A);if(fe!==void 0)return fe}var Ie;X=!0;var Ye=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var tt;tt=ae.current,ae.current=null,K();try{if(Q){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch(Gt){Ie=Gt}Reflect.construct(A,[],Ue)}else{try{Ue.call()}catch(Gt){Ie=Gt}A.call(Ue.prototype)}}else{try{throw Error()}catch(Gt){Ie=Gt}A()}}catch(Gt){if(Gt&&Ie&&typeof Gt.stack=="string"){for(var le=Gt.stack.split(`
|
|
19
19
|
`),Ce=Ie.stack.split(`
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
20
|
+
`),we=le.length-1,ze=Ce.length-1;we>=1&&ze>=0&&le[we]!==Ce[ze];)ze--;for(;we>=1&&ze>=0;we--,ze--)if(le[we]!==Ce[ze]){if(we!==1||ze!==1)do if(we--,ze--,ze<0||le[we]!==Ce[ze]){var At=`
|
|
21
|
+
`+le[we].replace(" at new "," at ");return A.displayName&&At.includes("<anonymous>")&&(At=At.replace("<anonymous>",A.displayName)),typeof A=="function"&&oe.set(A,At),At}while(we>=1&&ze>=0);break}}}finally{X=!1,ae.current=tt,Y(),Error.prepareStackTrace=Ye}var jt=A?A.displayName||A.name:"",hr=jt?D(jt):"";return typeof A=="function"&&oe.set(A,hr),hr}function te(A,Q,fe){return Z(A,!1)}function se(A){var Q=A.prototype;return!!(Q&&Q.isReactComponent)}function ue(A,Q,fe){if(A==null)return"";if(typeof A=="function")return Z(A,se(A));if(typeof A=="string")return D(A);switch(A){case c:return D("Suspense");case d:return D("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return te(A.render);case h:return ue(A.type,Q,fe);case m:{var Ie=A,Ye=Ie._payload,tt=Ie._init;try{return ue(tt(Ye),Q,fe)}catch{}}}return""}var ge=Object.prototype.hasOwnProperty,Re={},Oe=y.ReactDebugCurrentFrame;function Te(A){if(A){var Q=A._owner,fe=ue(A.type,A._source,Q?Q.type:null);Oe.setExtraStackFrame(fe)}else Oe.setExtraStackFrame(null)}function nt(A,Q,fe,Ie,Ye){{var tt=Function.call.bind(ge);for(var Ue in A)if(tt(A,Ue)){var le=void 0;try{if(typeof A[Ue]!="function"){var Ce=Error((Ie||"React class")+": "+fe+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ce.name="Invariant Violation",Ce}le=A[Ue](Q,Ue,Ie,fe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(we){le=we}le&&!(le instanceof Error)&&(Te(Ye),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ie||"React class",fe,Ue,typeof le),Te(null)),le instanceof Error&&!(le.message in Re)&&(Re[le.message]=!0,Te(Ye),b("Failed %s type: %s",fe,le.message),Te(null))}}}var ht=Array.isArray;function Tt(A){return ht(A)}function Ke(A){{var Q=typeof Symbol=="function"&&Symbol.toStringTag,fe=Q&&A[Symbol.toStringTag]||A.constructor.name||"Object";return fe}}function Ge(A){try{return Ve(A),!1}catch{return!0}}function Ve(A){return""+A}function $e(A){if(Ge(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ke(A)),Ve(A)}var He=y.ReactCurrentOwner,mt={key:!0,ref:!0,__self:!0,__source:!0},Dt,lt;function kt(A){if(ge.call(A,"ref")){var Q=Object.getOwnPropertyDescriptor(A,"ref").get;if(Q&&Q.isReactWarning)return!1}return A.ref!==void 0}function bt(A){if(ge.call(A,"key")){var Q=Object.getOwnPropertyDescriptor(A,"key").get;if(Q&&Q.isReactWarning)return!1}return A.key!==void 0}function gt(A,Q){typeof A.ref=="string"&&He.current}function pt(A,Q){{var fe=function(){Dt||(Dt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};fe.isReactWarning=!0,Object.defineProperty(A,"key",{get:fe,configurable:!0})}}function an(A,Q){{var fe=function(){lt||(lt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};fe.isReactWarning=!0,Object.defineProperty(A,"ref",{get:fe,configurable:!0})}}var dt=function(A,Q,fe,Ie,Ye,tt,Ue){var le={$$typeof:t,type:A,key:Q,ref:fe,props:Ue,_owner:tt};return le._store={},Object.defineProperty(le._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(le,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(le,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ye}),Object.freeze&&(Object.freeze(le.props),Object.freeze(le)),le};function ke(A,Q,fe,Ie,Ye){{var tt,Ue={},le=null,Ce=null;fe!==void 0&&($e(fe),le=""+fe),bt(Q)&&($e(Q.key),le=""+Q.key),kt(Q)&&(Ce=Q.ref,gt(Q,Ye));for(tt in Q)ge.call(Q,tt)&&!mt.hasOwnProperty(tt)&&(Ue[tt]=Q[tt]);if(A&&A.defaultProps){var we=A.defaultProps;for(tt in we)Ue[tt]===void 0&&(Ue[tt]=we[tt])}if(le||Ce){var ze=typeof A=="function"?A.displayName||A.name||"Unknown":A;le&&pt(Ue,ze),Ce&&an(Ue,ze)}return dt(A,le,Ce,Ye,Ie,He.current,Ue)}}var et=y.ReactCurrentOwner,Ae=y.ReactDebugCurrentFrame;function Le(A){if(A){var Q=A._owner,fe=ue(A.type,A._source,Q?Q.type:null);Ae.setExtraStackFrame(fe)}else Ae.setExtraStackFrame(null)}var Bt;Bt=!1;function re(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function ye(){{if(et.current){var A=q(et.current.type);if(A)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+A+"`."}return""}}function rt(A){return""}var
|
|
23
|
+
Check the render method of \``+A+"`."}return""}}function rt(A){return""}var xe={};function Pe(A){{var Q=ye();if(!Q){var fe=typeof A=="string"?A:A.displayName||A.name;fe&&(Q=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+fe+">.")}return Q}}function Xe(A,Q){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var fe=Pe(Q);if(xe[fe])return;xe[fe]=!0;var Ie="";A&&A._owner&&A._owner!==et.current&&(Ie=" It was passed a child from "+q(A._owner.type)+"."),Le(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',fe,Ie),Le(null)}}function St(A,Q){{if(typeof A!="object")return;if(Tt(A))for(var fe=0;fe<A.length;fe++){var Ie=A[fe];re(Ie)&&Xe(Ie,Q)}else if(re(A))A._store&&(A._store.validated=!0);else if(A){var Ye=x(A);if(typeof Ye=="function"&&Ye!==A.entries)for(var tt=Ye.call(A),Ue;!(Ue=tt.next()).done;)re(Ue.value)&&Xe(Ue.value,Q)}}}function Et(A){{var Q=A.type;if(Q==null||typeof Q=="string")return;var fe;if(typeof Q=="function")fe=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===l||Q.$$typeof===h))fe=Q.propTypes;else return;if(fe){var Ie=q(Q);nt(fe,A.props,"prop",Ie,A)}else if(Q.PropTypes!==void 0&&!Bt){Bt=!0;var Ye=q(Q);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ye||"Unknown")}typeof Q.getDefaultProps=="function"&&!Q.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nt(A){{for(var Q=Object.keys(A.props),fe=0;fe<Q.length;fe++){var Ie=Q[fe];if(Ie!=="children"&&Ie!=="key"){Le(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),Le(null);break}}A.ref!==null&&(Le(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),Le(null))}}var zt={};function _e(A,Q,fe,Ie,Ye,tt){{var Ue=L(A);if(!Ue){var le="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(le+=" 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 Ce=rt();Ce?le+=Ce:le+=ye();var we;A===null?we="null":Tt(A)?we="array":A!==void 0&&A.$$typeof===t?(we="<"+(q(A.type)||"Unknown")+" />",le=" Did you accidentally export a JSX literal instead of a component?"):we=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",we,le)}var ze=ke(A,Q,fe,Ye,tt);if(ze==null)return ze;if(Ue){var At=Q.children;if(At!==void 0)if(Ie)if(Tt(At)){for(var jt=0;jt<At.length;jt++)St(At[jt],A);Object.freeze&&Object.freeze(At)}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 St(At,A)}if(ge.call(Q,"key")){var hr=q(A),Gt=Object.keys(Q).filter(function(qI){return qI!=="key"}),Xl=Gt.length>0?"{key: someKey, "+Gt.join(": ..., ")+": ...}":"{key: someKey}";if(!zt[hr+Xl]){var KI=Gt.length>0?"{"+Gt.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} />`,Xl,hr,KI,hr),zt[hr+Xl]=!0}}return A===r?At(Fe):It(Fe),Fe}}function ct(A,Q,de){return _e(A,Q,de,!0)}function Je(A,Q,de){return _e(A,Q,de,!1)}var ft=Je,ln=ct;Wr.Fragment=r,Wr.jsx=ft,Wr.jsxs=ln}()),Wr}process.env.NODE_ENV==="production"?gi.exports=hx():gi.exports=px();var u=gi.exports;const mx=({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(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ic(e,t){return function(){return e.apply(t,arguments)}}const{toString:gx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Mo,toStringTag:ac}=Symbol,Ro=(e=>t=>{const n=gx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>Ro(t)===e),Oo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Oo("undefined");function Vr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=cn("ArrayBuffer");function xx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const vx=Oo("string"),Ht=Oo("function"),cc=Oo("number"),Kr=e=>e!==null&&typeof e=="object",wx=e=>e===!0||e===!1,Do=e=>{if(Ro(e)!=="object")return!1;const t=xi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ac in e)&&!(Mo in e)},bx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},yx=cn("Date"),Sx=cn("File"),Cx=cn("Blob"),Tx=cn("FileList"),kx=e=>Kr(e)&&Ht(e.pipe),Ex=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Ro(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Ix=cn("URLSearchParams"),[Nx,Ax,jx,_x]=["ReadableStream","Request","Response","Headers"].map(cn),Px=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(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 uc(e,t){if(Vr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!mr(e)&&e!==Jn;function vi(){const{caseless:e,skipUndefined:t}=dc(this)&&this||{},n={},r=(o,s)=>{const i=e&&uc(n,s)||s;Do(n[i])&&Do(o)?n[i]=vi(n[i],o):Do(o)?n[i]=vi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Mx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ht(o)?e[s]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Rx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ox=(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)},Dx=(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&&xi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Lx=(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},$x=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!cc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Fx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),Bx=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},zx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Hx=cn("HTMLFormElement"),Ux=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),fc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Wx=cn("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Vx=e=>{hc(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(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+"'")})}})},Kx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},qx=()=>{},Gx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Yx(e){return!!(e&&Ht(e.append)&&e[ac]==="FormData"&&e[Mo])}const Xx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Jx=cn("AsyncFunction"),Zx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),pc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Jn.postMessage)),Qx=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||pc,z={isArray:pr,isArrayBuffer:lc,isBuffer:Vr,isFormData:Ex,isArrayBufferView:xx,isString:vx,isNumber:cc,isBoolean:wx,isObject:Kr,isPlainObject:Do,isEmptyObject:bx,isReadableStream:Nx,isRequest:Ax,isResponse:jx,isHeaders:_x,isUndefined:mr,isDate:yx,isFile:Sx,isBlob:Cx,isRegExp:Wx,isFunction:Ht,isStream:kx,isURLSearchParams:Ix,isTypedArray:Fx,isFileList:Tx,forEach:qr,merge:vi,extend:Mx,trim:Px,stripBOM:Rx,inherits:Ox,toFlatObject:Dx,kindOf:Ro,kindOfTest:cn,endsWith:Lx,toArray:$x,forEachEntry:Bx,matchAll:zx,isHTMLForm:Hx,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:hc,freezeMethods:Vx,toObjectSet:Kx,toCamelCase:Ux,noop:qx,toFiniteNumber:Gx,findKey:uc,global:Jn,isContextDefined:dc,isSpecCompliantForm:Yx,toJSONObject:Xx,isAsyncFn:Jx,isThenable:Zx,setImmediate:pc,asap:Qx,isIterable:e=>e!=null&&Ht(e[Mo])};function Me(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)}z.inherits(Me,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:z.toJSONObject(this.config),code:this.code,status:this.status}}});const mc=Me.prototype,gc={};["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=>{gc[e]={value:e}}),Object.defineProperties(Me,gc),Object.defineProperty(mc,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(mc);z.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 Me.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 ev=null;function wi(e){return z.isPlainObject(e)||z.isArray(e)}function xc(e){return z.endsWith(e,"[]")?e.slice(0,-2):e}function vc(e,t,n){return e?e.concat(t).map(function(o,s){return o=xc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function tv(e){return z.isArray(e)&&!e.some(wi)}const nv=z.toFlatObject(z,{},null,function(t){return/^is[A-Z]/.test(t)});function Lo(e,t,n){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!z.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(z.isDate(v))return v.toISOString();if(z.isBoolean(v))return v.toString();if(!l&&z.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(v)||z.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(z.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(z.isArray(v)&&tv(v)||(z.isFileList(v)||z.endsWith(g,"[]"))&&(y=z.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(z.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return wi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(nv,{defaultVisitor:d,convertValue:c,isVisitable:wi});function f(v,g){if(!z.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),z.forEach(v,function(y,b){(!(z.isUndefined(y)||y===null)&&o.call(t,y,z.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),h.pop()}}if(!z.isObject(e))throw new TypeError("data must be an object");return f(e),t}function wc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function bi(e,t){this._pairs=[],e&&Lo(e,this,t)}const bc=bi.prototype;bc.append=function(t,n){this._pairs.push([t,n])},bc.toString=function(t){const n=t?function(r){return t.call(this,r,wc)}:wc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function rv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yc(e,t,n){if(!t)return e;const r=n&&n.encode||rv;z.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=z.isURLSearchParams(t)?t.toString():new bi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Sc{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){z.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ov={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:bi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yi=typeof window<"u"&&typeof document<"u",Si=typeof navigator=="object"&&navigator||void 0,sv=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),iv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",av=yi&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:sv,hasStandardBrowserWebWorkerEnv:iv,navigator:Si,origin:av},Symbol.toStringTag,{value:"Module"})),...ov};function lv(e,t){return Lo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&z.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function cv(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function uv(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 Tc(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&&z.isArray(o)?o.length:i,l?(z.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!z.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&z.isArray(o[i])&&(o[i]=uv(o[i])),!a)}if(z.isFormData(e)&&z.isFunction(e.entries)){const n={};return z.forEachEntry(e,(r,o)=>{t(cv(r),o,n,0)}),n}return null}function dv(e,t,n){if(z.isString(e))try{return(t||JSON.parse)(e),z.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=z.isObject(t);if(s&&z.isHTMLForm(t)&&(t=new FormData(t)),z.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(z.isArrayBuffer(t)||z.isBuffer(t)||z.isStream(t)||z.isFile(t)||z.isBlob(t)||z.isReadableStream(t))return t;if(z.isArrayBufferView(t))return t.buffer;if(z.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 lv(t,this.formSerializer).toString();if((a=z.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),dv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(z.isResponse(t)||z.isReadableStream(t))return t;if(t&&z.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"?Me.from(a,Me.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const fv=z.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"]),hv=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]&&fv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},kc=Symbol("internals");function Yr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:
|
|
32
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[kc]=this[kc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(xv(o,i),r[a]=!0)}return z.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),z.freezeMethods(Ut);function Ti(e,t){const n=this||Gr,r=t||n,o=Ut.from(r.headers);let s=r.data;return z.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ec(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}z.inherits(gr,Me,{__CANCEL__:!0});function Ic(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function vv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function wv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let h=s,m=0;for(;h!==o;)m+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function bv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const Fo=(e,t,n=3)=>{let r=0;const o=wv(50,250);return bv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Nc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ac=e=>(...t)=>z.asap(()=>e(...t)),yv=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Sv=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];z.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),z.isString(r)&&i.push("path="+r),z.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 Cv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!Cv(t);return e&&(r||n==!1)?Tv(e,t):t}const _c=e=>e instanceof Ut?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,h,m){return z.isPlainObject(c)&&z.isPlainObject(d)?z.merge.call({caseless:m},c,d):z.isPlainObject(d)?z.merge({},d):z.isArray(d)?d.slice():d}function o(c,d,h,m){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!z.isUndefined(d))return r(void 0,d)}function i(c,d){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,h){if(h in t)return r(c,d);if(h in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,h)=>o(_c(c),_c(d),h,!0)};return z.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);z.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Pc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=yc(jc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),z.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(_t.hasStandardBrowserEnv&&(r&&z.isFunction(r)&&(r=r(t)),r||r!==!1&&yv(t.url))){const l=o&&s&&Sv.read(s);l&&i.set(o,l)}return t},kv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pc(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Ut.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Ic(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Me("Request aborted",Me.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Me(C,Me.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Cc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Me(k,C.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&z.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),z.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Fo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=Fo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=vv(o.url);if(b&&_t.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Ev=(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 Me?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.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=()=>z.asap(a),l}},Iv=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},Nv=async function*(e,t){for await(const n of Av(e))yield*Iv(n,t)},Av=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()}},Mc=(e,t,n,r)=>{const o=Nv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let h=d.byteLength;if(n){let m=s+=h;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Rc=64*1024,{isFunction:Bo}=z,jv=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:Oc,TextEncoder:Dc}=z.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},_v=e=>{e=z.merge.call({skipUndefined:!0},jv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Bo(t):typeof fetch=="function",s=Bo(n),i=Bo(r);if(!o)return!1;const a=o&&Bo(Oc),l=o&&(typeof Dc=="function"?(v=>g=>v.encode(g))(new Dc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Lc(()=>{let v=!1;const g=new n(_t.origin,{body:new Oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Lc(()=>z.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Me(`Response type '${v}' is not supported`,Me.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(z.isBlob(v))return v.size;if(z.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(z.isArrayBufferView(v)||z.isArrayBuffer(v))return v.byteLength;if(z.isURLSearchParams(v)&&(v=v+""),z.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=z.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:M="same-origin",fetchOptions:L}=Pc(v),B=t||fetch;E=E?(E+"").toLowerCase():"text";let W=Ev([b,S&&S.toAbortSignal()],k),K=null;const N=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let U;try{if(T&&c&&x!=="get"&&x!=="head"&&(U=await f(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(z.isFormData(y)&&(_=J.headers.get("content-type"))&&j.setContentType(_),J.body){const[R,G]=Nc(U,Fo(Ac(T)));y=Mc(J.body,Rc,R,G)}}z.isString(M)||(M=M?"include":"omit");const $=s&&"credentials"in n.prototype,O={...L,signal:W,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:$?M:void 0};K=s&&new n(g,O);let P=await(s?B(K,L):B(g,O));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&N)){const J={};["status","statusText","headers"].forEach(X=>{J[X]=P[X]});const _=z.toFiniteNumber(P.headers.get("content-length")),[R,G]=C&&Nc(_,Fo(Ac(C),!0))||[];P=new r(Mc(P.body,Rc,R,()=>{G&&G(),N&&N()}),J)}E=E||"text";let q=await h[z.findKey(h,E)||"text"](P,v);return!I&&N&&N(),await new Promise((J,_)=>{Ic(J,_,{data:q,headers:Ut.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:K})})}catch($){throw N&&N(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,K),{cause:$.cause||$}):Me.from($,$&&$.code,v,K)}}},Pv=new Map,$c=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=Pv;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};$c();const ki={http:ev,xhr:kv,fetch:{get:$c}};z.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Mv=e=>z.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=z.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,!Mv(r)&&(o=ki[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`Unknown adapter '${a}'`);if(o&&(z.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} />`,Xl,hr,KI,hr),zt[hr+Xl]=!0}}return A===r?Nt(ze):Et(ze),ze}}function ct(A,Q,fe){return _e(A,Q,fe,!0)}function Je(A,Q,fe){return _e(A,Q,fe,!1)}var ft=Je,ln=ct;Wr.Fragment=r,Wr.jsx=ft,Wr.jsxs=ln}()),Wr}process.env.NODE_ENV==="production"?gi.exports=hx():gi.exports=px();var u=gi.exports;const mx=({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(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ic(e,t){return function(){return e.apply(t,arguments)}}const{toString:gx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Mo,toStringTag:ac}=Symbol,Ro=(e=>t=>{const n=gx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>Ro(t)===e),Oo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Oo("undefined");function Vr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=cn("ArrayBuffer");function xx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const vx=Oo("string"),Ht=Oo("function"),cc=Oo("number"),Kr=e=>e!==null&&typeof e=="object",wx=e=>e===!0||e===!1,Do=e=>{if(Ro(e)!=="object")return!1;const t=xi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ac in e)&&!(Mo in e)},bx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},yx=cn("Date"),Sx=cn("File"),Cx=cn("Blob"),Tx=cn("FileList"),kx=e=>Kr(e)&&Ht(e.pipe),Ex=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Ro(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Ix=cn("URLSearchParams"),[Nx,Ax,jx,_x]=["ReadableStream","Request","Response","Headers"].map(cn),Px=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(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 uc(e,t){if(Vr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!mr(e)&&e!==Jn;function vi(){const{caseless:e,skipUndefined:t}=dc(this)&&this||{},n={},r=(o,s)=>{const i=e&&uc(n,s)||s;Do(n[i])&&Do(o)?n[i]=vi(n[i],o):Do(o)?n[i]=vi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Mx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ht(o)?e[s]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Rx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ox=(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)},Dx=(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&&xi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Lx=(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},$x=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!cc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Fx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),Bx=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},zx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Hx=cn("HTMLFormElement"),Ux=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),fc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Wx=cn("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Vx=e=>{hc(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(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+"'")})}})},Kx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},qx=()=>{},Gx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Yx(e){return!!(e&&Ht(e.append)&&e[ac]==="FormData"&&e[Mo])}const Xx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Jx=cn("AsyncFunction"),Zx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),pc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Jn.postMessage)),Qx=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||pc,U={isArray:pr,isArrayBuffer:lc,isBuffer:Vr,isFormData:Ex,isArrayBufferView:xx,isString:vx,isNumber:cc,isBoolean:wx,isObject:Kr,isPlainObject:Do,isEmptyObject:bx,isReadableStream:Nx,isRequest:Ax,isResponse:jx,isHeaders:_x,isUndefined:mr,isDate:yx,isFile:Sx,isBlob:Cx,isRegExp:Wx,isFunction:Ht,isStream:kx,isURLSearchParams:Ix,isTypedArray:Fx,isFileList:Tx,forEach:qr,merge:vi,extend:Mx,trim:Px,stripBOM:Rx,inherits:Ox,toFlatObject:Dx,kindOf:Ro,kindOfTest:cn,endsWith:Lx,toArray:$x,forEachEntry:Bx,matchAll:zx,isHTMLForm:Hx,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:hc,freezeMethods:Vx,toObjectSet:Kx,toCamelCase:Ux,noop:qx,toFiniteNumber:Gx,findKey:uc,global:Jn,isContextDefined:dc,isSpecCompliantForm:Yx,toJSONObject:Xx,isAsyncFn:Jx,isThenable:Zx,setImmediate:pc,asap:Qx,isIterable:e=>e!=null&&Ht(e[Mo])};function Me(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}U.inherits(Me,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:U.toJSONObject(this.config),code:this.code,status:this.status}}});const mc=Me.prototype,gc={};["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=>{gc[e]={value:e}}),Object.defineProperties(Me,gc),Object.defineProperty(mc,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(mc);U.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Me.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 ev=null;function wi(e){return U.isPlainObject(e)||U.isArray(e)}function xc(e){return U.endsWith(e,"[]")?e.slice(0,-2):e}function vc(e,t,n){return e?e.concat(t).map(function(o,s){return o=xc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function tv(e){return U.isArray(e)&&!e.some(wi)}const nv=U.toFlatObject(U,{},null,function(t){return/^is[A-Z]/.test(t)});function Lo(e,t,n){if(!U.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=U.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!U.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&U.isSpecCompliantForm(t);if(!U.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(U.isDate(v))return v.toISOString();if(U.isBoolean(v))return v.toString();if(!l&&U.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return U.isArrayBuffer(v)||U.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(U.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(U.isArray(v)&&tv(v)||(U.isFileList(v)||U.endsWith(g,"[]"))&&(y=U.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(U.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return wi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(nv,{defaultVisitor:d,convertValue:c,isVisitable:wi});function f(v,g){if(!U.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),U.forEach(v,function(y,b){(!(U.isUndefined(y)||y===null)&&o.call(t,y,U.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),h.pop()}}if(!U.isObject(e))throw new TypeError("data must be an object");return f(e),t}function wc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function bi(e,t){this._pairs=[],e&&Lo(e,this,t)}const bc=bi.prototype;bc.append=function(t,n){this._pairs.push([t,n])},bc.toString=function(t){const n=t?function(r){return t.call(this,r,wc)}:wc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function rv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yc(e,t,n){if(!t)return e;const r=n&&n.encode||rv;U.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=U.isURLSearchParams(t)?t.toString():new bi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Sc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){U.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ov={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:bi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yi=typeof window<"u"&&typeof document<"u",Si=typeof navigator=="object"&&navigator||void 0,sv=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),iv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",av=yi&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:sv,hasStandardBrowserWebWorkerEnv:iv,navigator:Si,origin:av},Symbol.toStringTag,{value:"Module"})),...ov};function lv(e,t){return Lo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&U.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function cv(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function uv(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 Tc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&U.isArray(o)?o.length:i,l?(U.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!U.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&U.isArray(o[i])&&(o[i]=uv(o[i])),!a)}if(U.isFormData(e)&&U.isFunction(e.entries)){const n={};return U.forEachEntry(e,(r,o)=>{t(cv(r),o,n,0)}),n}return null}function dv(e,t,n){if(U.isString(e))try{return(t||JSON.parse)(e),U.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=U.isObject(t);if(s&&U.isHTMLForm(t)&&(t=new FormData(t)),U.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)||U.isReadableStream(t))return t;if(U.isArrayBufferView(t))return t.buffer;if(U.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return lv(t,this.formSerializer).toString();if((a=U.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),dv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(U.isResponse(t)||U.isReadableStream(t))return t;if(t&&U.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Me.from(a,Me.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};U.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const fv=U.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),hv=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]&&fv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},kc=Symbol("internals");function Yr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:U.isArray(e)?e.map($o):String(e)}function pv(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 mv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ci(e,t,n,r,o){if(U.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!U.isString(t)){if(U.isString(r))return t.indexOf(r)!==-1;if(U.isRegExp(r))return r.test(t)}}function gv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function xv(e,t){const n=U.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 Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Yr(l);if(!d)throw new Error("header name must be a non-empty string");const h=U.findKey(o,d);(!h||o[h]===void 0||c===!0||c===void 0&&o[h]!==!1)&&(o[h||l]=$o(a))}const i=(a,l)=>U.forEach(a,(c,d)=>s(c,d,l));if(U.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(U.isString(t)&&(t=t.trim())&&!mv(t))i(hv(t),n);else if(U.isObject(t)&&U.isIterable(t)){let a={},l,c;for(const d of t){if(!U.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?U.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=Yr(t),t){const r=U.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return pv(o);if(U.isFunction(n))return n.call(this,o,r);if(U.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Yr(t),t){const r=U.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ci(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Yr(i),i){const a=U.findKey(r,i);a&&(!n||Ci(r,r[a],a,n))&&(delete r[a],o=!0)}}return U.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||Ci(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return U.forEach(this,(o,s)=>{const i=U.findKey(r,s);if(i){n[i]=$o(o),delete n[s];return}const a=t?gv(s):String(s).trim();a!==s&&delete n[s],n[a]=$o(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return U.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&U.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[kc]=this[kc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(xv(o,i),r[a]=!0)}return U.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),U.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),U.freezeMethods(Ut);function Ti(e,t){const n=this||Gr,r=t||n,o=Ut.from(r.headers);let s=r.data;return U.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ec(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}U.inherits(gr,Me,{__CANCEL__:!0});function Ic(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function vv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function wv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let h=s,m=0;for(;h!==o;)m+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function bv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const Fo=(e,t,n=3)=>{let r=0;const o=wv(50,250);return bv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Nc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ac=e=>(...t)=>U.asap(()=>e(...t)),yv=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Sv=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];U.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),U.isString(r)&&i.push("path="+r),U.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Cv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!Cv(t);return e&&(r||n==!1)?Tv(e,t):t}const _c=e=>e instanceof Ut?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,h,m){return U.isPlainObject(c)&&U.isPlainObject(d)?U.merge.call({caseless:m},c,d):U.isPlainObject(d)?U.merge({},d):U.isArray(d)?d.slice():d}function o(c,d,h,m){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!U.isUndefined(d))return r(void 0,d)}function i(c,d){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,h){if(h in t)return r(c,d);if(h in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,h)=>o(_c(c),_c(d),h,!0)};return U.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);U.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Pc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=yc(jc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),U.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(U.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(_t.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&yv(t.url))){const l=o&&s&&Sv.read(s);l&&i.set(o,l)}return t},kv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pc(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Ut.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Ic(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Me("Request aborted",Me.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Me(C,Me.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Cc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Me(k,C.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&U.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),U.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Fo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=Fo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=vv(o.url);if(b&&_t.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Ev=(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 Me?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>U.asap(a),l}},Iv=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},Nv=async function*(e,t){for await(const n of Av(e))yield*Iv(n,t)},Av=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()}},Mc=(e,t,n,r)=>{const o=Nv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let h=d.byteLength;if(n){let m=s+=h;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Rc=64*1024,{isFunction:Bo}=U,jv=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Oc,TextEncoder:Dc}=U.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},_v=e=>{e=U.merge.call({skipUndefined:!0},jv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Bo(t):typeof fetch=="function",s=Bo(n),i=Bo(r);if(!o)return!1;const a=o&&Bo(Oc),l=o&&(typeof Dc=="function"?(v=>g=>v.encode(g))(new Dc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Lc(()=>{let v=!1;const g=new n(_t.origin,{body:new Oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Lc(()=>U.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Me(`Response type '${v}' is not supported`,Me.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(U.isBlob(v))return v.size;if(U.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(U.isArrayBufferView(v)||U.isArrayBuffer(v))return v.byteLength;if(U.isURLSearchParams(v)&&(v=v+""),U.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=U.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:M="same-origin",fetchOptions:L}=Pc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let B=Ev([b,S&&S.toAbortSignal()],k),q=null;const N=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let z;try{if(T&&c&&x!=="get"&&x!=="head"&&(z=await f(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(U.isFormData(y)&&(_=J.headers.get("content-type"))&&j.setContentType(_),J.body){const[O,K]=Nc(z,Fo(Ac(T)));y=Mc(J.body,Rc,O,K)}}U.isString(M)||(M=M?"include":"omit");const $=s&&"credentials"in n.prototype,R={...L,signal:B,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:$?M:void 0};q=s&&new n(g,R);let P=await(s?H(q,L):H(g,R));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&N)){const J={};["status","statusText","headers"].forEach(Y=>{J[Y]=P[Y]});const _=U.toFiniteNumber(P.headers.get("content-length")),[O,K]=C&&Nc(_,Fo(Ac(C),!0))||[];P=new r(Mc(P.body,Rc,O,()=>{K&&K(),N&&N()}),J)}E=E||"text";let V=await h[U.findKey(h,E)||"text"](P,v);return!I&&N&&N(),await new Promise((J,_)=>{Ic(J,_,{data:V,headers:Ut.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:q})})}catch($){throw N&&N(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,q),{cause:$.cause||$}):Me.from($,$&&$.code,v,q)}}},Pv=new Map,$c=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=Pv;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};$c();const ki={http:ev,xhr:kv,fetch:{get:$c}};U.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Mv=e=>U.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=U.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Mv(r)&&(o=ki[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`Unknown adapter '${a}'`);if(o&&(U.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Fc).join(`
|
|
34
34
|
`):" "+Fc(i[0]):"as no adapter specified";throw new Me("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ki};function Ei(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function zc(e){return Ei(e),e.headers=Ut.from(e.headers),e.data=Ti.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Bc.getAdapter(e.adapter||Gr.adapter,e)(e).then(function(r){return Ei(e),r.data=Ti.call(e,e.transformResponse,r),r.headers=Ut.from(r.headers),r},function(r){return Ec(r)||(Ei(e),r&&r.response&&(r.response.data=Ti.call(e,e.transformResponse,r.response),r.response.headers=Ut.from(r.response.headers))),Promise.reject(r)})}const Hc="1.12.2",zo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{zo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Uc={};zo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Hc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Me(o(i," has been removed"+(n?" in "+n:"")),Me.ERR_DEPRECATED);return n&&!Uc[i]&&(Uc[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}},zo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Rv(e,t,n){if(typeof e!="object")throw new Me("options must be an object",Me.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 Me("option "+s+" must be "+l,Me.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Me("Unknown option "+s,Me.ERR_BAD_OPTION)}}const Ho={assertOptions:Rv,validators:zo},vn=Ho.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Sc,response:new Sc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:vn.transitional(vn.boolean),forcedJSONParsing:vn.transitional(vn.boolean),clarifyTimeoutError:vn.transitional(vn.boolean)},!1),o!=null&&(z.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:vn.function,serialize:vn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:vn.spelling("baseURL"),withXsrfToken:vn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&z.merge(s.common,s[n.method]);s&&z.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,h=0,m;if(!l){const v=[zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);h<m;)d=d.then(v[h++],v[h++]);return d}m=a.length;let f=n;for(;h<m;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=zc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,m=c.length;h<m;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Zn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let Ov=class ex{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ex(function(o){t=o}),cancel:t}}};function Dv(e){return function(n){return e.apply(null,n)}}function Lv(e){return z.isObject(e)&&e.isAxiosError===!0}const Ii={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(Ii).forEach(([e,t])=>{Ii[t]=e});function Wc(e){const t=new Qn(e),n=ic(Qn.prototype.request,t);return z.extend(n,Qn.prototype,t,{allOwnKeys:!0}),z.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(Zn(e,o))},n}const vt=Wc(Gr);vt.Axios=Qn,vt.CanceledError=gr,vt.CancelToken=Ov,vt.isCancel=Ec,vt.VERSION=Hc,vt.toFormData=Lo,vt.AxiosError=Me,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=Dv,vt.isAxiosError=Lv,vt.mergeConfig=Zn,vt.AxiosHeaders=Ut,vt.formToJSON=e=>Tc(z.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Bc.getAdapter,vt.HttpStatusCode=Ii,vt.default=vt;const{Axios:nN,AxiosError:rN,CanceledError:oN,isCancel:sN,CancelToken:iN,VERSION:aN,all:lN,Cancel:cN,isAxiosError:uN,spread:dN,toFormData:fN,AxiosHeaders:hN,HttpStatusCode:pN,formToJSON:mN,getAdapter:gN,mergeConfig:xN}=vt,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?wn(Vc):void 0;function wn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Uo=null;const Ni=new Set;function qc(){return Uo}function Wo(e){Uo=e,Ni.forEach(t=>t(e))}function Gc(e){return Ni.add(e),()=>Ni.delete(e)}const Yc=3e4,Xc=9e4,Xt=vt.create({...Kc?{baseURL:Kc}:{},timeout:Yc,withCredentials:!0});Xt.interceptors.request.use(e=>(Uo&&(e.headers.Authorization=`Bearer ${Uo}`),e)),Xt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Wo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vo(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jc(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ai(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?wn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=wn(String(t.baseUrl))),t.authToken!==void 0&&Wo(t.authToken)}getAuthToken(){return qc()}setAuthToken(t){Wo(t)}onTokenChange(t){return Gc(t)}async listThreads(){const t=await Jt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Vo("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Jt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Xc});return Lt(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return Lt(r)}}const On=new Ko,$v=Ko,Fv=Ko;async function ji(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Bv(e,t){const n=await ji(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await ji(`/files/${e}/view`,t)).text()}async function Zc(e,t){const n=await ji(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function zv(e){return await Jt(`/files/${e}`)}async function Qc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const eu=w.createContext(null);function tu({children:e,apiConfig:t}){const n=On;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(eu.Provider,{value:r,children:e})}async function nu(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 ru(e=[]){const t=[],n=[];for(const r of e)try{const o=await nu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=w.useContext(eu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function ou(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Pi(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 Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Hv(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 su(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function iu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function au(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??iu(e);let l="",c=e.slice();if(s){const h=Uv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function lu(e){return e.replace(/\s+/g," ").trim()}function Uv(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=lu(e),o=lu(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 Wv(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 Jr(e,r,s)}return e}function cu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Vv(e={}){const t=w.useMemo(()=>wn(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),[h,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[S,k]=w.useState(null),C=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),j=w.useRef(null),M=w.useRef(null),L=w.useRef(null),B=w.useRef(null),W=w.useRef({messageId:null,lastSeq:null,lastText:""}),K=w.useCallback(O=>{o(O)},[]),N=w.useCallback(()=>{m(""),v(null),d(null),M.current=null,L.current=null,B.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""}},[]),U=w.useCallback(()=>{var O;console.debug("[use-chat] stop() invoked - aborting stream"),(O=C.current)==null||O.abort(),C.current=null,j.current=null,l(!1),b(!1),E.current=0,x(0)},[]),$=w.useCallback((O,P,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),M.current=null,L.current=null,B.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""};const q=new AbortController;C.current=q;let J=null,_=null,R=!1;return j.current={threadId:O.threadId??null,headers:{}},(async()=>{var X,se,V,D,Z,ne,Y,H,ae,le,fe,be,Re,Oe,Te,nt,ht,kt;const G=Ke=>{var Ge;try{const Ve=JSON.parse(JSON.stringify(Ke));return(Ge=Ve==null?void 0:Ve.payload)!=null&&Ge.files_info&&Array.isArray(Ve.payload.files_info)&&(Ve.payload.files_info=Ve.payload.files_info.map($e=>({...$e,data:$e!=null&&$e.data?`<base64 ${String($e.data).length} chars>`:$e==null?void 0:$e.data}))),Ve}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Le=window.__AUTH_TOKEN__,Bt=((X=window.localStorage)==null?void 0:X.getItem("authToken"))||null;let re=null;try{const rt=(se=window.localStorage)==null?void 0:se.getItem("chat-settings");rt&&(re=((V=JSON.parse(rt))==null?void 0:V.apiKey)||null)}catch{}const we=Le||Bt||re||null;we&&(Ke={Authorization:`Bearer ${we}`})}}catch{}console.debug("[use-chat] POST",t+n,G(O));let Ge={};if(typeof window<"u")try{const Ae=(D=window.localStorage)==null?void 0:D.getItem("authSessionId");Ae&&(Ge={"X-Session-Id":Ae})}catch{}const Ve={...Ke,...Ge,...s.current},$e={"Content-Type":"application/json",Accept:"text/event-stream",...Ve},He=await fetch(t+n,{method:"POST",headers:$e,body:JSON.stringify(O),signal:q.signal,credentials:i});if(j.current&&(j.current.headers=Ve),!He.ok||!He.body){const Ae=await He.text().catch(()=>"");console.debug("[use-chat] non-OK response",He.status,Ae==null?void 0:Ae.slice(0,500));const Le=`stream ${He.status}${Ae?": "+Ae:""}`;throw(Z=I==null?void 0:I.onConnectionError)==null||Z.call(I,Le),R=!0,J="error",_=Le,new Error(Le)}b(!0);const mt=He.body.getReader(),Dt=new TextDecoder;let lt="",Et=[];E.current=0,x(0);let yt=0,gt=null;const pt=()=>{if(Et.length){const Ae=Et.join("");Et=[],T.current&&m(Le=>Le+Ae)}gt=null},an=()=>{typeof window<"u"&>==null&&(gt=requestAnimationFrame(pt))};let dt=Date.now();const ke=setInterval(()=>{var Ae;if(Date.now()-dt>18e5){const Le="Stream idle timeout";d(Le),J="error",_=Le,q.abort(),(Ae=I==null?void 0:I.onError)==null||Ae.call(I,Le)}},5e3),et=1024*1024;try{const Ae=He.headers.get("X-Thread-Id")||He.headers.get("x-thread-id"),Le=He.headers.get("X-Thread-Created")||He.headers.get("x-thread-created"),Bt=Ae??null,re=String(Le??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Bt}),(ne=I==null?void 0:I.onOpen)==null||ne.call(I,{threadId:Bt,created:re});;){const{value:we,done:rt}=await mt.read();if(rt)break;lt+=Dt.decode(we,{stream:!0}),lt.length>et&&(lt="",console.warn("Stream buffer reset: exceeded 1MB"));let ge;for(;(ge=lt.indexOf(`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:vn.transitional(vn.boolean),forcedJSONParsing:vn.transitional(vn.boolean),clarifyTimeoutError:vn.transitional(vn.boolean)},!1),o!=null&&(U.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:vn.function,serialize:vn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:vn.spelling("baseURL"),withXsrfToken:vn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&U.merge(s.common,s[n.method]);s&&U.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,h=0,m;if(!l){const v=[zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);h<m;)d=d.then(v[h++],v[h++]);return d}m=a.length;let f=n;for(;h<m;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=zc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,m=c.length;h<m;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Zn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),U.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let Ov=class ex{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ex(function(o){t=o}),cancel:t}}};function Dv(e){return function(n){return e.apply(null,n)}}function Lv(e){return U.isObject(e)&&e.isAxiosError===!0}const Ii={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(Ii).forEach(([e,t])=>{Ii[t]=e});function Wc(e){const t=new Qn(e),n=ic(Qn.prototype.request,t);return U.extend(n,Qn.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(Zn(e,o))},n}const xt=Wc(Gr);xt.Axios=Qn,xt.CanceledError=gr,xt.CancelToken=Ov,xt.isCancel=Ec,xt.VERSION=Hc,xt.toFormData=Lo,xt.AxiosError=Me,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Dv,xt.isAxiosError=Lv,xt.mergeConfig=Zn,xt.AxiosHeaders=Ut,xt.formToJSON=e=>Tc(U.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=Bc.getAdapter,xt.HttpStatusCode=Ii,xt.default=xt;const{Axios:nN,AxiosError:rN,CanceledError:oN,isCancel:sN,CancelToken:iN,VERSION:aN,all:lN,Cancel:cN,isAxiosError:uN,spread:dN,toFormData:fN,AxiosHeaders:hN,HttpStatusCode:pN,formToJSON:mN,getAdapter:gN,mergeConfig:xN}=xt,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?wn(Vc):void 0;function wn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Uo=null;const Ni=new Set;function qc(){return Uo}function Wo(e){Uo=e,Ni.forEach(t=>t(e))}function Gc(e){return Ni.add(e),()=>Ni.delete(e)}const Yc=3e4,Xc=9e4,Xt=xt.create({...Kc?{baseURL:Kc}:{},timeout:Yc,withCredentials:!0});Xt.interceptors.request.use(e=>(Uo&&(e.headers.Authorization=`Bearer ${Uo}`),e)),Xt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Wo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vo(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jc(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ai(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?wn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=wn(String(t.baseUrl))),t.authToken!==void 0&&Wo(t.authToken)}getAuthToken(){return qc()}setAuthToken(t){Wo(t)}onTokenChange(t){return Gc(t)}async listThreads(){const t=await Jt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Vo("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Jt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Xc});return Lt(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return Lt(r)}}const On=new Ko,$v=Ko,Fv=Ko;async function ji(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Bv(e,t){const n=await ji(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await ji(`/files/${e}/view`,t)).text()}async function Zc(e,t){const n=await ji(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function zv(e){return await Jt(`/files/${e}`)}async function Qc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const eu=w.createContext(null);function tu({children:e,apiConfig:t}){const n=On;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(eu.Provider,{value:r,children:e})}async function nu(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 ru(e=[]){const t=[],n=[];for(const r of e)try{const o=await nu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=w.useContext(eu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function ou(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Pi(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 Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Hv(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 su(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function iu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function au(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??iu(e);let l="",c=e.slice();if(s){const h=Uv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function lu(e){return e.replace(/\s+/g," ").trim()}function Uv(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=lu(e),o=lu(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 Wv(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 Jr(e,r,s)}return e}function cu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Vv(e={}){const t=w.useMemo(()=>wn(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),[h,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[S,k]=w.useState(null),C=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),j=w.useRef(null),M=w.useRef(null),L=w.useRef(null),H=w.useRef(null),B=w.useRef({messageId:null,lastSeq:null,lastText:""}),q=w.useCallback(R=>{o(R)},[]),N=w.useCallback(()=>{m(""),v(null),d(null),M.current=null,L.current=null,H.current=null,k(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),z=w.useCallback(()=>{var R;console.debug("[use-chat] stop() invoked - aborting stream"),(R=C.current)==null||R.abort(),C.current=null,j.current=null,l(!1),b(!1),E.current=0,x(0)},[]),$=w.useCallback((R,P,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),M.current=null,L.current=null,H.current=null,k(null),B.current={messageId:null,lastSeq:null,lastText:""};const V=new AbortController;C.current=V;let J=null,_=null,O=!1;return j.current={threadId:R.threadId??null,headers:{}},(async()=>{var Y,ae,W,D,X,oe,G,Z,te,se,ue,ge,Re,Oe,Te,nt,ht,Tt;const K=Ke=>{var Ge;try{const Ve=JSON.parse(JSON.stringify(Ke));return(Ge=Ve==null?void 0:Ve.payload)!=null&&Ge.files_info&&Array.isArray(Ve.payload.files_info)&&(Ve.payload.files_info=Ve.payload.files_info.map($e=>({...$e,data:$e!=null&&$e.data?`<base64 ${String($e.data).length} chars>`:$e==null?void 0:$e.data}))),Ve}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Le=window.__AUTH_TOKEN__,Bt=((Y=window.localStorage)==null?void 0:Y.getItem("authToken"))||null;let re=null;try{const rt=(ae=window.localStorage)==null?void 0:ae.getItem("chat-settings");rt&&(re=((W=JSON.parse(rt))==null?void 0:W.apiKey)||null)}catch{}const ye=Le||Bt||re||null;ye&&(Ke={Authorization:`Bearer ${ye}`})}}catch{}console.debug("[use-chat] POST",t+n,K(R));let Ge={};if(typeof window<"u")try{const Ae=(D=window.localStorage)==null?void 0:D.getItem("authSessionId");Ae&&(Ge={"X-Session-Id":Ae})}catch{}const Ve={...Ke,...Ge,...s.current},$e={"Content-Type":"application/json",Accept:"text/event-stream",...Ve},He=await fetch(t+n,{method:"POST",headers:$e,body:JSON.stringify(R),signal:V.signal,credentials:i});if(j.current&&(j.current.headers=Ve),!He.ok||!He.body){const Ae=await He.text().catch(()=>"");console.debug("[use-chat] non-OK response",He.status,Ae==null?void 0:Ae.slice(0,500));const Le=`stream ${He.status}${Ae?": "+Ae:""}`;throw(X=I==null?void 0:I.onConnectionError)==null||X.call(I,Le),O=!0,J="error",_=Le,new Error(Le)}b(!0);const mt=He.body.getReader(),Dt=new TextDecoder;let lt="",kt=[];E.current=0,x(0);let bt=0,gt=null;const pt=()=>{if(kt.length){const Ae=kt.join("");kt=[],T.current&&m(Le=>Le+Ae)}gt=null},an=()=>{typeof window<"u"&>==null&&(gt=requestAnimationFrame(pt))};let dt=Date.now();const ke=setInterval(()=>{var Ae;if(Date.now()-dt>18e5){const Le="Stream idle timeout";d(Le),J="error",_=Le,V.abort(),(Ae=I==null?void 0:I.onError)==null||Ae.call(I,Le)}},5e3),et=1024*1024;try{const Ae=He.headers.get("X-Thread-Id")||He.headers.get("x-thread-id"),Le=He.headers.get("X-Thread-Created")||He.headers.get("x-thread-created"),Bt=Ae??null,re=String(Le??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Bt}),(oe=I==null?void 0:I.onOpen)==null||oe.call(I,{threadId:Bt,created:re});;){const{value:ye,done:rt}=await mt.read();if(rt)break;lt+=Dt.decode(ye,{stream:!0}),lt.length>et&&(lt="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=lt.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const Pe=lt.slice(0,
|
|
38
|
-
`);if(!It)continue;let At;try{At=JSON.parse(It)}catch{console.debug("[use-chat] malformed SSE:",It.slice(0,200));continue}const zt=ou(At)?At.data:At;if(!zt){console.warn("[use-chat] dropped envelope event without payload",At);continue}const _e=zt;dt=Date.now();const ct=_e.seq;if(ct!==void 0){if(ct<=yt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ct,lastProcessedSeq:yt,type:_e.type});continue}yt>0&&ct>yt+1&&((Y=I==null?void 0:I.onGap)==null||Y.call(I,{from:yt,to:ct})),yt=ct,E.current=ct,x(ct)}if(_e.type==="message.start"&&_e.role==="assistant"){const Je=cu(_e.model);W.current={messageId:_e.id,lastSeq:ct??null,lastText:""},k({id:_e.id,role:"assistant",name:Je??void 0,model:_e.model,createdAt:new Date().toISOString(),content:[]})}if(_e.type==="checkpoint")M.current=_e.checkpointId??null,L.current=_e.checkpointNs??null,v(_e.checkpointId??null);else if(_e.type==="state_history"){B.current=_e;try{const ft=Rn(_e).latest;ft&&(M.current=ft.checkpointId??null,L.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{P==null||P(_e)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",_e.type)}if(_e.type==="message.delta"){k(ft=>{const ln=W.current;if(!ft||ln.messageId!==ft.id)return ft;const{newParts:A,newMeta:Q,changed:de}=au(ft.content??[],_e.delta,{lastSeq:ln.lastSeq,lastText:ln.lastText},ct??null);return de?(W.current={...ln,lastSeq:Q.lastSeq??ln.lastSeq,lastText:Q.lastText??ln.lastText},{...ft,content:A}):ft});const Je=_e.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Je&&e.autoAppendAssistant!==!1&&(Et.push(Je),an())}else if(_e.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(H=I==null?void 0:I.onHeartbeat)==null||H.call(I,_e)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(gt!==null&&cancelAnimationFrame(gt),pt(),_e.type==="checkpoint")v(_e.checkpointId);else if(_e.type==="error"){const Je=_e;if(d(Je.message),J="error",_=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((ae=Je.message)==null?void 0:ae.includes("token"))||((le=Je.message)==null?void 0:le.includes("401"))||((fe=Je.message)==null?void 0:fe.includes("unauthorized"))||((be=Je.message)==null?void 0:be.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(Re=I==null?void 0:I.onAuthError)==null||Re.call(I,Je.message)}catch(ln){console.warn("[use-chat] onAuthError handler failed",ln)}q.abort()}}}}pt(),J===null&&!q.signal.aborted&&(J="complete")}catch(Ae){if(Ae.name==="AbortError")J=J??"aborted";else{const Le=Ae.message||String(Ae);J="error",_=Le,d(Le),(Oe=I==null?void 0:I.onError)==null||Oe.call(I,Le)}}finally{try{await mt.cancel()}catch{}finally{(Te=mt.releaseLock)==null||Te.call(mt)}gt!==null&&typeof window<"u"&&window.cancelAnimationFrame(gt),clearInterval(ke)}}catch(Ke){if(Ke.name==="AbortError")J=J??"aborted";else{const Ge=Ke.message||String(Ke);J="error",_=Ge,d(Ge),(nt=I==null?void 0:I.onError)==null||nt.call(I,Ge),R||((ht=I==null?void 0:I.onConnectionError)==null||ht.call(I,Ge),R=!0)}}finally{const Ke=E.current,Ge=M.current,Ve=L.current,$e=B.current,He=J??(q.signal.aborted?"aborted":_?"error":"complete");try{(kt=I==null?void 0:I.onClosed)==null||kt.call(I,{reason:He,lastSeq:Ke,lastCheckpointId:Ge,lastCheckpointNs:Ve,lastStateHistory:$e,error:_})}catch(mt){console.warn("[use-chat] onClosed callback failed",mt)}l(!1),b(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>q.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var O;T.current=!1,(O=C.current)==null||O.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:$,stop:U,clear:N,setToken:K}}const Kv=["detail","message","error","description","title"];function qo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Kv){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function qv(e){if(!e)return"Request failed";const t=e.response,n=qo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function uu({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),[h,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,S]=w.useState(null),[k,C]=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 P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),M=w.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{j()},[j]),w.useEffect(()=>{M()},[M]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async P=>{try{const I=await e.createThread(P);return l(I.threadId),await j(),I.threadId}catch(I){const q=String(I);return n==null||n(q),null}},[e,n,j]),B=w.useCallback(async P=>{const I=s;i(J=>J.filter(_=>_.threadId!==P));const q=new AbortController;E.current.set(P,q);try{await e.deleteThread(P),T.current===P&&(l(null),o==null||o())}catch(J){i(I);const _=String(J);n==null||n(_)}finally{E.current.delete(P)}},[e,o,n,s]),W=w.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await j()}catch(q){n==null||n(String(q))}},[e,n,j]),K=w.useCallback(async(P,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,I),await M(),S("Shared successfully")}catch(q){const J=qv(q);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,M]),N=w.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await M()}catch(q){const J=String(q);throw n==null||n(J),q}},[e,n,M]),U=w.useMemo(()=>({createThread:L,deleteThread:B,renameThread:W,refreshThreads:j,refreshSharedThreads:M,shareThread:K,unshareThread:N}),[L,B,W,j,M,K,N]),$=w.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(q=>{let J=!1;const _=q.map(R=>R.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...R,title:I.title??R.title,updatedAt:I.updatedAt??R.updatedAt,messageCount:I.messageCount??R.messageCount}):R);return J?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...q])})},[]),O=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:U,addThreadFromEvent:$,shareInFlight:k,shareStatus:b,clearShareStatus:O}}const du=w.createContext(null);function fu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=uu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(du.Provider,{value:b,children:e})}function xr(){const e=w.useContext(du);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Mi(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function hu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hu(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=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function vr(e){if(typeof e=="string")return e;if(hu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Gv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Yv(e){const t=vr(e);return typeof e=="string"&&Gv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Mi(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Xv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ri(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 Go(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Jv(e){const t=r=>{try{const o=Zr(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 Zv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function pu(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 Qv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ew(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function tw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Qv(n),i=o?`data:${s};base64,${e}`:t,a=ew(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function nw(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 tw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const rw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ow(e,t){var n;switch(t.type){case"reset":return{messages:Pi(((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=Pi(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=Pi(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 gu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>gu(o,s),e):e}default:return e}}function sw(e=[]){const[t,n]=w.useReducer(ow,{...rw,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,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function gu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=cu(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 aw(e,t);if(t.type==="tool.progress")return lw(e,t);if(t.type==="tool.end")return cw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??su(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:iu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=au(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??su(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Wv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Hv(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 Oi(e){return e.call_id??e.id??null}function xu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function vu(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 Di(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||Ri(r).toolCallId===t)return n}return-1}function iw(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function aw(e,t){const n=Oi(t),r=Di(e.messages,n),o=t.name??t.tool??void 0,s=xu(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:Jr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function lw(e,t){const n=Oi(t);if(!n)return e;const r=Di(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=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function cw(e,t){const n=Oi(t),r=xu(t);let o=e.messages,s=Di(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,vu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=iw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=wu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function bu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=w.useState(null),v=w.useMemo(()=>Rn(h),[h]).checkpoints,g=tc(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[C,T]=w.useState(!1),[E,j]=w.useState(!1),[M,L]=w.useState(!1),[B,W]=w.useState(null),K=w.useRef(o),N=w.useRef(null),U=w.useRef(null),$=w.useRef(null),O=w.useRef(null),P=w.useRef(null),I=w.useRef(new Map);w.useEffect(()=>{K.current=o},[o]);const q=w.useCallback(async Y=>{var ae,le;if(!Y.threadId)return;const H=Y.threadId;(ae=Y.onStart)==null||ae.call(Y),Y.setLoading(!0);try{await Y.action(H)}catch(fe){if(K.current===H){const be=String(fe);(le=Y.handleError)==null||le.call(Y,be),r==null||r(be)}throw fe}finally{Y.setLoading(!1)}},[r]),J=w.useCallback(async(Y,H)=>{if(!Y)return;const ae=`${Y}:${H??"latest"}`,le=I.current.get(ae);if(le)return le;const fe=q({threadId:Y,setLoading:T,onStart:()=>W(null),handleError:be=>W(be),action:async be=>{const Re=await e.getStateHistory({threadId:be,checkpointId:H??void 0});if(K.current!==be){console.log(`[useThreadHistoryState] Thread changed during load (was ${be}, now ${K.current}), discarding stale data`);return}const{checkpoints:Oe}=Rn(Re),Te=Oe.find(nt=>nt.messages&&nt.messages.length>0)??(H?Oe.find(nt=>nt.checkpointId===H):null)??Oe[0];t((Te==null?void 0:Te.messages)??[],{checkpointId:(Te==null?void 0:Te.checkpointId)??null,checkpointNs:(Te==null?void 0:Te.checkpointNs)??null}),m(Re),b(!!(Te!=null&&Te.nextCursor)),k((Te==null?void 0:Te.nextCursor)??null)}});I.current.set(ae,fe);try{await fe}finally{I.current.delete(ae)}return K.current===Y&&(P.current=ae),fe},[e,t,q]),_=w.useCallback(async(Y,H)=>{O.current=Y;try{await J(Y,H)}finally{O.current===Y&&(O.current=null)}},[J]),R=w.useCallback(Y=>{U.current=Y},[]),G=w.useCallback(Y=>{$.current=Y},[]),X=w.useCallback(Y=>{const H=Y.threadId??K.current;if(!H||K.current&&K.current!==H)return;const{checkpoints:ae}=Rn(Y);if(!ae.length)return;const le=ae.find(be=>be.messages&&be.messages.length>0)??ae.find(be=>!!be.checkpointId)??ae[0],fe=$.current===H;!c&&!fe&&t((le==null?void 0:le.messages)??[],{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),m(Y),b(!!(le!=null&&le.nextCursor)),k((le==null?void 0:le.nextCursor)??null),P.current=`${H}:latest`,U.current=null,$.current===H&&($.current=null)},[t,c]),se=w.useCallback(async(Y,H)=>{const ae=K.current;await q({threadId:ae,setLoading:L,action:async le=>{const fe=await e.getStateHistory({threadId:le,checkpointId:Y,checkpointNs:H??void 0});if(K.current!==le){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${le}, now ${K.current}), discarding stale data`);return}const{checkpoints:be}=Rn(fe),Re=be.find(Oe=>Oe.checkpointId===Y&&(H?Oe.checkpointNs===H:!0));if(!Re){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:Y,checkpointNs:H});return}m(fe),t(Re.messages??[],{checkpointId:Re.checkpointId??null,checkpointNs:Re.checkpointNs??null})}}).catch(()=>{})},[e,t,q]),V=w.useCallback((Y,H)=>{t(d(),{checkpointId:Y??null,checkpointNs:H??null})},[d,t]),D=w.useCallback(async()=>{K.current&&await _(K.current)},[_]),Z=w.useCallback(async()=>{const Y=K.current;!Y||!S||await q({threadId:Y,setLoading:j,action:async H=>{const ae=await e.getStateHistory({threadId:H,checkpointId:S});if(K.current!==H)return;const{checkpoints:le}=Rn(ae);if(le.length>0){const fe=le[le.length-1];n((fe==null?void 0:fe.messages)??[]),b(!!(fe!=null&&fe.nextCursor)),k((fe==null?void 0:fe.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,q]);w.useEffect(()=>{if(!l||!o||C||c)return;if(U.current===o){U.current=null,N.current=o;return}if($.current===o){N.current=o;return}if(O.current===o){O.current=null,N.current=o;return}if(N.current===o)return;N.current=o;let Y;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const H=`${o}:latest`;P.current!==H&&_(o,Y)},[l,o,i,a,s,C,c,_]);const ne=w.useCallback(()=>{m(null),b(!1),k(null),T(!1),j(!1),L(!1),W(null),U.current=null,$.current=null,N.current=null,P.current=null,O.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:M,threadStateError:B,hasMoreHistory:y,loadThread:_,navigateToCheckpoint:se,loadOlderMessages:Z,setCurrentCheckpointId:V,returnToLatest:D,handleStateHistoryEvent:X,markSkipNextLoad:R,markStreamPendingThread:G,resetHistoryState:ne}}const yu=w.createContext(null),Su=w.createContext(null);function eo(){const e=w.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=w.useContext(Su);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Tu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=sw(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:M,returnToLatest:L,handleStateHistoryEvent:B,markSkipNextLoad:W,markStreamPendingThread:K,resetHistoryState:N}=bu({api:a,seed:d,prepend:h,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")}),[O,P]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),N())},[l,d,N]);const I=w.useCallback(G=>$(()=>G),[]),q=w.useCallback(G=>P(()=>G),[]),J=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:U,navigateToCheckpoint:E,setCurrentCheckpointId:M,returnToLatest:L,loadThread:T,clearThread:U,respondToInterrupt:O,messagePreviews:x.messagePreviews,handleStateHistoryEvent:B,markSkipNextLoad:W,markStreamPendingThread:K,resetHistoryState:N,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,b,S,k,C,j,U,E,M,L,T,O,x.messagePreviews,B,W,K,N,m,f]),R=w.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:q}),[I,q]);return u.jsx(Su.Provider,{value:R,children:u.jsx(yu.Provider,{value:_,children:e})})}function ku(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return Mn(r,t)??null}function uw(e){const t=ku(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ku(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function dw(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 fw(e,t){const n=[...e].sort(dw);for(const r of n){if(r.messageId!==t)continue;const o=uw(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 Eu=w.createContext(null),Iu=w.createContext(!1);function hw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=w.useMemo(()=>wn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Vv({baseUrl:m}),[b,S]=w.useState(!1);return w.useEffect(()=>{S(g)},[g]),u.jsx(fu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Tu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(pw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function pw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:j}=Cu(),M=w.useCallback(O=>{v(O),f.current!==O.threadId&&((O.created??!f.current)&&b(O.threadId),S(O.threadId),m(O.threadId))},[v,b,S,m,f]),L=w.useCallback(O=>{O.type==="thread_info"?M(O):O.type==="state_history"?y(O):O.type==="tool.end"?i==null||i(O):T(O)},[M,y,T,i]),B=w.useCallback(O=>{a(O,L,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,L,r,o,s]),W=w.useRef(g);w.useEffect(()=>{W.current=g},[g]);const K=w.useCallback(async(O,P,I)=>{const q=f.current;if(!q)throw new Error("No active thread to handle interrupt");const J=P?I??!0:!1,_=W.current,R={threadId:q,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:J}};B(R)},[f,B]);w.useEffect(()=>{j(K)},[K,j]);const N=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(O){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",O)}},[t,k,m,l]);w.useEffect(()=>{E(N)},[N,E]);const U=w.useCallback(async(O,P)=>{let I=f.current;const q=(O==null?void 0:O.text)??"",J=(O==null?void 0:O.attachments)??[],_=(q==null?void 0:q.trim())??"",R={...(O==null?void 0:O.payload)??{}},G=Array.isArray(R.messages)?R.messages:void 0;G&&delete R.messages;const X=!!(G&&G.length);if(!I&&!_&&J.length===0&&!X)return;if(!I){const Oe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Te=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Oe}${Te}`,b(I),m(I)}const{contentParts:se,filesInfo:V}=await ru(J),D=[...se];_&&D.push({type:"text",text:q});const Z=P==null?void 0:P.originalMessageId,ne=!!(P!=null&&P.edit&&Z),Y=!X&&D.length>0;let H=null;Y&&(H={id:ne?Z:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},ne?C(H,Z):C(H));const ae=X?G:H?[H]:[],le={...R,...V.length?{files_info:V}:{}};ae.length?le.messages=ae:"messages"in le||(le.messages=[]);let fe=(P==null?void 0:P.checkpointId)??g.id??void 0,be=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(ne&&Z){const Oe=fw(x,Z);fe=Oe.checkpointId,be=Oe.checkpointNs??void 0}const Re={threadId:I,payload:le,checkpointId:fe,checkpointNs:be,edit:!!(P!=null&&P.edit)};B(Re)},[g,f,b,C,B,x]),$=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:U,send:U,stop:l,setAuthToken:h}),[c,d,U,l,h]);return u.jsx(Eu.Provider,{value:$,children:e})}function Li(){const e=w.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function mw(){return w.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function gw(e,t){if(Object.is(e,t))return!0;if(!Nu(e)||!Nu(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 Au(e){const t=w.useRef(e),n=w.useRef(e);return gw(t.current,e)||(t.current=e,n.current=e),n.current}function wr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=Au(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(tu,{apiConfig:h,children:u.jsx(hw,{...y,children:e})})}function to(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 br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function xw(e){if(typeof e!="string")return;const t=e.trim();if(t)return wn(t)}function ju(){const e=[br("__API_BASE_URL__"),br("__CHAT_API_BASE_URL__"),br("__CHAT_API_URL__")];for(const t of e){const n=xw(t);if(n)return n}}function _u(){const e=[br("__API_AUTH_TOKEN__"),br("__CHAT_API_KEY__"),br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Pu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return wn(t);return wn()}function Mu(){const e={},t=ju(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ru(){const e=Mu(),t=On.getAuthToken(),n=ju();return{apiBaseUrl:Pu(e.baseUrl,On.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Ou(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Du(e){try{const t={...e,apiBaseUrl:wn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&On.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vw(){const e=Ru(),t=Ou(),n=On.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(On.baseUrl,r,e.apiBaseUrl)}}function ww(e){On.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function te(...e){return nx.twMerge(tx.clsx(e))}const bw=zr.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"}}),Qe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:te(bw({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";function ce(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 Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Lu(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():Lu(e[o],null)}}}}function Be(...e){return p.useCallback(Dn(...e),e)}function yw(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function un(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Sw(o,...t)]}function Sw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Nt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Cw=p[" useInsertionEffect ".trim().toString()]||Nt;function Ln({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var h;if(a){const m=kw(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Tw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Cw(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kw(e){return typeof e=="function"}var Ew=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=Ew.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=un(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=Be(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),C=Be(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Iw=p.createContext(void 0);function Xo(e){const t=p.useContext(Iw);return e||t||"ltr"}function wt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Nw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Aw="DismissableLayer",Bi="dismissableLayer.update",jw="dismissableLayer.pointerDownOutside",_w="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Fu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=Be(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=Mw(E=>{const j=E.target,M=[...c.branches].some(L=>L.contains(j));!k||M||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Rw(E=>{const j=E.target;[...c.branches].some(L=>L.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Nw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&($u=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=$u)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),zu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Bi,E),()=>document.removeEventListener(Bi,E)},[]),u.jsx(me.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});yr.displayName=Aw;var Pw="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=Be(t,r);return p.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})});Bu.displayName=Pw;function Mw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(jw,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 Rw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(_w,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function zu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Hu(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?Fi(o,s):o.dispatchEvent(s)}var Ow=yr,Dw=Bu,zi=0;function Hi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Uu()),document.body.insertAdjacentElement("beforeend",e[1]??Uu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Uu(){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 Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Wu={bubbles:!1,cancelable:!0},Lw="FocusScope",Jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=wt(o),d=wt(s),h=p.useRef(null),m=Be(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:$n(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||$n(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&$n(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,f.paused]),p.useEffect(()=>{if(a){qu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Wu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||($w(Uw(Vu(a)),{select:!0}),document.activeElement===g&&$n(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||$n(g??document.body,{select:!0}),a.removeEventListener(Wi,d),qu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[S,k]=Fw(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&$n(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&$n(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=Lw;function $w(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($n(r,{select:t}),document.activeElement!==n)return}function Fw(e){const t=Vu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function Vu(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 Ku(e,t){for(const n of e)if(!Bw(n,{upTo:t}))return n}function Bw(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 zw(e){return e instanceof HTMLInputElement&&"select"in e}function $n(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zw(e)&&t&&e.select()}}var qu=Hw();function Hw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Gu(e,t),e.unshift(t)},remove(t){var n;e=Gu(e,t),(n=e[0])==null||n.resume()}}}function Gu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Uw(e){return e.filter(t=>t.tagName!=="A")}var Ww=p[" useId ".trim().toString()]||(()=>{}),Vw=0;function Pt(e){const[t,n]=p.useState(Ww());return Nt(()=>{n(r=>r??String(Vw++))},[e]),t?`radix-${t}`:""}const Kw=["top","right","bottom","left"],Fn=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,bn=e=>({x:e,y:e}),qw={left:"right",right:"left",bottom:"top",top:"bottom"},Gw={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,Fn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Yw=new Set(["top","bottom"]);function yn(e){return Yw.has(jn(e))?"y":"x"}function Gi(e){return Ki(yn(e))}function Xw(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=Gi(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=es(i)),[i,es(i)]}function Jw(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Gw[t])}const Yu=["left","right"],Xu=["right","left"],Zw=["top","bottom"],Qw=["bottom","top"];function eb(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Zw:Qw;default:return[]}}function tb(e,t,n,r){const o=Sr(e);let s=eb(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>qw[t])}function nb(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?nb(e):{top:e,right:e,bottom:e,left:e}}function ts(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 Zu(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Gi(t),a=qi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const rb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Zu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Zu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=Ju(f),x=a[m?h==="floating"?"reference":"floating":h],y=ts(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=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ts(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const ob=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const h=Ju(d),m={x:n,y:r},f=Gi(o),v=qi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,M=E/2-g[v]/2-1,L=Fn(h[y],M),B=Fn(h[b],M),W=L,K=E-g[v]-B,N=E/2-g[v]/2+j,U=Vi(W,N,K),$=!l.arrow&&Sr(o)!=null&&N!==U&&s.reference[v]/2-(N<W?L:B)-g[v]/2<0,O=$?N<W?N-W:N-K:0;return{[f]:m[f]+O,data:{[f]:U,centerOffset:N-U-O,...$&&{alignmentOffset:O}},reset:$}}}),sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),b=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Jw(a)),T=v!=="none";!m&&T&&C.push(...tb(a,g,v,k));const E=[a,...C],j=await no(t,x),M=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&M.push(j[y]),h){const N=Xw(o,i,k);M.push(j[N[0]],j[N[1]])}if(L=[...L,{placement:o,overflows:M}],!M.every(N=>N<=0)){var B,W;const N=(((B=s.flip)==null?void 0:B.index)||0)+1,U=E[N];if(U&&(!(h==="alignment"?b!==yn(U):!1)||L.every(P=>yn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:N,overflows:L},reset:{placement:U}};let $=(W=L.filter(O=>O.overflows[0]<=0).sort((O,P)=>O.overflows[1]-P.overflows[1])[0])==null?void 0:W.placement;if(!$)switch(f){case"bestFit":{var K;const O=(K=L.filter(P=>{if(T){const I=yn(P.placement);return I===b||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,q)=>I+q,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:K[0];O&&($=O);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return Kw.some(t=>e[t]>=0)}const ib=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 no(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function ab(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=Sr(n),l=yn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,h=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const lb=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 ab(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}}}}},cb=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 no(t,l),h=yn(jn(o)),m=Ki(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=Vi(b,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=Vi(b,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},ub=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},h=yn(o),m=Ki(h);let f=d[m],v=d[h];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,b;const S=m==="y"?"width":"height",k=td.has(jn(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},db=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 no(t,c),h=jn(o),m=Sr(o),f=yn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,S=v-d.left-d.right,k=Fn(g-d[x],b),C=Fn(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Zt(d.left,0),B=Zt(d.right,0),W=Zt(d.top,0),K=Zt(d.bottom,0);f?j=v-2*(L!==0||B!==0?L+B:Zt(d.left,d.right)):E=g-2*(W!==0||K!==0?W+K:Zt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const M=await i.getDimensions(a.floating);return v!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Cr(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Sn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function dn(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Cn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function rd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const fb=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=fn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fb.has(o)}const hb=new Set(["table","td","th"]);function pb(e){return hb.has(Cr(e))}const mb=[":popover-open",":modal"];function rs(e){return mb.some(t=>{try{return e.matches(t)}catch{return!1}})}const gb=["transform","translate","scale","rotate","perspective"],xb=["transform","translate","scale","rotate","perspective","filter"],vb=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=dn(e)?fn(e):e;return gb.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)||xb.some(r=>(n.willChange||"").includes(r))||vb.some(r=>(n.contain||"").includes(r))}function wb(e){let t=Bn(e);for(;Cn(t)&&!Tr(t);){if(Xi(t))return t;if(rs(t))return null;t=Bn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bb=new Set(["html","body","#document"]);function Tr(e){return bb.has(Cr(e))}function fn(e){return Qt(e).getComputedStyle(e)}function os(e){return dn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Bn(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||Sn(e);return rd(t)?t.host:t}function od(e){const t=Bn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Cn(t)&&ro(t)?t:od(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=fn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Cn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return dn(e)?e:e.contextElement}function kr(e){const t=Qi(e);if(!Cn(t))return bn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const yb=bn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?yb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=bn(1);t&&(r?dn(r)&&(i=kr(r)):i=kr(e));const a=Sb(s,n,r)?id(s):bn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Qt(s),f=r&&dn(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),b=fn(g),S=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,h*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:h,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:er(Sn(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Cb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Sn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=bn(1);const d=bn(0),h=Cn(r);if((h||!h&&!s)&&((Cr(r)!=="body"||ro(i))&&(l=os(r)),Cn(r))){const f=er(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ad(i,l):bn(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 Tb(e){return Array.from(e.getClientRects())}function kb(e){const t=Sn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return fn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Eb(e,t){const n=Qt(e),r=Sn(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=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=ld&&(s-=v)}else c<=ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const Ib=new Set(["absolute","fixed"]);function Nb(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Cn(e)?kr(e):bn(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 cd(e,t,n){let r;if(t==="viewport")r=Eb(e,n);else if(t==="document")r=kb(Sn(e));else if(dn(t))r=Nb(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function ud(e,t){const n=Bn(e);return n===t||!dn(n)||Tr(n)?!1:fn(n).position==="fixed"||ud(n,t)}function Ab(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>dn(a)&&Cr(a)!=="body"),o=null;const s=fn(e).position==="fixed";let i=s?Bn(e):e;for(;dn(i)&&!Tr(i);){const a=fn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Ib.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Bn(i)}return t.set(e,r),r}function jb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Ab(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=cd(t,d,o);return c.top=Zt(h.top,c.top),c.right=Fn(h.right,c.right),c.bottom=Fn(h.bottom,c.bottom),c.left=Zt(h.left,c.left),c},cd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function _b(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Pb(e,t,n){const r=Cn(t),o=Sn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=bn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Cr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ad(o,a):bn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ea(e){return fn(e).position==="static"}function dd(e,t){if(!Cn(e)||fn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Sn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Cn(e)){let o=Bn(e);for(;o&&!Tr(o);){if(dn(o)&&!ea(o))return o;o=Bn(o)}return n}let r=dd(e,t);for(;r&&pb(r)&&ea(r);)r=dd(r,t);return r&&Tr(r)&&ea(r)&&!Xi(r)?n:r||wb(e)||n}const Mb=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:Pb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rb(e){return fn(e).direction==="rtl"}const Ob={convertOffsetParentRelativeRectToViewportRelativeRect:Cb,getDocumentElement:Sn,getClippingRect:jb,getOffsetParent:fd,getElementRects:Mb,getClientRects:Tb,getDimensions:_b,getScale:kr,isElement:dn,isRTL:Rb};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Db(e,t){let n=null,r;const o=Sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Qo(h),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(h+f)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,Fn(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!hd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Lb(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=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Db(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!hd(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)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const $b=lb,Fb=cb,Bb=sb,zb=db,Hb=ib,pd=ob,Ub=ub,Wb=(e,t,n)=>{const r=new Map,o={platform:Ob,...n},s={...o.platform,_c:r};return rb(e,t,{...o,platform:s})};var Vb=typeof document<"u",Kb=function(){},is=Vb?w.useLayoutEffect:Kb;function as(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(!as(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)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gd(e,t){const n=md(e);return Math.round(t*n)/n}function ta(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function qb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);as(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),b=p.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),S=p.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),j=p.useRef(d),M=l!=null,L=ta(l),B=ta(o),W=ta(c),K=p.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};B.current&&(P.platform=B.current),Wb(T.current,E.current,P).then(I=>{const q={...I,isPositioned:W.current!==!1};N.current&&!as(j.current,q)&&(j.current=q,Hr.flushSync(()=>{h(q)}))})},[m,t,n,B,W]);is(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[c]);const N=p.useRef(!1);is(()=>(N.current=!0,()=>{N.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,K);K()}},[k,C,K,L,M]);const U=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),$=p.useMemo(()=>({reference:k,floating:C}),[k,C]),O=p.useMemo(()=>{const P={position:n,left:0,top:0};if(!$.floating)return P;const I=gd($.floating,d.x),q=gd($.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+q+"px)",...md($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:q}},[n,a,$.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:K,refs:U,elements:$,floatingStyles:O}),[d,K,U,$,O])}const Gb=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?pd({element:r.current,padding:o}).fn(n):{}:r?pd({element:r,padding:o}).fn(n):{}}}},Yb=(e,t)=>({...$b(e),options:[e,t]}),Xb=(e,t)=>({...Fb(e),options:[e,t]}),Jb=(e,t)=>({...Ub(e),options:[e,t]}),Zb=(e,t)=>({...Bb(e),options:[e,t]}),Qb=(e,t)=>({...zb(e),options:[e,t]}),ey=(e,t)=>({...Hb(e),options:[e,t]}),ty=(e,t)=>({...Gb(e),options:[e,t]});var ny="Arrow",xd=p.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"})})});xd.displayName=ny;var ry=xd;function vd(e){const[t,n]=p.useState(void 0);return Nt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[wd,Er]=un(na),[oy,bd]=wd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(oy,{scope:t,anchor:r,onAnchorChange:o,children:n})};yd.displayName=na;var Sd="PopperAnchor",Cd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=bd(Sd,n),i=p.useRef(null),a=Be(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[sy,iy]=wd(ra),Td=p.forwardRef((e,t)=>{var V,D,Z,ne,Y,H;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=bd(ra,n),[y,b]=p.useState(null),S=Be(t,ae=>b(ae)),[k,C]=p.useState(null),T=vd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,M=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},B=Array.isArray(c)?c:[c],W=B.length>0,K={padding:L,boundary:B.filter(ly),altBoundary:W},{refs:N,floatingStyles:U,placement:$,isPositioned:O,middlewareData:P}=qb({strategy:"fixed",placement:M,whileElementsMounted:(...ae)=>Lb(...ae,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Yb({mainAxis:o+j,alignmentAxis:i}),l&&Xb({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Jb():void 0,...K}),l&&Zb({...K}),Qb({...K,apply:({elements:ae,rects:le,availableWidth:fe,availableHeight:be})=>{const{width:Re,height:Oe}=le.reference,Te=ae.floating.style;Te.setProperty("--radix-popper-available-width",`${fe}px`),Te.setProperty("--radix-popper-available-height",`${be}px`),Te.setProperty("--radix-popper-anchor-width",`${Re}px`),Te.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),k&&ty({element:k,padding:a}),cy({arrowWidth:E,arrowHeight:j}),m&&ey({strategy:"referenceHidden",...K})]}),[I,q]=Id($),J=wt(v);Nt(()=>{O&&(J==null||J())},[O,J]);const _=(V=P.arrow)==null?void 0:V.x,R=(D=P.arrow)==null?void 0:D.y,G=((Z=P.arrow)==null?void 0:Z.centerOffset)!==0,[X,se]=p.useState();return Nt(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:O?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(ne=P.transformOrigin)==null?void 0:ne.x,(Y=P.transformOrigin)==null?void 0:Y.y].join(" "),...((H=P.hide)==null?void 0:H.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(sy,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:R,shouldHideArrow:G,children:u.jsx(me.div,{"data-side":I,"data-align":q,...g,ref:S,style:{...g.style,animation:O?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ay={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=iy(kd,r),i=ay[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(ry,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function ly(e){return e!==null}var cy=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]=Id(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Id(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=yd,sa=Cd,ia=Td,aa=Ed,uy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);Nt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Po.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});so.displayName=uy;function dy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=fy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Be(r.ref,hy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function fy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=dy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),Nt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ls(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Nt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=ls(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function hy(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 la="rovingFocusGroup.onEntryFocus",py={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,my]=Yo(io),[gy,Ad]=un(io,[my]),[xy,vy]=gy(io),jd=p.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wy,{...e,ref:t})})}));jd.displayName=io;var wy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=Be(t,m),v=Xo(s),[g,x]=Ln({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,b]=p.useState(!1),S=wt(c),k=Nd(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(la,S),()=>j.removeEventListener(la,S)},[S]),u.jsx(xy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(j=>x(j),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:p.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,j=>{const M=!C.current;if(j.target===j.currentTarget&&M&&!y){const L=new CustomEvent(la,py);if(j.currentTarget.dispatchEvent(L),!L.defaultPrevented){const B=k().filter($=>$.focusable),W=B.find($=>$.active),K=B.find($=>$.id===g),U=[W,K,...B].filter(Boolean).map($=>$.ref.current);Md(U,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>b(!1))})})}),_d="RovingFocusGroupItem",Pd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=vy(_d,n),h=d.currentTabStopId===c,m=Nd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Sy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Cy(S,k+1):S.slice(k+1)}setTimeout(()=>Md(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Pd.displayName=_d;var by={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sy(e,t,n){const r=yy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return by[r]}function Md(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Cy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ty=jd,ky=Pd,Ey=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ir=new WeakMap,cs=new WeakMap,us={},ua=0,Rd=function(e){return e&&(e.host||Rd(e.parentNode))},Iy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Rd(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})},Ny=function(e,t,n,r){var o=Iy(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Ir.get(m)||0)+1,x=(s.get(m)||0)+1;Ir.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.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(),ua++,function(){i.forEach(function(h){var m=Ir.get(h)-1,f=s.get(h)-1;Ir.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ua--,ua||(Ir=new WeakMap,Ir=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ey(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ny(r,o,n,"aria-hidden")):function(){return null}},Tn=function(){return Tn=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},Tn.apply(this,arguments)};function Od(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ay(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 ds="right-scroll-bar-position",fs="width-before-scroll-bar",jy="with-scroll-bars-hidden",_y="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Py(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 My=typeof window<"u"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function Ry(e,t){var n=Py(null,function(r){return e.forEach(function(o){return fa(o,r)})});return My(function(){var r=Dd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Dd.set(n,e)},[e]),n}function Oy(e){return e}function Dy(e,t){t===void 0&&(t=Oy);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 Ly(e){e===void 0&&(e={});var t=Dy(null);return t.options=Tn({async:!0,ssr:!1},e),t}var Ld=function(e){var t=e.sideCar,n=Od(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Tn({},n))};Ld.isSideCarExport=!0;function $y(e,t){return e.useMedium(t),Ld}var $d=Ly(),ha=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ha,onWheelCapture:ha,onTouchMoveCapture:ha}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,k=Od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ry([n,t]),E=Tn(Tn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:$d,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Tn(Tn({},E),{ref:T})):p.createElement(b,Tn({},E,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Fy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function By(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fy();return t&&e.setAttribute("nonce",t),e}function zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Uy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=By())&&(zy(t,n),Hy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wy=function(){var e=Uy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Wy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vy={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},Ky=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[pa(n),pa(r),pa(o)]},qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vy;var t=Ky(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])}},Gy=Fd(),Nr="data-scroll-locked",Yy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
37
|
+
`))>=0;){const Pe=lt.slice(0,xe);lt=lt.slice(xe+2);const Xe=Pe.split(/\r?\n/),St=[];for(const Je of Xe)if(!(!Je||Je.startsWith(":"))&&Je.startsWith("data:")){const ft=Je.slice(5);St.push(ft.startsWith(" ")?ft.slice(1):ft)}const Et=St.join(`
|
|
38
|
+
`);if(!Et)continue;let Nt;try{Nt=JSON.parse(Et)}catch{console.debug("[use-chat] malformed SSE:",Et.slice(0,200));continue}const zt=ou(Nt)?Nt.data:Nt;if(!zt){console.warn("[use-chat] dropped envelope event without payload",Nt);continue}const _e=zt;dt=Date.now();const ct=_e.seq;if(ct!==void 0){if(ct<=bt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ct,lastProcessedSeq:bt,type:_e.type});continue}bt>0&&ct>bt+1&&((G=I==null?void 0:I.onGap)==null||G.call(I,{from:bt,to:ct})),bt=ct,E.current=ct,x(ct)}if(_e.type==="message.start"&&_e.role==="assistant"){const Je=cu(_e.model);B.current={messageId:_e.id,lastSeq:ct??null,lastText:""},k({id:_e.id,role:"assistant",name:Je??void 0,model:_e.model,createdAt:new Date().toISOString(),content:[]})}if(_e.type==="checkpoint")M.current=_e.checkpointId??null,L.current=_e.checkpointNs??null,v(_e.checkpointId??null);else if(_e.type==="state_history"){H.current=_e;try{const ft=Rn(_e).latest;ft&&(M.current=ft.checkpointId??null,L.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{P==null||P(_e)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",_e.type)}if(_e.type==="message.delta"){k(ft=>{const ln=B.current;if(!ft||ln.messageId!==ft.id)return ft;const{newParts:A,newMeta:Q,changed:fe}=au(ft.content??[],_e.delta,{lastSeq:ln.lastSeq,lastText:ln.lastText},ct??null);return fe?(B.current={...ln,lastSeq:Q.lastSeq??ln.lastSeq,lastText:Q.lastText??ln.lastText},{...ft,content:A}):ft});const Je=_e.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Je&&e.autoAppendAssistant!==!1&&(kt.push(Je),an())}else if(_e.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Z=I==null?void 0:I.onHeartbeat)==null||Z.call(I,_e)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(gt!==null&&cancelAnimationFrame(gt),pt(),_e.type==="checkpoint")v(_e.checkpointId);else if(_e.type==="error"){const Je=_e;if(d(Je.message),J="error",_=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((te=Je.message)==null?void 0:te.includes("token"))||((se=Je.message)==null?void 0:se.includes("401"))||((ue=Je.message)==null?void 0:ue.includes("unauthorized"))||((ge=Je.message)==null?void 0:ge.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(Re=I==null?void 0:I.onAuthError)==null||Re.call(I,Je.message)}catch(ln){console.warn("[use-chat] onAuthError handler failed",ln)}V.abort()}}}}pt(),J===null&&!V.signal.aborted&&(J="complete")}catch(Ae){if(Ae.name==="AbortError")J=J??"aborted";else{const Le=Ae.message||String(Ae);J="error",_=Le,d(Le),(Oe=I==null?void 0:I.onError)==null||Oe.call(I,Le)}}finally{try{await mt.cancel()}catch{}finally{(Te=mt.releaseLock)==null||Te.call(mt)}gt!==null&&typeof window<"u"&&window.cancelAnimationFrame(gt),clearInterval(ke)}}catch(Ke){if(Ke.name==="AbortError")J=J??"aborted";else{const Ge=Ke.message||String(Ke);J="error",_=Ge,d(Ge),(nt=I==null?void 0:I.onError)==null||nt.call(I,Ge),O||((ht=I==null?void 0:I.onConnectionError)==null||ht.call(I,Ge),O=!0)}}finally{const Ke=E.current,Ge=M.current,Ve=L.current,$e=H.current,He=J??(V.signal.aborted?"aborted":_?"error":"complete");try{(Tt=I==null?void 0:I.onClosed)==null||Tt.call(I,{reason:He,lastSeq:Ke,lastCheckpointId:Ge,lastCheckpointNs:Ve,lastStateHistory:$e,error:_})}catch(mt){console.warn("[use-chat] onClosed callback failed",mt)}l(!1),b(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>V.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var R;T.current=!1,(R=C.current)==null||R.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:$,stop:z,clear:N,setToken:q}}const Kv=["detail","message","error","description","title"];function qo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Kv){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function qv(e){if(!e)return"Request failed";const t=e.response,n=qo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function uu({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),[h,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,S]=w.useState(null),[k,C]=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 P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),M=w.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{j()},[j]),w.useEffect(()=>{M()},[M]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async P=>{try{const I=await e.createThread(P);return l(I.threadId),await j(),I.threadId}catch(I){const V=String(I);return n==null||n(V),null}},[e,n,j]),H=w.useCallback(async P=>{const I=s;i(J=>J.filter(_=>_.threadId!==P));const V=new AbortController;E.current.set(P,V);try{await e.deleteThread(P),T.current===P&&(l(null),o==null||o())}catch(J){i(I);const _=String(J);n==null||n(_)}finally{E.current.delete(P)}},[e,o,n,s]),B=w.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await j()}catch(V){n==null||n(String(V))}},[e,n,j]),q=w.useCallback(async(P,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,I),await M(),S("Shared successfully")}catch(V){const J=qv(V);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,M]),N=w.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await M()}catch(V){const J=String(V);throw n==null||n(J),V}},[e,n,M]),z=w.useMemo(()=>({createThread:L,deleteThread:H,renameThread:B,refreshThreads:j,refreshSharedThreads:M,shareThread:q,unshareThread:N}),[L,H,B,j,M,q,N]),$=w.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(V=>{let J=!1;const _=V.map(O=>O.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return J?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...V])})},[]),R=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:z,addThreadFromEvent:$,shareInFlight:k,shareStatus:b,clearShareStatus:R}}const du=w.createContext(null);function fu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=uu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(du.Provider,{value:b,children:e})}function xr(){const e=w.useContext(du);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Mi(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function hu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hu(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=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function vr(e){if(typeof e=="string")return e;if(hu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Gv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Yv(e){const t=vr(e);return typeof e=="string"&&Gv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Mi(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Xv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ri(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 Go(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Jv(e){const t=r=>{try{const o=Zr(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 Zv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function pu(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 Qv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ew(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function tw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Qv(n),i=o?`data:${s};base64,${e}`:t,a=ew(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function nw(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 tw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const rw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ow(e,t){var n;switch(t.type){case"reset":return{messages:Pi(((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=Pi(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=Pi(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 gu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>gu(o,s),e):e}default:return e}}function sw(e=[]){const[t,n]=w.useReducer(ow,{...rw,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,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function gu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=cu(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 aw(e,t);if(t.type==="tool.progress")return lw(e,t);if(t.type==="tool.end")return cw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??su(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:iu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=au(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??su(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Wv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Hv(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 Oi(e){return e.call_id??e.id??null}function xu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function vu(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 Di(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||Ri(r).toolCallId===t)return n}return-1}function iw(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function aw(e,t){const n=Oi(t),r=Di(e.messages,n),o=t.name??t.tool??void 0,s=xu(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:Jr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function lw(e,t){const n=Oi(t);if(!n)return e;const r=Di(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=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function cw(e,t){const n=Oi(t),r=xu(t);let o=e.messages,s=Di(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,vu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=iw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=wu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function bu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=w.useState(null),v=w.useMemo(()=>Rn(h),[h]).checkpoints,g=tc(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[C,T]=w.useState(!1),[E,j]=w.useState(!1),[M,L]=w.useState(!1),[H,B]=w.useState(null),q=w.useRef(o),N=w.useRef(null),z=w.useRef(null),$=w.useRef(null),R=w.useRef(null),P=w.useRef(null),I=w.useRef(new Map);w.useEffect(()=>{q.current=o},[o]);const V=w.useCallback(async G=>{var te,se;if(!G.threadId)return;const Z=G.threadId;(te=G.onStart)==null||te.call(G),G.setLoading(!0);try{await G.action(Z)}catch(ue){if(q.current===Z){const ge=String(ue);(se=G.handleError)==null||se.call(G,ge),r==null||r(ge)}throw ue}finally{G.setLoading(!1)}},[r]),J=w.useCallback(async(G,Z)=>{if(!G)return;const te=`${G}:${Z??"latest"}`,se=I.current.get(te);if(se)return se;const ue=V({threadId:G,setLoading:T,onStart:()=>B(null),handleError:ge=>B(ge),action:async ge=>{const Re=await e.getStateHistory({threadId:ge,checkpointId:Z??void 0});if(q.current!==ge){console.log(`[useThreadHistoryState] Thread changed during load (was ${ge}, now ${q.current}), discarding stale data`);return}const{checkpoints:Oe}=Rn(Re),Te=Oe.find(nt=>nt.messages&&nt.messages.length>0)??(Z?Oe.find(nt=>nt.checkpointId===Z):null)??Oe[0];t((Te==null?void 0:Te.messages)??[],{checkpointId:(Te==null?void 0:Te.checkpointId)??null,checkpointNs:(Te==null?void 0:Te.checkpointNs)??null}),m(Re),b(!!(Te!=null&&Te.nextCursor)),k((Te==null?void 0:Te.nextCursor)??null)}});I.current.set(te,ue);try{await ue}finally{I.current.delete(te)}return q.current===G&&(P.current=te),ue},[e,t,V]),_=w.useCallback(async(G,Z)=>{R.current=G;try{await J(G,Z)}finally{R.current===G&&(R.current=null)}},[J]),O=w.useCallback(G=>{z.current=G},[]),K=w.useCallback(G=>{$.current=G},[]),Y=w.useCallback(G=>{const Z=G.threadId??q.current;if(!Z||q.current&&q.current!==Z)return;const{checkpoints:te}=Rn(G);if(!te.length)return;const se=te.find(ge=>ge.messages&&ge.messages.length>0)??te.find(ge=>!!ge.checkpointId)??te[0],ue=$.current===Z;!c&&!ue&&t((se==null?void 0:se.messages)??[],{checkpointId:(se==null?void 0:se.checkpointId)??null,checkpointNs:(se==null?void 0:se.checkpointNs)??null}),m(G),b(!!(se!=null&&se.nextCursor)),k((se==null?void 0:se.nextCursor)??null),P.current=`${Z}:latest`,z.current=null,$.current===Z&&($.current=null)},[t,c]),ae=w.useCallback(async(G,Z)=>{const te=q.current;await V({threadId:te,setLoading:L,action:async se=>{const ue=await e.getStateHistory({threadId:se,checkpointId:G,checkpointNs:Z??void 0});if(q.current!==se){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${se}, now ${q.current}), discarding stale data`);return}const{checkpoints:ge}=Rn(ue),Re=ge.find(Oe=>Oe.checkpointId===G&&(Z?Oe.checkpointNs===Z:!0));if(!Re){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:G,checkpointNs:Z});return}m(ue),t(Re.messages??[],{checkpointId:Re.checkpointId??null,checkpointNs:Re.checkpointNs??null})}}).catch(()=>{})},[e,t,V]),W=w.useCallback((G,Z)=>{t(d(),{checkpointId:G??null,checkpointNs:Z??null})},[d,t]),D=w.useCallback(async()=>{q.current&&await _(q.current)},[_]),X=w.useCallback(async()=>{const G=q.current;!G||!S||await V({threadId:G,setLoading:j,action:async Z=>{const te=await e.getStateHistory({threadId:Z,checkpointId:S});if(q.current!==Z)return;const{checkpoints:se}=Rn(te);if(se.length>0){const ue=se[se.length-1];n((ue==null?void 0:ue.messages)??[]),b(!!(ue!=null&&ue.nextCursor)),k((ue==null?void 0:ue.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,V]);w.useEffect(()=>{if(!l||!o||C||c)return;if(z.current===o){z.current=null,N.current=o;return}if($.current===o){N.current=o;return}if(R.current===o){R.current=null,N.current=o;return}if(N.current===o)return;N.current=o;let G;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const Z=`${o}:latest`;P.current!==Z&&_(o,G)},[l,o,i,a,s,C,c,_]);const oe=w.useCallback(()=>{m(null),b(!1),k(null),T(!1),j(!1),L(!1),B(null),z.current=null,$.current=null,N.current=null,P.current=null,R.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:M,threadStateError:H,hasMoreHistory:y,loadThread:_,navigateToCheckpoint:ae,loadOlderMessages:X,setCurrentCheckpointId:W,returnToLatest:D,handleStateHistoryEvent:Y,markSkipNextLoad:O,markStreamPendingThread:K,resetHistoryState:oe}}const yu=w.createContext(null),Su=w.createContext(null);function eo(){const e=w.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=w.useContext(Su);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Tu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=sw(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:M,returnToLatest:L,handleStateHistoryEvent:H,markSkipNextLoad:B,markStreamPendingThread:q,resetHistoryState:N}=bu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[z,$]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[R,P]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),N())},[l,d,N]);const I=w.useCallback(K=>$(()=>K),[]),V=w.useCallback(K=>P(()=>K),[]),J=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:z,navigateToCheckpoint:E,setCurrentCheckpointId:M,returnToLatest:L,loadThread:T,clearThread:z,respondToInterrupt:R,messagePreviews:x.messagePreviews,handleStateHistoryEvent:H,markSkipNextLoad:B,markStreamPendingThread:q,resetHistoryState:N,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,b,S,k,C,j,z,E,M,L,T,R,x.messagePreviews,H,B,q,N,m,f]),O=w.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:V}),[I,V]);return u.jsx(Su.Provider,{value:O,children:u.jsx(yu.Provider,{value:_,children:e})})}function ku(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return Mn(r,t)??null}function uw(e){const t=ku(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ku(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function dw(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 fw(e,t){const n=[...e].sort(dw);for(const r of n){if(r.messageId!==t)continue;const o=uw(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 Eu=w.createContext(null),Iu=w.createContext(!1);function hw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=w.useMemo(()=>wn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Vv({baseUrl:m}),[b,S]=w.useState(!1);return w.useEffect(()=>{S(g)},[g]),u.jsx(fu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Tu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(pw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function pw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:j}=Cu(),M=w.useCallback(R=>{v(R),f.current!==R.threadId&&((R.created??!f.current)&&b(R.threadId),S(R.threadId),m(R.threadId))},[v,b,S,m,f]),L=w.useCallback(R=>{R.type==="thread_info"?M(R):R.type==="state_history"?y(R):R.type==="tool.end"?i==null||i(R):T(R)},[M,y,T,i]),H=w.useCallback(R=>{a(R,L,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,L,r,o,s]),B=w.useRef(g);w.useEffect(()=>{B.current=g},[g]);const q=w.useCallback(async(R,P,I)=>{const V=f.current;if(!V)throw new Error("No active thread to handle interrupt");const J=P?I??!0:!1,_=B.current,O={threadId:V,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:J}};H(O)},[f,H]);w.useEffect(()=>{j(q)},[q,j]);const N=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(R){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",R)}},[t,k,m,l]);w.useEffect(()=>{E(N)},[N,E]);const z=w.useCallback(async(R,P)=>{let I=f.current;const V=(R==null?void 0:R.text)??"",J=(R==null?void 0:R.attachments)??[],_=(V==null?void 0:V.trim())??"",O={...(R==null?void 0:R.payload)??{}},K=Array.isArray(O.messages)?O.messages:void 0;K&&delete O.messages;const Y=!!(K&&K.length);if(!I&&!_&&J.length===0&&!Y)return;if(!I){const Oe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Te=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Oe}${Te}`,b(I),m(I)}const{contentParts:ae,filesInfo:W}=await ru(J),D=[...ae];_&&D.push({type:"text",text:V});const X=P==null?void 0:P.originalMessageId,oe=!!(P!=null&&P.edit&&X),G=!Y&&D.length>0;let Z=null;G&&(Z={id:oe?X:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},oe?C(Z,X):C(Z));const te=Y?K:Z?[Z]:[],se={...O,...W.length?{files_info:W}:{}};te.length?se.messages=te:"messages"in se||(se.messages=[]);let ue=(P==null?void 0:P.checkpointId)??g.id??void 0,ge=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(oe&&X){const Oe=fw(x,X);ue=Oe.checkpointId,ge=Oe.checkpointNs??void 0}const Re={threadId:I,payload:se,checkpointId:ue,checkpointNs:ge,edit:!!(P!=null&&P.edit)};H(Re)},[g,f,b,C,H,x]),$=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:z,send:z,stop:l,setAuthToken:h}),[c,d,z,l,h]);return u.jsx(Eu.Provider,{value:$,children:e})}function Li(){const e=w.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function mw(){return w.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function gw(e,t){if(Object.is(e,t))return!0;if(!Nu(e)||!Nu(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 Au(e){const t=w.useRef(e),n=w.useRef(e);return gw(t.current,e)||(t.current=e,n.current=e),n.current}function wr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=Au(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(tu,{apiConfig:h,children:u.jsx(hw,{...y,children:e})})}function to(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 br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function xw(e){if(typeof e!="string")return;const t=e.trim();if(t)return wn(t)}function ju(){const e=[br("__API_BASE_URL__"),br("__CHAT_API_BASE_URL__"),br("__CHAT_API_URL__")];for(const t of e){const n=xw(t);if(n)return n}}function _u(){const e=[br("__API_AUTH_TOKEN__"),br("__CHAT_API_KEY__"),br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Pu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return wn(t);return wn()}function Mu(){const e={},t=ju(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ru(){const e=Mu(),t=On.getAuthToken(),n=ju();return{apiBaseUrl:Pu(e.baseUrl,On.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Ou(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Du(e){try{const t={...e,apiBaseUrl:wn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&On.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vw(){const e=Ru(),t=Ou(),n=On.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(On.baseUrl,r,e.apiBaseUrl)}}function ww(e){On.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function ne(...e){return nx.twMerge(tx.clsx(e))}const bw=zr.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"}}),Qe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:ne(bw({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";function ce(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 Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Lu(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():Lu(e[o],null)}}}}function Fe(...e){return p.useCallback(Dn(...e),e)}function yw(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function un(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Sw(o,...t)]}function Sw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Cw=p[" useInsertionEffect ".trim().toString()]||It;function Ln({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var h;if(a){const m=kw(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Tw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Cw(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kw(e){return typeof e=="function"}var Ew=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=Ew.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=un(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=Fe(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),C=Fe(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Iw=p.createContext(void 0);function Xo(e){const t=p.useContext(Iw);return e||t||"ltr"}function vt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Nw(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Aw="DismissableLayer",Bi="dismissableLayer.update",jw="dismissableLayer.pointerDownOutside",_w="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Fu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=Fe(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=Mw(E=>{const j=E.target,M=[...c.branches].some(L=>L.contains(j));!k||M||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Rw(E=>{const j=E.target;[...c.branches].some(L=>L.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Nw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&($u=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=$u)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),zu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Bi,E),()=>document.removeEventListener(Bi,E)},[]),u.jsx(me.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});yr.displayName=Aw;var Pw="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=Fe(t,r);return p.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})});Bu.displayName=Pw;function Mw(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(jw,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 Rw(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(_w,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function zu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Hu(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?Fi(o,s):o.dispatchEvent(s)}var Ow=yr,Dw=Bu,zi=0;function Hi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Uu()),document.body.insertAdjacentElement("beforeend",e[1]??Uu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Uu(){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 Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Wu={bubbles:!1,cancelable:!0},Lw="FocusScope",Jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=vt(o),d=vt(s),h=p.useRef(null),m=Fe(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:$n(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||$n(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&$n(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,f.paused]),p.useEffect(()=>{if(a){qu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Wu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||($w(Uw(Vu(a)),{select:!0}),document.activeElement===g&&$n(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||$n(g??document.body,{select:!0}),a.removeEventListener(Wi,d),qu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[S,k]=Fw(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&$n(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&$n(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=Lw;function $w(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($n(r,{select:t}),document.activeElement!==n)return}function Fw(e){const t=Vu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function Vu(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 Ku(e,t){for(const n of e)if(!Bw(n,{upTo:t}))return n}function Bw(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 zw(e){return e instanceof HTMLInputElement&&"select"in e}function $n(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zw(e)&&t&&e.select()}}var qu=Hw();function Hw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Gu(e,t),e.unshift(t)},remove(t){var n;e=Gu(e,t),(n=e[0])==null||n.resume()}}}function Gu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Uw(e){return e.filter(t=>t.tagName!=="A")}var Ww=p[" useId ".trim().toString()]||(()=>{}),Vw=0;function Pt(e){const[t,n]=p.useState(Ww());return It(()=>{n(r=>r??String(Vw++))},[e]),t?`radix-${t}`:""}const Kw=["top","right","bottom","left"],Fn=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,bn=e=>({x:e,y:e}),qw={left:"right",right:"left",bottom:"top",top:"bottom"},Gw={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,Fn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Yw=new Set(["top","bottom"]);function yn(e){return Yw.has(jn(e))?"y":"x"}function Gi(e){return Ki(yn(e))}function Xw(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=Gi(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=es(i)),[i,es(i)]}function Jw(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Gw[t])}const Yu=["left","right"],Xu=["right","left"],Zw=["top","bottom"],Qw=["bottom","top"];function eb(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Zw:Qw;default:return[]}}function tb(e,t,n,r){const o=Sr(e);let s=eb(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>qw[t])}function nb(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?nb(e):{top:e,right:e,bottom:e,left:e}}function ts(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 Zu(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Gi(t),a=qi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const rb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Zu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Zu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=Ju(f),x=a[m?h==="floating"?"reference":"floating":h],y=ts(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=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ts(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const ob=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const h=Ju(d),m={x:n,y:r},f=Gi(o),v=qi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,M=E/2-g[v]/2-1,L=Fn(h[y],M),H=Fn(h[b],M),B=L,q=E-g[v]-H,N=E/2-g[v]/2+j,z=Vi(B,N,q),$=!l.arrow&&Sr(o)!=null&&N!==z&&s.reference[v]/2-(N<B?L:H)-g[v]/2<0,R=$?N<B?N-B:N-q:0;return{[f]:m[f]+R,data:{[f]:z,centerOffset:N-z-R,...$&&{alignmentOffset:R}},reset:$}}}),sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),b=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Jw(a)),T=v!=="none";!m&&T&&C.push(...tb(a,g,v,k));const E=[a,...C],j=await no(t,x),M=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&M.push(j[y]),h){const N=Xw(o,i,k);M.push(j[N[0]],j[N[1]])}if(L=[...L,{placement:o,overflows:M}],!M.every(N=>N<=0)){var H,B;const N=(((H=s.flip)==null?void 0:H.index)||0)+1,z=E[N];if(z&&(!(h==="alignment"?b!==yn(z):!1)||L.every(P=>yn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:N,overflows:L},reset:{placement:z}};let $=(B=L.filter(R=>R.overflows[0]<=0).sort((R,P)=>R.overflows[1]-P.overflows[1])[0])==null?void 0:B.placement;if(!$)switch(f){case"bestFit":{var q;const R=(q=L.filter(P=>{if(T){const I=yn(P.placement);return I===b||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,V)=>I+V,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:q[0];R&&($=R);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return Kw.some(t=>e[t]>=0)}const ib=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 no(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function ab(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=Sr(n),l=yn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,h=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const lb=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 ab(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}}}}},cb=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 no(t,l),h=yn(jn(o)),m=Ki(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=Vi(b,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=Vi(b,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},ub=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},h=yn(o),m=Ki(h);let f=d[m],v=d[h];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,b;const S=m==="y"?"width":"height",k=td.has(jn(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},db=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 no(t,c),h=jn(o),m=Sr(o),f=yn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,S=v-d.left-d.right,k=Fn(g-d[x],b),C=Fn(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Zt(d.left,0),H=Zt(d.right,0),B=Zt(d.top,0),q=Zt(d.bottom,0);f?j=v-2*(L!==0||H!==0?L+H:Zt(d.left,d.right)):E=g-2*(B!==0||q!==0?B+q:Zt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const M=await i.getDimensions(a.floating);return v!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Cr(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Sn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function dn(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Cn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function rd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const fb=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=fn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fb.has(o)}const hb=new Set(["table","td","th"]);function pb(e){return hb.has(Cr(e))}const mb=[":popover-open",":modal"];function rs(e){return mb.some(t=>{try{return e.matches(t)}catch{return!1}})}const gb=["transform","translate","scale","rotate","perspective"],xb=["transform","translate","scale","rotate","perspective","filter"],vb=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=dn(e)?fn(e):e;return gb.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)||xb.some(r=>(n.willChange||"").includes(r))||vb.some(r=>(n.contain||"").includes(r))}function wb(e){let t=Bn(e);for(;Cn(t)&&!Tr(t);){if(Xi(t))return t;if(rs(t))return null;t=Bn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bb=new Set(["html","body","#document"]);function Tr(e){return bb.has(Cr(e))}function fn(e){return Qt(e).getComputedStyle(e)}function os(e){return dn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Bn(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||Sn(e);return rd(t)?t.host:t}function od(e){const t=Bn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Cn(t)&&ro(t)?t:od(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=fn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Cn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return dn(e)?e:e.contextElement}function kr(e){const t=Qi(e);if(!Cn(t))return bn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const yb=bn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?yb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=bn(1);t&&(r?dn(r)&&(i=kr(r)):i=kr(e));const a=Sb(s,n,r)?id(s):bn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Qt(s),f=r&&dn(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),b=fn(g),S=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,h*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:h,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:er(Sn(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Cb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Sn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=bn(1);const d=bn(0),h=Cn(r);if((h||!h&&!s)&&((Cr(r)!=="body"||ro(i))&&(l=os(r)),Cn(r))){const f=er(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ad(i,l):bn(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 Tb(e){return Array.from(e.getClientRects())}function kb(e){const t=Sn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return fn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Eb(e,t){const n=Qt(e),r=Sn(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=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=ld&&(s-=v)}else c<=ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const Ib=new Set(["absolute","fixed"]);function Nb(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Cn(e)?kr(e):bn(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 cd(e,t,n){let r;if(t==="viewport")r=Eb(e,n);else if(t==="document")r=kb(Sn(e));else if(dn(t))r=Nb(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function ud(e,t){const n=Bn(e);return n===t||!dn(n)||Tr(n)?!1:fn(n).position==="fixed"||ud(n,t)}function Ab(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>dn(a)&&Cr(a)!=="body"),o=null;const s=fn(e).position==="fixed";let i=s?Bn(e):e;for(;dn(i)&&!Tr(i);){const a=fn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Ib.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Bn(i)}return t.set(e,r),r}function jb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Ab(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=cd(t,d,o);return c.top=Zt(h.top,c.top),c.right=Fn(h.right,c.right),c.bottom=Fn(h.bottom,c.bottom),c.left=Zt(h.left,c.left),c},cd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function _b(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Pb(e,t,n){const r=Cn(t),o=Sn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=bn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Cr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ad(o,a):bn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ea(e){return fn(e).position==="static"}function dd(e,t){if(!Cn(e)||fn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Sn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Cn(e)){let o=Bn(e);for(;o&&!Tr(o);){if(dn(o)&&!ea(o))return o;o=Bn(o)}return n}let r=dd(e,t);for(;r&&pb(r)&&ea(r);)r=dd(r,t);return r&&Tr(r)&&ea(r)&&!Xi(r)?n:r||wb(e)||n}const Mb=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:Pb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rb(e){return fn(e).direction==="rtl"}const Ob={convertOffsetParentRelativeRectToViewportRelativeRect:Cb,getDocumentElement:Sn,getClippingRect:jb,getOffsetParent:fd,getElementRects:Mb,getClientRects:Tb,getDimensions:_b,getScale:kr,isElement:dn,isRTL:Rb};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Db(e,t){let n=null,r;const o=Sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Qo(h),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(h+f)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,Fn(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!hd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Lb(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=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Db(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!hd(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)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const $b=lb,Fb=cb,Bb=sb,zb=db,Hb=ib,pd=ob,Ub=ub,Wb=(e,t,n)=>{const r=new Map,o={platform:Ob,...n},s={...o.platform,_c:r};return rb(e,t,{...o,platform:s})};var Vb=typeof document<"u",Kb=function(){},is=Vb?w.useLayoutEffect:Kb;function as(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(!as(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)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gd(e,t){const n=md(e);return Math.round(t*n)/n}function ta(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function qb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);as(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),b=p.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),S=p.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),j=p.useRef(d),M=l!=null,L=ta(l),H=ta(o),B=ta(c),q=p.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};H.current&&(P.platform=H.current),Wb(T.current,E.current,P).then(I=>{const V={...I,isPositioned:B.current!==!1};N.current&&!as(j.current,V)&&(j.current=V,Hr.flushSync(()=>{h(V)}))})},[m,t,n,H,B]);is(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[c]);const N=p.useRef(!1);is(()=>(N.current=!0,()=>{N.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,q);q()}},[k,C,q,L,M]);const z=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),$=p.useMemo(()=>({reference:k,floating:C}),[k,C]),R=p.useMemo(()=>{const P={position:n,left:0,top:0};if(!$.floating)return P;const I=gd($.floating,d.x),V=gd($.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+V+"px)",...md($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:V}},[n,a,$.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:q,refs:z,elements:$,floatingStyles:R}),[d,q,z,$,R])}const Gb=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?pd({element:r.current,padding:o}).fn(n):{}:r?pd({element:r,padding:o}).fn(n):{}}}},Yb=(e,t)=>({...$b(e),options:[e,t]}),Xb=(e,t)=>({...Fb(e),options:[e,t]}),Jb=(e,t)=>({...Ub(e),options:[e,t]}),Zb=(e,t)=>({...Bb(e),options:[e,t]}),Qb=(e,t)=>({...zb(e),options:[e,t]}),ey=(e,t)=>({...Hb(e),options:[e,t]}),ty=(e,t)=>({...Gb(e),options:[e,t]});var ny="Arrow",xd=p.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"})})});xd.displayName=ny;var ry=xd;function vd(e){const[t,n]=p.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[wd,Er]=un(na),[oy,bd]=wd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(oy,{scope:t,anchor:r,onAnchorChange:o,children:n})};yd.displayName=na;var Sd="PopperAnchor",Cd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=bd(Sd,n),i=p.useRef(null),a=Fe(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[sy,iy]=wd(ra),Td=p.forwardRef((e,t)=>{var W,D,X,oe,G,Z;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=bd(ra,n),[y,b]=p.useState(null),S=Fe(t,te=>b(te)),[k,C]=p.useState(null),T=vd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,M=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(c)?c:[c],B=H.length>0,q={padding:L,boundary:H.filter(ly),altBoundary:B},{refs:N,floatingStyles:z,placement:$,isPositioned:R,middlewareData:P}=qb({strategy:"fixed",placement:M,whileElementsMounted:(...te)=>Lb(...te,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Yb({mainAxis:o+j,alignmentAxis:i}),l&&Xb({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Jb():void 0,...q}),l&&Zb({...q}),Qb({...q,apply:({elements:te,rects:se,availableWidth:ue,availableHeight:ge})=>{const{width:Re,height:Oe}=se.reference,Te=te.floating.style;Te.setProperty("--radix-popper-available-width",`${ue}px`),Te.setProperty("--radix-popper-available-height",`${ge}px`),Te.setProperty("--radix-popper-anchor-width",`${Re}px`),Te.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),k&&ty({element:k,padding:a}),cy({arrowWidth:E,arrowHeight:j}),m&&ey({strategy:"referenceHidden",...q})]}),[I,V]=Id($),J=vt(v);It(()=>{R&&(J==null||J())},[R,J]);const _=(W=P.arrow)==null?void 0:W.x,O=(D=P.arrow)==null?void 0:D.y,K=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[Y,ae]=p.useState();return It(()=>{y&&ae(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:R?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(oe=P.transformOrigin)==null?void 0:oe.x,(G=P.transformOrigin)==null?void 0:G.y].join(" "),...((Z=P.hide)==null?void 0:Z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(sy,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:O,shouldHideArrow:K,children:u.jsx(me.div,{"data-side":I,"data-align":V,...g,ref:S,style:{...g.style,animation:R?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ay={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=iy(kd,r),i=ay[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(ry,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function ly(e){return e!==null}var cy=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]=Id(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Id(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=yd,sa=Cd,ia=Td,aa=Ed,uy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Po.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});so.displayName=uy;function dy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=fy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Fe(r.ref,hy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function fy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=dy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ls(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=ls(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function hy(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 la="rovingFocusGroup.onEntryFocus",py={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,my]=Yo(io),[gy,Ad]=un(io,[my]),[xy,vy]=gy(io),jd=p.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wy,{...e,ref:t})})}));jd.displayName=io;var wy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=Fe(t,m),v=Xo(s),[g,x]=Ln({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,b]=p.useState(!1),S=vt(c),k=Nd(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(la,S),()=>j.removeEventListener(la,S)},[S]),u.jsx(xy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(j=>x(j),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:p.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,j=>{const M=!C.current;if(j.target===j.currentTarget&&M&&!y){const L=new CustomEvent(la,py);if(j.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=k().filter($=>$.focusable),B=H.find($=>$.active),q=H.find($=>$.id===g),z=[B,q,...H].filter(Boolean).map($=>$.ref.current);Md(z,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>b(!1))})})}),_d="RovingFocusGroupItem",Pd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=vy(_d,n),h=d.currentTabStopId===c,m=Nd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Sy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Cy(S,k+1):S.slice(k+1)}setTimeout(()=>Md(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Pd.displayName=_d;var by={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sy(e,t,n){const r=yy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return by[r]}function Md(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Cy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ty=jd,ky=Pd,Ey=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ir=new WeakMap,cs=new WeakMap,us={},ua=0,Rd=function(e){return e&&(e.host||Rd(e.parentNode))},Iy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Rd(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})},Ny=function(e,t,n,r){var o=Iy(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Ir.get(m)||0)+1,x=(s.get(m)||0)+1;Ir.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.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(),ua++,function(){i.forEach(function(h){var m=Ir.get(h)-1,f=s.get(h)-1;Ir.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ua--,ua||(Ir=new WeakMap,Ir=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ey(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ny(r,o,n,"aria-hidden")):function(){return null}},Tn=function(){return Tn=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},Tn.apply(this,arguments)};function Od(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ay(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 ds="right-scroll-bar-position",fs="width-before-scroll-bar",jy="with-scroll-bars-hidden",_y="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Py(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 My=typeof window<"u"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function Ry(e,t){var n=Py(null,function(r){return e.forEach(function(o){return fa(o,r)})});return My(function(){var r=Dd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Dd.set(n,e)},[e]),n}function Oy(e){return e}function Dy(e,t){t===void 0&&(t=Oy);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 Ly(e){e===void 0&&(e={});var t=Dy(null);return t.options=Tn({async:!0,ssr:!1},e),t}var Ld=function(e){var t=e.sideCar,n=Od(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Tn({},n))};Ld.isSideCarExport=!0;function $y(e,t){return e.useMedium(t),Ld}var $d=Ly(),ha=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ha,onWheelCapture:ha,onTouchMoveCapture:ha}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,k=Od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ry([n,t]),E=Tn(Tn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:$d,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Tn(Tn({},E),{ref:T})):p.createElement(b,Tn({},E,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Fy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function By(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fy();return t&&e.setAttribute("nonce",t),e}function zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Uy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=By())&&(zy(t,n),Hy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wy=function(){var e=Uy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Wy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vy={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},Ky=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[pa(n),pa(r),pa(o)]},qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vy;var t=Ky(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])}},Gy=Fd(),Nr="data-scroll-locked",Yy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
40
|
.`.concat(jy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -76,11 +76,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
76
76
|
`)},Bd=function(){var e=parseInt(document.body.getAttribute(Nr)||"0",10);return isFinite(e)?e:0},Xy=function(){p.useEffect(function(){return document.body.setAttribute(Nr,(Bd()+1).toString()),function(){var e=Bd()-1;e<=0?document.body.removeAttribute(Nr):document.body.setAttribute(Nr,e.toString())}},[])},Jy=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Xy();var s=p.useMemo(function(){return qy(o)},[o]);return p.createElement(Gy,{styles:Yy(s,!t,o,n?"":"!important")})},ma=!1;if(typeof window<"u")try{var ps=Object.defineProperty({},"passive",{get:function(){return ma=!0,!0}});window.addEventListener("test",ps,ps),window.removeEventListener("test",ps,ps)}catch{ma=!1}var Ar=ma?{passive:!1}:!1,Zy=function(e){return e.tagName==="TEXTAREA"},zd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Zy(e)&&n[t]==="visible")},Qy=function(e){return zd(e,"overflowY")},e0=function(e){return zd(e,"overflowX")},Hd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ud(e,r);if(o){var s=Wd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},t0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},n0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ud=function(e,t){return e==="v"?Qy(t):e0(t)},Wd=function(e,t){return e==="v"?t0(t):n0(t)},r0=function(e,t){return e==="h"&&t==="rtl"?-1:1},o0=function(e,t,n,r,o){var s=r0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,h=0,m=0;do{if(!a)break;var f=Wd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Ud(e,a)&&(h+=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(h)<1||!d&&Math.abs(m)<1)&&(c=!0),c},ms=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Vd=function(e){return[e.deltaX,e.deltaY]},Kd=function(e){return e&&"current"in e?e.current:e},s0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},i0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},a0=0,jr=[];function l0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(a0++)[0],s=p.useState(Fd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Ay([e.lockRef.current],(e.shards||[]).map(Kd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ms(g),b=n.current,S="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Hd(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Hd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var M=r.current||C;return o0(M,x,g,M==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!jr.length||jr[jr.length-1]!==s)){var y="deltaY"in x?Vd(x):ms(x),b=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&s0(C.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Kd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,b){var S={name:g,delta:x,target:y,should:b,shadowParent:c0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=ms(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,Vd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,ms(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return jr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",d,Ar),function(){jr=jr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",d,Ar)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:i0(o)}):null,f?p.createElement(Jy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function c0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const u0=$y($d,l0);var gs=p.forwardRef(function(e,t){return p.createElement(hs,Tn({},e,{ref:t,sideCar:u0}))});gs.classNames=hs.classNames;var ga=["Enter"," "],d0=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],f0=[...d0,...qd],h0={ltr:[...ga,"ArrowRight"],rtl:[...ga,"ArrowLeft"]},p0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,m0,g0]=Yo(ao),[tr,Gd]=un(ao,[g0,Er,Ad]),xs=Er(),Yd=Ad(),[x0,nr]=tr(ao),[v0,co]=tr(ao),Xd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=xs(t),[l,c]=p.useState(null),d=p.useRef(!1),h=wt(s),m=Xo(o);return p.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(oa,{...a,children:u.jsx(x0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(v0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Xd.displayName=ao;var w0="MenuAnchor",xa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(sa,{...o,...r,ref:t})});xa.displayName=w0;var va="MenuPortal",[b0,Jd]=tr(va,{forceMount:void 0}),Zd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(va,t);return u.jsx(b0,{scope:t,forceMount:n,children:u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Zd.displayName=va;var nn="MenuContent",[y0,wa]=tr(nn),Qd=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(S0,{...o,ref:t}):u.jsx(C0,{...o,ref:t})})})})}),S0=p.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu),r=p.useRef(null),o=Be(t,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(ba,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),C0=p.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu);return u.jsx(ba,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),T0=Yt.createSlot("MenuContent.ScrollLock"),ba=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(nn,n),y=co(nn,n),b=xs(n),S=Yd(n),k=m0(n),[C,T]=p.useState(null),E=p.useRef(null),j=Be(t,E,x.onContentChange),M=p.useRef(0),L=p.useRef(""),B=p.useRef(0),W=p.useRef(null),K=p.useRef("right"),N=p.useRef(0),U=v?gs:p.Fragment,$=v?{as:T0,allowPinchZoom:!0}:void 0,O=I=>{var V,D;const q=L.current+I,J=k().filter(Z=>!Z.disabled),_=document.activeElement,R=(V=J.find(Z=>Z.ref.current===_))==null?void 0:V.textValue,G=J.map(Z=>Z.textValue),X=D0(G,q,R),se=(D=J.find(Z=>Z.textValue===X))==null?void 0:D.ref.current;(function Z(ne){L.current=ne,window.clearTimeout(M.current),ne!==""&&(M.current=window.setTimeout(()=>Z(""),1e3))})(q),se&&setTimeout(()=>se.focus())};p.useEffect(()=>()=>window.clearTimeout(M.current),[]),Hi();const P=p.useCallback(I=>{var J,_;return K.current===((J=W.current)==null?void 0:J.side)&&$0(I,(_=W.current)==null?void 0:_.area)},[]);return u.jsx(y0,{scope:n,searchRef:L,onItemEnter:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:p.useCallback(I=>{var q;P(I)||((q=E.current)==null||q.focus(),T(null))},[P]),onTriggerLeave:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:B,onPointerGraceIntentChange:p.useCallback(I=>{W.current=I},[]),children:u.jsx(U,{...$,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,I=>{var q;I.preventDefault(),(q=E.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Ty,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ia,{role:"menu","aria-orientation":"vertical","data-state":xf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,R=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!_&&R&&O(I.key));const G=E.current;if(I.target!==G||!f0.includes(I.key))return;I.preventDefault();const se=k().filter(V=>!V.disabled).map(V=>V.ref.current);qd.includes(I.key)&&se.reverse(),R0(se)}),onBlur:ce(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ce(e.onPointerMove,fo(I=>{const q=I.target,J=N.current!==I.clientX;if(I.currentTarget.contains(q)&&J){const _=I.clientX>N.current?"right":"left";K.current=_,N.current=I.clientX}}))})})})})})})});Qd.displayName=nn;var k0="MenuGroup",ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});ya.displayName=k0;var E0="MenuLabel",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});ef.displayName=E0;var vs="MenuItem",tf="menu.itemSelect",ws=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(vs,e.__scopeMenu),a=wa(vs,e.__scopeMenu),l=Be(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(tf,{bubbles:!0,cancelable:!0});h.addEventListener(tf,f=>r==null?void 0:r(f),{once:!0}),Fi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(nf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ce(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||ga.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ws.displayName=vs;var nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=wa(vs,n),a=Yd(n),l=p.useRef(null),c=Be(t,l),[d,h]=p.useState(!1),[m,f]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(ky,{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:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>h(!0)),onBlur:ce(e.onBlur,()=>h(!1))})})})}),I0="MenuCheckboxItem",rf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(cf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ws,{role:"menuitemcheckbox","aria-checked":bs(n)?"mixed":n,...o,ref:t,"data-state":Ca(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(bs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rf.displayName=I0;var of="MenuRadioGroup",[N0,A0]=tr(of,{value:void 0,onValueChange:()=>{}}),sf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=wt(r);return u.jsx(N0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ya,{...o,ref:t})})});sf.displayName=of;var af="MenuRadioItem",lf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=A0(af,e.__scopeMenu),s=n===o.value;return u.jsx(cf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ca(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lf.displayName=af;var Sa="MenuItemIndicator",[cf,j0]=tr(Sa,{checked:!1}),uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=j0(Sa,n);return u.jsx(Wt,{present:r||bs(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":Ca(s.checked)})})});uf.displayName=Sa;var _0="MenuSeparator",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});df.displayName=_0;var P0="MenuArrow",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(aa,{...o,...r,ref:t})});ff.displayName=P0;var M0="MenuSub",[vN,hf]=tr(M0),uo="MenuSubTrigger",pf=p.forwardRef((e,t)=>{const n=nr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=hf(uo,e.__scopeMenu),s=wa(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(xa,{asChild:!0,...c,children:u.jsx(nf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xf(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(h=>{var f,v;d();const m=(f=n.content)==null?void 0:f.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"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:b,y:m.top},{x:S,y:m.top},{x:S,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(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||h0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});pf.displayName=uo;var mf="MenuSubContent",gf=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=hf(mf,e.__scopeMenu),l=p.useRef(null),c=Be(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(ba,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=p0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});gf.displayName=mf;function xf(e){return e?"open":"closed"}function bs(e){return e==="indeterminate"}function Ca(e){return bs(e)?"indeterminate":e?"checked":"unchecked"}function R0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function O0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function D0(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=O0(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 L0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return L0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var F0=Xd,B0=xa,z0=Zd,H0=Qd,U0=ya,W0=ef,V0=ws,K0=rf,q0=sf,G0=lf,Y0=uf,X0=df,J0=ff,Z0=pf,Q0=gf,ys="DropdownMenu",[eS,wN]=un(ys,[Gd]),$t=Gd(),[tS,vf]=eS(ys),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=p.useRef(null),[d,h]=Ln({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(tS,{scope:t,triggerId:Pt(),triggerRef:c,contentId:Pt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(F0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};wf.displayName=ys;var bf="DropdownMenuTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(bf,n),i=$t(n);return u.jsx(B0,{asChild:!0,...i,children:u.jsx(me.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Dn(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yf.displayName=bf;var nS="DropdownMenuPortal",Sf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(z0,{...r,...n})};Sf.displayName=nS;var Cf="DropdownMenuContent",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Cf,n),s=$t(n),i=p.useRef(!1);return u.jsx(H0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(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)"}})});Tf.displayName=Cf;var rS="DropdownMenuGroup",oS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(U0,{...o,...r,ref:t})});oS.displayName=rS;var sS="DropdownMenuLabel",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(W0,{...o,...r,ref:t})});kf.displayName=sS;var iS="DropdownMenuItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(V0,{...o,...r,ref:t})});Ef.displayName=iS;var aS="DropdownMenuCheckboxItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(K0,{...o,...r,ref:t})});If.displayName=aS;var lS="DropdownMenuRadioGroup",cS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(q0,{...o,...r,ref:t})});cS.displayName=lS;var uS="DropdownMenuRadioItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(G0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuItemIndicator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Y0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuSeparator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(X0,{...o,...r,ref:t})});jf.displayName=fS;var hS="DropdownMenuArrow",pS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(J0,{...o,...r,ref:t})});pS.displayName=hS;var mS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});_f.displayName=mS;var gS="DropdownMenuSubContent",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...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)"}})});Pf.displayName=gS;var xS=wf,vS=yf,wS=Sf,Mf=Tf,Rf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf;const Ss=xS,Cs=vS,bS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Bf,{ref:o,className:te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));bS.displayName=Bf.displayName;const yS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{ref:n,className:te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));yS.displayName=zf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(wS,{children:u.jsx(Mf,{ref:r,sideOffset:t,className:te("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ho.displayName=Mf.displayName;const zn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));zn.displayName=Of.displayName;const SS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Df,{ref:o,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx($f,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));SS.displayName=Df.displayName;const CS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Lf,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx($f,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));CS.displayName=Lf.displayName;const TS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Rf,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));TS.displayName=Rf.displayName;const kS=p.forwardRef(({className:e,...t},n)=>u.jsx(Ff,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));kS.displayName=Ff.displayName;const Ta=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ta.displayName="Textarea";const ES=1e4;function Hf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=ES,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,b]=w.useState(e),S=(x?i:y)??"",[k,C]=w.useTransition(),T=w.useRef(null),E=w.useRef(0),j=w.useRef(null),M=w.useRef("");w.useEffect(()=>{x||(b(e??""),j.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[L,B]=w.useState(null),W=w.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),K=w.useMemo(()=>v??W,[v,W]),N=w.useCallback(R=>{const G=K(R);return B(G),g==null||g(G),M.current=R,G},[K,g]),U=w.useCallback(()=>{const R=T.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);w.useEffect(()=>{U()},[U,S]),w.useEffect(()=>{if(!L)return;const R=(S??"").trim();M.current!==R&&N(R)},[S,L,N]);const $=w.useCallback((R,{fromUser:G})=>{x||b(R),G&&(a==null||a(R))},[x,a]),O=w.useCallback(async R=>{R&&R.preventDefault();const G=(S??"").trim();if(!G&&!f||N(G))return;const X=++E.current;j.current={id:X,shouldClear:!0},C(()=>{var se,V,D;try{const Z=l(G);Z&&typeof Z.then=="function"?Z.then(()=>{var ne,Y;((ne=j.current)==null?void 0:ne.id)===X&&j.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((Y=j.current)==null?void 0:Y.id)===X&&(j.current=null)}).catch(()=>{var ne;((ne=j.current)==null?void 0:ne.id)===X&&(j.current=null)}):(((se=j.current)==null?void 0:se.id)===X&&j.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((V=j.current)==null?void 0:V.id)===X&&(j.current=null))}catch{((D=j.current)==null?void 0:D.id)===X&&(j.current=null)}})},[S,l,f,x,a,N]),P=w.useCallback(R=>{const G=R.target.value;$(G,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),L&&N(G.trim())},[$,N,L]),I=w.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),O()):R.key==="Escape"&&t&&(R.preventDefault(),c==null||c())},[O,t,c]),_=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:R=>void O(R),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ta,{ref:T,value:S,onChange:P,onKeyDown:I,placeholder:t?"Edit your message...":n,className:_,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(Qe,{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(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(ue.Send,{size:16})})})]})})}const IS=w.memo(Hf),Ts=0,Hn=1,_r=2,Uf=4;function Wf(e){return()=>e}function NS(e){e()}function Vf(e,t){return n=>e(t(n))}function Kf(e,t){return()=>e(t)}function AS(e,t){return n=>e(t,n)}function ka(e){return e!==void 0}function jS(...e){return()=>{e.map(NS)}}function Pr(){}function ks(e,t){return t(e),e}function _S(e,t){return t(e)}function it(...e){return e}function Ze(e,t){return e(Hn,t)}function De(e,t){e(Ts,t)}function Ea(e){e(_r)}function bt(e){return e(Uf)}function xe(e,t){return Ze(e,AS(t,Ts))}function hn(e,t){const n=e(Hn,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 Gf(e,t){return e===t}function at(e=Gf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>Vf(t,e)}function kn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=PS(...t);return(r,o)=>{switch(r){case _r:Ea(e);return;case Hn:return Ze(e,n(o))}}}function En(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function ze(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function PS(...e){return t=>e.reduceRight(_S,t)}function MS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Hn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Pr);case _r:r(),n=null;return}}}function oe(e){let t=e;const n=We();return(r,o)=>{switch(r){case Ts:t=o;break;case Hn:{o(t);break}case Uf:return t}return n(r,o)}}function Mt(e,t){return ks(oe(t),n=>xe(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case _r:e.splice(0,e.length);return;case Hn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(We(),t=>xe(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:RS(),singleton:n}}const RS=()=>Symbol();function OS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function St(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&De(t,n)})}),function(s,i){switch(s){case _r:{Ea(t);return}case Hn:return r===o&&i(n),Ze(t,i)}}}function Ee(e,t=Gf){return ee(e,at(t))}function Ia(...e){return function(t,n){switch(t){case _r:return;case Hn:return jS(...e.map(r=>Ze(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const DS={0:"debug",3:"error",1:"log",2:"warn"},LS=()=>typeof globalThis>"u"?window:globalThis,Un=qe(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=LS().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[DS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return Na(e,t,n).callbackRef}function Na(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 $S(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const h=FS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Yf("column-gap",getComputedStyle(d).columnGap,o):Yf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Na(c,n,l)}function FS(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},Vt.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Yf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Xf(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 h,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Na(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=qe(()=>{const e=We(),t=We(),n=oe(0),r=We(),o=oe(0),s=We(),i=We(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),h=We(),m=We(),f=oe(!1),v=oe(!1),g=oe(!1);return xe(ee(e,he(({scrollTop:x})=>x)),t),xe(ee(e,he(({scrollHeight:x})=>x)),i),xe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Jf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===po}function mo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function pn(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function tn(e,t,n){return ot(e)?eh(t,n,1):t===e.k?Tt(e,{k:t,v:n}):t<e.k?th(Tt(e,{l:tn(e.l,t,n)})):th(Tt(e,{r:tn(e.r,t,n)}))}function Mr(){return po}function Es(e,t,n){if(ot(e))return[];const r=pn(e,t)[0];return BS(ja(e,r,n))}function Aa(e,t){if(ot(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Qf(r);return Is(Tt(e,{k:s,l:Zf(r),v:i}))}}else return t<n?Is(Tt(e,{l:Aa(r,t)})):Is(Tt(e,{r:Aa(o,t)}))}function sr(e){return ot(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function ja(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ja(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ja(s,t,n))),a}function Is(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(_a(t))return nh(Tt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return Tt(t.r,{l:Tt(t,{r:t.r.l}),lvl:n,r:Tt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Pa(Tt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return Tt(o,{l:Tt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Pa(Tt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Tt(e,t){return eh(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 Zf(e){return ot(e.r)?e.l:Is(Tt(e,{r:Zf(e.r)}))}function _a(e){return ot(e)||e.lvl>e.r.lvl}function Qf(e){return ot(e.r)?[e.k,e.v]:Qf(e.r)}function eh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function th(e){return Pa(nh(e))}function nh(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?Tt(t,{r:Tt(e,{l:t.r})}):e}function Pa(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?Tt(n,{l:Tt(e,{r:n.l}),lvl:t+1}):e}function BS(e){return Jf(e,({k:t,v:n})=>({index:t,value:n}))}function rh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ma=qe(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function oh(e,t,n){return e[Ns(e,t,n)]}function Ns(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 zS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Wn(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!ot(e.groupOffsetTree)}function Ra({index:e},t){return t===e?0:t<e?-1:1}function HS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function US(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(XS(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=Aa(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function WS(e){return typeof e.groupIndex<"u"}function VS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=oh(t,e,Ra),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function sh(e,t){if(!As(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ih(e,t,n){if(WS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=sh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function KS(e,t,n,r=0){return r>0&&(t=Math.max(t,oh(e,r,Ra).offset)),Jf(zS(e,t,n,VS),YS)}function qS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,f),i)}else[i,a]=US(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Oa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,xo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function GS(e){return sr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ah(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 Oa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ns(o,t-1,Ra),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Es(n,t,1/0)){const h=c-s,m=h*i+a+h*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 YS(e){return{index:e.index,value:e}}function XS(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 JS={offsetHeight:"height",offsetWidth:"width"},In=qe(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Mt(r,0),s=We(),i=We(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),h=oe((C,T)=>Wn(C,JS[T])),m=oe(void 0),f=oe(0),v=HS(),g=Mt(ee(n,ze(l,e,f),En(qS,v),at()),v),x=Mt(ee(l,at(),En((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);xe(ee(l,Ne(C=>C.length>0),ze(g,f),he(([C,T,E])=>{const j=C.reduce((M,L,B)=>tn(M,L,xo(L,T.offsetTree,E)||B),Mr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),xe(ee(r,ze(g),Ne(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),xe(c,d);const y=Mt(ee(c,he(C=>C===void 0)),!0);xe(ee(d,Ne(C=>C!==void 0&&ot(bt(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=en(ee(n,ze(g),En(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),he(C=>C.changed)));Ze(ee(a,En((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=bt(g);if(C>0)De(t,!0),De(s,C+ah(C,T));else if(C<0){const E=bt(x);E.length>0&&(C-=ah(-C,E)),De(i,C)}}),Ze(ee(a,ze(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=en(s);xe(ee(s,ze(g),he(([C,T])=>{const E=T.groupIndices.length>0,j=[],M=T.lastSize;if(E){const L=mo(T.sizeTree,0);let B=0,W=0;for(;B<C;){const N=T.groupIndices[W],U=T.groupIndices.length===W+1?1/0:T.groupIndices[W+1]-N-1;j.push({endIndex:N,size:L,startIndex:N}),j.push({endIndex:N+1+U-1,size:M,startIndex:N+1}),W++,B+=U+1}const K=sr(T.sizeTree);return B!==C&&K.shift(),K.reduce((N,{k:U,v:$})=>{let O=N.ranges;return N.prevSize!==0&&(O=[...N.ranges,{endIndex:U+C-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:U+C,prevSize:$,ranges:O}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((L,{k:B,v:W})=>({prevIndex:B+C,prevSize:W,ranges:[...L.ranges,{endIndex:B+C-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:M,ranges:[]}).ranges})),n);const k=en(ee(i,ze(g,f),he(([C,{offsetTree:T},E])=>{const j=-C;return xo(j,T,E)})));return xe(ee(i,ze(g,f),he(([C,T,E])=>{if(T.groupIndices.length>0){if(ot(T.sizeTree))return T;let j=Mr();const M=bt(x);let L=0,B=0,W=0;for(;L<-C;){W=M[B];const K=M[B+1]-W-1;B++,L+=K+1}if(j=sr(T.sizeTree).reduce((K,{k:N,v:U})=>tn(K,Math.max(0,N+C),U),j),L!==-C){const K=mo(T.sizeTree,W);j=tn(j,0,K);const N=pn(T.sizeTree,-C+1)[1];j=tn(j,1,N)}return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((M,{k:L,v:B})=>tn(M,Math.max(0,L+C),B),Mr());return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(Un,Ma),{singleton:!0});function ZS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lh=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=en(ee(s,he(ZS)));return xe(ee(a,he(l=>l.totalCount)),n),xe(ee(a,he(l=>l.groupIndices)),e),xe(ee(St(o,t,r),Ne(([l,c])=>As(c)),he(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(In,Ft)),Vn=qe(([{log:e}])=>{const t=oe(!1),n=en(ee(t,Ne(r=>r),at()));return Ze(t,r=>{r&&bt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},it(Un),{singleton:!0}),QS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ch(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!QS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:m}])=>{const f=We(),v=We(),g=oe(0);let x=null,y=null,b=null;function S(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),De(l,!1)}return xe(ee(f,ze(n,h,r,g,a,i,m),ze(e,s,o),he(([[k,C,T,E,j,M,L,B],W,K,N])=>{const U=ch(k),{align:$,behavior:O,offset:P}=U,I=E-1,q=ih(U,C,I);let J=xo(q,C.offsetTree,W)+M;$==="end"?(J+=K+pn(C.sizeTree,q)[1]-T+N,q===I&&(J+=L)):$==="center"?J+=(K+pn(C.sizeTree,q)[1]-T+N)/2:J-=j,P&&(J+=P);const _=R=>{S(),R?(B("retrying to scroll to",{location:k},Vt.DEBUG),De(f,k)):(De(v,!0),B("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),O==="smooth"){let R=!1;b=Ze(t,G=>{R=R||G}),x=hn(d,()=>{_(R)})}else x=hn(ee(t,eC(150)),_);return y=setTimeout(()=>{S()},1200),De(l,!0),B("scrolling from index to",{behavior:O,index:q,top:J},Vt.DEBUG),{behavior:O,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},it(In,Ft,Un),{singleton:!0});function eC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Da(e,t){e==0?t():requestAnimationFrame(()=>{Da(e-1,t)})}function La(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const wo=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return xe(ee(i,ze(l),Ne(([d,h])=>!!h),kn(!1)),a),xe(ee(i,ze(l),Ne(([d,h])=>!!h),kn(!1)),c),Ze(ee(St(t,i),ze(a,n,e,c),Ne(([[,d],h,{sizeTree:m},f,v])=>d&&(!ot(m)||ka(f))&&!h&&!v),ze(l)),([,d])=>{hn(o,()=>{De(c,!0)}),Da(4,()=>{hn(r,()=>{De(a,!0)}),De(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(In,Ft,vo,Vn),{singleton:!0});function uh(e,t){return Math.abs(e-t)<1.01}const bo="up",yo="down",tC="none",nC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},rC=0,So=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=We(),c=We(),d=oe(4),h=oe(rC),m=Mt(ee(Ia(ee(Ee(o),rr(1),kn(!0)),ee(Ee(o),rr(1),kn(!1),qf(100))),at()),!1),f=Mt(ee(Ia(ee(n,kn(!0)),ee(n,kn(!1),qf(200))),at()),!1);xe(ee(St(Ee(o),Ee(h)),he(([b,S])=>b<=S),at()),a),xe(ee(a,_n(50)),c);const v=en(ee(St(r,Ee(s),Ee(t),Ee(e),Ee(d)),En((b,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const M=k+C-S>-j,L={scrollHeight:S,scrollTop:k,viewportHeight:C};if(M){let W,K;return k>b.state.scrollTop?(W="SCROLLED_DOWN",K=b.state.scrollTop-k):(W="SIZE_DECREASED",K=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:K,state:L}}let B;return L.scrollHeight>b.state.scrollHeight?B="SIZE_INCREASED":C<b.state.viewportHeight?B="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?B="SCROLLING_UPWARDS":B="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:B,state:L}},nC),at((b,S)=>b&&b.atBottom===S.atBottom))),g=Mt(ee(r,En((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(uh(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ne(b=>b.changed),he(b=>b.jump)),0);xe(ee(v,he(b=>b.atBottom)),i),xe(ee(i,_n(50)),l);const x=oe(yo);xe(ee(r,he(({scrollTop:b})=>b),at(),En((b,S)=>bt(f)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?bo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),he(b=>b.direction)),x),xe(ee(r,_n(50),kn(tC)),x);const y=oe(0);return xe(ee(m,Ne(b=>!b),kn(0)),y),xe(ee(o,_n(100),ze(m),Ne(([b,S])=>!!S),En(([b,S],[k])=>[S,k],[0,0]),he(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},it(Ft)),js="top",_s="bottom",dh="none";function fh(e,t,n){return typeof e=="number"?n===bo&&t===js||n===yo&&t===_s?e:0:n===bo?t===js?e.main:e.reverse:t===_s?e.main:e.reverse}function hh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const $a=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=oe(0),a=oe(0),l=oe(0),c=Mt(ee(St(Ee(r),Ee(o),Ee(n),Ee(s,go),Ee(l),Ee(i),Ee(t),Ee(e),Ee(a)),he(([d,h,m,[f,v],g,x,y,b,S])=>{const k=d-b,C=x+y,T=Math.max(m-k,0);let E=dh;const j=hh(S,js),M=hh(S,_s);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+C-j&&(E=bo),v<d-T+h+M&&(E=yo),E!==dh?[Math.max(k-m-fh(g,js,E)-j,0),k-T-y+h+fh(g,_s,E)+M]:null}),Ne(d=>d!=null),at(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Ft),{singleton:!0});function oC(e,t,n){if(As(t)){const r=sh(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Fa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ps(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:mh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:mh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function ph(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=La(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ps(c,[],a,o,n,r)}function mh(e,t,n){if(e.length===0)return[];if(!As(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=Es(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ir=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},m,{didMount:f},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=We();xe(s.topItemsIndexes,g);const b=Mt(ee(St(f,v,Ee(l,go),Ee(o),Ee(r),Ee(c),d,Ee(g),Ee(t),Ee(n),e),Ne(([T,E,,j,,,,,,,M])=>{const L=M&&M.length!==j;return T&&!E&&!L}),he(([,,[T,E],j,M,L,B,W,K,N,U])=>{const $=M,{offsetTree:O,sizeTree:P}=$,I=bt(x);if(j===0)return{...Fa,totalCount:j};if(T===0&&E===0)return I===0?{...Fa,totalCount:j}:ph(I,L,M,K,N,U||[]);if(ot(P))return I>0?null:Ps(oC(La(L,j),$,U),[],j,N,$,K);const q=[];if(W.length>0){const X=W[0],se=W[W.length-1];let V=0;for(const D of Es(P,X,se)){const Z=D.value,ne=Math.max(D.start,X),Y=Math.min(D.end,se);for(let H=ne;H<=Y;H++)q.push({data:U==null?void 0:U[H],index:H,offset:V,size:Z}),V+=Z}}if(!B)return Ps([],q,j,N,$,K);const J=W.length>0?W[W.length-1]+1:0,_=KS(O,T,E,J);if(_.length===0)return null;const R=j-1,G=ks([],X=>{for(const se of _){const V=se.value;let D=V.offset,Z=se.start;const ne=V.size;if(V.offset<T){Z+=Math.floor((T-V.offset+N)/(ne+N));const H=Z-se.start;D+=H*ne+H*N}Z<J&&(D+=(J-Z)*ne,Z=J);const Y=Math.min(se.end,R);for(let H=Z;H<=Y&&!(D>=E);H++)X.push({data:U==null?void 0:U[H],index:H,offset:D,size:ne}),D+=ne+N}});return Ps(G,q,j,N,$,K)}),Ne(T=>T!==null),at()),Fa);xe(ee(e,Ne(ka),he(T=>T==null?void 0:T.length)),o),xe(ee(b,he(T=>T.topListHeight)),h),xe(h,a),xe(ee(b,he(T=>[T.top,T.bottom])),i),xe(ee(b,he(T=>T.items)),y);const S=en(ee(b,Ne(({items:T})=>T.length>0),ze(o,e),Ne(([{items:T},E])=>T[T.length-1].originalIndex===E-1),he(([,T,E])=>[T-1,E]),at(go),he(([T])=>T))),k=en(ee(b,_n(200),Ne(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),he(({items:T})=>T[0].index),at())),C=en(ee(b,Ne(({items:T})=>T.length>0),he(({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}}),at(rh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},it(In,lh,$a,wo,vo,So,Vn,Ma),{singleton:!0}),gh=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Mt(ee(St(n,e,r,t,o),he(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return xe(Ee(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Ft,ir),{singleton:!0}),sC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Mt(ee(St(n,e,t),Ne(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),_n(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Ft,gh),{singleton:!0}),xh=qe(()=>({context:oe(null)})),iC=({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,vh=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return xe(ee(d,ze(t,l,n,s,o,r,a),ze(e),he(([[h,m,f,v,g,x,y,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=iC,done:E,...j}=h,M=ih(h,m,v-1),L=xo(M,m.offsetTree,S)+g+x,B=L+pn(m.sizeTree,M)[1],W=b+x,K=b+f-y,N=T({itemBottom:B,itemTop:L,locationParams:{align:k,behavior:C,...j},viewportBottom:K,viewportTop:W});return N?E&&hn(ee(i,Ne(U=>!U),rr(bt(i)?1:2)),E):E&&E(),N}),Ne(h=>h!==null)),c),{scrollIntoView:d}},it(In,Ft,vo,ir,Un),{singleton:!0});function wh(e){return e?e==="smooth"?"smooth":"auto":!1}const aC=(e,t)=>typeof e=="function"?wh(e(t)):t&&wh(e),lC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:h},{context:m},{scrollIntoView:f}])=>{const v=oe(!1),g=We();let x=null;function y(C){De(i,{align:"end",behavior:C,index:"LAST"})}Ze(ee(St(ee(Ee(t),rr(1)),l),ze(Ee(v),s,a,h),he(([[C,T],E,j,M,L])=>{let B=T&&M,W="auto";return B&&(W=aC(E,j||L),B=B&&!!W),{followOutputBehavior:W,shouldFollow:B,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=hn(e,()=>{bt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function b(C){const T=hn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(bt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(ee(St(Ee(v),t,c),Ne(([C,,T])=>C&&T),En(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),ze(v,t)),([,C])=>{bt(a)&&b(C!==!1)}),Ze(g,()=>{b(bt(v)!==!1)}),Ze(St(Ee(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=oe(null),k=We();return xe(Ia(ee(Ee(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(Ee(t))),k),Ze(ee(St(ee(k,rr(1)),l),ze(Ee(S),a,h,m),he(([[C,T],E,j,M,L])=>T&&j&&(E==null?void 0:E({context:L,totalCount:C,scrollingInProgress:M}))),Ne(C=>!!C),_n(0)),C=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),De(f,C)}):x=hn(e,()=>{bt(d)("scrolling into view",{}),De(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},it(In,So,vo,wo,Vn,Un,Ft,xh,vh)),cC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(ee(a,ze(s),Ne(([,l])=>l!==0),ze(o,r,t,n,e),he(([[,l],c,d,h,m,f=[]])=>ph(l,c,d,h,m,f))),i),{}),it(In,wo,ir,Vn),{singleton:!0}),uC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Ze(ee(e,ze(r),Ne(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{hn(ee(n,rr(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{De(t,o)})})}),{initialScrollTop:r}},it(Vn,Ft,ir),{singleton:!0}),bh=qe(([{scrollVelocity:e}])=>{const t=oe(!1),n=We(),r=oe(!1);return xe(ee(e,ze(r,t,n),Ne(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Ze(ee(St(t,e,n),ze(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(So),{singleton:!0}),Ba=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=oe(!1),i=oe(void 0);return xe(ee(St(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),xe(ee(t,ze(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Ft)),dC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=oe(void 0),h=oe(null),m=oe(null);return xe(a,h),xe(l,m),Ze(ee(c,ze(t,r,i,h,m,n)),([f,v,g,x,y,b,S])=>{const k=GS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),xe(ee(d,Ne(ka),he(fC)),o),xe(ee(s,ze(d),Ne(([,f])=>f!==void 0),at(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(In,Ft,wo,Vn,Ba));function fC(e){return{align:"start",index:0,offset:e.scrollTop}}const hC=qe(([{topItemsIndexes:e}])=>{const t=oe(0);return xe(ee(t,Ne(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ir));function yh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const pC=yh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),mC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=en(ee(l,ze(i),En(([,y,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const M=k+T;let L=0;return b===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(L=M-S,L!==0&&(L+=j))),[L,C,E,M]},[0,[],0,0]),Ne(([y])=>y!==0),ze(r,a,n,o,f,v),Ne(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===bo),he(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(De(t,{behavior:"auto",top:-y}),De(e,0)):(De(e,0),De(t,{behavior:"auto",top:-y}))}return Ze(ee(g,ze(e,s)),([y,b,S])=>{S&&pC()?De(e,b-y):x(-y)}),Ze(ee(St(Mt(s,!1),e,v),Ne(([y,b,S])=>!y&&!S&&b!==0),he(([y,b])=>b),_n(1)),x),xe(ee(h,he(y=>({top:-y}))),t),Ze(ee(c,ze(m,d),he(([y,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(b.length===0)return T(y);{let E=0;const j=mo(k,0);let M=0,L=0;for(;M<y;){M++,E+=j;let B=b.length===L+1?1/0:b[L+1]-b[L]-1;M+B>y&&(E-=j,B=y-M+1),M+=B,E+=T(B),L++}return E}})),y=>{De(e,y),requestAnimationFrame(()=>{De(t,{top:y}),requestAnimationFrame(()=>{De(e,0),De(v,!1)})})}),{deviation:e}},it(Ft,So,ir,In,Un,Ma)),gC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it($a,cC,Vn,bh,gh,uC,sC,Ba,vh,Un,xh)),Sh=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},M])=>(xe(k.rangeChanged,M.scrollSeekRangeChanged),xe(ee(M.windowViewportRect,he(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...M,...g,sizes:l,...x}),it(In,wo,Ft,dC,lC,ir,vo,mC,hC,lh,gC));function xC(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 Ms=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ch(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&&De(x.propsReady,!1);for(const b of r){const S=x[t.required[b]];De(S,y[b])}for(const b of o)if(b in y){const S=x[t.optional[b]];De(S,y[b])}x.propsReady&&De(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=S=>{const k=x[t.methods[b]];De(k,S)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=MS(x[t.events[b]]),y),{})}const h=w.forwardRef((x,y)=>{const{children:b,...S}=x,[k]=w.useState(()=>ks(OS(e),E=>{l(E,S)})),[C]=w.useState(Kf(d,k));Ms(()=>{for(const E of i)E in S&&Ze(C[E],S[E]);return()=>{Object.values(C).map(Ea)}},[S,C,k]),Ms(()=>{l(k,S)}),w.useImperativeHandle(y,Wf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...xC([...r,...o,...i],S),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{De(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(S=>Ze(y,S),[y]);return w.useSyncExternalStore(b,()=>bt(y),()=>bt(y))},v=x=>{const y=w.useContext(a)[x],[b,S]=w.useState(Kf(bt,y));return Ms(()=>Ze(y,k=>{k!==b&&S(Wf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ms(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Th=w.createContext(void 0),kh=w.createContext(void 0),Eh=typeof document<"u"?w.useLayoutEffect:w.useEffect;function za(e){return"self"in e}function vC(e){return"body"in e}function Ih(e,t,n,r=Pr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(vC(x)||za(x)){const b=za(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Po.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);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 f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;za(f)?(x=Math.max(Wn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Wn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),uh(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}),f.scrollTo(m)}function h(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Ha="-webkit-sticky",Nh="sticky",Ua=yh(()=>{if(typeof document>"u")return Nh;const e=document.createElement("div");return e.style.position=Ha,e.style.position===Ha?Ha:Nh});function Wa(e){return e}const wC=qe(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Wa),o=oe("div"),s=oe(Pr),i=(a,l=null)=>Mt(ee(n,he(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),bC=qe(([e,t])=>({...e,...t}),it(Sh,wC)),yC=({height:e})=>u.jsx("div",{style:{height:e}}),SC={overflowAnchor:"none",position:Ua(),zIndex:1},Ah={overflowAnchor:"none"},CC={...Ah,display:"inline-block",height:"100%"},jh=w.memo(function({showTopList:e=!1}){const t=je("listState"),n=rn("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),c=je("context"),d=je("groupContent"),h=je("trackItemSizes"),m=je("itemSize"),f=je("log"),v=rn("gap"),g=je("horizontalDirection"),{callbackRef:x}=$S(n,m,h,e?Pr:a,f,v,o,g,je("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Va("deviation",N=>{y!==N&&b(N)});const S=je("EmptyPlaceholder"),k=je("ScrollSeekPlaceholder")||yC,C=je("ListComponent"),T=je("ItemComponent"),E=je("GroupComponent"),j=je("computeItemKey"),M=je("isSeeking"),L=je("groupIndices").length>0,B=je("alignToBottom"),W=je("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:B?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:B?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Rt(S,c)}):u.jsx(C,{...Rt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:K,children:(e?t.topItems:t.items).map(N=>{const U=N.originalIndex,$=j(U+t.firstItemIndex,N.data,c);return M?w.createElement(k,{...Rt(k,c),height:N.size,index:N.index,key:$,type:N.type||"item",...N.type==="group"?{}:{groupIndex:N.groupIndex}}):N.type==="group"?w.createElement(E,{...Rt(E,c),"data-index":U,"data-item-index":N.index,"data-known-size":N.size,key:$,style:SC},d(N.index,c)):w.createElement(T,{...Rt(T,c),...IC(T,N.data),"data-index":U,"data-item-group-index":N.groupIndex,"data-item-index":N.index,"data-known-size":N.size,key:$,style:g?CC:Ah},L?l(N.index,N.groupIndex,N.data,c):l(N.index,N.data,c))})})}),TC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},kC={outline:"none",overflowX:"auto",position:"relative"},Rs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),EC={position:Ua(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function IC(e,t){return{item:typeof e=="string"?void 0:t}}const NC=w.memo(function(){const e=je("HeaderComponent"),t=rn("headerHeight"),n=je("HeaderFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),AC=w.memo(function(){const e=je("FooterComponent"),t=rn("footerHeight"),n=je("HeaderFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null});function _h({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"),h=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Ih(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?kC:TC,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Ph({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"),h=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ih(a,c,l,v,m);return Eh(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+h}:{}},...i,...Rt(l,s),children:r})})}const jC=({children:e})=>{const t=w.useContext(Th),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=w.useMemo(()=>Vf(n,l=>Wn(l,s?"width":"height")),[n,s]),a=or(i,!0,je("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Rs(o),children:e})},_C=({children:e})=>{const t=w.useContext(Th),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=je("customScrollParent"),s=Xf(n,o,je("skipAnimationFrameInResizeObserver")),i=je("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:Rs(i),children:e})},PC=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...EC,marginTop:`${n}px`},o=je("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},MC=w.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return u.jsxs(r||t?DC:OC,{...e,context:o,children:[n&&u.jsx(PC,{children:u.jsx(jh,{showTopList:!0})}),u.jsxs(r||t?_C:jC,{children:[u.jsx(NC,{}),u.jsx(jh,{}),u.jsx(AC,{})]})]})}),{Component:RC,useEmitter:Va,useEmitterValue:je,usePublisher:rn}=Ch(bC,{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"}},MC),OC=_h({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),DC=Ph({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),LC=RC;it(Sh,qe(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Wa),a=oe(Pr),l=(c,d=null)=>Mt(ee(s,he(h=>h[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Ua();const Mh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},$C={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Rh,floor:Os,max:Co,min:Ka,round:Oh}=Math;function Dh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function FC(e){return{...$C,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function BC(e,t){return e&&e.column===t.column&&e.row===t.row}const zC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=oe(0),E=oe(0),j=oe(Mh),M=oe({height:0,width:0}),L=oe({height:0,width:0}),B=We(),W=We(),K=oe(0),N=oe(null),U=oe({column:0,row:0}),$=We(),O=We(),P=oe(!1),I=oe(0),q=oe(!0),J=oe(!1),_=oe(!1);Ze(ee(v,ze(I),Ne(([D,Z])=>!!Z)),()=>{De(q,!1)}),Ze(ee(St(v,q,L,M,I,J),Ne(([D,Z,ne,Y,,H])=>D&&!Z&&ne.height!==0&&Y.height!==0&&!H)),([,,,,D])=>{De(J,!0),Da(1,()=>{De(B,D)}),hn(ee(c),()=>{De(t,[0,0]),De(q,!0)})}),xe(ee(O,Ne(D=>D!=null&&D.scrollTop>0),kn(0)),E),Ze(ee(v,ze(O),Ne(([,D])=>D!=null)),([,D])=>{D&&(De(M,D.viewport),De(L,D.item),De(U,D.gap),D.scrollTop>0&&(De(P,!0),hn(ee(c,rr(1)),Z=>{De(P,!1)}),De(l,{top:D.scrollTop})))}),xe(ee(M,he(({height:D})=>D)),h),xe(ee(St(Ee(M,Ds),Ee(L,Ds),Ee(U,(D,Z)=>D&&D.column===Z.column&&D.row===Z.row),Ee(c)),he(([D,Z,ne,Y])=>({gap:ne,item:Z,scrollTop:Y,viewport:D}))),$),xe(ee(St(Ee(T),r,Ee(U,BC),Ee(L,Ds),Ee(M,Ds),Ee(N),Ee(E),Ee(P),Ee(q),Ee(I)),Ne(([,,,,,,,D])=>!D),he(([D,[Z,ne],Y,H,ae,le,fe,,be,Re])=>{const{column:Oe,row:Te}=Y,{height:nt,width:ht}=H,{width:kt}=ae;if(fe===0&&(D===0||kt===0))return Mh;if(ht===0){const Et=La(Re,D),yt=Et+Math.max(fe-1,0);return FC(Dh(Et,yt,le))}const Ke=Lh(kt,ht,Oe);let Ge,Ve;be?Z===0&&ne===0&&fe>0?(Ge=0,Ve=fe-1):(Ge=Ke*Os((Z+Te)/(nt+Te)),Ve=Ke*Rh((ne+Te)/(nt+Te))-1,Ve=Ka(D-1,Co(Ve,Ke-1)),Ge=Ka(Ve,Co(0,Ge))):(Ge=0,Ve=-1);const $e=Dh(Ge,Ve,le),{bottom:He,top:mt}=$h(ae,Y,H,$e),Dt=Rh(D/Ke),lt=Dt*nt+(Dt-1)*Te-He;return{bottom:He,itemHeight:nt,items:$e,itemWidth:ht,offsetBottom:lt,offsetTop:mt,top:mt}})),j),xe(ee(N,Ne(D=>D!==null),he(D=>D.length)),T),xe(ee(St(M,L,j,U),Ne(([D,Z,{items:ne}])=>ne.length>0&&Z.height!==0&&D.height!==0),he(([D,Z,{items:ne},Y])=>{const{bottom:H,top:ae}=$h(D,Y,Z,ne);return[ae,H]}),at(go)),t);const R=oe(!1);xe(ee(c,ze(R),he(([D,Z])=>Z||D!==0)),R);const G=en(ee(St(j,T),Ne(([{items:D}])=>D.length>0),ze(R),Ne(([[D,Z],ne])=>{const Y=D.items[D.items.length-1].index===Z-1;return(ne||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===Z)&&Y}),he(([[,D]])=>D-1),at())),X=en(ee(Ee(j),Ne(({items:D})=>D.length>0&&D[0].index===0),kn(0),at())),se=en(ee(Ee(j),ze(P),Ne(([{items:D},Z])=>D.length>0&&!Z),he(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),at(rh),_n(0)));xe(se,f.scrollSeekRangeChanged),xe(ee(B,ze(M,L,T,U),he(([D,Z,ne,Y,H])=>{const ae=ch(D),{align:le,behavior:fe,offset:be}=ae;let Re=ae.index;Re==="LAST"&&(Re=Y-1),Re=Co(0,Re,Ka(Y-1,Re));let Oe=qa(Z,H,ne,Re);return le==="end"?Oe=Oh(Oe-Z.height+ne.height):le==="center"&&(Oe=Oh(Oe-Z.height/2+ne.height/2)),be&&(Oe+=be),{behavior:fe,top:Oe}})),l);const V=Mt(ee(j,he(D=>D.offsetBottom+D.bottom)),0);return xe(ee(k,he(D=>({height:D.visibleHeight,width:D.visibleWidth}))),M),{customScrollParent:x,data:N,deviation:K,footerHeight:o,gap:U,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:O,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:l,scrollToIndex:B,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:M,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:V,...m,endReached:G,propsReady:g,rangeChanged:se,startReached:X,stateChanged:$,stateRestoreInProgress:P,...C}},it($a,Ft,So,bh,Vn,Ba,Un));function Lh(e,t,n){return Co(1,Os((e+n)/(Os(t)+n)))}function $h(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=Lh(e.width,n.width,t.column),s=Os(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const HC=qe(()=>{const e=oe(h=>`Item ${h}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Wa),i=oe("div"),a=oe(Pr),l=(h,m=null)=>Mt(ee(t,he(f=>f[h]),at()),m),c=oe(!1),d=oe(!1);return xe(Ee(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")}}),UC=qe(([e,t])=>({...e,...t}),it(zC,HC)),WC=w.memo(function(){const e=ut("gridState"),t=ut("listClassName"),n=ut("itemClassName"),r=ut("itemContent"),o=ut("computeItemKey"),s=ut("isSeeking"),i=on("scrollHeight"),a=ut("ItemComponent"),l=ut("ListComponent"),c=ut("ScrollSeekPlaceholder"),d=ut("context"),h=on("itemDimensions"),m=on("gap"),f=ut("log"),v=ut("stateRestoreInProgress"),g=on("reportReadyState"),x=or(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Bh("column-gap",getComputedStyle(y).columnGap,f),row:Bh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Eh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Rt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{...Rt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),VC=w.memo(function(){const e=ut("HeaderComponent"),t=on("headerHeight"),n=ut("headerFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),KC=w.memo(function(){const e=ut("FooterComponent"),t=on("footerHeight"),n=ut("headerFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),qC=({children:e})=>{const t=w.useContext(kh),n=on("itemDimensions"),r=on("viewportDimensions"),o=or(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:Rs(!1),children:e})},GC=({children:e})=>{const t=w.useContext(kh),n=on("windowViewportRect"),r=on("itemDimensions"),o=ut("customScrollParent"),s=Xf(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:Rs(!1),children:e})},YC=w.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?JC:XC,o=n||t?GC:qC,s=ut("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(VC,{}),u.jsx(WC,{}),u.jsx(KC,{})]})})}),{useEmitter:Fh,useEmitterValue:ut,usePublisher:on}=Ch(UC,{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"}},YC),XC=_h({useEmitter:Fh,useEmitterValue:ut,usePublisher:on}),JC=Ph({useEmitter:Fh,useEmitterValue:ut,usePublisher:on});function Bh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const ZC=zr.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 zh({className:e,variant:t,...n}){return u.jsx("div",{className:te(ZC({variant:t}),e),...n})}var Ls="Dialog",[Hh,yN]=un(Ls),[QC,mn]=Hh(Ls),Uh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(QC,{scope:t,triggerRef:a,contentRef:l,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Uh.displayName=Ls;var Wh="DialogTrigger",Vh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Wh,n),s=Be(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xa(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Vh.displayName=Wh;var Ga="DialogPortal",[eT,Kh]=Hh(Ga,{forceMount:void 0}),qh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=mn(Ga,t);return u.jsx(eT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};qh.displayName=Ga;var $s="DialogOverlay",Gh=p.forwardRef((e,t)=>{const n=Kh($s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(nT,{...o,ref:t})}):null});Gh.displayName=$s;var tT=Yt.createSlot("DialogOverlay.RemoveScroll"),nT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn($s,n);return u.jsx(gs,{as:tT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":Xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Yh=p.forwardRef((e,t)=>{const n=Kh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn(ar,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(rT,{...o,ref:t}):u.jsx(oT,{...o,ref:t})})});Yh.displayName=ar;var rT=p.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=p.useRef(null),o=Be(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(Xh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),oT=p.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Xh,{...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()}})}),Xh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=mn(ar,n),l=p.useRef(null),c=Be(t,l);return Hi(),u.jsxs(u.Fragment,{children:[u.jsx(Jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(yr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(sT,{titleId:a.titleId}),u.jsx(aT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ya="DialogTitle",Jh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Ya,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Jh.displayName=Ya;var Zh="DialogDescription",Qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Zh,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});Qh.displayName=Zh;var ep="DialogClose",tp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(ep,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});tp.displayName=ep;function Xa(e){return e?"open":"closed"}var np="DialogTitleWarning",[SN,rp]=yw(np,{contentName:ar,titleName:Ya,docsSlug:"dialog"}),sT=({titleId:e})=>{const t=rp(np),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},a0=0,jr=[];function l0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(a0++)[0],s=p.useState(Fd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Ay([e.lockRef.current],(e.shards||[]).map(Kd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ms(g),b=n.current,S="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Hd(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Hd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var M=r.current||C;return o0(M,x,g,M==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!jr.length||jr[jr.length-1]!==s)){var y="deltaY"in x?Vd(x):ms(x),b=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&s0(C.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Kd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,b){var S={name:g,delta:x,target:y,should:b,shadowParent:c0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=ms(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,Vd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,ms(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return jr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",d,Ar),function(){jr=jr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",d,Ar)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:i0(o)}):null,f?p.createElement(Jy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function c0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const u0=$y($d,l0);var gs=p.forwardRef(function(e,t){return p.createElement(hs,Tn({},e,{ref:t,sideCar:u0}))});gs.classNames=hs.classNames;var ga=["Enter"," "],d0=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],f0=[...d0,...qd],h0={ltr:[...ga,"ArrowRight"],rtl:[...ga,"ArrowLeft"]},p0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,m0,g0]=Yo(ao),[tr,Gd]=un(ao,[g0,Er,Ad]),xs=Er(),Yd=Ad(),[x0,nr]=tr(ao),[v0,co]=tr(ao),Xd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=xs(t),[l,c]=p.useState(null),d=p.useRef(!1),h=vt(s),m=Xo(o);return p.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(oa,{...a,children:u.jsx(x0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(v0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Xd.displayName=ao;var w0="MenuAnchor",xa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(sa,{...o,...r,ref:t})});xa.displayName=w0;var va="MenuPortal",[b0,Jd]=tr(va,{forceMount:void 0}),Zd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(va,t);return u.jsx(b0,{scope:t,forceMount:n,children:u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Zd.displayName=va;var nn="MenuContent",[y0,wa]=tr(nn),Qd=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(S0,{...o,ref:t}):u.jsx(C0,{...o,ref:t})})})})}),S0=p.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu),r=p.useRef(null),o=Fe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(ba,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),C0=p.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu);return u.jsx(ba,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),T0=Yt.createSlot("MenuContent.ScrollLock"),ba=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(nn,n),y=co(nn,n),b=xs(n),S=Yd(n),k=m0(n),[C,T]=p.useState(null),E=p.useRef(null),j=Fe(t,E,x.onContentChange),M=p.useRef(0),L=p.useRef(""),H=p.useRef(0),B=p.useRef(null),q=p.useRef("right"),N=p.useRef(0),z=v?gs:p.Fragment,$=v?{as:T0,allowPinchZoom:!0}:void 0,R=I=>{var W,D;const V=L.current+I,J=k().filter(X=>!X.disabled),_=document.activeElement,O=(W=J.find(X=>X.ref.current===_))==null?void 0:W.textValue,K=J.map(X=>X.textValue),Y=D0(K,V,O),ae=(D=J.find(X=>X.textValue===Y))==null?void 0:D.ref.current;(function X(oe){L.current=oe,window.clearTimeout(M.current),oe!==""&&(M.current=window.setTimeout(()=>X(""),1e3))})(V),ae&&setTimeout(()=>ae.focus())};p.useEffect(()=>()=>window.clearTimeout(M.current),[]),Hi();const P=p.useCallback(I=>{var J,_;return q.current===((J=B.current)==null?void 0:J.side)&&$0(I,(_=B.current)==null?void 0:_.area)},[]);return u.jsx(y0,{scope:n,searchRef:L,onItemEnter:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:p.useCallback(I=>{var V;P(I)||((V=E.current)==null||V.focus(),T(null))},[P]),onTriggerLeave:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:H,onPointerGraceIntentChange:p.useCallback(I=>{B.current=I},[]),children:u.jsx(z,{...$,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,I=>{var V;I.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Ty,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ia,{role:"menu","aria-orientation":"vertical","data-state":xf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!_&&O&&R(I.key));const K=E.current;if(I.target!==K||!f0.includes(I.key))return;I.preventDefault();const ae=k().filter(W=>!W.disabled).map(W=>W.ref.current);qd.includes(I.key)&&ae.reverse(),R0(ae)}),onBlur:ce(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ce(e.onPointerMove,fo(I=>{const V=I.target,J=N.current!==I.clientX;if(I.currentTarget.contains(V)&&J){const _=I.clientX>N.current?"right":"left";q.current=_,N.current=I.clientX}}))})})})})})})});Qd.displayName=nn;var k0="MenuGroup",ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});ya.displayName=k0;var E0="MenuLabel",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});ef.displayName=E0;var vs="MenuItem",tf="menu.itemSelect",ws=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(vs,e.__scopeMenu),a=wa(vs,e.__scopeMenu),l=Fe(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(tf,{bubbles:!0,cancelable:!0});h.addEventListener(tf,f=>r==null?void 0:r(f),{once:!0}),Fi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(nf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ce(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||ga.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ws.displayName=vs;var nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=wa(vs,n),a=Yd(n),l=p.useRef(null),c=Fe(t,l),[d,h]=p.useState(!1),[m,f]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(ky,{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:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>h(!0)),onBlur:ce(e.onBlur,()=>h(!1))})})})}),I0="MenuCheckboxItem",rf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(cf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ws,{role:"menuitemcheckbox","aria-checked":bs(n)?"mixed":n,...o,ref:t,"data-state":Ca(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(bs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rf.displayName=I0;var of="MenuRadioGroup",[N0,A0]=tr(of,{value:void 0,onValueChange:()=>{}}),sf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=vt(r);return u.jsx(N0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ya,{...o,ref:t})})});sf.displayName=of;var af="MenuRadioItem",lf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=A0(af,e.__scopeMenu),s=n===o.value;return u.jsx(cf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ca(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lf.displayName=af;var Sa="MenuItemIndicator",[cf,j0]=tr(Sa,{checked:!1}),uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=j0(Sa,n);return u.jsx(Wt,{present:r||bs(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":Ca(s.checked)})})});uf.displayName=Sa;var _0="MenuSeparator",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});df.displayName=_0;var P0="MenuArrow",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(aa,{...o,...r,ref:t})});ff.displayName=P0;var M0="MenuSub",[vN,hf]=tr(M0),uo="MenuSubTrigger",pf=p.forwardRef((e,t)=>{const n=nr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=hf(uo,e.__scopeMenu),s=wa(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(xa,{asChild:!0,...c,children:u.jsx(nf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xf(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(h=>{var f,v;d();const m=(f=n.content)==null?void 0:f.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"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:b,y:m.top},{x:S,y:m.top},{x:S,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(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||h0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});pf.displayName=uo;var mf="MenuSubContent",gf=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=hf(mf,e.__scopeMenu),l=p.useRef(null),c=Fe(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(ba,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=p0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});gf.displayName=mf;function xf(e){return e?"open":"closed"}function bs(e){return e==="indeterminate"}function Ca(e){return bs(e)?"indeterminate":e?"checked":"unchecked"}function R0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function O0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function D0(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=O0(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 L0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return L0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var F0=Xd,B0=xa,z0=Zd,H0=Qd,U0=ya,W0=ef,V0=ws,K0=rf,q0=sf,G0=lf,Y0=uf,X0=df,J0=ff,Z0=pf,Q0=gf,ys="DropdownMenu",[eS,wN]=un(ys,[Gd]),$t=Gd(),[tS,vf]=eS(ys),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=p.useRef(null),[d,h]=Ln({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(tS,{scope:t,triggerId:Pt(),triggerRef:c,contentId:Pt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(F0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};wf.displayName=ys;var bf="DropdownMenuTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(bf,n),i=$t(n);return u.jsx(B0,{asChild:!0,...i,children:u.jsx(me.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Dn(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yf.displayName=bf;var nS="DropdownMenuPortal",Sf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(z0,{...r,...n})};Sf.displayName=nS;var Cf="DropdownMenuContent",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Cf,n),s=$t(n),i=p.useRef(!1);return u.jsx(H0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(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)"}})});Tf.displayName=Cf;var rS="DropdownMenuGroup",oS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(U0,{...o,...r,ref:t})});oS.displayName=rS;var sS="DropdownMenuLabel",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(W0,{...o,...r,ref:t})});kf.displayName=sS;var iS="DropdownMenuItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(V0,{...o,...r,ref:t})});Ef.displayName=iS;var aS="DropdownMenuCheckboxItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(K0,{...o,...r,ref:t})});If.displayName=aS;var lS="DropdownMenuRadioGroup",cS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(q0,{...o,...r,ref:t})});cS.displayName=lS;var uS="DropdownMenuRadioItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(G0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuItemIndicator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Y0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuSeparator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(X0,{...o,...r,ref:t})});jf.displayName=fS;var hS="DropdownMenuArrow",pS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(J0,{...o,...r,ref:t})});pS.displayName=hS;var mS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});_f.displayName=mS;var gS="DropdownMenuSubContent",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...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)"}})});Pf.displayName=gS;var xS=wf,vS=yf,wS=Sf,Mf=Tf,Rf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf;const Ss=xS,Cs=vS,bS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Bf,{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(de.ChevronRight,{className:"ml-auto h-4 w-4"})]}));bS.displayName=Bf.displayName;const yS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{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}));yS.displayName=zf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(wS,{children:u.jsx(Mf,{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})}));ho.displayName=Mf.displayName;const zn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{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}));zn.displayName=Of.displayName;const SS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Df,{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($f,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));SS.displayName=Df.displayName;const CS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Lf,{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($f,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));CS.displayName=Lf.displayName;const TS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Rf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));TS.displayName=Rf.displayName;const kS=p.forwardRef(({className:e,...t},n)=>u.jsx(Ff,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));kS.displayName=Ff.displayName;const Ta=p.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}));Ta.displayName="Textarea";const ES=1e4;function Hf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=ES,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,b]=w.useState(e),S=(x?i:y)??"",[k,C]=w.useTransition(),T=w.useRef(null),E=w.useRef(0),j=w.useRef(null),M=w.useRef("");w.useEffect(()=>{x||(b(e??""),j.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[L,H]=w.useState(null),B=w.useCallback(O=>O.length>s?`Message too long (${O.length}/${s} characters)`:null,[s]),q=w.useMemo(()=>v??B,[v,B]),N=w.useCallback(O=>{const K=q(O);return H(K),g==null||g(K),M.current=O,K},[q,g]),z=w.useCallback(()=>{const O=T.current;O&&(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)},[]);w.useEffect(()=>{z()},[z,S]),w.useEffect(()=>{if(!L)return;const O=(S??"").trim();M.current!==O&&N(O)},[S,L,N]);const $=w.useCallback((O,{fromUser:K})=>{x||b(O),K&&(a==null||a(O))},[x,a]),R=w.useCallback(async O=>{O&&O.preventDefault();const K=(S??"").trim();if(!K&&!f||N(K))return;const Y=++E.current;j.current={id:Y,shouldClear:!0},C(()=>{var ae,W,D;try{const X=l(K);X&&typeof X.then=="function"?X.then(()=>{var oe,G;((oe=j.current)==null?void 0:oe.id)===Y&&j.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((G=j.current)==null?void 0:G.id)===Y&&(j.current=null)}).catch(()=>{var oe;((oe=j.current)==null?void 0:oe.id)===Y&&(j.current=null)}):(((ae=j.current)==null?void 0:ae.id)===Y&&j.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((W=j.current)==null?void 0:W.id)===Y&&(j.current=null))}catch{((D=j.current)==null?void 0:D.id)===Y&&(j.current=null)}})},[S,l,f,x,a,N]),P=w.useCallback(O=>{const K=O.target.value;$(K,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),L&&N(K.trim())},[$,N,L]),I=w.useCallback(O=>{O.key==="Enter"&&!O.shiftKey?(O.preventDefault(),R()):O.key==="Escape"&&t&&(O.preventDefault(),c==null||c())},[R,t,c]),_=`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:O=>void R(O),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ta,{ref:T,value:S,onChange:P,onKeyDown:I,placeholder:t?"Edit your message...":n,className:_,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(Qe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(de.Square,{size:16})}):u.jsx(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(de.Send,{size:16})})})]})})}const IS=w.memo(Hf),Ts=0,Hn=1,_r=2,Uf=4;function Wf(e){return()=>e}function NS(e){e()}function Vf(e,t){return n=>e(t(n))}function Kf(e,t){return()=>e(t)}function AS(e,t){return n=>e(t,n)}function ka(e){return e!==void 0}function jS(...e){return()=>{e.map(NS)}}function Pr(){}function ks(e,t){return t(e),e}function _S(e,t){return t(e)}function it(...e){return e}function Ze(e,t){return e(Hn,t)}function De(e,t){e(Ts,t)}function Ea(e){e(_r)}function wt(e){return e(Uf)}function ve(e,t){return Ze(e,AS(t,Ts))}function hn(e,t){const n=e(Hn,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 Gf(e,t){return e===t}function at(e=Gf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>Vf(t,e)}function kn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=PS(...t);return(r,o)=>{switch(r){case _r:Ea(e);return;case Hn:return Ze(e,n(o))}}}function En(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Be(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function PS(...e){return t=>e.reduceRight(_S,t)}function MS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Hn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Pr);case _r:r(),n=null;return}}}function ie(e){let t=e;const n=We();return(r,o)=>{switch(r){case Ts:t=o;break;case Hn:{o(t);break}case Uf:return t}return n(r,o)}}function Mt(e,t){return ks(ie(t),n=>ve(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case _r:e.splice(0,e.length);return;case Hn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(We(),t=>ve(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:RS(),singleton:n}}const RS=()=>Symbol();function OS(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=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&De(t,n)})}),function(s,i){switch(s){case _r:{Ea(t);return}case Hn:return r===o&&i(n),Ze(t,i)}}}function Ee(e,t=Gf){return ee(e,at(t))}function Ia(...e){return function(t,n){switch(t){case _r:return;case Hn:return jS(...e.map(r=>Ze(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const DS={0:"debug",3:"error",1:"log",2:"warn"},LS=()=>typeof globalThis>"u"?window:globalThis,Un=qe(()=>{const e=ie(3);return{log:ie((t,n,r=1)=>{var o;const s=(o=LS().VIRTUOSO_LOG_LEVEL)!=null?o:wt(e);r>=s&&console[DS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return Na(e,t,n).callbackRef}function Na(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 $S(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const h=FS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Yf("column-gap",getComputedStyle(d).columnGap,o):Yf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Na(c,n,l)}function FS(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},Vt.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Yf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Xf(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 h,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Na(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=qe(()=>{const e=We(),t=We(),n=ie(0),r=We(),o=ie(0),s=We(),i=We(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),h=We(),m=We(),f=ie(!1),v=ie(!1),g=ie(!1);return ve(ee(e,he(({scrollTop:x})=>x)),t),ve(ee(e,he(({scrollHeight:x})=>x)),i),ve(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Jf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===po}function mo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function pn(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function tn(e,t,n){return ot(e)?eh(t,n,1):t===e.k?Ct(e,{k:t,v:n}):t<e.k?th(Ct(e,{l:tn(e.l,t,n)})):th(Ct(e,{r:tn(e.r,t,n)}))}function Mr(){return po}function Es(e,t,n){if(ot(e))return[];const r=pn(e,t)[0];return BS(ja(e,r,n))}function Aa(e,t){if(ot(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Qf(r);return Is(Ct(e,{k:s,l:Zf(r),v:i}))}}else return t<n?Is(Ct(e,{l:Aa(r,t)})):Is(Ct(e,{r:Aa(o,t)}))}function sr(e){return ot(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function ja(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ja(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ja(s,t,n))),a}function Is(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(_a(t))return nh(Ct(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return Ct(t.r,{l:Ct(t,{r:t.r.l}),lvl:n,r:Ct(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Pa(Ct(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return Ct(o,{l:Ct(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Pa(Ct(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Ct(e,t){return eh(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 Zf(e){return ot(e.r)?e.l:Is(Ct(e,{r:Zf(e.r)}))}function _a(e){return ot(e)||e.lvl>e.r.lvl}function Qf(e){return ot(e.r)?[e.k,e.v]:Qf(e.r)}function eh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function th(e){return Pa(nh(e))}function nh(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?Ct(t,{r:Ct(e,{l:t.r})}):e}function Pa(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?Ct(n,{l:Ct(e,{r:n.l}),lvl:t+1}):e}function BS(e){return Jf(e,({k:t,v:n})=>({index:t,value:n}))}function rh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ma=qe(()=>({recalcInProgress:ie(!1)}),[],{singleton:!0});function oh(e,t,n){return e[Ns(e,t,n)]}function Ns(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 zS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Wn(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!ot(e.groupOffsetTree)}function Ra({index:e},t){return t===e?0:t<e?-1:1}function HS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function US(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(XS(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=Aa(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function WS(e){return typeof e.groupIndex<"u"}function VS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=oh(t,e,Ra),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function sh(e,t){if(!As(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ih(e,t,n){if(WS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=sh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function KS(e,t,n,r=0){return r>0&&(t=Math.max(t,oh(e,r,Ra).offset)),Jf(zS(e,t,n,VS),YS)}function qS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,f),i)}else[i,a]=US(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Oa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,xo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function GS(e){return sr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ah(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 Oa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ns(o,t-1,Ra),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Es(n,t,1/0)){const h=c-s,m=h*i+a+h*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 YS(e){return{index:e.index,value:e}}function XS(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 JS={offsetHeight:"height",offsetWidth:"width"},In=qe(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Mt(r,0),s=We(),i=We(),a=ie(0),l=ie([]),c=ie(void 0),d=ie(void 0),h=ie((C,T)=>Wn(C,JS[T])),m=ie(void 0),f=ie(0),v=HS(),g=Mt(ee(n,Be(l,e,f),En(qS,v),at()),v),x=Mt(ee(l,at(),En((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);ve(ee(l,Ne(C=>C.length>0),Be(g,f),he(([C,T,E])=>{const j=C.reduce((M,L,H)=>tn(M,L,xo(L,T.offsetTree,E)||H),Mr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),ve(ee(r,Be(g),Ne(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ve(c,d);const y=Mt(ee(c,he(C=>C===void 0)),!0);ve(ee(d,Ne(C=>C!==void 0&&ot(wt(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=en(ee(n,Be(g),En(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),he(C=>C.changed)));Ze(ee(a,En((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=wt(g);if(C>0)De(t,!0),De(s,C+ah(C,T));else if(C<0){const E=wt(x);E.length>0&&(C-=ah(-C,E)),De(i,C)}}),Ze(ee(a,Be(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=en(s);ve(ee(s,Be(g),he(([C,T])=>{const E=T.groupIndices.length>0,j=[],M=T.lastSize;if(E){const L=mo(T.sizeTree,0);let H=0,B=0;for(;H<C;){const N=T.groupIndices[B],z=T.groupIndices.length===B+1?1/0:T.groupIndices[B+1]-N-1;j.push({endIndex:N,size:L,startIndex:N}),j.push({endIndex:N+1+z-1,size:M,startIndex:N+1}),B++,H+=z+1}const q=sr(T.sizeTree);return H!==C&&q.shift(),q.reduce((N,{k:z,v:$})=>{let R=N.ranges;return N.prevSize!==0&&(R=[...N.ranges,{endIndex:z+C-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:z+C,prevSize:$,ranges:R}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((L,{k:H,v:B})=>({prevIndex:H+C,prevSize:B,ranges:[...L.ranges,{endIndex:H+C-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:M,ranges:[]}).ranges})),n);const k=en(ee(i,Be(g,f),he(([C,{offsetTree:T},E])=>{const j=-C;return xo(j,T,E)})));return ve(ee(i,Be(g,f),he(([C,T,E])=>{if(T.groupIndices.length>0){if(ot(T.sizeTree))return T;let j=Mr();const M=wt(x);let L=0,H=0,B=0;for(;L<-C;){B=M[H];const q=M[H+1]-B-1;H++,L+=q+1}if(j=sr(T.sizeTree).reduce((q,{k:N,v:z})=>tn(q,Math.max(0,N+C),z),j),L!==-C){const q=mo(T.sizeTree,B);j=tn(j,0,q);const N=pn(T.sizeTree,-C+1)[1];j=tn(j,1,N)}return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((M,{k:L,v:H})=>tn(M,Math.max(0,L+C),H),Mr());return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(Un,Ma),{singleton:!0});function ZS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lh=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=en(ee(s,he(ZS)));return ve(ee(a,he(l=>l.totalCount)),n),ve(ee(a,he(l=>l.groupIndices)),e),ve(ee(yt(o,t,r),Ne(([l,c])=>As(c)),he(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(In,Ft)),Vn=qe(([{log:e}])=>{const t=ie(!1),n=en(ee(t,Ne(r=>r),at()));return Ze(t,r=>{r&&wt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},it(Un),{singleton:!0}),QS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ch(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!QS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:m}])=>{const f=We(),v=We(),g=ie(0);let x=null,y=null,b=null;function S(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),De(l,!1)}return ve(ee(f,Be(n,h,r,g,a,i,m),Be(e,s,o),he(([[k,C,T,E,j,M,L,H],B,q,N])=>{const z=ch(k),{align:$,behavior:R,offset:P}=z,I=E-1,V=ih(z,C,I);let J=xo(V,C.offsetTree,B)+M;$==="end"?(J+=q+pn(C.sizeTree,V)[1]-T+N,V===I&&(J+=L)):$==="center"?J+=(q+pn(C.sizeTree,V)[1]-T+N)/2:J-=j,P&&(J+=P);const _=O=>{S(),O?(H("retrying to scroll to",{location:k},Vt.DEBUG),De(f,k)):(De(v,!0),H("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),R==="smooth"){let O=!1;b=Ze(t,K=>{O=O||K}),x=hn(d,()=>{_(O)})}else x=hn(ee(t,eC(150)),_);return y=setTimeout(()=>{S()},1200),De(l,!0),H("scrolling from index to",{behavior:R,index:V,top:J},Vt.DEBUG),{behavior:R,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},it(In,Ft,Un),{singleton:!0});function eC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Da(e,t){e==0?t():requestAnimationFrame(()=>{Da(e-1,t)})}function La(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const wo=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=ie(!0),l=ie(0),c=ie(!0);return ve(ee(i,Be(l),Ne(([d,h])=>!!h),kn(!1)),a),ve(ee(i,Be(l),Ne(([d,h])=>!!h),kn(!1)),c),Ze(ee(yt(t,i),Be(a,n,e,c),Ne(([[,d],h,{sizeTree:m},f,v])=>d&&(!ot(m)||ka(f))&&!h&&!v),Be(l)),([,d])=>{hn(o,()=>{De(c,!0)}),Da(4,()=>{hn(r,()=>{De(a,!0)}),De(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(In,Ft,vo,Vn),{singleton:!0});function uh(e,t){return Math.abs(e-t)<1.01}const bo="up",yo="down",tC="none",nC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},rC=0,So=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=We(),c=We(),d=ie(4),h=ie(rC),m=Mt(ee(Ia(ee(Ee(o),rr(1),kn(!0)),ee(Ee(o),rr(1),kn(!1),qf(100))),at()),!1),f=Mt(ee(Ia(ee(n,kn(!0)),ee(n,kn(!1),qf(200))),at()),!1);ve(ee(yt(Ee(o),Ee(h)),he(([b,S])=>b<=S),at()),a),ve(ee(a,_n(50)),c);const v=en(ee(yt(r,Ee(s),Ee(t),Ee(e),Ee(d)),En((b,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const M=k+C-S>-j,L={scrollHeight:S,scrollTop:k,viewportHeight:C};if(M){let B,q;return k>b.state.scrollTop?(B="SCROLLED_DOWN",q=b.state.scrollTop-k):(B="SIZE_DECREASED",q=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:q,state:L}}let H;return L.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":C<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:L}},nC),at((b,S)=>b&&b.atBottom===S.atBottom))),g=Mt(ee(r,En((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(uh(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ne(b=>b.changed),he(b=>b.jump)),0);ve(ee(v,he(b=>b.atBottom)),i),ve(ee(i,_n(50)),l);const x=ie(yo);ve(ee(r,he(({scrollTop:b})=>b),at(),En((b,S)=>wt(f)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?bo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),he(b=>b.direction)),x),ve(ee(r,_n(50),kn(tC)),x);const y=ie(0);return ve(ee(m,Ne(b=>!b),kn(0)),y),ve(ee(o,_n(100),Be(m),Ne(([b,S])=>!!S),En(([b,S],[k])=>[S,k],[0,0]),he(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},it(Ft)),js="top",_s="bottom",dh="none";function fh(e,t,n){return typeof e=="number"?n===bo&&t===js||n===yo&&t===_s?e:0:n===bo?t===js?e.main:e.reverse:t===_s?e.main:e.reverse}function hh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const $a=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=ie(0),a=ie(0),l=ie(0),c=Mt(ee(yt(Ee(r),Ee(o),Ee(n),Ee(s,go),Ee(l),Ee(i),Ee(t),Ee(e),Ee(a)),he(([d,h,m,[f,v],g,x,y,b,S])=>{const k=d-b,C=x+y,T=Math.max(m-k,0);let E=dh;const j=hh(S,js),M=hh(S,_s);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+C-j&&(E=bo),v<d-T+h+M&&(E=yo),E!==dh?[Math.max(k-m-fh(g,js,E)-j,0),k-T-y+h+fh(g,_s,E)+M]:null}),Ne(d=>d!=null),at(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Ft),{singleton:!0});function oC(e,t,n){if(As(t)){const r=sh(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Fa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ps(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:mh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:mh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function ph(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=La(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ps(c,[],a,o,n,r)}function mh(e,t,n){if(e.length===0)return[];if(!As(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=Es(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ir=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},m,{didMount:f},{recalcInProgress:v}])=>{const g=ie([]),x=ie(0),y=We();ve(s.topItemsIndexes,g);const b=Mt(ee(yt(f,v,Ee(l,go),Ee(o),Ee(r),Ee(c),d,Ee(g),Ee(t),Ee(n),e),Ne(([T,E,,j,,,,,,,M])=>{const L=M&&M.length!==j;return T&&!E&&!L}),he(([,,[T,E],j,M,L,H,B,q,N,z])=>{const $=M,{offsetTree:R,sizeTree:P}=$,I=wt(x);if(j===0)return{...Fa,totalCount:j};if(T===0&&E===0)return I===0?{...Fa,totalCount:j}:ph(I,L,M,q,N,z||[]);if(ot(P))return I>0?null:Ps(oC(La(L,j),$,z),[],j,N,$,q);const V=[];if(B.length>0){const Y=B[0],ae=B[B.length-1];let W=0;for(const D of Es(P,Y,ae)){const X=D.value,oe=Math.max(D.start,Y),G=Math.min(D.end,ae);for(let Z=oe;Z<=G;Z++)V.push({data:z==null?void 0:z[Z],index:Z,offset:W,size:X}),W+=X}}if(!H)return Ps([],V,j,N,$,q);const J=B.length>0?B[B.length-1]+1:0,_=KS(R,T,E,J);if(_.length===0)return null;const O=j-1,K=ks([],Y=>{for(const ae of _){const W=ae.value;let D=W.offset,X=ae.start;const oe=W.size;if(W.offset<T){X+=Math.floor((T-W.offset+N)/(oe+N));const Z=X-ae.start;D+=Z*oe+Z*N}X<J&&(D+=(J-X)*oe,X=J);const G=Math.min(ae.end,O);for(let Z=X;Z<=G&&!(D>=E);Z++)Y.push({data:z==null?void 0:z[Z],index:Z,offset:D,size:oe}),D+=oe+N}});return Ps(K,V,j,N,$,q)}),Ne(T=>T!==null),at()),Fa);ve(ee(e,Ne(ka),he(T=>T==null?void 0:T.length)),o),ve(ee(b,he(T=>T.topListHeight)),h),ve(h,a),ve(ee(b,he(T=>[T.top,T.bottom])),i),ve(ee(b,he(T=>T.items)),y);const S=en(ee(b,Ne(({items:T})=>T.length>0),Be(o,e),Ne(([{items:T},E])=>T[T.length-1].originalIndex===E-1),he(([,T,E])=>[T-1,E]),at(go),he(([T])=>T))),k=en(ee(b,_n(200),Ne(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),he(({items:T})=>T[0].index),at())),C=en(ee(b,Ne(({items:T})=>T.length>0),he(({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}}),at(rh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},it(In,lh,$a,wo,vo,So,Vn,Ma),{singleton:!0}),gh=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Mt(ee(yt(n,e,r,t,o),he(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return ve(Ee(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Ft,ir),{singleton:!0}),sC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=Mt(ee(yt(n,e,t),Ne(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),_n(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Ft,gh),{singleton:!0}),xh=qe(()=>({context:ie(null)})),iC=({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,vh=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return ve(ee(d,Be(t,l,n,s,o,r,a),Be(e),he(([[h,m,f,v,g,x,y,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=iC,done:E,...j}=h,M=ih(h,m,v-1),L=xo(M,m.offsetTree,S)+g+x,H=L+pn(m.sizeTree,M)[1],B=b+x,q=b+f-y,N=T({itemBottom:H,itemTop:L,locationParams:{align:k,behavior:C,...j},viewportBottom:q,viewportTop:B});return N?E&&hn(ee(i,Ne(z=>!z),rr(wt(i)?1:2)),E):E&&E(),N}),Ne(h=>h!==null)),c),{scrollIntoView:d}},it(In,Ft,vo,ir,Un),{singleton:!0});function wh(e){return e?e==="smooth"?"smooth":"auto":!1}const aC=(e,t)=>typeof e=="function"?wh(e(t)):t&&wh(e),lC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:h},{context:m},{scrollIntoView:f}])=>{const v=ie(!1),g=We();let x=null;function y(C){De(i,{align:"end",behavior:C,index:"LAST"})}Ze(ee(yt(ee(Ee(t),rr(1)),l),Be(Ee(v),s,a,h),he(([[C,T],E,j,M,L])=>{let H=T&&M,B="auto";return H&&(B=aC(E,j||L),H=H&&!!B),{followOutputBehavior:B,shouldFollow:H,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=hn(e,()=>{wt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function b(C){const T=hn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(wt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(ee(yt(Ee(v),t,c),Ne(([C,,T])=>C&&T),En(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),Be(v,t)),([,C])=>{wt(a)&&b(C!==!1)}),Ze(g,()=>{b(wt(v)!==!1)}),Ze(yt(Ee(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=ie(null),k=We();return ve(Ia(ee(Ee(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(Ee(t))),k),Ze(ee(yt(ee(k,rr(1)),l),Be(Ee(S),a,h,m),he(([[C,T],E,j,M,L])=>T&&j&&(E==null?void 0:E({context:L,totalCount:C,scrollingInProgress:M}))),Ne(C=>!!C),_n(0)),C=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("scrolling into view",{}),De(f,C)}):x=hn(e,()=>{wt(d)("scrolling into view",{}),De(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},it(In,So,vo,wo,Vn,Un,Ft,xh,vh)),cC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(ee(a,Be(s),Ne(([,l])=>l!==0),Be(o,r,t,n,e),he(([[,l],c,d,h,m,f=[]])=>ph(l,c,d,h,m,f))),i),{}),it(In,wo,ir,Vn),{singleton:!0}),uC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return Ze(ee(e,Be(r),Ne(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{hn(ee(n,rr(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{De(t,o)})})}),{initialScrollTop:r}},it(Vn,Ft,ir),{singleton:!0}),bh=qe(([{scrollVelocity:e}])=>{const t=ie(!1),n=We(),r=ie(!1);return ve(ee(e,Be(r,t,n),Ne(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Ze(ee(yt(t,e,n),Be(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(So),{singleton:!0}),Ba=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=ie(!1),i=ie(void 0);return ve(ee(yt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ve(ee(t,Be(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Ft)),dC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=ie(void 0),h=ie(null),m=ie(null);return ve(a,h),ve(l,m),Ze(ee(c,Be(t,r,i,h,m,n)),([f,v,g,x,y,b,S])=>{const k=GS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),ve(ee(d,Ne(ka),he(fC)),o),ve(ee(s,Be(d),Ne(([,f])=>f!==void 0),at(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(In,Ft,wo,Vn,Ba));function fC(e){return{align:"start",index:0,offset:e.scrollTop}}const hC=qe(([{topItemsIndexes:e}])=>{const t=ie(0);return ve(ee(t,Ne(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ir));function yh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const pC=yh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),mC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=en(ee(l,Be(i),En(([,y,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const M=k+T;let L=0;return b===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(L=M-S,L!==0&&(L+=j))),[L,C,E,M]},[0,[],0,0]),Ne(([y])=>y!==0),Be(r,a,n,o,f,v),Ne(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===bo),he(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(De(t,{behavior:"auto",top:-y}),De(e,0)):(De(e,0),De(t,{behavior:"auto",top:-y}))}return Ze(ee(g,Be(e,s)),([y,b,S])=>{S&&pC()?De(e,b-y):x(-y)}),Ze(ee(yt(Mt(s,!1),e,v),Ne(([y,b,S])=>!y&&!S&&b!==0),he(([y,b])=>b),_n(1)),x),ve(ee(h,he(y=>({top:-y}))),t),Ze(ee(c,Be(m,d),he(([y,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(b.length===0)return T(y);{let E=0;const j=mo(k,0);let M=0,L=0;for(;M<y;){M++,E+=j;let H=b.length===L+1?1/0:b[L+1]-b[L]-1;M+H>y&&(E-=j,H=y-M+1),M+=H,E+=T(H),L++}return E}})),y=>{De(e,y),requestAnimationFrame(()=>{De(t,{top:y}),requestAnimationFrame(()=>{De(e,0),De(v,!1)})})}),{deviation:e}},it(Ft,So,ir,In,Un,Ma)),gC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it($a,cC,Vn,bh,gh,uC,sC,Ba,vh,Un,xh)),Sh=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},M])=>(ve(k.rangeChanged,M.scrollSeekRangeChanged),ve(ee(M.windowViewportRect,he(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...M,...g,sizes:l,...x}),it(In,wo,Ft,dC,lC,ir,vo,mC,hC,lh,gC));function xC(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 Ms=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ch(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&&De(x.propsReady,!1);for(const b of r){const S=x[t.required[b]];De(S,y[b])}for(const b of o)if(b in y){const S=x[t.optional[b]];De(S,y[b])}x.propsReady&&De(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=S=>{const k=x[t.methods[b]];De(k,S)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=MS(x[t.events[b]]),y),{})}const h=w.forwardRef((x,y)=>{const{children:b,...S}=x,[k]=w.useState(()=>ks(OS(e),E=>{l(E,S)})),[C]=w.useState(Kf(d,k));Ms(()=>{for(const E of i)E in S&&Ze(C[E],S[E]);return()=>{Object.values(C).map(Ea)}},[S,C,k]),Ms(()=>{l(k,S)}),w.useImperativeHandle(y,Wf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...xC([...r,...o,...i],S),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{De(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(S=>Ze(y,S),[y]);return w.useSyncExternalStore(b,()=>wt(y),()=>wt(y))},v=x=>{const y=w.useContext(a)[x],[b,S]=w.useState(Kf(wt,y));return Ms(()=>Ze(y,k=>{k!==b&&S(Wf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ms(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Th=w.createContext(void 0),kh=w.createContext(void 0),Eh=typeof document<"u"?w.useLayoutEffect:w.useEffect;function za(e){return"self"in e}function vC(e){return"body"in e}function Ih(e,t,n,r=Pr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(vC(x)||za(x)){const b=za(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Po.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);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 f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;za(f)?(x=Math.max(Wn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Wn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),uh(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}),f.scrollTo(m)}function h(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Ha="-webkit-sticky",Nh="sticky",Ua=yh(()=>{if(typeof document>"u")return Nh;const e=document.createElement("div");return e.style.position=Ha,e.style.position===Ha?Ha:Nh});function Wa(e){return e}const wC=qe(()=>{const e=ie(a=>`Item ${a}`),t=ie(a=>`Group ${a}`),n=ie({}),r=ie(Wa),o=ie("div"),s=ie(Pr),i=(a,l=null)=>Mt(ee(n,he(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),bC=qe(([e,t])=>({...e,...t}),it(Sh,wC)),yC=({height:e})=>u.jsx("div",{style:{height:e}}),SC={overflowAnchor:"none",position:Ua(),zIndex:1},Ah={overflowAnchor:"none"},CC={...Ah,display:"inline-block",height:"100%"},jh=w.memo(function({showTopList:e=!1}){const t=je("listState"),n=rn("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),c=je("context"),d=je("groupContent"),h=je("trackItemSizes"),m=je("itemSize"),f=je("log"),v=rn("gap"),g=je("horizontalDirection"),{callbackRef:x}=$S(n,m,h,e?Pr:a,f,v,o,g,je("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Va("deviation",N=>{y!==N&&b(N)});const S=je("EmptyPlaceholder"),k=je("ScrollSeekPlaceholder")||yC,C=je("ListComponent"),T=je("ItemComponent"),E=je("GroupComponent"),j=je("computeItemKey"),M=je("isSeeking"),L=je("groupIndices").length>0,H=je("alignToBottom"),B=je("initialItemFinalLocationReached"),q=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Rt(S,c)}):u.jsx(C,{...Rt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:q,children:(e?t.topItems:t.items).map(N=>{const z=N.originalIndex,$=j(z+t.firstItemIndex,N.data,c);return M?w.createElement(k,{...Rt(k,c),height:N.size,index:N.index,key:$,type:N.type||"item",...N.type==="group"?{}:{groupIndex:N.groupIndex}}):N.type==="group"?w.createElement(E,{...Rt(E,c),"data-index":z,"data-item-index":N.index,"data-known-size":N.size,key:$,style:SC},d(N.index,c)):w.createElement(T,{...Rt(T,c),...IC(T,N.data),"data-index":z,"data-item-group-index":N.groupIndex,"data-item-index":N.index,"data-known-size":N.size,key:$,style:g?CC:Ah},L?l(N.index,N.groupIndex,N.data,c):l(N.index,N.data,c))})})}),TC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},kC={outline:"none",overflowX:"auto",position:"relative"},Rs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),EC={position:Ua(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function IC(e,t){return{item:typeof e=="string"?void 0:t}}const NC=w.memo(function(){const e=je("HeaderComponent"),t=rn("headerHeight"),n=je("HeaderFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),AC=w.memo(function(){const e=je("FooterComponent"),t=rn("footerHeight"),n=je("HeaderFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null});function _h({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"),h=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Ih(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?kC:TC,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Ph({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"),h=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ih(a,c,l,v,m);return Eh(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+h}:{}},...i,...Rt(l,s),children:r})})}const jC=({children:e})=>{const t=w.useContext(Th),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=w.useMemo(()=>Vf(n,l=>Wn(l,s?"width":"height")),[n,s]),a=or(i,!0,je("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Rs(o),children:e})},_C=({children:e})=>{const t=w.useContext(Th),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=je("customScrollParent"),s=Xf(n,o,je("skipAnimationFrameInResizeObserver")),i=je("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:Rs(i),children:e})},PC=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...EC,marginTop:`${n}px`},o=je("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},MC=w.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return u.jsxs(r||t?DC:OC,{...e,context:o,children:[n&&u.jsx(PC,{children:u.jsx(jh,{showTopList:!0})}),u.jsxs(r||t?_C:jC,{children:[u.jsx(NC,{}),u.jsx(jh,{}),u.jsx(AC,{})]})]})}),{Component:RC,useEmitter:Va,useEmitterValue:je,usePublisher:rn}=Ch(bC,{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"}},MC),OC=_h({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),DC=Ph({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),LC=RC;it(Sh,qe(()=>{const e=ie(c=>u.jsxs("td",{children:["Item $",c]})),t=ie(null),n=ie(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ie(null),o=ie(null),s=ie({}),i=ie(Wa),a=ie(Pr),l=(c,d=null)=>Mt(ee(s,he(h=>h[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Ua();const Mh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},$C={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Rh,floor:Os,max:Co,min:Ka,round:Oh}=Math;function Dh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function FC(e){return{...$C,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function BC(e,t){return e&&e.column===t.column&&e.row===t.row}const zC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=ie(0),E=ie(0),j=ie(Mh),M=ie({height:0,width:0}),L=ie({height:0,width:0}),H=We(),B=We(),q=ie(0),N=ie(null),z=ie({column:0,row:0}),$=We(),R=We(),P=ie(!1),I=ie(0),V=ie(!0),J=ie(!1),_=ie(!1);Ze(ee(v,Be(I),Ne(([D,X])=>!!X)),()=>{De(V,!1)}),Ze(ee(yt(v,V,L,M,I,J),Ne(([D,X,oe,G,,Z])=>D&&!X&&oe.height!==0&&G.height!==0&&!Z)),([,,,,D])=>{De(J,!0),Da(1,()=>{De(H,D)}),hn(ee(c),()=>{De(t,[0,0]),De(V,!0)})}),ve(ee(R,Ne(D=>D!=null&&D.scrollTop>0),kn(0)),E),Ze(ee(v,Be(R),Ne(([,D])=>D!=null)),([,D])=>{D&&(De(M,D.viewport),De(L,D.item),De(z,D.gap),D.scrollTop>0&&(De(P,!0),hn(ee(c,rr(1)),X=>{De(P,!1)}),De(l,{top:D.scrollTop})))}),ve(ee(M,he(({height:D})=>D)),h),ve(ee(yt(Ee(M,Ds),Ee(L,Ds),Ee(z,(D,X)=>D&&D.column===X.column&&D.row===X.row),Ee(c)),he(([D,X,oe,G])=>({gap:oe,item:X,scrollTop:G,viewport:D}))),$),ve(ee(yt(Ee(T),r,Ee(z,BC),Ee(L,Ds),Ee(M,Ds),Ee(N),Ee(E),Ee(P),Ee(V),Ee(I)),Ne(([,,,,,,,D])=>!D),he(([D,[X,oe],G,Z,te,se,ue,,ge,Re])=>{const{column:Oe,row:Te}=G,{height:nt,width:ht}=Z,{width:Tt}=te;if(ue===0&&(D===0||Tt===0))return Mh;if(ht===0){const kt=La(Re,D),bt=kt+Math.max(ue-1,0);return FC(Dh(kt,bt,se))}const Ke=Lh(Tt,ht,Oe);let Ge,Ve;ge?X===0&&oe===0&&ue>0?(Ge=0,Ve=ue-1):(Ge=Ke*Os((X+Te)/(nt+Te)),Ve=Ke*Rh((oe+Te)/(nt+Te))-1,Ve=Ka(D-1,Co(Ve,Ke-1)),Ge=Ka(Ve,Co(0,Ge))):(Ge=0,Ve=-1);const $e=Dh(Ge,Ve,se),{bottom:He,top:mt}=$h(te,G,Z,$e),Dt=Rh(D/Ke),lt=Dt*nt+(Dt-1)*Te-He;return{bottom:He,itemHeight:nt,items:$e,itemWidth:ht,offsetBottom:lt,offsetTop:mt,top:mt}})),j),ve(ee(N,Ne(D=>D!==null),he(D=>D.length)),T),ve(ee(yt(M,L,j,z),Ne(([D,X,{items:oe}])=>oe.length>0&&X.height!==0&&D.height!==0),he(([D,X,{items:oe},G])=>{const{bottom:Z,top:te}=$h(D,G,X,oe);return[te,Z]}),at(go)),t);const O=ie(!1);ve(ee(c,Be(O),he(([D,X])=>X||D!==0)),O);const K=en(ee(yt(j,T),Ne(([{items:D}])=>D.length>0),Be(O),Ne(([[D,X],oe])=>{const G=D.items[D.items.length-1].index===X-1;return(oe||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&G}),he(([[,D]])=>D-1),at())),Y=en(ee(Ee(j),Ne(({items:D})=>D.length>0&&D[0].index===0),kn(0),at())),ae=en(ee(Ee(j),Be(P),Ne(([{items:D},X])=>D.length>0&&!X),he(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),at(rh),_n(0)));ve(ae,f.scrollSeekRangeChanged),ve(ee(H,Be(M,L,T,z),he(([D,X,oe,G,Z])=>{const te=ch(D),{align:se,behavior:ue,offset:ge}=te;let Re=te.index;Re==="LAST"&&(Re=G-1),Re=Co(0,Re,Ka(G-1,Re));let Oe=qa(X,Z,oe,Re);return se==="end"?Oe=Oh(Oe-X.height+oe.height):se==="center"&&(Oe=Oh(Oe-X.height/2+oe.height/2)),ge&&(Oe+=ge),{behavior:ue,top:Oe}})),l);const W=Mt(ee(j,he(D=>D.offsetBottom+D.bottom)),0);return ve(ee(k,he(D=>({height:D.visibleHeight,width:D.visibleWidth}))),M),{customScrollParent:x,data:N,deviation:q,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:R,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:M,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:W,...m,endReached:K,propsReady:g,rangeChanged:ae,startReached:Y,stateChanged:$,stateRestoreInProgress:P,...C}},it($a,Ft,So,bh,Vn,Ba,Un));function Lh(e,t,n){return Co(1,Os((e+n)/(Os(t)+n)))}function $h(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=Lh(e.width,n.width,t.column),s=Os(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const HC=qe(()=>{const e=ie(h=>`Item ${h}`),t=ie({}),n=ie(null),r=ie("virtuoso-grid-item"),o=ie("virtuoso-grid-list"),s=ie(Wa),i=ie("div"),a=ie(Pr),l=(h,m=null)=>Mt(ee(t,he(f=>f[h]),at()),m),c=ie(!1),d=ie(!1);return ve(Ee(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")}}),UC=qe(([e,t])=>({...e,...t}),it(zC,HC)),WC=w.memo(function(){const e=ut("gridState"),t=ut("listClassName"),n=ut("itemClassName"),r=ut("itemContent"),o=ut("computeItemKey"),s=ut("isSeeking"),i=on("scrollHeight"),a=ut("ItemComponent"),l=ut("ListComponent"),c=ut("ScrollSeekPlaceholder"),d=ut("context"),h=on("itemDimensions"),m=on("gap"),f=ut("log"),v=ut("stateRestoreInProgress"),g=on("reportReadyState"),x=or(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Bh("column-gap",getComputedStyle(y).columnGap,f),row:Bh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Eh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Rt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{...Rt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),VC=w.memo(function(){const e=ut("HeaderComponent"),t=on("headerHeight"),n=ut("headerFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),KC=w.memo(function(){const e=ut("FooterComponent"),t=on("footerHeight"),n=ut("headerFooterTag"),r=or(w.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),qC=({children:e})=>{const t=w.useContext(kh),n=on("itemDimensions"),r=on("viewportDimensions"),o=or(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:Rs(!1),children:e})},GC=({children:e})=>{const t=w.useContext(kh),n=on("windowViewportRect"),r=on("itemDimensions"),o=ut("customScrollParent"),s=Xf(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:Rs(!1),children:e})},YC=w.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?JC:XC,o=n||t?GC:qC,s=ut("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(VC,{}),u.jsx(WC,{}),u.jsx(KC,{})]})})}),{useEmitter:Fh,useEmitterValue:ut,usePublisher:on}=Ch(UC,{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"}},YC),XC=_h({useEmitter:Fh,useEmitterValue:ut,usePublisher:on}),JC=Ph({useEmitter:Fh,useEmitterValue:ut,usePublisher:on});function Bh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const ZC=zr.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 zh({className:e,variant:t,...n}){return u.jsx("div",{className:ne(ZC({variant:t}),e),...n})}var Ls="Dialog",[Hh,yN]=un(Ls),[QC,mn]=Hh(Ls),Uh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(QC,{scope:t,triggerRef:a,contentRef:l,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Uh.displayName=Ls;var Wh="DialogTrigger",Vh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Wh,n),s=Fe(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xa(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Vh.displayName=Wh;var Ga="DialogPortal",[eT,Kh]=Hh(Ga,{forceMount:void 0}),qh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=mn(Ga,t);return u.jsx(eT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};qh.displayName=Ga;var $s="DialogOverlay",Gh=p.forwardRef((e,t)=>{const n=Kh($s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(nT,{...o,ref:t})}):null});Gh.displayName=$s;var tT=Yt.createSlot("DialogOverlay.RemoveScroll"),nT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn($s,n);return u.jsx(gs,{as:tT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":Xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Yh=p.forwardRef((e,t)=>{const n=Kh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn(ar,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(rT,{...o,ref:t}):u.jsx(oT,{...o,ref:t})})});Yh.displayName=ar;var rT=p.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=p.useRef(null),o=Fe(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(Xh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),oT=p.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Xh,{...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()}})}),Xh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=mn(ar,n),l=p.useRef(null),c=Fe(t,l);return Hi(),u.jsxs(u.Fragment,{children:[u.jsx(Jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(yr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(sT,{titleId:a.titleId}),u.jsx(aT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ya="DialogTitle",Jh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Ya,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Jh.displayName=Ya;var Zh="DialogDescription",Qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Zh,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});Qh.displayName=Zh;var ep="DialogClose",tp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(ep,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});tp.displayName=ep;function Xa(e){return e?"open":"closed"}var np="DialogTitleWarning",[SN,rp]=yw(np,{contentName:ar,titleName:Ya,docsSlug:"dialog"}),sT=({titleId:e})=>{const t=rp(np),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 p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iT="DialogDescriptionWarning",aT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${rp(iT).contentName}}.`;return p.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ja=Uh,lT=Vh,Za=qh,To=Gh,ko=Yh,lr=Jh,Fs=Qh,op=tp;const Qa=Ja,cT=Za,sp=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{ref:n,className:te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));sp.displayName=To.displayName;const Bs=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(cT,{children:[u.jsx(sp,{}),u.jsxs(ko,{ref:r,className:te("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(op,{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"})]})]})]})});Bs.displayName=ko.displayName;const zs=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zs.displayName="DialogHeader";const Hs=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=lr.displayName;const uT=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));uT.displayName=Fs.displayName;const dT=1,fT=1e6;let el=0;function hT(){return el=(el+1)%Number.MAX_SAFE_INTEGER,el.toString()}const tl=new Map,ip=e=>{if(tl.has(e))return;const t=setTimeout(()=>{tl.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},fT);tl.set(e,t)},pT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,dT)};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?ip(n):e.toasts.forEach(r=>{ip(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)}}},Us=[];let Ws={toasts:[]};function Eo(e){Ws=pT(Ws,e),Us.forEach(t=>{t(Ws)})}function mT({...e}){const t=hT(),n=o=>Eo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Eo({type:"DISMISS_TOAST",toastId:t});return Eo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function nl(){const[e,t]=p.useState(Ws);return p.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:mT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function ap({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:h}=nl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await _i(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 f=async()=>{if(n)try{await Zc(n),h({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),h({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await _i(n),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),h({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(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(Qe,{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(Qa,{open:e,onOpenChange:t,children:u.jsxs(Bs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(zs,{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(Hs,{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(Qe,{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(Qe,{variant:"outline",size:"sm",onClick:f,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 lp(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let cr=lp();function gT(e){cr=e}const cp=/[&<>"']/,xT=new RegExp(cp.source,"g"),up=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vT=new RegExp(up.source,"g"),wT={"&":"&","<":"<",">":">",'"':""","'":"'"},dp=e=>wT[e];function Ot(e,t){if(t){if(cp.test(e))return e.replace(xT,dp)}else if(up.test(e))return e.replace(vT,dp);return e}const bT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function fp(e){return e.replace(bT,(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 yT=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(yT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const ST=/[^\w:]/g,CT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function hp(e,t,n){if(e){let r;try{r=decodeURIComponent(fp(n)).replace(ST,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!CT.test(n)&&(n=IT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},TT=/^[^:]+:\/*[^/]*$/,kT=/^([^:]+:)[\s\S]*$/,ET=/^([^:]+:\/*[^/]*)[\s\S]*$/;function IT(e,t){Vs[" "+e]||(TT.test(e)?Vs[" "+e]=e+"/":Vs[" "+e]=qs(e,"/",!0)),e=Vs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(kT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(ET,"$1")+t:e+t}const Ks={exec:function(){}};function pp(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 qs(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 NT(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 AT(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 mp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function gp(e,t,n,r){const o=t.href,s=t.title?Ot(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Ot(i)}}function jT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iT="DialogDescriptionWarning",aT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${rp(iT).contentName}}.`;return p.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ja=Uh,lT=Vh,Za=qh,To=Gh,ko=Yh,lr=Jh,Fs=Qh,op=tp;const Qa=Ja,cT=Za,sp=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));sp.displayName=To.displayName;const Bs=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(cT,{children:[u.jsx(sp,{}),u.jsxs(ko,{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(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(op,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Bs.displayName=ko.displayName;const zs=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zs.displayName="DialogHeader";const Hs=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=lr.displayName;const uT=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));uT.displayName=Fs.displayName;const dT=1,fT=1e6;let el=0;function hT(){return el=(el+1)%Number.MAX_SAFE_INTEGER,el.toString()}const tl=new Map,ip=e=>{if(tl.has(e))return;const t=setTimeout(()=>{tl.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},fT);tl.set(e,t)},pT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,dT)};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?ip(n):e.toasts.forEach(r=>{ip(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)}}},Us=[];let Ws={toasts:[]};function Eo(e){Ws=pT(Ws,e),Us.forEach(t=>{t(Ws)})}function mT({...e}){const t=hT(),n=o=>Eo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Eo({type:"DISMISS_TOAST",toastId:t});return Eo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function nl(){const[e,t]=p.useState(Ws);return p.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:mT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function ap({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:h}=nl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await _i(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 f=async()=>{if(n)try{await Zc(n),h({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),h({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await _i(n),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),h({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(de.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(Qe,{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(de.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):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(de.Image,{className:"h-5 w-5"}):u.jsx(de.FileText,{className:"h-5 w-5"});return u.jsx(Qa,{open:e,onOpenChange:t,children:u.jsxs(Bs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(zs,{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(Hs,{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(Qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(de.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Qe,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(de.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function lp(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let cr=lp();function gT(e){cr=e}const cp=/[&<>"']/,xT=new RegExp(cp.source,"g"),up=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vT=new RegExp(up.source,"g"),wT={"&":"&","<":"<",">":">",'"':""","'":"'"},dp=e=>wT[e];function Ot(e,t){if(t){if(cp.test(e))return e.replace(xT,dp)}else if(up.test(e))return e.replace(vT,dp);return e}const bT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function fp(e){return e.replace(bT,(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 yT=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(yT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const ST=/[^\w:]/g,CT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function hp(e,t,n){if(e){let r;try{r=decodeURIComponent(fp(n)).replace(ST,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!CT.test(n)&&(n=IT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},TT=/^[^:]+:\/*[^/]*$/,kT=/^([^:]+:)[\s\S]*$/,ET=/^([^:]+:\/*[^/]*)[\s\S]*$/;function IT(e,t){Vs[" "+e]||(TT.test(e)?Vs[" "+e]=e+"/":Vs[" "+e]=qs(e,"/",!0)),e=Vs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(kT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(ET,"$1")+t:e+t}const Ks={exec:function(){}};function pp(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 qs(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 NT(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 AT(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 mp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function gp(e,t,n,r){const o=t.href,s=t.title?Ot(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Ot(i)}}function jT(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 rl{constructor(t){this.options=t||cr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:qs(r,`
|
|
86
86
|
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=jT(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=qs(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,h,m,f,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(`
|
|
@@ -125,6 +125,6 @@ ${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=hp(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=hp(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 vp{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 wp{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 qn{constructor(t){this.options=t||cr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new vp,this.slugger=new wp}static parse(t,n){return new qn(n).parse(t)}static parseInline(t,n){return new qn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,h,m,f,v,g,x,y,b,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,fp(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(h="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(h+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(h,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)b=f.items[s],S=b.checked,k=b.task,y="",b.task&&(C=this.renderer.checkbox(S),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+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=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(b.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
127
|
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Gs{constructor(t){this.options=t||cr}preprocess(t){return t}postprocess(t){return t}}Qg(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function PT(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>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=PT(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(AT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&ve.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ve.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ve.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return bp(Kn.lex,qn.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},gT(ve.defaults),ve},ve.getDefaults=lp,ve.defaults=cr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ve.defaults.renderer||new ol;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ve.defaults.tokenizer||new rl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ve.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ve.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ve.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=bp(Kn.lexInline,qn.parseInline),ve.Parser=qn,ve.parser=qn.parse,ve.Renderer=ol,ve.TextRenderer=vp,ve.Lexer=Kn,ve.lexer=Kn.lex,ve.Tokenizer=rl,ve.Slugger=wp,ve.Hooks=Gs,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,qn.parse,Kn.lex;function Rr({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 ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:te("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function yp({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 Sp({artifact:e}){const[t,n]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(ue.Clock,{className:"w-4 h-4"})),[s,i]=w.useState("Processing");return w.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(ue.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(ue.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(ue.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(Rr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(ue.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function Cp({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nw(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(yp,{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 sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(sl,{className:te("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="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 ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:MT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Ep({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}function Ip({message:e,viewMode:t,isStreaming:n=!1}){const o=Ri(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Mi(l)??l:l;if(c&&typeof c=="object")return u.jsx(ul,{data:c});const d=typeof c=="string"?c:(()=>{try{return vr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Yv(l);return d?u.jsx(Rr,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(h=>h.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=Qr(m);return i(f)}const c=Zr(l),d=Qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Np({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Ap({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Rr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Qe,{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 jp({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:h,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:b,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:j,activeInterruptValue:M,iconForeground:L}){const B=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),W=w.useCallback(({part:N,i:U})=>{if(N.type==="text"){const $=N.text??"",O=$.trim(),P=Mi(O);return P&&b!=="tool"?u.jsx(ul,{data:P},U):b==="user"&&S&&O.length>k?u.jsx(Ap,{text:O,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},U):u.jsx(Rr,{content:$,allowHtml:!1},U)}if(N.type==="image_url"){const $=N;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"})},U)}if(N.type==="file"){const $=N,O=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,U),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[U]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[O,v[U]?" (processing)":""]})]},U)}if(N.type==="interrupt"){const $=N,O=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(j&&O&&O===j),I=P?M??($==null?void 0:$.value):$==null?void 0:$.value,q=O?{...$,id:O,interrupt_id:O}:$;return u.jsx(kp,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},U)}return null},[f,v,g,x,b,S,k,C,E,j,M,y]),K=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!h)return B();if(!t&&!K&&!h)return null;if(t)return!n&&r?null:n?u.jsx(Ip,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const N=u.jsx("div",{className:"space-y-2",children:i.map((U,$)=>u.jsx(W,{part:U,i:$},$))});return h?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx(Np,{className:L})]}):N}return null}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(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:Xv(r),toolMeta:Ri(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=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:h=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:j=[]}){const[M,L]=w.useState(!1),[B,W]=w.useState("preview"),[K,N]=w.useState(!1),{currentThreadId:U}=xr(),{respondToInterrupt:$}=eo(),O=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",q=w.useMemo(()=>t.role==="default_message"?t:null,[t]),J=!!q,_=!(r&&P!=="user"),{uploadingFiles:R,handleFileClick:G,fileViewerOpen:X,currentFileInfo:se,closeFileViewer:V}=_p({allowFileOpen:_,currentThreadId:U}),D=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]),Z=Pp(t,q),{contentParts:ne,imageParts:Y,fileParts:H,interruptParts:ae,textContent:le,toolMeta:fe,toolRaw:be,isToolStreaming:Re}=Z,Oe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),Te=Go(Oe),nt=y==null?void 0:y.value,ht=w.useMemo(()=>q||!m?null:t.artifact||null,[q,t,m]),kt=w.useCallback(async()=>{const ke=I?be:le;async function et(Ae){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ae);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Le=new Blob([Ae],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Le})]);return}throw new Error("Clipboard API not supported in this context.")}try{await et(ke),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(ke)}catch(Ae){console.error("Failed to copy:",Ae)}},[I,be,le,x]),Ke=w.useCallback(()=>{if(!v||!t.id)return;const ke=(I?be:le)??"",et="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,ke,et)},[v,t.id,I,be,le,t]),Ge=w.useCallback(()=>{g==null||g(n)},[g,n]),Ve=w.useCallback(()=>{const et=te(O?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(ue.User,{className:et});case"assistant":return u.jsx(ue.Bot,{className:et});case"tool":return u.jsx(ue.Wrench,{className:et});default:return u.jsx(ue.Bot,{className:et})}},[O,D,P]),$e=w.useCallback(()=>{const ke="group relative mb-4 flex w-full";switch(P){case"user":return te(ke,"justify-end");case"assistant":case"tool":case"system":return te(ke,"justify-start");default:return ke}},[P]),He=w.useCallback(()=>{const ke=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",O&&"px-3 py-2 text-sm");if(J)return te(ke,"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 te(ke,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return te(ke,"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 te(ke,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(ke,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(ke,"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")}},[O,J,P]),mt=w.useCallback(async ke=>{if(b)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!0)}catch(Ae){console.error("Failed to approve interrupt:",Ae)}finally{k==null||k()}},[b,k,S,$]),Dt=w.useCallback(async ke=>{if(b)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!1)}catch(Ae){console.error("Failed to reject interrupt:",Ae)}finally{k==null||k()}},[b,k,S,$]),lt=w.useMemo(()=>q?"Assistant":Zv(t),[q,t]),Et=P==="user"&&(C??1)>1&&typeof E=="function",yt=(j==null?void 0:j.length)??0,gt=yt>0&&T<yt-1?j[T+1]:void 0,pt=yt>0&&T>0?j[T-1]:void 0,an=w.useCallback(()=>{!gt||!E||E(gt.id,void 0,!!gt.isLatestAttempt)},[gt,E]),dt=w.useCallback(()=>{!pt||!E||E(pt.id,void 0,!!pt.isLatestAttempt)},[pt,E]);return I&&!h&&!ht?null:J&&q?u.jsx("div",{className:te($e(),f.container),children:u.jsxs("div",{className:te(He(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:te("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Rr,{content:q.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te($e(),f.container),children:u.jsxs("div",{className:te(He(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",O&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ve(),a&<&&u.jsx("span",{className:te("font-medium",O?"text-xs":"text-sm"),children:lt}),I&&u.jsxs(zh,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",O&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":B==="expanded",onClick:()=>W(ke=>ke==="expanded"?"preview":"expanded"),onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),W(et=>et==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:fe.name??"Tool Output"}),fe.toolCallId&&u.jsx("span",{className:"opacity-70",children:fe.toolCallId.slice(0,8)}),B==="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:[Et&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=C-1||an()},"aria-label":"Older attempt (back in time)",disabled:T>=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-T," / ",C]})}),u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||dt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",D,O&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>kt(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:te(M?"text-success":D,O?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:te(D,O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:te(D,O?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(jp,{message:t,isToolMessage:I,showToolMessages:h,artifactToRender:ht,toolViewMode:B,isToolStreaming:Re,contentParts:ne,textContent:le,imageParts:Y,fileParts:H,interruptParts:ae,isStreamingMessage:r,defaultMessage:q,handleFileClick:G,uploadingFiles:R,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:b,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:K,setIsUserExpanded:N,isCompactLayout:O,activeInterruptId:Te,activeInterruptValue:nt,iconForeground:D}),m&&ht&&u.jsx("div",{className:"mt-3",children:u.jsx(Cp,{artifact:ht,idx:0})})]}),I&&B==="expanded"&&(fe.toolCallId||fe.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",O&&"text-xs"),children:[fe.name&&u.jsxs("div",{children:["Function: ",fe.name]}),fe.toolCallId&&u.jsxs("div",{children:["Call ID: ",fe.toolCallId]})]}),!(i||a||I)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>kt(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:te(M?"text-success":"text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})})]})]})}),se&&u.jsx(ap,{isOpen:X,onClose:V,fileId:se.id,fileName:se.name,mimeType:se.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const RT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:b,onSelectCheckpoint:S}){const k=dl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,j=b??RT,M=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:B,attempts:W}=w.useMemo(()=>ec(t.id,M,j),[t.id,M,j]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:E||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:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:L,attemptIndex:B,attemptMetas:W,onSelectCheckpoint:S})})});fl.displayName="MessageRow";const hl=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:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:j,activeCheckpointId:M,onSelectCheckpoint:L,createSyntheticThinkingMessage:B=!0},W)=>{const K=w.useRef(null),N=w.useRef(null),U=w.useRef(!1),$=w.useRef(!1),[O,P]=w.useState(!0),I=w.useMemo(()=>b?e.some(H=>H.role==="default_message"?!1:Array.isArray(H==null?void 0:H.content)&&H.content.some(ae=>ae&&ae.type==="interrupt"&&(ae.id??ae.interrupt_id)===b.id)):!1,[b,e]),q=w.useMemo(()=>{if(!b||I)return null;const H=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let ae;const le=b.value;if(le&&typeof le=="object"&&!Array.isArray(le)){const fe=le.title;typeof fe=="string"&&fe.trim()&&(ae=fe.trim())}return{id:`interrupt-${H}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:H,value:le,title:ae}]}},[b,I]),J=w.useMemo(()=>q?[...e,q]:e,[e,q]),_=w.useMemo(()=>!B||!t?J:!(n&&J.some(ae=>ae.id===n))&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,n,B]),R=w.useMemo(()=>T?_:_.filter(H=>(H==null?void 0:H.role)!=="tool"),[_,T]),G=w.useCallback(H=>{P(H),x&&x(!H),y&&y(H)},[x,y]),X=w.useMemo(()=>{if(a)return async()=>{if(!U.current){U.current=!0;try{await a()}finally{U.current=!1}}}},[a]),se=w.useMemo(()=>!v||g?!1:O?"auto":!1,[O,v,g]),V=w.useMemo(()=>{if(typeof f!="string")return null;const H=f.trim();return!H||R&&R.length>0?null:{id:"default-message",role:"default_message",content:H,createdAt:new Date().toISOString()}},[f,R]),D=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),Z=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:V,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),ne=R.length,Y=ne>0;return w.useEffect(()=>{var H,ae;if(ne===0){$.current=!1;return}if(!$.current)if($.current=!0,K.current&&R.length>0){const le=R.length-1;(ae=(H=K.current).scrollToIndex)==null||ae.call(H,{index:le,align:"end",behavior:"auto"})}else N.current&&(N.current.scrollTop=N.current.scrollHeight)},[ne,R.length]),w.useImperativeHandle(W,()=>({scrollToLatest:()=>{var H,ae;if(K.current&&R.length>0){const le=R.length-1;(ae=(H=K.current).scrollToIndex)==null||ae.call(H,{index:le,align:"end",behavior:"auto"})}else N.current&&(N.current.scrollTop=N.current.scrollHeight)},scrollToTop:()=>{var H,ae;K.current&&R.length>0?(ae=(H=K.current).scrollToIndex)==null||ae.call(H,{index:0,align:"start",behavior:"auto"}):N.current&&(N.current.scrollTop=0)}}),[R]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Y?u.jsx(LC,{ref:H=>{K.current=H},scrollerRef:H=>{N.current=H instanceof HTMLDivElement?H:null},data:R,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{X&&X()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(H,ae)=>dl(ae,H),itemContent:(H,ae)=>u.jsx(fl,{message:ae,index:H,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:j,activeCheckpointId:M,onSelectCheckpoint:L})}):Z()})})});hl.displayName="MessageList";const Mp={value:""};function Or({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:h=!0,payloadExtras:m={},customStyles:f={},onMessageSent:v,onExcelUploadSuccess:g,onError:x}){const{api:y}=Xr(),{currentThreadId:b}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:M,checkpoints:L,interrupt:B,metadata:W,checkpointIndex:K}=eo(),{isStreaming:N,error:U,connectionState:$,submit:O,stop:P}=Li(),I=S??b??null,q=(M==null?void 0:M.id)??null,J=(M==null?void 0:M.namespace)??null,[_,R]=w.useState(null),G=(W==null?void 0:W.assemblingMessageId)??(N&&_?_:null),X=B,[se,V]=w.useState(!1);w.useEffect(()=>{X||V(!1)},[X]);const D=w.useCallback(()=>{V(!0)},[]),Z=w.useCallback(()=>{V(!1)},[]),ne=!!X||se,[Y,H]=w.useState(null),[ae,le]=w.useState(""),[fe,be]=w.useState(null),[Re,Oe]=w.useState(null),[Te,nt]=w.useState([]),[ht,kt]=w.useState(0),[Ke,Ge]=w.useState(0),[Ve,$e]=w.useState(!1),[He,mt]=w.useState(null),[Dt,lt]=w.useState(null),[Et,yt]=w.useState(!1),[gt,pt]=w.useState(null),an=w.useRef(!1),[dt,ke]=w.useState(()=>Mp.value),et=w.useRef(dt),Ae=w.useRef(null),Le=w.useCallback(ie=>{Mp.value=ie,ke(ie)},[]),[Bt,re]=w.useState(!1),we=w.useRef(null),rt=w.useRef(null),ge=w.useRef(null),Pe=w.useCallback(()=>{rt.current&&(rt.current.value=""),ge.current&&(ge.current.value=""),kt(ie=>ie+1),Ge(ie=>ie+1)},[]),Xe=w.useCallback(ie=>{Le(ie)},[Le]),Ct=w.useRef(!1);w.useEffect(()=>{Ct.current&&!N&&(nt([]),Pe()),Ct.current=N},[N,Pe]),w.useEffect(()=>{N||R(null)},[N]);const[It,At]=w.useState("desktop");w.useEffect(()=>{const ie=()=>{const Ce=window.innerWidth;At(Ce<640?"phone":Ce<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),w.useEffect(()=>{an.current=!1},[I]),w.useEffect(()=>{et.current=dt},[dt]),w.useEffect(()=>{if(!Y){Ae.current=null;return}Ae.current===null&&(Ae.current=et.current),Le(ae??"")},[ae,Y,Le]),w.useEffect(()=>{(async()=>{if(!y.baseUrl){pt(null);return}try{const ye=(await y.getAgent("default")).uiDefaultMessage||"";pt(ye||null)}catch(Ce){console.warn("Failed to fetch default message:",Ce),pt(null)}})()},[y.baseUrl]),w.useEffect(()=>{U&&!Et&&(x==null||x(U))},[U,Et,x]);const zt=async ie=>{const Ce=ie.trim();if(!Ce&&Te.length===0)return;const ye=Y;try{const Fe=Y?(fe==null?void 0:fe.checkpointId)??q??void 0:q??void 0,xt=Y?(fe==null?void 0:fe.checkpointNs)??J??void 0:J??void 0;await O({text:Ce||"",attachments:Te,payload:m},{checkpointId:Fe,checkpointNs:xt,edit:!!Y,originalMessageId:Y??void 0}),v==null||v(Ce),ye&&R(ye),Le(""),Oe(null),nt([]),Pe(),H(null),le(""),be(null)}catch(Fe){const xt=(Fe==null?void 0:Fe.message)||"Failed to send message";Oe(xt),x==null||x(xt)}},_e=w.useCallback((ie,Ce,ye)=>{c&&(Ae.current=dt,H(ie),le(Ce),Le(Ce),Oe(null),be({checkpointId:(ye==null?void 0:ye.checkpointId)??null,checkpointNs:(ye==null?void 0:ye.checkpointNs)??null}))},[dt,c,Le]),ct=w.useCallback(()=>{H(null),le(""),be(null),Oe(null),Le(Ae.current??dt),Ae.current=null,R(null)},[dt,Le]),Je=w.useCallback((ie,Ce,ye)=>{_e(ie,Ce,ye)},[_e]),ft=w.useCallback(ie=>{let Ce=null;for(let jt=ie-1;jt>=0;jt--)if(k[jt].role==="user"){Ce=k[jt];break}if(!Ce)return;const ye=Array.isArray(Ce.content)?Ce.content:[],xt=ye.filter(jt=>(jt==null?void 0:jt.type)==="text").map(jt=>jt.text).join("")||(()=>{try{return JSON.stringify(ye,null,2)}catch{return String(ye)}})();xt&&O({text:xt,payload:m},{checkpointId:q??void 0,checkpointNs:J??void 0,edit:!0,originalMessageId:Ce.id})},[k,O,q,J,m]),ln=ie=>{const Ce=Array.from(ie.target.files||[]);nt(ye=>[...ye,...Ce]),ie.target.value=""},A=ie=>{nt(Ce=>{const ye=Ce.filter((Fe,xt)=>ie!==xt);return ye.length===0&&Pe(),ye})},Q=async ie=>{const Ce=(ie.target.files||[])[0];if(Ce){mt(null),lt(null),$e(!0);try{await O({attachments:[Ce],payload:m},{checkpointId:q??void 0,checkpointNs:J??void 0});const ye=`Uploaded ${Ce.name} - processing through chat stream`;lt(ye)}catch(ye){const Fe=ye instanceof Error?ye.message:"Failed to upload Excel file";console.error("Excel upload failed",ye),mt(Fe),x==null||x(Fe)}finally{$e(!1),ie.target.value="",Pe()}}},de=async ie=>{if(b){re(!0);try{if(!ie){await j(),requestAnimationFrame(()=>{var Fe;(Fe=we.current)==null||Fe.scrollToLatest()});return}const Ce=L.find(Fe=>Fe.checkpointId===ie),ye=(Ce==null?void 0:Ce.checkpointNs)??null;await E(ie,ye),requestAnimationFrame(()=>{var Fe;(Fe=we.current)==null||Fe.scrollToTop()})}finally{re(!1)}}},Ie=w.useCallback(async(ie,Ce,ye)=>{await de(ye?null:ie)},[de]),Ye=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,tt=`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 ${f.messagesArea||""}`,Ue=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return u.jsxs("div",{className:Ye,children:[!!U&&!Et&&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:U}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>yt(!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 ${tt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:we,className:"h-full",style:{height:"100%"},messages:k,isStreaming:N,streamingAssistantId:G,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:It,enableMessageEditing:c,editingMessageId:Y,onEdit:Je,onRegenerate:ft,onCancelEdit:ct,emptyMessage:gt??void 0,isNavigatingCheckpoint:Bt,activeInterrupt:X,disableInterruptActions:se,onInterruptActionStart:D,onInterruptActionEnd:Z,showToolMessages:d,showArtifactPreviews:h,checkpointIndex:K,activeCheckpointId:q,onSelectCheckpoint:Ie,createSyntheticThinkingMessage:!0}),($==="reconnecting"||$==="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"}),$==="reconnecting"?"Reconnecting…":"Connecting…"]})}),$==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||Bt)&&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:Ue,children:[Y&&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(Qe,{variant:"ghost",size:"sm",onClick:ct,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:rt,type:"file",multiple:!0,onChange:ie=>ln(ie),className:"hidden"},ht),Te.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Te.map((ie,Ce)=>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:ie.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>A(Ce),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 ${ie.name}`,children:u.jsx(ue.X,{size:12})})]},Ce))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:ge,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Q,className:"hidden"},Ke),Ve&&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..."]}),Dt&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Dt}),He&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:He})]})]}),Re&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Re}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:N||ne,title:"More input actions",className:f.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(zn,{onClick:()=>{var ie;return(ie=rt.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(zn,{onClick:()=>{var ie;Ve||(ie=ge.current)==null||ie.click()},className:`cursor-pointer ${Ve?"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(IS,{initialValue:ae,editingMessageId:Y,value:dt,onValueChange:Xe,placeholder:Y?"Edit your message...":t,isStreaming:N,disabled:ne,onSend:zt,onCancelEdit:ct,onStop:P,allowEmptySend:Te.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${Y?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Re?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}var Rp=1,OT=.9,DT=.8,LT=.17,pl=.1,ml=.999,$T=.9999,FT=.99,BT=/[\\\/_+.#"@\[\(\{&]/,zT=/[\\\/_+.#"@\[\(\{&]/g,HT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Rp:FT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=gl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Rp:BT.test(e.charAt(c-1))?(h*=DT,f=e.slice(o,c-1).match(zT),f&&o>0&&(h*=Math.pow(ml,f.length))):HT.test(e.charAt(c-1))?(h*=OT,v=e.slice(o,c-1).match(Op),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=LT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=$T)),(h<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>h&&(h=m*pl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Dp(e){return e.toLowerCase().replace(Op," ")}function UT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',WT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Dr="data-value",VT=(e,t,n)=>UT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),wl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Lr(()=>{var _,R;return{search:"",value:(R=(_=e.value)!=null?_:e.defaultValue)!=null?R:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=Pt(),S=Pt(),k=Pt(),C=p.useRef(null),T=nk();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,K)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,R,G)=>{var X,se,V,D;if(!Object.is(n.current[_],R)){if(n.current[_]=R,_==="search")W(),L(),T(1,B);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(k);Z?Z.focus():(X=document.getElementById(b))==null||X.focus()}if(T(7,()=>{var Z;n.current.selectedItemId=(Z=N())==null?void 0:Z.id,E.emit()}),G||T(5,K),((se=a.current)==null?void 0:se.value)!==void 0){let Z=R??"";(D=(V=a.current).onValueChange)==null||D.call(V,Z);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=p.useMemo(()=>({value:(_,R,G)=>{var X;R!==((X=s.current.get(_))==null?void 0:X.value)&&(s.current.set(_,{value:R,keywords:G}),n.current.filtered.items.set(_,M(R,G)),T(2,()=>{L(),E.emit()}))},item:(_,R)=>(r.current.add(_),R&&(o.current.has(R)?o.current.get(R).add(_):o.current.set(R,new Set([_]))),T(3,()=>{W(),L(),n.current.value||B(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let G=N();T(4,()=>{W(),(G==null?void 0:G.getAttribute("id"))===_&&B(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:S,listInnerRef:C}),[]);function M(_,R){var G,X;let se=(X=(G=a.current)==null?void 0:G.filter)!=null?X:VT;return _?se(_,n.current.search,R):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,R=[];n.current.filtered.groups.forEach(X=>{let se=o.current.get(X),V=0;se.forEach(D=>{let Z=_.get(D);V=Math.max(Z,V)}),R.push([X,V])});let G=C.current;U().sort((X,se)=>{var V,D;let Z=X.getAttribute("id"),ne=se.getAttribute("id");return((V=_.get(ne))!=null?V:0)-((D=_.get(Z))!=null?D:0)}).forEach(X=>{let se=X.closest(xl);se?se.appendChild(X.parentElement===se?X:X.closest(`${xl} > *`)):G.appendChild(X.parentElement===G?X:X.closest(`${xl} > *`))}),R.sort((X,se)=>se[1]-X[1]).forEach(X=>{var se;let V=(se=C.current)==null?void 0:se.querySelector(`${Io}[${Dr}="${encodeURIComponent(X[0])}"]`);V==null||V.parentElement.appendChild(V)})}function B(){let _=U().find(G=>G.getAttribute("aria-disabled")!=="true"),R=_==null?void 0:_.getAttribute(Dr);E.setState("value",R||void 0)}function W(){var _,R,G,X;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let V of r.current){let D=(R=(_=s.current.get(V))==null?void 0:_.value)!=null?R:"",Z=(X=(G=s.current.get(V))==null?void 0:G.keywords)!=null?X:[],ne=M(D,Z);n.current.filtered.items.set(V,ne),ne>0&&se++}for(let[V,D]of o.current)for(let Z of D)if(n.current.filtered.items.get(Z)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=se}function K(){var _,R,G;let X=N();X&&(((_=X.parentElement)==null?void 0:_.firstChild)===X&&((G=(R=X.closest(Io))==null?void 0:R.querySelector(WT))==null||G.scrollIntoView({block:"nearest"})),X.scrollIntoView({block:"nearest"}))}function N(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Lp}[aria-selected="true"]`)}function U(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll($p))||[])}function $(_){let R=U()[_];R&&E.setState("value",R.getAttribute(Dr))}function O(_){var R;let G=N(),X=U(),se=X.findIndex(D=>D===G),V=X[se+_];(R=a.current)!=null&&R.loop&&(V=se+_<0?X[X.length-1]:se+_===X.length?X[0]:X[se+_]),V&&E.setState("value",V.getAttribute(Dr))}function P(_){let R=N(),G=R==null?void 0:R.closest(Io),X;for(;G&&!X;)G=_>0?ek(G,Io):tk(G,Io),X=G==null?void 0:G.querySelector($p);X?E.setState("value",X.getAttribute(Dr)):O(_)}let I=()=>$(U().length-1),q=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):O(1)},J=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):O(-1)};return p.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var R;(R=y.onKeyDown)==null||R.call(y,_);let G=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||G))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&q(_);break}case"ArrowDown":{q(_);break}case"p":case"k":{x&&_.ctrlKey&&J(_);break}case"ArrowUp":{J(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let X=N();if(X){let se=new Event(vl);X.dispatchEvent(se)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:ok},l),Xs(e,_=>p.createElement(Bp.Provider,{value:E},p.createElement(Fp.Provider,{value:j},_))))}),KT=p.forwardRef((e,t)=>{var n,r;let o=Pt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(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=Wp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:S,keywords:k,...C}=e;return p.createElement(me.div,{ref:Dn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),qT=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=p.useRef(null),l=p.useRef(null),c=Pt(),d=No(),h=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(me.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(zp.Provider,{value:m},f))))}),GT=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:p.createElement(me.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),YT=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.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)}})}),XT=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Gn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(me.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),JT=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Hp,{ref:t,...a}))))}),ZT=p.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?p.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),QT=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Hp,{List:XT,Item:KT,Input:YT,Group:qT,Separator:GT,Dialog:JT,Empty:ZT,Loading:QT});function ek(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Lr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Dr,a),o.current=a}),o}var nk=()=>{let[e,t]=p.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function rk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(rk(t),{ref:t.ref},n(t.props.children)):n(t)}var ok={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const bl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));bl.displayName=Kt.displayName;const yl=p.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(Kt.Input,{ref:n,className:te("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Group,{ref:n,className:te("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Tl.displayName=Kt.Group.displayName;const sk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));sk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function ik(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,CN]=un(Il),[ak,sn]=Vp(Il),Kp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,j]=p.useState(!1),M=Be(t,B=>l(B)),L=Xo(o);return u.jsx(ak,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(me.div,{dir:L,...i,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=Be(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})})]})});Gp.displayName=qp;var Nn="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(lk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(ck,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=Nn;var lk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),ck=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=ik("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(Nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(Nn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=em(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 h(m,f){return mk(m,i.current,a,f)}return n==="horizontal"?u.jsx(uk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=tm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(dk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=tm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),uk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Be(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),dk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Be(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[fk,Xp]=Vp(Nn),Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=sn(Nn,n),[v,g]=p.useState(null),x=Be(t,M=>g(M)),y=p.useRef(null),b=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=wt(d),T=wt(l),E=ei(h,10);function j(M){if(y.current){const L=M.clientX-y.current.left,B=M.clientY-y.current.top;c({x:L,y:B})}}return p.useEffect(()=>{const M=L=>{const B=L.target;(v==null?void 0:v.contains(B))&&C(L,k)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(fk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:wt(s),onThumbPointerUp:wt(i),onThumbPositionChange:T,onThumbPointerDown:wt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(M))}),onPointerMove:ce(e.onPointerMove,j),onPointerUp:ce(e.onPointerUp,M=>{const L=M.target;L.hasPointerCapture(M.pointerId)&&L.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(hk,{ref:t,...r})})}),hk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=Be(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=gk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.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:ce(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(pk,{...e,ref:t}):null});Qp.displayName=jl;var pk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(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 Zs(e){return e?parseInt(e,10):0}function em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(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=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return nm([l,c],h)(e)}function tm(e,t,n="ltr"){const r=Qs(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=El(e,l);return nm([0,i],[0,a])(c)}function nm(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 rm(e,t){return e>0&&e<t}var gk=(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 ei(e,t){const n=wt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function $r(e,t){const n=wt(t);Nt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var om=Kp,xk=Gp,vk=Qp;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(xk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(vk,{})]}));_l.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{ref:r,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const Pl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Pl.displayName="Input";const wk="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",yk="bg-slate-600 border-slate-500";function im({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,S=t?`${y??yk}`:`${x??bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${wk} ${S}`,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:C=>C.stopPropagation(),children:[u.jsx(Pl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Qe,{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:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(zn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(zn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(zn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},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 am=25,lm="thread-manager-view",Sk=e=>e==="default"||e==="shared",Ck=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(Sk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=w.useState(()=>Ck()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Tk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:M,actions:L,shareInFlight:B,shareStatus:W,clearShareStatus:K}=xr(),{createThread:N,deleteThread:U,renameThread:$,shareThread:O}=L,{loadThread:P}=eo(),I=i??T,[q,J]=w.useState(Array.isArray(k)?k:[]),_=w.useRef(q.length>0),R=w.useRef(null),G=w.useRef(0),[X,se]=w.useState(null),[V,D]=w.useState(""),[Z,ne]=w.useState(!1),[Y,H]=w.useState(!1),[ae,le]=w.useState(null),[fe,be]=w.useState(""),Re=v&&v.length>0?v:Tk,Oe=cm({defaultView:m}),Te=g??Oe,nt=h??Te.view,ht=w.useCallback(re=>{h||Te.setView(re),f==null||f(re)},[h,f,Te]),kt=Re.find(re=>re.key===nt)??Re[0],Ke=re=>{le(re),be(""),H(!0)},Ge=()=>{H(!1),le(null),be(""),K()},Ve=w.useCallback(async re=>{if(!(!ae||B)&&re.id)try{await O(ae,re.id),setTimeout(()=>Ge(),600)}catch(we){console.error("Failed to share thread:",we)}},[Ge,B,ae,O]),$e=w.useMemo(()=>{const re=y??[],we=fe.trim().toLowerCase();return we?S?re.filter(rt=>S(rt,we)):re.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(we)):re},[y,fe,S]),He=nt==="shared",mt=He?C:q,Dt=He?M:j,lt=He?"No shared conversations yet":"No conversations yet",Et=re=>{const we=re.sharedAt?` • ${Ae(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${we}`},yt=re=>"sharedByUserId"in re;w.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,J(re);return}j||(_.current=!1,J(re))},[k,j]),w.useEffect(()=>{if(!R.current)return;const re=R.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let we=null,rt=null;return we=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{re.scrollTop=G.current})}),()=>{we!==null&&cancelAnimationFrame(we),rt!==null&&cancelAnimationFrame(rt)}},[q]);const gt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(we){console.error("Failed to select thread:",we)}},pt=async()=>{try{ne(!0);const re=await N();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{ne(!1)}},an=async(re,we)=>{if(we.stopPropagation(),!!confirm("Delete this thread?")){if(R.current){const rt=R.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(G.current=rt.scrollTop)}try{await U(re),d==null||d(re)}catch(rt){console.error("Failed to delete thread:",rt)}}},dt=(re,we)=>{we.stopPropagation(),se(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},ke=async re=>{if(V.trim())try{await $(re,V.trim()),se(null),D("")}catch(we){console.error("Failed to update title:",we)}},et=()=>{se(null),D("")},Ae=re=>{if(!re)return"";try{const we=new Date(re),ge=new Date().getTime()-we.getTime(),Pe=Math.floor(ge/(1e3*60*60*24));return Pe===0?we.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:we.toLocaleDateString()}catch{return""}},Le=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,Bt=re=>{const we=Le(re);return we.length<=am?we:`${we.slice(0,am)}...`};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(Qe,{onClick:pt,disabled:Z||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Z?"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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{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:kt.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Re.map(re=>u.jsxs(zn,{className:"justify-between text-[12px]",onClick:we=>{we.preventDefault(),ht(re.key)},children:[u.jsx("span",{children:re.label}),nt===re.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(_l,{ref:R,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:Dt?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…"})]}):mt.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:lt})]}):mt.slice().sort((re,we)=>new Date(we.updatedAt||we.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(im,{thread:re,isActive:I===re.threadId,editingThreadId:X,editingTitle:V,onSelect:gt,onStartEditing:dt,onEditingTitleChange:we=>D(we),onSaveEditing:ke,onCancelEditing:et,onShare:()=>Ke(re.threadId),onDelete:an,showEditTitle:r,showDeleteButton:n,formatDate:Ae,getDisplayThreadTitle:Bt,secondaryLine:He&&yt(re)?Et(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:Y,onOpenChange:re=>!re&&Ge(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(bl,{children:[u.jsx(yl,{autoFocus:!0,value:fe,onValueChange:re=>be(re),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[B&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),u.jsx(Cl,{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"}),$e.length>0&&u.jsx(Tl,{heading:"Recipients",children:$e.map(re=>u.jsx(kl,{onSelect:()=>Ve(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.id))})]})]})]})})]})}function kk({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(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(wr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Ek({apiConfig:e,className:t="",onError:n}){return u.jsx(wr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function Ik({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(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Nk({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(wr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{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(Qe,{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(Qe,{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(Ik,{placeholder:t,onMessageSent:r})})]})})}):null}function Ak({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:te("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var jk="Label",um=p.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())}}));um.displayName=jk;var dm=um;const _k=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:te(_k(),e),...t}));fm.displayName=dm.displayName;function hm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pm=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"}),Pk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Pk;var Mk=ni,Rk=[" ","Enter","ArrowUp","ArrowDown"],Ok=[" ","Enter"],dr="Select",[ri,oi,Dk]=Yo(dr),[Fr,TN]=un(dr,[Dk,Er]),si=Er(),[Lk,Yn]=Fr(dr),[$k,Fk]=Fr(dr),mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=p.useState(null),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[E,j]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[M,L]=Ln({prop:i,defaultProp:a,onChange:l,caller:dr}),B=p.useRef(null),W=x?v||!!x.closest("form"):!0,[K,N]=p.useState(new Set),U=Array.from(K).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Lk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:M,onValueChange:L,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:B,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx($k,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback($=>{N(O=>new Set(O).add($))},[]),onNativeOptionRemove:p.useCallback($=>{N(O=>{const P=new Set(O);return P.delete($),P})},[]),children:n})}),W?u.jsxs(Fm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:M,onChange:$=>L($.target.value),disabled:m,form:v,children:[M===void 0?u.jsx("option",{value:""}):null,Array.from(K)]},U):null]})})};mm.displayName=dr;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Yn(gm,n),a=i.disabled||r,l=Be(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Hm(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sa,{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":Bm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(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:ce(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Rk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Be(t,l.onValueNodeChange);return Nt(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:h,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=vm;var Bk="SelectIcon",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});bm.displayName=Bk;var zk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=zk;var fr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=p.useState();if(Nt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=fr;var gn=10,[Cm,Xn]=Fr(fr),Hk="SelectContentImpl",Uk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=Yn(fr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=Be(t,V=>k(V)),[j,M]=p.useState(null),[L,B]=p.useState(null),W=oi(n),[K,N]=p.useState(!1),U=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=p.useCallback(V=>{const[D,...Z]=W().map(H=>H.ref.current),[ne]=Z.slice(-1),Y=document.activeElement;for(const H of V)if(H===Y||(H==null||H.scrollIntoView({block:"nearest"}),H===D&&C&&(C.scrollTop=0),H===ne&&C&&(C.scrollTop=C.scrollHeight),H==null||H.focus(),document.activeElement!==Y))return},[W,C]),O=p.useCallback(()=>$([j,S]),[$,j,S]);p.useEffect(()=>{K&&O()},[K,O]);const{onOpenChange:P,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(S){let V={x:0,y:0};const D=ne=>{var Y,H;V={x:Math.abs(Math.round(ne.pageX)-(((Y=I.current)==null?void 0:Y.x)??0)),y:Math.abs(Math.round(ne.pageY)-(((H=I.current)==null?void 0:H.y)??0))}},Z=ne=>{V.x<=10&&V.y<=10?ne.preventDefault():S.contains(ne.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",Z,{capture:!0})}}},[S,P,I]),p.useEffect(()=>{const V=()=>P(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[P]);const[q,J]=zm(V=>{const D=W().filter(Y=>!Y.disabled),Z=D.find(Y=>Y.ref.current===document.activeElement),ne=Hm(D,V,Z);ne&&setTimeout(()=>ne.ref.current.focus())}),_=p.useCallback((V,D,Z)=>{const ne=!U.current&&!Z;(b.value!==void 0&&b.value===D||ne)&&(M(V),ne&&(U.current=!0))},[b.value]),R=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((V,D,Z)=>{const ne=!U.current&&!Z;(b.value!==void 0&&b.value===D||ne)&&B(V)},[b.value]),X=r==="popper"?Ml:km,se=X===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:j,onItemLeave:R,itemTextRefCallback:G,focusSelectedItem:O,selectedItemText:L,position:r,isPositioned:K,searchRef:q,children:u.jsx(gs,{as:Uk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:b.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:ce(o,V=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(X,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:V=>V.preventDefault(),...y,...se,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,V=>{const D=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!D&&V.key.length===1&&J(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let ne=W().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);if(["ArrowUp","End"].includes(V.key)&&(ne=ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const Y=V.target,H=ne.indexOf(Y);ne=ne.slice(H+1)}setTimeout(()=>$(ne)),V.preventDefault()}})})})})})})});Tm.displayName=Hk;var Wk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=Be(t,E=>d(E)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const Y=L.left-j.left,H=M.left-Y,ae=E.left-H,le=E.width+ae,fe=Math.max(le,j.width),be=window.innerWidth-gn,Re=El(H,[gn,Math.max(gn,be-fe)]);a.style.minWidth=le+"px",a.style.left=Re+"px"}else{const Y=j.right-L.right,H=window.innerWidth-M.right-Y,ae=window.innerWidth-E.right-H,le=E.width+ae,fe=Math.max(le,j.width),be=window.innerWidth-gn,Re=El(H,[gn,Math.max(gn,be-fe)]);a.style.minWidth=le+"px",a.style.right=Re+"px"}const B=m(),W=window.innerHeight-gn*2,K=g.scrollHeight,N=window.getComputedStyle(c),U=parseInt(N.borderTopWidth,10),$=parseInt(N.paddingTop,10),O=parseInt(N.borderBottomWidth,10),P=parseInt(N.paddingBottom,10),I=U+$+K+P+O,q=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),_=parseInt(J.paddingTop,10),R=parseInt(J.paddingBottom,10),G=E.top+E.height/2-gn,X=W-G,se=x.offsetHeight/2,V=x.offsetTop+se,D=U+$+V,Z=I-D;if(D<=G){const Y=B.length>0&&x===B[B.length-1].ref.current;a.style.bottom="0px";const H=c.clientHeight-g.offsetTop-g.offsetHeight,ae=Math.max(X,se+(Y?R:0)+H+O),le=D+ae;a.style.height=le+"px"}else{const Y=B.length>0&&x===B[0].ref.current;a.style.top="0px";const ae=Math.max(G,U+g.offsetTop+(Y?_:0)+se)+Z;a.style.height=ae+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${gn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=W+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Nt(()=>S(),[S]);const[k,C]=p.useState();Nt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Kk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(me.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Wk;var Vk="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=gn,...s}=e,i=si(n);return u.jsx(ia,{...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)"}})});Ml.displayName=Vk;var[Kk,Rl]=Fr(fr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Ol,n),i=Rl(Ol,n),a=Be(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.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:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-gn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Em.displayName=Ol;var Im="SelectGroup",[qk,Gk]=Fr(Im),Yk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(qk,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Yk.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gk(Nm,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[Xk,jm]=Fr(ii),_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ii,n),l=Xn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=Be(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=Pt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Xk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ri.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:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ce(i.onPointerMove,b=>{var S;x.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Ok.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});_m.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(Ao,n),a=Xn(Ao,n),l=jm(Ao,n),c=Fk(Ao,n),[d,h]=p.useState(null),m=Be(t,y=>h(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Nt(()=>(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?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var Mm="SelectItemIndicator",Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Mm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Rm.displayName=Mm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Xn(Dl,e.__scopeSelect),r=Rl(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=Be(t,r.onScrollButtonChange);return Nt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Rl(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Be(t,r.onScrollButtonChange);return Nt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Nt(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),Jk="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=Jk;var $l="SelectArrow",Zk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Yn($l,n),i=Xn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});Zk.displayName=$l;var Qk="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Be(r,o),i=hm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(me.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=Qk;function Bm(e){return e===""||e===void 0}function zm(e){const t=wt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hm(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=eE(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 eE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tE=mm,Um=xm,nE=wm,rE=bm,oE=ym,Wm=Sm,sE=Em,Vm=Am,Km=_m,iE=Pm,aE=Rm,qm=Om,Gm=Dm,Ym=$m;const lE=tE,cE=nE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{ref:r,className:te("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(rE,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(oE,{children:u.jsxs(Wm,{ref:o,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Jm,{}),u.jsx(sE,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Zm,{})]})}));Qm.displayName=Wm.displayName;const uE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));uE.displayName=Vm.displayName;const eg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(aE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(iE,{children:t})]}));eg.displayName=Km.displayName;const dE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));dE.displayName=Ym.displayName;var fE="Separator",tg="horizontal",hE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=pE(r)?r:tg,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})});ng.displayName=fE;function pE(e){return hE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[mE,kN]=un(ai),[gE,xE]=mE(ai),sg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=Be(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=Ln({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(gE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ce(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=xE(ig,n);return u.jsx(me.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var vE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Be(i,s),l=hm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lg.displayName=vE;function cg(e){return e?"checked":"unchecked"}var ug=sg,wE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{className:te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(wE,{className:te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));dg.displayName=ug.displayName;const bE=Ja,yE=lT,SE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));fg.displayName=To.displayName;const CE=zr.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"}}),hg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(SE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:te(CE({side:e}),t),...r,children:[n,u.jsxs(op,{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"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));mg.displayName=lr.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,EN]=un("Tooltip",[Er]),ci=Er(),xg="TooltipProvider",TE=700,Fl="tooltip.open",[kE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=TE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(kE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};vg.displayName=xg;var jo="Tooltip",[EE,ui]=li(jo),wg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=Pt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,b]=Ln({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(E)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(EE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};wg.displayName=jo;var zl="TooltipTrigger",bg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=Be(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});bg.displayName=zl;var IE="TooltipPortal",[IN,NE]=li(IE,{forceMount:void 0}),Br="TooltipContent",yg=p.forwardRef((e,t)=>{const n=NE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Br,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(AE,{side:o,...s,ref:t})})}),AE=p.forwardRef((e,t)=>{const n=ui(Br,e.__scopeTooltip),r=Bl(Br,e.__scopeTooltip),o=p.useRef(null),s=Be(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=RE(y,x.getBoundingClientRect()),S=OE(y,b),k=DE(g.getBoundingClientRect()),C=$E([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.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)),S=!LE(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[jE,_E]=li(jo,{isInside:!1}),PE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Br,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"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(PE,{children:r}),u.jsx(jE,{scope:n,isInside:!0,children:u.jsx(Mk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Br;var Cg="TooltipArrow",ME=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return _E(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});ME.displayName=Cg;function RE(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 OE(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 DE(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 LE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $E(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),FE(t)}function FE(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 BE=vg,zE=wg,HE=bg,Tg=yg;const UE=BE,WE=zE,VE=HE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{ref:r,sideOffset:t,className:te("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,KE,qE]=Yo("Toast"),[Eg,NN]=un("Toast",[qE]),[GE,di]=Eg(Hl),Ig=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(GE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};Ig.displayName=Hl;var Ng="ToastViewport",YE=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=YE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=KE(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=Be(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,C=[k,...lI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var C,T,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const j=document.activeElement,M=b.shiftKey;if(b.target===x&&M){(C=c.current)==null||C.focus();return}const W=g({tabbingDirection:M?"backwards":"forwards"}),K=W.findIndex(N=>N===j);Gl(W.slice(K+1))?b.preventDefault():M?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Dw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=jg;var _o="Toast",XE="toast.swipeStart",JE="toast.swipeMove",ZE="toast.swipeCancel",QE="toast.swipeEnd",_g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Ln({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(nI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:wt(e.onPause),onResume:wt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ce(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:ce(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});_g.displayName=_o;var[eI,tI]=Eg(_o,{onClose(){}}),nI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=p.useState(null),b=Be(t,N=>y(N)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),j=p.useRef(0),{onToastAdd:M,onToastRemove:L}=g,B=wt(()=>{var U;(x==null?void 0:x.contains(document.activeElement))&&((U=g.viewport)==null||U.focus()),i()}),W=p.useCallback(N=>{!N||N===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(B,N))},[B]);p.useEffect(()=>{const N=g.viewport;if(N){const U=()=>{W(E.current),c==null||c()},$=()=>{const O=new Date().getTime()-T.current;E.current=E.current-O,window.clearTimeout(j.current),l==null||l()};return N.addEventListener(Wl,$),N.addEventListener(Vl,U),()=>{N.removeEventListener(Wl,$),N.removeEventListener(Vl,U)}}},[g.viewport,C,l,c,W]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&W(C)},[s,C,g.isClosePausedRef,W]),p.useEffect(()=>(M(),()=>L()),[M,L]);const K=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[K&&u.jsx(rI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:K}),u.jsx(eI,{scope:n,onClose:B,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ow,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||B(),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:ce(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,B()))}),onPointerDown:ce(e.onPointerDown,N=>{N.button===0&&(S.current={x:N.clientX,y:N.clientY})}),onPointerMove:ce(e.onPointerMove,N=>{if(!S.current)return;const U=N.clientX-S.current.x,$=N.clientY-S.current.y,O=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=P?I(0,U):0,J=P?0:I(0,$),_=N.pointerType==="touch"?10:2,R={x:q,y:J},G={originalEvent:N,delta:R};O?(k.current=R,fi(JE,h,G,{discrete:!1})):Fg(R,g.swipeDirection,_)?(k.current=R,fi(XE,d,G,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(U)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,N=>{const U=k.current,$=N.target;if($.hasPointerCapture(N.pointerId)&&$.releasePointerCapture(N.pointerId),k.current=null,S.current=null,U){const O=N.currentTarget,P={originalEvent:N,delta:U};Fg(U,g.swipeDirection,g.swipeThreshold)?fi(QE,f,P,{discrete:!0}):fi(ZE,m,P,{discrete:!0}),O.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),rI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return iI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},oI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Pg.displayName=oI;var sI="ToastDescription",Mg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Mg.displayName=sI;var Rg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Rg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Rg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=tI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.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 $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),aI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...$g(r))}}),t}function fi(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?Fi(o,s):o.dispatchEvent(s)}var Fg=(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 iI(e=()=>{}){const t=wt(e);Nt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function aI(e){return e.nodeType===e.ELEMENT_NODE}function lI(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 Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var cI=Ig,Bg=Ag,zg=_g,Hg=Pg,Ug=Mg,Wg=Og,Vg=ql;const uI=cI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:te("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Kg.displayName=Bg.displayName;const dI=zr.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=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:te(dI({variant:t}),e),...n}));qg.displayName=zg.displayName;const fI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:te("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));fI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:te("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:te("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:te("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function hI(){const{toasts:e}=nl();return u.jsxs(uI,{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(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var pI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},mI=p.createContext(void 0),gI={setTheme:e=>{},themes:[]},xI=()=>{var e;return(e=p.useContext(mI))!=null?e:gI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${pI.toString()})(${d})`}})});var vI=e=>{switch(e){case"success":return yI;case"info":return CI;case"warning":return SI;case"error":return TI;default:return null}},wI=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"},wI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),yI=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"})),SI=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"})),CI=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"})),TI=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"})),kI=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"})),EI=()=>{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},Yl=1,II=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:Yl++,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(AI(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)||Yl++;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}},qt=new II,NI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.addToast({title:e,...t,id:n}),n},AI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jI=NI,_I=()=>qt.toasts,PI=()=>qt.getActiveToasts();Object.assign(jI,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:_I,getToasts:PI});function MI(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))}MI(`: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%)}
|
|
130
|
-
`);function hi(e){return e.label!==void 0}var RI=3,OI="32px",DI="16px",Jg=4e3,LI=356,$I=14,FI=20,BI=200;function xn(...e){return e.filter(Boolean).join(" ")}function zI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var HI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:M,cancelButtonStyle:L,actionButtonStyle:B,className:W="",descriptionClassName:K="",duration:N,position:U,gap:$,loadingIcon:O,expandByDefault:P,classNames:I,icons:q,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:_}=e,[R,G]=w.useState(null),[X,se]=w.useState(null),[V,D]=w.useState(!1),[Z,ne]=w.useState(!1),[Y,H]=w.useState(!1),[ae,le]=w.useState(!1),[fe,be]=w.useState(!1),[Re,Oe]=w.useState(0),[Te,nt]=w.useState(0),ht=w.useRef(f.duration||N||Jg),kt=w.useRef(null),Ke=w.useRef(null),Ge=S===0,Ve=S+1<=y,$e=f.type,He=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",lt=w.useMemo(()=>b.findIndex(ge=>ge.toastId===f.id)||0,[b,f.id]),Et=w.useMemo(()=>{var ge;return(ge=f.closeButton)!=null?ge:j},[f.closeButton,j]),yt=w.useMemo(()=>f.duration||N||Jg,[f.duration,N]),gt=w.useRef(0),pt=w.useRef(0),an=w.useRef(0),dt=w.useRef(null),[ke,et]=U.split("-"),Ae=w.useMemo(()=>b.reduce((ge,Pe,Xe)=>Xe>=lt?ge:ge+Pe.height,0),[b,lt]),Le=EI(),Bt=f.invert||m,re=$e==="loading";pt.current=w.useMemo(()=>lt*$+Ae,[lt,Ae]),w.useEffect(()=>{ht.current=yt},[yt]),w.useEffect(()=>{D(!0)},[]),w.useEffect(()=>{let ge=Ke.current;if(ge){let Pe=ge.getBoundingClientRect().height;return nt(Pe),x(Xe=>[{toastId:f.id,height:Pe,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(Ct=>Ct.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!V)return;let ge=Ke.current,Pe=ge.style.height;ge.style.height="auto";let Xe=ge.getBoundingClientRect().height;ge.style.height=Pe,nt(Xe),x(Ct=>Ct.find(It=>It.toastId===f.id)?Ct.map(It=>It.toastId===f.id?{...It,height:Xe}:It):[{toastId:f.id,height:Xe,position:f.position},...Ct])},[V,f.title,f.description,x,f.id]);let we=w.useCallback(()=>{ne(!0),Oe(pt.current),x(ge=>ge.filter(Pe=>Pe.toastId!==f.id)),setTimeout(()=>{T(f)},BI)},[f,T,x,pt]);w.useEffect(()=>{if(f.promise&&$e==="loading"||f.duration===1/0||f.type==="loading")return;let ge;return C||g||_&&Le?(()=>{if(an.current<gt.current){let Pe=new Date().getTime()-gt.current;ht.current=ht.current-Pe}an.current=new Date().getTime()})():ht.current!==1/0&&(gt.current=new Date().getTime(),ge=setTimeout(()=>{var Pe;(Pe=f.onAutoClose)==null||Pe.call(f,f),we()},ht.current)),()=>clearTimeout(ge)},[C,g,f,$e,_,Le,we]),w.useEffect(()=>{f.delete&&we()},[we,f.delete]);function rt(){var ge,Pe,Xe;return q!=null&&q.loading?w.createElement("div",{className:xn(I==null?void 0:I.loader,(ge=f==null?void 0:f.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":$e==="loading"},q.loading):O?w.createElement("div",{className:xn(I==null?void 0:I.loader,(Pe=f==null?void 0:f.classNames)==null?void 0:Pe.loader,"sonner-loader"),"data-visible":$e==="loading"},O):w.createElement(bI,{className:xn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:$e==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ke,className:xn(W,mt,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[$e],(n=f==null?void 0:f.classNames)==null?void 0:n[$e]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":fe,"data-removed":Z,"data-visible":Ve,"data-y-position":ke,"data-x-position":et,"data-index":S,"data-front":Ge,"data-swiping":Y,"data-dismissible":He,"data-type":$e,"data-invert":Bt,"data-swipe-out":ae,"data-swipe-direction":X,"data-expanded":!!(C||P&&V),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${Z?Re:pt.current}px`,"--initial-height":P?"auto":`${Te}px`,...M,...f.style},onDragEnd:()=>{H(!1),G(null),dt.current=null},onPointerDown:ge=>{re||!He||(kt.current=new Date,Oe(pt.current),ge.target.setPointerCapture(ge.pointerId),ge.target.tagName!=="BUTTON"&&(H(!0),dt.current={x:ge.clientX,y:ge.clientY}))},onPointerUp:()=>{var ge,Pe,Xe,Ct;if(ae||!He)return;dt.current=null;let It=Number(((ge=Ke.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((Pe=Ke.current)==null?void 0:Pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),zt=new Date().getTime()-((Xe=kt.current)==null?void 0:Xe.getTime()),_e=R==="x"?It:At,ct=Math.abs(_e)/zt;if(Math.abs(_e)>=FI||ct>.11){Oe(pt.current),(Ct=f.onDismiss)==null||Ct.call(f,f),se(R==="x"?It>0?"right":"left":At>0?"down":"up"),we(),le(!0),be(!1);return}H(!1),G(null)},onPointerMove:ge=>{var Pe,Xe,Ct,It;if(!dt.current||!He||((Pe=window.getSelection())==null?void 0:Pe.toString().length)>0)return;let At=ge.clientY-dt.current.y,zt=ge.clientX-dt.current.x,_e=(Xe=e.swipeDirections)!=null?Xe:zI(U);!R&&(Math.abs(zt)>1||Math.abs(At)>1)&&G(Math.abs(zt)>Math.abs(At)?"x":"y");let ct={x:0,y:0};R==="y"?(_e.includes("top")||_e.includes("bottom"))&&(_e.includes("top")&&At<0||_e.includes("bottom")&&At>0)&&(ct.y=At):R==="x"&&(_e.includes("left")||_e.includes("right"))&&(_e.includes("left")&&zt<0||_e.includes("right")&&zt>0)&&(ct.x=zt),(Math.abs(ct.x)>0||Math.abs(ct.y)>0)&&be(!0),(Ct=Ke.current)==null||Ct.style.setProperty("--swipe-amount-x",`${ct.x}px`),(It=Ke.current)==null||It.style.setProperty("--swipe-amount-y",`${ct.y}px`)}},Et&&!f.jsx?w.createElement("button",{"aria-label":J,"data-disabled":re,"data-close-button":!0,onClick:re||!He?()=>{}:()=>{var ge;we(),(ge=f.onDismiss)==null||ge.call(f,f)},className:xn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:kI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,$e||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:xn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||rt():null,f.type!=="loading"?f.icon||(q==null?void 0:q[$e])||vI($e):null):null,w.createElement("div",{"data-content":"",className:xn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:xn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?w.createElement("div",{"data-description":"",className:xn(K,Dt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),w.isValidElement(f.cancel)?f.cancel:f.cancel&&hi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:ge=>{var Pe,Xe;hi(f.cancel)&&He&&((Xe=(Pe=f.cancel).onClick)==null||Xe.call(Pe,ge),we())},className:xn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&hi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||B,onClick:ge=>{var Pe,Xe;hi(f.action)&&((Xe=(Pe=f.action).onClick)==null||Xe.call(Pe,ge),!ge.defaultPrevented&&we())},className:xn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Zg(){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 UI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?DI:OI;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 WI=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:h,duration:m,style:f,visibleToasts:v=RI,toastOptions:g,dir:x=Zg(),gap:y=$I,loadingIcon:b,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=w.useState([]),j=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[M,L]=w.useState([]),[B,W]=w.useState(!1),[K,N]=w.useState(!1),[U,$]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=w.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),q=w.useRef(!1),J=w.useCallback(_=>{E(R=>{var G;return(G=R.find(X=>X.id===_.id))!=null&&G.delete||qt.dismiss(_.id),R.filter(({id:X})=>X!==_.id)})},[]);return w.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){E(R=>R.map(G=>G.id===_.id?{...G,delete:!0}:G));return}setTimeout(()=>{Po.flushSync(()=>{E(R=>{let G=R.findIndex(X=>X.id===_.id);return G!==-1?[...R.slice(0,G),{...R[G],..._},...R.slice(G+1)]:[_,...R]})})})}),[]),w.useEffect(()=>{if(d!=="system"){$(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:R})=>{$(R?"dark":"light")})}catch{_.addListener(({matches:G})=>{try{$(G?"dark":"light")}catch(X){console.error(X)}})}},[d]),w.useEffect(()=>{T.length<=1&&W(!1)},[T]),w.useEffect(()=>{let _=R=>{var G,X;o.every(se=>R[se]||R.code===se)&&(W(!0),(G=O.current)==null||G.focus()),R.code==="Escape"&&(document.activeElement===O.current||(X=O.current)!=null&&X.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),w.useEffect(()=>{if(O.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,q.current=!1)}},[O.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((_,R)=>{var G;let[X,se]=_.split("-");return T.length?w.createElement("ol",{key:_,dir:x==="auto"?Zg():x,tabIndex:-1,ref:O,className:a,"data-sonner-toaster":!0,"data-theme":U,"data-y-position":X,"data-lifted":B&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((G=M[0])==null?void 0:G.height)||0}px`,"--width":`${LI}px`,"--gap":`${y}px`,...f,...UI(l,c)},onBlur:V=>{q.current&&!V.currentTarget.contains(V.relatedTarget)&&(q.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||q.current||(q.current=!0,I.current=V.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{K||W(!1)},onDragEnd:()=>W(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},T.filter(V=>!V.position&&R===0||V.position===_).map((V,D)=>{var Z,ne;return w.createElement(HI,{key:V.id,icons:S,index:D,toast:V,defaultRichColors:h,duration:(Z=g==null?void 0:g.duration)!=null?Z:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(ne=g==null?void 0:g.closeButton)!=null?ne:i,interacting:K,position:_,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(Y=>Y.position==V.position),heights:M.filter(Y=>Y.position==V.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:B,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const VI=({...e})=>{const{theme:t="system"}=xI();return u.jsx(WI,{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})};F.Api=Fv,F.ApiClient=$v,F.ApiProvider=tu,F.ArtifactRenderer=Cp,F.Badge=zh,F.Button=Qe,F.Card=sl,F.CardContent=cl,F.CardDescription=ll,F.CardHeader=il,F.CardTitle=al,F.ChatApi=Ko,F.ChatApp=kk,F.ChatInput=Hf,F.ChatInterface=Or,F.ChatProviders=wr,F.ChatWidget=Nk,F.Command=bl,F.CommandEmpty=Cl,F.CommandGroup=Tl,F.CommandInput=yl,F.CommandItem=kl,F.CommandList=Sl,F.DEFAULT_TIMEOUT_MS=Yc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=ho,F.DropdownMenuItem=zn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=ap,F.HISTORY_TIMEOUT_MS=Xc,F.Input=Pl,F.InterruptPartRenderer=kp,F.Label=fm,F.MarkdownContent=Rr,F.MessageBody=jp,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=fl,F.NewChatButton=Ak,F.PlotArtifact=yp,F.ResearchTaskArtifact=Sp,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=_l,F.Select=lE,F.SelectContent=Qm,F.SelectItem=eg,F.SelectTrigger=Xm,F.SelectValue=cE,F.Separator=og,F.Sheet=bE,F.SheetContent=hg,F.SheetDescription=gg,F.SheetHeader=pg,F.SheetTitle=mg,F.SheetTrigger=yE,F.SimpleChat=Ek,F.SimpleJsonView=ul,F.Sonner=VI,F.StreamProgress=Ep,F.Switch=dg,F.Textarea=Ta,F.ThinkingIndicator=Np,F.ThreadListItem=im,F.ThreadManager=ti,F.ThreadStateProvider=Tu,F.ThreadsProvider=fu,F.TimelineColumn=mx,F.Toaster=hI,F.ToolComponent=Ip,F.Tooltip=WE,F.TooltipContent=kg,F.TooltipProvider=UE,F.TooltipTrigger=VE,F.UserTextContent=Ap,F.applySettings=ww,F.buildCheckpointIndex=Ql,F.buildCheckpointPreviewMap=ox,F.chatApiClient=On,F.del=Ai,F.downloadFileById=Zc,F.extractConfigFields=mi,F.fileToBase64=nu,F.get=Jt,F.getChatToken=qc,F.getCheckpointForMessage=sx,F.getCurrentSettings=vw,F.getDefaultApiConfig=Mu,F.getDefaultChatSettings=Ru,F.getFileContent=_i,F.getFileInfo=zv,F.getMessageAttemptInfo=ec,F.getMessageDomKey=dl,F.getPreviewForMessage=pi,F.httpClient=Xt,F.hydrateHistorySnapshots=Rn,F.isEnvelope=ou,F.listFiles=Qc,F.loadStoredSettings=Ou,F.onChatTokenChanged=Gc,F.post=Vo,F.processAttachments=ru,F.put=Jc,F.readNumber=nc,F.readString=Mn,F.resolveChatBaseUrl=wn,F.saveSettings=Du,F.setChatToken=Wo,F.toPlainObject=Pn,F.unwrap=Lt,F.useApi=Xr,F.useCheckpointIndex=tc,F.useFilePreview=_p,F.useHasChatSession=mw,F.useParsedMessageContent=Pp,F.useShallowStableValue=Au,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=bu,F.useThreadManagerViewState=cm,F.useThreadState=eo,F.useThreadStateUpdater=Cu,F.useThreads=xr,F.useThreadsState=uu,F.viewFileById=Bv,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=PT(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(AT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&be.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;be.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(be.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return bp(Kn.lex,qn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},gT(be.defaults),be},be.getDefaults=lp,be.defaults=cr,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=be.defaults.renderer||new ol;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=be.defaults.tokenizer||new rl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=be.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=be.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=bp(Kn.lexInline,qn.parseInline),be.Parser=qn,be.parser=qn.parse,be.Renderer=ol,be.TextRenderer=vp,be.Lexer=Kn,be.lexer=Kn.lex,be.Tokenizer=rl,be.Slugger=wp,be.Hooks=Gs,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,qn.parse,Kn.lex;function Rr({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 be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=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 yp({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 Sp({artifact:e}){const[t,n]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(de.Clock,{className:"w-4 h-4"})),[s,i]=w.useState("Processing");return w.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(de.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(de.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(de.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(de.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(de.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(Rr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(de.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function Cp({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nw(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(yp,{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 sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(sl,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="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 ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:MT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Ep({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(de.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ip({message:e,viewMode:t,isStreaming:n=!1}){const o=Ri(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Mi(l)??l:l;if(c&&typeof c=="object")return u.jsx(ul,{data:c});const d=typeof c=="string"?c:(()=>{try{return vr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Yv(l);return d?u.jsx(Rr,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(h=>h.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=Qr(m);return i(f)}const c=Zr(l),d=Qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Np({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Ap({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(Rr,{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(Qe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function jp({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:h,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:b,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:j,activeInterruptValue:M,iconForeground:L}){const H=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),B=w.useCallback(({part:N,i:z})=>{if(N.type==="text"){const $=N.text??"",R=$.trim(),P=Mi(R);return P&&b!=="tool"?u.jsx(ul,{data:P},z):b==="user"&&S&&R.length>k?u.jsx(Ap,{text:R,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},z):u.jsx(Rr,{content:$,allowHtml:!1},z)}if(N.type==="image_url"){const $=N;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"})},z)}if(N.type==="file"){const $=N,R=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,z),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[z]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[R,v[z]?" (processing)":""]})]},z)}if(N.type==="interrupt"){const $=N,R=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(j&&R&&R===j),I=P?M??($==null?void 0:$.value):$==null?void 0:$.value,V=R?{...$,id:R,interrupt_id:R}:$;return u.jsx(kp,{interruptPart:V,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},z)}return null},[f,v,g,x,b,S,k,C,E,j,M,y]),q=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!h)return H();if(!t&&!q&&!h)return null;if(t)return!n&&r?null:n?u.jsx(Ip,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const N=u.jsx("div",{className:"space-y-2",children:i.map((z,$)=>u.jsx(B,{part:z,i:$},$))});return h?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx(Np,{className:L})]}):N}return null}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(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:Xv(r),toolMeta:Ri(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=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:h=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:j=[]}){const[M,L]=w.useState(!1),[H,B]=w.useState("preview"),[q,N]=w.useState(!1),{currentThreadId:z}=xr(),{respondToInterrupt:$}=eo(),R=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",V=w.useMemo(()=>t.role==="default_message"?t:null,[t]),J=!!V,_=!(r&&P!=="user"),{uploadingFiles:O,handleFileClick:K,fileViewerOpen:Y,currentFileInfo:ae,closeFileViewer:W}=_p({allowFileOpen:_,currentThreadId:z}),D=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]),X=Pp(t,V),{contentParts:oe,imageParts:G,fileParts:Z,interruptParts:te,textContent:se,toolMeta:ue,toolRaw:ge,isToolStreaming:Re}=X,Oe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),Te=Go(Oe),nt=y==null?void 0:y.value,ht=w.useMemo(()=>V||!m?null:t.artifact||null,[V,t,m]),Tt=w.useCallback(async()=>{const ke=I?ge:se;async function et(Ae){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ae);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Le=new Blob([Ae],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Le})]);return}throw new Error("Clipboard API not supported in this context.")}try{await et(ke),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(ke)}catch(Ae){console.error("Failed to copy:",Ae)}},[I,ge,se,x]),Ke=w.useCallback(()=>{if(!v||!t.id)return;const ke=(I?ge:se)??"",et="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,ke,et)},[v,t.id,I,ge,se,t]),Ge=w.useCallback(()=>{g==null||g(n)},[g,n]),Ve=w.useCallback(()=>{const et=ne(R?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(de.User,{className:et});case"assistant":return u.jsx(de.Bot,{className:et});case"tool":return u.jsx(de.Wrench,{className:et});default:return u.jsx(de.Bot,{className:et})}},[R,D,P]),$e=w.useCallback(()=>{const ke="group relative mb-4 flex w-full";switch(P){case"user":return ne(ke,"justify-end");case"assistant":case"tool":case"system":return ne(ke,"justify-start");default:return ke}},[P]),He=w.useCallback(()=>{const ke=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",R&&"px-3 py-2 text-sm");if(J)return ne(ke,"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(ke,"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(ke,"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(ke,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(ke,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(ke,"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")}},[R,J,P]),mt=w.useCallback(async ke=>{if(b)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!0)}catch(Ae){console.error("Failed to approve interrupt:",Ae)}finally{k==null||k()}},[b,k,S,$]),Dt=w.useCallback(async ke=>{if(b)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!1)}catch(Ae){console.error("Failed to reject interrupt:",Ae)}finally{k==null||k()}},[b,k,S,$]),lt=w.useMemo(()=>V?"Assistant":Zv(t),[V,t]),kt=P==="user"&&(C??1)>1&&typeof E=="function",bt=(j==null?void 0:j.length)??0,gt=bt>0&&T<bt-1?j[T+1]:void 0,pt=bt>0&&T>0?j[T-1]:void 0,an=w.useCallback(()=>{!gt||!E||E(gt.id,void 0,!!gt.isLatestAttempt)},[gt,E]),dt=w.useCallback(()=>{!pt||!E||E(pt.id,void 0,!!pt.isLatestAttempt)},[pt,E]);return I&&!h&&!ht?null:J&&V?u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:ne("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Rr,{content:V.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",R&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ve(),a&<&&u.jsx("span",{className:ne("font-medium",R?"text-xs":"text-sm"),children:lt}),I&&u.jsxs(zh,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",R&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":H==="expanded",onClick:()=>B(ke=>ke==="expanded"?"preview":"expanded"),onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),B(et=>et==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ue.name??"Tool Output"}),ue.toolCallId&&u.jsx("span",{className:"opacity-70",children:ue.toolCallId.slice(0,8)}),H==="expanded"?u.jsx(de.ChevronUp,{className:"h-3 w-3"}):u.jsx(de.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[kt&&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",T<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=C-1||an()},"aria-label":"Older attempt (back in time)",disabled:T>=C-1,children:u.jsx(de.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-T," / ",C]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||dt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(de.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",D,R&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,R&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(de.Copy,{className:ne(M?"text-success":D,R?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,R&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(de.Edit,{className:ne(D,R?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,R&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(de.RotateCcw,{className:ne(D,R?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(jp,{message:t,isToolMessage:I,showToolMessages:h,artifactToRender:ht,toolViewMode:H,isToolStreaming:Re,contentParts:oe,textContent:se,imageParts:G,fileParts:Z,interruptParts:te,isStreamingMessage:r,defaultMessage:V,handleFileClick:K,uploadingFiles:O,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:b,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:q,setIsUserExpanded:N,isCompactLayout:R,activeInterruptId:Te,activeInterruptValue:nt,iconForeground:D}),m&&ht&&u.jsx("div",{className:"mt-3",children:u.jsx(Cp,{artifact:ht,idx:0})})]}),I&&H==="expanded"&&(ue.toolCallId||ue.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",R&&"text-xs"),children:[ue.name&&u.jsxs("div",{children:["Function: ",ue.name]}),ue.toolCallId&&u.jsxs("div",{children:["Call ID: ",ue.toolCallId]})]}),!(i||a||I)&&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",f.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",R&&"h-5 w-5"),children:u.jsx(de.Copy,{className:ne(M?"text-success":"text-current",R?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",R&&"h-5 w-5"),children:u.jsx(de.Edit,{className:ne("text-current",R?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",R&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:ne("text-current",R?"h-3 w-3":"h-4 w-4")})})]})]})}),ae&&u.jsx(ap,{isOpen:Y,onClose:W,fileId:ae.id,fileName:ae.name,mimeType:ae.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const RT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:b,onSelectCheckpoint:S}){const k=dl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,j=b??RT,M=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:H,attempts:B}=w.useMemo(()=>ec(t.id,M,j),[t.id,M,j]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:E||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:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:L,attemptIndex:H,attemptMetas:B,onSelectCheckpoint:S})})});fl.displayName="MessageRow";const hl=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:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:j,activeCheckpointId:M,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0,forceSyntheticThinking:B=!1},q)=>{const N=w.useRef(null),z=w.useRef(null),$=w.useRef(!1),R=w.useRef(!1),[P,I]=w.useState(!0),V=w.useMemo(()=>b?e.some(te=>te.role==="default_message"?!1:Array.isArray(te==null?void 0:te.content)&&te.content.some(se=>se&&se.type==="interrupt"&&(se.id??se.interrupt_id)===b.id)):!1,[b,e]),J=w.useMemo(()=>{if(!b||V)return null;const te=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let se;const ue=b.value;if(ue&&typeof ue=="object"&&!Array.isArray(ue)){const ge=ue.title;typeof ge=="string"&&ge.trim()&&(se=ge.trim())}return{id:`interrupt-${te}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:te,value:ue,title:se}]}},[b,V]),_=w.useMemo(()=>J?[...e,J]:e,[e,J]),O=w.useMemo(()=>{const te=n&&_.some(ue=>ue.id===n);return H&&(t||B)&&!te&&_.length>0?[..._,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:_},[_,t,n,H,B]),K=w.useMemo(()=>T?O:O.filter(te=>(te==null?void 0:te.role)!=="tool"),[O,T]),Y=w.useCallback(te=>{I(te),x&&x(!te),y&&y(te)},[x,y]),ae=w.useMemo(()=>{if(a)return async()=>{if(!$.current){$.current=!0;try{await a()}finally{$.current=!1}}}},[a]),W=w.useMemo(()=>!v||g?!1:P?"auto":!1,[P,v,g]),D=w.useMemo(()=>{if(typeof f!="string")return null;const te=f.trim();return!te||K&&K.length>0?null:{id:"default-message",role:"default_message",content:te,createdAt:new Date().toISOString()}},[f,K]),X=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),oe=()=>D?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:D,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),G=K.length,Z=G>0;return w.useEffect(()=>{var te,se;if(G===0){R.current=!1;return}if(!R.current)if(R.current=!0,N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[G,K.length]),w.useImperativeHandle(q,()=>({scrollToLatest:()=>{var te,se;if(N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var te,se;N.current&&K.length>0?(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[K]),u.jsx("div",{className:X,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Z?u.jsx(LC,{ref:te=>{N.current=te},scrollerRef:te=>{z.current=te instanceof HTMLDivElement?te:null},data:K,followOutput:W,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{ae&&ae()},atBottomStateChange:Y,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(te,se)=>dl(se,te),itemContent:(te,se)=>u.jsx(fl,{message:se,index:te,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:j,activeCheckpointId:M,onSelectCheckpoint:L})}):oe()})})});hl.displayName="MessageList";const Mp={value:""};function Or({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:h=!0,payloadExtras:m={},customStyles:f={},onMessageSent:v,onExcelUploadSuccess:g,onError:x}){const{api:y}=Xr(),{currentThreadId:b}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:M,checkpoints:L,interrupt:H,metadata:B,checkpointIndex:q}=eo(),{isStreaming:N,error:z,connectionState:$,submit:R,stop:P}=Li(),I=S??b??null,V=(M==null?void 0:M.id)??null,J=(M==null?void 0:M.namespace)??null,_=(B==null?void 0:B.assemblingMessageId)??null,O=H,[K,Y]=w.useState(!1),[ae,W]=w.useState(!1);w.useEffect(()=>{O||Y(!1)},[O]);const D=w.useCallback(()=>{Y(!0)},[]),X=w.useCallback(()=>{Y(!1)},[]),oe=!!O||K,[G,Z]=w.useState(null),[te,se]=w.useState(""),[ue,ge]=w.useState(null),[Re,Oe]=w.useState(null),[Te,nt]=w.useState([]),[ht,Tt]=w.useState(0),[Ke,Ge]=w.useState(0),[Ve,$e]=w.useState(!1),[He,mt]=w.useState(null),[Dt,lt]=w.useState(null),[kt,bt]=w.useState(!1),[gt,pt]=w.useState(null),an=w.useRef(!1),[dt,ke]=w.useState(()=>Mp.value),et=w.useRef(dt),Ae=w.useRef(null),Le=w.useCallback(le=>{Mp.value=le,ke(le)},[]),[Bt,re]=w.useState(!1),ye=w.useRef(null),rt=w.useRef(null),xe=w.useRef(null),Pe=w.useCallback(()=>{rt.current&&(rt.current.value=""),xe.current&&(xe.current.value=""),Tt(le=>le+1),Ge(le=>le+1)},[]),Xe=w.useCallback(le=>{Le(le)},[Le]),St=w.useRef(!1);w.useEffect(()=>{St.current&&!N&&(nt([]),Pe()),St.current=N},[N,Pe]),w.useEffect(()=>{N||W(!1)},[N]),w.useEffect(()=>{B!=null&&B.assemblingMessageId&&W(!1)},[B==null?void 0:B.assemblingMessageId]);const[Et,Nt]=w.useState("desktop");w.useEffect(()=>{const le=()=>{const Ce=window.innerWidth;Nt(Ce<640?"phone":Ce<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),w.useEffect(()=>{an.current=!1},[I]),w.useEffect(()=>{et.current=dt},[dt]),w.useEffect(()=>{if(!G){Ae.current=null;return}Ae.current===null&&(Ae.current=et.current),Le(te??"")},[te,G,Le]),w.useEffect(()=>{(async()=>{if(!y.baseUrl){pt(null);return}try{const we=(await y.getAgent("default")).uiDefaultMessage||"";pt(we||null)}catch(Ce){console.warn("Failed to fetch default message:",Ce),pt(null)}})()},[y.baseUrl]),w.useEffect(()=>{z&&!kt&&(x==null||x(z))},[z,kt,x]);const zt=async le=>{const Ce=le.trim();if(!(!Ce&&Te.length===0))try{const we=G?(ue==null?void 0:ue.checkpointId)??V??void 0:V??void 0,ze=G?(ue==null?void 0:ue.checkpointNs)??J??void 0:J??void 0;await R({text:Ce||"",attachments:Te,payload:m},{checkpointId:we,checkpointNs:ze,edit:!!G,originalMessageId:G??void 0}),v==null||v(Ce),W(!0),Le(""),Oe(null),nt([]),Pe(),Z(null),se(""),ge(null)}catch(we){const ze=(we==null?void 0:we.message)||"Failed to send message";Oe(ze),x==null||x(ze),W(!1)}},_e=w.useCallback((le,Ce,we)=>{c&&(Ae.current=dt,Z(le),se(Ce),Le(Ce),Oe(null),ge({checkpointId:(we==null?void 0:we.checkpointId)??null,checkpointNs:(we==null?void 0:we.checkpointNs)??null}))},[dt,c,Le]),ct=w.useCallback(()=>{Z(null),se(""),ge(null),Oe(null),Le(Ae.current??dt),Ae.current=null},[dt,Le]),Je=w.useCallback((le,Ce,we)=>{_e(le,Ce,we)},[_e]),ft=w.useCallback(le=>{let Ce=null;for(let jt=le-1;jt>=0;jt--)if(k[jt].role==="user"){Ce=k[jt];break}if(!Ce)return;const we=Array.isArray(Ce.content)?Ce.content:[],At=we.filter(jt=>(jt==null?void 0:jt.type)==="text").map(jt=>jt.text).join("")||(()=>{try{return JSON.stringify(we,null,2)}catch{return String(we)}})();At&&R({text:At,payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0,edit:!0,originalMessageId:Ce.id})},[k,R,V,J,m]),ln=le=>{const Ce=Array.from(le.target.files||[]);nt(we=>[...we,...Ce]),le.target.value=""},A=le=>{nt(Ce=>{const we=Ce.filter((ze,At)=>le!==At);return we.length===0&&Pe(),we})},Q=async le=>{const Ce=(le.target.files||[])[0];if(Ce){mt(null),lt(null),$e(!0);try{await R({attachments:[Ce],payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0});const we=`Uploaded ${Ce.name} - processing through chat stream`;lt(we)}catch(we){const ze=we instanceof Error?we.message:"Failed to upload Excel file";console.error("Excel upload failed",we),mt(ze),x==null||x(ze)}finally{$e(!1),le.target.value="",Pe()}}},fe=async le=>{if(b){re(!0);try{if(!le){await j(),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToLatest()});return}const Ce=L.find(ze=>ze.checkpointId===le),we=(Ce==null?void 0:Ce.checkpointNs)??null;await E(le,we),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToTop()})}finally{re(!1)}}},Ie=w.useCallback(async(le,Ce,we)=>{await fe(we?null:le)},[fe]),Ye=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,tt=`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 ${f.messagesArea||""}`,Ue=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return u.jsxs("div",{className:Ye,children:[!!z&&!kt&&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:z}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>bt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${tt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:ye,className:"h-full",style:{height:"100%"},messages:k,isStreaming:N,streamingAssistantId:_,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Et,enableMessageEditing:c,editingMessageId:G,onEdit:Je,onRegenerate:ft,onCancelEdit:ct,emptyMessage:gt??void 0,isNavigatingCheckpoint:Bt,activeInterrupt:O,disableInterruptActions:K,onInterruptActionStart:D,onInterruptActionEnd:X,showToolMessages:d,showArtifactPreviews:h,checkpointIndex:q,activeCheckpointId:V,onSelectCheckpoint:Ie,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae}),($==="reconnecting"||$==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),$==="reconnecting"?"Reconnecting…":"Connecting…"]})}),$==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||Bt)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Ue,children:[G&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:ct,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:rt,type:"file",multiple:!0,onChange:le=>ln(le),className:"hidden"},ht),Te.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Te.map((le,Ce)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>A(Ce),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 ${le.name}`,children:u.jsx(de.X,{size:12})})]},Ce))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:xe,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Q,className:"hidden"},Ke),Ve&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Dt&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Dt}),He&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:He})]})]}),Re&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Re}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:N||oe,title:"More input actions",className:f.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(zn,{onClick:()=>{var le;return(le=rt.current)==null?void 0:le.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(zn,{onClick:()=>{var le;Ve||(le=xe.current)==null||le.click()},className:`cursor-pointer ${Ve?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(IS,{initialValue:te,editingMessageId:G,value:dt,onValueChange:Xe,placeholder:G?"Edit your message...":t,isStreaming:N,disabled:oe,onSend:zt,onCancelEdit:ct,onStop:P,allowEmptySend:Te.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${G?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Re?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}var Rp=1,OT=.9,DT=.8,LT=.17,pl=.1,ml=.999,$T=.9999,FT=.99,BT=/[\\\/_+.#"@\[\(\{&]/,zT=/[\\\/_+.#"@\[\(\{&]/g,HT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Rp:FT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=gl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Rp:BT.test(e.charAt(c-1))?(h*=DT,f=e.slice(o,c-1).match(zT),f&&o>0&&(h*=Math.pow(ml,f.length))):HT.test(e.charAt(c-1))?(h*=OT,v=e.slice(o,c-1).match(Op),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=LT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=$T)),(h<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>h&&(h=m*pl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Dp(e){return e.toLowerCase().replace(Op," ")}function UT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',WT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Dr="data-value",VT=(e,t,n)=>UT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),wl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Lr(()=>{var _,O;return{search:"",value:(O=(_=e.value)!=null?_:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=Pt(),S=Pt(),k=Pt(),C=p.useRef(null),T=nk();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,q)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,O,K)=>{var Y,ae,W,D;if(!Object.is(n.current[_],O)){if(n.current[_]=O,_==="search")B(),L(),T(1,H);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Y=document.getElementById(b))==null||Y.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=N())==null?void 0:X.id,E.emit()}),K||T(5,q),((ae=a.current)==null?void 0:ae.value)!==void 0){let X=O??"";(D=(W=a.current).onValueChange)==null||D.call(W,X);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=p.useMemo(()=>({value:(_,O,K)=>{var Y;O!==((Y=s.current.get(_))==null?void 0:Y.value)&&(s.current.set(_,{value:O,keywords:K}),n.current.filtered.items.set(_,M(O,K)),T(2,()=>{L(),E.emit()}))},item:(_,O)=>(r.current.add(_),O&&(o.current.has(O)?o.current.get(O).add(_):o.current.set(O,new Set([_]))),T(3,()=>{B(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let K=N();T(4,()=>{B(),(K==null?void 0:K.getAttribute("id"))===_&&H(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:S,listInnerRef:C}),[]);function M(_,O){var K,Y;let ae=(Y=(K=a.current)==null?void 0:K.filter)!=null?Y:VT;return _?ae(_,n.current.search,O):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(Y=>{let ae=o.current.get(Y),W=0;ae.forEach(D=>{let X=_.get(D);W=Math.max(X,W)}),O.push([Y,W])});let K=C.current;z().sort((Y,ae)=>{var W,D;let X=Y.getAttribute("id"),oe=ae.getAttribute("id");return((W=_.get(oe))!=null?W:0)-((D=_.get(X))!=null?D:0)}).forEach(Y=>{let ae=Y.closest(xl);ae?ae.appendChild(Y.parentElement===ae?Y:Y.closest(`${xl} > *`)):K.appendChild(Y.parentElement===K?Y:Y.closest(`${xl} > *`))}),O.sort((Y,ae)=>ae[1]-Y[1]).forEach(Y=>{var ae;let W=(ae=C.current)==null?void 0:ae.querySelector(`${Io}[${Dr}="${encodeURIComponent(Y[0])}"]`);W==null||W.parentElement.appendChild(W)})}function H(){let _=z().find(K=>K.getAttribute("aria-disabled")!=="true"),O=_==null?void 0:_.getAttribute(Dr);E.setState("value",O||void 0)}function B(){var _,O,K,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ae=0;for(let W of r.current){let D=(O=(_=s.current.get(W))==null?void 0:_.value)!=null?O:"",X=(Y=(K=s.current.get(W))==null?void 0:K.keywords)!=null?Y:[],oe=M(D,X);n.current.filtered.items.set(W,oe),oe>0&&ae++}for(let[W,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=ae}function q(){var _,O,K;let Y=N();Y&&(((_=Y.parentElement)==null?void 0:_.firstChild)===Y&&((K=(O=Y.closest(Io))==null?void 0:O.querySelector(WT))==null||K.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function N(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Lp}[aria-selected="true"]`)}function z(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll($p))||[])}function $(_){let O=z()[_];O&&E.setState("value",O.getAttribute(Dr))}function R(_){var O;let K=N(),Y=z(),ae=Y.findIndex(D=>D===K),W=Y[ae+_];(O=a.current)!=null&&O.loop&&(W=ae+_<0?Y[Y.length-1]:ae+_===Y.length?Y[0]:Y[ae+_]),W&&E.setState("value",W.getAttribute(Dr))}function P(_){let O=N(),K=O==null?void 0:O.closest(Io),Y;for(;K&&!Y;)K=_>0?ek(K,Io):tk(K,Io),Y=K==null?void 0:K.querySelector($p);Y?E.setState("value",Y.getAttribute(Dr)):R(_)}let I=()=>$(z().length-1),V=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):R(1)},J=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):R(-1)};return p.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var O;(O=y.onKeyDown)==null||O.call(y,_);let K=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||K))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&V(_);break}case"ArrowDown":{V(_);break}case"p":case"k":{x&&_.ctrlKey&&J(_);break}case"ArrowUp":{J(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let Y=N();if(Y){let ae=new Event(vl);Y.dispatchEvent(ae)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:ok},l),Xs(e,_=>p.createElement(Bp.Provider,{value:E},p.createElement(Fp.Provider,{value:j},_))))}),KT=p.forwardRef((e,t)=>{var n,r;let o=Pt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(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=Wp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:S,keywords:k,...C}=e;return p.createElement(me.div,{ref:Dn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),qT=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=p.useRef(null),l=p.useRef(null),c=Pt(),d=No(),h=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(me.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(zp.Provider,{value:m},f))))}),GT=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:p.createElement(me.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),YT=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.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)}})}),XT=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Gn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(me.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),JT=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Hp,{ref:t,...a}))))}),ZT=p.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?p.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),QT=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Hp,{List:XT,Item:KT,Input:YT,Group:qT,Separator:GT,Dialog:JT,Empty:ZT,Loading:QT});function ek(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Lr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Dr,a),o.current=a}),o}var nk=()=>{let[e,t]=p.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function rk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(rk(t),{ref:t.ref},n(t.props.children)):n(t)}var ok={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const bl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));bl.displayName=Kt.displayName;const yl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.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})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));Tl.displayName=Kt.Group.displayName;const sk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));sk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function ik(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,CN]=un(Il),[ak,sn]=Vp(Il),Kp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,j]=p.useState(!1),M=Fe(t,H=>l(H)),L=Xo(o);return u.jsx(ak,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(me.div,{dir:L,...i,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=Fe(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})})]})});Gp.displayName=qp;var Nn="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(lk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(ck,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=Nn;var lk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),ck=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=ik("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(Nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(Nn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=em(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 h(m,f){return mk(m,i.current,a,f)}return n==="horizontal"?u.jsx(uk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=tm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(dk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=tm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),uk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Fe(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),dk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Fe(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[fk,Xp]=Vp(Nn),Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=sn(Nn,n),[v,g]=p.useState(null),x=Fe(t,M=>g(M)),y=p.useRef(null),b=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=vt(d),T=vt(l),E=ei(h,10);function j(M){if(y.current){const L=M.clientX-y.current.left,H=M.clientY-y.current.top;c({x:L,y:H})}}return p.useEffect(()=>{const M=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&C(L,k)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(fk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:vt(s),onThumbPointerUp:vt(i),onThumbPositionChange:T,onThumbPointerDown:vt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(M))}),onPointerMove:ce(e.onPointerMove,j),onPointerUp:ce(e.onPointerUp,M=>{const L=M.target;L.hasPointerCapture(M.pointerId)&&L.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(hk,{ref:t,...r})})}),hk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=Fe(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=gk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.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:ce(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(pk,{...e,ref:t}):null});Qp.displayName=jl;var pk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(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 Zs(e){return e?parseInt(e,10):0}function em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(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=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return nm([l,c],h)(e)}function tm(e,t,n="ltr"){const r=Qs(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=El(e,l);return nm([0,i],[0,a])(c)}function nm(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 rm(e,t){return e>0&&e<t}var gk=(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 ei(e,t){const n=vt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function $r(e,t){const n=vt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var om=Kp,xk=Gp,vk=Qp;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(xk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(vk,{})]}));_l.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{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(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const Pl=p.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}));Pl.displayName="Input";const wk="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",yk="bg-slate-600 border-slate-500";function im({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,S=t?`${y??yk}`:`${x??bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${wk} ${S}`,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:C=>C.stopPropagation(),children:[u.jsx(Pl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(de.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(zn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(zn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(zn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(de.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const am=25,lm="thread-manager-view",Sk=e=>e==="default"||e==="shared",Ck=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(Sk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=w.useState(()=>Ck()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Tk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:M,actions:L,shareInFlight:H,shareStatus:B,clearShareStatus:q}=xr(),{createThread:N,deleteThread:z,renameThread:$,shareThread:R}=L,{loadThread:P}=eo(),I=i??T,[V,J]=w.useState(Array.isArray(k)?k:[]),_=w.useRef(V.length>0),O=w.useRef(null),K=w.useRef(0),[Y,ae]=w.useState(null),[W,D]=w.useState(""),[X,oe]=w.useState(!1),[G,Z]=w.useState(!1),[te,se]=w.useState(null),[ue,ge]=w.useState(""),Re=v&&v.length>0?v:Tk,Oe=cm({defaultView:m}),Te=g??Oe,nt=h??Te.view,ht=w.useCallback(re=>{h||Te.setView(re),f==null||f(re)},[h,f,Te]),Tt=Re.find(re=>re.key===nt)??Re[0],Ke=re=>{se(re),ge(""),Z(!0)},Ge=()=>{Z(!1),se(null),ge(""),q()},Ve=w.useCallback(async re=>{if(!(!te||H)&&re.id)try{await R(te,re.id),setTimeout(()=>Ge(),600)}catch(ye){console.error("Failed to share thread:",ye)}},[Ge,H,te,R]),$e=w.useMemo(()=>{const re=y??[],ye=ue.trim().toLowerCase();return ye?S?re.filter(rt=>S(rt,ye)):re.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ye)):re},[y,ue,S]),He=nt==="shared",mt=He?C:V,Dt=He?M:j,lt=He?"No shared conversations yet":"No conversations yet",kt=re=>{const ye=re.sharedAt?` • ${Ae(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${ye}`},bt=re=>"sharedByUserId"in re;w.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,J(re);return}j||(_.current=!1,J(re))},[k,j]),w.useEffect(()=>{if(!O.current)return;const re=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let ye=null,rt=null;return ye=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{re.scrollTop=K.current})}),()=>{ye!==null&&cancelAnimationFrame(ye),rt!==null&&cancelAnimationFrame(rt)}},[V]);const gt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(ye){console.error("Failed to select thread:",ye)}},pt=async()=>{try{oe(!0);const re=await N();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{oe(!1)}},an=async(re,ye)=>{if(ye.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const rt=O.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(K.current=rt.scrollTop)}try{await z(re),d==null||d(re)}catch(rt){console.error("Failed to delete thread:",rt)}}},dt=(re,ye)=>{ye.stopPropagation(),ae(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},ke=async re=>{if(W.trim())try{await $(re,W.trim()),ae(null),D("")}catch(ye){console.error("Failed to update title:",ye)}},et=()=>{ae(null),D("")},Ae=re=>{if(!re)return"";try{const ye=new Date(re),xe=new Date().getTime()-ye.getTime(),Pe=Math.floor(xe/(1e3*60*60*24));return Pe===0?ye.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:ye.toLocaleDateString()}catch{return""}},Le=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,Bt=re=>{const ye=Le(re);return ye.length<=am?ye:`${ye.slice(0,am)}...`};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(Qe,{onClick:pt,disabled:X||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(de.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:Tt.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Re.map(re=>u.jsxs(zn,{className:"justify-between text-[12px]",onClick:ye=>{ye.preventDefault(),ht(re.key)},children:[u.jsx("span",{children:re.label}),nt===re.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(_l,{ref:O,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Dt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):mt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:lt})]}):mt.slice().sort((re,ye)=>new Date(ye.updatedAt||ye.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(im,{thread:re,isActive:I===re.threadId,editingThreadId:Y,editingTitle:W,onSelect:gt,onStartEditing:dt,onEditingTitleChange:ye=>D(ye),onSaveEditing:ke,onCancelEditing:et,onShare:()=>Ke(re.threadId),onDelete:an,showEditTitle:r,showDeleteButton:n,formatDate:Ae,getDisplayThreadTitle:Bt,secondaryLine:He&&bt(re)?kt(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:G,onOpenChange:re=>!re&&Ge(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(bl,{children:[u.jsx(yl,{autoFocus:!0,value:ue,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[B&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:B.startsWith("Failed")?"text-red-500":B.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:B})]}),u.jsx(Cl,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),$e.length>0&&u.jsx(Tl,{heading:"Recipients",children:$e.map(re=>u.jsx(kl,{onSelect:()=>Ve(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.id))})]})]})]})})]})}function kk({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(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(wr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(wr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Ek({apiConfig:e,className:t="",onError:n}){return u.jsx(wr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function Ik({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(de.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Nk({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(wr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(de.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(de.Edit3,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(de.Maximize2,{size:14}):u.jsx(de.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Ik,{placeholder:t,onMessageSent:r})})]})})}):null}function Ak({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{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(de.Edit3,{size:16}),t??e]})}var jk="Label",um=p.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())}}));um.displayName=jk;var dm=um;const _k=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:ne(_k(),e),...t}));fm.displayName=dm.displayName;function hm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pm=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"}),Pk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Pk;var Mk=ni,Rk=[" ","Enter","ArrowUp","ArrowDown"],Ok=[" ","Enter"],dr="Select",[ri,oi,Dk]=Yo(dr),[Fr,TN]=un(dr,[Dk,Er]),si=Er(),[Lk,Yn]=Fr(dr),[$k,Fk]=Fr(dr),mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=p.useState(null),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[E,j]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[M,L]=Ln({prop:i,defaultProp:a,onChange:l,caller:dr}),H=p.useRef(null),B=x?v||!!x.closest("form"):!0,[q,N]=p.useState(new Set),z=Array.from(q).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Lk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:M,onValueChange:L,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx($k,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback($=>{N(R=>new Set(R).add($))},[]),onNativeOptionRemove:p.useCallback($=>{N(R=>{const P=new Set(R);return P.delete($),P})},[]),children:n})}),B?u.jsxs(Fm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:M,onChange:$=>L($.target.value),disabled:m,form:v,children:[M===void 0?u.jsx("option",{value:""}):null,Array.from(q)]},z):null]})})};mm.displayName=dr;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Yn(gm,n),a=i.disabled||r,l=Fe(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Hm(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sa,{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":Bm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(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:ce(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Rk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Fe(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:h,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=vm;var Bk="SelectIcon",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});bm.displayName=Bk;var zk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=zk;var fr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=p.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=fr;var gn=10,[Cm,Xn]=Fr(fr),Hk="SelectContentImpl",Uk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=Yn(fr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=Fe(t,W=>k(W)),[j,M]=p.useState(null),[L,H]=p.useState(null),B=oi(n),[q,N]=p.useState(!1),z=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=p.useCallback(W=>{const[D,...X]=B().map(Z=>Z.ref.current),[oe]=X.slice(-1),G=document.activeElement;for(const Z of W)if(Z===G||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===D&&C&&(C.scrollTop=0),Z===oe&&C&&(C.scrollTop=C.scrollHeight),Z==null||Z.focus(),document.activeElement!==G))return},[B,C]),R=p.useCallback(()=>$([j,S]),[$,j,S]);p.useEffect(()=>{q&&R()},[q,R]);const{onOpenChange:P,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(S){let W={x:0,y:0};const D=oe=>{var G,Z;W={x:Math.abs(Math.round(oe.pageX)-(((G=I.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(oe.pageY)-(((Z=I.current)==null?void 0:Z.y)??0))}},X=oe=>{W.x<=10&&W.y<=10?oe.preventDefault():S.contains(oe.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,I]),p.useEffect(()=>{const W=()=>P(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[P]);const[V,J]=zm(W=>{const D=B().filter(G=>!G.disabled),X=D.find(G=>G.ref.current===document.activeElement),oe=Hm(D,W,X);oe&&setTimeout(()=>oe.ref.current.focus())}),_=p.useCallback((W,D,X)=>{const oe=!z.current&&!X;(b.value!==void 0&&b.value===D||oe)&&(M(W),oe&&(z.current=!0))},[b.value]),O=p.useCallback(()=>S==null?void 0:S.focus(),[S]),K=p.useCallback((W,D,X)=>{const oe=!z.current&&!X;(b.value!==void 0&&b.value===D||oe)&&H(W)},[b.value]),Y=r==="popper"?Ml:km,ae=Y===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:j,onItemLeave:O,itemTextRefCallback:K,focusSelectedItem:R,selectedItemText:L,position:r,isPositioned:q,searchRef:V,children:u.jsx(gs,{as:Uk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:b.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ce(o,W=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(Y,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:W=>W.preventDefault(),...y,...ae,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,W=>{const D=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!D&&W.key.length===1&&J(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let oe=B().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(W.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const G=W.target,Z=oe.indexOf(G);oe=oe.slice(Z+1)}setTimeout(()=>$(oe)),W.preventDefault()}})})})})})})});Tm.displayName=Hk;var Wk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=Fe(t,E=>d(E)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const G=L.left-j.left,Z=M.left-G,te=E.left-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Re=El(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.left=Re+"px"}else{const G=j.right-L.right,Z=window.innerWidth-M.right-G,te=window.innerWidth-E.right-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Re=El(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.right=Re+"px"}const H=m(),B=window.innerHeight-gn*2,q=g.scrollHeight,N=window.getComputedStyle(c),z=parseInt(N.borderTopWidth,10),$=parseInt(N.paddingTop,10),R=parseInt(N.borderBottomWidth,10),P=parseInt(N.paddingBottom,10),I=z+$+q+P+R,V=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),_=parseInt(J.paddingTop,10),O=parseInt(J.paddingBottom,10),K=E.top+E.height/2-gn,Y=B-K,ae=x.offsetHeight/2,W=x.offsetTop+ae,D=z+$+W,X=I-D;if(D<=K){const G=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const Z=c.clientHeight-g.offsetTop-g.offsetHeight,te=Math.max(Y,ae+(G?O:0)+Z+R),se=D+te;a.style.height=se+"px"}else{const G=H.length>0&&x===H[0].ref.current;a.style.top="0px";const te=Math.max(K,z+g.offsetTop+(G?_:0)+ae)+X;a.style.height=te+"px",g.scrollTop=D-K+g.offsetTop}a.style.margin=`${gn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=p.useState();It(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Kk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(me.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Wk;var Vk="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=gn,...s}=e,i=si(n);return u.jsx(ia,{...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)"}})});Ml.displayName=Vk;var[Kk,Rl]=Fr(fr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Ol,n),i=Rl(Ol,n),a=Fe(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.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:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-gn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Em.displayName=Ol;var Im="SelectGroup",[qk,Gk]=Fr(Im),Yk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(qk,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Yk.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gk(Nm,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[Xk,jm]=Fr(ii),_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ii,n),l=Xn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=Fe(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=Pt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Xk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ri.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:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ce(i.onPointerMove,b=>{var S;x.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Ok.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});_m.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(Ao,n),a=Xn(Ao,n),l=jm(Ao,n),c=Fk(Ao,n),[d,h]=p.useState(null),m=Fe(t,y=>h(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(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?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var Mm="SelectItemIndicator",Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Mm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Rm.displayName=Mm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Xn(Dl,e.__scopeSelect),r=Rl(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Rl(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),Jk="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=Jk;var $l="SelectArrow",Zk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Yn($l,n),i=Xn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});Zk.displayName=$l;var Qk="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Fe(r,o),i=hm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(me.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=Qk;function Bm(e){return e===""||e===void 0}function zm(e){const t=vt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hm(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=eE(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 eE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tE=mm,Um=xm,nE=wm,rE=bm,oE=ym,Wm=Sm,sE=Em,Vm=Am,Km=_m,iE=Pm,aE=Rm,qm=Om,Gm=Dm,Ym=$m;const lE=tE,cE=nE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{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(rE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.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(de.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(oE,{children:u.jsxs(Wm,{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(Jm,{}),u.jsx(sE,{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(Zm,{})]})}));Qm.displayName=Wm.displayName;const uE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));uE.displayName=Vm.displayName;const eg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{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(aE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(iE,{children:t})]}));eg.displayName=Km.displayName;const dE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));dE.displayName=Ym.displayName;var fE="Separator",tg="horizontal",hE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=pE(r)?r:tg,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})});ng.displayName=fE;function pE(e){return hE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[mE,kN]=un(ai),[gE,xE]=mE(ai),sg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=Fe(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=Ln({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(gE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ce(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=xE(ig,n);return u.jsx(me.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var vE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Fe(i,s),l=hm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lg.displayName=vE;function cg(e){return e?"checked":"unchecked"}var ug=sg,wE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{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(wE,{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")})}));dg.displayName=ug.displayName;const bE=Ja,yE=lT,SE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));fg.displayName=To.displayName;const CE=zr.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"}}),hg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(SE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:ne(CE({side:e}),t),...r,children:[n,u.jsxs(op,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));mg.displayName=lr.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,EN]=un("Tooltip",[Er]),ci=Er(),xg="TooltipProvider",TE=700,Fl="tooltip.open",[kE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=TE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(kE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};vg.displayName=xg;var jo="Tooltip",[EE,ui]=li(jo),wg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=Pt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,b]=Ln({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(E)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(EE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};wg.displayName=jo;var zl="TooltipTrigger",bg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=Fe(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});bg.displayName=zl;var IE="TooltipPortal",[IN,NE]=li(IE,{forceMount:void 0}),Br="TooltipContent",yg=p.forwardRef((e,t)=>{const n=NE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Br,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(AE,{side:o,...s,ref:t})})}),AE=p.forwardRef((e,t)=>{const n=ui(Br,e.__scopeTooltip),r=Bl(Br,e.__scopeTooltip),o=p.useRef(null),s=Fe(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=RE(y,x.getBoundingClientRect()),S=OE(y,b),k=DE(g.getBoundingClientRect()),C=$E([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.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)),S=!LE(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[jE,_E]=li(jo,{isInside:!1}),PE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Br,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"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(PE,{children:r}),u.jsx(jE,{scope:n,isInside:!0,children:u.jsx(Mk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Br;var Cg="TooltipArrow",ME=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return _E(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});ME.displayName=Cg;function RE(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 OE(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 DE(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 LE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $E(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),FE(t)}function FE(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 BE=vg,zE=wg,HE=bg,Tg=yg;const UE=BE,WE=zE,VE=HE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{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}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,KE,qE]=Yo("Toast"),[Eg,NN]=un("Toast",[qE]),[GE,di]=Eg(Hl),Ig=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(GE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};Ig.displayName=Hl;var Ng="ToastViewport",YE=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=YE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=KE(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=Fe(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,C=[k,...lI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var C,T,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const j=document.activeElement,M=b.shiftKey;if(b.target===x&&M){(C=c.current)==null||C.focus();return}const B=g({tabbingDirection:M?"backwards":"forwards"}),q=B.findIndex(N=>N===j);Gl(B.slice(q+1))?b.preventDefault():M?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Dw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=jg;var _o="Toast",XE="toast.swipeStart",JE="toast.swipeMove",ZE="toast.swipeCancel",QE="toast.swipeEnd",_g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Ln({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(nI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:vt(e.onPause),onResume:vt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ce(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:ce(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});_g.displayName=_o;var[eI,tI]=Eg(_o,{onClose(){}}),nI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=p.useState(null),b=Fe(t,N=>y(N)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),j=p.useRef(0),{onToastAdd:M,onToastRemove:L}=g,H=vt(()=>{var z;(x==null?void 0:x.contains(document.activeElement))&&((z=g.viewport)==null||z.focus()),i()}),B=p.useCallback(N=>{!N||N===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(H,N))},[H]);p.useEffect(()=>{const N=g.viewport;if(N){const z=()=>{B(E.current),c==null||c()},$=()=>{const R=new Date().getTime()-T.current;E.current=E.current-R,window.clearTimeout(j.current),l==null||l()};return N.addEventListener(Wl,$),N.addEventListener(Vl,z),()=>{N.removeEventListener(Wl,$),N.removeEventListener(Vl,z)}}},[g.viewport,C,l,c,B]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(C)},[s,C,g.isClosePausedRef,B]),p.useEffect(()=>(M(),()=>L()),[M,L]);const q=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[q&&u.jsx(rI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:q}),u.jsx(eI,{scope:n,onClose:H,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ow,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),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:ce(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ce(e.onPointerDown,N=>{N.button===0&&(S.current={x:N.clientX,y:N.clientY})}),onPointerMove:ce(e.onPointerMove,N=>{if(!S.current)return;const z=N.clientX-S.current.x,$=N.clientY-S.current.y,R=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,V=P?I(0,z):0,J=P?0:I(0,$),_=N.pointerType==="touch"?10:2,O={x:V,y:J},K={originalEvent:N,delta:O};R?(k.current=O,fi(JE,h,K,{discrete:!1})):Fg(O,g.swipeDirection,_)?(k.current=O,fi(XE,d,K,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(z)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,N=>{const z=k.current,$=N.target;if($.hasPointerCapture(N.pointerId)&&$.releasePointerCapture(N.pointerId),k.current=null,S.current=null,z){const R=N.currentTarget,P={originalEvent:N,delta:z};Fg(z,g.swipeDirection,g.swipeThreshold)?fi(QE,f,P,{discrete:!0}):fi(ZE,m,P,{discrete:!0}),R.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),rI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return iI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},oI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Pg.displayName=oI;var sI="ToastDescription",Mg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Mg.displayName=sI;var Rg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Rg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Rg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=tI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.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 $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),aI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...$g(r))}}),t}function fi(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?Fi(o,s):o.dispatchEvent(s)}var Fg=(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 iI(e=()=>{}){const t=vt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function aI(e){return e.nodeType===e.ELEMENT_NODE}function lI(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 Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var cI=Ig,Bg=Ag,zg=_g,Hg=Pg,Ug=Mg,Wg=Og,Vg=ql;const uI=cI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{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}));Kg.displayName=Bg.displayName;const dI=zr.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=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:ne(dI({variant:t}),e),...n}));qg.displayName=zg.displayName;const fI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{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}));fI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{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(de.X,{className:"h-4 w-4"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:ne("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:ne("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function hI(){const{toasts:e}=nl();return u.jsxs(uI,{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(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var pI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},mI=p.createContext(void 0),gI={setTheme:e=>{},themes:[]},xI=()=>{var e;return(e=p.useContext(mI))!=null?e:gI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${pI.toString()})(${d})`}})});var vI=e=>{switch(e){case"success":return yI;case"info":return CI;case"warning":return SI;case"error":return TI;default:return null}},wI=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"},wI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),yI=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"})),SI=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"})),CI=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"})),TI=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"})),kI=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"})),EI=()=>{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},Yl=1,II=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:Yl++,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(AI(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)||Yl++;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}},qt=new II,NI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.addToast({title:e,...t,id:n}),n},AI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jI=NI,_I=()=>qt.toasts,PI=()=>qt.getActiveToasts();Object.assign(jI,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:_I,getToasts:PI});function MI(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))}MI(`: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%)}
|
|
130
|
+
`);function hi(e){return e.label!==void 0}var RI=3,OI="32px",DI="16px",Jg=4e3,LI=356,$I=14,FI=20,BI=200;function xn(...e){return e.filter(Boolean).join(" ")}function zI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var HI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:M,cancelButtonStyle:L,actionButtonStyle:H,className:B="",descriptionClassName:q="",duration:N,position:z,gap:$,loadingIcon:R,expandByDefault:P,classNames:I,icons:V,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:_}=e,[O,K]=w.useState(null),[Y,ae]=w.useState(null),[W,D]=w.useState(!1),[X,oe]=w.useState(!1),[G,Z]=w.useState(!1),[te,se]=w.useState(!1),[ue,ge]=w.useState(!1),[Re,Oe]=w.useState(0),[Te,nt]=w.useState(0),ht=w.useRef(f.duration||N||Jg),Tt=w.useRef(null),Ke=w.useRef(null),Ge=S===0,Ve=S+1<=y,$e=f.type,He=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",lt=w.useMemo(()=>b.findIndex(xe=>xe.toastId===f.id)||0,[b,f.id]),kt=w.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:j},[f.closeButton,j]),bt=w.useMemo(()=>f.duration||N||Jg,[f.duration,N]),gt=w.useRef(0),pt=w.useRef(0),an=w.useRef(0),dt=w.useRef(null),[ke,et]=z.split("-"),Ae=w.useMemo(()=>b.reduce((xe,Pe,Xe)=>Xe>=lt?xe:xe+Pe.height,0),[b,lt]),Le=EI(),Bt=f.invert||m,re=$e==="loading";pt.current=w.useMemo(()=>lt*$+Ae,[lt,Ae]),w.useEffect(()=>{ht.current=bt},[bt]),w.useEffect(()=>{D(!0)},[]),w.useEffect(()=>{let xe=Ke.current;if(xe){let Pe=xe.getBoundingClientRect().height;return nt(Pe),x(Xe=>[{toastId:f.id,height:Pe,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(St=>St.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!W)return;let xe=Ke.current,Pe=xe.style.height;xe.style.height="auto";let Xe=xe.getBoundingClientRect().height;xe.style.height=Pe,nt(Xe),x(St=>St.find(Et=>Et.toastId===f.id)?St.map(Et=>Et.toastId===f.id?{...Et,height:Xe}:Et):[{toastId:f.id,height:Xe,position:f.position},...St])},[W,f.title,f.description,x,f.id]);let ye=w.useCallback(()=>{oe(!0),Oe(pt.current),x(xe=>xe.filter(Pe=>Pe.toastId!==f.id)),setTimeout(()=>{T(f)},BI)},[f,T,x,pt]);w.useEffect(()=>{if(f.promise&&$e==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Le?(()=>{if(an.current<gt.current){let Pe=new Date().getTime()-gt.current;ht.current=ht.current-Pe}an.current=new Date().getTime()})():ht.current!==1/0&&(gt.current=new Date().getTime(),xe=setTimeout(()=>{var Pe;(Pe=f.onAutoClose)==null||Pe.call(f,f),ye()},ht.current)),()=>clearTimeout(xe)},[C,g,f,$e,_,Le,ye]),w.useEffect(()=>{f.delete&&ye()},[ye,f.delete]);function rt(){var xe,Pe,Xe;return V!=null&&V.loading?w.createElement("div",{className:xn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":$e==="loading"},V.loading):R?w.createElement("div",{className:xn(I==null?void 0:I.loader,(Pe=f==null?void 0:f.classNames)==null?void 0:Pe.loader,"sonner-loader"),"data-visible":$e==="loading"},R):w.createElement(bI,{className:xn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:$e==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ke,className:xn(B,mt,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[$e],(n=f==null?void 0:f.classNames)==null?void 0:n[$e]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":X,"data-visible":Ve,"data-y-position":ke,"data-x-position":et,"data-index":S,"data-front":Ge,"data-swiping":G,"data-dismissible":He,"data-type":$e,"data-invert":Bt,"data-swipe-out":te,"data-swipe-direction":Y,"data-expanded":!!(C||P&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Re:pt.current}px`,"--initial-height":P?"auto":`${Te}px`,...M,...f.style},onDragEnd:()=>{Z(!1),K(null),dt.current=null},onPointerDown:xe=>{re||!He||(Tt.current=new Date,Oe(pt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(Z(!0),dt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Pe,Xe,St;if(te||!He)return;dt.current=null;let Et=Number(((xe=Ke.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((Pe=Ke.current)==null?void 0:Pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),zt=new Date().getTime()-((Xe=Tt.current)==null?void 0:Xe.getTime()),_e=O==="x"?Et:Nt,ct=Math.abs(_e)/zt;if(Math.abs(_e)>=FI||ct>.11){Oe(pt.current),(St=f.onDismiss)==null||St.call(f,f),ae(O==="x"?Et>0?"right":"left":Nt>0?"down":"up"),ye(),se(!0),ge(!1);return}Z(!1),K(null)},onPointerMove:xe=>{var Pe,Xe,St,Et;if(!dt.current||!He||((Pe=window.getSelection())==null?void 0:Pe.toString().length)>0)return;let Nt=xe.clientY-dt.current.y,zt=xe.clientX-dt.current.x,_e=(Xe=e.swipeDirections)!=null?Xe:zI(z);!O&&(Math.abs(zt)>1||Math.abs(Nt)>1)&&K(Math.abs(zt)>Math.abs(Nt)?"x":"y");let ct={x:0,y:0};O==="y"?(_e.includes("top")||_e.includes("bottom"))&&(_e.includes("top")&&Nt<0||_e.includes("bottom")&&Nt>0)&&(ct.y=Nt):O==="x"&&(_e.includes("left")||_e.includes("right"))&&(_e.includes("left")&&zt<0||_e.includes("right")&&zt>0)&&(ct.x=zt),(Math.abs(ct.x)>0||Math.abs(ct.y)>0)&&ge(!0),(St=Ke.current)==null||St.style.setProperty("--swipe-amount-x",`${ct.x}px`),(Et=Ke.current)==null||Et.style.setProperty("--swipe-amount-y",`${ct.y}px`)}},kt&&!f.jsx?w.createElement("button",{"aria-label":J,"data-disabled":re,"data-close-button":!0,onClick:re||!He?()=>{}:()=>{var xe;ye(),(xe=f.onDismiss)==null||xe.call(f,f)},className:xn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=V==null?void 0:V.close)!=null?s:kI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,$e||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:xn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||rt():null,f.type!=="loading"?f.icon||(V==null?void 0:V[$e])||vI($e):null):null,w.createElement("div",{"data-content":"",className:xn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:xn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?w.createElement("div",{"data-description":"",className:xn(q,Dt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),w.isValidElement(f.cancel)?f.cancel:f.cancel&&hi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:xe=>{var Pe,Xe;hi(f.cancel)&&He&&((Xe=(Pe=f.cancel).onClick)==null||Xe.call(Pe,xe),ye())},className:xn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&hi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:xe=>{var Pe,Xe;hi(f.action)&&((Xe=(Pe=f.action).onClick)==null||Xe.call(Pe,xe),!xe.defaultPrevented&&ye())},className:xn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Zg(){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 UI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?DI:OI;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 WI=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:h,duration:m,style:f,visibleToasts:v=RI,toastOptions:g,dir:x=Zg(),gap:y=$I,loadingIcon:b,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=w.useState([]),j=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[M,L]=w.useState([]),[H,B]=w.useState(!1),[q,N]=w.useState(!1),[z,$]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),R=w.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),V=w.useRef(!1),J=w.useCallback(_=>{E(O=>{var K;return(K=O.find(Y=>Y.id===_.id))!=null&&K.delete||qt.dismiss(_.id),O.filter(({id:Y})=>Y!==_.id)})},[]);return w.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){E(O=>O.map(K=>K.id===_.id?{...K,delete:!0}:K));return}setTimeout(()=>{Po.flushSync(()=>{E(O=>{let K=O.findIndex(Y=>Y.id===_.id);return K!==-1?[...O.slice(0,K),{...O[K],..._},...O.slice(K+1)]:[_,...O]})})})}),[]),w.useEffect(()=>{if(d!=="system"){$(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:O})=>{$(O?"dark":"light")})}catch{_.addListener(({matches:K})=>{try{$(K?"dark":"light")}catch(Y){console.error(Y)}})}},[d]),w.useEffect(()=>{T.length<=1&&B(!1)},[T]),w.useEffect(()=>{let _=O=>{var K,Y;o.every(ae=>O[ae]||O.code===ae)&&(B(!0),(K=R.current)==null||K.focus()),O.code==="Escape"&&(document.activeElement===R.current||(Y=R.current)!=null&&Y.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),w.useEffect(()=>{if(R.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,V.current=!1)}},[R.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((_,O)=>{var K;let[Y,ae]=_.split("-");return T.length?w.createElement("ol",{key:_,dir:x==="auto"?Zg():x,tabIndex:-1,ref:R,className:a,"data-sonner-toaster":!0,"data-theme":z,"data-y-position":Y,"data-lifted":H&&T.length>1&&!s,"data-x-position":ae,style:{"--front-toast-height":`${((K=M[0])==null?void 0:K.height)||0}px`,"--width":`${LI}px`,"--gap":`${y}px`,...f,...UI(l,c)},onBlur:W=>{V.current&&!W.currentTarget.contains(W.relatedTarget)&&(V.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||V.current||(V.current=!0,I.current=W.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{q||B(!1)},onDragEnd:()=>B(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},T.filter(W=>!W.position&&O===0||W.position===_).map((W,D)=>{var X,oe;return w.createElement(HI,{key:W.id,icons:S,index:D,toast:W,defaultRichColors:h,duration:(X=g==null?void 0:g.duration)!=null?X:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(oe=g==null?void 0:g.closeButton)!=null?oe:i,interacting:q,position:_,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(G=>G.position==W.position),heights:M.filter(G=>G.position==W.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:H,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const VI=({...e})=>{const{theme:t="system"}=xI();return u.jsx(WI,{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})};F.Api=Fv,F.ApiClient=$v,F.ApiProvider=tu,F.ArtifactRenderer=Cp,F.Badge=zh,F.Button=Qe,F.Card=sl,F.CardContent=cl,F.CardDescription=ll,F.CardHeader=il,F.CardTitle=al,F.ChatApi=Ko,F.ChatApp=kk,F.ChatInput=Hf,F.ChatInterface=Or,F.ChatProviders=wr,F.ChatWidget=Nk,F.Command=bl,F.CommandEmpty=Cl,F.CommandGroup=Tl,F.CommandInput=yl,F.CommandItem=kl,F.CommandList=Sl,F.DEFAULT_TIMEOUT_MS=Yc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=ho,F.DropdownMenuItem=zn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=ap,F.HISTORY_TIMEOUT_MS=Xc,F.Input=Pl,F.InterruptPartRenderer=kp,F.Label=fm,F.MarkdownContent=Rr,F.MessageBody=jp,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=fl,F.NewChatButton=Ak,F.PlotArtifact=yp,F.ResearchTaskArtifact=Sp,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=_l,F.Select=lE,F.SelectContent=Qm,F.SelectItem=eg,F.SelectTrigger=Xm,F.SelectValue=cE,F.Separator=og,F.Sheet=bE,F.SheetContent=hg,F.SheetDescription=gg,F.SheetHeader=pg,F.SheetTitle=mg,F.SheetTrigger=yE,F.SimpleChat=Ek,F.SimpleJsonView=ul,F.Sonner=VI,F.StreamProgress=Ep,F.Switch=dg,F.Textarea=Ta,F.ThinkingIndicator=Np,F.ThreadListItem=im,F.ThreadManager=ti,F.ThreadStateProvider=Tu,F.ThreadsProvider=fu,F.TimelineColumn=mx,F.Toaster=hI,F.ToolComponent=Ip,F.Tooltip=WE,F.TooltipContent=kg,F.TooltipProvider=UE,F.TooltipTrigger=VE,F.UserTextContent=Ap,F.applySettings=ww,F.buildCheckpointIndex=Ql,F.buildCheckpointPreviewMap=ox,F.chatApiClient=On,F.del=Ai,F.downloadFileById=Zc,F.extractConfigFields=mi,F.fileToBase64=nu,F.get=Jt,F.getChatToken=qc,F.getCheckpointForMessage=sx,F.getCurrentSettings=vw,F.getDefaultApiConfig=Mu,F.getDefaultChatSettings=Ru,F.getFileContent=_i,F.getFileInfo=zv,F.getMessageAttemptInfo=ec,F.getMessageDomKey=dl,F.getPreviewForMessage=pi,F.httpClient=Xt,F.hydrateHistorySnapshots=Rn,F.isEnvelope=ou,F.listFiles=Qc,F.loadStoredSettings=Ou,F.onChatTokenChanged=Gc,F.post=Vo,F.processAttachments=ru,F.put=Jc,F.readNumber=nc,F.readString=Mn,F.resolveChatBaseUrl=wn,F.saveSettings=Du,F.setChatToken=Wo,F.toPlainObject=Pn,F.unwrap=Lt,F.useApi=Xr,F.useCheckpointIndex=tc,F.useFilePreview=_p,F.useHasChatSession=mw,F.useParsedMessageContent=Pp,F.useShallowStableValue=Au,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=bu,F.useThreadManagerViewState=cm,F.useThreadState=eo,F.useThreadStateUpdater=Cu,F.useThreads=xr,F.useThreadsState=uu,F.viewFileById=Bv,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|