teodor-new-chat-ui 3.0.182 → 3.0.183
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 +45 -51
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3202,58 +3202,52 @@ function Ms({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3202
3202
|
}, [u, H, L, k]), he = Ye(async ($, Y) => {
|
|
3203
3203
|
await u.updateThread($, Y), await H();
|
|
3204
3204
|
}, [u, H]), ye = Ye(async ($, Y) => {
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
...
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
{
|
|
3248
|
-
onError: (ze) => console.warn("stream error", ze),
|
|
3249
|
-
onOpen: ({ threadId: ze, created: Lt }) => {
|
|
3250
|
-
!L && ze && (j(ze), Lt && H().catch(() => {
|
|
3251
|
-
}));
|
|
3252
|
-
}
|
|
3205
|
+
var je;
|
|
3206
|
+
const Ae = (Y == null ? void 0 : Y.attachments) || [], { contentParts: tt, filesInfo: Ne } = await Vg(
|
|
3207
|
+
u,
|
|
3208
|
+
Ae,
|
|
3209
|
+
t == null ? void 0 : t.uploadPath
|
|
3210
|
+
), at = [];
|
|
3211
|
+
$ && $.trim() && at.push({ type: "text", text: $.trim() });
|
|
3212
|
+
const Dt = {
|
|
3213
|
+
id: ((je = crypto.randomUUID) == null ? void 0 : je.call(crypto)) || `user-${Date.now()}`,
|
|
3214
|
+
role: "user",
|
|
3215
|
+
content: at,
|
|
3216
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3217
|
+
checkpointId: (Y == null ? void 0 : Y.checkpointId) ?? w.lastCheckpointId ?? void 0,
|
|
3218
|
+
checkpointNs: (Y == null ? void 0 : Y.checkpointNs) ?? w.lastCheckpointNs ?? void 0
|
|
3219
|
+
};
|
|
3220
|
+
S(Dt);
|
|
3221
|
+
const _n = {
|
|
3222
|
+
...Dt,
|
|
3223
|
+
content: at
|
|
3224
|
+
}, xt = { ...(Y == null ? void 0 : Y.payloadExtras) ?? {} }, At = !!xt.edit, ht = xt.originalMessageId, Rt = typeof ht == "string" ? ht : void 0, te = Ae && Ae.length > 0, pe = {
|
|
3225
|
+
...L ? { threadId: L } : {},
|
|
3226
|
+
payload: {
|
|
3227
|
+
messages: [_n],
|
|
3228
|
+
files_info: Ne,
|
|
3229
|
+
...a && te && c ? { active_agent: c } : {},
|
|
3230
|
+
...xt
|
|
3231
|
+
},
|
|
3232
|
+
checkpointId: (Y == null ? void 0 : Y.checkpointId) ?? w.lastCheckpointId ?? void 0,
|
|
3233
|
+
checkpointNs: (Y == null ? void 0 : Y.checkpointNs) ?? w.lastCheckpointNs ?? void 0,
|
|
3234
|
+
nodeFilter: Y == null ? void 0 : Y.nodeFilter,
|
|
3235
|
+
config: Y == null ? void 0 : Y.config,
|
|
3236
|
+
edit: At,
|
|
3237
|
+
originalMessageId: Rt
|
|
3238
|
+
};
|
|
3239
|
+
h(
|
|
3240
|
+
pe,
|
|
3241
|
+
(ze) => C(ze),
|
|
3242
|
+
{
|
|
3243
|
+
onError: (ze) => console.warn("stream error", ze),
|
|
3244
|
+
onOpen: ({ threadId: ze, created: Lt }) => {
|
|
3245
|
+
!L && ze && (j(ze), Lt && H().catch(() => {
|
|
3246
|
+
}));
|
|
3253
3247
|
}
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
}, [L, S, h, C, w.lastCheckpointId, w.lastCheckpointNs, u, t == null ? void 0 : t.uploadPath, H, j, a, c
|
|
3248
|
+
}
|
|
3249
|
+
);
|
|
3250
|
+
}, [L, S, h, C, w.lastCheckpointId, w.lastCheckpointNs, u, t == null ? void 0 : t.uploadPath, H, j, a, c]), Pe = Ye(
|
|
3257
3251
|
async ($) => {
|
|
3258
3252
|
if (!L) throw new Error("No active thread");
|
|
3259
3253
|
if (I || !N) return;
|
package/dist/index.umd.js
CHANGED
|
@@ -35,7 +35,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
35
35
|
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=_n(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&oo.assertOptions(r,{silentJSONParsing:Zt.transitional(Zt.boolean),forcedJSONParsing:Zt.transitional(Zt.boolean),clarifyTimeoutError:Zt.transitional(Zt.boolean)},!1),o!=null&&(_.isFunction(o)?n.paramsSerializer={serialize:o}:oo.assertOptions(o,{encode:Zt.function,serialize:Zt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),oo.assertOptions(n,{baseUrl:Zt.spelling("baseURL"),withXsrfToken:Zt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&_.merge(s.common,s[n.method]);s&&_.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),n.headers=Tt.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(c=c&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!c){const b=[ul.bind(this),void 0];for(b.unshift(...a),b.push(...u),h=b.length,d=Promise.resolve(n);f<h;)d=d.then(b[f++],b[f++]);return d}h=a.length;let m=n;for(;f<h;){const b=a[f++],v=a[f++];try{m=b(m)}catch(g){v.call(this,g);break}}try{d=ul.call(this,m)}catch(b){return Promise.reject(b)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=_n(this.defaults,t);const n=Qa(t.baseURL,t.url,t.allowAbsoluteUrls);return Wa(n,t.params,t.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(t){jn.prototype[t]=function(n,r){return this.request(_n(r||{},{method:t,url:n,data:(r||{}).data}))}}),_.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(_n(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}jn.prototype[t]=n(),jn.prototype[t+"Form"]=n(!0)});let _m=class ap{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new Zn(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ap(function(o){t=o}),cancel:t}}};function jm(e){return function(n){return e.apply(null,n)}}function Pm(e){return _.isObject(e)&&e.isAxiosError===!0}const $s={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries($s).forEach(([e,t])=>{$s[t]=e});function hl(e){const t=new jn(e),n=Aa(jn.prototype.request,t);return _.extend(n,jn.prototype,t,{allOwnKeys:!0}),_.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return hl(_n(e,o))},n}const rt=hl(wr);rt.Axios=jn,rt.CanceledError=Zn,rt.CancelToken=_m,rt.isCancel=Ya,rt.VERSION=dl,rt.toFormData=Qr,rt.AxiosError=Ie,rt.Cancel=rt.CanceledError,rt.all=function(t){return Promise.all(t)},rt.spread=jm,rt.isAxiosError=Pm,rt.mergeConfig=_n,rt.AxiosHeaders=Tt,rt.formToJSON=e=>Ka(_.isHTMLForm(e)?new FormData(e):e),rt.getAdapter=cl.getAdapter,rt.HttpStatusCode=$s,rt.default=rt;const{Axios:iC,AxiosError:aC,CanceledError:lC,isCancel:cC,CancelToken:uC,VERSION:dC,all:fC,Cancel:hC,isAxiosError:pC,spread:mC,toFormData:gC,AxiosHeaders:xC,HttpStatusCode:vC,formToJSON:wC,getAdapter:bC,mergeConfig:yC}=rt,pl=typeof window<"u"?window.__API_BASE_URL__:void 0,ml=pl?pl.replace(/\/+$/,""):void 0;let so=null;const Fs=new Set;function gl(){return so}function zs(e){so=e,Fs.forEach(t=>t(e))}function xl(e){return Fs.add(e),()=>Fs.delete(e)}const Mt=rt.create({...ml?{baseURL:ml}:{},timeout:3e4,withCredentials:!0});Mt.interceptors.request.use(e=>(so&&(e.headers.Authorization=`Bearer ${so}`),e)),Mt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Nt(e,t){return Mt.defaults.baseURL?(await Mt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function vl(e,t,n){return Mt.defaults.baseURL?(await Mt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function wl(e,t,n){return Mt.defaults.baseURL?(await Mt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function bl(e,t){return Mt.defaults.baseURL?(await Mt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Dt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class yl{get baseUrl(){const t=Mt.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(Mt.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&zs(t.authToken)}getAuthToken(){return gl()}setAuthToken(t){zs(t)}onTokenChange(t){return xl(t)}async listThreads(){const t=await Nt("/chat/threads"),n=Dt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await vl("/chat/threads",t?{title:t}:void 0);return Dt(r)}async updateThread(t,n){const r=await wl(`/chat/threads/${t}`,{title:n});return Dt(r)}async deleteThread(t){const n=await bl(`/chat/threads/${t}`);return Dt(n)}async threadInfo(t){const n=await Nt(`/chat/threads/${t}/info`);return Dt(n)}async listAgents(){const t=await Nt("/chat/agents"),n=Dt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Nt(`/chat/agents/${t}`);return Dt(n)}async getAgentSchema(t){const n=await Nt(`/chat/agents/${t}/schema`);return Dt(n)}async getMessages(t){const n=await Nt(`/chat/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Dt(n)}async getState(t){const n=await Nt(`/chat/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Dt(n)}async getStateHistory(t){const n=await Nt(`/chat/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Dt(n)}async listCheckpoints(t){const n=await Nt(`/chat/threads/${t}/checkpoints`,{params:{thread_id:t}});return Dt(n)}}const gn=new yl;function Sl(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/runs/stream",[r,o]=C.useState(e.token??null),s=C.useRef(e.headers??{}),[i,a]=C.useState(!1),[c,u]=C.useState(null),[d,f]=C.useState(""),[h,m]=C.useState(null),[b,v]=C.useState(0),[g,x]=C.useState(!1),w=C.useRef(null),y=C.useRef(!0),E=C.useRef(0),S=C.useCallback(R=>{o(R)},[]),T=C.useCallback(()=>{var R;(R=w.current)==null||R.abort(),w.current=null,a(!1),x(!1)},[]),I=C.useCallback(()=>{f(""),m(null),u(null)},[]),N=C.useCallback((R,j,A)=>{w.current&&(w.current.abort(),w.current=null),a(!0),u(null),e.autoAppendAssistant!==!1&&f("");const z=new AbortController;return w.current=z,(async()=>{var O,G,W,q,L,M,le,Z;const V=ee=>{var D;try{const J=JSON.parse(JSON.stringify(ee));return(D=J==null?void 0:J.payload)!=null&&D.files_info&&Array.isArray(J.payload.files_info)&&(J.payload.files_info=J.payload.files_info.map(ke=>({...ke,data:ke!=null&&ke.data?`<base64 ${String(ke.data).length} chars>`:ke==null?void 0:ke.data}))),J}catch{return ee}};try{let ee={};try{if(r)ee={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ne=window.__AUTH_TOKEN__,Ue=((O=window.localStorage)==null?void 0:O.getItem("authToken"))||null;let et=null;try{const ut=(G=window.localStorage)==null?void 0:G.getItem("chat-settings");ut&&(et=((W=JSON.parse(ut))==null?void 0:W.apiKey)||null)}catch{}const Xe=Ne||Ue||et||null;Xe&&(ee={Authorization:`Bearer ${Xe}`})}}catch{}console.debug("[use-chat] POST",t+n,V(R));const D=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...ee,...s.current},body:JSON.stringify(R),signal:z.signal});if(!D.ok||!D.body){const we=await D.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",D.status,we==null?void 0:we.slice(0,500)),new Error(`stream ${D.status}${we?": "+we:""}`)}x(!0);const J=D.body.getReader(),ke=new TextDecoder;let he="",$=[],P=E.current,H=null;const Q=()=>{if($.length){const we=$.join("");$=[],y.current&&f(Ne=>Ne+we)}H=null},ce=()=>{typeof window<"u"&&H==null&&(H=requestAnimationFrame(Q))};let ie=Date.now();const Fe=setInterval(()=>{var we;if(Date.now()-ie>2e4){const Ne="Stream idle timeout";u(Ne),z.abort(),(we=A==null?void 0:A.onError)==null||we.call(A,Ne)}},5e3),$e=1024*1024;try{const we=D.headers.get("X-Thread-Id")||D.headers.get("x-thread-id"),Ne=D.headers.get("X-Thread-Created")||D.headers.get("x-thread-created"),Ue=we??null,et=String(Ne??"").toLowerCase()==="true";for((q=A==null?void 0:A.onOpen)==null||q.call(A,{threadId:Ue,created:et});;){const{value:Xe,done:ut}=await J.read();if(ut)break;he+=ke.decode(Xe,{stream:!0}),he.length>$e&&(he="",console.warn("Stream buffer reset: exceeded 1MB"));let dt;for(;(dt=he.indexOf(`
|
|
36
36
|
|
|
37
37
|
`))>=0;){const ue=he.slice(0,dt);he=he.slice(dt+2);const fe=Mm(ue);if(!fe)continue;let pe;try{pe=JSON.parse(fe)}catch{console.debug("[use-chat] malformed SSE:",fe.slice(0,200));continue}const Se=Om(pe)?pe.data:pe;ie=Date.now(),j==null||j(Se);const Oe=Se.seq;if(Oe!==void 0){if(Oe<=P)continue;P>0&&Oe>P+1&&((L=A==null?void 0:A.onGap)==null||L.call(A,{from:P,to:Oe})),P=Oe,E.current=Oe,v(Oe)}if(Se.type==="token"&&e.autoAppendAssistant!==!1)$.push(Se.content),ce();else if(Se.type==="message_delta"){const Ve=Se.delta.filter(F=>F.type==="text").map(F=>F.text).join("");Ve&&e.autoAppendAssistant!==!1&&($.push(Ve),ce())}else H!==null&&cancelAnimationFrame(H),Q(),Se.type==="checkpoint"?m(Se.checkpointId):Se.type==="error"&&u(Se.message)}}Q()}catch(we){if(we.name!=="AbortError"){const Ne=we.message||String(we);u(Ne),(M=A==null?void 0:A.onError)==null||M.call(A,Ne)}}finally{try{await J.cancel()}catch{}finally{(le=J.releaseLock)==null||le.call(J)}H!==null&&typeof window<"u"&&window.cancelAnimationFrame(H),clearInterval(Fe),a(!1),x(!1),w.current=null}}catch(ee){if(ee.name!=="AbortError"){const D=ee.message||String(ee);u(D),(Z=A==null?void 0:A.onError)==null||Z.call(A,D)}}finally{a(!1),x(!1),w.current=null}})(),{close:()=>z.abort()}},[t,n,r,e.autoAppendAssistant]);return C.useEffect(()=>()=>{var R;y.current=!1,(R=w.current)==null||R.abort()},[]),{isStreaming:i,error:c,assistantText:d,lastCheckpointId:h,lastSeq:b,connected:g,stream:N,stop:T,clear:I,setToken:S}}function Om(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Mm(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
|
|
38
|
-
`)}const Dm={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Lm(e,t){var n;switch(t.type){case"reset":console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Bs(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r;case"seed":{const o=Bs(t.payload.messages),s={...e,messages:o,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(s.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(s.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:o.length,previousCount:e.messages.length,checkpointId:s.lastCheckpointId}),s}case"prepend":{const o=Bs(t.payload.messages);if(!o.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const s=new Set(e.messages.map(a=>a.id)),i=o.filter(a=>!s.has(a.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:i.length,duplicates:o.length-i.length,finalTotal:i.length+e.messages.length}),i.length?{...e,messages:[...i,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const o=t.payload.message;if(e.assemblingId){const s=e.messages.findIndex(i=>i.id===e.assemblingId);if(s!==-1)return{...e,messages:[...e.messages.slice(0,s),o,...e.messages.slice(s)]}}return{...e,messages:[...e.messages,o]}}case"event":return Tl(e,t.payload.ev);case"batch":{const{events:o}=t.payload;return o.length?o.reduce((s,i)=>Tl(s,i),e):e}default:return e}}function Cl(e=[]){const[t,n]=C.useReducer(Lm,{...Dm,messages:e}),r=C.useRef([]),o=C.useRef(null),s=C.useRef(null),i=C.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=C.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=C.useCallback(d=>{r.current.push(d),a()},[a]);C.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=C.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:c}),[c]);return{state:t,dispatch:n,...u}}function Tl(e,t){var n;if(t.type==="message_start"&&t.role==="assistant"){const r=t.id,o=Hm(t.model),s={id:r,role:"assistant",name:o||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:r,messages:[...e.messages,s]}}if(t.type==="token"){const r=e.assemblingId??Hs(e.messages);return r?{...e,messages:Fm(e.messages,r,t.content)}:e}if(t.type==="message_delta"){const r=e.assemblingId??Hs(e.messages);return r?{...e,messages:El(e.messages,r,t.delta)}:e}if(t.type==="message_end"){const r=e.assemblingId??Hs(e.messages);if(!r)return{...e,assemblingId:null};const o=e.messages,s=o.findIndex(i=>i.id===r&&i.role==="assistant");if(s>=0&&!((n=o[s].content)==null?void 0:n.some(c=>{var u;return(c==null?void 0:c.type)==="text"&&((u=c.text)==null?void 0:u.trim())}))){const c=[...o.slice(0,s),...o.slice(s+1)];return{...e,assemblingId:null,messages:c}}return e}if(t.type==="tool_start"){const r=`tool-${t.id}`,o={type:"tool_call",id:t.id,name:t.name,args:t.args},s={id:r,role:"tool",name:t.name,createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,s],toolIndex:{...e.toolIndex,[t.id]:r}}}if(t.type==="tool_result"){const r=e.toolIndex[t.id]??`tool-${t.id}`,o={type:"tool_result",toolCallId:t.id,output:t.output,error:t.error},s=e.messages.find(c=>c.id===r),i={id:r,role:"tool",content:[o],createdAt:new Date().toISOString()},a=s?El(e.messages,r,[o]):[...e.messages,i];return{...e,messages:a}}if(t.type==="checkpoint"){const r=t.checkpointNs??e.lastCheckpointNs??null,o=Bm(e.messages,t.checkpointId,r);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:r,messages:o}}if(t.type==="branch"){const r=t.checkpointId??e.lastCheckpointId,o=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:r??null,lastCheckpointNs:o??null}}if(t.type==="error"){const r={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,r]}}return e}function Bs(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function $m(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Hs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function kl(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Fm(e,t,n){return kl(e,t,r=>{const o=r.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=n:o.push({type:"text",text:n}),{...r,content:o}})}function El(e,t,n){return kl(e,t,r=>({...r,content:zm(r.content,n)}))}function zm(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Bm(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 $m(e,r,s)}return e}function Hm(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Um(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function Wm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Vm(e,t=[],n,r,o,s){const i=[],a=[];for(const c of t)try{const u=await Wm(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Il=C.createContext(null);function io({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,autoLoadInitial:s=!0,disableAutoRestore:i=!1,enableFileAgentRouting:a=!1,fileAgentId:c="invoice_reader"}){const u=gn;C.useEffect(()=>{t&&u.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[u,t]);const{isStreaming:d,error:f,stream:h,stop:m,setToken:b}=Sl({baseUrl:u.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/runs/stream"}),[v,g]=C.useState(()=>typeof u.getAuthToken=="function"?u.getAuthToken():null);C.useEffect(()=>{b(typeof u.getAuthToken=="function"?u.getAuthToken():null);const F=u.onTokenChange(Y=>{g(Y),b(Y)});return()=>{F()}},[u,b]);const x=C.useCallback(F=>{u.setAuthToken(F)},[u]),{state:w,seed:y,prepend:E,pushUser:S,onEvent:T,reset:I}=Cl(),N=20,[R,j]=C.useState(!1),[A,z]=C.useState(!1),[V,O]=C.useState(null),[G,W]=C.useState(void 0),[q,L]=C.useState(void 0),M=C.useRef(!1),le=C.useRef([]),Z=C.useRef(null),ee=C.useCallback(F=>{F.cursor!==void 0&&O(F.cursor),F.hasMore!==void 0&&j(F.hasMore),F.checkpointId!==void 0&&W(F.checkpointId),F.checkpointNs!==void 0&&L(F.checkpointNs)},[]),D=C.useCallback((F,Y)=>new Promise((je,nt)=>{const Re=async()=>{if(M.current){console.warn(`[ChatProvider] Operation "${Y}" queued - another operation in progress`),le.current.push(Re);return}M.current=!0;try{console.log(`[ChatProvider] Executing operation: ${Y}`),await F(),je()}catch(at){console.error(`[ChatProvider] Operation "${Y}" failed:`,at),nt(at)}finally{M.current=!1;const at=le.current.shift();at&&at().catch(()=>{})}};M.current?(le.current.push(Re),console.log(`[ChatProvider] Queued operation: ${Y}`)):Re().catch(at=>{nt(at)})}),[]),J=C.useCallback((F,Y)=>{const je=Array.isArray(F==null?void 0:F.messages)?F.messages:[];Y==="replace"?(console.log("[ChatProvider] Replacing messages, count:",je.length),y(je,{checkpointId:(F==null?void 0:F.checkpointId)??null,checkpointNs:(F==null?void 0:F.checkpointNs)??null})):Y==="prepend"&&je.length?(console.log("[ChatProvider] Calling prepend with",je.length,"messages"),E(je)):console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"),O((F==null?void 0:F.nextCursor)??null),j(!!(F!=null&&F.hasMore)),W(nt=>(F==null?void 0:F.checkpointId)??nt??void 0),L(nt=>(F==null?void 0:F.checkpointNs)??nt??void 0)},[y,E]),[ke,he]=C.useState([]),[$,P]=C.useState(null),H=C.useCallback(async()=>{const F=await u.listThreads();he(F)},[u]),[Q,ce]=C.useState(!1),ie=C.useCallback(async F=>{const Y=(F==null?void 0:F.maxAttempts)??5,je=(F==null?void 0:F.baseDelayMs)??500,nt=(F==null?void 0:F.timeoutMs)??2e3;if(!u.baseUrl)return!1;const Re=u.baseUrl.replace(/\/+$/,""),at=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],Ht=async wt=>{try{const Ot=new AbortController,ft=setTimeout(()=>Ot.abort(),nt),Et=await fetch(wt,{method:"GET",signal:Ot.signal});return clearTimeout(ft),Et.ok}catch{return!1}},Gn=async wt=>{try{const Ot=new AbortController,ft=setTimeout(()=>Ot.abort(),nt),Et=await fetch(wt,{method:"HEAD",signal:Ot.signal});return clearTimeout(ft),Et.ok}catch{return!1}};for(let wt=0;wt<Y;wt++){console.debug(`[ChatProvider] health-check attempt ${wt+1}/${Y}`);for(const ft of at){let Et=ft;Re.endsWith("/api")&&ft.startsWith("/api")&&(Et=ft.replace(/^\/api/,"")||"/");const te=Et==="/"?Re+"/":Re+Et;if(console.debug(`[ChatProvider] checking ${te}`),await Ht(te)||ft==="/"&&await Gn(Re+"/"))return ce(!0),!0}const Ot=je*Math.pow(2,wt);await new Promise(ft=>setTimeout(ft,Ot))}return ce(!1),!1},[u.baseUrl]);C.useEffect(()=>{let F=!0;if(!u.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const Y=await ie();if(!F)return;Y?H().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{F=!1}},[H,u.baseUrl,ie]),C.useEffect(()=>{r==null||r($)},[$,r]);const Fe=C.useRef(null);C.useEffect(()=>{if(o&&s){if(!u.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!Q){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}Fe.current!==o&&(Fe.current=o,Ne(o).catch(()=>{}))}},[o,s,u.baseUrl,Q]);const $e=C.useRef(null),we=C.useRef(null),Ne=C.useCallback(async(F,Y,je)=>{await D(async()=>{if(Z.current===F){console.log(`[ChatProvider] Skipping auto-load for thread ${F} - suppressed after clear`),Z.current=null;return}if(!u.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if($e.current){console.warn(`[ChatProvider] Thread load cancelled - another thread (${$e.current}) is loading`);return}we.current!==null&&we.current!==F&&(console.log(`[ChatProvider] Thread switch detected: ${we.current} -> ${F}`),I([])),$e.current=F,we.current=F;try{ee({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),P(F);const Re=await u.getMessages({threadId:F,checkpointId:Y,checkpointNs:je,limit:N}),at=Array.isArray(Re==null?void 0:Re.messages)?Re.messages:[];console.log("[ChatProvider] Loading thread with",at.length,"messages"),y(at,{checkpointId:(Re==null?void 0:Re.checkpointId)??null,checkpointNs:(Re==null?void 0:Re.checkpointNs)??null}),O((Re==null?void 0:Re.nextCursor)??null),j(!!(Re!=null&&Re.hasMore)),W(Ht=>(Re==null?void 0:Re.checkpointId)??Ht??void 0),L(Ht=>(Re==null?void 0:Re.checkpointNs)??Ht??void 0)}finally{$e.current=null}},`loadThread-${F}`)},[u,D,ee,y]),Ue=C.useCallback(async F=>{const Y=await u.listCheckpoints(F);return Um(Y,F)},[u]),et=C.useCallback(async(F,Y)=>{await D(async()=>{if(!$)throw new Error("No active thread");ee({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0});const je=await u.getMessages({threadId:$,checkpointId:F,checkpointNs:Y??void 0,limit:N});J(je,"replace")},`navigateToCheckpoint-${F}`)},[u,$,J,D,ee]),Xe=C.useCallback(async()=>{if(!$)throw new Error("No active thread");await Ne($)},[$,Ne]),ut=C.useRef(!1);C.useEffect(()=>{const F=ut.current;ut.current=d,F&&!d&&$&&D(async()=>{try{await H()}catch(Y){console.warn("[ChatProvider] Post-streaming thread refresh failed:",Y)}},"postStreamingRefresh")},[d,$,u,J,H,D]);const dt=C.useCallback(async()=>{console.log("[ChatProvider] 🔄 clearCurrentThread called"),console.log("[ChatProvider] 📊 Before clear - currentThreadId:",$),console.log("[ChatProvider] 📊 Before clear - messages count:",w.messages.length),$&&(Z.current=$,console.log(`[ChatProvider] 🚫 Suppressing next auto-load for thread: ${$}`)),await D(()=>(console.log("[ChatProvider] 🚀 Executing atomic clear operation"),P(null),I([]),ee({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),typeof window<"u"&&localStorage.removeItem("currentThreadId"),console.log("[ChatProvider] ✅ Atomic clear operation completed"),Promise.resolve()),"clearCurrentThread"),console.log("[ChatProvider] 📊 After clear - currentThreadId should be null")},[I,ee,$,w.messages.length,D]),ue=C.useCallback(async F=>{dt();const Y=await u.createThread(F);return await H(),await Ne(Y.threadId),Y.threadId},[u,H,Ne,dt]),fe=C.useCallback(async F=>{await u.deleteThread(F),await H(),$===F&&(P(null),I([]),j(!1),O(null),W(void 0),L(void 0))},[u,H,$,I]),pe=C.useCallback(async(F,Y)=>{await u.updateThread(F,Y),await H()},[u,H]),Se=C.useCallback(async(F,Y)=>{await D(async()=>{var Pe;const je=(Y==null?void 0:Y.attachments)||[],{contentParts:nt,filesInfo:Re}=await Vm(u,je,t==null?void 0:t.uploadPath),at=[];F&&F.trim()&&at.push({type:"text",text:F.trim()});const Ht={id:((Pe=crypto.randomUUID)==null?void 0:Pe.call(crypto))||`user-${Date.now()}`,role:"user",content:at,createdAt:new Date().toISOString(),checkpointId:(Y==null?void 0:Y.checkpointId)??w.lastCheckpointId??void 0,checkpointNs:(Y==null?void 0:Y.checkpointNs)??w.lastCheckpointNs??void 0};S(Ht);const Gn={...Ht,content:at},wt={...(Y==null?void 0:Y.payloadExtras)??{}},Ot=!!wt.edit,ft=wt.originalMessageId,Et=typeof ft=="string"?ft:void 0,te=je&&je.length>0,me={...$?{threadId:$}:{},payload:{messages:[Gn],files_info:Re,...a&&te&&c?{active_agent:c}:{},...wt},checkpointId:(Y==null?void 0:Y.checkpointId)??w.lastCheckpointId??void 0,checkpointNs:(Y==null?void 0:Y.checkpointNs)??w.lastCheckpointNs??void 0,nodeFilter:Y==null?void 0:Y.nodeFilter,config:Y==null?void 0:Y.config,edit:Ot,originalMessageId:Et};h(me,Be=>T(Be),{onError:Be=>console.warn("stream error",Be),onOpen:({threadId:Be,created:Ut})=>{!$&&Be&&(P(Be),Ut&&H().catch(()=>{}))}})},"send")},[$,S,h,T,w.lastCheckpointId,w.lastCheckpointNs,u,t==null?void 0:t.uploadPath,H,P,a,c,D]),Oe=C.useCallback(async F=>{if(!$)throw new Error("No active thread");if(A||!R)return;const Y=V;if(Y){z(!0);try{const je=await u.getMessages({threadId:$,checkpointId:G,checkpointNs:q,limit:(F==null?void 0:F.limit)??N,beforeId:Y});J(je,"prepend")}finally{z(!1)}}},[u,$,G,q,V,R,A,J,N]),Ve={baseUrl:u.baseUrl,token:v,setToken:x,api:u,threads:ke,currentThreadId:$,setCurrentThreadId:P,messages:w.messages,isStreaming:d,error:f,lastCheckpointId:w.lastCheckpointId,lastCheckpointNs:w.lastCheckpointNs,streamingAssistantId:w.assemblingId,hasMoreHistory:R,isLoadingHistory:A,loadOlderMessages:Oe,historyPageSize:N,listCheckpoints:Ue,navigateToCheckpoint:et,returnToLatest:Xe,refreshThreads:H,createThread:ue,deleteThread:fe,renameThread:pe,loadThread:Ne,clearCurrentThread:dt,send:Se,stop:m};return l.jsx(Il.Provider,{value:Ve,children:e})}function ao(){const e=C.useContext(Il);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function X(...e){return cp.twMerge(lp.clsx(e))}const qm=Kr.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"}}),We=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?An.Slot:"button";return l.jsx(i,{className:X(qm({variant:t,size:n,className:e})),ref:s,...o})});We.displayName="Button";const Nl=p.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:X("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Nl.displayName="Textarea";function Km({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,m]=C.useState(e),[b,v]=C.useTransition(),g=C.useRef(null);C.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=C.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);C.useEffect(()=>{x()},[x]);const w=C.useCallback(async N=>{N&&N.preventDefault();const R=(h??"").trim();!R&&!f||v(()=>{try{const j=i(R);j&&typeof j.then=="function"?j.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),y=C.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=C.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),w()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[w,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return l.jsx("form",{onSubmit:N=>void w(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(Nl,{ref:g,value:h,onChange:y,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(We,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(oe.Square,{size:16})}):l.jsx(We,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||b,children:l.jsx(oe.Send,{size:16})})})]})})}const Gm=C.memo(Km),lo=0,xn=1,Qn=2,Al=4;function Rl(e){return()=>e}function Ym(e){e()}function _l(e,t){return n=>e(t(n))}function jl(e,t){return()=>e(t)}function Xm(e,t){return n=>e(t,n)}function Us(e){return e!==void 0}function Jm(...e){return()=>{e.map(Ym)}}function er(){}function co(e,t){return t(e),e}function Zm(e,t){return t(e)}function Ze(...e){return e}function qe(e,t){return e(xn,t)}function Ae(e,t){e(lo,t)}function Ws(e){e(Qn)}function ot(e){return e(Al)}function de(e,t){return qe(e,Xm(t,lo))}function qt(e,t){const n=e(xn,r=>{n(),t(r)});return n}function Pl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ol(e,t){return e===t}function Qe(e=Ol){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function be(e){return t=>n=>{e(n)&&t(n)}}function re(e){return t=>_l(t,e)}function Qt(e){return t=>()=>{t(e)}}function B(e,...t){const n=Qm(...t);return(r,o)=>{switch(r){case Qn:Ws(e);return;case xn:return qe(e,n(o))}}}function en(e,t){return n=>r=>{n(t=e(t,r))}}function Pn(e){return t=>n=>{e>0?e--:t(n)}}function fn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function _e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);qe(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Qm(...e){return t=>e.reduceRight(Zm,t)}function eg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case xn:return s?n===s?void 0:(r(),n=s,t=qe(e,s),t):(r(),er);case Qn:r(),n=null;return}}}function K(e){let t=e;const n=Le();return(r,o)=>{switch(r){case lo:t=o;break;case xn:{o(t);break}case Al:return t}return n(r,o)}}function gt(e,t){return co(K(t),n=>de(e,n))}function Le(){const e=[];return(t,n)=>{switch(t){case lo:e.slice().forEach(r=>{r(n)});return;case Qn:e.splice(0,e.length);return;case xn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return co(Le(),t=>de(e,t))}function He(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:tg(),singleton:n}}const tg=()=>Symbol();function ng(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 it(...e){const t=Le(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);qe(s,c=>{n[i]=c,r=r|a,r===o&&Ae(t,n)})}),function(s,i){switch(s){case Qn:{Ws(t);return}case xn:return r===o&&i(n),qe(t,i)}}}function ve(e,t=Ol){return B(e,Qe(t))}function Vs(...e){return function(t,n){switch(t){case Qn:return;case xn:return Jm(...e.map(r=>qe(r,n)))}}}var kt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(kt||{});const rg={0:"debug",3:"error",1:"log",2:"warn"},og=()=>typeof globalThis>"u"?window:globalThis,vn=He(()=>{const e=K(3);return{log:K((t,n,r=1)=>{var o;const s=(o=og().VIRTUOSO_LOG_LEVEL)!=null?o:ot(e);r>=s&&console[rg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function On(e,t,n){return qs(e,t,n).callbackRef}function qs(e,t,n){const r=C.useRef(null);let o=i=>{};const s=C.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 sg(e,t,n,r,o,s,i,a,c){const u=C.useCallback(d=>{const f=ig(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let b;m&&(b=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:m?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?b.innerWidth:b.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Ml("column-gap",getComputedStyle(d).columnGap,o):Ml("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return qs(u,n,c)}function ig(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),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},kt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function Ml(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,kt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Dl(e,t,n){const r=C.useRef(null),o=C.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,h;if(t){const m=t.getBoundingClientRect(),b=u.top-m.top;h=m.height-Math.max(0,b),f=b+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=qs(o,!0,n),a=C.useCallback(()=>{o(i.current)},[o,i]);return C.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const bt=He(()=>{const e=Le(),t=Le(),n=K(0),r=Le(),o=K(0),s=Le(),i=Le(),a=K(0),c=K(0),u=K(0),d=K(0),f=Le(),h=Le(),m=K(!1),b=K(!1),v=K(!1);return de(B(e,re(({scrollTop:g})=>g)),t),de(B(e,re(({scrollHeight:g})=>g)),i),de(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),yr={lvl:0};function Ll(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 Ge(e){return e===yr}function Sr(e,t){if(!Ge(e))return t===e.k?e.v:t<e.k?Sr(e.l,t):Sr(e.r,t)}function Kt(e,t,n="k"){if(Ge(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Kt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Kt(e.l,t,n)}function Rt(e,t,n){return Ge(e)?zl(t,n,1):t===e.k?ct(e,{k:t,v:n}):t<e.k?Bl(ct(e,{l:Rt(e.l,t,n)})):Bl(ct(e,{r:Rt(e.r,t,n)}))}function tr(){return yr}function uo(e,t,n){if(Ge(e))return[];const r=Kt(e,t)[0];return ag(Gs(e,r,n))}function Ks(e,t){if(Ge(e))return yr;const{k:n,l:r,r:o}=e;if(t===n){if(Ge(r))return o;if(Ge(o))return r;{const[s,i]=Fl(r);return fo(ct(e,{k:s,l:$l(r),v:i}))}}else return t<n?fo(ct(e,{l:Ks(r,t)})):fo(ct(e,{r:Ks(o,t)}))}function Mn(e){return Ge(e)?[]:[...Mn(e.l),{k:e.k,v:e.v},...Mn(e.r)]}function Gs(e,t,n){if(Ge(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Gs(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Gs(s,t,n))),a}function fo(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(Ys(t))return Hl(ct(e,{lvl:n-1}));if(!Ge(t)&&!Ge(t.r))return ct(t.r,{l:ct(t,{r:t.r.l}),lvl:n,r:ct(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ys(e))return Xs(ct(e,{lvl:n-1}));if(!Ge(r)&&!Ge(r.l)){const o=r.l,s=Ys(o)?r.lvl-1:r.lvl;return ct(o,{l:ct(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Xs(ct(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ct(e,t){return zl(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 $l(e){return Ge(e.r)?e.l:fo(ct(e,{r:$l(e.r)}))}function Ys(e){return Ge(e)||e.lvl>e.r.lvl}function Fl(e){return Ge(e.r)?[e.k,e.v]:Fl(e.r)}function zl(e,t,n,r=yr,o=yr){return{k:e,l:r,lvl:n,r:o,v:t}}function Bl(e){return Xs(Hl(e))}function Hl(e){const{l:t}=e;return!Ge(t)&&t.lvl===e.lvl?ct(t,{r:ct(e,{l:t.r})}):e}function Xs(e){const{lvl:t,r:n}=e;return!Ge(n)&&!Ge(n.r)&&n.lvl===t&&n.r.lvl===t?ct(n,{l:ct(e,{r:n.l}),lvl:t+1}):e}function ag(e){return Ll(e,({k:t,v:n})=>({index:t,value:n}))}function Ul(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Cr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Js=He(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function Wl(e,t,n){return e[ho(e,t,n)]}function ho(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 lg(e,t,n,r){const o=ho(e,t,r),s=ho(e,n,r,o);return e.slice(o,s+1)}function wn(e,t){return Math.round(e.getBoundingClientRect()[t])}function po(e){return!Ge(e.groupOffsetTree)}function Zs({index:e},t){return t===e?0:t<e?-1:1}function cg(){return{groupIndices:[],groupOffsetTree:tr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:tr()}}function ug(e,t){let n=Ge(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ge(e)){e=Rt(e,0,s);continue}const a=uo(e,i-1,o+1);if(a.some(xg(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=Ks(e,f)):(u=h!==s,c=!0),d>o&&o>=f&&h!==s&&(e=Rt(e,o+1,h));u&&(e=Rt(e,i,s))}return[e,n]}function dg(e){return typeof e.groupIndex<"u"}function fg({offset:e},t){return t===e?0:t<e?-1:1}function Tr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Wl(t,e,Zs),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Vl(e,t){if(!po(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ql(e,t,n){if(dg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Vl(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function hg(e,t,n,r=0){return r>0&&(t=Math.max(t,Wl(e,r,Zs).offset)),Ll(lg(e,t,n,fg),gg)}function pg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,kt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ge(s)&&t.length===2){const h=t[0].size,m=t[1].size;i=n.reduce((b,v)=>Rt(Rt(b,v,h),v+1,m),i)}else[i,a]=ug(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=Qs(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>Rt(h,m,Tr(m,f,o)),tr()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function mg(e){return Mn(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 Kl(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 Qs(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=ho(o,t-1,Zs),a=o[c].offset;const u=Kt(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===Kt(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:u,value:d}of uo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function gg(e){return{index:e.index,value:e}}function xg(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 vg={offsetHeight:"height",offsetWidth:"width"},tn=He(([{log:e},{recalcInProgress:t}])=>{const n=Le(),r=Le(),o=gt(r,0),s=Le(),i=Le(),a=K(0),c=K([]),u=K(void 0),d=K(void 0),f=K((S,T)=>wn(S,vg[T])),h=K(void 0),m=K(0),b=cg(),v=gt(B(n,_e(c,e,m),en(pg,b),Qe()),b),g=gt(B(c,Qe(),en((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),re(({prev:S})=>S)),[]);de(B(c,be(S=>S.length>0),_e(v,m),re(([S,T,I])=>{const N=S.reduce((R,j,A)=>Rt(R,j,Tr(j,T.offsetTree,I)||A),tr());return{...T,groupIndices:S,groupOffsetTree:N}})),v),de(B(r,_e(v),be(([S,{lastIndex:T}])=>S<T),re(([S,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:S}])),n),de(u,d);const x=gt(B(u,re(S=>S===void 0)),!0);de(B(d,be(S=>S!==void 0&&Ge(ot(v).sizeTree)),re(S=>[{endIndex:0,size:S,startIndex:0}])),n);const w=At(B(n,_e(v),en(({sizes:S},[T,I])=>({changed:I!==S,sizes:I}),{changed:!1,sizes:b}),re(S=>S.changed)));qe(B(a,en((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),re(S=>S.diff)),S=>{const{groupIndices:T}=ot(v);if(S>0)Ae(t,!0),Ae(s,S+Kl(S,T));else if(S<0){const I=ot(g);I.length>0&&(S-=Kl(-S,I)),Ae(i,S)}}),qe(B(a,_e(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},kt.ERROR)});const y=At(s);de(B(s,_e(v),re(([S,T])=>{const I=T.groupIndices.length>0,N=[],R=T.lastSize;if(I){const j=Sr(T.sizeTree,0);let A=0,z=0;for(;A<S;){const O=T.groupIndices[z],G=T.groupIndices.length===z+1?1/0:T.groupIndices[z+1]-O-1;N.push({endIndex:O,size:j,startIndex:O}),N.push({endIndex:O+1+G-1,size:R,startIndex:O+1}),z++,A+=G+1}const V=Mn(T.sizeTree);return A!==S&&V.shift(),V.reduce((O,{k:G,v:W})=>{let q=O.ranges;return O.prevSize!==0&&(q=[...O.ranges,{endIndex:G+S-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:G+S,prevSize:W,ranges:q}},{prevIndex:S,prevSize:0,ranges:N}).ranges}return Mn(T.sizeTree).reduce((j,{k:A,v:z})=>({prevIndex:A+S,prevSize:z,ranges:[...j.ranges,{endIndex:A+S-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=At(B(i,_e(v,m),re(([S,{offsetTree:T},I])=>{const N=-S;return Tr(N,T,I)})));return de(B(i,_e(v,m),re(([S,T,I])=>{if(T.groupIndices.length>0){if(Ge(T.sizeTree))return T;let N=tr();const R=ot(g);let j=0,A=0,z=0;for(;j<-S;){z=R[A];const V=R[A+1]-z-1;A++,j+=V+1}if(N=Mn(T.sizeTree).reduce((V,{k:O,v:G})=>Rt(V,Math.max(0,O+S),G),N),j!==-S){const V=Sr(T.sizeTree,z);N=Rt(N,0,V);const O=Kt(T.sizeTree,-S+1)[1];N=Rt(N,1,O)}return{...T,sizeTree:N,...Qs(T.offsetTree,0,N,I)}}else{const N=Mn(T.sizeTree).reduce((R,{k:j,v:A})=>Rt(R,Math.max(0,j+S),A),tr());return{...T,sizeTree:N,...Qs(T.offsetTree,0,N,I)}}})),v),{beforeUnshiftWith:y,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},Ze(vn,Js),{singleton:!0});function wg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Gl=He(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Le(),i=Le(),a=At(B(s,re(wg)));return de(B(a,re(c=>c.totalCount)),n),de(B(a,re(c=>c.groupIndices)),e),de(B(it(o,t,r),be(([c,u])=>po(u)),re(([c,u,d])=>Kt(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),Qe(),re(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Ze(tn,bt)),bn=He(([{log:e}])=>{const t=K(!1),n=At(B(t,be(r=>r),Qe()));return qe(t,r=>{r&&ot(e)("props updated",{},kt.DEBUG)}),{didMount:n,propsReady:t}},Ze(vn),{singleton:!0}),bg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Yl(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!bg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const kr=He(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const m=Le(),b=Le(),v=K(0);let g=null,x=null,w=null;function y(){g&&(g(),g=null),w&&(w(),w=null),x&&(clearTimeout(x),x=null),Ae(c,!1)}return de(B(m,_e(n,f,r,v,a,i,h),_e(e,s,o),re(([[E,S,T,I,N,R,j,A],z,V,O])=>{const G=Yl(E),{align:W,behavior:q,offset:L}=G,M=I-1,le=ql(G,S,M);let Z=Tr(le,S.offsetTree,z)+R;W==="end"?(Z+=V+Kt(S.sizeTree,le)[1]-T+O,le===M&&(Z+=j)):W==="center"?Z+=(V+Kt(S.sizeTree,le)[1]-T+O)/2:Z-=N,L&&(Z+=L);const ee=D=>{y(),D?(A("retrying to scroll to",{location:E},kt.DEBUG),Ae(m,E)):(Ae(b,!0),A("list did not change, scroll successful",{},kt.DEBUG))};if(y(),q==="smooth"){let D=!1;w=qe(t,J=>{D=D||J}),g=qt(d,()=>{ee(D)})}else g=qt(B(t,yg(150)),ee);return x=setTimeout(()=>{y()},1200),Ae(c,!0),A("scrolling from index to",{behavior:q,index:le,top:Z},kt.DEBUG),{behavior:q,top:Z}})),u),{scrollTargetReached:b,scrollToIndex:m,topListHeight:v}},Ze(tn,bt,vn),{singleton:!0});function yg(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ei(e,t){e==0?t():requestAnimationFrame(()=>{ei(e-1,t)})}function ti(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Er=He(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=K(!0),c=K(0),u=K(!0);return de(B(i,_e(c),be(([d,f])=>!!f),Qt(!1)),a),de(B(i,_e(c),be(([d,f])=>!!f),Qt(!1)),u),qe(B(it(t,i),_e(a,n,e,u),be(([[,d],f,{sizeTree:h},m,b])=>d&&(!Ge(h)||Us(m))&&!f&&!b),_e(c)),([,d])=>{qt(o,()=>{Ae(u,!0)}),ei(4,()=>{qt(r,()=>{Ae(a,!0)}),Ae(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Ze(tn,bt,kr,bn),{singleton:!0});function Xl(e,t){return Math.abs(e-t)<1.01}const Ir="up",Nr="down",Sg="none",Cg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Tg=0,Ar=He(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=K(!1),a=K(!0),c=Le(),u=Le(),d=K(4),f=K(Tg),h=gt(B(Vs(B(ve(o),Pn(1),Qt(!0)),B(ve(o),Pn(1),Qt(!1),Pl(100))),Qe()),!1),m=gt(B(Vs(B(n,Qt(!0)),B(n,Qt(!1),Pl(200))),Qe()),!1);de(B(it(ve(o),ve(f)),re(([w,y])=>w<=y),Qe()),a),de(B(a,fn(50)),u);const b=At(B(it(r,ve(s),ve(t),ve(e),ve(d)),en((w,[{scrollHeight:y,scrollTop:E},S,T,I,N])=>{const R=E+S-y>-N,j={scrollHeight:y,scrollTop:E,viewportHeight:S};if(R){let z,V;return E>w.state.scrollTop?(z="SCROLLED_DOWN",V=w.state.scrollTop-E):(z="SIZE_DECREASED",V=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:V,state:j}}let A;return j.scrollHeight>w.state.scrollHeight?A="SIZE_INCREASED":S<w.state.viewportHeight?A="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?A="SCROLLING_UPWARDS":A="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:A,state:j}},Cg),Qe((w,y)=>w&&w.atBottom===y.atBottom))),v=gt(B(r,en((w,{scrollHeight:y,scrollTop:E,viewportHeight:S})=>{if(Xl(w.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:E};{const T=y-(E+S)<1;return w.scrollTop!==E&&T?{changed:!0,jump:w.scrollTop-E,scrollHeight:y,scrollTop:E}:{changed:!0,jump:0,scrollHeight:y,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),be(w=>w.changed),re(w=>w.jump)),0);de(B(b,re(w=>w.atBottom)),i),de(B(i,fn(50)),c);const g=K(Nr);de(B(r,re(({scrollTop:w})=>w),Qe(),en((w,y)=>ot(m)?{direction:w.direction,prevScrollTop:y}:{direction:y<w.prevScrollTop?Ir:Nr,prevScrollTop:y},{direction:Nr,prevScrollTop:0}),re(w=>w.direction)),g),de(B(r,fn(50),Qt(Sg)),g);const x=K(0);return de(B(h,be(w=>!w),Qt(0)),x),de(B(o,fn(100),_e(h),be(([w,y])=>!!y),en(([w,y],[E])=>[y,E],[0,0]),re(([w,y])=>y-w)),x),{atBottomState:b,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},Ze(bt)),mo="top",go="bottom",Jl="none";function Zl(e,t,n){return typeof e=="number"?n===Ir&&t===mo||n===Nr&&t===go?e:0:n===Ir?t===mo?e.main:e.reverse:t===go?e.main:e.reverse}function Ql(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ni=He(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Le(),i=K(0),a=K(0),c=K(0),u=gt(B(it(ve(r),ve(o),ve(n),ve(s,Cr),ve(c),ve(i),ve(t),ve(e),ve(a)),re(([d,f,h,[m,b],v,g,x,w,y])=>{const E=d-w,S=g+x,T=Math.max(h-E,0);let I=Jl;const N=Ql(y,mo),R=Ql(y,go);return m-=w,m+=h+x,b+=h+x,b-=w,m>d+S-N&&(I=Ir),b<d-T+f+R&&(I=Nr),I!==Jl?[Math.max(E-h-Zl(v,mo,I)-N,0),E-T-x+f+Zl(v,go,I)+R]:null}),be(d=>d!=null),Qe(Cr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},Ze(bt),{singleton:!0});function kg(e,t,n){if(po(t)){const r=Vl(e,t);return[{index:Kt(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 ri={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function xo(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*c+(f-1)*r,m=u,b=h-d;return{bottom:d,firstItemIndex:s,items:tc(e,o,s),offsetBottom:b,offsetTop:u,top:m,topItems:tc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function ec(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,c=ti(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return xo(u,[],a,o,n,r)}function tc(e,t,n){if(e.length===0)return[];if(!po(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=uo(t.groupOffsetTree,r,o);let a,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Dn=He(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:m},{recalcInProgress:b}])=>{const v=K([]),g=K(0),x=Le();de(s.topItemsIndexes,v);const w=gt(B(it(m,b,ve(c,Cr),ve(o),ve(r),ve(u),d,ve(v),ve(t),ve(n),e),be(([T,I,,N,,,,,,,R])=>{const j=R&&R.length!==N;return T&&!I&&!j}),re(([,,[T,I],N,R,j,A,z,V,O,G])=>{const W=R,{offsetTree:q,sizeTree:L}=W,M=ot(g);if(N===0)return{...ri,totalCount:N};if(T===0&&I===0)return M===0?{...ri,totalCount:N}:ec(M,j,R,V,O,G||[]);if(Ge(L))return M>0?null:xo(kg(ti(j,N),W,G),[],N,O,W,V);const le=[];if(z.length>0){const ke=z[0],he=z[z.length-1];let $=0;for(const P of uo(L,ke,he)){const H=P.value,Q=Math.max(P.start,ke),ce=Math.min(P.end,he);for(let ie=Q;ie<=ce;ie++)le.push({data:G==null?void 0:G[ie],index:ie,offset:$,size:H}),$+=H}}if(!A)return xo([],le,N,O,W,V);const Z=z.length>0?z[z.length-1]+1:0,ee=hg(q,T,I,Z);if(ee.length===0)return null;const D=N-1,J=co([],ke=>{for(const he of ee){const $=he.value;let P=$.offset,H=he.start;const Q=$.size;if($.offset<T){H+=Math.floor((T-$.offset+O)/(Q+O));const ie=H-he.start;P+=ie*Q+ie*O}H<Z&&(P+=(Z-H)*Q,H=Z);const ce=Math.min(he.end,D);for(let ie=H;ie<=ce&&!(P>=I);ie++)ke.push({data:G==null?void 0:G[ie],index:ie,offset:P,size:Q}),P+=Q+O}});return xo(J,le,N,O,W,V)}),be(T=>T!==null),Qe()),ri);de(B(e,be(Us),re(T=>T==null?void 0:T.length)),o),de(B(w,re(T=>T.topListHeight)),f),de(f,a),de(B(w,re(T=>[T.top,T.bottom])),i),de(B(w,re(T=>T.items)),x);const y=At(B(w,be(({items:T})=>T.length>0),_e(o,e),be(([{items:T},I])=>T[T.length-1].originalIndex===I-1),re(([,T,I])=>[T-1,I]),Qe(Cr),re(([T])=>T))),E=At(B(w,fn(200),be(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),re(({items:T})=>T[0].index),Qe())),S=At(B(w,be(({items:T})=>T.length>0),re(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),Qe(Ul)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:w,rangeChanged:S,startReached:E,topItemsIndexes:v,...h}},Ze(tn,Gl,ni,Er,kr,Ar,bn,Js),{singleton:!0}),nc=He(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Le(),i=gt(B(it(n,e,r,t,o),re(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return de(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},Ze(bt,Dn),{singleton:!0}),Eg=He(([{viewportHeight:e},{totalListHeight:t}])=>{const n=K(!1),r=gt(B(it(n,e,t),be(([o])=>o),re(([,o,s])=>Math.max(0,o-s)),fn(0),Qe()),0);return{alignToBottom:n,paddingTopAddition:r}},Ze(bt,nc),{singleton:!0}),rc=He(()=>({context:K(null)})),Ig=({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,oc=He(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=Le();return de(B(d,_e(t,c,n,s,o,r,a),_e(e),re(([[f,h,m,b,v,g,x,w],y])=>{const{align:E,behavior:S,calculateViewLocation:T=Ig,done:I,...N}=f,R=ql(f,h,b-1),j=Tr(R,h.offsetTree,y)+v+g,A=j+Kt(h.sizeTree,R)[1],z=w+g,V=w+m-x,O=T({itemBottom:A,itemTop:j,locationParams:{align:E,behavior:S,...N},viewportBottom:V,viewportTop:z});return O?I&&qt(B(i,be(G=>!G),Pn(ot(i)?1:2)),I):I&&I(),O}),be(f=>f!==null)),u),{scrollIntoView:d}},Ze(tn,bt,kr,Dn,vn),{singleton:!0});function sc(e){return e?e==="smooth"?"smooth":"auto":!1}const Ng=(e,t)=>typeof e=="function"?sc(e(t)):t&&sc(e),Ag=He(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const b=K(!1),v=Le();let g=null;function x(S){Ae(i,{align:"end",behavior:S,index:"LAST"})}qe(B(it(B(ve(t),Pn(1)),c),_e(ve(b),s,a,f),re(([[S,T],I,N,R,j])=>{let A=T&&R,z="auto";return A&&(z=Ng(I,N||j),A=A&&!!z),{followOutputBehavior:z,shouldFollow:A,totalCount:S}}),be(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{g&&(g(),g=null),ot(n)?requestAnimationFrame(()=>{ot(d)("following output to ",{totalCount:T},kt.DEBUG),x(S)}):g=qt(e,()=>{ot(d)("following output to ",{totalCount:T},kt.DEBUG),x(S),g=null})});function w(S){const T=qt(o,I=>{S&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ot(d)("scrolling to bottom due to increased size",{},kt.DEBUG),x("auto"))});setTimeout(T,100)}qe(B(it(ve(b),t,u),be(([S,,T])=>S&&T),en(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),be(({refreshed:S})=>S),_e(b,t)),([,S])=>{ot(a)&&w(S!==!1)}),qe(v,()=>{w(ot(b)!==!1)}),qe(it(ve(b),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=K(null),E=Le();return de(Vs(B(ve(r),re(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),B(ve(t))),E),qe(B(it(B(E,Pn(1)),c),_e(ve(y),a,f,h),re(([[S,T],I,N,R,j])=>T&&N&&(I==null?void 0:I({context:j,totalCount:S,scrollingInProgress:R}))),be(S=>!!S),fn(0)),S=>{g&&(g(),g=null),ot(n)?requestAnimationFrame(()=>{ot(d)("scrolling into view",{}),Ae(m,S)}):g=qt(e,()=>{ot(d)("scrolling into view",{}),Ae(m,S),g=null})}),{autoscrollToBottom:v,followOutput:b,scrollIntoViewOnChange:y}},Ze(tn,Ar,kr,Er,bn,vn,bt,rc,oc)),Rg=He(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(de(B(a,_e(s),be(([,c])=>c!==0),_e(o,r,t,n,e),re(([[,c],u,d,f,h,m=[]])=>ec(c,u,d,f,h,m))),i),{}),Ze(tn,Er,Dn,bn),{singleton:!0}),_g=He(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=K(0);return qe(B(e,_e(r),be(([,o])=>o!==0),re(([,o])=>({top:o}))),o=>{qt(B(n,Pn(1),be(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ae(t,o)})})}),{initialScrollTop:r}},Ze(bn,bt,Dn),{singleton:!0}),ic=He(([{scrollVelocity:e}])=>{const t=K(!1),n=Le(),r=K(!1);return de(B(e,_e(r,t,n),be(([o,s])=>!!s),re(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),Qe()),t),qe(B(it(t,e,n),_e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Ze(Ar),{singleton:!0}),oi=He(([{scrollContainerState:e,scrollTo:t}])=>{const n=Le(),r=Le(),o=Le(),s=K(!1),i=K(void 0);return de(B(it(n,r),re(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),de(B(t,_e(r),re(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Ze(bt)),jg=He(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=Le(),d=K(void 0),f=K(null),h=K(null);return de(a,f),de(c,h),qe(B(u,_e(t,r,i,f,h,n)),([m,b,v,g,x,w,y])=>{const E=mg(b.sizeTree);g&&x!==null&&w!==null&&(v=x.scrollTop-w.offsetTop),v-=y,m({ranges:E,scrollTop:v})}),de(B(d,be(Us),re(Pg)),o),de(B(s,_e(d),be(([,m])=>m!==void 0),Qe(),re(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},Ze(tn,bt,Er,bn,oi));function Pg(e){return{align:"start",index:0,offset:e.scrollTop}}const Og=He(([{topItemsIndexes:e}])=>{const t=K(0);return de(B(t,be(n=>n>=0),re(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Ze(Dn));function ac(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Mg=ac(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Dg=He(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:b}])=>{const v=At(B(c,_e(i),en(([,x,w,y],[{bottom:E,items:S,offsetBottom:T,totalCount:I},N])=>{const R=E+T;let j=0;return w===I&&x.length>0&&S.length>0&&(S[0].originalIndex===0&&x[0].originalIndex===0||(j=R-y,j!==0&&(j+=N))),[j,S,I,R]},[0,[],0,0]),be(([x])=>x!==0),_e(r,a,n,o,m,b),be(([,x,w,y,,,E])=>!E&&!y&&x!==0&&w===Ir),re(([[x],,,,,w])=>(w("Upward scrolling compensation",{amount:x},kt.DEBUG),x))));function g(x){x>0?(Ae(t,{behavior:"auto",top:-x}),Ae(e,0)):(Ae(e,0),Ae(t,{behavior:"auto",top:-x}))}return qe(B(v,_e(e,s)),([x,w,y])=>{y&&Mg()?Ae(e,w-x):g(-x)}),qe(B(it(gt(s,!1),e,b),be(([x,w,y])=>!x&&!y&&w!==0),re(([x,w])=>w),fn(1)),g),de(B(f,re(x=>({top:-x}))),t),qe(B(u,_e(h,d),re(([x,{groupIndices:w,lastSize:y,sizeTree:E},S])=>{function T(I){return I*(y+S)}if(w.length===0)return T(x);{let I=0;const N=Sr(E,0);let R=0,j=0;for(;R<x;){R++,I+=N;let A=w.length===j+1?1/0:w[j+1]-w[j]-1;R+A>x&&(I-=N,A=x-R+1),R+=A,I+=T(A),j++}return I}})),x=>{Ae(e,x),requestAnimationFrame(()=>{Ae(t,{top:x}),requestAnimationFrame(()=>{Ae(e,0),Ae(b,!1)})})}),{deviation:e}},Ze(bt,Ar,Dn,tn,vn,Js)),Lg=He(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),Ze(ni,Rg,bn,ic,nc,_g,Eg,oi,oc,vn,rc)),lc=He(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b},v,g,x,{listState:w,topItemsIndexes:y,...E},{scrollToIndex:S},T,{topItemCount:I},{groupCounts:N},R])=>(de(E.rangeChanged,R.scrollSeekRangeChanged),de(B(R.windowViewportRect,re(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:w,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:f,...E,...R,...v,sizes:c,...g}),Ze(tn,Er,bt,jg,Ag,Dn,kr,Dg,Og,Gl,Lg));function $g(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 vo=typeof document<"u"?C.useLayoutEffect:C.useEffect;function cc(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=C.createContext({});function c(g,x){g.propsReady&&Ae(g.propsReady,!1);for(const w of r){const y=g[t.required[w]];Ae(y,x[w])}for(const w of o)if(w in x){const y=g[t.optional[w]];Ae(y,x[w])}g.propsReady&&Ae(g.propsReady,!0)}function u(g){return s.reduce((x,w)=>(x[w]=y=>{const E=g[t.methods[w]];Ae(E,y)},x),{})}function d(g){return i.reduce((x,w)=>(x[w]=eg(g[t.events[w]]),x),{})}const f=C.forwardRef((g,x)=>{const{children:w,...y}=g,[E]=C.useState(()=>co(ng(e),I=>{c(I,y)})),[S]=C.useState(jl(d,E));vo(()=>{for(const I of i)I in y&&qe(S[I],y[I]);return()=>{Object.values(S).map(Ws)}},[y,S,E]),vo(()=>{c(E,y)}),C.useImperativeHandle(x,Rl(u(E)));const T=n;return l.jsx(a.Provider,{value:E,children:n?l.jsx(T,{...$g([...r,...o,...i],y),children:w}):w})}),h=g=>{const x=C.useContext(a);return C.useCallback(w=>{Ae(x[g],w)},[x,g])},m=g=>{const x=C.useContext(a)[g],w=C.useCallback(y=>qe(x,y),[x]);return C.useSyncExternalStore(w,()=>ot(x),()=>ot(x))},b=g=>{const x=C.useContext(a)[g],[w,y]=C.useState(jl(ot,x));return vo(()=>qe(x,E=>{E!==w&&y(Rl(E))}),[x,w]),w},v=C.version.startsWith("18")?m:b;return{Component:f,useEmitter:(g,x)=>{const w=C.useContext(a)[g];vo(()=>qe(w,x),[x,w])},useEmitterValue:v,usePublisher:h}}const uc=C.createContext(void 0),dc=C.createContext(void 0),fc=typeof document<"u"?C.useLayoutEffect:C.useEffect;function si(e){return"self"in e}function Fg(e){return"body"in e}function hc(e,t,n,r=er,o,s){const i=C.useRef(null),a=C.useRef(null),c=C.useRef(null),u=C.useCallback(h=>{let m,b,v;const g=h.target;if(Fg(g)||si(g)){const w=si(g)?g:g.defaultView;v=s?w.scrollX:w.scrollY,m=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=s?w.innerWidth:w.innerHeight}else v=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,b=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(v,0),viewportHeight:b})};h.suppressFlushSync?x():Es.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===m-b)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);C.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const b=h.behavior==="smooth";let v,g,x;si(m)?(g=Math.max(wn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),v=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],v=wn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const w=g-v;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),Xl(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),b&&t(!0);return}b?(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}),m.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const ii="-webkit-sticky",pc="sticky",ai=ac(()=>{if(typeof document>"u")return pc;const e=document.createElement("div");return e.style.position=ii,e.style.position===ii?ii:pc});function li(e){return e}const zg=He(()=>{const e=K(a=>`Item ${a}`),t=K(a=>`Group ${a}`),n=K({}),r=K(li),o=K("div"),s=K(er),i=(a,c=null)=>gt(B(n,re(u=>u[a]),Qe()),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")}}),Bg=He(([e,t])=>({...e,...t}),Ze(lc,zg)),Hg=({height:e})=>l.jsx("div",{style:{height:e}}),Ug={overflowAnchor:"none",position:ai(),zIndex:1},mc={overflowAnchor:"none"},Wg={...mc,display:"inline-block",height:"100%"},gc=C.memo(function({showTopList:e=!1}){const t=Te("listState"),n=Lt("sizeRanges"),r=Te("useWindowScroll"),o=Te("customScrollParent"),s=Lt("windowScrollContainerState"),i=Lt("scrollContainerState"),a=o||r?s:i,c=Te("itemContent"),u=Te("context"),d=Te("groupContent"),f=Te("trackItemSizes"),h=Te("itemSize"),m=Te("log"),b=Lt("gap"),v=Te("horizontalDirection"),{callbackRef:g}=sg(n,h,f,e?er:a,m,b,o,v,Te("skipAnimationFrameInResizeObserver")),[x,w]=C.useState(0);ci("deviation",O=>{x!==O&&w(O)});const y=Te("EmptyPlaceholder"),E=Te("ScrollSeekPlaceholder")||Hg,S=Te("ListComponent"),T=Te("ItemComponent"),I=Te("GroupComponent"),N=Te("computeItemKey"),R=Te("isSeeking"),j=Te("groupIndices").length>0,A=Te("alignToBottom"),z=Te("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:A?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:A?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?l.jsx(y,{...xt(y,u)}):l.jsx(S,{...xt(S,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:V,children:(e?t.topItems:t.items).map(O=>{const G=O.originalIndex,W=N(G+t.firstItemIndex,O.data,u);return R?C.createElement(E,{...xt(E,u),height:O.size,index:O.index,key:W,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?C.createElement(I,{...xt(I,u),"data-index":G,"data-item-index":O.index,"data-known-size":O.size,key:W,style:Ug},d(O.index,u)):C.createElement(T,{...xt(T,u),...Gg(T,O.data),"data-index":G,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:W,style:v?Wg:mc},j?c(O.index,O.groupIndex,O.data,u):c(O.index,O.data,u))})})}),Vg={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},qg={outline:"none",overflowX:"auto",position:"relative"},wo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Kg={position:ai(),top:0,width:"100%",zIndex:1};function xt(e,t){if(typeof e!="string")return{context:t}}function Gg(e,t){return{item:typeof e=="string"?void 0:t}}const Yg=C.memo(function(){const e=Te("HeaderComponent"),t=Lt("headerHeight"),n=Te("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null}),Xg=C.memo(function(){const e=Te("FooterComponent"),t=Lt("footerHeight"),n=Te("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null});function xc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:b}=hc(a,u,c,d,void 0,f);return e("scrollTo",b),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?qg:Vg,...o},tabIndex:0,...i,...xt(c,s),children:r})})}function vc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),m=C.useRef(null),b=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=hc(a,u,c,b,h);return fc(()=>{var w;return g.current=h||((w=m.current)==null?void 0:w.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...xt(c,s),children:r})})}const Jg=({children:e})=>{const t=C.useContext(uc),n=Lt("viewportHeight"),r=Lt("fixedItemHeight"),o=Te("alignToBottom"),s=Te("horizontalDirection"),i=C.useMemo(()=>_l(n,c=>wn(c,s?"width":"height")),[n,s]),a=On(i,!0,Te("skipAnimationFrameInResizeObserver"));return C.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:wo(o),children:e})},Zg=({children:e})=>{const t=C.useContext(uc),n=Lt("windowViewportRect"),r=Lt("fixedItemHeight"),o=Te("customScrollParent"),s=Dl(n,o,Te("skipAnimationFrameInResizeObserver")),i=Te("alignToBottom");return C.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:wo(i),children:e})},Qg=({children:e})=>{const t=Te("TopItemListComponent")||"div",n=Te("headerHeight"),r={...Kg,marginTop:`${n}px`},o=Te("context");return l.jsx(t,{style:r,...xt(t,o),children:e})},ex=C.memo(function(e){const t=Te("useWindowScroll"),n=Te("topItemsIndexes").length>0,r=Te("customScrollParent"),o=Te("context");return l.jsxs(r||t?rx:nx,{...e,context:o,children:[n&&l.jsx(Qg,{children:l.jsx(gc,{showTopList:!0})}),l.jsxs(r||t?Zg:Jg,{children:[l.jsx(Yg,{}),l.jsx(gc,{}),l.jsx(Xg,{})]})]})}),{Component:tx,useEmitter:ci,useEmitterValue:Te,usePublisher:Lt}=cc(Bg,{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"}},ex),nx=xc({useEmitter:ci,useEmitterValue:Te,usePublisher:Lt}),rx=vc({useEmitter:ci,useEmitterValue:Te,usePublisher:Lt}),ox=tx;Ze(lc,He(()=>{const e=K(u=>l.jsxs("td",{children:["Item $",u]})),t=K(null),n=K(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=K(null),o=K(null),s=K({}),i=K(li),a=K(er),c=(u,d=null)=>gt(B(s,re(f=>f[u]),Qe()),d);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")}})),ai();const wc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},sx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:bc,floor:bo,max:Rr,min:ui,round:yc}=Math;function Sc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function ix(e){return{...sx,items:e}}function yo(e,t){return e&&e.width===t.width&&e.height===t.height}function ax(e,t){return e&&e.column===t.column&&e.row===t.row}const lx=He(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,m,{didMount:b,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:w,windowScrollTo:y,windowViewportRect:E},S])=>{const T=K(0),I=K(0),N=K(wc),R=K({height:0,width:0}),j=K({height:0,width:0}),A=Le(),z=Le(),V=K(0),O=K(null),G=K({column:0,row:0}),W=Le(),q=Le(),L=K(!1),M=K(0),le=K(!0),Z=K(!1),ee=K(!1);qe(B(b,_e(M),be(([P,H])=>!!H)),()=>{Ae(le,!1)}),qe(B(it(b,le,j,R,M,Z),be(([P,H,Q,ce,,ie])=>P&&!H&&Q.height!==0&&ce.height!==0&&!ie)),([,,,,P])=>{Ae(Z,!0),ei(1,()=>{Ae(A,P)}),qt(B(u),()=>{Ae(t,[0,0]),Ae(le,!0)})}),de(B(q,be(P=>P!=null&&P.scrollTop>0),Qt(0)),I),qe(B(b,_e(q),be(([,P])=>P!=null)),([,P])=>{P&&(Ae(R,P.viewport),Ae(j,P.item),Ae(G,P.gap),P.scrollTop>0&&(Ae(L,!0),qt(B(u,Pn(1)),H=>{Ae(L,!1)}),Ae(c,{top:P.scrollTop})))}),de(B(R,re(({height:P})=>P)),f),de(B(it(ve(R,yo),ve(j,yo),ve(G,(P,H)=>P&&P.column===H.column&&P.row===H.row),ve(u)),re(([P,H,Q,ce])=>({gap:Q,item:H,scrollTop:ce,viewport:P}))),W),de(B(it(ve(T),r,ve(G,ax),ve(j,yo),ve(R,yo),ve(O),ve(I),ve(L),ve(le),ve(M)),be(([,,,,,,,P])=>!P),re(([P,[H,Q],ce,ie,Fe,$e,we,,Ne,Ue])=>{const{column:et,row:Xe}=ce,{height:ut,width:dt}=ie,{width:ue}=Fe;if(we===0&&(P===0||ue===0))return wc;if(dt===0){const nt=ti(Ue,P),Re=nt+Math.max(we-1,0);return ix(Sc(nt,Re,$e))}const fe=Cc(ue,dt,et);let pe,Se;Ne?H===0&&Q===0&&we>0?(pe=0,Se=we-1):(pe=fe*bo((H+Xe)/(ut+Xe)),Se=fe*bc((Q+Xe)/(ut+Xe))-1,Se=ui(P-1,Rr(Se,fe-1)),pe=ui(Se,Rr(0,pe))):(pe=0,Se=-1);const Oe=Sc(pe,Se,$e),{bottom:Ve,top:F}=Tc(Fe,ce,ie,Oe),Y=bc(P/fe),je=Y*ut+(Y-1)*Xe-Ve;return{bottom:Ve,itemHeight:ut,items:Oe,itemWidth:dt,offsetBottom:je,offsetTop:F,top:F}})),N),de(B(O,be(P=>P!==null),re(P=>P.length)),T),de(B(it(R,j,N,G),be(([P,H,{items:Q}])=>Q.length>0&&H.height!==0&&P.height!==0),re(([P,H,{items:Q},ce])=>{const{bottom:ie,top:Fe}=Tc(P,ce,H,Q);return[Fe,ie]}),Qe(Cr)),t);const D=K(!1);de(B(u,_e(D),re(([P,H])=>H||P!==0)),D);const J=At(B(it(N,T),be(([{items:P}])=>P.length>0),_e(D),be(([[P,H],Q])=>{const ce=P.items[P.items.length-1].index===H-1;return(Q||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===H)&&ce}),re(([[,P]])=>P-1),Qe())),ke=At(B(ve(N),be(({items:P})=>P.length>0&&P[0].index===0),Qt(0),Qe())),he=At(B(ve(N),_e(L),be(([{items:P},H])=>P.length>0&&!H),re(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),Qe(Ul),fn(0)));de(he,m.scrollSeekRangeChanged),de(B(A,_e(R,j,T,G),re(([P,H,Q,ce,ie])=>{const Fe=Yl(P),{align:$e,behavior:we,offset:Ne}=Fe;let Ue=Fe.index;Ue==="LAST"&&(Ue=ce-1),Ue=Rr(0,Ue,ui(ce-1,Ue));let et=di(H,ie,Q,Ue);return $e==="end"?et=yc(et-H.height+Q.height):$e==="center"&&(et=yc(et-H.height/2+Q.height/2)),Ne&&(et+=Ne),{behavior:we,top:et}})),c);const $=gt(B(N,re(P=>P.offsetBottom+P.bottom)),0);return de(B(E,re(P=>({height:P.visibleHeight,width:P.visibleWidth}))),R),{customScrollParent:g,data:O,deviation:V,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:q,scrollBy:i,scrollContainerState:a,scrollHeight:z,scrollTo:c,scrollToIndex:A,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:R,windowScrollContainerState:w,windowScrollTo:y,windowViewportRect:E,...m,gridState:N,horizontalDirection:ee,initialTopMostItemIndex:M,totalListHeight:$,...h,endReached:J,propsReady:v,rangeChanged:he,startReached:ke,stateChanged:W,stateRestoreInProgress:L,...S}},Ze(ni,bt,Ar,ic,bn,oi,vn));function Cc(e,t,n){return Rr(1,bo((e+n)/(bo(t)+n)))}function Tc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=di(e,t,n,r[0].index);return{bottom:di(e,t,n,r[r.length-1].index)+o,top:s}}function di(e,t,n,r){const o=Cc(e.width,n.width,t.column),s=bo(r/o),i=s*n.height+Rr(0,s-1)*t.row;return i>0?i+t.row:i}const cx=He(()=>{const e=K(f=>`Item ${f}`),t=K({}),n=K(null),r=K("virtuoso-grid-item"),o=K("virtuoso-grid-list"),s=K(li),i=K("div"),a=K(er),c=(f,h=null)=>gt(B(t,re(m=>m[f]),Qe()),h),u=K(!1),d=K(!1);return de(ve(d),u),{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:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),ux=He(([e,t])=>({...e,...t}),Ze(lx,cx)),dx=C.memo(function(){const e=tt("gridState"),t=tt("listClassName"),n=tt("itemClassName"),r=tt("itemContent"),o=tt("computeItemKey"),s=tt("isSeeking"),i=$t("scrollHeight"),a=tt("ItemComponent"),c=tt("ListComponent"),u=tt("ScrollSeekPlaceholder"),d=tt("context"),f=$t("itemDimensions"),h=$t("gap"),m=tt("log"),b=tt("stateRestoreInProgress"),v=$t("reportReadyState"),g=On(C.useMemo(()=>x=>{const w=x.parentElement.parentElement.scrollHeight;i(w);const y=x.firstChild;if(y){const{height:E,width:S}=y.getBoundingClientRect();f({height:E,width:S})}h({column:Ec("column-gap",getComputedStyle(x).columnGap,m),row:Ec("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,h,m]),!0,!1);return fc(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),b?null:l.jsx(c,{className:t,ref:g,...xt(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const w=o(x.index,x.data,d);return s?l.jsx(u,{...xt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},w):C.createElement(a,{...xt(a,d),className:n,"data-index":x.index,key:w},r(x.index,x.data,d))})})}),fx=C.memo(function(){const e=tt("HeaderComponent"),t=$t("headerHeight"),n=tt("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,!1),o=tt("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null}),hx=C.memo(function(){const e=tt("FooterComponent"),t=$t("footerHeight"),n=tt("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,!1),o=tt("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null}),px=({children:e})=>{const t=C.useContext(dc),n=$t("itemDimensions"),r=$t("viewportDimensions"),o=On(C.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return C.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:wo(!1),children:e})},mx=({children:e})=>{const t=C.useContext(dc),n=$t("windowViewportRect"),r=$t("itemDimensions"),o=tt("customScrollParent"),s=Dl(n,o,!1);return C.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:wo(!1),children:e})},gx=C.memo(function({...e}){const t=tt("useWindowScroll"),n=tt("customScrollParent"),r=n||t?vx:xx,o=n||t?mx:px,s=tt("context");return l.jsx(r,{...e,...xt(r,s),children:l.jsxs(o,{children:[l.jsx(fx,{}),l.jsx(dx,{}),l.jsx(hx,{})]})})}),{useEmitter:kc,useEmitterValue:tt,usePublisher:$t}=cc(ux,{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"}},gx),xx=xc({useEmitter:kc,useEmitterValue:tt,usePublisher:$t}),vx=vc({useEmitter:kc,useEmitterValue:tt,usePublisher:$t});function Ec(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,kt.WARN),t==="normal"?0:parseInt(t??"0",10)}const wx=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function fi({className:e,variant:t,...n}){return l.jsx("div",{className:X(wx({variant:t}),e),...n})}function ae(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function bx(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,c=p.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function nn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:m,...b}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,g=p.useMemo(()=>b,Object.values(b));return l.jsx(v.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,h){var v;const m=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,b=p.useContext(m);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,yx(o,...t)]}function yx(...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:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var ht=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Sx=p[" useInsertionEffect ".trim().toString()]||ht;function Ln({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Cx({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=p.useCallback(d=>{var f;if(a){const h=Tx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[c,u]}function Cx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Sx(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Tx(e){return typeof e=="function"}function Ic(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function hi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ic(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():Ic(e[o],null)}}}}function Me(...e){return p.useCallback(hi(...e),e)}var kx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=kx.reduce((e,t)=>{const n=An.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Nc(e,t){e&&Gr.flushSync(()=>e.dispatchEvent(t))}function Ex(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var _t=e=>{const{present:t,children:n}=e,r=Ix(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Me(r.ref,Nx(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};_t.displayName="Presence";function Ix(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Ex(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=So(r.current);s.current=a==="mounted"?u:"none"},[a]),ht(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,m=So(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),ht(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const v=So(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(c("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=m=>{m.target===t&&(s.current=So(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function So(e){return(e==null?void 0:e.animationName)||"none"}function Nx(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 Ax=p[" useId ".trim().toString()]||(()=>{}),Rx=0;function rn(e){const[t,n]=p.useState(Ax());return ht(()=>{n(r=>r??String(Rx++))},[e]),e||(t?`radix-${t}`:"")}var Co="Collapsible",[_x,CC]=nn(Co),[jx,pi]=_x(Co),Ac=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=Ln({prop:r,defaultProp:o??!1,onChange:i,caller:Co});return l.jsx(jx,{scope:n,disabled:s,contentId:rn(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:l.jsx(ye.div,{"data-state":gi(c),"data-disabled":s?"":void 0,...a,ref:t})})});Ac.displayName=Co;var Rc="CollapsibleTrigger",_c=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=pi(Rc,n);return l.jsx(ye.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":gi(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ae(e.onClick,o.onOpenToggle)})});_c.displayName=Rc;var mi="CollapsibleContent",Px=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=pi(mi,e.__scopeCollapsible);return l.jsx(_t,{present:n||o.open,children:({present:s})=>l.jsx(Ox,{...r,ref:t,present:s})})});Px.displayName=mi;var Ox=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=pi(mi,n),[a,c]=p.useState(r),u=p.useRef(null),d=Me(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),b=m.current,v=i.open||a,g=p.useRef(v),x=p.useRef(void 0);return p.useEffect(()=>{const w=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(w)},[]),ht(()=>{const w=u.current;if(w){x.current=x.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const y=w.getBoundingClientRect();f.current=y.height,m.current=y.width,g.current||(w.style.transitionDuration=x.current.transitionDuration,w.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(ye.div,{"data-state":gi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:v&&o})});function gi(e){return e?"open":"closed"}var Mx=Ac;const jc=Mx,Pc=_c;function Oc(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let $n=Oc();function Dx(e){$n=e}const Mc=/[&<>"']/,Lx=new RegExp(Mc.source,"g"),Dc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,$x=new RegExp(Dc.source,"g"),Fx={"&":"&","<":"<",">":">",'"':""","'":"'"},Lc=e=>Fx[e];function vt(e,t){if(t){if(Mc.test(e))return e.replace(Lx,Lc)}else if(Dc.test(e))return e.replace($x,Lc);return e}const zx=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function $c(e){return e.replace(zx,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const Bx=/(^|[^\[])\^/g;function Ye(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Bx,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Hx=/[^\w:]/g,Ux=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Fc(e,t,n){if(e){let r;try{r=decodeURIComponent($c(n)).replace(Hx,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Ux.test(n)&&(n=Kx(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const To={},Wx=/^[^:]+:\/*[^/]*$/,Vx=/^([^:]+:)[\s\S]*$/,qx=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Kx(e,t){To[" "+e]||(Wx.test(e)?To[" "+e]=e+"/":To[" "+e]=Eo(e,"/",!0)),e=To[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Vx,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(qx,"$1")+t:e+t}const ko={exec:function(){}};function zc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Eo(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function Gx(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function Yx(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Bc(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Hc(e,t,n,r){const o=t.href,s=t.title?vt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:vt(i)}}function Xx(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
38
|
+
`)}const Dm={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Lm(e,t){var n;switch(t.type){case"reset":console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Bs(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r;case"seed":{const o=Bs(t.payload.messages),s={...e,messages:o,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(s.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(s.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:o.length,previousCount:e.messages.length,checkpointId:s.lastCheckpointId}),s}case"prepend":{const o=Bs(t.payload.messages);if(!o.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const s=new Set(e.messages.map(a=>a.id)),i=o.filter(a=>!s.has(a.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:i.length,duplicates:o.length-i.length,finalTotal:i.length+e.messages.length}),i.length?{...e,messages:[...i,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const o=t.payload.message;if(e.assemblingId){const s=e.messages.findIndex(i=>i.id===e.assemblingId);if(s!==-1)return{...e,messages:[...e.messages.slice(0,s),o,...e.messages.slice(s)]}}return{...e,messages:[...e.messages,o]}}case"event":return Tl(e,t.payload.ev);case"batch":{const{events:o}=t.payload;return o.length?o.reduce((s,i)=>Tl(s,i),e):e}default:return e}}function Cl(e=[]){const[t,n]=C.useReducer(Lm,{...Dm,messages:e}),r=C.useRef([]),o=C.useRef(null),s=C.useRef(null),i=C.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=C.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=C.useCallback(d=>{r.current.push(d),a()},[a]);C.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=C.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:c}),[c]);return{state:t,dispatch:n,...u}}function Tl(e,t){var n;if(t.type==="message_start"&&t.role==="assistant"){const r=t.id,o=Hm(t.model),s={id:r,role:"assistant",name:o||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:r,messages:[...e.messages,s]}}if(t.type==="token"){const r=e.assemblingId??Hs(e.messages);return r?{...e,messages:Fm(e.messages,r,t.content)}:e}if(t.type==="message_delta"){const r=e.assemblingId??Hs(e.messages);return r?{...e,messages:El(e.messages,r,t.delta)}:e}if(t.type==="message_end"){const r=e.assemblingId??Hs(e.messages);if(!r)return{...e,assemblingId:null};const o=e.messages,s=o.findIndex(i=>i.id===r&&i.role==="assistant");if(s>=0&&!((n=o[s].content)==null?void 0:n.some(c=>{var u;return(c==null?void 0:c.type)==="text"&&((u=c.text)==null?void 0:u.trim())}))){const c=[...o.slice(0,s),...o.slice(s+1)];return{...e,assemblingId:null,messages:c}}return e}if(t.type==="tool_start"){const r=`tool-${t.id}`,o={type:"tool_call",id:t.id,name:t.name,args:t.args},s={id:r,role:"tool",name:t.name,createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,s],toolIndex:{...e.toolIndex,[t.id]:r}}}if(t.type==="tool_result"){const r=e.toolIndex[t.id]??`tool-${t.id}`,o={type:"tool_result",toolCallId:t.id,output:t.output,error:t.error},s=e.messages.find(c=>c.id===r),i={id:r,role:"tool",content:[o],createdAt:new Date().toISOString()},a=s?El(e.messages,r,[o]):[...e.messages,i];return{...e,messages:a}}if(t.type==="checkpoint"){const r=t.checkpointNs??e.lastCheckpointNs??null,o=Bm(e.messages,t.checkpointId,r);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:r,messages:o}}if(t.type==="branch"){const r=t.checkpointId??e.lastCheckpointId,o=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:r??null,lastCheckpointNs:o??null}}if(t.type==="error"){const r={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,r]}}return e}function Bs(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function $m(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Hs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function kl(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Fm(e,t,n){return kl(e,t,r=>{const o=r.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=n:o.push({type:"text",text:n}),{...r,content:o}})}function El(e,t,n){return kl(e,t,r=>({...r,content:zm(r.content,n)}))}function zm(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Bm(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 $m(e,r,s)}return e}function Hm(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Um(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function Wm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Vm(e,t=[],n,r,o,s){const i=[],a=[];for(const c of t)try{const u=await Wm(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Il=C.createContext(null);function io({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,autoLoadInitial:s=!0,disableAutoRestore:i=!1,enableFileAgentRouting:a=!1,fileAgentId:c="invoice_reader"}){const u=gn;C.useEffect(()=>{t&&u.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[u,t]);const{isStreaming:d,error:f,stream:h,stop:m,setToken:b}=Sl({baseUrl:u.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/runs/stream"}),[v,g]=C.useState(()=>typeof u.getAuthToken=="function"?u.getAuthToken():null);C.useEffect(()=>{b(typeof u.getAuthToken=="function"?u.getAuthToken():null);const F=u.onTokenChange(Y=>{g(Y),b(Y)});return()=>{F()}},[u,b]);const x=C.useCallback(F=>{u.setAuthToken(F)},[u]),{state:w,seed:y,prepend:E,pushUser:S,onEvent:T,reset:I}=Cl(),N=20,[R,j]=C.useState(!1),[A,z]=C.useState(!1),[V,O]=C.useState(null),[G,W]=C.useState(void 0),[q,L]=C.useState(void 0),M=C.useRef(!1),le=C.useRef([]),Z=C.useRef(null),ee=C.useCallback(F=>{F.cursor!==void 0&&O(F.cursor),F.hasMore!==void 0&&j(F.hasMore),F.checkpointId!==void 0&&W(F.checkpointId),F.checkpointNs!==void 0&&L(F.checkpointNs)},[]),D=C.useCallback((F,Y)=>new Promise((je,nt)=>{const Re=async()=>{if(M.current){console.warn(`[ChatProvider] Operation "${Y}" queued - another operation in progress`),le.current.push(Re);return}M.current=!0;try{console.log(`[ChatProvider] Executing operation: ${Y}`),await F(),je()}catch(at){console.error(`[ChatProvider] Operation "${Y}" failed:`,at),nt(at)}finally{M.current=!1;const at=le.current.shift();at&&at().catch(()=>{})}};M.current?(le.current.push(Re),console.log(`[ChatProvider] Queued operation: ${Y}`)):Re().catch(at=>{nt(at)})}),[]),J=C.useCallback((F,Y)=>{const je=Array.isArray(F==null?void 0:F.messages)?F.messages:[];Y==="replace"?(console.log("[ChatProvider] Replacing messages, count:",je.length),y(je,{checkpointId:(F==null?void 0:F.checkpointId)??null,checkpointNs:(F==null?void 0:F.checkpointNs)??null})):Y==="prepend"&&je.length?(console.log("[ChatProvider] Calling prepend with",je.length,"messages"),E(je)):console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"),O((F==null?void 0:F.nextCursor)??null),j(!!(F!=null&&F.hasMore)),W(nt=>(F==null?void 0:F.checkpointId)??nt??void 0),L(nt=>(F==null?void 0:F.checkpointNs)??nt??void 0)},[y,E]),[ke,he]=C.useState([]),[$,P]=C.useState(null),H=C.useCallback(async()=>{const F=await u.listThreads();he(F)},[u]),[Q,ce]=C.useState(!1),ie=C.useCallback(async F=>{const Y=(F==null?void 0:F.maxAttempts)??5,je=(F==null?void 0:F.baseDelayMs)??500,nt=(F==null?void 0:F.timeoutMs)??2e3;if(!u.baseUrl)return!1;const Re=u.baseUrl.replace(/\/+$/,""),at=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],Ht=async wt=>{try{const Ot=new AbortController,ft=setTimeout(()=>Ot.abort(),nt),Et=await fetch(wt,{method:"GET",signal:Ot.signal});return clearTimeout(ft),Et.ok}catch{return!1}},Gn=async wt=>{try{const Ot=new AbortController,ft=setTimeout(()=>Ot.abort(),nt),Et=await fetch(wt,{method:"HEAD",signal:Ot.signal});return clearTimeout(ft),Et.ok}catch{return!1}};for(let wt=0;wt<Y;wt++){console.debug(`[ChatProvider] health-check attempt ${wt+1}/${Y}`);for(const ft of at){let Et=ft;Re.endsWith("/api")&&ft.startsWith("/api")&&(Et=ft.replace(/^\/api/,"")||"/");const te=Et==="/"?Re+"/":Re+Et;if(console.debug(`[ChatProvider] checking ${te}`),await Ht(te)||ft==="/"&&await Gn(Re+"/"))return ce(!0),!0}const Ot=je*Math.pow(2,wt);await new Promise(ft=>setTimeout(ft,Ot))}return ce(!1),!1},[u.baseUrl]);C.useEffect(()=>{let F=!0;if(!u.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const Y=await ie();if(!F)return;Y?H().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{F=!1}},[H,u.baseUrl,ie]),C.useEffect(()=>{r==null||r($)},[$,r]);const Fe=C.useRef(null);C.useEffect(()=>{if(o&&s){if(!u.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!Q){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}Fe.current!==o&&(Fe.current=o,Ne(o).catch(()=>{}))}},[o,s,u.baseUrl,Q]);const $e=C.useRef(null),we=C.useRef(null),Ne=C.useCallback(async(F,Y,je)=>{await D(async()=>{if(Z.current===F){console.log(`[ChatProvider] Skipping auto-load for thread ${F} - suppressed after clear`),Z.current=null;return}if(!u.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if($e.current){console.warn(`[ChatProvider] Thread load cancelled - another thread (${$e.current}) is loading`);return}we.current!==null&&we.current!==F&&(console.log(`[ChatProvider] Thread switch detected: ${we.current} -> ${F}`),I([])),$e.current=F,we.current=F;try{ee({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),P(F);const Re=await u.getMessages({threadId:F,checkpointId:Y,checkpointNs:je,limit:N}),at=Array.isArray(Re==null?void 0:Re.messages)?Re.messages:[];console.log("[ChatProvider] Loading thread with",at.length,"messages"),y(at,{checkpointId:(Re==null?void 0:Re.checkpointId)??null,checkpointNs:(Re==null?void 0:Re.checkpointNs)??null}),O((Re==null?void 0:Re.nextCursor)??null),j(!!(Re!=null&&Re.hasMore)),W(Ht=>(Re==null?void 0:Re.checkpointId)??Ht??void 0),L(Ht=>(Re==null?void 0:Re.checkpointNs)??Ht??void 0)}finally{$e.current=null}},`loadThread-${F}`)},[u,D,ee,y]),Ue=C.useCallback(async F=>{const Y=await u.listCheckpoints(F);return Um(Y,F)},[u]),et=C.useCallback(async(F,Y)=>{await D(async()=>{if(!$)throw new Error("No active thread");ee({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0});const je=await u.getMessages({threadId:$,checkpointId:F,checkpointNs:Y??void 0,limit:N});J(je,"replace")},`navigateToCheckpoint-${F}`)},[u,$,J,D,ee]),Xe=C.useCallback(async()=>{if(!$)throw new Error("No active thread");await Ne($)},[$,Ne]),ut=C.useRef(!1);C.useEffect(()=>{const F=ut.current;ut.current=d,F&&!d&&$&&D(async()=>{try{await H()}catch(Y){console.warn("[ChatProvider] Post-streaming thread refresh failed:",Y)}},"postStreamingRefresh")},[d,$,u,J,H,D]);const dt=C.useCallback(async()=>{console.log("[ChatProvider] 🔄 clearCurrentThread called"),console.log("[ChatProvider] 📊 Before clear - currentThreadId:",$),console.log("[ChatProvider] 📊 Before clear - messages count:",w.messages.length),$&&(Z.current=$,console.log(`[ChatProvider] 🚫 Suppressing next auto-load for thread: ${$}`)),await D(()=>(console.log("[ChatProvider] 🚀 Executing atomic clear operation"),P(null),I([]),ee({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),typeof window<"u"&&localStorage.removeItem("currentThreadId"),console.log("[ChatProvider] ✅ Atomic clear operation completed"),Promise.resolve()),"clearCurrentThread"),console.log("[ChatProvider] 📊 After clear - currentThreadId should be null")},[I,ee,$,w.messages.length,D]),ue=C.useCallback(async F=>{dt();const Y=await u.createThread(F);return await H(),await Ne(Y.threadId),Y.threadId},[u,H,Ne,dt]),fe=C.useCallback(async F=>{await u.deleteThread(F),await H(),$===F&&(P(null),I([]),j(!1),O(null),W(void 0),L(void 0))},[u,H,$,I]),pe=C.useCallback(async(F,Y)=>{await u.updateThread(F,Y),await H()},[u,H]),Se=C.useCallback(async(F,Y)=>{var Pe;const je=(Y==null?void 0:Y.attachments)||[],{contentParts:nt,filesInfo:Re}=await Vm(u,je,t==null?void 0:t.uploadPath),at=[];F&&F.trim()&&at.push({type:"text",text:F.trim()});const Ht={id:((Pe=crypto.randomUUID)==null?void 0:Pe.call(crypto))||`user-${Date.now()}`,role:"user",content:at,createdAt:new Date().toISOString(),checkpointId:(Y==null?void 0:Y.checkpointId)??w.lastCheckpointId??void 0,checkpointNs:(Y==null?void 0:Y.checkpointNs)??w.lastCheckpointNs??void 0};S(Ht);const Gn={...Ht,content:at},wt={...(Y==null?void 0:Y.payloadExtras)??{}},Ot=!!wt.edit,ft=wt.originalMessageId,Et=typeof ft=="string"?ft:void 0,te=je&&je.length>0,me={...$?{threadId:$}:{},payload:{messages:[Gn],files_info:Re,...a&&te&&c?{active_agent:c}:{},...wt},checkpointId:(Y==null?void 0:Y.checkpointId)??w.lastCheckpointId??void 0,checkpointNs:(Y==null?void 0:Y.checkpointNs)??w.lastCheckpointNs??void 0,nodeFilter:Y==null?void 0:Y.nodeFilter,config:Y==null?void 0:Y.config,edit:Ot,originalMessageId:Et};h(me,Be=>T(Be),{onError:Be=>console.warn("stream error",Be),onOpen:({threadId:Be,created:Ut})=>{!$&&Be&&(P(Be),Ut&&H().catch(()=>{}))}})},[$,S,h,T,w.lastCheckpointId,w.lastCheckpointNs,u,t==null?void 0:t.uploadPath,H,P,a,c]),Oe=C.useCallback(async F=>{if(!$)throw new Error("No active thread");if(A||!R)return;const Y=V;if(Y){z(!0);try{const je=await u.getMessages({threadId:$,checkpointId:G,checkpointNs:q,limit:(F==null?void 0:F.limit)??N,beforeId:Y});J(je,"prepend")}finally{z(!1)}}},[u,$,G,q,V,R,A,J,N]),Ve={baseUrl:u.baseUrl,token:v,setToken:x,api:u,threads:ke,currentThreadId:$,setCurrentThreadId:P,messages:w.messages,isStreaming:d,error:f,lastCheckpointId:w.lastCheckpointId,lastCheckpointNs:w.lastCheckpointNs,streamingAssistantId:w.assemblingId,hasMoreHistory:R,isLoadingHistory:A,loadOlderMessages:Oe,historyPageSize:N,listCheckpoints:Ue,navigateToCheckpoint:et,returnToLatest:Xe,refreshThreads:H,createThread:ue,deleteThread:fe,renameThread:pe,loadThread:Ne,clearCurrentThread:dt,send:Se,stop:m};return l.jsx(Il.Provider,{value:Ve,children:e})}function ao(){const e=C.useContext(Il);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function X(...e){return cp.twMerge(lp.clsx(e))}const qm=Kr.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"}}),We=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?An.Slot:"button";return l.jsx(i,{className:X(qm({variant:t,size:n,className:e})),ref:s,...o})});We.displayName="Button";const Nl=p.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:X("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Nl.displayName="Textarea";function Km({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,m]=C.useState(e),[b,v]=C.useTransition(),g=C.useRef(null);C.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=C.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);C.useEffect(()=>{x()},[x]);const w=C.useCallback(async N=>{N&&N.preventDefault();const R=(h??"").trim();!R&&!f||v(()=>{try{const j=i(R);j&&typeof j.then=="function"?j.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),y=C.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=C.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),w()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[w,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return l.jsx("form",{onSubmit:N=>void w(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(Nl,{ref:g,value:h,onChange:y,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(We,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(oe.Square,{size:16})}):l.jsx(We,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||b,children:l.jsx(oe.Send,{size:16})})})]})})}const Gm=C.memo(Km),lo=0,xn=1,Qn=2,Al=4;function Rl(e){return()=>e}function Ym(e){e()}function _l(e,t){return n=>e(t(n))}function jl(e,t){return()=>e(t)}function Xm(e,t){return n=>e(t,n)}function Us(e){return e!==void 0}function Jm(...e){return()=>{e.map(Ym)}}function er(){}function co(e,t){return t(e),e}function Zm(e,t){return t(e)}function Ze(...e){return e}function qe(e,t){return e(xn,t)}function Ae(e,t){e(lo,t)}function Ws(e){e(Qn)}function ot(e){return e(Al)}function de(e,t){return qe(e,Xm(t,lo))}function qt(e,t){const n=e(xn,r=>{n(),t(r)});return n}function Pl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ol(e,t){return e===t}function Qe(e=Ol){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function be(e){return t=>n=>{e(n)&&t(n)}}function re(e){return t=>_l(t,e)}function Qt(e){return t=>()=>{t(e)}}function B(e,...t){const n=Qm(...t);return(r,o)=>{switch(r){case Qn:Ws(e);return;case xn:return qe(e,n(o))}}}function en(e,t){return n=>r=>{n(t=e(t,r))}}function Pn(e){return t=>n=>{e>0?e--:t(n)}}function fn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function _e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);qe(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Qm(...e){return t=>e.reduceRight(Zm,t)}function eg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case xn:return s?n===s?void 0:(r(),n=s,t=qe(e,s),t):(r(),er);case Qn:r(),n=null;return}}}function K(e){let t=e;const n=Le();return(r,o)=>{switch(r){case lo:t=o;break;case xn:{o(t);break}case Al:return t}return n(r,o)}}function gt(e,t){return co(K(t),n=>de(e,n))}function Le(){const e=[];return(t,n)=>{switch(t){case lo:e.slice().forEach(r=>{r(n)});return;case Qn:e.splice(0,e.length);return;case xn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return co(Le(),t=>de(e,t))}function He(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:tg(),singleton:n}}const tg=()=>Symbol();function ng(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 it(...e){const t=Le(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);qe(s,c=>{n[i]=c,r=r|a,r===o&&Ae(t,n)})}),function(s,i){switch(s){case Qn:{Ws(t);return}case xn:return r===o&&i(n),qe(t,i)}}}function ve(e,t=Ol){return B(e,Qe(t))}function Vs(...e){return function(t,n){switch(t){case Qn:return;case xn:return Jm(...e.map(r=>qe(r,n)))}}}var kt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(kt||{});const rg={0:"debug",3:"error",1:"log",2:"warn"},og=()=>typeof globalThis>"u"?window:globalThis,vn=He(()=>{const e=K(3);return{log:K((t,n,r=1)=>{var o;const s=(o=og().VIRTUOSO_LOG_LEVEL)!=null?o:ot(e);r>=s&&console[rg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function On(e,t,n){return qs(e,t,n).callbackRef}function qs(e,t,n){const r=C.useRef(null);let o=i=>{};const s=C.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 sg(e,t,n,r,o,s,i,a,c){const u=C.useCallback(d=>{const f=ig(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let b;m&&(b=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:m?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?b.innerWidth:b.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Ml("column-gap",getComputedStyle(d).columnGap,o):Ml("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return qs(u,n,c)}function ig(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),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},kt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function Ml(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,kt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Dl(e,t,n){const r=C.useRef(null),o=C.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,h;if(t){const m=t.getBoundingClientRect(),b=u.top-m.top;h=m.height-Math.max(0,b),f=b+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=qs(o,!0,n),a=C.useCallback(()=>{o(i.current)},[o,i]);return C.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const bt=He(()=>{const e=Le(),t=Le(),n=K(0),r=Le(),o=K(0),s=Le(),i=Le(),a=K(0),c=K(0),u=K(0),d=K(0),f=Le(),h=Le(),m=K(!1),b=K(!1),v=K(!1);return de(B(e,re(({scrollTop:g})=>g)),t),de(B(e,re(({scrollHeight:g})=>g)),i),de(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),yr={lvl:0};function Ll(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 Ge(e){return e===yr}function Sr(e,t){if(!Ge(e))return t===e.k?e.v:t<e.k?Sr(e.l,t):Sr(e.r,t)}function Kt(e,t,n="k"){if(Ge(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Kt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Kt(e.l,t,n)}function Rt(e,t,n){return Ge(e)?zl(t,n,1):t===e.k?ct(e,{k:t,v:n}):t<e.k?Bl(ct(e,{l:Rt(e.l,t,n)})):Bl(ct(e,{r:Rt(e.r,t,n)}))}function tr(){return yr}function uo(e,t,n){if(Ge(e))return[];const r=Kt(e,t)[0];return ag(Gs(e,r,n))}function Ks(e,t){if(Ge(e))return yr;const{k:n,l:r,r:o}=e;if(t===n){if(Ge(r))return o;if(Ge(o))return r;{const[s,i]=Fl(r);return fo(ct(e,{k:s,l:$l(r),v:i}))}}else return t<n?fo(ct(e,{l:Ks(r,t)})):fo(ct(e,{r:Ks(o,t)}))}function Mn(e){return Ge(e)?[]:[...Mn(e.l),{k:e.k,v:e.v},...Mn(e.r)]}function Gs(e,t,n){if(Ge(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Gs(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Gs(s,t,n))),a}function fo(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(Ys(t))return Hl(ct(e,{lvl:n-1}));if(!Ge(t)&&!Ge(t.r))return ct(t.r,{l:ct(t,{r:t.r.l}),lvl:n,r:ct(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ys(e))return Xs(ct(e,{lvl:n-1}));if(!Ge(r)&&!Ge(r.l)){const o=r.l,s=Ys(o)?r.lvl-1:r.lvl;return ct(o,{l:ct(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Xs(ct(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ct(e,t){return zl(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 $l(e){return Ge(e.r)?e.l:fo(ct(e,{r:$l(e.r)}))}function Ys(e){return Ge(e)||e.lvl>e.r.lvl}function Fl(e){return Ge(e.r)?[e.k,e.v]:Fl(e.r)}function zl(e,t,n,r=yr,o=yr){return{k:e,l:r,lvl:n,r:o,v:t}}function Bl(e){return Xs(Hl(e))}function Hl(e){const{l:t}=e;return!Ge(t)&&t.lvl===e.lvl?ct(t,{r:ct(e,{l:t.r})}):e}function Xs(e){const{lvl:t,r:n}=e;return!Ge(n)&&!Ge(n.r)&&n.lvl===t&&n.r.lvl===t?ct(n,{l:ct(e,{r:n.l}),lvl:t+1}):e}function ag(e){return Ll(e,({k:t,v:n})=>({index:t,value:n}))}function Ul(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Cr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Js=He(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function Wl(e,t,n){return e[ho(e,t,n)]}function ho(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 lg(e,t,n,r){const o=ho(e,t,r),s=ho(e,n,r,o);return e.slice(o,s+1)}function wn(e,t){return Math.round(e.getBoundingClientRect()[t])}function po(e){return!Ge(e.groupOffsetTree)}function Zs({index:e},t){return t===e?0:t<e?-1:1}function cg(){return{groupIndices:[],groupOffsetTree:tr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:tr()}}function ug(e,t){let n=Ge(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ge(e)){e=Rt(e,0,s);continue}const a=uo(e,i-1,o+1);if(a.some(xg(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=Ks(e,f)):(u=h!==s,c=!0),d>o&&o>=f&&h!==s&&(e=Rt(e,o+1,h));u&&(e=Rt(e,i,s))}return[e,n]}function dg(e){return typeof e.groupIndex<"u"}function fg({offset:e},t){return t===e?0:t<e?-1:1}function Tr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Wl(t,e,Zs),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Vl(e,t){if(!po(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ql(e,t,n){if(dg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Vl(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function hg(e,t,n,r=0){return r>0&&(t=Math.max(t,Wl(e,r,Zs).offset)),Ll(lg(e,t,n,fg),gg)}function pg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,kt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ge(s)&&t.length===2){const h=t[0].size,m=t[1].size;i=n.reduce((b,v)=>Rt(Rt(b,v,h),v+1,m),i)}else[i,a]=ug(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=Qs(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>Rt(h,m,Tr(m,f,o)),tr()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function mg(e){return Mn(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 Kl(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 Qs(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=ho(o,t-1,Zs),a=o[c].offset;const u=Kt(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===Kt(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:u,value:d}of uo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function gg(e){return{index:e.index,value:e}}function xg(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 vg={offsetHeight:"height",offsetWidth:"width"},tn=He(([{log:e},{recalcInProgress:t}])=>{const n=Le(),r=Le(),o=gt(r,0),s=Le(),i=Le(),a=K(0),c=K([]),u=K(void 0),d=K(void 0),f=K((S,T)=>wn(S,vg[T])),h=K(void 0),m=K(0),b=cg(),v=gt(B(n,_e(c,e,m),en(pg,b),Qe()),b),g=gt(B(c,Qe(),en((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),re(({prev:S})=>S)),[]);de(B(c,be(S=>S.length>0),_e(v,m),re(([S,T,I])=>{const N=S.reduce((R,j,A)=>Rt(R,j,Tr(j,T.offsetTree,I)||A),tr());return{...T,groupIndices:S,groupOffsetTree:N}})),v),de(B(r,_e(v),be(([S,{lastIndex:T}])=>S<T),re(([S,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:S}])),n),de(u,d);const x=gt(B(u,re(S=>S===void 0)),!0);de(B(d,be(S=>S!==void 0&&Ge(ot(v).sizeTree)),re(S=>[{endIndex:0,size:S,startIndex:0}])),n);const w=At(B(n,_e(v),en(({sizes:S},[T,I])=>({changed:I!==S,sizes:I}),{changed:!1,sizes:b}),re(S=>S.changed)));qe(B(a,en((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),re(S=>S.diff)),S=>{const{groupIndices:T}=ot(v);if(S>0)Ae(t,!0),Ae(s,S+Kl(S,T));else if(S<0){const I=ot(g);I.length>0&&(S-=Kl(-S,I)),Ae(i,S)}}),qe(B(a,_e(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},kt.ERROR)});const y=At(s);de(B(s,_e(v),re(([S,T])=>{const I=T.groupIndices.length>0,N=[],R=T.lastSize;if(I){const j=Sr(T.sizeTree,0);let A=0,z=0;for(;A<S;){const O=T.groupIndices[z],G=T.groupIndices.length===z+1?1/0:T.groupIndices[z+1]-O-1;N.push({endIndex:O,size:j,startIndex:O}),N.push({endIndex:O+1+G-1,size:R,startIndex:O+1}),z++,A+=G+1}const V=Mn(T.sizeTree);return A!==S&&V.shift(),V.reduce((O,{k:G,v:W})=>{let q=O.ranges;return O.prevSize!==0&&(q=[...O.ranges,{endIndex:G+S-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:G+S,prevSize:W,ranges:q}},{prevIndex:S,prevSize:0,ranges:N}).ranges}return Mn(T.sizeTree).reduce((j,{k:A,v:z})=>({prevIndex:A+S,prevSize:z,ranges:[...j.ranges,{endIndex:A+S-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=At(B(i,_e(v,m),re(([S,{offsetTree:T},I])=>{const N=-S;return Tr(N,T,I)})));return de(B(i,_e(v,m),re(([S,T,I])=>{if(T.groupIndices.length>0){if(Ge(T.sizeTree))return T;let N=tr();const R=ot(g);let j=0,A=0,z=0;for(;j<-S;){z=R[A];const V=R[A+1]-z-1;A++,j+=V+1}if(N=Mn(T.sizeTree).reduce((V,{k:O,v:G})=>Rt(V,Math.max(0,O+S),G),N),j!==-S){const V=Sr(T.sizeTree,z);N=Rt(N,0,V);const O=Kt(T.sizeTree,-S+1)[1];N=Rt(N,1,O)}return{...T,sizeTree:N,...Qs(T.offsetTree,0,N,I)}}else{const N=Mn(T.sizeTree).reduce((R,{k:j,v:A})=>Rt(R,Math.max(0,j+S),A),tr());return{...T,sizeTree:N,...Qs(T.offsetTree,0,N,I)}}})),v),{beforeUnshiftWith:y,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},Ze(vn,Js),{singleton:!0});function wg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Gl=He(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Le(),i=Le(),a=At(B(s,re(wg)));return de(B(a,re(c=>c.totalCount)),n),de(B(a,re(c=>c.groupIndices)),e),de(B(it(o,t,r),be(([c,u])=>po(u)),re(([c,u,d])=>Kt(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),Qe(),re(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Ze(tn,bt)),bn=He(([{log:e}])=>{const t=K(!1),n=At(B(t,be(r=>r),Qe()));return qe(t,r=>{r&&ot(e)("props updated",{},kt.DEBUG)}),{didMount:n,propsReady:t}},Ze(vn),{singleton:!0}),bg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Yl(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!bg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const kr=He(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const m=Le(),b=Le(),v=K(0);let g=null,x=null,w=null;function y(){g&&(g(),g=null),w&&(w(),w=null),x&&(clearTimeout(x),x=null),Ae(c,!1)}return de(B(m,_e(n,f,r,v,a,i,h),_e(e,s,o),re(([[E,S,T,I,N,R,j,A],z,V,O])=>{const G=Yl(E),{align:W,behavior:q,offset:L}=G,M=I-1,le=ql(G,S,M);let Z=Tr(le,S.offsetTree,z)+R;W==="end"?(Z+=V+Kt(S.sizeTree,le)[1]-T+O,le===M&&(Z+=j)):W==="center"?Z+=(V+Kt(S.sizeTree,le)[1]-T+O)/2:Z-=N,L&&(Z+=L);const ee=D=>{y(),D?(A("retrying to scroll to",{location:E},kt.DEBUG),Ae(m,E)):(Ae(b,!0),A("list did not change, scroll successful",{},kt.DEBUG))};if(y(),q==="smooth"){let D=!1;w=qe(t,J=>{D=D||J}),g=qt(d,()=>{ee(D)})}else g=qt(B(t,yg(150)),ee);return x=setTimeout(()=>{y()},1200),Ae(c,!0),A("scrolling from index to",{behavior:q,index:le,top:Z},kt.DEBUG),{behavior:q,top:Z}})),u),{scrollTargetReached:b,scrollToIndex:m,topListHeight:v}},Ze(tn,bt,vn),{singleton:!0});function yg(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ei(e,t){e==0?t():requestAnimationFrame(()=>{ei(e-1,t)})}function ti(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Er=He(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=K(!0),c=K(0),u=K(!0);return de(B(i,_e(c),be(([d,f])=>!!f),Qt(!1)),a),de(B(i,_e(c),be(([d,f])=>!!f),Qt(!1)),u),qe(B(it(t,i),_e(a,n,e,u),be(([[,d],f,{sizeTree:h},m,b])=>d&&(!Ge(h)||Us(m))&&!f&&!b),_e(c)),([,d])=>{qt(o,()=>{Ae(u,!0)}),ei(4,()=>{qt(r,()=>{Ae(a,!0)}),Ae(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Ze(tn,bt,kr,bn),{singleton:!0});function Xl(e,t){return Math.abs(e-t)<1.01}const Ir="up",Nr="down",Sg="none",Cg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Tg=0,Ar=He(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=K(!1),a=K(!0),c=Le(),u=Le(),d=K(4),f=K(Tg),h=gt(B(Vs(B(ve(o),Pn(1),Qt(!0)),B(ve(o),Pn(1),Qt(!1),Pl(100))),Qe()),!1),m=gt(B(Vs(B(n,Qt(!0)),B(n,Qt(!1),Pl(200))),Qe()),!1);de(B(it(ve(o),ve(f)),re(([w,y])=>w<=y),Qe()),a),de(B(a,fn(50)),u);const b=At(B(it(r,ve(s),ve(t),ve(e),ve(d)),en((w,[{scrollHeight:y,scrollTop:E},S,T,I,N])=>{const R=E+S-y>-N,j={scrollHeight:y,scrollTop:E,viewportHeight:S};if(R){let z,V;return E>w.state.scrollTop?(z="SCROLLED_DOWN",V=w.state.scrollTop-E):(z="SIZE_DECREASED",V=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:V,state:j}}let A;return j.scrollHeight>w.state.scrollHeight?A="SIZE_INCREASED":S<w.state.viewportHeight?A="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?A="SCROLLING_UPWARDS":A="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:A,state:j}},Cg),Qe((w,y)=>w&&w.atBottom===y.atBottom))),v=gt(B(r,en((w,{scrollHeight:y,scrollTop:E,viewportHeight:S})=>{if(Xl(w.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:E};{const T=y-(E+S)<1;return w.scrollTop!==E&&T?{changed:!0,jump:w.scrollTop-E,scrollHeight:y,scrollTop:E}:{changed:!0,jump:0,scrollHeight:y,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),be(w=>w.changed),re(w=>w.jump)),0);de(B(b,re(w=>w.atBottom)),i),de(B(i,fn(50)),c);const g=K(Nr);de(B(r,re(({scrollTop:w})=>w),Qe(),en((w,y)=>ot(m)?{direction:w.direction,prevScrollTop:y}:{direction:y<w.prevScrollTop?Ir:Nr,prevScrollTop:y},{direction:Nr,prevScrollTop:0}),re(w=>w.direction)),g),de(B(r,fn(50),Qt(Sg)),g);const x=K(0);return de(B(h,be(w=>!w),Qt(0)),x),de(B(o,fn(100),_e(h),be(([w,y])=>!!y),en(([w,y],[E])=>[y,E],[0,0]),re(([w,y])=>y-w)),x),{atBottomState:b,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},Ze(bt)),mo="top",go="bottom",Jl="none";function Zl(e,t,n){return typeof e=="number"?n===Ir&&t===mo||n===Nr&&t===go?e:0:n===Ir?t===mo?e.main:e.reverse:t===go?e.main:e.reverse}function Ql(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ni=He(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Le(),i=K(0),a=K(0),c=K(0),u=gt(B(it(ve(r),ve(o),ve(n),ve(s,Cr),ve(c),ve(i),ve(t),ve(e),ve(a)),re(([d,f,h,[m,b],v,g,x,w,y])=>{const E=d-w,S=g+x,T=Math.max(h-E,0);let I=Jl;const N=Ql(y,mo),R=Ql(y,go);return m-=w,m+=h+x,b+=h+x,b-=w,m>d+S-N&&(I=Ir),b<d-T+f+R&&(I=Nr),I!==Jl?[Math.max(E-h-Zl(v,mo,I)-N,0),E-T-x+f+Zl(v,go,I)+R]:null}),be(d=>d!=null),Qe(Cr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},Ze(bt),{singleton:!0});function kg(e,t,n){if(po(t)){const r=Vl(e,t);return[{index:Kt(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 ri={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function xo(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*c+(f-1)*r,m=u,b=h-d;return{bottom:d,firstItemIndex:s,items:tc(e,o,s),offsetBottom:b,offsetTop:u,top:m,topItems:tc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function ec(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,c=ti(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return xo(u,[],a,o,n,r)}function tc(e,t,n){if(e.length===0)return[];if(!po(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=uo(t.groupOffsetTree,r,o);let a,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Dn=He(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:m},{recalcInProgress:b}])=>{const v=K([]),g=K(0),x=Le();de(s.topItemsIndexes,v);const w=gt(B(it(m,b,ve(c,Cr),ve(o),ve(r),ve(u),d,ve(v),ve(t),ve(n),e),be(([T,I,,N,,,,,,,R])=>{const j=R&&R.length!==N;return T&&!I&&!j}),re(([,,[T,I],N,R,j,A,z,V,O,G])=>{const W=R,{offsetTree:q,sizeTree:L}=W,M=ot(g);if(N===0)return{...ri,totalCount:N};if(T===0&&I===0)return M===0?{...ri,totalCount:N}:ec(M,j,R,V,O,G||[]);if(Ge(L))return M>0?null:xo(kg(ti(j,N),W,G),[],N,O,W,V);const le=[];if(z.length>0){const ke=z[0],he=z[z.length-1];let $=0;for(const P of uo(L,ke,he)){const H=P.value,Q=Math.max(P.start,ke),ce=Math.min(P.end,he);for(let ie=Q;ie<=ce;ie++)le.push({data:G==null?void 0:G[ie],index:ie,offset:$,size:H}),$+=H}}if(!A)return xo([],le,N,O,W,V);const Z=z.length>0?z[z.length-1]+1:0,ee=hg(q,T,I,Z);if(ee.length===0)return null;const D=N-1,J=co([],ke=>{for(const he of ee){const $=he.value;let P=$.offset,H=he.start;const Q=$.size;if($.offset<T){H+=Math.floor((T-$.offset+O)/(Q+O));const ie=H-he.start;P+=ie*Q+ie*O}H<Z&&(P+=(Z-H)*Q,H=Z);const ce=Math.min(he.end,D);for(let ie=H;ie<=ce&&!(P>=I);ie++)ke.push({data:G==null?void 0:G[ie],index:ie,offset:P,size:Q}),P+=Q+O}});return xo(J,le,N,O,W,V)}),be(T=>T!==null),Qe()),ri);de(B(e,be(Us),re(T=>T==null?void 0:T.length)),o),de(B(w,re(T=>T.topListHeight)),f),de(f,a),de(B(w,re(T=>[T.top,T.bottom])),i),de(B(w,re(T=>T.items)),x);const y=At(B(w,be(({items:T})=>T.length>0),_e(o,e),be(([{items:T},I])=>T[T.length-1].originalIndex===I-1),re(([,T,I])=>[T-1,I]),Qe(Cr),re(([T])=>T))),E=At(B(w,fn(200),be(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),re(({items:T})=>T[0].index),Qe())),S=At(B(w,be(({items:T})=>T.length>0),re(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),Qe(Ul)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:w,rangeChanged:S,startReached:E,topItemsIndexes:v,...h}},Ze(tn,Gl,ni,Er,kr,Ar,bn,Js),{singleton:!0}),nc=He(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Le(),i=gt(B(it(n,e,r,t,o),re(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return de(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},Ze(bt,Dn),{singleton:!0}),Eg=He(([{viewportHeight:e},{totalListHeight:t}])=>{const n=K(!1),r=gt(B(it(n,e,t),be(([o])=>o),re(([,o,s])=>Math.max(0,o-s)),fn(0),Qe()),0);return{alignToBottom:n,paddingTopAddition:r}},Ze(bt,nc),{singleton:!0}),rc=He(()=>({context:K(null)})),Ig=({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,oc=He(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=Le();return de(B(d,_e(t,c,n,s,o,r,a),_e(e),re(([[f,h,m,b,v,g,x,w],y])=>{const{align:E,behavior:S,calculateViewLocation:T=Ig,done:I,...N}=f,R=ql(f,h,b-1),j=Tr(R,h.offsetTree,y)+v+g,A=j+Kt(h.sizeTree,R)[1],z=w+g,V=w+m-x,O=T({itemBottom:A,itemTop:j,locationParams:{align:E,behavior:S,...N},viewportBottom:V,viewportTop:z});return O?I&&qt(B(i,be(G=>!G),Pn(ot(i)?1:2)),I):I&&I(),O}),be(f=>f!==null)),u),{scrollIntoView:d}},Ze(tn,bt,kr,Dn,vn),{singleton:!0});function sc(e){return e?e==="smooth"?"smooth":"auto":!1}const Ng=(e,t)=>typeof e=="function"?sc(e(t)):t&&sc(e),Ag=He(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const b=K(!1),v=Le();let g=null;function x(S){Ae(i,{align:"end",behavior:S,index:"LAST"})}qe(B(it(B(ve(t),Pn(1)),c),_e(ve(b),s,a,f),re(([[S,T],I,N,R,j])=>{let A=T&&R,z="auto";return A&&(z=Ng(I,N||j),A=A&&!!z),{followOutputBehavior:z,shouldFollow:A,totalCount:S}}),be(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{g&&(g(),g=null),ot(n)?requestAnimationFrame(()=>{ot(d)("following output to ",{totalCount:T},kt.DEBUG),x(S)}):g=qt(e,()=>{ot(d)("following output to ",{totalCount:T},kt.DEBUG),x(S),g=null})});function w(S){const T=qt(o,I=>{S&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ot(d)("scrolling to bottom due to increased size",{},kt.DEBUG),x("auto"))});setTimeout(T,100)}qe(B(it(ve(b),t,u),be(([S,,T])=>S&&T),en(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),be(({refreshed:S})=>S),_e(b,t)),([,S])=>{ot(a)&&w(S!==!1)}),qe(v,()=>{w(ot(b)!==!1)}),qe(it(ve(b),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=K(null),E=Le();return de(Vs(B(ve(r),re(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),B(ve(t))),E),qe(B(it(B(E,Pn(1)),c),_e(ve(y),a,f,h),re(([[S,T],I,N,R,j])=>T&&N&&(I==null?void 0:I({context:j,totalCount:S,scrollingInProgress:R}))),be(S=>!!S),fn(0)),S=>{g&&(g(),g=null),ot(n)?requestAnimationFrame(()=>{ot(d)("scrolling into view",{}),Ae(m,S)}):g=qt(e,()=>{ot(d)("scrolling into view",{}),Ae(m,S),g=null})}),{autoscrollToBottom:v,followOutput:b,scrollIntoViewOnChange:y}},Ze(tn,Ar,kr,Er,bn,vn,bt,rc,oc)),Rg=He(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(de(B(a,_e(s),be(([,c])=>c!==0),_e(o,r,t,n,e),re(([[,c],u,d,f,h,m=[]])=>ec(c,u,d,f,h,m))),i),{}),Ze(tn,Er,Dn,bn),{singleton:!0}),_g=He(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=K(0);return qe(B(e,_e(r),be(([,o])=>o!==0),re(([,o])=>({top:o}))),o=>{qt(B(n,Pn(1),be(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ae(t,o)})})}),{initialScrollTop:r}},Ze(bn,bt,Dn),{singleton:!0}),ic=He(([{scrollVelocity:e}])=>{const t=K(!1),n=Le(),r=K(!1);return de(B(e,_e(r,t,n),be(([o,s])=>!!s),re(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),Qe()),t),qe(B(it(t,e,n),_e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Ze(Ar),{singleton:!0}),oi=He(([{scrollContainerState:e,scrollTo:t}])=>{const n=Le(),r=Le(),o=Le(),s=K(!1),i=K(void 0);return de(B(it(n,r),re(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),de(B(t,_e(r),re(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Ze(bt)),jg=He(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=Le(),d=K(void 0),f=K(null),h=K(null);return de(a,f),de(c,h),qe(B(u,_e(t,r,i,f,h,n)),([m,b,v,g,x,w,y])=>{const E=mg(b.sizeTree);g&&x!==null&&w!==null&&(v=x.scrollTop-w.offsetTop),v-=y,m({ranges:E,scrollTop:v})}),de(B(d,be(Us),re(Pg)),o),de(B(s,_e(d),be(([,m])=>m!==void 0),Qe(),re(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},Ze(tn,bt,Er,bn,oi));function Pg(e){return{align:"start",index:0,offset:e.scrollTop}}const Og=He(([{topItemsIndexes:e}])=>{const t=K(0);return de(B(t,be(n=>n>=0),re(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Ze(Dn));function ac(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Mg=ac(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Dg=He(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:b}])=>{const v=At(B(c,_e(i),en(([,x,w,y],[{bottom:E,items:S,offsetBottom:T,totalCount:I},N])=>{const R=E+T;let j=0;return w===I&&x.length>0&&S.length>0&&(S[0].originalIndex===0&&x[0].originalIndex===0||(j=R-y,j!==0&&(j+=N))),[j,S,I,R]},[0,[],0,0]),be(([x])=>x!==0),_e(r,a,n,o,m,b),be(([,x,w,y,,,E])=>!E&&!y&&x!==0&&w===Ir),re(([[x],,,,,w])=>(w("Upward scrolling compensation",{amount:x},kt.DEBUG),x))));function g(x){x>0?(Ae(t,{behavior:"auto",top:-x}),Ae(e,0)):(Ae(e,0),Ae(t,{behavior:"auto",top:-x}))}return qe(B(v,_e(e,s)),([x,w,y])=>{y&&Mg()?Ae(e,w-x):g(-x)}),qe(B(it(gt(s,!1),e,b),be(([x,w,y])=>!x&&!y&&w!==0),re(([x,w])=>w),fn(1)),g),de(B(f,re(x=>({top:-x}))),t),qe(B(u,_e(h,d),re(([x,{groupIndices:w,lastSize:y,sizeTree:E},S])=>{function T(I){return I*(y+S)}if(w.length===0)return T(x);{let I=0;const N=Sr(E,0);let R=0,j=0;for(;R<x;){R++,I+=N;let A=w.length===j+1?1/0:w[j+1]-w[j]-1;R+A>x&&(I-=N,A=x-R+1),R+=A,I+=T(A),j++}return I}})),x=>{Ae(e,x),requestAnimationFrame(()=>{Ae(t,{top:x}),requestAnimationFrame(()=>{Ae(e,0),Ae(b,!1)})})}),{deviation:e}},Ze(bt,Ar,Dn,tn,vn,Js)),Lg=He(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),Ze(ni,Rg,bn,ic,nc,_g,Eg,oi,oc,vn,rc)),lc=He(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b},v,g,x,{listState:w,topItemsIndexes:y,...E},{scrollToIndex:S},T,{topItemCount:I},{groupCounts:N},R])=>(de(E.rangeChanged,R.scrollSeekRangeChanged),de(B(R.windowViewportRect,re(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:w,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:f,...E,...R,...v,sizes:c,...g}),Ze(tn,Er,bt,jg,Ag,Dn,kr,Dg,Og,Gl,Lg));function $g(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 vo=typeof document<"u"?C.useLayoutEffect:C.useEffect;function cc(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=C.createContext({});function c(g,x){g.propsReady&&Ae(g.propsReady,!1);for(const w of r){const y=g[t.required[w]];Ae(y,x[w])}for(const w of o)if(w in x){const y=g[t.optional[w]];Ae(y,x[w])}g.propsReady&&Ae(g.propsReady,!0)}function u(g){return s.reduce((x,w)=>(x[w]=y=>{const E=g[t.methods[w]];Ae(E,y)},x),{})}function d(g){return i.reduce((x,w)=>(x[w]=eg(g[t.events[w]]),x),{})}const f=C.forwardRef((g,x)=>{const{children:w,...y}=g,[E]=C.useState(()=>co(ng(e),I=>{c(I,y)})),[S]=C.useState(jl(d,E));vo(()=>{for(const I of i)I in y&&qe(S[I],y[I]);return()=>{Object.values(S).map(Ws)}},[y,S,E]),vo(()=>{c(E,y)}),C.useImperativeHandle(x,Rl(u(E)));const T=n;return l.jsx(a.Provider,{value:E,children:n?l.jsx(T,{...$g([...r,...o,...i],y),children:w}):w})}),h=g=>{const x=C.useContext(a);return C.useCallback(w=>{Ae(x[g],w)},[x,g])},m=g=>{const x=C.useContext(a)[g],w=C.useCallback(y=>qe(x,y),[x]);return C.useSyncExternalStore(w,()=>ot(x),()=>ot(x))},b=g=>{const x=C.useContext(a)[g],[w,y]=C.useState(jl(ot,x));return vo(()=>qe(x,E=>{E!==w&&y(Rl(E))}),[x,w]),w},v=C.version.startsWith("18")?m:b;return{Component:f,useEmitter:(g,x)=>{const w=C.useContext(a)[g];vo(()=>qe(w,x),[x,w])},useEmitterValue:v,usePublisher:h}}const uc=C.createContext(void 0),dc=C.createContext(void 0),fc=typeof document<"u"?C.useLayoutEffect:C.useEffect;function si(e){return"self"in e}function Fg(e){return"body"in e}function hc(e,t,n,r=er,o,s){const i=C.useRef(null),a=C.useRef(null),c=C.useRef(null),u=C.useCallback(h=>{let m,b,v;const g=h.target;if(Fg(g)||si(g)){const w=si(g)?g:g.defaultView;v=s?w.scrollX:w.scrollY,m=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=s?w.innerWidth:w.innerHeight}else v=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,b=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(v,0),viewportHeight:b})};h.suppressFlushSync?x():Es.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===m-b)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);C.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const b=h.behavior==="smooth";let v,g,x;si(m)?(g=Math.max(wn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),v=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],v=wn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const w=g-v;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),Xl(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),b&&t(!0);return}b?(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}),m.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const ii="-webkit-sticky",pc="sticky",ai=ac(()=>{if(typeof document>"u")return pc;const e=document.createElement("div");return e.style.position=ii,e.style.position===ii?ii:pc});function li(e){return e}const zg=He(()=>{const e=K(a=>`Item ${a}`),t=K(a=>`Group ${a}`),n=K({}),r=K(li),o=K("div"),s=K(er),i=(a,c=null)=>gt(B(n,re(u=>u[a]),Qe()),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")}}),Bg=He(([e,t])=>({...e,...t}),Ze(lc,zg)),Hg=({height:e})=>l.jsx("div",{style:{height:e}}),Ug={overflowAnchor:"none",position:ai(),zIndex:1},mc={overflowAnchor:"none"},Wg={...mc,display:"inline-block",height:"100%"},gc=C.memo(function({showTopList:e=!1}){const t=Te("listState"),n=Lt("sizeRanges"),r=Te("useWindowScroll"),o=Te("customScrollParent"),s=Lt("windowScrollContainerState"),i=Lt("scrollContainerState"),a=o||r?s:i,c=Te("itemContent"),u=Te("context"),d=Te("groupContent"),f=Te("trackItemSizes"),h=Te("itemSize"),m=Te("log"),b=Lt("gap"),v=Te("horizontalDirection"),{callbackRef:g}=sg(n,h,f,e?er:a,m,b,o,v,Te("skipAnimationFrameInResizeObserver")),[x,w]=C.useState(0);ci("deviation",O=>{x!==O&&w(O)});const y=Te("EmptyPlaceholder"),E=Te("ScrollSeekPlaceholder")||Hg,S=Te("ListComponent"),T=Te("ItemComponent"),I=Te("GroupComponent"),N=Te("computeItemKey"),R=Te("isSeeking"),j=Te("groupIndices").length>0,A=Te("alignToBottom"),z=Te("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:A?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:A?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?l.jsx(y,{...xt(y,u)}):l.jsx(S,{...xt(S,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:V,children:(e?t.topItems:t.items).map(O=>{const G=O.originalIndex,W=N(G+t.firstItemIndex,O.data,u);return R?C.createElement(E,{...xt(E,u),height:O.size,index:O.index,key:W,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?C.createElement(I,{...xt(I,u),"data-index":G,"data-item-index":O.index,"data-known-size":O.size,key:W,style:Ug},d(O.index,u)):C.createElement(T,{...xt(T,u),...Gg(T,O.data),"data-index":G,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:W,style:v?Wg:mc},j?c(O.index,O.groupIndex,O.data,u):c(O.index,O.data,u))})})}),Vg={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},qg={outline:"none",overflowX:"auto",position:"relative"},wo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Kg={position:ai(),top:0,width:"100%",zIndex:1};function xt(e,t){if(typeof e!="string")return{context:t}}function Gg(e,t){return{item:typeof e=="string"?void 0:t}}const Yg=C.memo(function(){const e=Te("HeaderComponent"),t=Lt("headerHeight"),n=Te("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null}),Xg=C.memo(function(){const e=Te("FooterComponent"),t=Lt("footerHeight"),n=Te("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null});function xc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:b}=hc(a,u,c,d,void 0,f);return e("scrollTo",b),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?qg:Vg,...o},tabIndex:0,...i,...xt(c,s),children:r})})}function vc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),m=C.useRef(null),b=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=hc(a,u,c,b,h);return fc(()=>{var w;return g.current=h||((w=m.current)==null?void 0:w.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...xt(c,s),children:r})})}const Jg=({children:e})=>{const t=C.useContext(uc),n=Lt("viewportHeight"),r=Lt("fixedItemHeight"),o=Te("alignToBottom"),s=Te("horizontalDirection"),i=C.useMemo(()=>_l(n,c=>wn(c,s?"width":"height")),[n,s]),a=On(i,!0,Te("skipAnimationFrameInResizeObserver"));return C.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:wo(o),children:e})},Zg=({children:e})=>{const t=C.useContext(uc),n=Lt("windowViewportRect"),r=Lt("fixedItemHeight"),o=Te("customScrollParent"),s=Dl(n,o,Te("skipAnimationFrameInResizeObserver")),i=Te("alignToBottom");return C.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:wo(i),children:e})},Qg=({children:e})=>{const t=Te("TopItemListComponent")||"div",n=Te("headerHeight"),r={...Kg,marginTop:`${n}px`},o=Te("context");return l.jsx(t,{style:r,...xt(t,o),children:e})},ex=C.memo(function(e){const t=Te("useWindowScroll"),n=Te("topItemsIndexes").length>0,r=Te("customScrollParent"),o=Te("context");return l.jsxs(r||t?rx:nx,{...e,context:o,children:[n&&l.jsx(Qg,{children:l.jsx(gc,{showTopList:!0})}),l.jsxs(r||t?Zg:Jg,{children:[l.jsx(Yg,{}),l.jsx(gc,{}),l.jsx(Xg,{})]})]})}),{Component:tx,useEmitter:ci,useEmitterValue:Te,usePublisher:Lt}=cc(Bg,{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"}},ex),nx=xc({useEmitter:ci,useEmitterValue:Te,usePublisher:Lt}),rx=vc({useEmitter:ci,useEmitterValue:Te,usePublisher:Lt}),ox=tx;Ze(lc,He(()=>{const e=K(u=>l.jsxs("td",{children:["Item $",u]})),t=K(null),n=K(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=K(null),o=K(null),s=K({}),i=K(li),a=K(er),c=(u,d=null)=>gt(B(s,re(f=>f[u]),Qe()),d);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")}})),ai();const wc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},sx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:bc,floor:bo,max:Rr,min:ui,round:yc}=Math;function Sc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function ix(e){return{...sx,items:e}}function yo(e,t){return e&&e.width===t.width&&e.height===t.height}function ax(e,t){return e&&e.column===t.column&&e.row===t.row}const lx=He(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,m,{didMount:b,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:w,windowScrollTo:y,windowViewportRect:E},S])=>{const T=K(0),I=K(0),N=K(wc),R=K({height:0,width:0}),j=K({height:0,width:0}),A=Le(),z=Le(),V=K(0),O=K(null),G=K({column:0,row:0}),W=Le(),q=Le(),L=K(!1),M=K(0),le=K(!0),Z=K(!1),ee=K(!1);qe(B(b,_e(M),be(([P,H])=>!!H)),()=>{Ae(le,!1)}),qe(B(it(b,le,j,R,M,Z),be(([P,H,Q,ce,,ie])=>P&&!H&&Q.height!==0&&ce.height!==0&&!ie)),([,,,,P])=>{Ae(Z,!0),ei(1,()=>{Ae(A,P)}),qt(B(u),()=>{Ae(t,[0,0]),Ae(le,!0)})}),de(B(q,be(P=>P!=null&&P.scrollTop>0),Qt(0)),I),qe(B(b,_e(q),be(([,P])=>P!=null)),([,P])=>{P&&(Ae(R,P.viewport),Ae(j,P.item),Ae(G,P.gap),P.scrollTop>0&&(Ae(L,!0),qt(B(u,Pn(1)),H=>{Ae(L,!1)}),Ae(c,{top:P.scrollTop})))}),de(B(R,re(({height:P})=>P)),f),de(B(it(ve(R,yo),ve(j,yo),ve(G,(P,H)=>P&&P.column===H.column&&P.row===H.row),ve(u)),re(([P,H,Q,ce])=>({gap:Q,item:H,scrollTop:ce,viewport:P}))),W),de(B(it(ve(T),r,ve(G,ax),ve(j,yo),ve(R,yo),ve(O),ve(I),ve(L),ve(le),ve(M)),be(([,,,,,,,P])=>!P),re(([P,[H,Q],ce,ie,Fe,$e,we,,Ne,Ue])=>{const{column:et,row:Xe}=ce,{height:ut,width:dt}=ie,{width:ue}=Fe;if(we===0&&(P===0||ue===0))return wc;if(dt===0){const nt=ti(Ue,P),Re=nt+Math.max(we-1,0);return ix(Sc(nt,Re,$e))}const fe=Cc(ue,dt,et);let pe,Se;Ne?H===0&&Q===0&&we>0?(pe=0,Se=we-1):(pe=fe*bo((H+Xe)/(ut+Xe)),Se=fe*bc((Q+Xe)/(ut+Xe))-1,Se=ui(P-1,Rr(Se,fe-1)),pe=ui(Se,Rr(0,pe))):(pe=0,Se=-1);const Oe=Sc(pe,Se,$e),{bottom:Ve,top:F}=Tc(Fe,ce,ie,Oe),Y=bc(P/fe),je=Y*ut+(Y-1)*Xe-Ve;return{bottom:Ve,itemHeight:ut,items:Oe,itemWidth:dt,offsetBottom:je,offsetTop:F,top:F}})),N),de(B(O,be(P=>P!==null),re(P=>P.length)),T),de(B(it(R,j,N,G),be(([P,H,{items:Q}])=>Q.length>0&&H.height!==0&&P.height!==0),re(([P,H,{items:Q},ce])=>{const{bottom:ie,top:Fe}=Tc(P,ce,H,Q);return[Fe,ie]}),Qe(Cr)),t);const D=K(!1);de(B(u,_e(D),re(([P,H])=>H||P!==0)),D);const J=At(B(it(N,T),be(([{items:P}])=>P.length>0),_e(D),be(([[P,H],Q])=>{const ce=P.items[P.items.length-1].index===H-1;return(Q||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===H)&&ce}),re(([[,P]])=>P-1),Qe())),ke=At(B(ve(N),be(({items:P})=>P.length>0&&P[0].index===0),Qt(0),Qe())),he=At(B(ve(N),_e(L),be(([{items:P},H])=>P.length>0&&!H),re(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),Qe(Ul),fn(0)));de(he,m.scrollSeekRangeChanged),de(B(A,_e(R,j,T,G),re(([P,H,Q,ce,ie])=>{const Fe=Yl(P),{align:$e,behavior:we,offset:Ne}=Fe;let Ue=Fe.index;Ue==="LAST"&&(Ue=ce-1),Ue=Rr(0,Ue,ui(ce-1,Ue));let et=di(H,ie,Q,Ue);return $e==="end"?et=yc(et-H.height+Q.height):$e==="center"&&(et=yc(et-H.height/2+Q.height/2)),Ne&&(et+=Ne),{behavior:we,top:et}})),c);const $=gt(B(N,re(P=>P.offsetBottom+P.bottom)),0);return de(B(E,re(P=>({height:P.visibleHeight,width:P.visibleWidth}))),R),{customScrollParent:g,data:O,deviation:V,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:q,scrollBy:i,scrollContainerState:a,scrollHeight:z,scrollTo:c,scrollToIndex:A,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:R,windowScrollContainerState:w,windowScrollTo:y,windowViewportRect:E,...m,gridState:N,horizontalDirection:ee,initialTopMostItemIndex:M,totalListHeight:$,...h,endReached:J,propsReady:v,rangeChanged:he,startReached:ke,stateChanged:W,stateRestoreInProgress:L,...S}},Ze(ni,bt,Ar,ic,bn,oi,vn));function Cc(e,t,n){return Rr(1,bo((e+n)/(bo(t)+n)))}function Tc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=di(e,t,n,r[0].index);return{bottom:di(e,t,n,r[r.length-1].index)+o,top:s}}function di(e,t,n,r){const o=Cc(e.width,n.width,t.column),s=bo(r/o),i=s*n.height+Rr(0,s-1)*t.row;return i>0?i+t.row:i}const cx=He(()=>{const e=K(f=>`Item ${f}`),t=K({}),n=K(null),r=K("virtuoso-grid-item"),o=K("virtuoso-grid-list"),s=K(li),i=K("div"),a=K(er),c=(f,h=null)=>gt(B(t,re(m=>m[f]),Qe()),h),u=K(!1),d=K(!1);return de(ve(d),u),{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:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),ux=He(([e,t])=>({...e,...t}),Ze(lx,cx)),dx=C.memo(function(){const e=tt("gridState"),t=tt("listClassName"),n=tt("itemClassName"),r=tt("itemContent"),o=tt("computeItemKey"),s=tt("isSeeking"),i=$t("scrollHeight"),a=tt("ItemComponent"),c=tt("ListComponent"),u=tt("ScrollSeekPlaceholder"),d=tt("context"),f=$t("itemDimensions"),h=$t("gap"),m=tt("log"),b=tt("stateRestoreInProgress"),v=$t("reportReadyState"),g=On(C.useMemo(()=>x=>{const w=x.parentElement.parentElement.scrollHeight;i(w);const y=x.firstChild;if(y){const{height:E,width:S}=y.getBoundingClientRect();f({height:E,width:S})}h({column:Ec("column-gap",getComputedStyle(x).columnGap,m),row:Ec("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,h,m]),!0,!1);return fc(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),b?null:l.jsx(c,{className:t,ref:g,...xt(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const w=o(x.index,x.data,d);return s?l.jsx(u,{...xt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},w):C.createElement(a,{...xt(a,d),className:n,"data-index":x.index,key:w},r(x.index,x.data,d))})})}),fx=C.memo(function(){const e=tt("HeaderComponent"),t=$t("headerHeight"),n=tt("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,!1),o=tt("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null}),hx=C.memo(function(){const e=tt("FooterComponent"),t=$t("footerHeight"),n=tt("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(wn(s,"height"))},[t]),!0,!1),o=tt("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...xt(e,o)})}):null}),px=({children:e})=>{const t=C.useContext(dc),n=$t("itemDimensions"),r=$t("viewportDimensions"),o=On(C.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return C.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:wo(!1),children:e})},mx=({children:e})=>{const t=C.useContext(dc),n=$t("windowViewportRect"),r=$t("itemDimensions"),o=tt("customScrollParent"),s=Dl(n,o,!1);return C.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:wo(!1),children:e})},gx=C.memo(function({...e}){const t=tt("useWindowScroll"),n=tt("customScrollParent"),r=n||t?vx:xx,o=n||t?mx:px,s=tt("context");return l.jsx(r,{...e,...xt(r,s),children:l.jsxs(o,{children:[l.jsx(fx,{}),l.jsx(dx,{}),l.jsx(hx,{})]})})}),{useEmitter:kc,useEmitterValue:tt,usePublisher:$t}=cc(ux,{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"}},gx),xx=xc({useEmitter:kc,useEmitterValue:tt,usePublisher:$t}),vx=vc({useEmitter:kc,useEmitterValue:tt,usePublisher:$t});function Ec(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,kt.WARN),t==="normal"?0:parseInt(t??"0",10)}const wx=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function fi({className:e,variant:t,...n}){return l.jsx("div",{className:X(wx({variant:t}),e),...n})}function ae(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function bx(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,c=p.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function nn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:m,...b}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,g=p.useMemo(()=>b,Object.values(b));return l.jsx(v.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,h){var v;const m=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,b=p.useContext(m);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,yx(o,...t)]}function yx(...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:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var ht=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Sx=p[" useInsertionEffect ".trim().toString()]||ht;function Ln({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Cx({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=p.useCallback(d=>{var f;if(a){const h=Tx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[c,u]}function Cx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Sx(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Tx(e){return typeof e=="function"}function Ic(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function hi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ic(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():Ic(e[o],null)}}}}function Me(...e){return p.useCallback(hi(...e),e)}var kx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=kx.reduce((e,t)=>{const n=An.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Nc(e,t){e&&Gr.flushSync(()=>e.dispatchEvent(t))}function Ex(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var _t=e=>{const{present:t,children:n}=e,r=Ix(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Me(r.ref,Nx(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};_t.displayName="Presence";function Ix(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Ex(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=So(r.current);s.current=a==="mounted"?u:"none"},[a]),ht(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,m=So(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),ht(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const v=So(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(c("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=m=>{m.target===t&&(s.current=So(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function So(e){return(e==null?void 0:e.animationName)||"none"}function Nx(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 Ax=p[" useId ".trim().toString()]||(()=>{}),Rx=0;function rn(e){const[t,n]=p.useState(Ax());return ht(()=>{n(r=>r??String(Rx++))},[e]),e||(t?`radix-${t}`:"")}var Co="Collapsible",[_x,CC]=nn(Co),[jx,pi]=_x(Co),Ac=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=Ln({prop:r,defaultProp:o??!1,onChange:i,caller:Co});return l.jsx(jx,{scope:n,disabled:s,contentId:rn(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:l.jsx(ye.div,{"data-state":gi(c),"data-disabled":s?"":void 0,...a,ref:t})})});Ac.displayName=Co;var Rc="CollapsibleTrigger",_c=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=pi(Rc,n);return l.jsx(ye.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":gi(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ae(e.onClick,o.onOpenToggle)})});_c.displayName=Rc;var mi="CollapsibleContent",Px=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=pi(mi,e.__scopeCollapsible);return l.jsx(_t,{present:n||o.open,children:({present:s})=>l.jsx(Ox,{...r,ref:t,present:s})})});Px.displayName=mi;var Ox=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=pi(mi,n),[a,c]=p.useState(r),u=p.useRef(null),d=Me(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),b=m.current,v=i.open||a,g=p.useRef(v),x=p.useRef(void 0);return p.useEffect(()=>{const w=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(w)},[]),ht(()=>{const w=u.current;if(w){x.current=x.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const y=w.getBoundingClientRect();f.current=y.height,m.current=y.width,g.current||(w.style.transitionDuration=x.current.transitionDuration,w.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(ye.div,{"data-state":gi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:v&&o})});function gi(e){return e?"open":"closed"}var Mx=Ac;const jc=Mx,Pc=_c;function Oc(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let $n=Oc();function Dx(e){$n=e}const Mc=/[&<>"']/,Lx=new RegExp(Mc.source,"g"),Dc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,$x=new RegExp(Dc.source,"g"),Fx={"&":"&","<":"<",">":">",'"':""","'":"'"},Lc=e=>Fx[e];function vt(e,t){if(t){if(Mc.test(e))return e.replace(Lx,Lc)}else if(Dc.test(e))return e.replace($x,Lc);return e}const zx=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function $c(e){return e.replace(zx,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const Bx=/(^|[^\[])\^/g;function Ye(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Bx,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Hx=/[^\w:]/g,Ux=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Fc(e,t,n){if(e){let r;try{r=decodeURIComponent($c(n)).replace(Hx,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Ux.test(n)&&(n=Kx(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const To={},Wx=/^[^:]+:\/*[^/]*$/,Vx=/^([^:]+:)[\s\S]*$/,qx=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Kx(e,t){To[" "+e]||(Wx.test(e)?To[" "+e]=e+"/":To[" "+e]=Eo(e,"/",!0)),e=To[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Vx,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(qx,"$1")+t:e+t}const ko={exec:function(){}};function zc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Eo(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function Gx(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function Yx(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Bc(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Hc(e,t,n,r){const o=t.href,s=t.title?vt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:vt(i)}}function Xx(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
39
39
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
40
40
|
`)}class xi{constructor(t){this.options=t||$n}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Eo(r,`
|
|
41
41
|
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=Xx(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Eo(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,c,u,d,f,h,m,b,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const w=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(b=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
package/package.json
CHANGED