teodor-new-chat-ui 4.3.620 → 4.3.621
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +6 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -36,7 +36,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
36
36
|
|
|
37
37
|
`))>=0;){const kn=jt.slice(0,zt);jt=jt.slice(zt+2);const Tn=kn.split(/\r?\n/),Gt=[];let vn=null;for(const O of Tn){if(O.startsWith(":")){O.startsWith(": heartbeat")&&console.debug("[use-chat] SSE heartbeat comment received");continue}if(O){if(O.startsWith("event:")){const z=O.slice(6).trim();z&&(vn=z);continue}if(O.startsWith("data:")){const z=O.slice(5);Gt.push(z.startsWith(" ")?z.slice(1):z)}}}const ln=Gt.join(`
|
|
38
38
|
`);if(!ln)continue;let Y;try{Y=JSON.parse(ln)}catch{console.debug("[use-chat] malformed SSE:",ln.slice(0,200));continue}vn&&typeof Y=="object"&&Y!==null&&!("type"in Y)&&(Y.type=vn);const fe=Zl(Y)?Y.data:Y;if(!fe){console.warn("[use-chat] dropped envelope event without payload",Y);continue}const Q=fe;gt=Date.now(),Q.type==="values"&&(Q.type="state_history"),Q.type==="metadata"&&(Q.title||Q.createdAt)&&(Q.type="thread_info");const C=Q.seq;if(C!==void 0){if(C<=kt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:C,lastProcessedSeq:kt,type:Q.type});continue}kt>0&&C>kt+1&&((ge=N==null?void 0:N.onGap)==null||ge.call(N,{from:kt,to:C})),kt=C,L.current=C,b(C)}if(Q.type==="checkpoint")V.current=Q.checkpointId??null,$.current=Q.checkpointNs??null,m(Q.checkpointId??null);else if(Q.type==="state_history"){Z.current=Q;try{const z=cr(Q).latest;z&&(V.current=z.checkpointId??null,$.current=z.checkpointNs??null,m(z.checkpointId??null),j(z.values??{}))}catch(O){console.warn("[use-chat] Failed to hydrate state_history payload",O)}}try{A==null||A(Q)}catch(O){console.error("[use-chat] Error in onEvent callback:",O,"for event:",Q.type)}try{Q.type==="tool.start"&&(N!=null&&N.onToolStart)?N.onToolStart(Q):Q.type==="tool.end"&&(N!=null&&N.onToolEnd)?N.onToolEnd(Q):Q.type==="token"&&(N!=null&&N.onToken)?N.onToken(Q.token):Q.type==="thread_info"&&(N!=null&&N.onThreadInfo)&&N.onThreadInfo(Q)}catch(O){console.warn("[use-chat] Typed callback error:",O)}if(Q.type==="messages/partial"){const z=Q.messages;if(Array.isArray(z)&&z.length>0){const se=z.find(ie=>ie.type==="ai");if(se){const ie=se.id,Ce=se.content??"",Te=se.response_metadata??{};if(X.current.messageId!==ie){const nt=Te.model_name??Te.model_provider??"assistant";X.current={messageId:ie,lastSeq:null,lastText:""};const Ye={id:ie,role:"assistant",name:nt,model:nt,createdAt:new Date().toISOString(),content:[{type:"text",text:Ce}]};I(it=>({...it,[ie]:Ye})),S(ie)}else I(nt=>{const Ye=nt[ie];return Ye?{...nt,[ie]:{...Ye,content:[{type:"text",text:Ce}]}}:nt});const _e=X.current.lastText||"";if(Ce.length>_e.length){const nt=Ce.slice(_e.length);X.current.lastText=Ce,e.autoAppendAssistant!==!1&&(ct.push(nt),Ge())}}}}else if(Q.type==="updates"){const O=Q;if(O.tools){const z=O.tools;if(z.status==="start"){const se={type:"tool.start",id:z.id,name:z.name,args:z.args,seq:O.seq,call_id:z.id};try{A==null||A(se)}catch(ie){console.error("[use-chat] Error in onEvent (tool.start polyfill):",ie)}}else if(z.status==="end"){const se={type:"tool.end",id:z.id,name:z.name,output:z.output,artifact:z.artifact,seq:O.seq,call_id:z.id};try{A==null||A(se)}catch(ie){console.error("[use-chat] Error in onEvent (tool.end polyfill):",ie)}}}continue}else if(Q.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(be=N==null?void 0:N.onHeartbeat)==null||be.call(N,Q)}catch(O){console.warn("[use-chat] heartbeat callback failed",O)}}else if(Tt!==null&&cancelAnimationFrame(Tt),bt(),Q.type==="checkpoint")m(Q.checkpointId??null);else if(Q.type==="error"){const O=Q;if(u(O.message),M="error",q=O.message,O.error_type==="auth_error"||O.code==="TOKEN_EXPIRED"||((Be=O.message)==null?void 0:Be.includes("token"))||((Le=O.message)==null?void 0:Le.includes("401"))||((je=O.message)==null?void 0:je.includes("unauthorized"))||((Fe=O.message)==null?void 0:Fe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",O.message);try{(tt=N==null?void 0:N.onAuthError)==null||tt.call(N,O.message)}catch(se){console.warn("[use-chat] onAuthError handler failed",se)}R.abort()}}}}bt(),M===null&&!R.signal.aborted&&(M="complete")}catch($e){if($e.name==="AbortError")M=M??"aborted";else{const Ee=$e.message||String($e);M="error",q=Ee,u(Ee),(mt=N==null?void 0:N.onError)==null||mt.call(N,Ee)}}finally{try{await st.cancel()}catch{}finally{(ot=st.releaseLock)==null||ot.call(st)}Tt!==null&&typeof window<"u"&&window.cancelAnimationFrame(Tt),clearInterval(ut)}}catch(rt){if(rt.name==="AbortError")M=M??"aborted";else{const qe=rt.message||String(rt);M="error",q=qe,u(qe),(ze=N==null?void 0:N.onError)==null||ze.call(N,qe),J||((Me=N==null?void 0:N.onConnectionError)==null||Me.call(N,qe),J=!0)}}finally{const rt=L.current,qe=V.current,ht=$.current,xt=Z.current,He=M??(R.signal.aborted?"aborted":q?"error":"complete");try{(Ze=N==null?void 0:N.onClosed)==null||Ze.call(N,{reason:He,lastSeq:rt,lastCheckpointId:qe,lastCheckpointNs:ht,lastStateHistory:xt,error:q})}catch(st){console.warn("[use-chat] onClosed callback failed",st)}c(!1),y(!1),_.current=null,L.current=0,b(0),W.current=null}})(),{close:()=>R.abort()}},[t,n,r,e.autoAppendAssistant]);return x.useEffect(()=>()=>{var H;D.current=!1,(H=_.current)==null||H.abort()},[]),{isStreaming:a,error:l,assistantText:f,activeMessageId:k,streamedMessages:T,lastCheckpointId:p,lastSeq:g,connected:v,stream:G,stop:F,clear:U,setToken:oe,values:E,interrupt:()=>Promise.resolve(),resume:()=>Promise.resolve(),goto:()=>Promise.resolve()}}const Zm=["detail","message","error","description","title"];function _o(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=_o(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Zm){const r=_o(t[n]);if(r)return r}if("errors"in t){const n=_o(t.errors);if(n)return n}}return null}function Qm(e){if(!e)return"Request failed";const t=e.response,n=_o(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 Ql({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=x.useState([]),[a,c]=x.useState(t),[l,u]=x.useState(!1),[f,h]=x.useState(null),[p,m]=x.useState([]),[g,b]=x.useState(!1),[,v]=x.useState(null),[y,T]=x.useState(null),[I,k]=x.useState(!1),S=x.useRef(a),E=x.useRef(new Map);x.useEffect(()=>{S.current=a},[a]),x.useEffect(()=>{t!==void 0&&t!==S.current&&c(t)},[t]);const j=x.useCallback(async()=>{u(!0),h(null);try{const U=await e.listThreads();i(U??[])}catch(U){const F=String(U);h(F),n==null||n(F)}finally{u(!1)}},[e,n]),_=x.useCallback(async()=>{b(!0),v(null);try{const U=await e.listSharedThreads();m(U??[])}catch(U){const F=String(U);v(F),n==null||n(F)}finally{b(!1)}},[e,n]);x.useEffect(()=>{j()},[j]),x.useEffect(()=>{_()},[_]),x.useEffect(()=>{r==null||r(a)},[a,r]);const D=x.useCallback(async(U,F)=>{try{const G=F&&typeof F=="object"?{id:F.id,name:F.name??""}:void 0,H=await e.createThread(U,G);return c(H.threadId),await j(),H.threadId}catch(G){const H=String(G);return n==null||n(H),null}},[e,n,j]),L=x.useCallback(async U=>{const F=s;i(H=>H.filter(A=>A.threadId!==U));const G=new AbortController;E.current.set(U,G);try{await e.deleteThread(U),S.current===U&&(c(null),o==null||o())}catch(H){i(F);const A=String(H);n==null||n(A)}finally{E.current.delete(U)}},[e,o,n,s]),W=x.useCallback(async(U,F)=>{try{await e.updateThread(U,F),await j()}catch(G){n==null||n(String(G))}},[e,n,j]),V=x.useCallback(async(U,F)=>{k(!0),T("Sharing thread…");try{await e.shareThread(U,F),await _(),T("Shared successfully")}catch(G){const H=Qm(G);throw n==null||n(H),T(`Failed to share: ${H}`),new Error(H)}finally{k(!1)}},[e,n,_]),$=x.useCallback(async(U,F)=>{try{await e.unshareThread(U,F),await _()}catch(G){const H=String(G);throw n==null||n(H),G}},[e,n,_]),Z=x.useMemo(()=>({createThread:D,deleteThread:L,renameThread:W,refreshThreads:j,refreshSharedThreads:_,shareThread:V,unshareThread:$}),[D,L,W,j,_,V,$]),X=x.useCallback(U=>{if(!(U!=null&&U.threadId))return;const F={threadId:U.threadId,title:U.title||`Thread ${U.threadId.slice(0,8)}`,project:U.project,createdAt:U.createdAt||new Date().toISOString(),updatedAt:U.updatedAt||new Date().toISOString(),messageCount:U.messageCount??1};i(G=>{let H=!1;const A=G.map(N=>N.threadId===F.threadId?(H=!0,console.debug("[useThreadsState] thread_info: updating existing thread",F.threadId),{...N,title:F.title??N.title,project:F.project??N.project,updatedAt:F.updatedAt??N.updatedAt,messageCount:F.messageCount??N.messageCount}):N);return H?A:(console.debug("[useThreadsState] thread_info: adding thread to list",F.threadId),[F,...G])})},[]),oe=x.useCallback(()=>T(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:S,setCurrentThreadId:c,isLoadingThreads:l,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:Z,addThreadFromEvent:X,shareInFlight:I,shareStatus:y,clearShareStatus:oe}}const ec=x.createContext(null);function tc({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{chatApi:o}=Vn(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoadingThreads:l,threadsError:u,sharedThreads:f,isLoadingSharedThreads:h,actions:p,addThreadFromEvent:m,shareInFlight:g,shareStatus:b,clearShareStatus:v}=Ql({api:o,initialThreadId:t,onError:n,onThreadChange:r}),y=x.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoading:l,error:u,sharedThreads:f,isLoadingSharedThreads:h,actions:p,shareInFlight:g,shareStatus:b,clearShareStatus:v,addThreadFromEvent:m}),[s,i,a,c,l,u,f,h,p,g,b,v,m]);return d.jsx(ec.Provider,{value:y,children:e})}function ur(){const e=x.useContext(ec);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function dr(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=eg(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function eg(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function ti(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(ti(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 fr(e){if(typeof e=="string")return e;if(ti(e))return"";try{const t=zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function nc(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function tg(e){const t=fr(e);return typeof e=="string"&&nc(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Br(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=dr(t);if(n!==null)return Br(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Br(e.content):e}function rc(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function jo(e){return{toolCallId:(e.toolCallId||e.tool_call_id)??void 0,name:e.name??void 0}}function oc(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function ng(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 rg(e){var n;if(e.name&&e.name.trim())return e.name;const t=(n=e.additionalKwargs)==null?void 0:n.agent_name;return typeof t=="string"&&t.trim()?t:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function sc(e){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":return"img";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 ni(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function ic(e){if(e.role!=="assistant")return!1;const t=Array.isArray(e.content)?e.content:Array.isArray(e.parts)?e.parts:[],n=t.some(s=>s.type==="text"&&s.text&&s.text.trim().length>0),r=t.some(s=>s.type==="image"||s.type==="image_url"||s.type==="file"),o=!!e.artifact;return!n&&!r&&!o}function og(e){return e.role==="tool"?!0:e.role==="assistant"?ic(e):!1}function sg(e,t){const n=[],r=e.findIndex(c=>c.id===t);if(r===-1)return n;const o=new Map;let s=0;for(let c=r;c>=0;c--){const l=e[c];if(c<r&&l.role==="assistant"&&!ic(l))break;if(l.role==="assistant"){const u=Array.isArray(l.content)?l.content:Array.isArray(l.parts)?l.parts:[];if(l.tool_calls)for(const f of l.tool_calls)f.id&&f.name&&!o.has(f.id)&&o.set(f.id,{name:f.name,timestamp:l.createdAt,order:s++});for(const f of u)if(f.type==="tool_call"){const h=f;h.id&&h.name&&!o.has(h.id)&&o.set(h.id,{name:h.name,timestamp:l.createdAt,order:s++})}}}if(o.size===0)return n;const i=new Map;for(let c=r+1;c<e.length;c++){const l=e[c];if(l.role==="tool"){const f=jo(l).toolCallId;if(f&&o.has(f)){const h=Array.isArray(l.content)?l.content:Array.isArray(l.parts)?l.parts:[],p=rc(h.filter(m=>m.type==="text"));i.set(f,{content:p||`Finished ${l.name||"tool"}`,artifact:l.artifact,timestamp:l.createdAt})}}}const a=Array.from(o.entries()).sort((c,l)=>c[1].order-l[1].order);for(const[c,l]of a){const u=i.get(c);u?(n.push({type:"tool.start",toolName:l.name,toolCallId:c,content:`Starting ${l.name}...`,timestamp:l.timestamp}),n.push({type:"tool.end",toolName:l.name,toolCallId:c,content:u.content,timestamp:u.timestamp,output:u.content,artifact:u.artifact})):n.push({type:"tool.start",toolName:l.name,toolCallId:c,content:`Starting ${l.name}...`,timestamp:l.timestamp})}return n}function hr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=dr(t);return n!==null?hr(n):t}if(Array.isArray(e))return e.map(t=>hr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return hr(t)}return e}function ac(e){const t=hr(e.value);return t===e.value?e:{...e,value:t}}function Po(e){const t=e.artifact;return!t||typeof t!="object"?null:"metadata"in t&&t.metadata?t.metadata:{id:t.id??e.id??`artifact-${Date.now()}`,type:t.type??"unknown",created_at:e.createdAt??new Date().toISOString(),status:t.status??"completed",progress:t.progress??void 0}}function ig(e){if(!e||typeof e!="object")return!1;const t=Po({artifact:e});return!!(t&&t.status==="in_progress"&&(t.progress??0)<100)}function ag(e,t){const n=Po(e);if(!n)return e;const r={...n,...t,updated_at:new Date().toISOString()};return{...e,artifact:{...typeof e.artifact=="object"&&e.artifact?e.artifact:{},metadata:r}}}function lg(e,t){return e.find(n=>{const r=Po(n);return(r==null?void 0:r.id)===t})??null}function Oo(e){return e.filter(t=>{var c;if(t.role!=="assistant")return!0;const n=t.content,r=typeof n=="string"?n.trim().length>0:Array.isArray(n)&&n.some(l=>{var u;return l&&l.type==="text"&&((u=l.text)==null?void 0:u.trim())}),o=Array.isArray(n)&&n.some(l=>l&&l.type==="image"),s=t.artifact!==null&&t.artifact!==void 0,i=((c=t.tool_calls)==null?void 0:c.length)>0,a=Array.isArray(n)&&n.some(l=>l&&["file","tool_call","interrupt"].includes(l.type));return!!(r||o||s||i||a)})}function Hr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function cg(e){let t=!1;const n=e.map(r=>{var s;const o=(r.content??[]).filter(i=>i.type!=="interrupt");return o.length!==((s=r.parts)==null?void 0:s.length)?(t=!0,{...r,content:o}):r});return t?n:e}function ug(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 Hr(e,r,s)}return e}function dg(e){const t=new Map,n=[];return e.slice().sort((r,o)=>{const s=r.createdAt?Date.parse(r.createdAt):0,i=o.createdAt?Date.parse(o.createdAt):0;return s-i}).forEach(r=>{const o=Array.isArray(r.messages)?r.messages:[];for(const s of o)!(s!=null&&s.id)||t.has(s.id)||(t.set(s.id,s),n.push(s))}),n.sort((r,o)=>{const s=r.createdAt?Date.parse(r.createdAt):0,i=o.createdAt?Date.parse(o.createdAt):0;return s-i}),n}const fg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null,values:{}};function hg(e,t){var n;switch(t.type){case"reset":return{messages:Oo(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{},values:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r],assemblingId:null}}}return{...e,messages:[...e.messages,r],assemblingId:null}}case"seed":{const r=Oo(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=Oo(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 lc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>lc(o,s),e):e}default:return e}}function pg(e=[]){const[t,n]=x.useReducer(hg,{...fg,messages:e}),r=x.useRef([]),o=x.useRef(null),s=x.useRef(null),i=x.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const u=r.current;u.length&&(r.current=[],n({type:"batch",payload:{events:u}}))},[]),a=x.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]),c=x.useCallback(u=>{r.current.push(u),a()},[a]);x.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const l=x.useMemo(()=>({reset:u=>n({type:"reset",payload:{messages:u}}),seed:(u,f)=>n({type:"seed",payload:{messages:u,...f??{}}}),prepend:u=>n({type:"prepend",payload:{messages:u}}),pushUser:(u,f)=>n({type:"user_message",payload:{message:u,editingMessageId:f}}),onEvent:c}),[c]);return{state:t,dispatch:n,...l}}function lc(e,t){if(t.type==="tool.start")return gg(e,t);if(t.type==="tool.progress")return xg(e,t);if(t.type==="tool.end")return bg(e,t);if(t.type==="artifact.update")return wg(e,t);if(t.type==="checkpoint"){const n=t.checkpointNs??e.lastCheckpointNs??null,r=ug(e.messages,t.checkpointId,n);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:n,messages:r}}if(t.type==="error"){const n={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,n]}}if(t.type==="state_history"){const n=cr(t),r=n.interrupt,o=n.latest,s=dg(n.checkpoints);let i=s.length?s:o==null?void 0:o.messages;if(i){if(e.assemblingId&&!i.some(a=>a.id===e.assemblingId)){const a=e.messages.find(c=>c.id===e.assemblingId);a&&(i=[...i,a])}i=Oo(i)}else i=r===null?cg(e.messages):e.messages;return{...e,messages:i,pendingInterrupt:r,lastCheckpointId:(o==null?void 0:o.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(o==null?void 0:o.checkpointNs)??e.lastCheckpointNs,values:(o==null?void 0:o.values)??e.values}}return t.type==="thread_info",e}function ri(e){return e.call_id??e.id??null}function cc(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function uc(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,toolCallId:o,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function oi(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.toolCallId;if(typeof o=="string"&&o===t)return n;const s=r.additionalKwargs??{};if(typeof s.toolCallId=="string"&&s.toolCallId===t||jo(r).toolCallId===t)return n}return-1}function mg(e){if(e==null)return[];const t=Br(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=fr(t??e);return n?[{type:"text",text:n}]:[]}function si(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function gg(e,t){const n=ri(t),r=oi(e.messages,n),o=t.name??t.tool??void 0,s=cc(t),i={type:t.type,content:`Starting ${o??"tool"}...`,seq:t.seq??null,timestamp:new Date().toISOString()};if(r>=0){const l=e.messages[r],f={...l.additionalKwargs??{},toolStreaming:!0,toolProgress:[i]},h={...l,name:o??l.name,additionalKwargs:f};return{...e,messages:Hr(e.messages,r,h)}}const a=uc(s,n,o,t.args),c=si(a,i);return{...e,messages:[...e.messages,c]}}function xg(e,t){var u,f,h,p,m;const n=t.id??t.call_id??((u=t.data)==null?void 0:u.id)??ri(t);if(!n)return e;const r=oi(e.messages,n);if(r===-1)return e;const o=t.status??t.step??t.type??((f=t.data)==null?void 0:f.type)??"progress",s=t.content??((h=t.data)==null?void 0:h.content)??(typeof t.data=="string"?t.data:void 0),i={type:o,content:s,seq:t.seq??null,timestamp:new Date().toISOString()},a=t.metadata??((p=t.data)==null?void 0:p.metadata);a&&(i.metadata=a);const c=t.idx??((m=t.data)==null?void 0:m.idx);typeof c=="number"&&(i.idx=c);const l=si(e.messages[r],i);return{...e,messages:Hr(e.messages,r,l)}}function bg(e,t){const n=ri(t),r=cc(t);let o=e.messages,s=oi(o,n);if(s===-1){const m=t.name??t.tool??void 0;o=[...o,uc(r,n,m,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,c=mg(a),l=[...i.content,...c],u={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(u.artifact=t.artifact);const f=si(i,u),h=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:l,artifact:h,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Hr(o,s,p)}}function wg(e,t){const n=lg(e.messages,t.artifact_id);if(!n){const s={id:`artifact-${t.artifact_id}`,role:"tool",name:"artifact_updater",content:[],createdAt:new Date().toISOString(),artifact:{type:"unknown",metadata:{id:t.artifact_id,type:"unknown",created_at:new Date().toISOString(),status:t.status,progress:t.progress},...t.partial_data}};return{...e,messages:[...e.messages,s]}}const r=e.messages.indexOf(n),o=ag(n,{status:t.status,progress:t.progress,error:t.error});return t.partial_data&&o.artifact&&(o.artifact={...o.artifact,...t.partial_data}),{...e,messages:Hr(e.messages,r,o)}}const dc=120;function vg(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>dc?`${n.slice(0,dc-3)}…`:n:""}function yg(e){return vg(e.content)||""}function Sg(e){const t=new Map,n=[],r=new Map,o=[];for(let l=0;l<e.length;l++){const u=e[l],f=u.checkpointId,h=f??`cp-${l}`,p=u.metadata??{},m=typeof p.step=="number"?p.step:null,g=typeof p.source=="string"?p.source:null;let b=null,v=null;const y=Array.isArray(u.messages)?u.messages:[];for(const S of y)S.role==="user"&&(v||(v=S),S.id&&(b=S.id));const T=u.next&&u.next.length>0?String(u.next[0]):null,I=u.parentConfig??null,k={id:h,step:m,source:g,createdAt:u.createdAt??null,namespace:u.checkpointNs??null,parentId:u.parentId??null,next:T,parentConfig:I,userMessageId:b};if(o.push(k),f&&t.set(f,k),f&&v){const S=yg(v);S&&r.set(f,S)}n.push({id:h,messageId:b,step:m,source:g,createdAt:u.createdAt??null,next:T,parentConfig:I})}const s=new Map;for(const l of o){if(!l.userMessageId)continue;const u=s.get(l.userMessageId)??[];u.push(l),s.set(l.userMessageId,u)}for(const l of s.values()){if(!l.length)continue;l.sort((f,h)=>{const p=f.createdAt?Date.parse(f.createdAt):0;return(h.createdAt?Date.parse(h.createdAt):0)-p});const u=l.length;for(let f=0;f<l.length;f++){const h=l[f];h.attemptCount=u,h.attemptIndex=f,h.isLatestAttempt=f===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const l=n[0];if(l)return t.get(l.id)},getCheckpoint:l=>t.get(l),getMessageAttempts:l=>{const u=[];for(const f of t.values())f.userMessageId===l&&u.push(f);return u.length?(u.sort((f,h)=>{const p=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,m=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER;return p-m}),u):[]}}}function Cg(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 kg(e){return x.useMemo(()=>Sg(e),[e])}function fc({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:c,getMessages:l}){const[u,f]=x.useState(null),p=x.useMemo(()=>cr(u),[u]).checkpoints,m=kg(p),g=m.timeline,[b,v]=x.useState(!1),[y,T]=x.useState(!1),[I,k]=x.useState(null),S=x.useRef(r),E=x.useRef(null),j=x.useRef(null),_=x.useRef(null),D=x.useRef(null),L=x.useRef(null),W=x.useRef(new Map),V=x.useRef(null);x.useEffect(()=>{S.current=r},[r]);const $=x.useCallback(async R=>{var q,J;if(!R.threadId)return;const M=R.threadId;(q=R.onStart)==null||q.call(R),R.setLoading(!0);try{await R.action(M)}catch(P){if(!Ll(P)&&S.current===M){const te=String(P);(J=R.handleError)==null||J.call(R,te),n==null||n(te)}throw P}finally{R.setLoading(!1)}},[n]),Z=x.useCallback(async(R,M)=>{var te;if(!R)return;const q=`${R}:${M??"latest"}`,J=W.current.get(q);if(J)return J;(te=V.current)==null||te.abort();const P=new AbortController;V.current=P;const K=$({threadId:R,setLoading:v,onStart:()=>k(null),handleError:le=>k(le),action:async le=>{const he=await e.getStateHistory({threadId:le,checkpointId:M??void 0,signal:P.signal});if(S.current!==le){console.log(`[useThreadHistoryState] Thread changed during load (was ${le}, now ${S.current}), discarding stale data`);return}const{checkpoints:ue,latest:ge}=cr(he),be=M?ue.find(Be=>Be.checkpointId===M)??ge:ge;t((be==null?void 0:be.messages)??[],{checkpointId:(be==null?void 0:be.checkpointId)??null,checkpointNs:(be==null?void 0:be.checkpointNs)??null,pendingInterrupt:(be==null?void 0:be.interrupt)??null}),f(he)}});W.current.set(q,K);try{await K}finally{W.current.delete(q),V.current===P&&(V.current=null)}return S.current===R&&(L.current=q),K},[e,t,$]),X=x.useCallback(async(R,M)=>{D.current=R;try{await Z(R,M)}catch(q){if(!Ll(q))throw q}finally{D.current===R&&(D.current=null)}},[Z]),oe=x.useCallback(R=>{j.current=R},[]),U=x.useCallback(R=>{_.current=R},[]),F=x.useCallback(R=>{const M=R.threadId??S.current;if(!M||S.current&&S.current!==M)return;const{checkpoints:q,latest:J}=cr(R);if(!q.length)return;const P=J,K=_.current===M;!c&&!K&&t((P==null?void 0:P.messages)??[],{checkpointId:(P==null?void 0:P.checkpointId)??null,checkpointNs:(P==null?void 0:P.checkpointNs)??null,pendingInterrupt:(P==null?void 0:P.interrupt)??null}),f(R),L.current=`${M}:latest`,j.current=null,_.current===M&&(_.current=null)},[t,c]),G=x.useCallback(async(R,M)=>{const q=S.current;await $({threadId:q,setLoading:T,action:async J=>{const P=await e.getStateHistory({threadId:J,checkpointId:R,checkpointNs:M??void 0});if(S.current!==J)return;const{checkpoints:K}=cr(P),te=K.find(le=>le.checkpointId===R&&(M?le.checkpointNs===M:!0));if(!te){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:R,checkpointNs:M});return}f(P),t(te.messages??[],{checkpointId:te.checkpointId??null,checkpointNs:te.checkpointNs??null})}}).catch(()=>{})},[e,t,$]),H=x.useCallback((R,M)=>{t(l(),{checkpointId:R??null,checkpointNs:M??null})},[l,t]),A=x.useCallback(async()=>{S.current&&await X(S.current)},[X]);x.useEffect(()=>{if(!a||!r||b||c)return;if(j.current===r){j.current=null,E.current=r;return}if(_.current===r){E.current=r;return}if(D.current===r){D.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let R;const M=`${r}:latest`;L.current!==M&&X(r,R)},[a,r,s,i,o,b,c,X]);const N=x.useCallback(()=>{f(null),v(!1),T(!1),k(null),j.current=null,_.current=null,E.current=null,L.current=null,D.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:m,isLoadingThread:b,isLoadingCheckpoint:y,threadStateError:I,loadThread:X,navigateToCheckpoint:G,setCurrentCheckpointId:H,returnToLatest:A,handleStateHistoryEvent:F,markSkipNextLoad:oe,markStreamPendingThread:U,resetHistoryState:N,clearState:N}}const hc=x.createContext(null),pc=x.createContext(null);function Ur(){const e=x.useContext(hc);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function mc(){const e=x.useContext(pc);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function gc({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{chatApi:a}=Vn(),{currentThreadId:c}=ur(),{state:l,seed:u,onEvent:f,dispatch:h}=pg(),{threadCheckpoints:p,threadTimeline:m,checkpointIndex:g,isLoadingThread:b,isLoadingCheckpoint:v,threadStateError:y,loadThread:T,navigateToCheckpoint:I,setCurrentCheckpointId:k,returnToLatest:S,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:_,resetHistoryState:D}=fc({api:a,seed:u,onError:i,currentThreadId:c,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:x.useCallback(()=>l.messages,[l.messages])});x.useEffect(()=>{c||(u([],{}),D())},[c,u,D]);const L=x.useRef(null),W=x.useCallback(G=>{L.current=G},[]),V=x.useRef(null),$=x.useCallback(G=>{V.current=G},[]),Z=x.useMemo(()=>({assemblingMessageId:l.assemblingId??null}),[l.assemblingId]),X=x.useCallback((G,H)=>{const A=Yl(G,"user");return h({type:"user_message",payload:{message:A,editingMessageId:H==null?void 0:H.editingMessageId}}),A},[h]),oe=x.useCallback(async()=>{L.current?await L.current():(u([],{}),D())},[u,D]),U=x.useMemo(()=>({threadId:c,messages:l.messages,interrupt:l.pendingInterrupt,checkpoint:{id:l.lastCheckpointId??null,namespace:l.lastCheckpointNs??null},checkpoints:p,checkpointIndex:g,timelineCheckpoints:m,metadata:Z,values:l.values??{},isLoading:b,isLoadingCheckpoint:v,error:y,loadOlder:async()=>{},seedFromSnapshot:G=>{u(G.messages,{checkpointId:G.checkpointId,checkpointNs:G.checkpointNs,pendingInterrupt:G.interrupt})},clearState:oe,navigateToCheckpoint:I,setCurrentCheckpointId:k,returnToLatest:S,loadThread:async(G,H,A)=>{await T(G,H,{clearProgress:!1})},clearThread:oe,respondToInterrupt:async(G,H,A)=>{V.current&&await V.current(G,H,A)},messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:_,resetHistoryState:D,pushUser:X,onEvent:f}),[c,l.messages,l.pendingInterrupt,l.lastCheckpointId,l.lastCheckpointNs,l.values,p,m,g,Z,b,v,y,u,oe,I,k,S,T,E,j,_,X,f]),F=x.useMemo(()=>({registerClearThread:W,registerRespondToInterrupt:$}),[W,$]);return d.jsx(pc.Provider,{value:F,children:d.jsx(hc.Provider,{value:U,children:e})})}function xc(e,t){if(!e)return null;const n=Kn(e);if(!n)return null;const r=Kn(n.configurable)??n;return Fr(r,t)??null}function Tg(e){const t=xc(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=xc(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function Eg(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 Ig(e,t){const n=[...e].sort(Eg);for(const r of n){if(r.messageId!==t)continue;const o=Tg(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 bc=x.createContext(null),wc=x.createContext(!1);function Ag({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:c,onToolEnd:l}){const{chatApi:u,baseUrl:f}=Vn(),h=f,{stream:p,stop:m,clear:g,isStreaming:b,error:v,connected:y}=Jm({baseUrl:h}),[T,I]=x.useState(!1);return x.useEffect(()=>{I(b)},[b]),d.jsx(tc,{initialThreadId:t,onError:s,onThreadChange:a,children:d.jsx(gc,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:T,children:d.jsx(wc.Provider,{value:!0,children:d.jsx(Ng,{api:u,streamApi:{stream:p,stop:m,clear:g,isStreaming:b,error:v,connected:y},onError:s,onAuthError:i,onConnectionError:c,onToolEnd:l,children:e})})})})}function Ng({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:c,clear:l,isStreaming:u,error:f,connected:h}=n,{setCurrentThreadId:p,currentThreadIdRef:m,addThreadFromEvent:g,currentThreadId:b}=ur();x.useEffect(()=>{b!==void 0&&l()},[b,l]);const{interrupt:v,checkpoint:y,timelineCheckpoints:T,handleStateHistoryEvent:I,markSkipNextLoad:k,markStreamPendingThread:S,resetHistoryState:E,pushUser:j,onEvent:_,messages:D}=Ur(),{registerClearThread:L,registerRespondToInterrupt:W}=mc(),V=x.useCallback(H=>{g(H),m.current!==H.threadId&&((H.created??!m.current)&&k(H.threadId),S(H.threadId),p(H.threadId))},[g,k,S,p,m]),$=x.useCallback(H=>{H.type==="thread_info"?V(H):H.type==="state_history"?I(H):H.type==="tool.end"?(_(H),i==null||i(H)):_(H)},[V,I,_,i]),Z=x.useCallback((H,A)=>{a(H,N=>{$(N),A==null||A(N)},{onError:N=>{console.error("[StreamingProvider] Stream error:",N),r==null||r(N)},onAuthError:N=>{console.error("[StreamingProvider] Auth error:",N),o==null||o(N)},onConnectionError:N=>{console.error("[StreamingProvider] Connection error:",N),s==null||s(N)}})},[a,$,r,o,s]),X=x.useRef(y);x.useEffect(()=>{X.current=y},[y]);const oe=x.useCallback(async(H,A,N)=>{const R=m.current;if(!R)throw new Error("No active thread to handle interrupt");const M=H?A??!0:!1,q=X.current,J={threadId:R,checkpointId:q.id??void 0,checkpointNs:q.namespace??void 0,command:{kind:"resume",value:M},payload:N==null?void 0:N.payload};Z(J)},[m,Z]);x.useEffect(()=>{W(oe)},[oe,W]);const U=x.useCallback(async()=>{c(),l(),E(),p(null)},[l,E,p,c]);x.useEffect(()=>{L(U)},[U,L]);const F=x.useCallback(async(H,A)=>{u&&c();let N=m.current;const R=(H==null?void 0:H.text)??"",M=(H==null?void 0:H.attachments)??[],q=(R==null?void 0:R.trim())??"",J={...(H==null?void 0:H.payload)??{}},P=Array.isArray(J.messages)?J.messages:void 0;P&&delete J.messages;const K=!!(P&&P.length),te=!!(H.contentParts&&H.contentParts.length>0);if(!N&&!q&&M.length===0&&!K&&!te)return;if(!N){const Me=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Ze=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);N=`${Me}${Ze}`,k(N),p(N)}let le=null;H.contentParts&&H.contentParts.length>0&&(le=H.contentParts);const{contentParts:he,filesInfo:ue}=le?{contentParts:le,filesInfo:[]}:await Gl(M),ge=[...he];q&&ge.push({type:"text",text:R});const be=A==null?void 0:A.originalMessageId,Be=!!(A!=null&&A.edit&&be),Le=!K&&ge.length>0;let je=null;if(Le){const Me=Be?be:`msg-${Date.now()}`;je=Yl({id:Me,role:"user",content:ge,createdAt:new Date().toISOString()},"user"),Be?j(je,{editingMessageId:be}):j(je)}const Fe=K?P:je?[je]:[],tt={...J,...ue.length?{files_info:ue}:{}};Fe.length?tt.messages=Fe:"messages"in tt||(tt.messages=[]);let mt=(A==null?void 0:A.checkpointId)??y.id??void 0,ot=(A==null?void 0:A.checkpointNs)??y.namespace??void 0;if(Be&&be){const Me=Ig(T,be);mt=Me.checkpointId,ot=Me.checkpointNs??void 0}const ze={threadId:N,payload:tt,checkpointId:mt,checkpointNs:ot,config:A==null?void 0:A.config,edit:!!(A!=null&&A.edit)};Z(ze,A==null?void 0:A.onEvent)},[y,m,u,k,j,Z,c,T]),G=x.useMemo(()=>({isStreaming:u,error:f,connectionState:f?"error":u?h?"connected":"connecting":"idle",messages:D,submit:F,stop:c,interrupt:v,resume:()=>Promise.resolve(),goto:(H,A)=>Promise.resolve(),clearError:()=>{}}),[u,f,F,c,v,h,D]);return d.jsx(bc.Provider,{value:G,children:e})}function ii(){const e=x.useContext(bc);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function _g(){return x.useContext(wc)}function vc(e){return typeof e=="object"&&e!==null}function jg(e,t){if(Object.is(e,t))return!0;if(!vc(e)||!vc(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 yc(e){const t=x.useRef(e),n=x.useRef(e);return jg(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:c,onThreadChange:l,onToolEnd:u}){const f=yc(t),h=Vr(a),p=Vr(c),m=Vr(i),g=Vr(l),b=Vr(u),v=x.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:h,onAuthError:p,onConnectionError:m,onThreadChange:g,onToolEnd:b}),[n,r,o,s,h,p,m,g,b]);return d.jsx(Kl,{apiConfig:f,children:d.jsx(Ag,{...v,children:e})})}function Vr(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e},[e]),x.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function pr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Sc(){const e=[pr("__API_BASE_URL__"),pr("__CHAT_API_BASE_URL__"),pr("__CHAT_API_URL__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"")}function Cc(){const e=[pr("__API_AUTH_TOKEN__"),pr("__CHAT_API_KEY__"),pr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function kc(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"");return""}function Tc(){const e={},t=Sc(),n=Cc();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ec(){const e=Tc(),t=An.getAuthToken(),n=Sc();return{apiBaseUrl:kc(e.baseUrl,n),apiKey:t||e.apiKey||Cc()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const ai=En.chatSettings;function Ic(){try{const e=localStorage.getItem(ai);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Ac(e){try{const t={...e,apiBaseUrl:e.apiBaseUrl.trim().replace(/\/+$/,"")};localStorage.setItem(ai,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Pg(){const e=Ec(),t=Ic(),n=An.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:kc(An.baseUrl,r,e.apiBaseUrl)}}function Og(e){An.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),Ac(e)}function ae(...e){return Bn.twMerge(Pt.clsx(e))}const Rg=Ya.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"}}),Ke=w.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?sr.Slot:"button";return d.jsx(i,{className:ae(Rg({variant:t,size:n,className:e})),ref:s,...o})});Ke.displayName="Button";const Ro=0,Nn=1,mr=2,Nc=4;function _c(e){return()=>e}function Mg(e){e()}function jc(e,t){return n=>e(t(n))}function Pc(e,t){return()=>e(t)}function Dg(e,t){return n=>e(t,n)}function li(e){return e!==void 0}function Lg(...e){return()=>{e.map(Mg)}}function gr(){}function Mo(e,t){return t(e),e}function $g(e,t){return t(e)}function Xe(...e){return e}function De(e,t){return e(Nn,t)}function Ae(e,t){e(Ro,t)}function ci(e){e(mr)}function lt(e){return e(Nc)}function me(e,t){return De(e,Dg(t,Ro))}function tn(e,t){const n=e(Nn,r=>{n(),t(r)});return n}function Oc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Rc(e,t){return e===t}function Je(e=Rc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>jc(t,e)}function un(e){return t=>()=>{t(e)}}function ee(e,...t){const n=Fg(...t);return(r,o)=>{switch(r){case mr:ci(e);return;case Nn:return De(e,n(o))}}}function dn(e,t){return n=>r=>{n(t=e(t,r))}}function qn(e){return t=>n=>{e>0?e--:t(n)}}function yn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Ne(...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);De(s,c=>{const l=n;n=n|a,t[i]=c,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Fg(...e){return t=>e.reduceRight($g,t)}function zg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Nn:return s?n===s?void 0:(r(),n=s,t=De(e,s),t):(r(),gr);case mr:r(),n=null;return}}}function re(e){let t=e;const n=Oe();return(r,o)=>{switch(r){case Ro:t=o;break;case Nn:{o(t);break}case Nc:return t}return n(r,o)}}function vt(e,t){return Mo(re(t),n=>me(e,n))}function Oe(){const e=[];return(t,n)=>{switch(t){case Ro:e.slice().forEach(r=>{r(n)});return;case mr:e.splice(0,e.length);return;case Nn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Ht(e){return Mo(Oe(),t=>me(e,t))}function Re(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Bg(),singleton:n}}const Bg=()=>Symbol();function Hg(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function ft(...e){const t=Oe(),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);De(s,c=>{n[i]=c,r=r|a,r===o&&Ae(t,n)})}),function(s,i){switch(s){case mr:{ci(t);return}case Nn:return r===o&&i(n),De(t,i)}}}function ve(e,t=Rc){return ee(e,Je(t))}function ui(...e){return function(t,n){switch(t){case mr:return;case Nn:return Lg(...e.map(r=>De(r,n)))}}}var Dt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Dt||{});const Ug={0:"debug",3:"error",1:"log",2:"warn"},Wg=()=>typeof globalThis>"u"?window:globalThis,_n=Re(()=>{const e=re(3);return{log:re((t,n,r=1)=>{var o;const s=(o=Wg().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[Ug[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Gn(e,t,n){return di(e,t,n).callbackRef}function di(e,t,n){const r=x.useRef(null);let o=i=>{};const s=x.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 Vg(e,t,n,r,o,s,i,a,c){const l=x.useCallback(u=>{const f=Kg(u.children,t,a?"offsetWidth":"offsetHeight",o);let h=u.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let m;p&&(m=h.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?m.scrollX||m.document.documentElement.scrollLeft:m.scrollY||m.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,b=i?a?i.scrollWidth:i.scrollHeight:p?a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=i?a?i.offsetWidth:i.offsetHeight:p?a?m.innerWidth:m.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:b,scrollTop:Math.max(g,0),viewportHeight:v}),s==null||s(a?Mc("column-gap",getComputedStyle(u).columnGap,o):Mc("row-gap",getComputedStyle(u).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return di(l,n,c)}function Kg(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 c=parseInt(a.dataset.index),l=parseFloat(a.dataset.knownSize),u=t(a,n);if(u===0&&r("Zero-sized element, this should not happen",{child:a},Dt.ERROR),u===l)continue;const f=s[s.length-1];s.length===0||f.size!==u||f.endIndex!==c-1?s.push({endIndex:c,size:u,startIndex:c}):s[s.length-1].endIndex++}return s}function Mc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Dt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Dc(e,t,n){const r=x.useRef(null),o=x.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),u=l.width;let f,h;if(t){const p=t.getBoundingClientRect(),m=l.top-p.top;h=p.height-Math.max(0,m),f=m+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,l.top),f=l.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:u},e(r.current)},[e,t]),{callbackRef:s,ref:i}=di(o,!0,n),a=x.useCallback(()=>{o(i.current)},[o,i]);return x.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const l=new ResizeObserver(()=>{requestAnimationFrame(a)});return l.observe(t),()=>{t.removeEventListener("scroll",a),l.unobserve(t)}}else{const l=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",a),l==null||l.addEventListener("resize",a),()=>{l==null||l.removeEventListener("scroll",a),l==null||l.removeEventListener("resize",a)}}},[a,t,i]),s}const Nt=Re(()=>{const e=Oe(),t=Oe(),n=re(0),r=Oe(),o=re(0),s=Oe(),i=Oe(),a=re(0),c=re(0),l=re(0),u=re(0),f=Oe(),h=Oe(),p=re(!1),m=re(!1),g=re(!1);return me(ee(e,ce(({scrollTop:b})=>b)),t),me(ee(e,ce(({scrollHeight:b})=>b)),i),me(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:a,horizontalDirection:m,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Kr={lvl:0};function Lc(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:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function Ue(e){return e===Kr}function qr(e,t){if(!Ue(e))return t===e.k?e.v:t<e.k?qr(e.l,t):qr(e.r,t)}function nn(e,t,n="k"){if(Ue(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=nn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return nn(e.l,t,n)}function Ut(e,t,n){return Ue(e)?zc(t,n,1):t===e.k?pt(e,{k:t,v:n}):t<e.k?Bc(pt(e,{l:Ut(e.l,t,n)})):Bc(pt(e,{r:Ut(e.r,t,n)}))}function xr(){return Kr}function Do(e,t,n){if(Ue(e))return[];const r=nn(e,t)[0];return qg(hi(e,r,n))}function fi(e,t){if(Ue(e))return Kr;const{k:n,l:r,r:o}=e;if(t===n){if(Ue(r))return o;if(Ue(o))return r;{const[s,i]=Fc(r);return Lo(pt(e,{k:s,l:$c(r),v:i}))}}else return t<n?Lo(pt(e,{l:fi(r,t)})):Lo(pt(e,{r:fi(o,t)}))}function Yn(e){return Ue(e)?[]:[...Yn(e.l),{k:e.k,v:e.v},...Yn(e.r)]}function hi(e,t,n){if(Ue(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(hi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(hi(s,t,n))),a}function Lo(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(pi(t))return Hc(pt(e,{lvl:n-1}));if(!Ue(t)&&!Ue(t.r))return pt(t.r,{l:pt(t,{r:t.r.l}),lvl:n,r:pt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(pi(e))return mi(pt(e,{lvl:n-1}));if(!Ue(r)&&!Ue(r.l)){const o=r.l,s=pi(o)?r.lvl-1:r.lvl;return pt(o,{l:pt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:mi(pt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function pt(e,t){return zc(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 $c(e){return Ue(e.r)?e.l:Lo(pt(e,{r:$c(e.r)}))}function pi(e){return Ue(e)||e.lvl>e.r.lvl}function Fc(e){return Ue(e.r)?[e.k,e.v]:Fc(e.r)}function zc(e,t,n,r=Kr,o=Kr){return{k:e,l:r,lvl:n,r:o,v:t}}function Bc(e){return mi(Hc(e))}function Hc(e){const{l:t}=e;return!Ue(t)&&t.lvl===e.lvl?pt(t,{r:pt(e,{l:t.r})}):e}function mi(e){const{lvl:t,r:n}=e;return!Ue(n)&&!Ue(n.r)&&n.lvl===t&&n.r.lvl===t?pt(n,{l:pt(e,{r:n.l}),lvl:t+1}):e}function qg(e){return Lc(e,({k:t,v:n})=>({index:t,value:n}))}function Uc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Gr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const gi=Re(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function Wc(e,t,n){return e[$o(e,t,n)]}function $o(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 Gg(e,t,n,r){const o=$o(e,t,r),s=$o(e,n,r,o);return e.slice(o,s+1)}function jn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Fo(e){return!Ue(e.groupOffsetTree)}function xi({index:e},t){return t===e?0:t<e?-1:1}function Yg(){return{groupIndices:[],groupOffsetTree:xr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:xr()}}function Xg(e,t){let n=Ue(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ue(e)){e=Ut(e,0,s);continue}const a=Do(e,i-1,o+1);if(a.some(rx(r)))continue;let c=!1,l=!1;for(const{end:u,start:f,value:h}of a)c?(o>=f||s===h)&&(e=fi(e,f)):(l=h!==s,c=!0),u>o&&o>=f&&h!==s&&(e=Ut(e,o+1,h));l&&(e=Ut(e,i,s))}return[e,n]}function Jg(e){return typeof e.groupIndex<"u"}function Zg({offset:e},t){return t===e?0:t<e?-1:1}function Yr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Wc(t,e,xi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Vc(e,t){if(!Fo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Kc(e,t,n){if(Jg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Vc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Qg(e,t,n,r=0){return r>0&&(t=Math.max(t,Wc(e,r,xi).offset)),Lc(Gg(e,t,n,Zg),nx)}function ex(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Dt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ue(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((m,g)=>Ut(Ut(m,g,h),g+1,p),i)}else[i,a]=Xg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:f}=bi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ut(h,p,Yr(p,f,o)),xr()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:f,sizeTree:i}}function tx(e){return Yn(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 qc(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 bi(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=$o(o,t-1,xi),a=o[c].offset;const l=nn(n,t-1);s=l[0],i=l[1],o.length&&o[c].size===nn(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:l,value:u}of Do(n,t,1/0)){const f=l-s,h=f*i+a+f*r;o.push({index:l,offset:h,size:u}),s=l,a=h,i=u}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function nx(e){return{index:e.index,value:e}}function rx(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 ox={offsetHeight:"height",offsetWidth:"width"},fn=Re(([{log:e},{recalcInProgress:t}])=>{const n=Oe(),r=Oe(),o=vt(r,0),s=Oe(),i=Oe(),a=re(0),c=re([]),l=re(void 0),u=re(void 0),f=re((k,S)=>jn(k,ox[S])),h=re(void 0),p=re(0),m=Yg(),g=vt(ee(n,Ne(c,e,p),dn(ex,m),Je()),m),b=vt(ee(c,Je(),dn((k,S)=>({current:S,prev:k.current}),{current:[],prev:[]}),ce(({prev:k})=>k)),[]);me(ee(c,ye(k=>k.length>0),Ne(g,p),ce(([k,S,E])=>{const j=k.reduce((_,D,L)=>Ut(_,D,Yr(D,S.offsetTree,E)||L),xr());return{...S,groupIndices:k,groupOffsetTree:j}})),g),me(ee(r,Ne(g),ye(([k,{lastIndex:S}])=>k<S),ce(([k,{lastIndex:S,lastSize:E}])=>[{endIndex:S,size:E,startIndex:k}])),n),me(l,u);const v=vt(ee(l,ce(k=>k===void 0)),!0);me(ee(u,ye(k=>k!==void 0&&Ue(lt(g).sizeTree)),ce(k=>[{endIndex:0,size:k,startIndex:0}])),n);const y=Ht(ee(n,Ne(g),dn(({sizes:k},[S,E])=>({changed:E!==k,sizes:E}),{changed:!1,sizes:m}),ce(k=>k.changed)));De(ee(a,dn((k,S)=>({diff:k.prev-S,prev:S}),{diff:0,prev:0}),ce(k=>k.diff)),k=>{const{groupIndices:S}=lt(g);if(k>0)Ae(t,!0),Ae(s,k+qc(k,S));else if(k<0){const E=lt(b);E.length>0&&(k-=qc(-k,E)),Ae(i,k)}}),De(ee(a,Ne(e)),([k,S])=>{k<0&&S("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Dt.ERROR)});const T=Ht(s);me(ee(s,Ne(g),ce(([k,S])=>{const E=S.groupIndices.length>0,j=[],_=S.lastSize;if(E){const D=qr(S.sizeTree,0);let L=0,W=0;for(;L<k;){const $=S.groupIndices[W],Z=S.groupIndices.length===W+1?1/0:S.groupIndices[W+1]-$-1;j.push({endIndex:$,size:D,startIndex:$}),j.push({endIndex:$+1+Z-1,size:_,startIndex:$+1}),W++,L+=Z+1}const V=Yn(S.sizeTree);return L!==k&&V.shift(),V.reduce(($,{k:Z,v:X})=>{let oe=$.ranges;return $.prevSize!==0&&(oe=[...$.ranges,{endIndex:Z+k-1,size:$.prevSize,startIndex:$.prevIndex}]),{prevIndex:Z+k,prevSize:X,ranges:oe}},{prevIndex:k,prevSize:0,ranges:j}).ranges}return Yn(S.sizeTree).reduce((D,{k:L,v:W})=>({prevIndex:L+k,prevSize:W,ranges:[...D.ranges,{endIndex:L+k-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const I=Ht(ee(i,Ne(g,p),ce(([k,{offsetTree:S},E])=>{const j=-k;return Yr(j,S,E)})));return me(ee(i,Ne(g,p),ce(([k,S,E])=>{if(S.groupIndices.length>0){if(Ue(S.sizeTree))return S;let j=xr();const _=lt(b);let D=0,L=0,W=0;for(;D<-k;){W=_[L];const V=_[L+1]-W-1;L++,D+=V+1}if(j=Yn(S.sizeTree).reduce((V,{k:$,v:Z})=>Ut(V,Math.max(0,$+k),Z),j),D!==-k){const V=qr(S.sizeTree,W);j=Ut(j,0,V);const $=nn(S.sizeTree,-k+1)[1];j=Ut(j,1,$)}return{...S,sizeTree:j,...bi(S.offsetTree,0,j,E)}}else{const j=Yn(S.sizeTree).reduce((_,{k:D,v:L})=>Ut(_,Math.max(0,D+k),L),xr());return{...S,sizeTree:j,...bi(S.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:T,data:h,defaultItemSize:u,firstItemIndex:a,fixedItemSize:l,gap:p,groupIndices:c,itemSize:f,listRefresh:y,shiftWith:i,shiftWithOffset:I,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:v,unshiftWith:s}},Xe(_n,gi),{singleton:!0});function sx(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Gc=Re(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Oe(),i=Oe(),a=Ht(ee(s,ce(sx)));return me(ee(a,ce(c=>c.totalCount)),n),me(ee(a,ce(c=>c.groupIndices)),e),me(ee(ft(o,t,r),ye(([c,l])=>Fo(l)),ce(([c,l,u])=>nn(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),Je(),ce(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Xe(fn,Nt)),Pn=Re(([{log:e}])=>{const t=re(!1),n=Ht(ee(t,ye(r=>r),Je()));return De(t,r=>{r&<(e)("props updated",{},Dt.DEBUG)}),{didMount:n,propsReady:t}},Xe(_n),{singleton:!0}),ix=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Yc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!ix)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Xr=Re(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:f},{log:h}])=>{const p=Oe(),m=Oe(),g=re(0);let b=null,v=null,y=null;function T(){b&&(b(),b=null),y&&(y(),y=null),v&&(clearTimeout(v),v=null),Ae(c,!1)}return me(ee(p,Ne(n,f,r,g,a,i,h),Ne(e,s,o),ce(([[I,k,S,E,j,_,D,L],W,V,$])=>{const Z=Yc(I),{align:X,behavior:oe,offset:U}=Z,F=E-1,G=Kc(Z,k,F);let H=Yr(G,k.offsetTree,W)+_;X==="end"?(H+=V+nn(k.sizeTree,G)[1]-S+$,G===F&&(H+=D)):X==="center"?H+=(V+nn(k.sizeTree,G)[1]-S+$)/2:H-=j,U&&(H+=U);const A=N=>{T(),N?(L("retrying to scroll to",{location:I},Dt.DEBUG),Ae(p,I)):(Ae(m,!0),L("list did not change, scroll successful",{},Dt.DEBUG))};if(T(),oe==="smooth"){let N=!1;y=De(t,R=>{N=N||R}),b=tn(u,()=>{A(N)})}else b=tn(ee(t,ax(150)),A);return v=setTimeout(()=>{T()},1200),Ae(c,!0),L("scrolling from index to",{behavior:oe,index:G,top:H},Dt.DEBUG),{behavior:oe,top:H}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:g}},Xe(fn,Nt,_n),{singleton:!0});function ax(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function wi(e,t){e==0?t():requestAnimationFrame(()=>{wi(e-1,t)})}function vi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Jr=Re(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=re(!0),c=re(0),l=re(!0);return me(ee(i,Ne(c),ye(([u,f])=>!!f),un(!1)),a),me(ee(i,Ne(c),ye(([u,f])=>!!f),un(!1)),l),De(ee(ft(t,i),Ne(a,n,e,l),ye(([[,u],f,{sizeTree:h},p,m])=>u&&(!Ue(h)||li(p))&&!f&&!m),Ne(c)),([,u])=>{tn(o,()=>{Ae(l,!0)}),wi(4,()=>{tn(r,()=>{Ae(a,!0)}),Ae(s,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Xe(fn,Nt,Xr,Pn),{singleton:!0});function Xc(e,t){return Math.abs(e-t)<1.01}const Zr="up",Qr="down",lx="none",cx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ux=0,eo=Re(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=re(!1),a=re(!0),c=Oe(),l=Oe(),u=re(4),f=re(ux),h=vt(ee(ui(ee(ve(o),qn(1),un(!0)),ee(ve(o),qn(1),un(!1),Oc(100))),Je()),!1),p=vt(ee(ui(ee(n,un(!0)),ee(n,un(!1),Oc(200))),Je()),!1);me(ee(ft(ve(o),ve(f)),ce(([y,T])=>y<=T),Je()),a),me(ee(a,yn(50)),l);const m=Ht(ee(ft(r,ve(s),ve(t),ve(e),ve(u)),dn((y,[{scrollHeight:T,scrollTop:I},k,S,E,j])=>{const _=I+k-T>-j,D={scrollHeight:T,scrollTop:I,viewportHeight:k};if(_){let W,V;return I>y.state.scrollTop?(W="SCROLLED_DOWN",V=y.state.scrollTop-I):(W="SIZE_DECREASED",V=y.state.scrollTop-I||y.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:V,state:D}}let L;return D.scrollHeight>y.state.scrollHeight?L="SIZE_INCREASED":k<y.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":I<y.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:D}},cx),Je((y,T)=>y&&y.atBottom===T.atBottom))),g=vt(ee(r,dn((y,{scrollHeight:T,scrollTop:I,viewportHeight:k})=>{if(Xc(y.scrollHeight,T))return{changed:!1,jump:0,scrollHeight:T,scrollTop:I};{const S=T-(I+k)<1;return y.scrollTop!==I&&S?{changed:!0,jump:y.scrollTop-I,scrollHeight:T,scrollTop:I}:{changed:!0,jump:0,scrollHeight:T,scrollTop:I}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(y=>y.changed),ce(y=>y.jump)),0);me(ee(m,ce(y=>y.atBottom)),i),me(ee(i,yn(50)),c);const b=re(Qr);me(ee(r,ce(({scrollTop:y})=>y),Je(),dn((y,T)=>lt(p)?{direction:y.direction,prevScrollTop:T}:{direction:T<y.prevScrollTop?Zr:Qr,prevScrollTop:T},{direction:Qr,prevScrollTop:0}),ce(y=>y.direction)),b),me(ee(r,yn(50),un(lx)),b);const v=re(0);return me(ee(h,ye(y=>!y),un(0)),v),me(ee(o,yn(100),Ne(h),ye(([y,T])=>!!T),dn(([y,T],[I])=>[T,I],[0,0]),ce(([y,T])=>T-y)),v),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:g,scrollDirection:b,scrollVelocity:v}},Xe(Nt)),zo="top",Bo="bottom",Jc="none";function Zc(e,t,n){return typeof e=="number"?n===Zr&&t===zo||n===Qr&&t===Bo?e:0:n===Zr?t===zo?e.main:e.reverse:t===Bo?e.main:e.reverse}function Qc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const yi=Re(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Oe(),i=re(0),a=re(0),c=re(0),l=vt(ee(ft(ve(r),ve(o),ve(n),ve(s,Gr),ve(c),ve(i),ve(t),ve(e),ve(a)),ce(([u,f,h,[p,m],g,b,v,y,T])=>{const I=u-y,k=b+v,S=Math.max(h-I,0);let E=Jc;const j=Qc(T,zo),_=Qc(T,Bo);return p-=y,p+=h+v,m+=h+v,m-=y,p>u+k-j&&(E=Zr),m<u-S+f+_&&(E=Qr),E!==Jc?[Math.max(I-h-Zc(g,zo,E)-j,0),I-S-v+f+Zc(g,Bo,E)+_]:null}),ye(u=>u!=null),Je(Gr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:l}},Xe(Nt),{singleton:!0});function dx(e,t,n){if(Fo(t)){const r=Vc(e,t);return[{index:nn(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 Si={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ho(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let l=0,u=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];u=g.offset+g.size}const f=n-i,h=a+f*c+(f-1)*r,p=l,m=h-u;return{bottom:u,firstItemIndex:s,items:tu(e,o,s),offsetBottom:m,offsetTop:l,top:p,topItems:tu(t,o,s),topListHeight:t.reduce((g,b)=>b.size+g,0),totalCount:n}}function eu(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const u of n.groupIndices){if(u-i>=e)break;i++}const a=e+i,c=vi(t,a),l=Array.from({length:a}).map((u,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return Ho(l,[],a,o,n,r)}function tu(e,t,n){if(e.length===0)return[];if(!Fo(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Do(t.groupOffsetTree,r,o);let a,c=0;for(const l of e){(!a||a.end<l.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let u;l.index===a.start?u={index:c,type:"group"}:u={groupIndex:c,index:l.index-(c+1)+n},s.push({...u,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}const Xn=Re(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:f},h,{didMount:p},{recalcInProgress:m}])=>{const g=re([]),b=re(0),v=Oe();me(s.topItemsIndexes,g);const y=vt(ee(ft(p,m,ve(c,Gr),ve(o),ve(r),ve(l),u,ve(g),ve(t),ve(n),e),ye(([S,E,,j,,,,,,,_])=>{const D=_&&_.length!==j;return S&&!E&&!D}),ce(([,,[S,E],j,_,D,L,W,V,$,Z])=>{const X=_,{offsetTree:oe,sizeTree:U}=X,F=lt(b);if(j===0)return{...Si,totalCount:j};if(S===0&&E===0)return F===0?{...Si,totalCount:j}:eu(F,D,_,V,$,Z||[]);if(Ue(U))return F>0?null:Ho(dx(vi(D,j),X,Z),[],j,$,X,V);const G=[];if(W.length>0){const M=W[0],q=W[W.length-1];let J=0;for(const P of Do(U,M,q)){const K=P.value,te=Math.max(P.start,M),le=Math.min(P.end,q);for(let he=te;he<=le;he++)G.push({data:Z==null?void 0:Z[he],index:he,offset:J,size:K}),J+=K}}if(!L)return Ho([],G,j,$,X,V);const H=W.length>0?W[W.length-1]+1:0,A=Qg(oe,S,E,H);if(A.length===0)return null;const N=j-1,R=Mo([],M=>{for(const q of A){const J=q.value;let P=J.offset,K=q.start;const te=J.size;if(J.offset<S){K+=Math.floor((S-J.offset+$)/(te+$));const he=K-q.start;P+=he*te+he*$}K<H&&(P+=(H-K)*te,K=H);const le=Math.min(q.end,N);for(let he=K;he<=le&&!(P>=E);he++)M.push({data:Z==null?void 0:Z[he],index:he,offset:P,size:te}),P+=te+$}});return Ho(R,G,j,$,X,V)}),ye(S=>S!==null),Je()),Si);me(ee(e,ye(li),ce(S=>S==null?void 0:S.length)),o),me(ee(y,ce(S=>S.topListHeight)),f),me(f,a),me(ee(y,ce(S=>[S.top,S.bottom])),i),me(ee(y,ce(S=>S.items)),v);const T=Ht(ee(y,ye(({items:S})=>S.length>0),Ne(o,e),ye(([{items:S},E])=>S[S.length-1].originalIndex===E-1),ce(([,S,E])=>[S-1,E]),Je(Gr),ce(([S])=>S))),I=Ht(ee(y,yn(200),ye(({items:S,topItems:E})=>S.length>0&&S[0].originalIndex===E.length),ce(({items:S})=>S[0].index),Je())),k=Ht(ee(y,ye(({items:S})=>S.length>0),ce(({items:S})=>{let E=0,j=S.length-1;for(;S[E].type==="group"&&E<j;)E++;for(;S[j].type==="group"&&j>E;)j--;return{endIndex:S[j].index,startIndex:S[E].index}}),Je(Uc)));return{endReached:T,initialItemCount:b,itemsRendered:v,listState:y,rangeChanged:k,startReached:I,topItemsIndexes:g,...h}},Xe(fn,Gc,yi,Jr,Xr,eo,Pn,gi),{singleton:!0}),nu=Re(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Oe(),i=vt(ee(ft(n,e,r,t,o),ce(([a,c,l,u,f])=>a+c+l+u+f.offsetBottom+f.bottom)),0);return me(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},Xe(Nt,Xn),{singleton:!0}),fx=Re(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=vt(ee(ft(n,e,t),ye(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),yn(0),Je()),0);return{alignToBottom:n,paddingTopAddition:r}},Xe(Nt,nu),{singleton:!0}),ru=Re(()=>({context:re(null)})),hx=({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,ou=Re(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:l}])=>{const u=Oe();return me(ee(u,Ne(t,c,n,s,o,r,a),Ne(e),ce(([[f,h,p,m,g,b,v,y],T])=>{const{align:I,behavior:k,calculateViewLocation:S=hx,done:E,...j}=f,_=Kc(f,h,m-1),D=Yr(_,h.offsetTree,T)+g+b,L=D+nn(h.sizeTree,_)[1],W=y+b,V=y+p-v,$=S({itemBottom:L,itemTop:D,locationParams:{align:I,behavior:k,...j},viewportBottom:V,viewportTop:W});return $?E&&tn(ee(i,ye(Z=>!Z),qn(lt(i)?1:2)),E):E&&E(),$}),ye(f=>f!==null)),l),{scrollIntoView:u}},Xe(fn,Nt,Xr,Xn,_n),{singleton:!0});function su(e){return e?e==="smooth"?"smooth":"auto":!1}const px=(e,t)=>typeof e=="function"?su(e(t)):t&&su(e),mx=Re(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const m=re(!1),g=Oe();let b=null;function v(k){Ae(i,{align:"end",behavior:k,index:"LAST"})}De(ee(ft(ee(ve(t),qn(1)),c),Ne(ve(m),s,a,f),ce(([[k,S],E,j,_,D])=>{let L=S&&_,W="auto";return L&&(W=px(E,j||D),L=L&&!!W),{followOutputBehavior:W,shouldFollow:L,totalCount:k}}),ye(({shouldFollow:k})=>k)),({followOutputBehavior:k,totalCount:S})=>{b&&(b(),b=null),lt(n)?requestAnimationFrame(()=>{lt(u)("following output to ",{totalCount:S},Dt.DEBUG),v(k)}):b=tn(e,()=>{lt(u)("following output to ",{totalCount:S},Dt.DEBUG),v(k),b=null})});function y(k){const S=tn(o,E=>{k&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!b&&(lt(u)("scrolling to bottom due to increased size",{},Dt.DEBUG),v("auto"))});setTimeout(S,100)}De(ee(ft(ve(m),t,l),ye(([k,,S])=>k&&S),dn(({value:k},[,S])=>({refreshed:k===S,value:S}),{refreshed:!1,value:0}),ye(({refreshed:k})=>k),Ne(m,t)),([,k])=>{lt(a)&&y(k!==!1)}),De(g,()=>{y(lt(m)!==!1)}),De(ft(ve(m),o),([k,S])=>{k&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const T=re(null),I=Oe();return me(ui(ee(ve(r),ce(k=>{var S;return(S=k==null?void 0:k.length)!=null?S:0})),ee(ve(t))),I),De(ee(ft(ee(I,qn(1)),c),Ne(ve(T),a,f,h),ce(([[k,S],E,j,_,D])=>S&&j&&(E==null?void 0:E({context:D,totalCount:k,scrollingInProgress:_}))),ye(k=>!!k),yn(0)),k=>{b&&(b(),b=null),lt(n)?requestAnimationFrame(()=>{lt(u)("scrolling into view",{}),Ae(p,k)}):b=tn(e,()=>{lt(u)("scrolling into view",{}),Ae(p,k),b=null})}),{autoscrollToBottom:g,followOutput:m,scrollIntoViewOnChange:T}},Xe(fn,eo,Xr,Jr,Pn,_n,Nt,ru,ou)),gx=Re(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(ee(a,Ne(s),ye(([,c])=>c!==0),Ne(o,r,t,n,e),ce(([[,c],l,u,f,h,p=[]])=>eu(c,l,u,f,h,p))),i),{}),Xe(fn,Jr,Xn,Pn),{singleton:!0}),xx=Re(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return De(ee(e,Ne(r),ye(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{tn(ee(n,qn(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ae(t,o)})})}),{initialScrollTop:r}},Xe(Pn,Nt,Xn),{singleton:!0}),iu=Re(([{scrollVelocity:e}])=>{const t=re(!1),n=Oe(),r=re(!1);return me(ee(e,Ne(r,t,n),ye(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:c,exit:l}=s;if(i){if(l(o,a))return!1}else if(c(o,a))return!0;return i}),Je()),t),De(ee(ft(t,e,n),Ne(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Xe(eo),{singleton:!0}),Ci=Re(([{scrollContainerState:e,scrollTo:t}])=>{const n=Oe(),r=Oe(),o=Oe(),s=re(!1),i=re(void 0);return me(ee(ft(n,r),ce(([{scrollHeight:a,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:a,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),me(ee(t,Ne(r),ce(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Xe(Nt)),bx=Re(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const l=Oe(),u=re(void 0),f=re(null),h=re(null);return me(a,f),me(c,h),De(ee(l,Ne(t,r,i,f,h,n)),([p,m,g,b,v,y,T])=>{const I=tx(m.sizeTree);b&&v!==null&&y!==null&&(g=v.scrollTop-y.offsetTop),g-=T,p({ranges:I,scrollTop:g})}),me(ee(u,ye(li),ce(wx)),o),me(ee(s,Ne(u),ye(([,p])=>p!==void 0),Je(),ce(([,p])=>p.ranges)),e),{getState:l,restoreStateFrom:u}},Xe(fn,Nt,Jr,Pn,Ci));function wx(e){return{align:"start",index:0,offset:e.scrollTop}}const vx=Re(([{topItemsIndexes:e}])=>{const t=re(0);return me(ee(t,ye(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Xe(Xn));function au(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const yx=au(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sx=Re(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:m}])=>{const g=Ht(ee(c,Ne(i),dn(([,v,y,T],[{bottom:I,items:k,offsetBottom:S,totalCount:E},j])=>{const _=I+S;let D=0;return y===E&&v.length>0&&k.length>0&&(k[0].originalIndex===0&&v[0].originalIndex===0||(D=_-T,D!==0&&(D+=j))),[D,k,E,_]},[0,[],0,0]),ye(([v])=>v!==0),Ne(r,a,n,o,p,m),ye(([,v,y,T,,,I])=>!I&&!T&&v!==0&&y===Zr),ce(([[v],,,,,y])=>(y("Upward scrolling compensation",{amount:v},Dt.DEBUG),v))));function b(v){v>0?(Ae(t,{behavior:"auto",top:-v}),Ae(e,0)):(Ae(e,0),Ae(t,{behavior:"auto",top:-v}))}return De(ee(g,Ne(e,s)),([v,y,T])=>{T&&yx()?Ae(e,y-v):b(-v)}),De(ee(ft(vt(s,!1),e,m),ye(([v,y,T])=>!v&&!T&&y!==0),ce(([v,y])=>y),yn(1)),b),me(ee(f,ce(v=>({top:-v}))),t),De(ee(l,Ne(h,u),ce(([v,{groupIndices:y,lastSize:T,sizeTree:I},k])=>{function S(E){return E*(T+k)}if(y.length===0)return S(v);{let E=0;const j=qr(I,0);let _=0,D=0;for(;_<v;){_++,E+=j;let L=y.length===D+1?1/0:y[D+1]-y[D]-1;_+L>v&&(E-=j,L=v-_+1),_+=L,E+=S(L),D++}return E}})),v=>{Ae(e,v),requestAnimationFrame(()=>{Ae(t,{top:v}),requestAnimationFrame(()=>{Ae(e,0),Ae(m,!1)})})}),{deviation:e}},Xe(Nt,eo,Xn,fn,_n,gi)),Cx=Re(([e,t,n,r,o,s,i,a,c,l,u])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...l,...u}),Xe(yi,gx,Pn,iu,nu,xx,fx,Ci,ou,_n,ru)),lu=Re(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:l,totalCount:u,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m},g,b,v,{listState:y,topItemsIndexes:T,...I},{scrollToIndex:k},S,{topItemCount:E},{groupCounts:j},_])=>(me(I.rangeChanged,_.scrollSeekRangeChanged),me(ee(_.windowViewportRect,ce(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m,sizeRanges:a,topItemCount:E,topItemsIndexes:T,totalCount:u,...v,groupIndices:s,itemSize:i,listState:y,scrollToIndex:k,statefulTotalCount:l,trackItemSizes:f,...I,..._,...g,sizes:c,...b}),Xe(fn,Jr,Nt,bx,mx,Xn,Xr,Sx,vx,Gc,Cx));function kx(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 Uo=typeof document<"u"?x.useLayoutEffect:x.useEffect;function cu(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=x.createContext({});function c(b,v){b.propsReady&&Ae(b.propsReady,!1);for(const y of r){const T=b[t.required[y]];Ae(T,v[y])}for(const y of o)if(y in v){const T=b[t.optional[y]];Ae(T,v[y])}b.propsReady&&Ae(b.propsReady,!0)}function l(b){return s.reduce((v,y)=>(v[y]=T=>{const I=b[t.methods[y]];Ae(I,T)},v),{})}function u(b){return i.reduce((v,y)=>(v[y]=zg(b[t.events[y]]),v),{})}const f=x.forwardRef((b,v)=>{const{children:y,...T}=b,[I]=x.useState(()=>Mo(Hg(e),E=>{c(E,T)})),[k]=x.useState(Pc(u,I));Uo(()=>{for(const E of i)E in T&&De(k[E],T[E]);return()=>{Object.values(k).map(ci)}},[T,k,I]),Uo(()=>{c(I,T)}),x.useImperativeHandle(v,_c(l(I)));const S=n;return d.jsx(a.Provider,{value:I,children:n?d.jsx(S,{...kx([...r,...o,...i],T),children:y}):y})}),h=b=>{const v=x.useContext(a);return x.useCallback(y=>{Ae(v[b],y)},[v,b])},p=b=>{const v=x.useContext(a)[b],y=x.useCallback(T=>De(v,T),[v]);return x.useSyncExternalStore(y,()=>lt(v),()=>lt(v))},m=b=>{const v=x.useContext(a)[b],[y,T]=x.useState(Pc(lt,v));return Uo(()=>De(v,I=>{I!==y&&T(_c(I))}),[v,y]),y},g=x.version.startsWith("18")?p:m;return{Component:f,useEmitter:(b,v)=>{const y=x.useContext(a)[b];Uo(()=>De(y,v),[v,y])},useEmitterValue:g,usePublisher:h}}const uu=x.createContext(void 0),du=x.createContext(void 0),fu=typeof document<"u"?x.useLayoutEffect:x.useEffect;function ki(e){return"self"in e}function Tx(e){return"body"in e}function hu(e,t,n,r=gr,o,s){const i=x.useRef(null),a=x.useRef(null),c=x.useRef(null),l=x.useCallback(h=>{let p,m,g;const b=h.target;if(Tx(b)||ki(b)){const y=ki(b)?b:b.defaultView;g=s?y.scrollX:y.scrollY,p=s?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight,m=s?y.innerWidth:y.innerHeight}else g=s?b.scrollLeft:b.scrollTop,p=s?b.scrollWidth:b.scrollHeight,m=s?b.offsetWidth:b.offsetHeight;const v=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:m})};h.suppressFlushSync?v():Ls.flushSync(v),a.current!==null&&(g===a.current||g<=0||g===p-m)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);x.useEffect(()=>{const h=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",l,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",l)}},[i,l,n,r,o]);function u(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const m=h.behavior==="smooth";let g,b,v;ki(p)?(b=Math.max(jn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(b=p[s?"scrollWidth":"scrollHeight"],g=jn(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const y=b-g;if(h.top=Math.ceil(Math.max(Math.min(y,h.top),0)),Xc(g,b)||h.top===v){e({scrollHeight:b,scrollTop:v,viewportHeight:g}),m&&t(!0);return}m?(a.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:u}}const Ti="-webkit-sticky",pu="sticky",Ei=au(()=>{if(typeof document>"u")return pu;const e=document.createElement("div");return e.style.position=Ti,e.style.position===Ti?Ti:pu});function Ii(e){return e}const Ex=Re(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(Ii),o=re("div"),s=re(gr),i=(a,c=null)=>vt(ee(n,ce(l=>l[a]),Je()),c);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")}}),Ix=Re(([e,t])=>({...e,...t}),Xe(lu,Ex)),Ax=({height:e})=>d.jsx("div",{style:{height:e}}),Nx={overflowAnchor:"none",position:Ei(),zIndex:1},mu={overflowAnchor:"none"},_x={...mu,display:"inline-block",height:"100%"},gu=x.memo(function({showTopList:e=!1}){const t=ke("listState"),n=Yt("sizeRanges"),r=ke("useWindowScroll"),o=ke("customScrollParent"),s=Yt("windowScrollContainerState"),i=Yt("scrollContainerState"),a=o||r?s:i,c=ke("itemContent"),l=ke("context"),u=ke("groupContent"),f=ke("trackItemSizes"),h=ke("itemSize"),p=ke("log"),m=Yt("gap"),g=ke("horizontalDirection"),{callbackRef:b}=Vg(n,h,f,e?gr:a,p,m,o,g,ke("skipAnimationFrameInResizeObserver")),[v,y]=x.useState(0);Ai("deviation",$=>{v!==$&&y($)});const T=ke("EmptyPlaceholder"),I=ke("ScrollSeekPlaceholder")||Ax,k=ke("ListComponent"),S=ke("ItemComponent"),E=ke("GroupComponent"),j=ke("computeItemKey"),_=ke("isSeeking"),D=ke("groupIndices").length>0,L=ke("alignToBottom"),W=ke("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&T?d.jsx(T,{...yt(T,l)}):d.jsx(k,{...yt(k,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:b,style:V,children:(e?t.topItems:t.items).map($=>{const Z=$.originalIndex,X=j(Z+t.firstItemIndex,$.data,l);return _?x.createElement(I,{...yt(I,l),height:$.size,index:$.index,key:X,type:$.type||"item",...$.type==="group"?{}:{groupIndex:$.groupIndex}}):$.type==="group"?x.createElement(E,{...yt(E,l),"data-index":Z,"data-item-index":$.index,"data-known-size":$.size,key:X,style:Nx},u($.index,l)):x.createElement(S,{...yt(S,l),...Rx(S,$.data),"data-index":Z,"data-item-group-index":$.groupIndex,"data-item-index":$.index,"data-known-size":$.size,key:X,style:g?_x:mu},D?c($.index,$.groupIndex,$.data,l):c($.index,$.data,l))})})}),jx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Px={outline:"none",overflowX:"auto",position:"relative"},Wo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ox={position:Ei(),top:0,width:"100%",zIndex:1};function yt(e,t){if(typeof e!="string")return{context:t}}function Rx(e,t){return{item:typeof e=="string"?void 0:t}}const Mx=x.memo(function(){const e=ke("HeaderComponent"),t=Yt("headerHeight"),n=ke("HeaderFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null}),Dx=x.memo(function(){const e=ke("FooterComponent"),t=Yt("footerHeight"),n=ke("HeaderFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null});function xu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),u=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:m}=hu(a,l,c,u,void 0,f);return e("scrollTo",m),e("scrollBy",h),d.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Px:jx,...o},tabIndex:0,...i,...yt(c,s),children:r})})}function bu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),u=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=x.useRef(null),m=t("scrollerRef"),{scrollByCallback:g,scrollerRef:b,scrollToCallback:v}=hu(a,l,c,m,h);return fu(()=>{var y;return b.current=h||((y=p.current)==null?void 0:y.ownerDocument.defaultView),()=>{b.current=null}},[b,h]),e("windowScrollTo",v),e("scrollBy",g),d.jsx(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...u!==0?{height:u+f}:{}},...i,...yt(c,s),children:r})})}const Lx=({children:e})=>{const t=x.useContext(uu),n=Yt("viewportHeight"),r=Yt("fixedItemHeight"),o=ke("alignToBottom"),s=ke("horizontalDirection"),i=x.useMemo(()=>jc(n,c=>jn(c,s?"width":"height")),[n,s]),a=Gn(i,!0,ke("skipAnimationFrameInResizeObserver"));return x.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),d.jsx("div",{"data-viewport-type":"element",ref:a,style:Wo(o),children:e})},$x=({children:e})=>{const t=x.useContext(uu),n=Yt("windowViewportRect"),r=Yt("fixedItemHeight"),o=ke("customScrollParent"),s=Dc(n,o,ke("skipAnimationFrameInResizeObserver")),i=ke("alignToBottom");return x.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),d.jsx("div",{"data-viewport-type":"window",ref:s,style:Wo(i),children:e})},Fx=({children:e})=>{const t=ke("TopItemListComponent")||"div",n=ke("headerHeight"),r={...Ox,marginTop:`${n}px`},o=ke("context");return d.jsx(t,{style:r,...yt(t,o),children:e})},zx=x.memo(function(e){const t=ke("useWindowScroll"),n=ke("topItemsIndexes").length>0,r=ke("customScrollParent"),o=ke("context");return d.jsxs(r||t?Ux:Hx,{...e,context:o,children:[n&&d.jsx(Fx,{children:d.jsx(gu,{showTopList:!0})}),d.jsxs(r||t?$x:Lx,{children:[d.jsx(Mx,{}),d.jsx(gu,{}),d.jsx(Dx,{})]})]})}),{Component:Bx,useEmitter:Ai,useEmitterValue:ke,usePublisher:Yt}=cu(Ix,{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"}},zx),Hx=xu({useEmitter:Ai,useEmitterValue:ke,usePublisher:Yt}),Ux=bu({useEmitter:Ai,useEmitterValue:ke,usePublisher:Yt}),Wx=Bx;Xe(lu,Re(()=>{const e=re(l=>d.jsxs("td",{children:["Item $",l]})),t=re(null),n=re(l=>d.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=re(null),o=re(null),s=re({}),i=re(Ii),a=re(gr),c=(l,u=null)=>vt(ee(s,ce(f=>f[l]),Je()),u);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),Ei();const wu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Vx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:vu,floor:Vo,max:to,min:Ni,round:yu}=Math;function Su(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Kx(e){return{...Vx,items:e}}function Ko(e,t){return e&&e.width===t.width&&e.height===t.height}function qx(e,t){return e&&e.column===t.column&&e.row===t.row}const Gx=Re(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:f},h,p,{didMount:m,propsReady:g},{customScrollParent:b,useWindowScroll:v,windowScrollContainerState:y,windowScrollTo:T,windowViewportRect:I},k])=>{const S=re(0),E=re(0),j=re(wu),_=re({height:0,width:0}),D=re({height:0,width:0}),L=Oe(),W=Oe(),V=re(0),$=re(null),Z=re({column:0,row:0}),X=Oe(),oe=Oe(),U=re(!1),F=re(0),G=re(!0),H=re(!1),A=re(!1);De(ee(m,Ne(F),ye(([P,K])=>!!K)),()=>{Ae(G,!1)}),De(ee(ft(m,G,D,_,F,H),ye(([P,K,te,le,,he])=>P&&!K&&te.height!==0&&le.height!==0&&!he)),([,,,,P])=>{Ae(H,!0),wi(1,()=>{Ae(L,P)}),tn(ee(l),()=>{Ae(t,[0,0]),Ae(G,!0)})}),me(ee(oe,ye(P=>P!=null&&P.scrollTop>0),un(0)),E),De(ee(m,Ne(oe),ye(([,P])=>P!=null)),([,P])=>{P&&(Ae(_,P.viewport),Ae(D,P.item),Ae(Z,P.gap),P.scrollTop>0&&(Ae(U,!0),tn(ee(l,qn(1)),K=>{Ae(U,!1)}),Ae(c,{top:P.scrollTop})))}),me(ee(_,ce(({height:P})=>P)),f),me(ee(ft(ve(_,Ko),ve(D,Ko),ve(Z,(P,K)=>P&&P.column===K.column&&P.row===K.row),ve(l)),ce(([P,K,te,le])=>({gap:te,item:K,scrollTop:le,viewport:P}))),X),me(ee(ft(ve(S),r,ve(Z,qx),ve(D,Ko),ve(_,Ko),ve($),ve(E),ve(U),ve(G),ve(F)),ye(([,,,,,,,P])=>!P),ce(([P,[K,te],le,he,ue,ge,be,,Be,Le])=>{const{column:je,row:Fe}=le,{height:tt,width:mt}=he,{width:ot}=ue;if(be===0&&(P===0||ot===0))return wu;if(mt===0){const st=vi(Le,P),an=st+Math.max(be-1,0);return Kx(Su(st,an,ge))}const ze=Cu(ot,mt,je);let Me,Ze;Be?K===0&&te===0&&be>0?(Me=0,Ze=be-1):(Me=ze*Vo((K+Fe)/(tt+Fe)),Ze=ze*vu((te+Fe)/(tt+Fe))-1,Ze=Ni(P-1,to(Ze,ze-1)),Me=Ni(Ze,to(0,Me))):(Me=0,Ze=-1);const rt=Su(Me,Ze,ge),{bottom:qe,top:ht}=ku(ue,le,he,rt),xt=vu(P/ze),He=xt*tt+(xt-1)*Fe-qe;return{bottom:qe,itemHeight:tt,items:rt,itemWidth:mt,offsetBottom:He,offsetTop:ht,top:ht}})),j),me(ee($,ye(P=>P!==null),ce(P=>P.length)),S),me(ee(ft(_,D,j,Z),ye(([P,K,{items:te}])=>te.length>0&&K.height!==0&&P.height!==0),ce(([P,K,{items:te},le])=>{const{bottom:he,top:ue}=ku(P,le,K,te);return[ue,he]}),Je(Gr)),t);const N=re(!1);me(ee(l,Ne(N),ce(([P,K])=>K||P!==0)),N);const R=Ht(ee(ft(j,S),ye(([{items:P}])=>P.length>0),Ne(N),ye(([[P,K],te])=>{const le=P.items[P.items.length-1].index===K-1;return(te||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===K)&&le}),ce(([[,P]])=>P-1),Je())),M=Ht(ee(ve(j),ye(({items:P})=>P.length>0&&P[0].index===0),un(0),Je())),q=Ht(ee(ve(j),Ne(U),ye(([{items:P},K])=>P.length>0&&!K),ce(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),Je(Uc),yn(0)));me(q,p.scrollSeekRangeChanged),me(ee(L,Ne(_,D,S,Z),ce(([P,K,te,le,he])=>{const ue=Yc(P),{align:ge,behavior:be,offset:Be}=ue;let Le=ue.index;Le==="LAST"&&(Le=le-1),Le=to(0,Le,Ni(le-1,Le));let je=_i(K,he,te,Le);return ge==="end"?je=yu(je-K.height+te.height):ge==="center"&&(je=yu(je-K.height/2+te.height/2)),Be&&(je+=Be),{behavior:be,top:je}})),c);const J=vt(ee(j,ce(P=>P.offsetBottom+P.bottom)),0);return me(ee(I,ce(P=>({height:P.visibleHeight,width:P.visibleWidth}))),_),{customScrollParent:b,data:$,deviation:V,footerHeight:o,gap:Z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:oe,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:c,scrollToIndex:L,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:v,viewportDimensions:_,windowScrollContainerState:y,windowScrollTo:T,windowViewportRect:I,...p,gridState:j,horizontalDirection:A,initialTopMostItemIndex:F,totalListHeight:J,...h,endReached:R,propsReady:g,rangeChanged:q,startReached:M,stateChanged:X,stateRestoreInProgress:U,...k}},Xe(yi,Nt,eo,iu,Pn,Ci,_n));function Cu(e,t,n){return to(1,Vo((e+n)/(Vo(t)+n)))}function ku(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=_i(e,t,n,r[0].index);return{bottom:_i(e,t,n,r[r.length-1].index)+o,top:s}}function _i(e,t,n,r){const o=Cu(e.width,n.width,t.column),s=Vo(r/o),i=s*n.height+to(0,s-1)*t.row;return i>0?i+t.row:i}const Yx=Re(()=>{const e=re(f=>`Item ${f}`),t=re({}),n=re(null),r=re("virtuoso-grid-item"),o=re("virtuoso-grid-list"),s=re(Ii),i=re("div"),a=re(gr),c=(f,h=null)=>vt(ee(t,ce(p=>p[f]),Je()),h),l=re(!1),u=re(!1);return me(ve(u),l),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Xx=Re(([e,t])=>({...e,...t}),Xe(Gx,Yx)),Jx=x.memo(function(){const e=Qe("gridState"),t=Qe("listClassName"),n=Qe("itemClassName"),r=Qe("itemContent"),o=Qe("computeItemKey"),s=Qe("isSeeking"),i=Xt("scrollHeight"),a=Qe("ItemComponent"),c=Qe("ListComponent"),l=Qe("ScrollSeekPlaceholder"),u=Qe("context"),f=Xt("itemDimensions"),h=Xt("gap"),p=Qe("log"),m=Qe("stateRestoreInProgress"),g=Xt("reportReadyState"),b=Gn(x.useMemo(()=>v=>{const y=v.parentElement.parentElement.scrollHeight;i(y);const T=v.firstChild;if(T){const{height:I,width:k}=T.getBoundingClientRect();f({height:I,width:k})}h({column:Eu("column-gap",getComputedStyle(v).columnGap,p),row:Eu("row-gap",getComputedStyle(v).rowGap,p)})},[i,f,h,p]),!0,!1);return fu(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),m?null:d.jsx(c,{className:t,ref:b,...yt(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const y=o(v.index,v.data,u);return s?d.jsx(l,{...yt(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},y):x.createElement(a,{...yt(a,u),className:n,"data-index":v.index,key:y},r(v.index,v.data,u))})})}),Zx=x.memo(function(){const e=Qe("HeaderComponent"),t=Xt("headerHeight"),n=Qe("headerFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null}),Qx=x.memo(function(){const e=Qe("FooterComponent"),t=Xt("footerHeight"),n=Qe("headerFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null}),eb=({children:e})=>{const t=x.useContext(du),n=Xt("itemDimensions"),r=Xt("viewportDimensions"),o=Gn(x.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return x.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),d.jsx("div",{ref:o,style:Wo(!1),children:e})},tb=({children:e})=>{const t=x.useContext(du),n=Xt("windowViewportRect"),r=Xt("itemDimensions"),o=Qe("customScrollParent"),s=Dc(n,o,!1);return x.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),d.jsx("div",{ref:s,style:Wo(!1),children:e})},nb=x.memo(function({...e}){const t=Qe("useWindowScroll"),n=Qe("customScrollParent"),r=n||t?ob:rb,o=n||t?tb:eb,s=Qe("context");return d.jsx(r,{...e,...yt(r,s),children:d.jsxs(o,{children:[d.jsx(Zx,{}),d.jsx(Jx,{}),d.jsx(Qx,{})]})})}),{useEmitter:Tu,useEmitterValue:Qe,usePublisher:Xt}=cu(Xx,{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"}},nb),rb=xu({useEmitter:Tu,useEmitterValue:Qe,usePublisher:Xt}),ob=bu({useEmitter:Tu,useEmitterValue:Qe,usePublisher:Xt});function Eu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Dt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Se(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 Iu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Iu(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():Iu(e[o],null)}}}}function et(...e){return w.useCallback(On(...e),e)}function sb(e,t){const n=w.createContext(t),r=s=>{const{children:i,...a}=s,c=w.useMemo(()=>a,Object.values(a));return d.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=w.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 Rn(e,t=[]){let n=[];function r(s,i){const a=w.createContext(i),c=n.length;n=[...n,i];const l=f=>{var v;const{scope:h,children:p,...m}=f,g=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,b=w.useMemo(()=>m,Object.values(m));return d.jsx(g.Provider,{value:b,children:p})};l.displayName=s+"Provider";function u(f,h){var g;const p=((g=h==null?void 0:h[e])==null?void 0:g[c])||a,m=w.useContext(p);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[l,u]}const o=()=>{const s=n.map(i=>w.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return w.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,ib(o,...t)]}function ib(...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:c,scopeName:l})=>{const f=c(s)[`__scope${l}`];return{...a,...f}},{});return w.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var hn=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},ab=w[" useId ".trim().toString()]||(()=>{}),lb=0;function Wt(e){const[t,n]=w.useState(ab());return hn(()=>{n(r=>r??String(lb++))},[e]),e||(t?`radix-${t}`:"")}var cb=w[" useInsertionEffect ".trim().toString()]||hn;function qo({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ub({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const u=w.useRef(e!==void 0);w.useEffect(()=>{const f=u.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const l=w.useCallback(u=>{var f;if(a){const h=db(u)?u(e):u;h!==e&&((f=i.current)==null||f.call(i,h))}else s(u)},[a,e,s,i]);return[c,l]}function ub({defaultProp:e,onChange:t}){const[n,r]=w.useState(e),o=w.useRef(n),s=w.useRef(t);return cb(()=>{s.current=t},[t]),w.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function db(e){return typeof e=="function"}var fb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Pe=fb.reduce((e,t)=>{const n=sr.createSlot(`Primitive.${t}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Au(e,t){e&&Ja.flushSync(()=>e.dispatchEvent(t))}function St(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function hb(e,t=globalThis==null?void 0:globalThis.document){const n=St(e);w.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 pb="DismissableLayer",ji="dismissableLayer.update",mb="dismissableLayer.pointerDownOutside",gb="dismissableLayer.focusOutside",Nu,_u=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Pi=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,l=w.useContext(_u),[u,f]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),m=et(t,E=>f(E)),g=Array.from(l.layers),[b]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(b),y=u?g.indexOf(u):-1,T=l.layersWithOutsidePointerEventsDisabled.size>0,I=y>=v,k=wb(E=>{const j=E.target,_=[...l.branches].some(D=>D.contains(j));!I||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),S=vb(E=>{const j=E.target;[...l.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return hb(E=>{y===l.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Nu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),ju(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Nu)}},[u,h,n,l]),w.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),ju())},[u,l]),w.useEffect(()=>{const E=()=>p({});return document.addEventListener(ji,E),()=>document.removeEventListener(ji,E)},[]),d.jsx(Pe.div,{...c,ref:m,style:{pointerEvents:T?I?"auto":"none":void 0,...e.style},onFocusCapture:Se(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Se(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Se(e.onPointerDownCapture,k.onPointerDownCapture)})});Pi.displayName=pb;var xb="DismissableLayerBranch",bb=w.forwardRef((e,t)=>{const n=w.useContext(_u),r=w.useRef(null),o=et(t,r);return w.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(Pe.div,{...e,ref:o})});bb.displayName=xb;function wb(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){Pu(mb,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 vb(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=w.useRef(!1);return w.useEffect(()=>{const o=s=>{s.target&&!r.current&&Pu(gb,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 ju(){const e=new CustomEvent(ji);document.dispatchEvent(e)}function Pu(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?Au(o,s):o.dispatchEvent(s)}var Oi="focusScope.autoFocusOnMount",Ri="focusScope.autoFocusOnUnmount",Ou={bubbles:!1,cancelable:!0},yb="FocusScope",Mi=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=w.useState(null),l=St(o),u=St(s),f=w.useRef(null),h=et(t,g=>c(g)),p=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let g=function(T){if(p.paused||!a)return;const I=T.target;a.contains(I)?f.current=I:Mn(f.current,{select:!0})},b=function(T){if(p.paused||!a)return;const I=T.relatedTarget;I!==null&&(a.contains(I)||Mn(f.current,{select:!0}))},v=function(T){if(document.activeElement===document.body)for(const k of T)k.removedNodes.length>0&&Mn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const y=new MutationObserver(v);return a&&y.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),y.disconnect()}}},[r,a,p.paused]),w.useEffect(()=>{if(a){Du.add(p);const g=document.activeElement;if(!a.contains(g)){const v=new CustomEvent(Oi,Ou);a.addEventListener(Oi,l),a.dispatchEvent(v),v.defaultPrevented||(Sb(Ib(Ru(a)),{select:!0}),document.activeElement===g&&Mn(a))}return()=>{a.removeEventListener(Oi,l),setTimeout(()=>{const v=new CustomEvent(Ri,Ou);a.addEventListener(Ri,u),a.dispatchEvent(v),v.defaultPrevented||Mn(g??document.body,{select:!0}),a.removeEventListener(Ri,u),Du.remove(p)},0)}}},[a,l,u,p]);const m=w.useCallback(g=>{if(!n&&!r||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(b&&v){const y=g.currentTarget,[T,I]=Cb(y);T&&I?!g.shiftKey&&v===I?(g.preventDefault(),n&&Mn(T,{select:!0})):g.shiftKey&&v===T&&(g.preventDefault(),n&&Mn(I,{select:!0})):v===y&&g.preventDefault()}},[n,r,p.paused]);return d.jsx(Pe.div,{tabIndex:-1,...i,ref:h,onKeyDown:m})});Mi.displayName=yb;function Sb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Mn(r,{select:t}),document.activeElement!==n)return}function Cb(e){const t=Ru(e),n=Mu(t,e),r=Mu(t.reverse(),e);return[n,r]}function Ru(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 Mu(e,t){for(const n of e)if(!kb(n,{upTo:t}))return n}function kb(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 Tb(e){return e instanceof HTMLInputElement&&"select"in e}function Mn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Tb(e)&&t&&e.select()}}var Du=Eb();function Eb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Lu(e,t),e.unshift(t)},remove(t){var n;e=Lu(e,t),(n=e[0])==null||n.resume()}}}function Lu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ib(e){return e.filter(t=>t.tagName!=="A")}var Ab="Portal",Di=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=w.useState(!1);hn(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ls.createPortal(d.jsx(Pe.div,{...r,ref:t}),i):null});Di.displayName=Ab;function Nb(e,t){return w.useReducer((n,r)=>t[n][r]??n,e)}var Vt=e=>{const{present:t,children:n}=e,r=_b(t),o=typeof n=="function"?n({present:r.isPresent}):w.Children.only(n),s=et(r.ref,jb(o));return typeof n=="function"||r.isPresent?w.cloneElement(o,{ref:s}):null};Vt.displayName="Presence";function _b(e){const[t,n]=w.useState(),r=w.useRef(null),o=w.useRef(e),s=w.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Nb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{const l=Go(r.current);s.current=a==="mounted"?l:"none"},[a]),hn(()=>{const l=r.current,u=o.current;if(u!==e){const h=s.current,p=Go(l);e?c("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),hn(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,f=p=>{const g=Go(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(c("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},h=p=>{p.target===t&&(s.current=Go(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:w.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function Go(e){return(e==null?void 0:e.animationName)||"none"}function jb(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 Li=0;function $u(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Fu()),document.body.insertAdjacentElement("beforeend",e[1]??Fu()),Li++,()=>{Li===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Li--}},[])}function Fu(){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 pn=function(){return pn=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},pn.apply(this,arguments)};function zu(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 Pb(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 Yo="right-scroll-bar-position",Xo="width-before-scroll-bar",Ob="with-scroll-bars-hidden",Rb="--removed-body-scroll-bar-size";function $i(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Mb(e,t){var n=x.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 Db=typeof window<"u"?w.useLayoutEffect:w.useEffect,Bu=new WeakMap;function Lb(e,t){var n=Mb(null,function(r){return e.forEach(function(o){return $i(o,r)})});return Db(function(){var r=Bu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||$i(a,null)}),s.forEach(function(a){o.has(a)||$i(a,i)})}Bu.set(n,e)},[e]),n}function $b(e){return e}function Fb(e,t){t===void 0&&(t=$b);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 c=function(){var u=i;i=[],u.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return o}function zb(e){e===void 0&&(e={});var t=Fb(null);return t.options=pn({async:!0,ssr:!1},e),t}var Hu=function(e){var t=e.sideCar,n=zu(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 w.createElement(r,pn({},n))};Hu.isSideCarExport=!0;function Bb(e,t){return e.useMedium(t),Hu}var Uu=zb(),Fi=function(){},Jo=w.forwardRef(function(e,t){var n=w.useRef(null),r=w.useState({onScrollCapture:Fi,onWheelCapture:Fi,onTouchMoveCapture:Fi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,b=e.allowPinchZoom,v=e.as,y=v===void 0?"div":v,T=e.gapMode,I=zu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,S=Lb([n,t]),E=pn(pn({},I),o);return w.createElement(w.Fragment,null,u&&w.createElement(k,{sideCar:Uu,removeScrollBar:l,shards:f,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:T}),i?w.cloneElement(w.Children.only(a),pn(pn({},E),{ref:S})):w.createElement(y,pn({},E,{className:c,ref:S}),a))});Jo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Jo.classNames={fullWidth:Xo,zeroRight:Yo};var Hb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ub(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Hb();return t&&e.setAttribute("nonce",t),e}function Wb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Kb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ub())&&(Wb(t,n),Vb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qb=function(){var e=Kb();return function(t,n){w.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wu=function(){var e=qb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Gb={left:0,top:0,right:0,gap:0},zi=function(e){return parseInt(e||"",10)||0},Yb=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[zi(n),zi(r),zi(o)]},Xb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gb;var t=Yb(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])}},Jb=Wu(),br="data-scroll-locked",Zb=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
39
|
+
`)):t(e)}function rg(e){var n;if(e.name&&e.name.trim())return e.name;const t=(n=e.additionalKwargs)==null?void 0:n.agent_name;return typeof t=="string"&&t.trim()?t:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function sc(e){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":return"img";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 ni(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function ic(e){if(e.role!=="assistant")return!1;const t=Array.isArray(e.content)?e.content:Array.isArray(e.parts)?e.parts:[],n=t.some(s=>s.type==="text"&&s.text&&s.text.trim().length>0),r=t.some(s=>s.type==="image"||s.type==="image_url"||s.type==="file"),o=!!e.artifact;return!n&&!r&&!o}function og(e){return e.role==="tool"?!0:e.role==="assistant"?ic(e):!1}function sg(e,t){const n=[],r=e.findIndex(c=>c.id===t);if(r===-1)return n;const o=new Map;let s=0;for(let c=r;c>=0;c--){const l=e[c];if(c<r&&l.role==="assistant"&&!ic(l))break;if(l.role==="assistant"){const u=Array.isArray(l.content)?l.content:Array.isArray(l.parts)?l.parts:[];if(l.tool_calls)for(const f of l.tool_calls)f.id&&f.name&&!o.has(f.id)&&o.set(f.id,{name:f.name,timestamp:l.createdAt,order:s++});for(const f of u)if(f.type==="tool_call"){const h=f;h.id&&h.name&&!o.has(h.id)&&o.set(h.id,{name:h.name,timestamp:l.createdAt,order:s++})}}}if(o.size===0)return n;const i=new Map;for(let c=r+1;c<e.length;c++){const l=e[c];if(l.role==="tool"){const f=jo(l).toolCallId;if(console.log("[buildToolExecutionTimeline] Tool message at index",c,{toolCallId:f,name:l.name,hasMatch:o.has(f||""),toolCallMapKeys:Array.from(o.keys())}),f&&o.has(f)){const h=Array.isArray(l.content)?l.content:Array.isArray(l.parts)?l.parts:[],p=rc(h.filter(m=>m.type==="text"));i.set(f,{content:p||`Finished ${l.name||"tool"}`,artifact:l.artifact,timestamp:l.createdAt})}}}const a=Array.from(o.entries()).sort((c,l)=>c[1].order-l[1].order);for(const[c,l]of a){const u=i.get(c);u?(n.push({type:"tool.start",toolName:l.name,toolCallId:c,content:`Starting ${l.name}...`,timestamp:l.timestamp}),n.push({type:"tool.end",toolName:l.name,toolCallId:c,content:u.content,timestamp:u.timestamp,output:u.content,artifact:u.artifact})):n.push({type:"tool.start",toolName:l.name,toolCallId:c,content:`Starting ${l.name}...`,timestamp:l.timestamp})}return n}function hr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=dr(t);return n!==null?hr(n):t}if(Array.isArray(e))return e.map(t=>hr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return hr(t)}return e}function ac(e){const t=hr(e.value);return t===e.value?e:{...e,value:t}}function Po(e){const t=e.artifact;return!t||typeof t!="object"?null:"metadata"in t&&t.metadata?t.metadata:{id:t.id??e.id??`artifact-${Date.now()}`,type:t.type??"unknown",created_at:e.createdAt??new Date().toISOString(),status:t.status??"completed",progress:t.progress??void 0}}function ig(e){if(!e||typeof e!="object")return!1;const t=Po({artifact:e});return!!(t&&t.status==="in_progress"&&(t.progress??0)<100)}function ag(e,t){const n=Po(e);if(!n)return e;const r={...n,...t,updated_at:new Date().toISOString()};return{...e,artifact:{...typeof e.artifact=="object"&&e.artifact?e.artifact:{},metadata:r}}}function lg(e,t){return e.find(n=>{const r=Po(n);return(r==null?void 0:r.id)===t})??null}function Oo(e){return e.filter(t=>{var c;if(t.role!=="assistant")return!0;const n=t.content,r=typeof n=="string"?n.trim().length>0:Array.isArray(n)&&n.some(l=>{var u;return l&&l.type==="text"&&((u=l.text)==null?void 0:u.trim())}),o=Array.isArray(n)&&n.some(l=>l&&l.type==="image"),s=t.artifact!==null&&t.artifact!==void 0,i=((c=t.tool_calls)==null?void 0:c.length)>0,a=Array.isArray(n)&&n.some(l=>l&&["file","tool_call","interrupt"].includes(l.type));return!!(r||o||s||i||a)})}function Hr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function cg(e){let t=!1;const n=e.map(r=>{var s;const o=(r.content??[]).filter(i=>i.type!=="interrupt");return o.length!==((s=r.parts)==null?void 0:s.length)?(t=!0,{...r,content:o}):r});return t?n:e}function ug(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 Hr(e,r,s)}return e}function dg(e){const t=new Map,n=[];return e.slice().sort((r,o)=>{const s=r.createdAt?Date.parse(r.createdAt):0,i=o.createdAt?Date.parse(o.createdAt):0;return s-i}).forEach(r=>{const o=Array.isArray(r.messages)?r.messages:[];for(const s of o)!(s!=null&&s.id)||t.has(s.id)||(t.set(s.id,s),n.push(s))}),n.sort((r,o)=>{const s=r.createdAt?Date.parse(r.createdAt):0,i=o.createdAt?Date.parse(o.createdAt):0;return s-i}),n}const fg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null,values:{}};function hg(e,t){var n;switch(t.type){case"reset":return{messages:Oo(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{},values:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r],assemblingId:null}}}return{...e,messages:[...e.messages,r],assemblingId:null}}case"seed":{const r=Oo(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=Oo(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 lc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>lc(o,s),e):e}default:return e}}function pg(e=[]){const[t,n]=x.useReducer(hg,{...fg,messages:e}),r=x.useRef([]),o=x.useRef(null),s=x.useRef(null),i=x.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const u=r.current;u.length&&(r.current=[],n({type:"batch",payload:{events:u}}))},[]),a=x.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]),c=x.useCallback(u=>{r.current.push(u),a()},[a]);x.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const l=x.useMemo(()=>({reset:u=>n({type:"reset",payload:{messages:u}}),seed:(u,f)=>n({type:"seed",payload:{messages:u,...f??{}}}),prepend:u=>n({type:"prepend",payload:{messages:u}}),pushUser:(u,f)=>n({type:"user_message",payload:{message:u,editingMessageId:f}}),onEvent:c}),[c]);return{state:t,dispatch:n,...l}}function lc(e,t){if(t.type==="tool.start")return gg(e,t);if(t.type==="tool.progress")return xg(e,t);if(t.type==="tool.end")return bg(e,t);if(t.type==="artifact.update")return wg(e,t);if(t.type==="checkpoint"){const n=t.checkpointNs??e.lastCheckpointNs??null,r=ug(e.messages,t.checkpointId,n);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:n,messages:r}}if(t.type==="error"){const n={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,n]}}if(t.type==="state_history"){const n=cr(t),r=n.interrupt,o=n.latest,s=dg(n.checkpoints);let i=s.length?s:o==null?void 0:o.messages;if(i){if(e.assemblingId&&!i.some(a=>a.id===e.assemblingId)){const a=e.messages.find(c=>c.id===e.assemblingId);a&&(i=[...i,a])}i=Oo(i)}else i=r===null?cg(e.messages):e.messages;return{...e,messages:i,pendingInterrupt:r,lastCheckpointId:(o==null?void 0:o.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(o==null?void 0:o.checkpointNs)??e.lastCheckpointNs,values:(o==null?void 0:o.values)??e.values}}return t.type==="thread_info",e}function ri(e){return e.call_id??e.id??null}function cc(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function uc(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,toolCallId:o,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function oi(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.toolCallId;if(typeof o=="string"&&o===t)return n;const s=r.additionalKwargs??{};if(typeof s.toolCallId=="string"&&s.toolCallId===t||jo(r).toolCallId===t)return n}return-1}function mg(e){if(e==null)return[];const t=Br(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=fr(t??e);return n?[{type:"text",text:n}]:[]}function si(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function gg(e,t){const n=ri(t),r=oi(e.messages,n),o=t.name??t.tool??void 0,s=cc(t),i={type:t.type,content:`Starting ${o??"tool"}...`,seq:t.seq??null,timestamp:new Date().toISOString()};if(r>=0){const l=e.messages[r],f={...l.additionalKwargs??{},toolStreaming:!0,toolProgress:[i]},h={...l,name:o??l.name,additionalKwargs:f};return{...e,messages:Hr(e.messages,r,h)}}const a=uc(s,n,o,t.args),c=si(a,i);return{...e,messages:[...e.messages,c]}}function xg(e,t){var u,f,h,p,m;const n=t.id??t.call_id??((u=t.data)==null?void 0:u.id)??ri(t);if(!n)return e;const r=oi(e.messages,n);if(r===-1)return e;const o=t.status??t.step??t.type??((f=t.data)==null?void 0:f.type)??"progress",s=t.content??((h=t.data)==null?void 0:h.content)??(typeof t.data=="string"?t.data:void 0),i={type:o,content:s,seq:t.seq??null,timestamp:new Date().toISOString()},a=t.metadata??((p=t.data)==null?void 0:p.metadata);a&&(i.metadata=a);const c=t.idx??((m=t.data)==null?void 0:m.idx);typeof c=="number"&&(i.idx=c);const l=si(e.messages[r],i);return{...e,messages:Hr(e.messages,r,l)}}function bg(e,t){const n=ri(t),r=cc(t);let o=e.messages,s=oi(o,n);if(s===-1){const m=t.name??t.tool??void 0;o=[...o,uc(r,n,m,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,c=mg(a),l=[...i.content,...c],u={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(u.artifact=t.artifact);const f=si(i,u),h=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:l,artifact:h,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Hr(o,s,p)}}function wg(e,t){const n=lg(e.messages,t.artifact_id);if(!n){const s={id:`artifact-${t.artifact_id}`,role:"tool",name:"artifact_updater",content:[],createdAt:new Date().toISOString(),artifact:{type:"unknown",metadata:{id:t.artifact_id,type:"unknown",created_at:new Date().toISOString(),status:t.status,progress:t.progress},...t.partial_data}};return{...e,messages:[...e.messages,s]}}const r=e.messages.indexOf(n),o=ag(n,{status:t.status,progress:t.progress,error:t.error});return t.partial_data&&o.artifact&&(o.artifact={...o.artifact,...t.partial_data}),{...e,messages:Hr(e.messages,r,o)}}const dc=120;function vg(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>dc?`${n.slice(0,dc-3)}…`:n:""}function yg(e){return vg(e.content)||""}function Sg(e){const t=new Map,n=[],r=new Map,o=[];for(let l=0;l<e.length;l++){const u=e[l],f=u.checkpointId,h=f??`cp-${l}`,p=u.metadata??{},m=typeof p.step=="number"?p.step:null,g=typeof p.source=="string"?p.source:null;let b=null,v=null;const y=Array.isArray(u.messages)?u.messages:[];for(const S of y)S.role==="user"&&(v||(v=S),S.id&&(b=S.id));const T=u.next&&u.next.length>0?String(u.next[0]):null,I=u.parentConfig??null,k={id:h,step:m,source:g,createdAt:u.createdAt??null,namespace:u.checkpointNs??null,parentId:u.parentId??null,next:T,parentConfig:I,userMessageId:b};if(o.push(k),f&&t.set(f,k),f&&v){const S=yg(v);S&&r.set(f,S)}n.push({id:h,messageId:b,step:m,source:g,createdAt:u.createdAt??null,next:T,parentConfig:I})}const s=new Map;for(const l of o){if(!l.userMessageId)continue;const u=s.get(l.userMessageId)??[];u.push(l),s.set(l.userMessageId,u)}for(const l of s.values()){if(!l.length)continue;l.sort((f,h)=>{const p=f.createdAt?Date.parse(f.createdAt):0;return(h.createdAt?Date.parse(h.createdAt):0)-p});const u=l.length;for(let f=0;f<l.length;f++){const h=l[f];h.attemptCount=u,h.attemptIndex=f,h.isLatestAttempt=f===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const l=n[0];if(l)return t.get(l.id)},getCheckpoint:l=>t.get(l),getMessageAttempts:l=>{const u=[];for(const f of t.values())f.userMessageId===l&&u.push(f);return u.length?(u.sort((f,h)=>{const p=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,m=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER;return p-m}),u):[]}}}function Cg(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 kg(e){return x.useMemo(()=>Sg(e),[e])}function fc({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:c,getMessages:l}){const[u,f]=x.useState(null),p=x.useMemo(()=>cr(u),[u]).checkpoints,m=kg(p),g=m.timeline,[b,v]=x.useState(!1),[y,T]=x.useState(!1),[I,k]=x.useState(null),S=x.useRef(r),E=x.useRef(null),j=x.useRef(null),_=x.useRef(null),D=x.useRef(null),L=x.useRef(null),W=x.useRef(new Map),V=x.useRef(null);x.useEffect(()=>{S.current=r},[r]);const $=x.useCallback(async R=>{var q,J;if(!R.threadId)return;const M=R.threadId;(q=R.onStart)==null||q.call(R),R.setLoading(!0);try{await R.action(M)}catch(P){if(!Ll(P)&&S.current===M){const te=String(P);(J=R.handleError)==null||J.call(R,te),n==null||n(te)}throw P}finally{R.setLoading(!1)}},[n]),Z=x.useCallback(async(R,M)=>{var te;if(!R)return;const q=`${R}:${M??"latest"}`,J=W.current.get(q);if(J)return J;(te=V.current)==null||te.abort();const P=new AbortController;V.current=P;const K=$({threadId:R,setLoading:v,onStart:()=>k(null),handleError:le=>k(le),action:async le=>{const he=await e.getStateHistory({threadId:le,checkpointId:M??void 0,signal:P.signal});if(S.current!==le){console.log(`[useThreadHistoryState] Thread changed during load (was ${le}, now ${S.current}), discarding stale data`);return}const{checkpoints:ue,latest:ge}=cr(he),be=M?ue.find(Be=>Be.checkpointId===M)??ge:ge;t((be==null?void 0:be.messages)??[],{checkpointId:(be==null?void 0:be.checkpointId)??null,checkpointNs:(be==null?void 0:be.checkpointNs)??null,pendingInterrupt:(be==null?void 0:be.interrupt)??null}),f(he)}});W.current.set(q,K);try{await K}finally{W.current.delete(q),V.current===P&&(V.current=null)}return S.current===R&&(L.current=q),K},[e,t,$]),X=x.useCallback(async(R,M)=>{D.current=R;try{await Z(R,M)}catch(q){if(!Ll(q))throw q}finally{D.current===R&&(D.current=null)}},[Z]),oe=x.useCallback(R=>{j.current=R},[]),U=x.useCallback(R=>{_.current=R},[]),F=x.useCallback(R=>{const M=R.threadId??S.current;if(!M||S.current&&S.current!==M)return;const{checkpoints:q,latest:J}=cr(R);if(!q.length)return;const P=J,K=_.current===M;!c&&!K&&t((P==null?void 0:P.messages)??[],{checkpointId:(P==null?void 0:P.checkpointId)??null,checkpointNs:(P==null?void 0:P.checkpointNs)??null,pendingInterrupt:(P==null?void 0:P.interrupt)??null}),f(R),L.current=`${M}:latest`,j.current=null,_.current===M&&(_.current=null)},[t,c]),G=x.useCallback(async(R,M)=>{const q=S.current;await $({threadId:q,setLoading:T,action:async J=>{const P=await e.getStateHistory({threadId:J,checkpointId:R,checkpointNs:M??void 0});if(S.current!==J)return;const{checkpoints:K}=cr(P),te=K.find(le=>le.checkpointId===R&&(M?le.checkpointNs===M:!0));if(!te){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:R,checkpointNs:M});return}f(P),t(te.messages??[],{checkpointId:te.checkpointId??null,checkpointNs:te.checkpointNs??null})}}).catch(()=>{})},[e,t,$]),H=x.useCallback((R,M)=>{t(l(),{checkpointId:R??null,checkpointNs:M??null})},[l,t]),A=x.useCallback(async()=>{S.current&&await X(S.current)},[X]);x.useEffect(()=>{if(!a||!r||b||c)return;if(j.current===r){j.current=null,E.current=r;return}if(_.current===r){E.current=r;return}if(D.current===r){D.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let R;const M=`${r}:latest`;L.current!==M&&X(r,R)},[a,r,s,i,o,b,c,X]);const N=x.useCallback(()=>{f(null),v(!1),T(!1),k(null),j.current=null,_.current=null,E.current=null,L.current=null,D.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:m,isLoadingThread:b,isLoadingCheckpoint:y,threadStateError:I,loadThread:X,navigateToCheckpoint:G,setCurrentCheckpointId:H,returnToLatest:A,handleStateHistoryEvent:F,markSkipNextLoad:oe,markStreamPendingThread:U,resetHistoryState:N,clearState:N}}const hc=x.createContext(null),pc=x.createContext(null);function Ur(){const e=x.useContext(hc);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function mc(){const e=x.useContext(pc);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function gc({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{chatApi:a}=Vn(),{currentThreadId:c}=ur(),{state:l,seed:u,onEvent:f,dispatch:h}=pg(),{threadCheckpoints:p,threadTimeline:m,checkpointIndex:g,isLoadingThread:b,isLoadingCheckpoint:v,threadStateError:y,loadThread:T,navigateToCheckpoint:I,setCurrentCheckpointId:k,returnToLatest:S,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:_,resetHistoryState:D}=fc({api:a,seed:u,onError:i,currentThreadId:c,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:x.useCallback(()=>l.messages,[l.messages])});x.useEffect(()=>{c||(u([],{}),D())},[c,u,D]);const L=x.useRef(null),W=x.useCallback(G=>{L.current=G},[]),V=x.useRef(null),$=x.useCallback(G=>{V.current=G},[]),Z=x.useMemo(()=>({assemblingMessageId:l.assemblingId??null}),[l.assemblingId]),X=x.useCallback((G,H)=>{const A=Yl(G,"user");return h({type:"user_message",payload:{message:A,editingMessageId:H==null?void 0:H.editingMessageId}}),A},[h]),oe=x.useCallback(async()=>{L.current?await L.current():(u([],{}),D())},[u,D]),U=x.useMemo(()=>({threadId:c,messages:l.messages,interrupt:l.pendingInterrupt,checkpoint:{id:l.lastCheckpointId??null,namespace:l.lastCheckpointNs??null},checkpoints:p,checkpointIndex:g,timelineCheckpoints:m,metadata:Z,values:l.values??{},isLoading:b,isLoadingCheckpoint:v,error:y,loadOlder:async()=>{},seedFromSnapshot:G=>{u(G.messages,{checkpointId:G.checkpointId,checkpointNs:G.checkpointNs,pendingInterrupt:G.interrupt})},clearState:oe,navigateToCheckpoint:I,setCurrentCheckpointId:k,returnToLatest:S,loadThread:async(G,H,A)=>{await T(G,H,{clearProgress:!1})},clearThread:oe,respondToInterrupt:async(G,H,A)=>{V.current&&await V.current(G,H,A)},messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:_,resetHistoryState:D,pushUser:X,onEvent:f}),[c,l.messages,l.pendingInterrupt,l.lastCheckpointId,l.lastCheckpointNs,l.values,p,m,g,Z,b,v,y,u,oe,I,k,S,T,E,j,_,X,f]),F=x.useMemo(()=>({registerClearThread:W,registerRespondToInterrupt:$}),[W,$]);return d.jsx(pc.Provider,{value:F,children:d.jsx(hc.Provider,{value:U,children:e})})}function xc(e,t){if(!e)return null;const n=Kn(e);if(!n)return null;const r=Kn(n.configurable)??n;return Fr(r,t)??null}function Tg(e){const t=xc(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=xc(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function Eg(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 Ig(e,t){const n=[...e].sort(Eg);for(const r of n){if(r.messageId!==t)continue;const o=Tg(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 bc=x.createContext(null),wc=x.createContext(!1);function Ag({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:c,onToolEnd:l}){const{chatApi:u,baseUrl:f}=Vn(),h=f,{stream:p,stop:m,clear:g,isStreaming:b,error:v,connected:y}=Jm({baseUrl:h}),[T,I]=x.useState(!1);return x.useEffect(()=>{I(b)},[b]),d.jsx(tc,{initialThreadId:t,onError:s,onThreadChange:a,children:d.jsx(gc,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:T,children:d.jsx(wc.Provider,{value:!0,children:d.jsx(Ng,{api:u,streamApi:{stream:p,stop:m,clear:g,isStreaming:b,error:v,connected:y},onError:s,onAuthError:i,onConnectionError:c,onToolEnd:l,children:e})})})})}function Ng({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:c,clear:l,isStreaming:u,error:f,connected:h}=n,{setCurrentThreadId:p,currentThreadIdRef:m,addThreadFromEvent:g,currentThreadId:b}=ur();x.useEffect(()=>{b!==void 0&&l()},[b,l]);const{interrupt:v,checkpoint:y,timelineCheckpoints:T,handleStateHistoryEvent:I,markSkipNextLoad:k,markStreamPendingThread:S,resetHistoryState:E,pushUser:j,onEvent:_,messages:D}=Ur(),{registerClearThread:L,registerRespondToInterrupt:W}=mc(),V=x.useCallback(H=>{g(H),m.current!==H.threadId&&((H.created??!m.current)&&k(H.threadId),S(H.threadId),p(H.threadId))},[g,k,S,p,m]),$=x.useCallback(H=>{H.type==="thread_info"?V(H):H.type==="state_history"?I(H):H.type==="tool.end"?(_(H),i==null||i(H)):_(H)},[V,I,_,i]),Z=x.useCallback((H,A)=>{a(H,N=>{$(N),A==null||A(N)},{onError:N=>{console.error("[StreamingProvider] Stream error:",N),r==null||r(N)},onAuthError:N=>{console.error("[StreamingProvider] Auth error:",N),o==null||o(N)},onConnectionError:N=>{console.error("[StreamingProvider] Connection error:",N),s==null||s(N)}})},[a,$,r,o,s]),X=x.useRef(y);x.useEffect(()=>{X.current=y},[y]);const oe=x.useCallback(async(H,A,N)=>{const R=m.current;if(!R)throw new Error("No active thread to handle interrupt");const M=H?A??!0:!1,q=X.current,J={threadId:R,checkpointId:q.id??void 0,checkpointNs:q.namespace??void 0,command:{kind:"resume",value:M},payload:N==null?void 0:N.payload};Z(J)},[m,Z]);x.useEffect(()=>{W(oe)},[oe,W]);const U=x.useCallback(async()=>{c(),l(),E(),p(null)},[l,E,p,c]);x.useEffect(()=>{L(U)},[U,L]);const F=x.useCallback(async(H,A)=>{u&&c();let N=m.current;const R=(H==null?void 0:H.text)??"",M=(H==null?void 0:H.attachments)??[],q=(R==null?void 0:R.trim())??"",J={...(H==null?void 0:H.payload)??{}},P=Array.isArray(J.messages)?J.messages:void 0;P&&delete J.messages;const K=!!(P&&P.length),te=!!(H.contentParts&&H.contentParts.length>0);if(!N&&!q&&M.length===0&&!K&&!te)return;if(!N){const Me=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Ze=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);N=`${Me}${Ze}`,k(N),p(N)}let le=null;H.contentParts&&H.contentParts.length>0&&(le=H.contentParts);const{contentParts:he,filesInfo:ue}=le?{contentParts:le,filesInfo:[]}:await Gl(M),ge=[...he];q&&ge.push({type:"text",text:R});const be=A==null?void 0:A.originalMessageId,Be=!!(A!=null&&A.edit&&be),Le=!K&&ge.length>0;let je=null;if(Le){const Me=Be?be:`msg-${Date.now()}`;je=Yl({id:Me,role:"user",content:ge,createdAt:new Date().toISOString()},"user"),Be?j(je,{editingMessageId:be}):j(je)}const Fe=K?P:je?[je]:[],tt={...J,...ue.length?{files_info:ue}:{}};Fe.length?tt.messages=Fe:"messages"in tt||(tt.messages=[]);let mt=(A==null?void 0:A.checkpointId)??y.id??void 0,ot=(A==null?void 0:A.checkpointNs)??y.namespace??void 0;if(Be&&be){const Me=Ig(T,be);mt=Me.checkpointId,ot=Me.checkpointNs??void 0}const ze={threadId:N,payload:tt,checkpointId:mt,checkpointNs:ot,config:A==null?void 0:A.config,edit:!!(A!=null&&A.edit)};Z(ze,A==null?void 0:A.onEvent)},[y,m,u,k,j,Z,c,T]),G=x.useMemo(()=>({isStreaming:u,error:f,connectionState:f?"error":u?h?"connected":"connecting":"idle",messages:D,submit:F,stop:c,interrupt:v,resume:()=>Promise.resolve(),goto:(H,A)=>Promise.resolve(),clearError:()=>{}}),[u,f,F,c,v,h,D]);return d.jsx(bc.Provider,{value:G,children:e})}function ii(){const e=x.useContext(bc);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function _g(){return x.useContext(wc)}function vc(e){return typeof e=="object"&&e!==null}function jg(e,t){if(Object.is(e,t))return!0;if(!vc(e)||!vc(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 yc(e){const t=x.useRef(e),n=x.useRef(e);return jg(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:c,onThreadChange:l,onToolEnd:u}){const f=yc(t),h=Vr(a),p=Vr(c),m=Vr(i),g=Vr(l),b=Vr(u),v=x.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:h,onAuthError:p,onConnectionError:m,onThreadChange:g,onToolEnd:b}),[n,r,o,s,h,p,m,g,b]);return d.jsx(Kl,{apiConfig:f,children:d.jsx(Ag,{...v,children:e})})}function Vr(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e},[e]),x.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function pr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Sc(){const e=[pr("__API_BASE_URL__"),pr("__CHAT_API_BASE_URL__"),pr("__CHAT_API_URL__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"")}function Cc(){const e=[pr("__API_AUTH_TOKEN__"),pr("__CHAT_API_KEY__"),pr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function kc(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"");return""}function Tc(){const e={},t=Sc(),n=Cc();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ec(){const e=Tc(),t=An.getAuthToken(),n=Sc();return{apiBaseUrl:kc(e.baseUrl,n),apiKey:t||e.apiKey||Cc()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const ai=En.chatSettings;function Ic(){try{const e=localStorage.getItem(ai);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Ac(e){try{const t={...e,apiBaseUrl:e.apiBaseUrl.trim().replace(/\/+$/,"")};localStorage.setItem(ai,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Pg(){const e=Ec(),t=Ic(),n=An.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:kc(An.baseUrl,r,e.apiBaseUrl)}}function Og(e){An.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),Ac(e)}function ae(...e){return Bn.twMerge(Pt.clsx(e))}const Rg=Ya.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"}}),Ke=w.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?sr.Slot:"button";return d.jsx(i,{className:ae(Rg({variant:t,size:n,className:e})),ref:s,...o})});Ke.displayName="Button";const Ro=0,Nn=1,mr=2,Nc=4;function _c(e){return()=>e}function Mg(e){e()}function jc(e,t){return n=>e(t(n))}function Pc(e,t){return()=>e(t)}function Dg(e,t){return n=>e(t,n)}function li(e){return e!==void 0}function Lg(...e){return()=>{e.map(Mg)}}function gr(){}function Mo(e,t){return t(e),e}function $g(e,t){return t(e)}function Xe(...e){return e}function De(e,t){return e(Nn,t)}function Ae(e,t){e(Ro,t)}function ci(e){e(mr)}function lt(e){return e(Nc)}function me(e,t){return De(e,Dg(t,Ro))}function tn(e,t){const n=e(Nn,r=>{n(),t(r)});return n}function Oc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Rc(e,t){return e===t}function Je(e=Rc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>jc(t,e)}function un(e){return t=>()=>{t(e)}}function ee(e,...t){const n=Fg(...t);return(r,o)=>{switch(r){case mr:ci(e);return;case Nn:return De(e,n(o))}}}function dn(e,t){return n=>r=>{n(t=e(t,r))}}function qn(e){return t=>n=>{e>0?e--:t(n)}}function yn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Ne(...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);De(s,c=>{const l=n;n=n|a,t[i]=c,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Fg(...e){return t=>e.reduceRight($g,t)}function zg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Nn:return s?n===s?void 0:(r(),n=s,t=De(e,s),t):(r(),gr);case mr:r(),n=null;return}}}function re(e){let t=e;const n=Oe();return(r,o)=>{switch(r){case Ro:t=o;break;case Nn:{o(t);break}case Nc:return t}return n(r,o)}}function vt(e,t){return Mo(re(t),n=>me(e,n))}function Oe(){const e=[];return(t,n)=>{switch(t){case Ro:e.slice().forEach(r=>{r(n)});return;case mr:e.splice(0,e.length);return;case Nn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Ht(e){return Mo(Oe(),t=>me(e,t))}function Re(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Bg(),singleton:n}}const Bg=()=>Symbol();function Hg(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function ft(...e){const t=Oe(),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);De(s,c=>{n[i]=c,r=r|a,r===o&&Ae(t,n)})}),function(s,i){switch(s){case mr:{ci(t);return}case Nn:return r===o&&i(n),De(t,i)}}}function ve(e,t=Rc){return ee(e,Je(t))}function ui(...e){return function(t,n){switch(t){case mr:return;case Nn:return Lg(...e.map(r=>De(r,n)))}}}var Dt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Dt||{});const Ug={0:"debug",3:"error",1:"log",2:"warn"},Wg=()=>typeof globalThis>"u"?window:globalThis,_n=Re(()=>{const e=re(3);return{log:re((t,n,r=1)=>{var o;const s=(o=Wg().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[Ug[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Gn(e,t,n){return di(e,t,n).callbackRef}function di(e,t,n){const r=x.useRef(null);let o=i=>{};const s=x.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 Vg(e,t,n,r,o,s,i,a,c){const l=x.useCallback(u=>{const f=Kg(u.children,t,a?"offsetWidth":"offsetHeight",o);let h=u.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let m;p&&(m=h.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?m.scrollX||m.document.documentElement.scrollLeft:m.scrollY||m.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,b=i?a?i.scrollWidth:i.scrollHeight:p?a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=i?a?i.offsetWidth:i.offsetHeight:p?a?m.innerWidth:m.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:b,scrollTop:Math.max(g,0),viewportHeight:v}),s==null||s(a?Mc("column-gap",getComputedStyle(u).columnGap,o):Mc("row-gap",getComputedStyle(u).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return di(l,n,c)}function Kg(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 c=parseInt(a.dataset.index),l=parseFloat(a.dataset.knownSize),u=t(a,n);if(u===0&&r("Zero-sized element, this should not happen",{child:a},Dt.ERROR),u===l)continue;const f=s[s.length-1];s.length===0||f.size!==u||f.endIndex!==c-1?s.push({endIndex:c,size:u,startIndex:c}):s[s.length-1].endIndex++}return s}function Mc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Dt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Dc(e,t,n){const r=x.useRef(null),o=x.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),u=l.width;let f,h;if(t){const p=t.getBoundingClientRect(),m=l.top-p.top;h=p.height-Math.max(0,m),f=m+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,l.top),f=l.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:u},e(r.current)},[e,t]),{callbackRef:s,ref:i}=di(o,!0,n),a=x.useCallback(()=>{o(i.current)},[o,i]);return x.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const l=new ResizeObserver(()=>{requestAnimationFrame(a)});return l.observe(t),()=>{t.removeEventListener("scroll",a),l.unobserve(t)}}else{const l=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",a),l==null||l.addEventListener("resize",a),()=>{l==null||l.removeEventListener("scroll",a),l==null||l.removeEventListener("resize",a)}}},[a,t,i]),s}const Nt=Re(()=>{const e=Oe(),t=Oe(),n=re(0),r=Oe(),o=re(0),s=Oe(),i=Oe(),a=re(0),c=re(0),l=re(0),u=re(0),f=Oe(),h=Oe(),p=re(!1),m=re(!1),g=re(!1);return me(ee(e,ce(({scrollTop:b})=>b)),t),me(ee(e,ce(({scrollHeight:b})=>b)),i),me(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:a,horizontalDirection:m,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Kr={lvl:0};function Lc(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:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function Ue(e){return e===Kr}function qr(e,t){if(!Ue(e))return t===e.k?e.v:t<e.k?qr(e.l,t):qr(e.r,t)}function nn(e,t,n="k"){if(Ue(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=nn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return nn(e.l,t,n)}function Ut(e,t,n){return Ue(e)?zc(t,n,1):t===e.k?pt(e,{k:t,v:n}):t<e.k?Bc(pt(e,{l:Ut(e.l,t,n)})):Bc(pt(e,{r:Ut(e.r,t,n)}))}function xr(){return Kr}function Do(e,t,n){if(Ue(e))return[];const r=nn(e,t)[0];return qg(hi(e,r,n))}function fi(e,t){if(Ue(e))return Kr;const{k:n,l:r,r:o}=e;if(t===n){if(Ue(r))return o;if(Ue(o))return r;{const[s,i]=Fc(r);return Lo(pt(e,{k:s,l:$c(r),v:i}))}}else return t<n?Lo(pt(e,{l:fi(r,t)})):Lo(pt(e,{r:fi(o,t)}))}function Yn(e){return Ue(e)?[]:[...Yn(e.l),{k:e.k,v:e.v},...Yn(e.r)]}function hi(e,t,n){if(Ue(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(hi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(hi(s,t,n))),a}function Lo(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(pi(t))return Hc(pt(e,{lvl:n-1}));if(!Ue(t)&&!Ue(t.r))return pt(t.r,{l:pt(t,{r:t.r.l}),lvl:n,r:pt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(pi(e))return mi(pt(e,{lvl:n-1}));if(!Ue(r)&&!Ue(r.l)){const o=r.l,s=pi(o)?r.lvl-1:r.lvl;return pt(o,{l:pt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:mi(pt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function pt(e,t){return zc(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 $c(e){return Ue(e.r)?e.l:Lo(pt(e,{r:$c(e.r)}))}function pi(e){return Ue(e)||e.lvl>e.r.lvl}function Fc(e){return Ue(e.r)?[e.k,e.v]:Fc(e.r)}function zc(e,t,n,r=Kr,o=Kr){return{k:e,l:r,lvl:n,r:o,v:t}}function Bc(e){return mi(Hc(e))}function Hc(e){const{l:t}=e;return!Ue(t)&&t.lvl===e.lvl?pt(t,{r:pt(e,{l:t.r})}):e}function mi(e){const{lvl:t,r:n}=e;return!Ue(n)&&!Ue(n.r)&&n.lvl===t&&n.r.lvl===t?pt(n,{l:pt(e,{r:n.l}),lvl:t+1}):e}function qg(e){return Lc(e,({k:t,v:n})=>({index:t,value:n}))}function Uc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Gr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const gi=Re(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function Wc(e,t,n){return e[$o(e,t,n)]}function $o(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 Gg(e,t,n,r){const o=$o(e,t,r),s=$o(e,n,r,o);return e.slice(o,s+1)}function jn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Fo(e){return!Ue(e.groupOffsetTree)}function xi({index:e},t){return t===e?0:t<e?-1:1}function Yg(){return{groupIndices:[],groupOffsetTree:xr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:xr()}}function Xg(e,t){let n=Ue(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ue(e)){e=Ut(e,0,s);continue}const a=Do(e,i-1,o+1);if(a.some(rx(r)))continue;let c=!1,l=!1;for(const{end:u,start:f,value:h}of a)c?(o>=f||s===h)&&(e=fi(e,f)):(l=h!==s,c=!0),u>o&&o>=f&&h!==s&&(e=Ut(e,o+1,h));l&&(e=Ut(e,i,s))}return[e,n]}function Jg(e){return typeof e.groupIndex<"u"}function Zg({offset:e},t){return t===e?0:t<e?-1:1}function Yr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Wc(t,e,xi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Vc(e,t){if(!Fo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Kc(e,t,n){if(Jg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Vc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Qg(e,t,n,r=0){return r>0&&(t=Math.max(t,Wc(e,r,xi).offset)),Lc(Gg(e,t,n,Zg),nx)}function ex(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Dt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ue(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((m,g)=>Ut(Ut(m,g,h),g+1,p),i)}else[i,a]=Xg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:f}=bi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ut(h,p,Yr(p,f,o)),xr()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:f,sizeTree:i}}function tx(e){return Yn(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 qc(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 bi(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=$o(o,t-1,xi),a=o[c].offset;const l=nn(n,t-1);s=l[0],i=l[1],o.length&&o[c].size===nn(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:l,value:u}of Do(n,t,1/0)){const f=l-s,h=f*i+a+f*r;o.push({index:l,offset:h,size:u}),s=l,a=h,i=u}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function nx(e){return{index:e.index,value:e}}function rx(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 ox={offsetHeight:"height",offsetWidth:"width"},fn=Re(([{log:e},{recalcInProgress:t}])=>{const n=Oe(),r=Oe(),o=vt(r,0),s=Oe(),i=Oe(),a=re(0),c=re([]),l=re(void 0),u=re(void 0),f=re((k,S)=>jn(k,ox[S])),h=re(void 0),p=re(0),m=Yg(),g=vt(ee(n,Ne(c,e,p),dn(ex,m),Je()),m),b=vt(ee(c,Je(),dn((k,S)=>({current:S,prev:k.current}),{current:[],prev:[]}),ce(({prev:k})=>k)),[]);me(ee(c,ye(k=>k.length>0),Ne(g,p),ce(([k,S,E])=>{const j=k.reduce((_,D,L)=>Ut(_,D,Yr(D,S.offsetTree,E)||L),xr());return{...S,groupIndices:k,groupOffsetTree:j}})),g),me(ee(r,Ne(g),ye(([k,{lastIndex:S}])=>k<S),ce(([k,{lastIndex:S,lastSize:E}])=>[{endIndex:S,size:E,startIndex:k}])),n),me(l,u);const v=vt(ee(l,ce(k=>k===void 0)),!0);me(ee(u,ye(k=>k!==void 0&&Ue(lt(g).sizeTree)),ce(k=>[{endIndex:0,size:k,startIndex:0}])),n);const y=Ht(ee(n,Ne(g),dn(({sizes:k},[S,E])=>({changed:E!==k,sizes:E}),{changed:!1,sizes:m}),ce(k=>k.changed)));De(ee(a,dn((k,S)=>({diff:k.prev-S,prev:S}),{diff:0,prev:0}),ce(k=>k.diff)),k=>{const{groupIndices:S}=lt(g);if(k>0)Ae(t,!0),Ae(s,k+qc(k,S));else if(k<0){const E=lt(b);E.length>0&&(k-=qc(-k,E)),Ae(i,k)}}),De(ee(a,Ne(e)),([k,S])=>{k<0&&S("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Dt.ERROR)});const T=Ht(s);me(ee(s,Ne(g),ce(([k,S])=>{const E=S.groupIndices.length>0,j=[],_=S.lastSize;if(E){const D=qr(S.sizeTree,0);let L=0,W=0;for(;L<k;){const $=S.groupIndices[W],Z=S.groupIndices.length===W+1?1/0:S.groupIndices[W+1]-$-1;j.push({endIndex:$,size:D,startIndex:$}),j.push({endIndex:$+1+Z-1,size:_,startIndex:$+1}),W++,L+=Z+1}const V=Yn(S.sizeTree);return L!==k&&V.shift(),V.reduce(($,{k:Z,v:X})=>{let oe=$.ranges;return $.prevSize!==0&&(oe=[...$.ranges,{endIndex:Z+k-1,size:$.prevSize,startIndex:$.prevIndex}]),{prevIndex:Z+k,prevSize:X,ranges:oe}},{prevIndex:k,prevSize:0,ranges:j}).ranges}return Yn(S.sizeTree).reduce((D,{k:L,v:W})=>({prevIndex:L+k,prevSize:W,ranges:[...D.ranges,{endIndex:L+k-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const I=Ht(ee(i,Ne(g,p),ce(([k,{offsetTree:S},E])=>{const j=-k;return Yr(j,S,E)})));return me(ee(i,Ne(g,p),ce(([k,S,E])=>{if(S.groupIndices.length>0){if(Ue(S.sizeTree))return S;let j=xr();const _=lt(b);let D=0,L=0,W=0;for(;D<-k;){W=_[L];const V=_[L+1]-W-1;L++,D+=V+1}if(j=Yn(S.sizeTree).reduce((V,{k:$,v:Z})=>Ut(V,Math.max(0,$+k),Z),j),D!==-k){const V=qr(S.sizeTree,W);j=Ut(j,0,V);const $=nn(S.sizeTree,-k+1)[1];j=Ut(j,1,$)}return{...S,sizeTree:j,...bi(S.offsetTree,0,j,E)}}else{const j=Yn(S.sizeTree).reduce((_,{k:D,v:L})=>Ut(_,Math.max(0,D+k),L),xr());return{...S,sizeTree:j,...bi(S.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:T,data:h,defaultItemSize:u,firstItemIndex:a,fixedItemSize:l,gap:p,groupIndices:c,itemSize:f,listRefresh:y,shiftWith:i,shiftWithOffset:I,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:v,unshiftWith:s}},Xe(_n,gi),{singleton:!0});function sx(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Gc=Re(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Oe(),i=Oe(),a=Ht(ee(s,ce(sx)));return me(ee(a,ce(c=>c.totalCount)),n),me(ee(a,ce(c=>c.groupIndices)),e),me(ee(ft(o,t,r),ye(([c,l])=>Fo(l)),ce(([c,l,u])=>nn(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),Je(),ce(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Xe(fn,Nt)),Pn=Re(([{log:e}])=>{const t=re(!1),n=Ht(ee(t,ye(r=>r),Je()));return De(t,r=>{r&<(e)("props updated",{},Dt.DEBUG)}),{didMount:n,propsReady:t}},Xe(_n),{singleton:!0}),ix=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Yc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!ix)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Xr=Re(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:f},{log:h}])=>{const p=Oe(),m=Oe(),g=re(0);let b=null,v=null,y=null;function T(){b&&(b(),b=null),y&&(y(),y=null),v&&(clearTimeout(v),v=null),Ae(c,!1)}return me(ee(p,Ne(n,f,r,g,a,i,h),Ne(e,s,o),ce(([[I,k,S,E,j,_,D,L],W,V,$])=>{const Z=Yc(I),{align:X,behavior:oe,offset:U}=Z,F=E-1,G=Kc(Z,k,F);let H=Yr(G,k.offsetTree,W)+_;X==="end"?(H+=V+nn(k.sizeTree,G)[1]-S+$,G===F&&(H+=D)):X==="center"?H+=(V+nn(k.sizeTree,G)[1]-S+$)/2:H-=j,U&&(H+=U);const A=N=>{T(),N?(L("retrying to scroll to",{location:I},Dt.DEBUG),Ae(p,I)):(Ae(m,!0),L("list did not change, scroll successful",{},Dt.DEBUG))};if(T(),oe==="smooth"){let N=!1;y=De(t,R=>{N=N||R}),b=tn(u,()=>{A(N)})}else b=tn(ee(t,ax(150)),A);return v=setTimeout(()=>{T()},1200),Ae(c,!0),L("scrolling from index to",{behavior:oe,index:G,top:H},Dt.DEBUG),{behavior:oe,top:H}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:g}},Xe(fn,Nt,_n),{singleton:!0});function ax(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function wi(e,t){e==0?t():requestAnimationFrame(()=>{wi(e-1,t)})}function vi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Jr=Re(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=re(!0),c=re(0),l=re(!0);return me(ee(i,Ne(c),ye(([u,f])=>!!f),un(!1)),a),me(ee(i,Ne(c),ye(([u,f])=>!!f),un(!1)),l),De(ee(ft(t,i),Ne(a,n,e,l),ye(([[,u],f,{sizeTree:h},p,m])=>u&&(!Ue(h)||li(p))&&!f&&!m),Ne(c)),([,u])=>{tn(o,()=>{Ae(l,!0)}),wi(4,()=>{tn(r,()=>{Ae(a,!0)}),Ae(s,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Xe(fn,Nt,Xr,Pn),{singleton:!0});function Xc(e,t){return Math.abs(e-t)<1.01}const Zr="up",Qr="down",lx="none",cx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ux=0,eo=Re(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=re(!1),a=re(!0),c=Oe(),l=Oe(),u=re(4),f=re(ux),h=vt(ee(ui(ee(ve(o),qn(1),un(!0)),ee(ve(o),qn(1),un(!1),Oc(100))),Je()),!1),p=vt(ee(ui(ee(n,un(!0)),ee(n,un(!1),Oc(200))),Je()),!1);me(ee(ft(ve(o),ve(f)),ce(([y,T])=>y<=T),Je()),a),me(ee(a,yn(50)),l);const m=Ht(ee(ft(r,ve(s),ve(t),ve(e),ve(u)),dn((y,[{scrollHeight:T,scrollTop:I},k,S,E,j])=>{const _=I+k-T>-j,D={scrollHeight:T,scrollTop:I,viewportHeight:k};if(_){let W,V;return I>y.state.scrollTop?(W="SCROLLED_DOWN",V=y.state.scrollTop-I):(W="SIZE_DECREASED",V=y.state.scrollTop-I||y.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:V,state:D}}let L;return D.scrollHeight>y.state.scrollHeight?L="SIZE_INCREASED":k<y.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":I<y.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:D}},cx),Je((y,T)=>y&&y.atBottom===T.atBottom))),g=vt(ee(r,dn((y,{scrollHeight:T,scrollTop:I,viewportHeight:k})=>{if(Xc(y.scrollHeight,T))return{changed:!1,jump:0,scrollHeight:T,scrollTop:I};{const S=T-(I+k)<1;return y.scrollTop!==I&&S?{changed:!0,jump:y.scrollTop-I,scrollHeight:T,scrollTop:I}:{changed:!0,jump:0,scrollHeight:T,scrollTop:I}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(y=>y.changed),ce(y=>y.jump)),0);me(ee(m,ce(y=>y.atBottom)),i),me(ee(i,yn(50)),c);const b=re(Qr);me(ee(r,ce(({scrollTop:y})=>y),Je(),dn((y,T)=>lt(p)?{direction:y.direction,prevScrollTop:T}:{direction:T<y.prevScrollTop?Zr:Qr,prevScrollTop:T},{direction:Qr,prevScrollTop:0}),ce(y=>y.direction)),b),me(ee(r,yn(50),un(lx)),b);const v=re(0);return me(ee(h,ye(y=>!y),un(0)),v),me(ee(o,yn(100),Ne(h),ye(([y,T])=>!!T),dn(([y,T],[I])=>[T,I],[0,0]),ce(([y,T])=>T-y)),v),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:g,scrollDirection:b,scrollVelocity:v}},Xe(Nt)),zo="top",Bo="bottom",Jc="none";function Zc(e,t,n){return typeof e=="number"?n===Zr&&t===zo||n===Qr&&t===Bo?e:0:n===Zr?t===zo?e.main:e.reverse:t===Bo?e.main:e.reverse}function Qc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const yi=Re(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Oe(),i=re(0),a=re(0),c=re(0),l=vt(ee(ft(ve(r),ve(o),ve(n),ve(s,Gr),ve(c),ve(i),ve(t),ve(e),ve(a)),ce(([u,f,h,[p,m],g,b,v,y,T])=>{const I=u-y,k=b+v,S=Math.max(h-I,0);let E=Jc;const j=Qc(T,zo),_=Qc(T,Bo);return p-=y,p+=h+v,m+=h+v,m-=y,p>u+k-j&&(E=Zr),m<u-S+f+_&&(E=Qr),E!==Jc?[Math.max(I-h-Zc(g,zo,E)-j,0),I-S-v+f+Zc(g,Bo,E)+_]:null}),ye(u=>u!=null),Je(Gr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:l}},Xe(Nt),{singleton:!0});function dx(e,t,n){if(Fo(t)){const r=Vc(e,t);return[{index:nn(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 Si={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ho(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let l=0,u=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];u=g.offset+g.size}const f=n-i,h=a+f*c+(f-1)*r,p=l,m=h-u;return{bottom:u,firstItemIndex:s,items:tu(e,o,s),offsetBottom:m,offsetTop:l,top:p,topItems:tu(t,o,s),topListHeight:t.reduce((g,b)=>b.size+g,0),totalCount:n}}function eu(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const u of n.groupIndices){if(u-i>=e)break;i++}const a=e+i,c=vi(t,a),l=Array.from({length:a}).map((u,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return Ho(l,[],a,o,n,r)}function tu(e,t,n){if(e.length===0)return[];if(!Fo(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Do(t.groupOffsetTree,r,o);let a,c=0;for(const l of e){(!a||a.end<l.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let u;l.index===a.start?u={index:c,type:"group"}:u={groupIndex:c,index:l.index-(c+1)+n},s.push({...u,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}const Xn=Re(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:f},h,{didMount:p},{recalcInProgress:m}])=>{const g=re([]),b=re(0),v=Oe();me(s.topItemsIndexes,g);const y=vt(ee(ft(p,m,ve(c,Gr),ve(o),ve(r),ve(l),u,ve(g),ve(t),ve(n),e),ye(([S,E,,j,,,,,,,_])=>{const D=_&&_.length!==j;return S&&!E&&!D}),ce(([,,[S,E],j,_,D,L,W,V,$,Z])=>{const X=_,{offsetTree:oe,sizeTree:U}=X,F=lt(b);if(j===0)return{...Si,totalCount:j};if(S===0&&E===0)return F===0?{...Si,totalCount:j}:eu(F,D,_,V,$,Z||[]);if(Ue(U))return F>0?null:Ho(dx(vi(D,j),X,Z),[],j,$,X,V);const G=[];if(W.length>0){const M=W[0],q=W[W.length-1];let J=0;for(const P of Do(U,M,q)){const K=P.value,te=Math.max(P.start,M),le=Math.min(P.end,q);for(let he=te;he<=le;he++)G.push({data:Z==null?void 0:Z[he],index:he,offset:J,size:K}),J+=K}}if(!L)return Ho([],G,j,$,X,V);const H=W.length>0?W[W.length-1]+1:0,A=Qg(oe,S,E,H);if(A.length===0)return null;const N=j-1,R=Mo([],M=>{for(const q of A){const J=q.value;let P=J.offset,K=q.start;const te=J.size;if(J.offset<S){K+=Math.floor((S-J.offset+$)/(te+$));const he=K-q.start;P+=he*te+he*$}K<H&&(P+=(H-K)*te,K=H);const le=Math.min(q.end,N);for(let he=K;he<=le&&!(P>=E);he++)M.push({data:Z==null?void 0:Z[he],index:he,offset:P,size:te}),P+=te+$}});return Ho(R,G,j,$,X,V)}),ye(S=>S!==null),Je()),Si);me(ee(e,ye(li),ce(S=>S==null?void 0:S.length)),o),me(ee(y,ce(S=>S.topListHeight)),f),me(f,a),me(ee(y,ce(S=>[S.top,S.bottom])),i),me(ee(y,ce(S=>S.items)),v);const T=Ht(ee(y,ye(({items:S})=>S.length>0),Ne(o,e),ye(([{items:S},E])=>S[S.length-1].originalIndex===E-1),ce(([,S,E])=>[S-1,E]),Je(Gr),ce(([S])=>S))),I=Ht(ee(y,yn(200),ye(({items:S,topItems:E})=>S.length>0&&S[0].originalIndex===E.length),ce(({items:S})=>S[0].index),Je())),k=Ht(ee(y,ye(({items:S})=>S.length>0),ce(({items:S})=>{let E=0,j=S.length-1;for(;S[E].type==="group"&&E<j;)E++;for(;S[j].type==="group"&&j>E;)j--;return{endIndex:S[j].index,startIndex:S[E].index}}),Je(Uc)));return{endReached:T,initialItemCount:b,itemsRendered:v,listState:y,rangeChanged:k,startReached:I,topItemsIndexes:g,...h}},Xe(fn,Gc,yi,Jr,Xr,eo,Pn,gi),{singleton:!0}),nu=Re(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Oe(),i=vt(ee(ft(n,e,r,t,o),ce(([a,c,l,u,f])=>a+c+l+u+f.offsetBottom+f.bottom)),0);return me(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},Xe(Nt,Xn),{singleton:!0}),fx=Re(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=vt(ee(ft(n,e,t),ye(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),yn(0),Je()),0);return{alignToBottom:n,paddingTopAddition:r}},Xe(Nt,nu),{singleton:!0}),ru=Re(()=>({context:re(null)})),hx=({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,ou=Re(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:l}])=>{const u=Oe();return me(ee(u,Ne(t,c,n,s,o,r,a),Ne(e),ce(([[f,h,p,m,g,b,v,y],T])=>{const{align:I,behavior:k,calculateViewLocation:S=hx,done:E,...j}=f,_=Kc(f,h,m-1),D=Yr(_,h.offsetTree,T)+g+b,L=D+nn(h.sizeTree,_)[1],W=y+b,V=y+p-v,$=S({itemBottom:L,itemTop:D,locationParams:{align:I,behavior:k,...j},viewportBottom:V,viewportTop:W});return $?E&&tn(ee(i,ye(Z=>!Z),qn(lt(i)?1:2)),E):E&&E(),$}),ye(f=>f!==null)),l),{scrollIntoView:u}},Xe(fn,Nt,Xr,Xn,_n),{singleton:!0});function su(e){return e?e==="smooth"?"smooth":"auto":!1}const px=(e,t)=>typeof e=="function"?su(e(t)):t&&su(e),mx=Re(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const m=re(!1),g=Oe();let b=null;function v(k){Ae(i,{align:"end",behavior:k,index:"LAST"})}De(ee(ft(ee(ve(t),qn(1)),c),Ne(ve(m),s,a,f),ce(([[k,S],E,j,_,D])=>{let L=S&&_,W="auto";return L&&(W=px(E,j||D),L=L&&!!W),{followOutputBehavior:W,shouldFollow:L,totalCount:k}}),ye(({shouldFollow:k})=>k)),({followOutputBehavior:k,totalCount:S})=>{b&&(b(),b=null),lt(n)?requestAnimationFrame(()=>{lt(u)("following output to ",{totalCount:S},Dt.DEBUG),v(k)}):b=tn(e,()=>{lt(u)("following output to ",{totalCount:S},Dt.DEBUG),v(k),b=null})});function y(k){const S=tn(o,E=>{k&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!b&&(lt(u)("scrolling to bottom due to increased size",{},Dt.DEBUG),v("auto"))});setTimeout(S,100)}De(ee(ft(ve(m),t,l),ye(([k,,S])=>k&&S),dn(({value:k},[,S])=>({refreshed:k===S,value:S}),{refreshed:!1,value:0}),ye(({refreshed:k})=>k),Ne(m,t)),([,k])=>{lt(a)&&y(k!==!1)}),De(g,()=>{y(lt(m)!==!1)}),De(ft(ve(m),o),([k,S])=>{k&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const T=re(null),I=Oe();return me(ui(ee(ve(r),ce(k=>{var S;return(S=k==null?void 0:k.length)!=null?S:0})),ee(ve(t))),I),De(ee(ft(ee(I,qn(1)),c),Ne(ve(T),a,f,h),ce(([[k,S],E,j,_,D])=>S&&j&&(E==null?void 0:E({context:D,totalCount:k,scrollingInProgress:_}))),ye(k=>!!k),yn(0)),k=>{b&&(b(),b=null),lt(n)?requestAnimationFrame(()=>{lt(u)("scrolling into view",{}),Ae(p,k)}):b=tn(e,()=>{lt(u)("scrolling into view",{}),Ae(p,k),b=null})}),{autoscrollToBottom:g,followOutput:m,scrollIntoViewOnChange:T}},Xe(fn,eo,Xr,Jr,Pn,_n,Nt,ru,ou)),gx=Re(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(ee(a,Ne(s),ye(([,c])=>c!==0),Ne(o,r,t,n,e),ce(([[,c],l,u,f,h,p=[]])=>eu(c,l,u,f,h,p))),i),{}),Xe(fn,Jr,Xn,Pn),{singleton:!0}),xx=Re(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return De(ee(e,Ne(r),ye(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{tn(ee(n,qn(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ae(t,o)})})}),{initialScrollTop:r}},Xe(Pn,Nt,Xn),{singleton:!0}),iu=Re(([{scrollVelocity:e}])=>{const t=re(!1),n=Oe(),r=re(!1);return me(ee(e,Ne(r,t,n),ye(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:c,exit:l}=s;if(i){if(l(o,a))return!1}else if(c(o,a))return!0;return i}),Je()),t),De(ee(ft(t,e,n),Ne(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Xe(eo),{singleton:!0}),Ci=Re(([{scrollContainerState:e,scrollTo:t}])=>{const n=Oe(),r=Oe(),o=Oe(),s=re(!1),i=re(void 0);return me(ee(ft(n,r),ce(([{scrollHeight:a,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:a,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),me(ee(t,Ne(r),ce(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Xe(Nt)),bx=Re(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const l=Oe(),u=re(void 0),f=re(null),h=re(null);return me(a,f),me(c,h),De(ee(l,Ne(t,r,i,f,h,n)),([p,m,g,b,v,y,T])=>{const I=tx(m.sizeTree);b&&v!==null&&y!==null&&(g=v.scrollTop-y.offsetTop),g-=T,p({ranges:I,scrollTop:g})}),me(ee(u,ye(li),ce(wx)),o),me(ee(s,Ne(u),ye(([,p])=>p!==void 0),Je(),ce(([,p])=>p.ranges)),e),{getState:l,restoreStateFrom:u}},Xe(fn,Nt,Jr,Pn,Ci));function wx(e){return{align:"start",index:0,offset:e.scrollTop}}const vx=Re(([{topItemsIndexes:e}])=>{const t=re(0);return me(ee(t,ye(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Xe(Xn));function au(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const yx=au(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sx=Re(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:m}])=>{const g=Ht(ee(c,Ne(i),dn(([,v,y,T],[{bottom:I,items:k,offsetBottom:S,totalCount:E},j])=>{const _=I+S;let D=0;return y===E&&v.length>0&&k.length>0&&(k[0].originalIndex===0&&v[0].originalIndex===0||(D=_-T,D!==0&&(D+=j))),[D,k,E,_]},[0,[],0,0]),ye(([v])=>v!==0),Ne(r,a,n,o,p,m),ye(([,v,y,T,,,I])=>!I&&!T&&v!==0&&y===Zr),ce(([[v],,,,,y])=>(y("Upward scrolling compensation",{amount:v},Dt.DEBUG),v))));function b(v){v>0?(Ae(t,{behavior:"auto",top:-v}),Ae(e,0)):(Ae(e,0),Ae(t,{behavior:"auto",top:-v}))}return De(ee(g,Ne(e,s)),([v,y,T])=>{T&&yx()?Ae(e,y-v):b(-v)}),De(ee(ft(vt(s,!1),e,m),ye(([v,y,T])=>!v&&!T&&y!==0),ce(([v,y])=>y),yn(1)),b),me(ee(f,ce(v=>({top:-v}))),t),De(ee(l,Ne(h,u),ce(([v,{groupIndices:y,lastSize:T,sizeTree:I},k])=>{function S(E){return E*(T+k)}if(y.length===0)return S(v);{let E=0;const j=qr(I,0);let _=0,D=0;for(;_<v;){_++,E+=j;let L=y.length===D+1?1/0:y[D+1]-y[D]-1;_+L>v&&(E-=j,L=v-_+1),_+=L,E+=S(L),D++}return E}})),v=>{Ae(e,v),requestAnimationFrame(()=>{Ae(t,{top:v}),requestAnimationFrame(()=>{Ae(e,0),Ae(m,!1)})})}),{deviation:e}},Xe(Nt,eo,Xn,fn,_n,gi)),Cx=Re(([e,t,n,r,o,s,i,a,c,l,u])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...l,...u}),Xe(yi,gx,Pn,iu,nu,xx,fx,Ci,ou,_n,ru)),lu=Re(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:l,totalCount:u,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m},g,b,v,{listState:y,topItemsIndexes:T,...I},{scrollToIndex:k},S,{topItemCount:E},{groupCounts:j},_])=>(me(I.rangeChanged,_.scrollSeekRangeChanged),me(ee(_.windowViewportRect,ce(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m,sizeRanges:a,topItemCount:E,topItemsIndexes:T,totalCount:u,...v,groupIndices:s,itemSize:i,listState:y,scrollToIndex:k,statefulTotalCount:l,trackItemSizes:f,...I,..._,...g,sizes:c,...b}),Xe(fn,Jr,Nt,bx,mx,Xn,Xr,Sx,vx,Gc,Cx));function kx(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 Uo=typeof document<"u"?x.useLayoutEffect:x.useEffect;function cu(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=x.createContext({});function c(b,v){b.propsReady&&Ae(b.propsReady,!1);for(const y of r){const T=b[t.required[y]];Ae(T,v[y])}for(const y of o)if(y in v){const T=b[t.optional[y]];Ae(T,v[y])}b.propsReady&&Ae(b.propsReady,!0)}function l(b){return s.reduce((v,y)=>(v[y]=T=>{const I=b[t.methods[y]];Ae(I,T)},v),{})}function u(b){return i.reduce((v,y)=>(v[y]=zg(b[t.events[y]]),v),{})}const f=x.forwardRef((b,v)=>{const{children:y,...T}=b,[I]=x.useState(()=>Mo(Hg(e),E=>{c(E,T)})),[k]=x.useState(Pc(u,I));Uo(()=>{for(const E of i)E in T&&De(k[E],T[E]);return()=>{Object.values(k).map(ci)}},[T,k,I]),Uo(()=>{c(I,T)}),x.useImperativeHandle(v,_c(l(I)));const S=n;return d.jsx(a.Provider,{value:I,children:n?d.jsx(S,{...kx([...r,...o,...i],T),children:y}):y})}),h=b=>{const v=x.useContext(a);return x.useCallback(y=>{Ae(v[b],y)},[v,b])},p=b=>{const v=x.useContext(a)[b],y=x.useCallback(T=>De(v,T),[v]);return x.useSyncExternalStore(y,()=>lt(v),()=>lt(v))},m=b=>{const v=x.useContext(a)[b],[y,T]=x.useState(Pc(lt,v));return Uo(()=>De(v,I=>{I!==y&&T(_c(I))}),[v,y]),y},g=x.version.startsWith("18")?p:m;return{Component:f,useEmitter:(b,v)=>{const y=x.useContext(a)[b];Uo(()=>De(y,v),[v,y])},useEmitterValue:g,usePublisher:h}}const uu=x.createContext(void 0),du=x.createContext(void 0),fu=typeof document<"u"?x.useLayoutEffect:x.useEffect;function ki(e){return"self"in e}function Tx(e){return"body"in e}function hu(e,t,n,r=gr,o,s){const i=x.useRef(null),a=x.useRef(null),c=x.useRef(null),l=x.useCallback(h=>{let p,m,g;const b=h.target;if(Tx(b)||ki(b)){const y=ki(b)?b:b.defaultView;g=s?y.scrollX:y.scrollY,p=s?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight,m=s?y.innerWidth:y.innerHeight}else g=s?b.scrollLeft:b.scrollTop,p=s?b.scrollWidth:b.scrollHeight,m=s?b.offsetWidth:b.offsetHeight;const v=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:m})};h.suppressFlushSync?v():Ls.flushSync(v),a.current!==null&&(g===a.current||g<=0||g===p-m)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);x.useEffect(()=>{const h=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",l,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",l)}},[i,l,n,r,o]);function u(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const m=h.behavior==="smooth";let g,b,v;ki(p)?(b=Math.max(jn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(b=p[s?"scrollWidth":"scrollHeight"],g=jn(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const y=b-g;if(h.top=Math.ceil(Math.max(Math.min(y,h.top),0)),Xc(g,b)||h.top===v){e({scrollHeight:b,scrollTop:v,viewportHeight:g}),m&&t(!0);return}m?(a.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:u}}const Ti="-webkit-sticky",pu="sticky",Ei=au(()=>{if(typeof document>"u")return pu;const e=document.createElement("div");return e.style.position=Ti,e.style.position===Ti?Ti:pu});function Ii(e){return e}const Ex=Re(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(Ii),o=re("div"),s=re(gr),i=(a,c=null)=>vt(ee(n,ce(l=>l[a]),Je()),c);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")}}),Ix=Re(([e,t])=>({...e,...t}),Xe(lu,Ex)),Ax=({height:e})=>d.jsx("div",{style:{height:e}}),Nx={overflowAnchor:"none",position:Ei(),zIndex:1},mu={overflowAnchor:"none"},_x={...mu,display:"inline-block",height:"100%"},gu=x.memo(function({showTopList:e=!1}){const t=ke("listState"),n=Yt("sizeRanges"),r=ke("useWindowScroll"),o=ke("customScrollParent"),s=Yt("windowScrollContainerState"),i=Yt("scrollContainerState"),a=o||r?s:i,c=ke("itemContent"),l=ke("context"),u=ke("groupContent"),f=ke("trackItemSizes"),h=ke("itemSize"),p=ke("log"),m=Yt("gap"),g=ke("horizontalDirection"),{callbackRef:b}=Vg(n,h,f,e?gr:a,p,m,o,g,ke("skipAnimationFrameInResizeObserver")),[v,y]=x.useState(0);Ai("deviation",$=>{v!==$&&y($)});const T=ke("EmptyPlaceholder"),I=ke("ScrollSeekPlaceholder")||Ax,k=ke("ListComponent"),S=ke("ItemComponent"),E=ke("GroupComponent"),j=ke("computeItemKey"),_=ke("isSeeking"),D=ke("groupIndices").length>0,L=ke("alignToBottom"),W=ke("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&T?d.jsx(T,{...yt(T,l)}):d.jsx(k,{...yt(k,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:b,style:V,children:(e?t.topItems:t.items).map($=>{const Z=$.originalIndex,X=j(Z+t.firstItemIndex,$.data,l);return _?x.createElement(I,{...yt(I,l),height:$.size,index:$.index,key:X,type:$.type||"item",...$.type==="group"?{}:{groupIndex:$.groupIndex}}):$.type==="group"?x.createElement(E,{...yt(E,l),"data-index":Z,"data-item-index":$.index,"data-known-size":$.size,key:X,style:Nx},u($.index,l)):x.createElement(S,{...yt(S,l),...Rx(S,$.data),"data-index":Z,"data-item-group-index":$.groupIndex,"data-item-index":$.index,"data-known-size":$.size,key:X,style:g?_x:mu},D?c($.index,$.groupIndex,$.data,l):c($.index,$.data,l))})})}),jx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Px={outline:"none",overflowX:"auto",position:"relative"},Wo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ox={position:Ei(),top:0,width:"100%",zIndex:1};function yt(e,t){if(typeof e!="string")return{context:t}}function Rx(e,t){return{item:typeof e=="string"?void 0:t}}const Mx=x.memo(function(){const e=ke("HeaderComponent"),t=Yt("headerHeight"),n=ke("HeaderFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null}),Dx=x.memo(function(){const e=ke("FooterComponent"),t=Yt("footerHeight"),n=ke("HeaderFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null});function xu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),u=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:m}=hu(a,l,c,u,void 0,f);return e("scrollTo",m),e("scrollBy",h),d.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Px:jx,...o},tabIndex:0,...i,...yt(c,s),children:r})})}function bu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),u=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=x.useRef(null),m=t("scrollerRef"),{scrollByCallback:g,scrollerRef:b,scrollToCallback:v}=hu(a,l,c,m,h);return fu(()=>{var y;return b.current=h||((y=p.current)==null?void 0:y.ownerDocument.defaultView),()=>{b.current=null}},[b,h]),e("windowScrollTo",v),e("scrollBy",g),d.jsx(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...u!==0?{height:u+f}:{}},...i,...yt(c,s),children:r})})}const Lx=({children:e})=>{const t=x.useContext(uu),n=Yt("viewportHeight"),r=Yt("fixedItemHeight"),o=ke("alignToBottom"),s=ke("horizontalDirection"),i=x.useMemo(()=>jc(n,c=>jn(c,s?"width":"height")),[n,s]),a=Gn(i,!0,ke("skipAnimationFrameInResizeObserver"));return x.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),d.jsx("div",{"data-viewport-type":"element",ref:a,style:Wo(o),children:e})},$x=({children:e})=>{const t=x.useContext(uu),n=Yt("windowViewportRect"),r=Yt("fixedItemHeight"),o=ke("customScrollParent"),s=Dc(n,o,ke("skipAnimationFrameInResizeObserver")),i=ke("alignToBottom");return x.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),d.jsx("div",{"data-viewport-type":"window",ref:s,style:Wo(i),children:e})},Fx=({children:e})=>{const t=ke("TopItemListComponent")||"div",n=ke("headerHeight"),r={...Ox,marginTop:`${n}px`},o=ke("context");return d.jsx(t,{style:r,...yt(t,o),children:e})},zx=x.memo(function(e){const t=ke("useWindowScroll"),n=ke("topItemsIndexes").length>0,r=ke("customScrollParent"),o=ke("context");return d.jsxs(r||t?Ux:Hx,{...e,context:o,children:[n&&d.jsx(Fx,{children:d.jsx(gu,{showTopList:!0})}),d.jsxs(r||t?$x:Lx,{children:[d.jsx(Mx,{}),d.jsx(gu,{}),d.jsx(Dx,{})]})]})}),{Component:Bx,useEmitter:Ai,useEmitterValue:ke,usePublisher:Yt}=cu(Ix,{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"}},zx),Hx=xu({useEmitter:Ai,useEmitterValue:ke,usePublisher:Yt}),Ux=bu({useEmitter:Ai,useEmitterValue:ke,usePublisher:Yt}),Wx=Bx;Xe(lu,Re(()=>{const e=re(l=>d.jsxs("td",{children:["Item $",l]})),t=re(null),n=re(l=>d.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=re(null),o=re(null),s=re({}),i=re(Ii),a=re(gr),c=(l,u=null)=>vt(ee(s,ce(f=>f[l]),Je()),u);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),Ei();const wu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Vx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:vu,floor:Vo,max:to,min:Ni,round:yu}=Math;function Su(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Kx(e){return{...Vx,items:e}}function Ko(e,t){return e&&e.width===t.width&&e.height===t.height}function qx(e,t){return e&&e.column===t.column&&e.row===t.row}const Gx=Re(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:f},h,p,{didMount:m,propsReady:g},{customScrollParent:b,useWindowScroll:v,windowScrollContainerState:y,windowScrollTo:T,windowViewportRect:I},k])=>{const S=re(0),E=re(0),j=re(wu),_=re({height:0,width:0}),D=re({height:0,width:0}),L=Oe(),W=Oe(),V=re(0),$=re(null),Z=re({column:0,row:0}),X=Oe(),oe=Oe(),U=re(!1),F=re(0),G=re(!0),H=re(!1),A=re(!1);De(ee(m,Ne(F),ye(([P,K])=>!!K)),()=>{Ae(G,!1)}),De(ee(ft(m,G,D,_,F,H),ye(([P,K,te,le,,he])=>P&&!K&&te.height!==0&&le.height!==0&&!he)),([,,,,P])=>{Ae(H,!0),wi(1,()=>{Ae(L,P)}),tn(ee(l),()=>{Ae(t,[0,0]),Ae(G,!0)})}),me(ee(oe,ye(P=>P!=null&&P.scrollTop>0),un(0)),E),De(ee(m,Ne(oe),ye(([,P])=>P!=null)),([,P])=>{P&&(Ae(_,P.viewport),Ae(D,P.item),Ae(Z,P.gap),P.scrollTop>0&&(Ae(U,!0),tn(ee(l,qn(1)),K=>{Ae(U,!1)}),Ae(c,{top:P.scrollTop})))}),me(ee(_,ce(({height:P})=>P)),f),me(ee(ft(ve(_,Ko),ve(D,Ko),ve(Z,(P,K)=>P&&P.column===K.column&&P.row===K.row),ve(l)),ce(([P,K,te,le])=>({gap:te,item:K,scrollTop:le,viewport:P}))),X),me(ee(ft(ve(S),r,ve(Z,qx),ve(D,Ko),ve(_,Ko),ve($),ve(E),ve(U),ve(G),ve(F)),ye(([,,,,,,,P])=>!P),ce(([P,[K,te],le,he,ue,ge,be,,Be,Le])=>{const{column:je,row:Fe}=le,{height:tt,width:mt}=he,{width:ot}=ue;if(be===0&&(P===0||ot===0))return wu;if(mt===0){const st=vi(Le,P),an=st+Math.max(be-1,0);return Kx(Su(st,an,ge))}const ze=Cu(ot,mt,je);let Me,Ze;Be?K===0&&te===0&&be>0?(Me=0,Ze=be-1):(Me=ze*Vo((K+Fe)/(tt+Fe)),Ze=ze*vu((te+Fe)/(tt+Fe))-1,Ze=Ni(P-1,to(Ze,ze-1)),Me=Ni(Ze,to(0,Me))):(Me=0,Ze=-1);const rt=Su(Me,Ze,ge),{bottom:qe,top:ht}=ku(ue,le,he,rt),xt=vu(P/ze),He=xt*tt+(xt-1)*Fe-qe;return{bottom:qe,itemHeight:tt,items:rt,itemWidth:mt,offsetBottom:He,offsetTop:ht,top:ht}})),j),me(ee($,ye(P=>P!==null),ce(P=>P.length)),S),me(ee(ft(_,D,j,Z),ye(([P,K,{items:te}])=>te.length>0&&K.height!==0&&P.height!==0),ce(([P,K,{items:te},le])=>{const{bottom:he,top:ue}=ku(P,le,K,te);return[ue,he]}),Je(Gr)),t);const N=re(!1);me(ee(l,Ne(N),ce(([P,K])=>K||P!==0)),N);const R=Ht(ee(ft(j,S),ye(([{items:P}])=>P.length>0),Ne(N),ye(([[P,K],te])=>{const le=P.items[P.items.length-1].index===K-1;return(te||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===K)&&le}),ce(([[,P]])=>P-1),Je())),M=Ht(ee(ve(j),ye(({items:P})=>P.length>0&&P[0].index===0),un(0),Je())),q=Ht(ee(ve(j),Ne(U),ye(([{items:P},K])=>P.length>0&&!K),ce(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),Je(Uc),yn(0)));me(q,p.scrollSeekRangeChanged),me(ee(L,Ne(_,D,S,Z),ce(([P,K,te,le,he])=>{const ue=Yc(P),{align:ge,behavior:be,offset:Be}=ue;let Le=ue.index;Le==="LAST"&&(Le=le-1),Le=to(0,Le,Ni(le-1,Le));let je=_i(K,he,te,Le);return ge==="end"?je=yu(je-K.height+te.height):ge==="center"&&(je=yu(je-K.height/2+te.height/2)),Be&&(je+=Be),{behavior:be,top:je}})),c);const J=vt(ee(j,ce(P=>P.offsetBottom+P.bottom)),0);return me(ee(I,ce(P=>({height:P.visibleHeight,width:P.visibleWidth}))),_),{customScrollParent:b,data:$,deviation:V,footerHeight:o,gap:Z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:oe,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:c,scrollToIndex:L,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:v,viewportDimensions:_,windowScrollContainerState:y,windowScrollTo:T,windowViewportRect:I,...p,gridState:j,horizontalDirection:A,initialTopMostItemIndex:F,totalListHeight:J,...h,endReached:R,propsReady:g,rangeChanged:q,startReached:M,stateChanged:X,stateRestoreInProgress:U,...k}},Xe(yi,Nt,eo,iu,Pn,Ci,_n));function Cu(e,t,n){return to(1,Vo((e+n)/(Vo(t)+n)))}function ku(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=_i(e,t,n,r[0].index);return{bottom:_i(e,t,n,r[r.length-1].index)+o,top:s}}function _i(e,t,n,r){const o=Cu(e.width,n.width,t.column),s=Vo(r/o),i=s*n.height+to(0,s-1)*t.row;return i>0?i+t.row:i}const Yx=Re(()=>{const e=re(f=>`Item ${f}`),t=re({}),n=re(null),r=re("virtuoso-grid-item"),o=re("virtuoso-grid-list"),s=re(Ii),i=re("div"),a=re(gr),c=(f,h=null)=>vt(ee(t,ce(p=>p[f]),Je()),h),l=re(!1),u=re(!1);return me(ve(u),l),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Xx=Re(([e,t])=>({...e,...t}),Xe(Gx,Yx)),Jx=x.memo(function(){const e=Qe("gridState"),t=Qe("listClassName"),n=Qe("itemClassName"),r=Qe("itemContent"),o=Qe("computeItemKey"),s=Qe("isSeeking"),i=Xt("scrollHeight"),a=Qe("ItemComponent"),c=Qe("ListComponent"),l=Qe("ScrollSeekPlaceholder"),u=Qe("context"),f=Xt("itemDimensions"),h=Xt("gap"),p=Qe("log"),m=Qe("stateRestoreInProgress"),g=Xt("reportReadyState"),b=Gn(x.useMemo(()=>v=>{const y=v.parentElement.parentElement.scrollHeight;i(y);const T=v.firstChild;if(T){const{height:I,width:k}=T.getBoundingClientRect();f({height:I,width:k})}h({column:Eu("column-gap",getComputedStyle(v).columnGap,p),row:Eu("row-gap",getComputedStyle(v).rowGap,p)})},[i,f,h,p]),!0,!1);return fu(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),m?null:d.jsx(c,{className:t,ref:b,...yt(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const y=o(v.index,v.data,u);return s?d.jsx(l,{...yt(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},y):x.createElement(a,{...yt(a,u),className:n,"data-index":v.index,key:y},r(v.index,v.data,u))})})}),Zx=x.memo(function(){const e=Qe("HeaderComponent"),t=Xt("headerHeight"),n=Qe("headerFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null}),Qx=x.memo(function(){const e=Qe("FooterComponent"),t=Xt("footerHeight"),n=Qe("headerFooterTag"),r=Gn(x.useMemo(()=>s=>{t(jn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?d.jsx(n,{ref:r,children:d.jsx(e,{...yt(e,o)})}):null}),eb=({children:e})=>{const t=x.useContext(du),n=Xt("itemDimensions"),r=Xt("viewportDimensions"),o=Gn(x.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return x.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),d.jsx("div",{ref:o,style:Wo(!1),children:e})},tb=({children:e})=>{const t=x.useContext(du),n=Xt("windowViewportRect"),r=Xt("itemDimensions"),o=Qe("customScrollParent"),s=Dc(n,o,!1);return x.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),d.jsx("div",{ref:s,style:Wo(!1),children:e})},nb=x.memo(function({...e}){const t=Qe("useWindowScroll"),n=Qe("customScrollParent"),r=n||t?ob:rb,o=n||t?tb:eb,s=Qe("context");return d.jsx(r,{...e,...yt(r,s),children:d.jsxs(o,{children:[d.jsx(Zx,{}),d.jsx(Jx,{}),d.jsx(Qx,{})]})})}),{useEmitter:Tu,useEmitterValue:Qe,usePublisher:Xt}=cu(Xx,{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"}},nb),rb=xu({useEmitter:Tu,useEmitterValue:Qe,usePublisher:Xt}),ob=bu({useEmitter:Tu,useEmitterValue:Qe,usePublisher:Xt});function Eu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Dt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Se(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 Iu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Iu(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():Iu(e[o],null)}}}}function et(...e){return w.useCallback(On(...e),e)}function sb(e,t){const n=w.createContext(t),r=s=>{const{children:i,...a}=s,c=w.useMemo(()=>a,Object.values(a));return d.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=w.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 Rn(e,t=[]){let n=[];function r(s,i){const a=w.createContext(i),c=n.length;n=[...n,i];const l=f=>{var v;const{scope:h,children:p,...m}=f,g=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,b=w.useMemo(()=>m,Object.values(m));return d.jsx(g.Provider,{value:b,children:p})};l.displayName=s+"Provider";function u(f,h){var g;const p=((g=h==null?void 0:h[e])==null?void 0:g[c])||a,m=w.useContext(p);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[l,u]}const o=()=>{const s=n.map(i=>w.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return w.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,ib(o,...t)]}function ib(...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:c,scopeName:l})=>{const f=c(s)[`__scope${l}`];return{...a,...f}},{});return w.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var hn=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},ab=w[" useId ".trim().toString()]||(()=>{}),lb=0;function Wt(e){const[t,n]=w.useState(ab());return hn(()=>{n(r=>r??String(lb++))},[e]),e||(t?`radix-${t}`:"")}var cb=w[" useInsertionEffect ".trim().toString()]||hn;function qo({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ub({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const u=w.useRef(e!==void 0);w.useEffect(()=>{const f=u.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const l=w.useCallback(u=>{var f;if(a){const h=db(u)?u(e):u;h!==e&&((f=i.current)==null||f.call(i,h))}else s(u)},[a,e,s,i]);return[c,l]}function ub({defaultProp:e,onChange:t}){const[n,r]=w.useState(e),o=w.useRef(n),s=w.useRef(t);return cb(()=>{s.current=t},[t]),w.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function db(e){return typeof e=="function"}var fb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Pe=fb.reduce((e,t)=>{const n=sr.createSlot(`Primitive.${t}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Au(e,t){e&&Ja.flushSync(()=>e.dispatchEvent(t))}function St(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function hb(e,t=globalThis==null?void 0:globalThis.document){const n=St(e);w.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 pb="DismissableLayer",ji="dismissableLayer.update",mb="dismissableLayer.pointerDownOutside",gb="dismissableLayer.focusOutside",Nu,_u=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Pi=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,l=w.useContext(_u),[u,f]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),m=et(t,E=>f(E)),g=Array.from(l.layers),[b]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(b),y=u?g.indexOf(u):-1,T=l.layersWithOutsidePointerEventsDisabled.size>0,I=y>=v,k=wb(E=>{const j=E.target,_=[...l.branches].some(D=>D.contains(j));!I||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),S=vb(E=>{const j=E.target;[...l.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return hb(E=>{y===l.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Nu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),ju(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Nu)}},[u,h,n,l]),w.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),ju())},[u,l]),w.useEffect(()=>{const E=()=>p({});return document.addEventListener(ji,E),()=>document.removeEventListener(ji,E)},[]),d.jsx(Pe.div,{...c,ref:m,style:{pointerEvents:T?I?"auto":"none":void 0,...e.style},onFocusCapture:Se(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Se(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Se(e.onPointerDownCapture,k.onPointerDownCapture)})});Pi.displayName=pb;var xb="DismissableLayerBranch",bb=w.forwardRef((e,t)=>{const n=w.useContext(_u),r=w.useRef(null),o=et(t,r);return w.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(Pe.div,{...e,ref:o})});bb.displayName=xb;function wb(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){Pu(mb,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 vb(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=w.useRef(!1);return w.useEffect(()=>{const o=s=>{s.target&&!r.current&&Pu(gb,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 ju(){const e=new CustomEvent(ji);document.dispatchEvent(e)}function Pu(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?Au(o,s):o.dispatchEvent(s)}var Oi="focusScope.autoFocusOnMount",Ri="focusScope.autoFocusOnUnmount",Ou={bubbles:!1,cancelable:!0},yb="FocusScope",Mi=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=w.useState(null),l=St(o),u=St(s),f=w.useRef(null),h=et(t,g=>c(g)),p=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let g=function(T){if(p.paused||!a)return;const I=T.target;a.contains(I)?f.current=I:Mn(f.current,{select:!0})},b=function(T){if(p.paused||!a)return;const I=T.relatedTarget;I!==null&&(a.contains(I)||Mn(f.current,{select:!0}))},v=function(T){if(document.activeElement===document.body)for(const k of T)k.removedNodes.length>0&&Mn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const y=new MutationObserver(v);return a&&y.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),y.disconnect()}}},[r,a,p.paused]),w.useEffect(()=>{if(a){Du.add(p);const g=document.activeElement;if(!a.contains(g)){const v=new CustomEvent(Oi,Ou);a.addEventListener(Oi,l),a.dispatchEvent(v),v.defaultPrevented||(Sb(Ib(Ru(a)),{select:!0}),document.activeElement===g&&Mn(a))}return()=>{a.removeEventListener(Oi,l),setTimeout(()=>{const v=new CustomEvent(Ri,Ou);a.addEventListener(Ri,u),a.dispatchEvent(v),v.defaultPrevented||Mn(g??document.body,{select:!0}),a.removeEventListener(Ri,u),Du.remove(p)},0)}}},[a,l,u,p]);const m=w.useCallback(g=>{if(!n&&!r||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(b&&v){const y=g.currentTarget,[T,I]=Cb(y);T&&I?!g.shiftKey&&v===I?(g.preventDefault(),n&&Mn(T,{select:!0})):g.shiftKey&&v===T&&(g.preventDefault(),n&&Mn(I,{select:!0})):v===y&&g.preventDefault()}},[n,r,p.paused]);return d.jsx(Pe.div,{tabIndex:-1,...i,ref:h,onKeyDown:m})});Mi.displayName=yb;function Sb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Mn(r,{select:t}),document.activeElement!==n)return}function Cb(e){const t=Ru(e),n=Mu(t,e),r=Mu(t.reverse(),e);return[n,r]}function Ru(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 Mu(e,t){for(const n of e)if(!kb(n,{upTo:t}))return n}function kb(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 Tb(e){return e instanceof HTMLInputElement&&"select"in e}function Mn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Tb(e)&&t&&e.select()}}var Du=Eb();function Eb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Lu(e,t),e.unshift(t)},remove(t){var n;e=Lu(e,t),(n=e[0])==null||n.resume()}}}function Lu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ib(e){return e.filter(t=>t.tagName!=="A")}var Ab="Portal",Di=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=w.useState(!1);hn(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ls.createPortal(d.jsx(Pe.div,{...r,ref:t}),i):null});Di.displayName=Ab;function Nb(e,t){return w.useReducer((n,r)=>t[n][r]??n,e)}var Vt=e=>{const{present:t,children:n}=e,r=_b(t),o=typeof n=="function"?n({present:r.isPresent}):w.Children.only(n),s=et(r.ref,jb(o));return typeof n=="function"||r.isPresent?w.cloneElement(o,{ref:s}):null};Vt.displayName="Presence";function _b(e){const[t,n]=w.useState(),r=w.useRef(null),o=w.useRef(e),s=w.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Nb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{const l=Go(r.current);s.current=a==="mounted"?l:"none"},[a]),hn(()=>{const l=r.current,u=o.current;if(u!==e){const h=s.current,p=Go(l);e?c("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),hn(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,f=p=>{const g=Go(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(c("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},h=p=>{p.target===t&&(s.current=Go(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:w.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function Go(e){return(e==null?void 0:e.animationName)||"none"}function jb(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 Li=0;function $u(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Fu()),document.body.insertAdjacentElement("beforeend",e[1]??Fu()),Li++,()=>{Li===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Li--}},[])}function Fu(){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 pn=function(){return pn=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},pn.apply(this,arguments)};function zu(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 Pb(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 Yo="right-scroll-bar-position",Xo="width-before-scroll-bar",Ob="with-scroll-bars-hidden",Rb="--removed-body-scroll-bar-size";function $i(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Mb(e,t){var n=x.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 Db=typeof window<"u"?w.useLayoutEffect:w.useEffect,Bu=new WeakMap;function Lb(e,t){var n=Mb(null,function(r){return e.forEach(function(o){return $i(o,r)})});return Db(function(){var r=Bu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||$i(a,null)}),s.forEach(function(a){o.has(a)||$i(a,i)})}Bu.set(n,e)},[e]),n}function $b(e){return e}function Fb(e,t){t===void 0&&(t=$b);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 c=function(){var u=i;i=[],u.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return o}function zb(e){e===void 0&&(e={});var t=Fb(null);return t.options=pn({async:!0,ssr:!1},e),t}var Hu=function(e){var t=e.sideCar,n=zu(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 w.createElement(r,pn({},n))};Hu.isSideCarExport=!0;function Bb(e,t){return e.useMedium(t),Hu}var Uu=zb(),Fi=function(){},Jo=w.forwardRef(function(e,t){var n=w.useRef(null),r=w.useState({onScrollCapture:Fi,onWheelCapture:Fi,onTouchMoveCapture:Fi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,b=e.allowPinchZoom,v=e.as,y=v===void 0?"div":v,T=e.gapMode,I=zu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,S=Lb([n,t]),E=pn(pn({},I),o);return w.createElement(w.Fragment,null,u&&w.createElement(k,{sideCar:Uu,removeScrollBar:l,shards:f,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:T}),i?w.cloneElement(w.Children.only(a),pn(pn({},E),{ref:S})):w.createElement(y,pn({},E,{className:c,ref:S}),a))});Jo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Jo.classNames={fullWidth:Xo,zeroRight:Yo};var Hb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ub(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Hb();return t&&e.setAttribute("nonce",t),e}function Wb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Kb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ub())&&(Wb(t,n),Vb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qb=function(){var e=Kb();return function(t,n){w.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wu=function(){var e=qb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Gb={left:0,top:0,right:0,gap:0},zi=function(e){return parseInt(e||"",10)||0},Yb=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[zi(n),zi(r),zi(o)]},Xb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gb;var t=Yb(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])}},Jb=Wu(),br="data-scroll-locked",Zb=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(Ob,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|