db-studio 1.7.10 → 1.7.11

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.
Files changed (27) hide show
  1. package/dist/core-dist/assets/_pathlessLayout-DtaYfYwJ.js +2 -0
  2. package/dist/core-dist/assets/{_queryId-k0QvsBGf.js → _queryId-BuwY4WmY.js} +1 -1
  3. package/dist/core-dist/assets/{_table-cCBv5kB-.js → _table-D8MYcfMf.js} +1 -1
  4. package/dist/core-dist/assets/_table-dqCYe5jr.js +10 -0
  5. package/dist/core-dist/assets/{cdoe-editor-IGx3GQWB.js → cdoe-editor-DT99U124.js} +1 -1
  6. package/dist/core-dist/assets/{chat-sidebar-D2GaNd69.js → chat-sidebar-_z_c1b34.js} +1 -1
  7. package/dist/core-dist/assets/{dist-v6aWpqmu.js → dist-DZQDOYlI.js} +1 -1
  8. package/dist/core-dist/assets/{dist-ZzQZZhtF.js → dist-lZgQTehN.js} +1 -1
  9. package/dist/core-dist/assets/{index-BtQYs6UF.js → index-D9Wxg2ot.js} +3 -3
  10. package/dist/core-dist/assets/index-fMzwkmHJ.css +2 -0
  11. package/dist/core-dist/assets/{queries.store-BtuppsNj.js → queries.store-D-hvraJW.js} +1 -1
  12. package/dist/core-dist/assets/{runner-VSPg2lHo.js → runner-D2QKCRKR.js} +1 -1
  13. package/dist/core-dist/assets/{runner-tab-BQH-lTnK.js → runner-tab-BgDrAAsO.js} +3 -3
  14. package/dist/core-dist/assets/{scroll-area-BnT9xy-y.js → scroll-area-XVOss7Ty.js} +1 -1
  15. package/dist/core-dist/assets/tanstack-CJpNvQIy.js +9 -0
  16. package/dist/core-dist/assets/{tooltip-B3DXDN3Y.js → tooltip-CFEia1PZ.js} +1 -1
  17. package/dist/core-dist/assets/use-delete-column-B78zy_1_.js +1 -0
  18. package/dist/core-dist/assets/{use-rate-limit-BenJo7Lk.js → use-rate-limit-FcN06qzk.js} +1 -1
  19. package/dist/core-dist/index.html +3 -3
  20. package/dist/index.js +2 -2
  21. package/dist/index.js.map +1 -1
  22. package/package.json +2 -2
  23. package/dist/core-dist/assets/_pathlessLayout-Dh-wnEbU.js +0 -2
  24. package/dist/core-dist/assets/_table-BuJCKd_h.js +0 -10
  25. package/dist/core-dist/assets/index-Dv6o03bL.css +0 -2
  26. package/dist/core-dist/assets/tanstack-DyfKDo5s.js +0 -9
  27. package/dist/core-dist/assets/use-delete-column-B-oY2CU8.js +0 -1
@@ -0,0 +1,9 @@
1
+ import{r as zn,t as $e}from"./rolldown-runtime-Bnw7wDfq.js";import{nt as fs}from"./icons-BywMJ5og.js";import{Dt as Vr,Ot as Br}from"./radix-ui-C0u6gLux.js";var Ne=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},zr={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Hr=class{#t=zr;#e=!1;setTimeoutProvider(e){this.#t=e}setTimeout(e,t){return this.#t.setTimeout(e,t)}clearTimeout(e){this.#t.clearTimeout(e)}setInterval(e,t){return this.#t.setInterval(e,t)}clearInterval(e){this.#t.clearInterval(e)}},Re=new Hr;function Ur(e){setTimeout(e,0)}var Pe=typeof window>"u"||"Deno"in globalThis;function U(){}function jr(e,t){return typeof e=="function"?e(t):e}function Yt(e){return typeof e=="number"&&e>=0&&e!==1/0}function Hn(e,t){return Math.max(e+(t||0)-Date.now(),0)}function he(e,t){return typeof e=="function"?e(t):e}function X(e,t){return typeof e=="function"?e(t):e}function Bs(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:o,stale:a}=e;if(o){if(n){if(t.queryHash!==gs(o,t.options))return!1}else if(!Ye(t.queryKey,o))return!1}if(s!=="all"){const u=t.isActive();if(s==="active"&&!u||s==="inactive"&&u)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||r&&r!==t.state.fetchStatus||i&&!i(t))}function zs(e,t){const{exact:s,status:n,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(s){if(Me(t.options.mutationKey)!==Me(i))return!1}else if(!Ye(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||r&&!r(t))}function gs(e,t){return(t?.queryKeyHashFn||Me)(e)}function Me(e){return JSON.stringify(e,(t,s)=>Xt(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Ye(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>Ye(e[s],t[s])):!1}var Gr=Object.prototype.hasOwnProperty;function Un(e,t,s=0){if(e===t)return e;if(s>500)return t;const n=Hs(e)&&Hs(t);if(!n&&!(Xt(e)&&Xt(t)))return t;const r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),o=i.length,a=n?new Array(o):{};let u=0;for(let l=0;l<o;l++){const h=n?l:i[l],c=e[h],d=t[h];if(c===d){a[h]=c,(n?l<r:Gr.call(e,h))&&u++;continue}if(c===null||d===null||typeof c!="object"||typeof d!="object"){a[h]=d;continue}const f=Un(c,d,s+1);a[h]=f,f===c&&u++}return r===o&&u===r?e:a}function St(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Hs(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Xt(e){if(!Us(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Us(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Us(e){return Object.prototype.toString.call(e)==="[object Object]"}function qr(e){return new Promise(t=>{Re.setTimeout(t,e)})}function Zt(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?Un(e,t):t}function Wr(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function Kr(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var ps=Symbol();function jn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ps?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ms(e,t){return typeof e=="function"?e(...t):!!e}function Qr(e,t,s){let n=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??=t(),n||(n=!0,r.aborted?s():r.addEventListener("abort",s,{once:!0})),r)}),e}var Jr=class extends Ne{#t;#e;#s;constructor(){super(),this.#s=e=>{if(!Pe&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#s=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},vs=new Jr;function es(){let e,t;const s=new Promise((r,i)=>{e=r,t=i});s.status="pending",s.catch(()=>{});function n(r){Object.assign(s,r),delete s.resolve,delete s.reject}return s.resolve=r=>{n({status:"fulfilled",value:r}),e(r)},s.reject=r=>{n({status:"rejected",reason:r}),t(r)},s}function Al(e){return e.state.status==="success"}var Yr=Ur;function Xr(){let e=[],t=0,s=a=>{a()},n=a=>{a()},r=Yr;const i=a=>{t?e.push(a):r(()=>{s(a)})},o=()=>{const a=e;e=[],a.length&&r(()=>{n(()=>{a.forEach(u=>{s(u)})})})};return{batch:a=>{let u;t++;try{u=a()}finally{t--,t||o()}return u},batchCalls:a=>(...u)=>{i(()=>{a(...u)})},schedule:i,setNotifyFunction:a=>{s=a},setBatchNotifyFunction:a=>{n=a},setScheduler:a=>{r=a}}}var $=Xr(),Zr=class extends Ne{#t=!0;#e;#s;constructor(){super(),this.#s=e=>{if(!Pe&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#s=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#t}},yt=new Zr;function ei(e){return Math.min(1e3*2**e,3e4)}function Gn(e){return(e??"online")==="online"?yt.isOnline():!0}var ts=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function qn(e){let t=!1,s=0,n;const r=es(),i=()=>r.status!=="pending",o=p=>{if(!i()){const v=new ts(p);d(v),e.onCancel?.(v)}},a=()=>{t=!0},u=()=>{t=!1},l=()=>vs.isFocused()&&(e.networkMode==="always"||yt.isOnline())&&e.canRun(),h=()=>Gn(e.networkMode)&&e.canRun(),c=p=>{i()||(n?.(),r.resolve(p))},d=p=>{i()||(n?.(),r.reject(p))},f=()=>new Promise(p=>{n=v=>{(i()||l())&&p(v)},e.onPause?.()}).then(()=>{n=void 0,i()||e.onContinue?.()}),g=()=>{if(i())return;let p;const v=s===0?e.initialPromise:void 0;try{p=v??e.fn()}catch(m){p=Promise.reject(m)}Promise.resolve(p).then(c).catch(m=>{if(i())return;const y=e.retry??(Pe?0:3),C=e.retryDelay??ei,S=typeof C=="function"?C(s,m):C,w=y===!0||typeof y=="number"&&s<y||typeof y=="function"&&y(s,m);if(t||!w){d(m);return}s++,e.onFail?.(s,m),qr(S).then(()=>l()?void 0:f()).then(()=>{t?d(m):g()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(n?.(),r),cancelRetry:a,continueRetry:u,canStart:h,start:()=>(h()?g():f().then(g),r)}}var Wn=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Yt(this.gcTime)&&(this.#t=Re.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Pe?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Re.clearTimeout(this.#t),this.#t=void 0)}},ti=class extends Wn{#t;#e;#s;#r;#n;#a;#i;constructor(e){super(),this.#i=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#s=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Gs(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=Gs(this.options);t.data!==void 0&&(this.setState(js(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const s=Zt(this.state.data,e,this.options);return this.#o({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e,t){this.#o({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(U).catch(U):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>X(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ps||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>he(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Hn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#i?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){const a=this.observers.find(u=>u.options.queryFn);a&&this.setOptions(a.options)}const s=new AbortController,n=a=>{Object.defineProperty(a,"signal",{enumerable:!0,get:()=>(this.#i=!0,s.signal)})},r=()=>{const a=jn(this.options,t),l=(()=>{const h={client:this.#r,queryKey:this.queryKey,meta:this.meta};return n(h),h})();return this.#i=!1,this.options.persister?this.options.persister(a,l,this):a(l)},o=(()=>{const a={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:r};return n(a),a})();this.options.behavior?.onFetch(o,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#o({type:"fetch",meta:o.fetchOptions?.meta}),this.#n=qn({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:a=>{a instanceof ts&&a.revert&&this.setState({...this.#e,fetchStatus:"idle"}),s.abort()},onFail:(a,u)=>{this.#o({type:"failed",failureCount:a,error:u})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const a=await this.#n.start();if(a===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(a),this.#s.config.onSuccess?.(a,this),this.#s.config.onSettled?.(a,this.state.error,this),a}catch(a){if(a instanceof ts){if(a.silent)return this.#n.promise;if(a.revert){if(this.state.data===void 0)throw a;return this.state.data}}throw this.#o({type:"error",error:a}),this.#s.config.onError?.(a,this),this.#s.config.onSettled?.(this.state.data,a,this),a}finally{this.scheduleGc()}}#o(e){const t=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Kn(s.data,this.options),fetchMeta:e.meta??null};case"success":const n={...s,...js(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=e.manual?n:void 0,n;case"error":const r=e.error;return{...s,error:r,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),$.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function Kn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Gn(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function js(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Gs(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,n=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var si=class extends Ne{constructor(e,t){super(),this.options=t,this.#t=e,this.#o=null,this.#i=es(),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#s=void 0;#r=void 0;#n;#a;#i;#o;#g;#p;#u;#c;#l;#d;#h=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),qs(this.#e,this.options)?this.#f():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ss(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ss(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#C(),this.#R(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,s=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof X(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),t._defaulted&&!St(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const n=this.hasListeners();n&&Ws(this.#e,s,this.options,t)&&this.#f(),this.updateResult(),n&&(this.#e!==s||X(this.options.enabled,this.#e)!==X(t.enabled,this.#e)||he(this.options.staleTime,this.#e)!==he(t.staleTime,this.#e))&&this.#m();const r=this.#v();n&&(this.#e!==s||X(this.options.enabled,this.#e)!==X(t.enabled,this.#e)||r!==this.#d)&&this.#S(r)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),s=this.createResult(t,e);return ri(this,s)&&(this.#r=s,this.#a=this.options,this.#n=this.#e.state),s}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(s,n)=>(this.trackProp(n),t?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#i.status==="pending"&&this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(e){this.#h.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),s=this.#t.getQueryCache().build(this.#t,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#f({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#f(e){this.#w();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(U)),t}#m(){this.#C();const e=he(this.options.staleTime,this.#e);if(Pe||this.#r.isStale||!Yt(e))return;const t=Hn(this.#r.dataUpdatedAt,e)+1;this.#c=Re.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#S(e){this.#R(),this.#d=e,!(Pe||X(this.options.enabled,this.#e)===!1||!Yt(this.#d)||this.#d===0)&&(this.#l=Re.setInterval(()=>{(this.options.refetchIntervalInBackground||vs.isFocused())&&this.#f()},this.#d))}#y(){this.#m(),this.#S(this.#v())}#C(){this.#c&&(Re.clearTimeout(this.#c),this.#c=void 0)}#R(){this.#l&&(Re.clearInterval(this.#l),this.#l=void 0)}createResult(e,t){const s=this.#e,n=this.options,r=this.#r,i=this.#n,o=this.#a,a=e!==s?e.state:this.#s,{state:u}=e;let l={...u},h=!1,c;if(t._optimisticResults){const _=this.hasListeners(),P=!_&&qs(e,t),b=_&&Ws(e,s,t,n);(P||b)&&(l={...l,...Kn(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:d,errorUpdatedAt:f,status:g}=l;c=l.data;let p=!1;if(t.placeholderData!==void 0&&c===void 0&&g==="pending"){let _;r?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(_=r.data,p=!0):_=typeof t.placeholderData=="function"?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,_!==void 0&&(g="success",c=Zt(r?.data,_,t),h=!0)}if(t.select&&c!==void 0&&!p)if(r&&c===i?.data&&t.select===this.#g)c=this.#p;else try{this.#g=t.select,c=t.select(c),c=Zt(r?.data,c,t),this.#p=c,this.#o=null}catch(_){this.#o=_}this.#o&&(d=this.#o,c=this.#p,f=Date.now(),g="error");const v=l.fetchStatus==="fetching",m=g==="pending",y=g==="error",C=m&&v,S=c!==void 0,w={status:g,fetchStatus:l.fetchStatus,isPending:m,isSuccess:g==="success",isError:y,isInitialLoading:C,isLoading:C,data:c,dataUpdatedAt:l.dataUpdatedAt,error:d,errorUpdatedAt:f,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>a.dataUpdateCount||l.errorUpdateCount>a.errorUpdateCount,isFetching:v,isRefetching:v&&!m,isLoadingError:y&&!S,isPaused:l.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:y&&S,isStale:Ss(e,t),refetch:this.refetch,promise:this.#i,isEnabled:X(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const _=w.data!==void 0,P=w.status==="error"&&!_,b=M=>{P?M.reject(w.error):_&&M.resolve(w.data)},I=()=>{b(this.#i=w.promise=es())},x=this.#i;switch(x.status){case"pending":e.queryHash===s.queryHash&&b(x);break;case"fulfilled":(P||w.data!==x.value)&&I();break;case"rejected":(!P||w.error!==x.reason)&&I();break}}return w}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#n=this.#e.state,this.#a=this.options,this.#n.data!==void 0&&(this.#u=this.#e),St(t,e))return;this.#r=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,r=typeof n=="function"?n():n;if(r==="all"||!r&&!this.#h.size)return!0;const i=new Set(r??this.#h);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(o=>{const a=o;return this.#r[a]!==e[a]&&i.has(a)})};this.#b({listeners:s()})}#w(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#b(e){$.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function ni(e,t){return X(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function qs(e,t){return ni(e,t)||e.state.data!==void 0&&ss(e,t,t.refetchOnMount)}function ss(e,t,s){if(X(t.enabled,e)!==!1&&he(t.staleTime,e)!=="static"){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&Ss(e,t)}return!1}function Ws(e,t,s,n){return(e!==t||X(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&Ss(e,s)}function Ss(e,t){return X(t.enabled,e)!==!1&&e.isStaleByTime(he(t.staleTime,e))}function ri(e,t){return!St(e.getCurrentResult(),t)}function Ks(e){return{onFetch:(t,s)=>{const n=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},u=0;const l=async()=>{let h=!1;const c=g=>{Qr(g,()=>t.signal,()=>h=!0)},d=jn(t.options,t.fetchOptions),f=async(g,p,v)=>{if(h)return Promise.reject();if(p==null&&g.pages.length)return Promise.resolve(g);const y=await d((()=>{const w={client:t.client,queryKey:t.queryKey,pageParam:p,direction:v?"backward":"forward",meta:t.options.meta};return c(w),w})()),{maxPages:C}=t.options,S=v?Kr:Wr;return{pages:S(g.pages,y,C),pageParams:S(g.pageParams,p,C)}};if(r&&i.length){const g=r==="backward",p=g?ii:Qs,v={pages:i,pageParams:o};a=await f(v,p(n,v),g)}else{const g=e??i.length;do{const p=u===0?o[0]??n.initialPageParam:Qs(n,a);if(u>0&&p==null)break;a=await f(a,p),u++}while(u<g)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s):t.fetchFn=l}}}function Qs(e,{pages:t,pageParams:s}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,s[n],s):void 0}function ii(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var oi=class extends Wn{#t;#e;#s;#r;constructor(e){super(),this.#t=e.client,this.mutationId=e.mutationId,this.#s=e.mutationCache,this.#e=[],this.state=e.state||Qn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#n({type:"continue"})},s={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=qn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(i,o)=>{this.#n({type:"failed",failureCount:i,error:o})},onPause:()=>{this.#n({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const n=this.state.status==="pending",r=!this.#r.canStart();try{if(n)t();else{this.#n({type:"pending",variables:e,isPaused:r}),await this.#s.config.onMutate?.(e,this,s);const o=await this.options.onMutate?.(e,s);o!==this.state.context&&this.#n({type:"pending",context:o,variables:e,isPaused:r})}const i=await this.#r.start();return await this.#s.config.onSuccess?.(i,e,this.state.context,this,s),await this.options.onSuccess?.(i,e,this.state.context,s),await this.#s.config.onSettled?.(i,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(i,null,e,this.state.context,s),this.#n({type:"success",data:i}),i}catch(i){try{await this.#s.config.onError?.(i,e,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onError?.(i,e,this.state.context,s)}catch(o){Promise.reject(o)}try{await this.#s.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,i,e,this.state.context,s)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:i}),i}finally{this.#s.runNext(this)}}#n(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),$.batch(()=>{this.#e.forEach(s=>{s.onMutationUpdate(e)}),this.#s.notify({mutation:this,type:"updated",action:e})})}};function Qn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ai=class extends Ne{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#s=0}#t;#e;#s;build(e,t,s){const n=new oi({client:e,mutationCache:this,mutationId:++this.#s,options:e.defaultMutationOptions(t),state:s});return this.add(n),n}add(e){this.#t.add(e);const t=it(e);if(typeof t=="string"){const s=this.#e.get(t);s?s.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=it(e);if(typeof t=="string"){const s=this.#e.get(t);if(s)if(s.length>1){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}else s[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=it(e);if(typeof t=="string"){const s=this.#e.get(t)?.find(n=>n.state.status==="pending");return!s||s===e}else return!0}runNext(e){const t=it(e);return typeof t=="string"?this.#e.get(t)?.find(s=>s!==e&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){$.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(s=>zs(t,s))}findAll(e={}){return this.getAll().filter(t=>zs(e,t))}notify(e){$.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return $.batch(()=>Promise.all(e.map(t=>t.continue().catch(U))))}};function it(e){return e.options.scope?.id}var li=class extends Ne{#t;#e=void 0;#s;#r;constructor(e,t){super(),this.#t=e,this.setOptions(t),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#t.defaultMutationOptions(e),St(this.options,t)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&Me(t.mutationKey)!==Me(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#n(),this.#a(e)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#n(),this.#a()}mutate(e,t){return this.#r=t,this.#s?.removeObserver(this),this.#s=this.#t.getMutationCache().build(this.#t,this.options),this.#s.addObserver(this),this.#s.execute(e)}#n(){const e=this.#s?.state??Qn();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){$.batch(()=>{if(this.#r&&this.hasListeners()){const t=this.#e.variables,s=this.#e.context,n={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#r.onSuccess?.(e.data,t,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(e.data,null,t,s,n)}catch(r){Promise.reject(r)}}else if(e?.type==="error"){try{this.#r.onError?.(e.error,t,s,n)}catch(r){Promise.reject(r)}try{this.#r.onSettled?.(void 0,e.error,t,s,n)}catch(r){Promise.reject(r)}}}this.listeners.forEach(t=>{t(this.#e)})})}},ui=class extends Ne{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,s){const n=t.queryKey,r=t.queryHash??gs(n,t);let i=this.get(r);return i||(i=new ti({client:e,queryKey:n,queryHash:r,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(n)}),this.add(i)),i}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){$.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(s=>Bs(t,s))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(s=>Bs(e,s)):t}notify(e){$.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){$.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){$.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},kl=class{#t;#e;#s;#r;#n;#a;#i;#o;constructor(e={}){this.#t=e.queryCache||new ui,this.#e=e.mutationCache||new ai,this.#s=e.defaultOptions||{},this.#r=new Map,this.#n=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#i=vs.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#o=yt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#i?.(),this.#i=void 0,this.#o?.(),this.#o=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#t.build(this,t),n=s.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(he(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:s})=>[t,s.data])}setQueryData(e,t,s){const n=this.defaultQueryOptions({queryKey:e}),r=this.#t.get(n.queryHash)?.state.data,i=jr(t,r);if(i!==void 0)return this.#t.build(this,n).setData(i,{...s,manual:!0})}setQueriesData(e,t,s){return $.batch(()=>this.#t.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,s)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;$.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#t;return $.batch(()=>(s.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},n=$.batch(()=>this.#t.findAll(e).map(r=>r.cancel(s)));return Promise.all(n).then(U).catch(U)}invalidateQueries(e,t={}){return $.batch(()=>(this.#t.findAll(e).forEach(s=>{s.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},n=$.batch(()=>this.#t.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,s);return s.throwOnError||(i=i.catch(U)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(U)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#t.build(this,t);return s.isStaleByTime(he(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(U).catch(U)}fetchInfiniteQuery(e){return e.behavior=Ks(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(U).catch(U)}ensureInfiniteQueryData(e){return e.behavior=Ks(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return yt.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#s}setDefaultOptions(e){this.#s=e}setQueryDefaults(e,t){this.#r.set(Me(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],s={};return t.forEach(n=>{Ye(e,n.queryKey)&&Object.assign(s,n.defaultOptions)}),s}setMutationDefaults(e,t){this.#n.set(Me(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],s={};return t.forEach(n=>{Ye(e,n.mutationKey)&&Object.assign(s,n.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#s.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=gs(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ps&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#s.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},R=zn(fs(),1),E=Br(),Jn=R.createContext(void 0),Yn=e=>{const t=R.useContext(Jn);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Dl=({client:e,children:t})=>(R.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,E.jsx)(Jn.Provider,{value:e,children:t})),Xn=R.createContext(!1),ci=()=>R.useContext(Xn),$l=Xn.Provider;function di(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var hi=R.createContext(di()),fi=()=>R.useContext(hi),gi=(e,t,s)=>{const n=s?.state.error&&typeof e.throwOnError=="function"?ms(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},pi=e=>{R.useEffect(()=>{e.clearReset()},[e])},mi=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(r&&e.data===void 0||ms(s,[e.error,n])),vi=e=>{if(e.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>s(n(...r)):s(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Si=(e,t)=>e.isLoading&&e.isFetching&&!t,yi=(e,t)=>e?.suspense&&t.isPending,Js=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ci(e,t,s){const n=ci(),r=fi(),i=Yn(s),o=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const a=i.getQueryCache().get(o.queryHash);o._optimisticResults=n?"isRestoring":"optimistic",vi(o),gi(o,r,a),pi(r);const u=!i.getQueryCache().get(o.queryHash),[l]=R.useState(()=>new t(i,o)),h=l.getOptimisticResult(o),c=!n&&e.subscribed!==!1;if(R.useSyncExternalStore(R.useCallback(d=>{const f=c?l.subscribe($.batchCalls(d)):U;return l.updateResult(),f},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),R.useEffect(()=>{l.setOptions(o)},[o,l]),yi(o,h))throw Js(o,l,r);if(mi({result:h,errorResetBoundary:r,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw h.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(o,h),o.experimental_prefetchInRender&&!Pe&&Si(h,n)&&(u?Js(o,l,r):a?.promise)?.catch(U).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?h:l.trackResult(h)}function Nl(e,t){return Ci(e,si,t)}function Vl(e,t){const s=Yn(t),[n]=R.useState(()=>new li(s,e));R.useEffect(()=>{n.setOptions(e)},[n,e]);const r=R.useSyncExternalStore(R.useCallback(o=>n.subscribe($.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=R.useCallback((o,a)=>{n.mutate(o,a).catch(U)},[n]);if(r.error&&ms(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}var Ys=R.use,Qe=typeof window<"u"?R.useLayoutEffect:R.useEffect;function At(e){const t=R.useRef({value:e,prev:null}),s=t.current.value;return e!==s&&(t.current={value:e,prev:s}),t.current.prev}function Ri(e,t,s={},n={}){R.useEffect(()=>{if(!e.current||n.disabled||typeof IntersectionObserver!="function")return;const r=new IntersectionObserver(([i])=>{t(i)},s);return r.observe(e.current),()=>{r.disconnect()}},[t,s,n.disabled,e])}function wi(e){const t=R.useRef(null);return R.useImperativeHandle(e,()=>t.current,[]),t}function Xe(e){return e[e.length-1]}function bi(e){return typeof e=="function"}function ne(e,t){return bi(e)?e(t):e}var Pi=Object.prototype.hasOwnProperty,Xs=Object.prototype.propertyIsEnumerable,Mi=()=>Object.create(null),ye=(e,t)=>le(e,t,Mi);function le(e,t,s=()=>({}),n=0){if(e===t)return e;if(n>500)return t;const r=t,i=tn(e)&&tn(r);if(!i&&!(ke(e)&&ke(r)))return r;const o=i?e:Zs(e);if(!o)return r;const a=i?r:Zs(r);if(!a)return r;const u=o.length,l=a.length,h=i?new Array(l):s();let c=0;for(let d=0;d<l;d++){const f=i?d:a[d],g=e[f],p=r[f];if(g===p){h[f]=g,(i?d<u:Pi.call(e,f))&&c++;continue}if(g===null||p===null||typeof g!="object"||typeof p!="object"){h[f]=p;continue}const v=le(g,p,s,n+1);h[f]=v,v===g&&c++}return u===l&&c===u?e:h}function Zs(e){const t=Object.getOwnPropertyNames(e);for(const r of t)if(!Xs.call(e,r))return!1;const s=Object.getOwnPropertySymbols(e);if(s.length===0)return t;const n=t;for(const r of s){if(!Xs.call(e,r))return!1;n.push(r)}return n}function ke(e){if(!en(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const s=t.prototype;return!(!en(s)||!s.hasOwnProperty("isPrototypeOf"))}function en(e){return Object.prototype.toString.call(e)==="[object Object]"}function tn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function fe(e,t,s){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(!fe(e[n],t[n],s))return!1;return!0}if(ke(e)&&ke(t)){const n=s?.ignoreUndefined??!0;if(s?.partial){for(const o in t)if((!n||t[o]!==void 0)&&!fe(e[o],t[o],s))return!1;return!0}let r=0;if(!n)r=Object.keys(e).length;else for(const o in e)e[o]!==void 0&&r++;let i=0;for(const o in t)if((!n||t[o]!==void 0)&&(i++,i>r||!fe(e[o],t[o],s)))return!1;return r===i}return!1}function De(e){let t,s;const n=new Promise((r,i)=>{t=r,s=i});return n.status="pending",n.resolve=r=>{n.status="resolved",n.value=r,t(r),e?.(r)},n.reject=r=>{n.status="rejected",s(r)},n}function _i(e){return typeof e?.message!="string"?!1:e.message.startsWith("Failed to fetch dynamically imported module")||e.message.startsWith("error loading dynamically imported module")||e.message.startsWith("Importing a module script failed")}function Ze(e){return!!(e&&typeof e=="object"&&typeof e.then=="function")}function Ii(e){return e.replace(/[\x00-\x1f\x7f]/g,"")}function sn(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,s=>{try{return decodeURI(s)}catch{return s}})}return Ii(t)}var xi=["http:","https:","mailto:","tel:"];function Ce(e,t){if(!e)return!1;try{const s=new URL(e);return!t.has(s.protocol)}catch{return!1}}function je(e){if(!e)return{path:e,handledProtocolRelativeURL:!1};if(!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith("//"))return{path:e,handledProtocolRelativeURL:!1};const t=/%25|%5C/gi;let s=0,n="",r;for(;(r=t.exec(e))!==null;)n+=sn(e.slice(s,r.index))+r[0],s=t.lastIndex;n=n+sn(s?e.slice(s):e);let i=!1;return n.startsWith("//")&&(i=!0,n="/"+n.replace(/^\/+/,"")),{path:n,handledProtocolRelativeURL:i}}function Ei(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Li(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function ie(){throw new Error("Invariant failed")}function et(e){const t=new Map;let s,n;const r=i=>{i.next&&(i.prev?(i.prev.next=i.next,i.next.prev=i.prev,i.next=void 0,n&&(n.next=i,i.prev=n)):(i.next.prev=void 0,s=i.next,i.next=void 0,n&&(i.prev=n,n.next=i)),n=i)};return{get(i){const o=t.get(i);if(o)return r(o),o.value},set(i,o){if(t.size>=e&&s){const u=s;t.delete(u.key),u.next&&(s=u.next,u.next.prev=void 0),u===n&&(n=void 0)}const a=t.get(i);if(a)a.value=o,r(a);else{const u={key:i,value:o,prev:n};n&&(n.next=u),n=u,s||(s=u),t.set(i,u)}},clear(){t.clear(),s=void 0,n=void 0}}}var ue=4,Zn=5;function Ti(e){const t=e.indexOf("{");if(t===-1)return null;const s=e.indexOf("}",t);return s===-1||t+1>=e.length?null:[t,s]}function ys(e,t,s=new Uint16Array(6)){const n=e.indexOf("/",t),r=n===-1?e.length:n,i=e.substring(t,r);if(!i||!i.includes("$"))return s[0]=0,s[1]=t,s[2]=t,s[3]=r,s[4]=r,s[5]=r,s;if(i==="$"){const a=e.length;return s[0]=2,s[1]=t,s[2]=t,s[3]=a,s[4]=a,s[5]=a,s}if(i.charCodeAt(0)===36)return s[0]=1,s[1]=t,s[2]=t+1,s[3]=r,s[4]=r,s[5]=r,s;const o=Ti(i);if(o){const[a,u]=o,l=i.charCodeAt(a+1);if(l===45){if(a+2<i.length&&i.charCodeAt(a+2)===36){const h=a+3,c=u;if(h<c)return s[0]=3,s[1]=t+a,s[2]=t+h,s[3]=t+c,s[4]=t+u+1,s[5]=r,s}}else if(l===36){const h=a+1,c=a+2;return c===u?(s[0]=2,s[1]=t+a,s[2]=t+h,s[3]=t+c,s[4]=t+u+1,s[5]=e.length,s):(s[0]=1,s[1]=t+a,s[2]=t+c,s[3]=t+u,s[4]=t+u+1,s[5]=r,s)}}return s[0]=0,s[1]=t,s[2]=t,s[3]=r,s[4]=r,s[5]=r,s}function Pt(e,t,s,n,r,i,o){o?.(s);let a=n;{const u=s.fullPath??s.from,l=u.length,h=s.options?.caseSensitive??e,c=!!(s.options?.params?.parse&&s.options?.skipRouteOnParseError?.params);for(;a<l;){const f=ys(u,a,t);let g;const p=a,v=f[5];switch(a=v+1,i++,f[0]){case 0:{const m=u.substring(f[2],f[3]);if(h){const y=r.static?.get(m);if(y)g=y;else{r.static??=new Map;const C=we(s.fullPath??s.from);C.parent=r,C.depth=i,g=C,r.static.set(m,C)}}else{const y=m.toLowerCase(),C=r.staticInsensitive?.get(y);if(C)g=C;else{r.staticInsensitive??=new Map;const S=we(s.fullPath??s.from);S.parent=r,S.depth=i,g=S,r.staticInsensitive.set(y,S)}}break}case 1:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=h&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,_=!c&&r.dynamic?.find(P=>!P.skipOnParamError&&P.caseSensitive===C&&P.prefix===S&&P.suffix===w);if(_)g=_;else{const P=Dt(1,s.fullPath??s.from,C,S,w);g=P,P.depth=i,P.parent=r,r.dynamic??=[],r.dynamic.push(P)}break}case 3:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=h&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,_=!c&&r.optional?.find(P=>!P.skipOnParamError&&P.caseSensitive===C&&P.prefix===S&&P.suffix===w);if(_)g=_;else{const P=Dt(3,s.fullPath??s.from,C,S,w);g=P,P.parent=r,P.depth=i,r.optional??=[],r.optional.push(P)}break}case 2:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=h&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,_=Dt(2,s.fullPath??s.from,C,S,w);g=_,_.parent=r,_.depth=i,r.wildcard??=[],r.wildcard.push(_)}}r=g}if(c&&s.children&&!s.isRoot&&s.id&&s.id.charCodeAt(s.id.lastIndexOf("/")+1)===95){const f=we(s.fullPath??s.from);f.kind=Zn,f.parent=r,i++,f.depth=i,r.pathless??=[],r.pathless.push(f),r=f}const d=(s.path||!s.children)&&!s.isRoot;if(d&&u.endsWith("/")){const f=we(s.fullPath??s.from);f.kind=ue,f.parent=r,i++,f.depth=i,r.index=f,r=f}r.parse=s.options?.params?.parse??null,r.skipOnParamError=c,r.parsingPriority=s.options?.skipRouteOnParseError?.priority??0,d&&!r.route&&(r.route=s,r.fullPath=s.fullPath??s.from)}if(s.children)for(const u of s.children)Pt(e,t,u,a,r,i,o)}function kt(e,t){if(e.skipOnParamError&&!t.skipOnParamError)return-1;if(!e.skipOnParamError&&t.skipOnParamError)return 1;if(e.skipOnParamError&&t.skipOnParamError&&(e.parsingPriority||t.parsingPriority))return t.parsingPriority-e.parsingPriority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function ae(e){if(e.pathless)for(const t of e.pathless)ae(t);if(e.static)for(const t of e.static.values())ae(t);if(e.staticInsensitive)for(const t of e.staticInsensitive.values())ae(t);if(e.dynamic?.length){e.dynamic.sort(kt);for(const t of e.dynamic)ae(t)}if(e.optional?.length){e.optional.sort(kt);for(const t of e.optional)ae(t)}if(e.wildcard?.length){e.wildcard.sort(kt);for(const t of e.wildcard)ae(t)}}function we(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0}}function Dt(e,t,s,n,r){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0,caseSensitive:s,prefix:n,suffix:r}}function Oi(e,t){const s=we("/"),n=new Uint16Array(6);for(const r of e)Pt(!1,n,r,1,s,0);ae(s),t.masksTree=s,t.flatCache=et(1e3)}function Fi(e,t){e||="/";const s=t.flatCache.get(e);if(s)return s;const n=Cs(e,t.masksTree);return t.flatCache.set(e,n),n}function Ai(e,t,s,n,r){e||="/",n||="/";const i=t?`case\0${e}`:e;let o=r.singleCache.get(i);return o||(o=we("/"),Pt(t,new Uint16Array(6),{from:e},1,o,0),r.singleCache.set(i,o)),Cs(n,o,s)}function ki(e,t,s=!1){const n=s?e:`nofuzz\0${e}`,r=t.matchCache.get(n);if(r!==void 0)return r;e||="/";let i;try{i=Cs(e,t.segmentTree,s)}catch(o){if(o instanceof URIError)i=null;else throw o}return i&&(i.branch=Ni(i.route)),t.matchCache.set(n,i),i}function Di(e){return e==="/"?e:e.replace(/\/{1,}$/,"")}function $i(e,t=!1,s){const n=we(e.fullPath),r=new Uint16Array(6),i={},o={};let a=0;return Pt(t,r,e,1,n,0,u=>{if(s?.(u,a),u.id in i&&ie(),i[u.id]=u,a!==0&&u.path){const l=Di(u.fullPath);(!o[l]||u.fullPath.endsWith("/"))&&(o[l]=u)}a++}),ae(n),{processedTree:{segmentTree:n,singleCache:et(1e3),matchCache:et(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:o}}function Cs(e,t,s=!1){const n=e.split("/"),r=Bi(e,n,t,s);if(!r)return null;const[i]=er(e,n,r);return{route:r.node.route,rawParams:i,parsedParams:r.parsedParams}}function er(e,t,s){const n=Vi(s.node);let r=null;const i=Object.create(null);let o=s.extract?.part??0,a=s.extract?.node??0,u=s.extract?.path??0,l=s.extract?.segment??0;for(;a<n.length;o++,a++,u++,l++){const h=n[a];if(h.kind===ue)break;if(h.kind===Zn){l--,o--,u--;continue}const c=t[o],d=u;if(c&&(u+=c.length),h.kind===1){r??=s.node.fullPath.split("/");const f=r[l],g=h.prefix?.length??0;if(f.charCodeAt(g)===123){const p=h.suffix?.length??0,v=f.substring(g+2,f.length-p-1),m=c.substring(g,c.length-p);i[v]=decodeURIComponent(m)}else{const p=f.substring(1);i[p]=decodeURIComponent(c)}}else if(h.kind===3){if(s.skipped&1<<a){o--,u=d-1;continue}r??=s.node.fullPath.split("/");const f=r[l],g=h.prefix?.length??0,p=h.suffix?.length??0,v=f.substring(g+3,f.length-p-1),m=h.suffix||h.prefix?c.substring(g,c.length-p):c;m&&(i[v]=decodeURIComponent(m))}else if(h.kind===2){const f=h,g=e.substring(d+(f.prefix?.length??0),e.length-(f.suffix?.length??0)),p=decodeURIComponent(g);i["*"]=p,i._splat=p;break}}return s.rawParams&&Object.assign(i,s.rawParams),[i,{part:o,node:a,path:u,segment:l}]}function Ni(e){const t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Vi(e){const t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function Bi(e,t,s,n){if(e==="/"&&s.index)return{node:s.index,skipped:0};const r=!Xe(t),i=r&&e!=="/",o=t.length-(r?1:0),a=[{node:s,index:1,skipped:0,depth:1,statics:0,dynamics:0,optionals:0}];let u=null,l=null;for(;a.length;){const h=a.pop(),{node:c,index:d,skipped:f,depth:g,statics:p,dynamics:v,optionals:m}=h;let{extract:y,rawParams:C,parsedParams:S}=h;if(c.kind===2&&c.route&&!at(l,h))continue;if(c.skipOnParamError){if(!nn(e,t,h))continue;C=h.rawParams,y=h.extract,S=h.parsedParams}n&&c.route&&c.kind!==ue&&at(u,h)&&(u=h);const w=d===o;if(w&&(c.route&&(!i||c.kind===ue||c.kind===2)&&at(l,h)&&(l=h),!c.optional&&!c.wildcard&&!c.index&&!c.pathless))continue;const _=w?void 0:t[d];let P;if(w&&c.index){const b={node:c.index,index:d,skipped:f,depth:g+1,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C,parsedParams:S};let I=!0;if(c.index.skipOnParamError&&(nn(e,t,b)||(I=!1)),I){if(!v&&!m&&!f&&zi(p,o))return b;at(l,b)&&(l=b)}}if(c.wildcard)for(let b=c.wildcard.length-1;b>=0;b--){const I=c.wildcard[b],{prefix:x,suffix:M}=I;if(!(x&&(w||!(I.caseSensitive?_:P??=_.toLowerCase()).startsWith(x)))){if(M){if(w)continue;const A=t.slice(d).join("/").slice(-M.length);if((I.caseSensitive?A:A.toLowerCase())!==M)continue}a.push({node:I,index:o,skipped:f,depth:g+1,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C,parsedParams:S})}}if(c.optional){const b=f|1<<g,I=g+1;for(let x=c.optional.length-1;x>=0;x--){const M=c.optional[x];a.push({node:M,index:d,skipped:b,depth:I,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C,parsedParams:S})}if(!w)for(let x=c.optional.length-1;x>=0;x--){const M=c.optional[x],{prefix:A,suffix:D}=M;if(A||D){const ee=M.caseSensitive?_:P??=_.toLowerCase();if(A&&!ee.startsWith(A)||D&&!ee.endsWith(D))continue}a.push({node:M,index:d+1,skipped:f,depth:I,statics:p,dynamics:v,optionals:m+ot(o,d),extract:y,rawParams:C,parsedParams:S})}}if(!w&&c.dynamic&&_)for(let b=c.dynamic.length-1;b>=0;b--){const I=c.dynamic[b],{prefix:x,suffix:M}=I;if(x||M){const A=I.caseSensitive?_:P??=_.toLowerCase();if(x&&!A.startsWith(x)||M&&!A.endsWith(M))continue}a.push({node:I,index:d+1,skipped:f,depth:g+1,statics:p,dynamics:v+ot(o,d),optionals:m,extract:y,rawParams:C,parsedParams:S})}if(!w&&c.staticInsensitive){const b=c.staticInsensitive.get(P??=_.toLowerCase());b&&a.push({node:b,index:d+1,skipped:f,depth:g+1,statics:p+ot(o,d),dynamics:v,optionals:m,extract:y,rawParams:C,parsedParams:S})}if(!w&&c.static){const b=c.static.get(_);b&&a.push({node:b,index:d+1,skipped:f,depth:g+1,statics:p+ot(o,d),dynamics:v,optionals:m,extract:y,rawParams:C,parsedParams:S})}if(c.pathless){const b=g+1;for(let I=c.pathless.length-1;I>=0;I--){const x=c.pathless[I];a.push({node:x,index:d,skipped:f,depth:b,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C,parsedParams:S})}}}if(l)return l;if(n&&u){let h=u.index;for(let d=0;d<u.index;d++)h+=t[d].length;const c=h===e.length?"/":e.slice(h);return u.rawParams??=Object.create(null),u.rawParams["**"]=decodeURIComponent(c),u}return null}function ot(e,t){return 2**(e-t-1)}function zi(e,t){return e===2**(t-1)-1}function nn(e,t,s){try{const[n,r]=er(e,t,s);s.rawParams=n,s.extract=r;const i=s.node.parse(n);return s.parsedParams=Object.assign(Object.create(null),s.parsedParams,i),!0}catch{return null}}function at(e,t){return e?t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===ue)>(e.node.kind===ue)||t.node.kind===ue==(e.node.kind===ue)&&t.depth>e.depth))):!0}function ft(e){return Rs(e.filter(t=>t!==void 0).join("/"))}function Rs(e){return e.replace(/\/{2,}/g,"/")}function tr(e){return e==="/"?e:e.replace(/^\/{1,}/,"")}function ge(e){const t=e.length;return t>1&&e[t-1]==="/"?e.replace(/\/{1,}$/,""):e}function sr(e){return ge(tr(e))}function Fe(e,t){return e?.endsWith("/")&&e!=="/"&&e!==`${t}/`?e.slice(0,-1):e}function rn(e,t,s){return Fe(e,s)===Fe(t,s)}function Hi({base:e,to:t,trailingSlash:s="never",cache:n}){const r=t.startsWith("/"),i=!r&&t===".";let o;if(n){o=r?t:i?e:e+"\0"+t;const c=n.get(o);if(c)return c}let a;if(i)a=e.split("/");else if(r)a=t.split("/");else{for(a=e.split("/");a.length>1&&Xe(a)==="";)a.pop();const c=t.split("/");for(let d=0,f=c.length;d<f;d++){const g=c[d];g===""?d?d===f-1&&a.push(g):a=[g]:g===".."?a.pop():g==="."||a.push(g)}}a.length>1&&(Xe(a)===""?s==="never"&&a.pop():s==="always"&&a.push(""));let u,l="";for(let c=0;c<a.length;c++){c>0&&(l+="/");const d=a[c];if(!d)continue;u=ys(d,0,u);const f=u[0];if(f===0){l+=d;continue}const g=u[5],p=d.substring(0,u[1]),v=d.substring(u[4],g),m=d.substring(u[2],u[3]);f===1?l+=p||v?`${p}{$${m}}${v}`:`$${m}`:f===2?l+=p||v?`${p}{$}${v}`:"$":l+=`${p}{-$${m}}${v}`}l=Rs(l);const h=l||"/";return o&&n&&n.set(o,h),h}function Ui(e){const t=new Map(e.map(r=>[encodeURIComponent(r),r])),s=Array.from(t.keys()).map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),n=new RegExp(s,"g");return r=>r.replace(n,i=>t.get(i)??i)}function $t(e,t,s){const n=t[e];return typeof n!="string"?n:e==="_splat"?/^[a-zA-Z0-9\-._~!/]*$/.test(n)?n:n.split("/").map(r=>an(r,s)).join("/"):an(n,s)}function on({path:e,params:t,decoder:s,...n}){let r=!1;const i=Object.create(null);if(!e||e==="/")return{interpolatedPath:"/",usedParams:i,isMissingParams:r};if(!e.includes("$"))return{interpolatedPath:e,usedParams:i,isMissingParams:r};const o=e.length;let a=0,u,l="";for(;a<o;){const h=a;u=ys(e,h,u);const c=u[5];if(a=c+1,h===c)continue;const d=u[0];if(d===0){l+="/"+e.substring(h,c);continue}if(d===2){const f=t._splat;i._splat=f,i["*"]=f;const g=e.substring(h,u[1]),p=e.substring(u[4],c);if(!f){r=!0,(g||p)&&(l+="/"+g+p);continue}const v=$t("_splat",t,s);l+="/"+g+v+p;continue}if(d===1){const f=e.substring(u[2],u[3]);!r&&!(f in t)&&(r=!0),i[f]=t[f];const g=e.substring(h,u[1]),p=e.substring(u[4],c),v=$t(f,t,s)??"undefined";l+="/"+g+v+p;continue}if(d===3){const f=e.substring(u[2],u[3]),g=t[f];if(g==null)continue;i[f]=g;const p=e.substring(h,u[1]),v=e.substring(u[4],c),m=$t(f,t,s)??"";l+="/"+p+m+v;continue}}return e.endsWith("/")&&(l+="/"),{usedParams:i,interpolatedPath:l||"/",isMissingParams:r}}function an(e,t){const s=encodeURIComponent(e);return t?.(s)??s}function z(e){return e?.isNotFound===!0}function ji(){try{return typeof window<"u"&&typeof window.sessionStorage=="object"?window.sessionStorage:void 0}catch{return}}var Gi="tsr-scroll-restoration-v1_3";function qi(){const e=ji();if(!e)return null;let t={};try{const n=JSON.parse(e.getItem("tsr-scroll-restoration-v1_3")||"{}");ke(n)&&(t=n)}catch{}return{get state(){return t},set:n=>{t=ne(n,t)||t},persist:()=>{try{e.setItem(Gi,JSON.stringify(t))}catch{}}}}var ln=qi(),Wi=e=>e.state.__TSR_key||e.href;function Ki(e){const t=[];let s;for(;s=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(s.children,e)+1})`),e=s;return`${t.reverse().join(" > ")}`.toLowerCase()}var lt=!1,Ge="window",un="data-scroll-restoration-id";function Qi(e,t){if(!ln)return;const s=ln;if((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isScrollRestorationSetup||!s)return;e.isScrollRestorationSetup=!0,lt=!1;const n=e.options.getScrollRestorationKey||Wi,r=new Map;window.history.scrollRestoration="manual";const i=a=>{if(!(lt||!e.isScrollRestoring))if(a.target===document||a.target===window)r.set(Ge,{scrollX:window.scrollX||0,scrollY:window.scrollY||0});else{const u=a.target;r.set(u,{scrollX:u.scrollLeft||0,scrollY:u.scrollTop||0})}},o=a=>{if(!e.isScrollRestoring||!a||r.size===0||!s)return;const u=s.state[a]||={};for(const[l,h]of r){let c;if(l===Ge)c=Ge;else if(l.isConnected){const d=l.getAttribute(un);c=d?`[${un}="${d}"]`:Ki(l)}c&&(u[c]=h)}};document.addEventListener("scroll",i,!0),e.subscribe("onBeforeLoad",a=>{o(a.fromLocation?n(a.fromLocation):void 0),r.clear()}),window.addEventListener("pagehide",()=>{o(n(e.stores.resolvedLocation.get()??e.stores.location.get())),s.persist()}),e.subscribe("onRendered",a=>{const u=n(a.toLocation),l=e.options.scrollRestorationBehavior,h=e.options.scrollToTopSelectors;if(r.clear(),!e.resetNextScroll){e.resetNextScroll=!0;return}if(!(typeof e.options.scrollRestoration=="function"&&!e.options.scrollRestoration({location:e.latestLocation}))){lt=!0;try{const c=e.isScrollRestoring?s.state[u]:void 0;let d=!1;if(c)for(const f in c){const g=c[f];if(!ke(g))continue;const{scrollX:p,scrollY:v}=g;if(!(!Number.isFinite(p)||!Number.isFinite(v))){if(f===Ge)window.scrollTo({top:v,left:p,behavior:l}),d=!0;else if(f){let m;try{m=document.querySelector(f)}catch{continue}m&&(m.scrollLeft=p,m.scrollTop=v,d=!0)}}}if(!d){const f=e.history.location.hash.slice(1);if(f){const g=window.history.state?.__hashScrollIntoViewOptions??!0;if(g){const p=document.getElementById(f);p&&p.scrollIntoView(g)}}else{const g={top:0,left:0,behavior:l};if(window.scrollTo(g),h)for(const p of h){if(p===Ge)continue;const v=typeof p=="function"?p():document.querySelector(p);v&&v.scrollTo(g)}}}}finally{lt=!1}e.isScrollRestoring&&s.set(c=>(c[u]||={},c))}})}function Ji(e,t=String){const s=new URLSearchParams;for(const n in e){const r=e[n];r!==void 0&&s.set(n,t(r))}return s.toString()}function Nt(e){return e?e==="false"?!1:e==="true"?!0:+e*0===0&&+e+""===e?+e:e:""}function Yi(e){const t=new URLSearchParams(e),s=Object.create(null);for(const[n,r]of t.entries()){const i=s[n];i==null?s[n]=Nt(r):Array.isArray(i)?i.push(Nt(r)):s[n]=[i,Nt(r)]}return s}var Xi=eo(JSON.parse),Zi=to(JSON.stringify,JSON.parse);function eo(e){return t=>{t[0]==="?"&&(t=t.substring(1));const s=Yi(t);for(const n in s){const r=s[n];if(typeof r=="string")try{s[n]=e(r)}catch{}}return s}}function to(e,t){const s=typeof t=="function";function n(r){if(typeof r=="object"&&r!==null)try{return e(r)}catch{}else if(s&&typeof r=="string")try{return t(r),e(r)}catch{}return r}return r=>{const i=Ji(r,n);return i?`?${i}`:""}}var gt="__root__";function so(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href=="string")try{new URL(e.href),e.reloadDocument=!0}catch{}const t=new Headers(e.headers);e.href&&t.get("Location")===null&&t.set("Location",e.href);const s=new Response(null,{status:e.statusCode,headers:t});if(s.options=e,e.throw)throw s;return s}function q(e){return e instanceof Response&&!!e.options}function no(e){return{input:({url:t})=>{for(const s of e)t=ns(s,t);return t},output:({url:t})=>{for(let s=e.length-1;s>=0;s--)t=nr(e[s],t);return t}}}function ro(e){const t=sr(e.basepath),s=`/${t}`,n=`${s}/`,r=e.caseSensitive?s:s.toLowerCase(),i=e.caseSensitive?n:n.toLowerCase();return{input:({url:o})=>{const a=e.caseSensitive?o.pathname:o.pathname.toLowerCase();return a===r?o.pathname="/":a.startsWith(i)&&(o.pathname=o.pathname.slice(s.length)),o},output:({url:o})=>(o.pathname=ft(["/",t,o.pathname]),o)}}function ns(e,t){const s=e?.input?.({url:t});if(s){if(typeof s=="string")return new URL(s);if(s instanceof URL)return s}return t}function nr(e,t){const s=e?.output?.({url:t});if(s){if(typeof s=="string")return new URL(s);if(s instanceof URL)return s}return t}function io(e,t){const{createMutableStore:s,createReadonlyStore:n,batch:r,init:i}=t,o=new Map,a=new Map,u=new Map,l=s(e.status),h=s(e.loadedAt),c=s(e.isLoading),d=s(e.isTransitioning),f=s(e.location),g=s(e.resolvedLocation),p=s(e.statusCode),v=s(e.redirect),m=s([]),y=s([]),C=s([]),S=n(()=>Vt(o,m.get())),w=n(()=>Vt(a,y.get())),_=n(()=>Vt(u,C.get())),P=n(()=>m.get()[0]),b=n(()=>m.get().some(J=>o.get(J)?.get().status==="pending")),I=n(()=>({locationHref:f.get().href,resolvedLocationHref:g.get()?.href,status:l.get()})),x=n(()=>({status:l.get(),loadedAt:h.get(),isLoading:c.get(),isTransitioning:d.get(),matches:S.get(),location:f.get(),resolvedLocation:g.get(),statusCode:p.get(),redirect:v.get()})),M=et(64);function A(J){let Ve=M.get(J);return Ve||(Ve=n(()=>{const xs=m.get();for(const Es of xs){const st=o.get(Es);if(st&&st.routeId===J)return st.get()}}),M.set(J,Ve)),Ve}const D={status:l,loadedAt:h,isLoading:c,isTransitioning:d,location:f,resolvedLocation:g,statusCode:p,redirect:v,matchesId:m,pendingIds:y,cachedIds:C,matches:S,pendingMatches:w,cachedMatches:_,firstId:P,hasPending:b,matchRouteDeps:I,matchStores:o,pendingMatchStores:a,cachedMatchStores:u,__store:x,getRouteMatchStore:A,setMatches:ee,setPending:K,setCached:oe};ee(e.matches),i?.(D);function ee(J){Bt(J,o,m,s,r)}function K(J){Bt(J,a,y,s,r)}function oe(J){Bt(J,u,C,s,r)}return D}function Vt(e,t){const s=[];for(const n of t){const r=e.get(n);r&&s.push(r.get())}return s}function Bt(e,t,s,n,r){const i=e.map(a=>a.id),o=new Set(i);r(()=>{for(const a of t.keys())o.has(a)||t.delete(a);for(const a of e){const u=t.get(a.id);if(!u){const l=n(a);l.routeId=a.routeId,t.set(a.id,l);continue}u.routeId=a.routeId,u.get()!==a&&u.set(a)}Li(s.get(),i)||s.set(i)})}var rs=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},oo=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),Mt=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),be=(e,t,s=!0)=>{const n={...e.router.options.context??{}},r=s?t:t-1;for(let i=0;i<=r;i++){const o=e.matches[i];if(!o)continue;const a=e.router.getMatch(o.id);a&&Object.assign(n,a.__routeContext,a.__beforeLoadContext)}return n},cn=(e,t)=>{if(!e.matches.length)return;const s=t.routeId,n=e.matches.findIndex(o=>o.routeId===e.router.routeTree.id),r=n>=0?n:0;let i=s?e.matches.findIndex(o=>o.routeId===s):e.firstBadMatchIndex??e.matches.length-1;i<0&&(i=r);for(let o=i;o>=0;o--){const a=e.matches[o];if(e.router.looseRoutesById[a.routeId].options.notFoundComponent)return o}return s?i:r},ce=(e,t,s)=>{if(!(!q(s)&&!z(s)))throw q(s)&&s.redirectHandled&&!s.options.reloadDocument||(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=s,e.updateMatch(t.id,n=>({...n,status:q(s)?"redirected":z(s)?"notFound":n.status==="pending"?"success":n.status,context:be(e,t.index),isFetching:!1,error:s})),z(s)&&!s.routeId&&(s.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),q(s)&&(e.rendered=!0,s.options._fromLocation=e.location,s.redirectHandled=!0,s=e.router.resolveRedirect(s))),s},rr=(e,t)=>{const s=e.router.getMatch(t);return!!(!s||s._nonReactive.dehydrated)},dn=(e,t,s)=>{const n=be(e,s);e.updateMatch(t,r=>({...r,context:n}))},qe=(e,t,s,n)=>{const{id:r,routeId:i}=e.matches[t],o=e.router.looseRoutesById[i];if(s instanceof Promise)throw s;s.routerCode=n,e.firstBadMatchIndex??=t,ce(e,e.router.getMatch(r),s);try{o.options.onError?.(s)}catch(a){s=a,ce(e,e.router.getMatch(r),s)}e.updateMatch(r,a=>(a._nonReactive.beforeLoadPromise?.resolve(),a._nonReactive.beforeLoadPromise=void 0,a._nonReactive.loadPromise?.resolve(),{...a,error:s,status:"error",isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!q(s)&&!z(s)&&(e.serialError??=s)};var ir=(e,t,s,n)=>{if(n._nonReactive.pendingTimeout!==void 0)return;const r=s.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!Mt(e,t)&&(s.options.loader||s.options.beforeLoad||ar(s))&&typeof r=="number"&&r!==1/0&&(s.options.pendingComponent??e.router.options?.defaultPendingComponent)){const i=setTimeout(()=>{rs(e)},r);n._nonReactive.pendingTimeout=i}},ao=(e,t,s)=>{const n=e.router.getMatch(t);if(!n._nonReactive.beforeLoadPromise&&!n._nonReactive.loaderPromise)return;ir(e,t,s,n);const r=()=>{const i=e.router.getMatch(t);i.preload&&(i.status==="redirected"||i.status==="notFound")&&ce(e,i,i.error)};return n._nonReactive.beforeLoadPromise?n._nonReactive.beforeLoadPromise.then(r):r()},lo=(e,t,s,n)=>{const r=e.router.getMatch(t);let i=r._nonReactive.loadPromise;r._nonReactive.loadPromise=De(()=>{i?.resolve(),i=void 0});const{paramsError:o,searchError:a}=r;o&&qe(e,s,o,"PARSE_PARAMS"),a&&qe(e,s,a,"VALIDATE_SEARCH"),ir(e,t,n,r);const u=new AbortController;let l=!1;const h=()=>{l||(l=!0,e.updateMatch(t,S=>({...S,isFetching:"beforeLoad",fetchCount:S.fetchCount+1,abortController:u})))},c=()=>{r._nonReactive.beforeLoadPromise?.resolve(),r._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,S=>({...S,isFetching:!1}))};if(!n.options.beforeLoad){e.router.batch(()=>{h(),c()});return}r._nonReactive.beforeLoadPromise=De();const d={...be(e,s,!1),...r.__routeContext},{search:f,params:g,cause:p}=r,v=Mt(e,t),m={search:f,abortController:u,params:g,preload:v,context:d,location:e.location,navigate:S=>e.router.navigate({...S,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:v?"preload":p,matches:e.matches,routeId:n.id,...e.router.options.additionalContext},y=S=>{if(S===void 0){e.router.batch(()=>{h(),c()});return}(q(S)||z(S))&&(h(),qe(e,s,S,"BEFORE_LOAD")),e.router.batch(()=>{h(),e.updateMatch(t,w=>({...w,__beforeLoadContext:S})),c()})};let C;try{if(C=n.options.beforeLoad(m),Ze(C))return h(),C.catch(S=>{qe(e,s,S,"BEFORE_LOAD")}).then(y)}catch(S){h(),qe(e,s,S,"BEFORE_LOAD")}y(C)},uo=(e,t)=>{const{id:s,routeId:n}=e.matches[t],r=e.router.looseRoutesById[n],i=()=>a(),o=()=>lo(e,s,t,r),a=()=>{if(rr(e,s))return;const u=ao(e,s,r);return Ze(u)?u.then(o):o()};return i()},co=(e,t,s)=>{const n=e.router.getMatch(t);if(!n||!s.options.head&&!s.options.scripts&&!s.options.headers)return;const r={ssr:e.router.options.ssr,matches:e.matches,match:n,params:n.params,loaderData:n.loaderData};return Promise.all([s.options.head?.(r),s.options.scripts?.(r),s.options.headers?.(r)]).then(([i,o,a])=>({meta:i?.meta,links:i?.links,headScripts:i?.scripts,headers:a,scripts:o,styles:i?.styles}))},or=(e,t,s,n,r)=>{const i=t[n-1],{params:o,loaderDeps:a,abortController:u,cause:l}=e.router.getMatch(s),h=be(e,n),c=Mt(e,s);return{params:o,deps:a,preload:!!c,parentMatchPromise:i,abortController:u,context:h,location:e.location,navigate:d=>e.router.navigate({...d,_fromLocation:e.location}),cause:c?"preload":l,route:r,...e.router.options.additionalContext}},hn=async(e,t,s,n,r)=>{try{const i=e.router.getMatch(s);try{tt(r);const o=r.options.loader,a=typeof o=="function"?o:o?.handler,u=a?.(or(e,t,s,n,r)),l=!!a&&Ze(u);if((l||r._lazyPromise||r._componentsPromise||r.options.head||r.options.scripts||r.options.headers||i._nonReactive.minPendingPromise)&&e.updateMatch(s,c=>({...c,isFetching:"loader"})),a){const c=l?await u:u;ce(e,e.router.getMatch(s),c),c!==void 0&&e.updateMatch(s,d=>({...d,loaderData:c}))}r._lazyPromise&&await r._lazyPromise;const h=i._nonReactive.minPendingPromise;h&&await h,r._componentsPromise&&await r._componentsPromise,e.updateMatch(s,c=>({...c,error:void 0,context:be(e,n),status:"success",isFetching:!1,updatedAt:Date.now()}))}catch(o){let a=o;if(a?.name==="AbortError"){if(i.abortController.signal.aborted){i._nonReactive.loaderPromise?.resolve(),i._nonReactive.loaderPromise=void 0;return}e.updateMatch(s,l=>({...l,status:l.status==="pending"?"success":l.status,isFetching:!1,context:be(e,n)}));return}const u=i._nonReactive.minPendingPromise;u&&await u,z(o)&&await r.options.notFoundComponent?.preload?.(),ce(e,e.router.getMatch(s),o);try{r.options.onError?.(o)}catch(l){a=l,ce(e,e.router.getMatch(s),l)}!q(a)&&!z(a)&&await tt(r,["errorComponent"]),e.updateMatch(s,l=>({...l,error:a,context:be(e,n),status:"error",isFetching:!1}))}}catch(i){const o=e.router.getMatch(s);o&&(o._nonReactive.loaderPromise=void 0),ce(e,o,i)}},ho=async(e,t,s)=>{async function n(f,g,p,v,m){const y=Date.now()-g.updatedAt,C=f?m.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:m.options.staleTime??e.router.options.defaultStaleTime??0,S=m.options.shouldReload,w=typeof S=="function"?S(or(e,t,r,s,m)):S,{status:_,invalid:P}=v,b=y>=C&&(!!e.forceStaleReload||v.cause==="enter"||p!==void 0&&p!==v.id);o=_==="success"&&(P||(w??b)),f&&m.options.preload===!1||(o&&!e.sync&&h?(a=!0,(async()=>{try{await hn(e,t,r,s,m);const I=e.router.getMatch(r);I._nonReactive.loaderPromise?.resolve(),I._nonReactive.loadPromise?.resolve(),I._nonReactive.loaderPromise=void 0,I._nonReactive.loadPromise=void 0}catch(I){q(I)&&await e.router.navigate(I.options)}})()):_!=="success"||o?await hn(e,t,r,s,m):dn(e,r,s))}const{id:r,routeId:i}=e.matches[s];let o=!1,a=!1;const u=e.router.looseRoutesById[i],l=u.options.loader,h=((typeof l=="function"?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!=="blocking";if(rr(e,r)){if(!e.router.getMatch(r))return e.matches[s];dn(e,r,s)}else{const f=e.router.getMatch(r),g=e.router.stores.matchesId.get()[s],p=(g&&e.router.stores.matchStores.get(g)||null)?.routeId===i?g:e.router.stores.matches.get().find(m=>m.routeId===i)?.id,v=Mt(e,r);if(f._nonReactive.loaderPromise){if(f.status==="success"&&!e.sync&&!f.preload&&h)return f;await f._nonReactive.loaderPromise;const m=e.router.getMatch(r),y=m._nonReactive.error||m.error;y&&ce(e,m,y),m.status==="pending"&&await n(v,f,p,m,u)}else{const m=v&&!e.router.stores.matchStores.has(r),y=e.router.getMatch(r);y._nonReactive.loaderPromise=De(),m!==y.preload&&e.updateMatch(r,C=>({...C,preload:m})),await n(v,f,p,y,u)}}const c=e.router.getMatch(r);a||(c._nonReactive.loaderPromise?.resolve(),c._nonReactive.loadPromise?.resolve(),c._nonReactive.loadPromise=void 0),clearTimeout(c._nonReactive.pendingTimeout),c._nonReactive.pendingTimeout=void 0,a||(c._nonReactive.loaderPromise=void 0),c._nonReactive.dehydrated=void 0;const d=a?c.isFetching:!1;return d!==c.isFetching||c.invalid!==!1?(e.updateMatch(r,f=>({...f,isFetching:d,invalid:!1})),e.router.getMatch(r)):c};async function fn(e){const t=e,s=[];oo(t.router)&&rs(t);let n;for(let d=0;d<t.matches.length;d++){try{const f=uo(t,d);Ze(f)&&await f}catch(f){if(q(f))throw f;if(z(f))n=f;else if(!t.preload)throw f;break}if(t.serialError||t.firstBadMatchIndex!=null)break}const r=t.firstBadMatchIndex??t.matches.length,i=n&&!t.preload?cn(t,n):void 0,o=n&&t.preload?0:i!==void 0?Math.min(i+1,r):r;let a,u;for(let d=0;d<o;d++)s.push(ho(t,s,d));try{await Promise.all(s)}catch{const d=await Promise.allSettled(s);for(const f of d){if(f.status!=="rejected")continue;const g=f.reason;if(q(g))throw g;z(g)?a??=g:u??=g}if(u!==void 0)throw u}const l=a??(n&&!t.preload?n:void 0);let h=t.firstBadMatchIndex!==void 0?t.firstBadMatchIndex:t.matches.length-1;if(!l&&n&&t.preload)return t.matches;if(l){const d=cn(t,l);d===void 0&&ie();const f=t.matches[d],g=t.router.looseRoutesById[f.routeId],p=t.router.options?.defaultNotFoundComponent;!g.options.notFoundComponent&&p&&(g.options.notFoundComponent=p),l.routeId=f.routeId;const v=f.routeId===t.router.routeTree.id;t.updateMatch(f.id,m=>({...m,...v?{status:"success",globalNotFound:!0,error:void 0}:{status:"notFound",error:l},isFetching:!1})),h=d,await tt(g,["notFoundComponent"])}else if(!t.preload){const d=t.matches[0];d.globalNotFound||t.router.getMatch(d.id)?.globalNotFound&&t.updateMatch(d.id,f=>({...f,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){const d=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await tt(d,["errorComponent"])}for(let d=0;d<=h;d++){const{id:f,routeId:g}=t.matches[d],p=t.router.looseRoutesById[g];try{const v=co(t,f,p);if(v){const m=await v;t.updateMatch(f,y=>({...y,...m}))}}catch(v){console.error(`Error executing head for route ${g}:`,v)}}const c=rs(t);if(Ze(c)&&await c,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function gn(e,t){const s=t.map(n=>e.options[n]?.preload?.()).filter(Boolean);if(s.length!==0)return Promise.all(s)}function tt(e,t=pt){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(n=>{const{id:r,...i}=n.options;Object.assign(e.options,i),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);const s=()=>e._componentsLoaded?void 0:t===pt?(()=>{if(e._componentsPromise===void 0){const n=gn(e,pt);n?e._componentsPromise=n.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():gn(e,t);return e._lazyPromise?e._lazyPromise.then(s):s()}function ar(e){for(const t of pt)if(e.options[t]?.preload)return!0;return!1}var pt=["component","errorComponent","pendingComponent","notFoundComponent"],pe="__TSR_index",pn="popstate",mn="beforeunload";function fo(e){let t=e.getLocation();const s=new Set,n=o=>{t=e.getLocation(),s.forEach(a=>a({location:t,action:o}))},r=o=>{e.notifyOnIndexChange??!0?n(o):t=e.getLocation()},i=async({task:o,navigateOpts:a,...u})=>{if(a?.ignoreBlocker??!1){o();return}const l=e.getBlockers?.()??[],h=u.type==="PUSH"||u.type==="REPLACE";if(typeof document<"u"&&l.length&&h)for(const c of l){const d=Ct(u.path,u.state);if(await c.blockerFn({currentLocation:t,nextLocation:d,action:u.type})){e.onBlocked?.();return}}o()};return{get location(){return t},get length(){return e.getLength()},subscribers:s,subscribe:o=>(s.add(o),()=>{s.delete(o)}),push:(o,a,u)=>{const l=t.state[pe];a=vn(l+1,a),i({task:()=>{e.pushState(o,a),n({type:"PUSH"})},navigateOpts:u,type:"PUSH",path:o,state:a})},replace:(o,a,u)=>{const l=t.state[pe];a=vn(l,a),i({task:()=>{e.replaceState(o,a),n({type:"REPLACE"})},navigateOpts:u,type:"REPLACE",path:o,state:a})},go:(o,a)=>{i({task:()=>{e.go(o),r({type:"GO",index:o})},navigateOpts:a,type:"GO"})},back:o=>{i({task:()=>{e.back(o?.ignoreBlocker??!1),r({type:"BACK"})},navigateOpts:o,type:"BACK"})},forward:o=>{i({task:()=>{e.forward(o?.ignoreBlocker??!1),r({type:"FORWARD"})},navigateOpts:o,type:"FORWARD"})},canGoBack:()=>t.state[pe]!==0,createHref:o=>e.createHref(o),block:o=>{if(!e.setBlockers)return()=>{};const a=e.getBlockers?.()??[];return e.setBlockers([...a,o]),()=>{const u=e.getBlockers?.()??[];e.setBlockers?.(u.filter(l=>l!==o))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:n}}function vn(e,t){t||(t={});const s=ws();return{...t,key:s,__TSR_key:s,[pe]:e}}function go(e){const t=e?.window??(typeof document<"u"?window:void 0),s=t.history.pushState,n=t.history.replaceState;let r=[];const i=()=>r,o=b=>r=b,a=e?.createHref??(b=>b),u=e?.parseLocation??(()=>Ct(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){const b=ws();t.history.replaceState({[pe]:0,key:b,__TSR_key:b},"")}let l=u(),h,c=!1,d=!1,f=!1,g=!1;const p=()=>l;let v,m;const y=()=>{v&&(P._ignoreSubscribers=!0,(v.isPush?t.history.pushState:t.history.replaceState)(v.state,"",v.href),P._ignoreSubscribers=!1,v=void 0,m=void 0,h=void 0)},C=(b,I,x)=>{const M=a(I);m||(h=l),l=Ct(I,x),v={href:M,state:x,isPush:v?.isPush||b==="push"},m||(m=Promise.resolve().then(()=>y()))},S=b=>{l=u(),P.notify({type:b})},w=async()=>{if(d){d=!1;return}const b=u(),I=b.state[pe]-l.state[pe],x=I===1,M=I===-1,A=!x&&!M||c;c=!1;const D=A?"GO":M?"BACK":"FORWARD",ee=A?{type:"GO",index:I}:{type:M?"BACK":"FORWARD"};if(f)f=!1;else{const K=i();if(typeof document<"u"&&K.length){for(const oe of K)if(await oe.blockerFn({currentLocation:l,nextLocation:b,action:D})){d=!0,t.history.go(1),P.notify(ee);return}}}l=u(),P.notify(ee)},_=b=>{if(g){g=!1;return}let I=!1;const x=i();if(typeof document<"u"&&x.length)for(const M of x){const A=M.enableBeforeUnload??!0;if(A===!0){I=!0;break}if(typeof A=="function"&&A()===!0){I=!0;break}}if(I)return b.preventDefault(),b.returnValue=""},P=fo({getLocation:p,getLength:()=>t.history.length,pushState:(b,I)=>C("push",b,I),replaceState:(b,I)=>C("replace",b,I),back:b=>(b&&(f=!0),g=!0,t.history.back()),forward:b=>{b&&(f=!0),g=!0,t.history.forward()},go:b=>{c=!0,t.history.go(b)},createHref:b=>a(b),flush:y,destroy:()=>{t.history.pushState=s,t.history.replaceState=n,t.removeEventListener(mn,_,{capture:!0}),t.removeEventListener(pn,w)},onBlocked:()=>{h&&l!==h&&(l=h)},getBlockers:i,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(mn,_,{capture:!0}),t.addEventListener(pn,w),t.history.pushState=function(...b){const I=s.apply(t.history,b);return P._ignoreSubscribers||S("PUSH"),I},t.history.replaceState=function(...b){const I=n.apply(t.history,b);return P._ignoreSubscribers||S("REPLACE"),I},P}function po(e){let t=e.replace(/[\x00-\x1f\x7f]/g,"");return t.startsWith("//")&&(t="/"+t.replace(/^\/+/,"")),t}function Ct(e,t){const s=po(e),n=s.indexOf("#"),r=s.indexOf("?"),i=ws();return{href:s,pathname:s.substring(0,n>0?r>0?Math.min(n,r):n:r>0?r:s.length),hash:n>-1?s.substring(n):"",search:r>-1?s.slice(r,n===-1?void 0:n):"",state:t||{[pe]:0,key:i,__TSR_key:i}}}function ws(){return(Math.random()+1).toString(36).substring(7)}function Ae(e,t){const s=t,n=e;return{fromLocation:s,toLocation:n,pathChanged:s?.pathname!==n.pathname,hrefChanged:s?.href!==n.href,hashChanged:s?.hash!==n.hash}}var mo=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=s=>s(),this.update=s=>{const n=this.options,r=this.basepath??n?.basepath??"/",i=this.basepath===void 0,o=n?.rewrite;if(this.options={...n,...s},this.isServer=this.options.isServer??typeof document>"u",this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=Ui(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=go()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!=="null"?this.origin=window.origin:this.origin="http://localhost"),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let h;this.resolvePathCache=et(1e3),h=this.buildRouteTree(),this.setRoutes(h)}if(!this.stores&&this.latestLocation){const h=this.getStoreConfig(this);this.batch=h.batch,this.stores=io(So(this.latestLocation),h),Qi(this)}let a=!1;const u=this.options.basepath??"/",l=this.options.rewrite;if(i||r!==u||o!==l){this.basepath=u;const h=[],c=sr(u);c&&c!=="/"&&h.push(ro({basepath:u})),l&&h.push(l),this.rewrite=h.length===0?void 0:h.length===1?h[0]:no(h),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.set(this.latestLocation),typeof window<"u"&&"CSS"in window&&typeof window.CSS?.supports=="function"&&(this.isViewTransitionTypesSupported=window.CSS.supports("selector(:active-view-transition-type(a)"))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{const s=$i(this.routeTree,this.options.caseSensitive,(n,r)=>{n.init({originalIndex:r})});return this.options.routeMasks&&Oi(this.options.routeMasks,s.processedTree),s},this.subscribe=(s,n)=>{const r={eventType:s,fn:n};return this.subscribers.add(r),()=>{this.subscribers.delete(r)}},this.emit=s=>{this.subscribers.forEach(n=>{n.eventType===s.type&&n.fn(s)})},this.parseLocation=(s,n)=>{const r=({pathname:u,search:l,hash:h,href:c,state:d})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(u)){const m=this.options.parseSearch(l),y=this.options.stringifySearch(m);return{href:u+y+h,publicHref:u+y+h,pathname:je(u).path,external:!1,searchStr:y,search:ye(n?.search,m),hash:je(h.slice(1)).path,state:le(n?.state,d)}}const f=new URL(c,this.origin),g=ns(this.rewrite,f),p=this.options.parseSearch(g.search),v=this.options.stringifySearch(p);return g.search=v,{href:g.href.replace(g.origin,""),publicHref:c,pathname:je(g.pathname).path,external:!!this.rewrite&&g.origin!==this.origin,searchStr:v,search:ye(n?.search,p),hash:je(g.hash.slice(1)).path,state:le(n?.state,d)}},i=r(s),{__tempLocation:o,__tempKey:a}=i.state;if(o&&(!a||a===this.tempLocationKey)){const u=r(o);return u.state.key=i.state.key,u.state.__TSR_key=i.state.__TSR_key,delete u.state.__tempLocation,{...u,maskedLocation:i}}return i},this.resolvePathWithBase=(s,n)=>Hi({base:s,to:Rs(n),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(s,n,r)=>typeof s=="string"?this.matchRoutesInternal({pathname:s,search:n},r):this.matchRoutesInternal(s,n),this.getMatchedRoutes=s=>yo({pathname:s,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=s=>{const n=this.getMatch(s);n&&(n.abortController.abort(),clearTimeout(n._nonReactive.pendingTimeout),n._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(s=>{this.cancelMatch(s)}),this.stores.matchesId.get().forEach(s=>{if(this.stores.pendingMatchStores.has(s))return;const n=this.stores.matchStores.get(s)?.get();n&&(n.status==="pending"||n.isFetching==="loader")&&this.cancelMatch(s)})},this.buildLocation=s=>{const n=(i={})=>{const o=i._fromLocation||this.pendingBuiltLocation||this.latestLocation,a=this.matchRoutesLightweight(o);i.from;const u=i.unsafeRelative==="path"?o.pathname:i.from??a.fullPath,l=this.resolvePathWithBase(u,"."),h=a.search,c=Object.assign(Object.create(null),a.params),d=i.to?this.resolvePathWithBase(l,`${i.to}`):this.resolvePathWithBase(l,"."),f=i.params===!1||i.params===null?Object.create(null):(i.params??!0)===!0?c:Object.assign(c,ne(i.params,c)),g=this.getMatchedRoutes(d);let p=g.matchedRoutes;if((!g.foundRoute||g.foundRoute.path!=="/"&&g.routeParams["**"])&&this.options.notFoundRoute&&(p=[...p,this.options.notFoundRoute]),Object.keys(f).length>0)for(const x of p){const M=x.options.params?.stringify??x.options.stringifyParams;if(M)try{Object.assign(f,M(f))}catch{}}const v=s.leaveParams?d:je(on({path:d,params:f,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path;let m=h;if(s._includeValidateSearch&&this.options.search?.strict){const x={};p.forEach(M=>{if(M.options.validateSearch)try{Object.assign(x,mt(M.options.validateSearch,{...x,...m}))}catch{}}),m=x}m=Co({search:m,dest:i,destRoutes:p,_includeValidateSearch:s._includeValidateSearch}),m=ye(h,m);const y=this.options.stringifySearch(m),C=i.hash===!0?o.hash:i.hash?ne(i.hash,o.hash):void 0,S=C?`#${C}`:"";let w=i.state===!0?o.state:i.state?ne(i.state,o.state):{};w=le(o.state,w);const _=`${v}${y}${S}`;let P,b,I=!1;if(this.rewrite){const x=new URL(_,this.origin),M=nr(this.rewrite,x);P=x.href.replace(x.origin,""),M.origin!==this.origin?(b=M.href,I=!0):b=M.pathname+M.search+M.hash}else P=Ei(_),b=P;return{publicHref:b,href:P,pathname:v,search:m,searchStr:y,state:w,hash:C??"",external:I,unmaskOnReload:i.unmaskOnReload}},r=(i={},o)=>{const a=n(i);let u=o?n(o):void 0;if(!u){const l=Object.create(null);if(this.options.routeMasks){const h=Fi(a.pathname,this.processedTree);if(h){Object.assign(l,h.rawParams);const{from:c,params:d,...f}=h.route,g=d===!1||d===null?Object.create(null):(d??!0)===!0?l:Object.assign(l,ne(d,l));o={from:s.from,...f,params:g},u=n(o)}}}return u&&(a.maskedLocation=u),a};return s.mask?r(s,{from:s.from,...s.mask}):r(s)},this.commitLocation=async({viewTransition:s,ignoreBlocker:n,...r})=>{const i=()=>{const u=["key","__TSR_key","__TSR_index","__hashScrollIntoViewOptions"];u.forEach(h=>{r.state[h]=this.latestLocation.state[h]});const l=fe(r.state,this.latestLocation.state);return u.forEach(h=>{delete r.state[h]}),l},o=ge(this.latestLocation.href)===ge(r.href);let a=this.commitLocationPromise;if(this.commitLocationPromise=De(()=>{a?.resolve(),a=void 0}),o&&i())this.load();else{let{maskedLocation:u,hashScrollIntoView:l,...h}=r;u&&(h={...u,state:{...u.state,__tempKey:void 0,__tempLocation:{...h,search:h.searchStr,state:{...h.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(h.unmaskOnReload??this.options.unmaskOnReload??!1)&&(h.state.__tempKey=this.tempLocationKey)),h.state.__hashScrollIntoViewOptions=l??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=s,this.history[r.replace?"replace":"push"](h.publicHref,h.state,{ignoreBlocker:n})}return this.resetNextScroll=r.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:s,resetScroll:n,hashScrollIntoView:r,viewTransition:i,ignoreBlocker:o,href:a,...u}={})=>{if(a){const c=this.history.location.state.__TSR_index,d=Ct(a,{__TSR_index:s?c:c+1}),f=new URL(d.pathname,this.origin);u.to=ns(this.rewrite,f).pathname,u.search=this.options.parseSearch(d.search),u.hash=d.hash.slice(1)}const l=this.buildLocation({...u,_includeValidateSearch:!0});this.pendingBuiltLocation=l;const h=this.commitLocation({...l,viewTransition:i,replace:s,resetScroll:n,hashScrollIntoView:r,ignoreBlocker:o});return Promise.resolve().then(()=>{this.pendingBuiltLocation===l&&(this.pendingBuiltLocation=void 0)}),h},this.navigate=async({to:s,reloadDocument:n,href:r,publicHref:i,...o})=>{let a=!1;if(r)try{new URL(`${r}`),a=!0}catch{}if(a&&!n&&(n=!0),n){if(s!==void 0||!r){const l=this.buildLocation({to:s,...o});r=r??l.publicHref,i=i??l.publicHref}const u=!a&&i?i:r;if(Ce(u,this.protocolAllowlist))return Promise.resolve();if(!o.ignoreBlocker){const l=this.history.getBlockers?.()??[];for(const h of l)if(h?.blockerFn&&await h.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:"PUSH"}))return Promise.resolve()}return o.replace?window.location.replace(u):window.location.href=u,Promise.resolve()}return this.buildAndCommitLocation({...o,href:r,to:s,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();const s=this.matchRoutes(this.latestLocation),n=this.stores.cachedMatches.get().filter(r=>!s.some(i=>i.id===r.id));this.batch(()=>{this.stores.status.set("pending"),this.stores.statusCode.set(200),this.stores.isLoading.set(!0),this.stores.location.set(this.latestLocation),this.stores.setPending(s),this.stores.setCached(n)})},this.load=async s=>{let n,r,i;const o=this.stores.resolvedLocation.get()??this.stores.location.get();for(i=new Promise(u=>{this.startTransition(async()=>{try{this.beforeLoad();const l=this.latestLocation,h=Ae(l,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:"onBeforeNavigate",...h}),this.emit({type:"onBeforeLoad",...h}),await fn({router:this,sync:s?.sync,forceStaleReload:o.href===l.href,matches:this.stores.pendingMatches.get(),location:l,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let c=null,d=null,f=null,g=null;this.batch(()=>{const p=this.stores.pendingMatches.get(),v=p.length,m=this.stores.matches.get();c=v?m.filter(S=>!this.stores.pendingMatchStores.has(S.id)):null;const y=new Set;for(const S of this.stores.pendingMatchStores.values())S.routeId&&y.add(S.routeId);const C=new Set;for(const S of this.stores.matchStores.values())S.routeId&&C.add(S.routeId);d=v?m.filter(S=>!y.has(S.routeId)):null,f=v?p.filter(S=>!C.has(S.routeId)):null,g=v?p.filter(S=>C.has(S.routeId)):m,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),v&&(this.stores.setMatches(p),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...c.filter(S=>S.status!=="error"&&S.status!=="notFound"&&S.status!=="redirected")]),this.clearExpiredCache())});for(const[p,v]of[[d,"onLeave"],[f,"onEnter"],[g,"onStay"]])if(p)for(const m of p)this.looseRoutesById[m.routeId].options[v]?.(m)})})}})}catch(l){q(l)?(n=l,this.navigate({...n.options,replace:!0,ignoreBlocker:!0})):z(l)&&(r=l);const h=n?n.status:r?404:this.stores.matches.get().some(c=>c.status==="error")?500:200;this.batch(()=>{this.stores.statusCode.set(h),this.stores.redirect.set(n)})}this.latestLoadPromise===i&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),u()})}),this.latestLoadPromise=i,await i;this.latestLoadPromise&&i!==this.latestLoadPromise;)await this.latestLoadPromise;let a;this.hasNotFoundMatch()?a=404:this.stores.matches.get().some(u=>u.status==="error")&&(a=500),a!==void 0&&this.stores.statusCode.set(a)},this.startViewTransition=s=>{const n=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,n&&typeof document<"u"&&"startViewTransition"in document&&typeof document.startViewTransition=="function"){let r;if(typeof n=="object"&&this.isViewTransitionTypesSupported){const i=this.latestLocation,o=this.stores.resolvedLocation.get(),a=typeof n.types=="function"?n.types(Ae(i,o)):n.types;if(a===!1){s();return}r={update:s,types:a}}else r=s;document.startViewTransition(r)}else s()},this.updateMatch=(s,n)=>{this.startTransition(()=>{const r=this.stores.pendingMatchStores.get(s);if(r){r.set(n);return}const i=this.stores.matchStores.get(s);if(i){i.set(n);return}const o=this.stores.cachedMatchStores.get(s);if(o){const a=n(o.get());a.status==="redirected"?this.stores.cachedMatchStores.delete(s)&&this.stores.cachedIds.set(u=>u.filter(l=>l!==s)):o.set(a)}})},this.getMatch=s=>this.stores.cachedMatchStores.get(s)?.get()??this.stores.pendingMatchStores.get(s)?.get()??this.stores.matchStores.get(s)?.get(),this.invalidate=s=>{const n=r=>s?.filter?.(r)??!0?{...r,invalid:!0,...s?.forcePending||r.status==="error"||r.status==="notFound"?{status:"pending",error:void 0}:void 0}:r;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(n)),this.stores.setCached(this.stores.cachedMatches.get().map(n)),this.stores.setPending(this.stores.pendingMatches.get().map(n))}),this.shouldViewTransition=!1,this.load({sync:s?.sync})},this.getParsedLocationHref=s=>s.publicHref||"/",this.resolveRedirect=s=>{const n=s.headers.get("Location");if(!s.options.href||s.options._builtLocation){const r=s.options._builtLocation??this.buildLocation(s.options),i=this.getParsedLocationHref(r);s.options.href=i,s.headers.set("Location",i)}else if(n)try{const r=new URL(n);if(this.origin&&r.origin===this.origin){const i=r.pathname+r.search+r.hash;s.options.href=i,s.headers.set("Location",i)}}catch{}if(s.options.href&&!s.options._builtLocation&&Ce(s.options.href,this.protocolAllowlist))throw new Error("Redirect blocked: unsafe protocol");return s.headers.get("Location")||s.headers.set("Location",s.options.href),s},this.clearCache=s=>{const n=s?.filter;n!==void 0?this.stores.setCached(this.stores.cachedMatches.get().filter(r=>!n(r))):this.stores.setCached([])},this.clearExpiredCache=()=>{const s=Date.now(),n=r=>{const i=this.looseRoutesById[r.routeId];if(!i.options.loader)return!0;const o=(r.preload?i.options.preloadGcTime??this.options.defaultPreloadGcTime:i.options.gcTime??this.options.defaultGcTime)??300*1e3;return r.status==="error"?!0:s-r.updatedAt>=o};this.clearCache({filter:n})},this.loadRouteChunk=tt,this.preloadRoute=async s=>{const n=s._builtLocation??this.buildLocation(s);let r=this.matchRoutes(n,{throwOnError:!0,preload:!0,dest:s});const i=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),o=new Set([...i,...this.stores.cachedIds.get()]),a=r.filter(u=>!o.has(u.id));if(a.length){const u=this.stores.cachedMatches.get();this.stores.setCached([...u,...a])}try{return r=await fn({router:this,matches:r,location:n,preload:!0,updateMatch:(u,l)=>{i.has(u)?r=r.map(h=>h.id===u?l(h):h):this.updateMatch(u,l)}}),r}catch(u){if(q(u))return u.options.reloadDocument?void 0:await this.preloadRoute({...u.options,_fromLocation:n});z(u)||console.error(u);return}},this.matchRoute=(s,n)=>{const r={...s,to:s.to?this.resolvePathWithBase(s.from||"",s.to):void 0,params:s.params||{},leaveParams:!0},i=this.buildLocation(r);if(n?.pending&&this.stores.status.get()!=="pending")return!1;const o=(n?.pending===void 0?!this.stores.isLoading.get():n.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=Ai(i.pathname,n?.caseSensitive??!1,n?.fuzzy??!1,o.pathname,this.processedTree);return!a||s.params&&!fe(a.rawParams,s.params,{partial:!0})?!1:n?.includeSearch??!0?fe(o.search,i.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(s=>s.status==="notFound"||s.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??"fuzzy",stringifySearch:e.stringifySearch??Zi,parseSearch:e.parseSearch??Xi,protocolAllowlist:e.protocolAllowlist??xi}),typeof document<"u"&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:s}){this.routesById=e,this.routesByPath=t,this.processedTree=s;const n=this.options.notFoundRoute;n&&(n.init({originalIndex:99999999999}),this.routesById[n.id]=n)}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){const s=this.getMatchedRoutes(e.pathname),{foundRoute:n,routeParams:r,parsedParams:i}=s;let{matchedRoutes:o}=s,a=!1;(n?n.path!=="/"&&r["**"]:ge(e.pathname))&&(this.options.notFoundRoute?o=[...o,this.options.notFoundRoute]:a=!0);const u=a?wo(this.options.notFoundMode,o):void 0,l=new Array(o.length),h=new Map;for(const c of this.stores.matchStores.values())c.routeId&&h.set(c.routeId,c.get());for(let c=0;c<o.length;c++){const d=o[c],f=l[c-1];let g,p,v;{const D=f?.search??e.search,ee=f?._strictSearch??void 0;try{const K=mt(d.options.validateSearch,{...D})??void 0;g={...D,...K},p={...ee,...K},v=void 0}catch(K){let oe=K;if(K instanceof Rt||(oe=new Rt(K.message,{cause:K})),t?.throwOnError)throw oe;g=D,p={},v=oe}}const m=d.options.loaderDeps?.({search:g})??"",y=m?JSON.stringify(m):"",{interpolatedPath:C,usedParams:S}=on({path:d.fullPath,params:r,decoder:this.pathParamsDecoder,server:this.isServer}),w=d.id+C+y,_=this.getMatch(w),P=h.get(d.id),b=_?._strictParams??S;let I;if(!_)try{Sn(d,S,i,b)}catch(D){if(z(D)||q(D)?I=D:I=new vo(D.message,{cause:D}),t?.throwOnError)throw I}Object.assign(r,b);const x=P?"stay":"enter";let M;if(_)M={..._,cause:x,params:P?.params??r,_strictParams:b,search:ye(P?P.search:_.search,g),_strictSearch:p};else{const D=d.options.loader||d.options.beforeLoad||d.lazyFn||ar(d)?"pending":"success";M={id:w,ssr:d.options.ssr,index:c,routeId:d.id,params:P?.params??r,_strictParams:b,pathname:C,updatedAt:Date.now(),search:P?ye(P.search,g):g,_strictSearch:p,searchError:void 0,status:D,isFetching:!1,error:void 0,paramsError:I,__routeContext:void 0,_nonReactive:{loadPromise:De()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:x,loaderDeps:P?le(P.loaderDeps,m):m,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:d.options.staticData||{},fullPath:d.fullPath}}t?.preload||(M.globalNotFound=u===d.id),M.searchError=v;const A=this.getParentContext(f);M.context={...A,...M.__routeContext,...M.__beforeLoadContext},l[c]=M}for(let c=0;c<l.length;c++){const d=l[c],f=this.looseRoutesById[d.routeId],g=this.getMatch(d.id),p=h.get(d.routeId);if(d.params=p?ye(p.params,r):r,!g){const v=l[c-1],m=this.getParentContext(v);if(f.options.context){const y={deps:d.loaderDeps,params:d.params,context:m??{},location:e,navigate:C=>this.navigate({...C,_fromLocation:e}),buildLocation:this.buildLocation,cause:d.cause,abortController:d.abortController,preload:!!d.preload,matches:l,routeId:f.id};d.__routeContext=f.options.context(y)??void 0}d.context={...m,...d.__routeContext,...d.__beforeLoadContext}}}return l}matchRoutesLightweight(e){const{matchedRoutes:t,routeParams:s,parsedParams:n}=this.getMatchedRoutes(e.pathname),r=Xe(t),i={...e.search};for(const h of t)try{Object.assign(i,mt(h.options.validateSearch,i))}catch{}const o=Xe(this.stores.matchesId.get()),a=o&&this.stores.matchStores.get(o)?.get(),u=a&&a.routeId===r.id&&a.pathname===e.pathname;let l;if(u)l=a.params;else{const h=Object.assign(Object.create(null),s);for(const c of t)try{Sn(c,s,n??{},h)}catch{}l=h}return{matchedRoutes:t,fullPath:r.fullPath,search:i,params:l}}},Rt=class extends Error{},vo=class extends Error{};function So(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:"idle",resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function mt(e,t){if(e==null)return{};if("~standard"in e){const s=e["~standard"].validate(t);if(s instanceof Promise)throw new Rt("Async validation not supported");if(s.issues)throw new Rt(JSON.stringify(s.issues,void 0,2),{cause:s});return s.value}return"parse"in e?e.parse(t):typeof e=="function"?e(t):{}}function yo({pathname:e,routesById:t,processedTree:s}){const n=Object.create(null),r=ge(e);let i,o;const a=ki(r,s,!0);return a&&(i=a.route,Object.assign(n,a.rawParams),o=Object.assign(Object.create(null),a.parsedParams)),{matchedRoutes:a?.branch||[t.__root__],routeParams:n,foundRoute:i,parsedParams:o}}function Co({search:e,dest:t,destRoutes:s,_includeValidateSearch:n}){return Ro(s)(e,t,n??!1)}function Ro(e){const t={dest:null,_includeValidateSearch:!1,middlewares:[]};for(const r of e){if("search"in r.options)r.options.search?.middlewares&&t.middlewares.push(...r.options.search.middlewares);else if(r.options.preSearchFilters||r.options.postSearchFilters){const i=({search:o,next:a})=>{let u=o;"preSearchFilters"in r.options&&r.options.preSearchFilters&&(u=r.options.preSearchFilters.reduce((h,c)=>c(h),o));const l=a(u);return"postSearchFilters"in r.options&&r.options.postSearchFilters?r.options.postSearchFilters.reduce((h,c)=>c(h),l):l};t.middlewares.push(i)}if(r.options.validateSearch){const i=({search:o,next:a})=>{const u=a(o);if(!t._includeValidateSearch)return u;try{return{...u,...mt(r.options.validateSearch,u)??void 0}}catch{return u}};t.middlewares.push(i)}}const s=({search:r})=>{const i=t.dest;return i.search?i.search===!0?r:ne(i.search,r):{}};t.middlewares.push(s);const n=(r,i,o)=>{if(r>=o.length)return i;const a=o[r];return a({search:i,next:l=>n(r+1,l,o)})};return function(i,o,a){return t.dest=o,t._includeValidateSearch=a,n(0,i,t.middlewares)}}function wo(e,t){if(e!=="root")for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.children)return n.id}return gt}function Sn(e,t,s,n){const r=e.options.params?.parse??e.options.parseParams;if(r)if(e.options.skipRouteOnParseError)for(const i in t)i in s&&(n[i]=s[i]);else{const i=r(n);Object.assign(n,i)}}var bo="Error preloading route! ☝️",lr=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=t=>{this.originalIndex=t.originalIndex;const s=this.options,n=!s?.path&&!s?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=gt:this.parentRoute||ie();let r=n?gt:s?.path;r&&r!=="/"&&(r=tr(r));const i=s?.id||r;let o=n?gt:ft([this.parentRoute.id==="__root__"?"":this.parentRoute.id,i]);r==="__root__"&&(r="/"),o!=="__root__"&&(o=ft(["/",o]));const a=o==="__root__"?"/":ft([this.parentRoute.fullPath,r]);this._path=r,this._id=o,this._fullPath=a,this._to=ge(a)},this.addChildren=t=>this._addFileChildren(t),this._addFileChildren=t=>(Array.isArray(t)&&(this.children=t),typeof t=="object"&&t!==null&&(this.children=Object.values(t)),this),this._addFileTypes=()=>this,this.updateLoader=t=>(Object.assign(this.options,t),this),this.update=t=>(Object.assign(this.options,t),this),this.lazy=t=>(this.lazyFn=t,this),this.redirect=t=>so({from:this.fullPath,...t}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw new Error("Route cannot have both an 'id' and a 'path' option.")}},Po=class extends lr{constructor(e){super(e)}};function Mo(e){if(typeof document<"u"&&document.querySelector){const t=e.stores.location.get(),s=t.state.__hashScrollIntoViewOptions??!0;if(s&&t.hash!==""){const n=document.getElementById(t.hash);n&&n.scrollIntoView(s)}}}function bs(e){const t=e.errorComponent??Ps;return(0,E.jsx)(_o,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:s,reset:n})=>s?R.createElement(t,{error:s,reset:n}):e.children})}var _o=class extends R.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){const s=e.getResetKey();return t.error&&t.resetKey!==s?{resetKey:s,error:null}:{resetKey:s}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.error,reset:()=>{this.reset()}})}};function Ps({error:e}){const[t,s]=R.useState(!1);return(0,E.jsxs)("div",{style:{padding:".5rem",maxWidth:"100%"},children:[(0,E.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:".5rem"},children:[(0,E.jsx)("strong",{style:{fontSize:"1rem"},children:"Something went wrong!"}),(0,E.jsx)("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>s(n=>!n),children:t?"Hide Error":"Show Error"})]}),(0,E.jsx)("div",{style:{height:".25rem"}}),t?(0,E.jsx)("div",{children:(0,E.jsx)("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"},children:e.message?(0,E.jsx)("code",{children:e.message}):null})}):null]})}function Io({children:e,fallback:t=null}){return ur()?(0,E.jsx)(R.Fragment,{children:e}):(0,E.jsx)(R.Fragment,{children:t})}function ur(){return R.useSyncExternalStore(xo,()=>!0,()=>!1)}function xo(){return()=>{}}var cr=R.createContext(null);function Z(e){return R.useContext(cr)}var _t=R.createContext(void 0),Eo=R.createContext(void 0),k=(e=>(e[e.None=0]="None",e[e.Mutable=1]="Mutable",e[e.Watching=2]="Watching",e[e.RecursedCheck=4]="RecursedCheck",e[e.Recursed=8]="Recursed",e[e.Dirty=16]="Dirty",e[e.Pending=32]="Pending",e))(k||{});function Lo({update:e,notify:t,unwatched:s}){return{link:n,unlink:r,propagate:i,checkDirty:o,shallowPropagate:a};function n(l,h,c){const d=h.depsTail;if(d!==void 0&&d.dep===l)return;const f=d!==void 0?d.nextDep:h.deps;if(f!==void 0&&f.dep===l){f.version=c,h.depsTail=f;return}const g=l.subsTail;if(g!==void 0&&g.version===c&&g.sub===h)return;const p=h.depsTail=l.subsTail={version:c,dep:l,sub:h,prevDep:d,nextDep:f,prevSub:g,nextSub:void 0};f!==void 0&&(f.prevDep=p),d!==void 0?d.nextDep=p:h.deps=p,g!==void 0?g.nextSub=p:l.subs=p}function r(l,h=l.sub){const c=l.dep,d=l.prevDep,f=l.nextDep,g=l.nextSub,p=l.prevSub;return f!==void 0?f.prevDep=d:h.depsTail=d,d!==void 0?d.nextDep=f:h.deps=f,g!==void 0?g.prevSub=p:c.subsTail=p,p!==void 0?p.nextSub=g:(c.subs=g)===void 0&&s(c),f}function i(l){let h=l.nextSub,c;e:do{const d=l.sub;let f=d.flags;if(f&60?f&12?f&4?!(f&48)&&u(l,d)?(d.flags=f|40,f&=1):f=0:d.flags=f&-9|32:f=0:d.flags=f|32,f&2&&t(d),f&1){const g=d.subs;if(g!==void 0){const p=(l=g).nextSub;p!==void 0&&(c={value:h,prev:c},h=p);continue}}if((l=h)!==void 0){h=l.nextSub;continue}for(;c!==void 0;)if(l=c.value,c=c.prev,l!==void 0){h=l.nextSub;continue e}break}while(!0)}function o(l,h){let c,d=0,f=!1;e:do{const g=l.dep,p=g.flags;if(h.flags&16)f=!0;else if((p&17)===17){if(e(g)){const v=g.subs;v.nextSub!==void 0&&a(v),f=!0}}else if((p&33)===33){(l.nextSub!==void 0||l.prevSub!==void 0)&&(c={value:l,prev:c}),l=g.deps,h=g,++d;continue}if(!f){const v=l.nextDep;if(v!==void 0){l=v;continue}}for(;d--;){const v=h.subs,m=v.nextSub!==void 0;if(m?(l=c.value,c=c.prev):l=v,f){if(e(h)){m&&a(v),h=l.sub;continue}f=!1}else h.flags&=-33;h=l.sub;const y=l.nextDep;if(y!==void 0){l=y;continue e}}return f}while(!0)}function a(l){do{const h=l.sub,c=h.flags;(c&48)===32&&(h.flags=c|16,(c&6)===2&&t(h))}while((l=l.nextSub)!==void 0)}function u(l,h){let c=h.depsTail;for(;c!==void 0;){if(c===l)return!0;c=c.prevDep}return!1}}function To(e,t,s){const n=typeof e=="object",r=n?e:void 0;return{next:(n?e.next:e)?.bind(r),error:(n?e.error:t)?.bind(r),complete:(n?e.complete:s)?.bind(r)}}var is=[],vt=0,{link:yn,unlink:Oo,propagate:Fo,checkDirty:dr,shallowPropagate:Cn}=Lo({update(e){return e._update()},notify(e){is[os++]=e,e.flags&=~k.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=k.Mutable|k.Dirty,wt(e))}}),ut=0,os=0,se,as=0;function hr(e){try{++as,e()}finally{--as||fr()}}function wt(e){const t=e.depsTail;let s=t!==void 0?t.nextDep:e.deps;for(;s!==void 0;)s=Oo(s,e)}function fr(){if(!(as>0)){for(;ut<os;){const e=is[ut];is[ut++]=void 0,e.notify()}ut=0,os=0}}function Rn(e,t){const s=typeof e=="function",n=e,r={_snapshot:s?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:s?k.None:k.Mutable,get(){return se!==void 0&&yn(r,se,vt),r._snapshot},subscribe(i){const o=To(i),a={current:!1},u=Ao(()=>{r.get(),a.current?o.next?.(r._snapshot):a.current=!0});return{unsubscribe:()=>{u.stop()}}},_update(i){const o=se,a=t?.compare??Object.is;if(s)se=r,++vt,r.depsTail=void 0;else if(i===void 0)return!1;s&&(r.flags=k.Mutable|k.RecursedCheck);try{const u=r._snapshot,l=typeof i=="function"?i(u):i===void 0&&s?n(u):i;return u===void 0||!a(u,l)?(r._snapshot=l,!0):!1}finally{se=o,s&&(r.flags&=~k.RecursedCheck),wt(r)}}};return s?(r.flags=k.Mutable|k.Dirty,r.get=function(){const i=r.flags;if(i&k.Dirty||i&k.Pending&&dr(r.deps,r)){if(r._update()){const o=r.subs;o!==void 0&&Cn(o)}}else i&k.Pending&&(r.flags=i&~k.Pending);return se!==void 0&&yn(r,se,vt),r._snapshot}):r.set=function(i){if(r._update(i)){const o=r.subs;o!==void 0&&(Fo(o),Cn(o),fr())}},r}function Ao(e){const t=()=>{const n=se;se=s,++vt,s.depsTail=void 0,s.flags=k.Watching|k.RecursedCheck;try{return e()}finally{se=n,s.flags&=~k.RecursedCheck,wt(s)}},s={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:k.Watching|k.RecursedCheck,notify(){const n=this.flags;n&k.Dirty||n&k.Pending&&dr(this.deps,this)?t():this.flags=k.Watching},stop(){this.flags=k.None,this.depsTail=void 0,wt(this)}};return t(),s}var ko=$e((e=>{var t=fs();function s(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:s,r=t.useState,i=t.useEffect,o=t.useLayoutEffect,a=t.useDebugValue;function u(d,f){var g=f(),p=r({inst:{value:g,getSnapshot:f}}),v=p[0].inst,m=p[1];return o(function(){v.value=g,v.getSnapshot=f,l(v)&&m({inst:v})},[d,g,f]),i(function(){return l(v)&&m({inst:v}),d(function(){l(v)&&m({inst:v})})},[d]),a(g),g}function l(d){var f=d.getSnapshot;d=d.value;try{var g=f();return!n(d,g)}catch{return!0}}function h(d,f){return f()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:c})),Do=$e(((e,t)=>{t.exports=ko()})),$o=$e((e=>{var t=fs(),s=Do();function n(h,c){return h===c&&(h!==0||1/h===1/c)||h!==h&&c!==c}var r=typeof Object.is=="function"?Object.is:n,i=s.useSyncExternalStore,o=t.useRef,a=t.useEffect,u=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(h,c,d,f,g){var p=o(null);if(p.current===null){var v={hasValue:!1,value:null};p.current=v}else v=p.current;p=u(function(){function y(P){if(!C){if(C=!0,S=P,P=f(P),g!==void 0&&v.hasValue){var b=v.value;if(g(b,P))return w=b}return w=P}if(b=w,r(S,P))return b;var I=f(P);return g!==void 0&&g(b,I)?(S=P,b):(S=P,w=I)}var C=!1,S,w,_=d===void 0?null:d;return[function(){return y(c())},_===null?void 0:function(){return y(_())}]},[c,d,f,g]);var m=i(h,p[0],p[1]);return a(function(){v.hasValue=!0,v.value=m},[m]),l(m),m}})),No=$e(((e,t)=>{t.exports=$o()})),Vo=No();function Bo(e,t){return e===t}function W(e,t,s=Bo){const n=(0,R.useCallback)(i=>{if(!e)return()=>{};const{unsubscribe:o}=e.subscribe(i);return o},[e]),r=(0,R.useCallback)(()=>e?.get(),[e]);return(0,Vo.useSyncExternalStoreWithSelector)(n,r,r,t,s)}var zo={get:()=>{},subscribe:()=>({unsubscribe:()=>{}})};function _e(e){const t=Z(),s=R.useContext(e.from?Eo:_t),n=e.from??s,r=n?e.from?t.stores.getRouteMatchStore(n):t.stores.matchStores.get(n):void 0,i=R.useRef(void 0);return W(r??zo,o=>{if((e.shouldThrow??!0)&&!o&&ie(),o===void 0)return;const a=e.select?e.select(o):o;if(e.structuralSharing??t.options.defaultStructuralSharing){const u=le(i.current,a);return i.current=u,u}return a})}function gr(e){return _e({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function pr(e){const{select:t,...s}=e;return _e({...s,select:n=>t?t(n.loaderDeps):n.loaderDeps})}function mr(e){return _e({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{const s=e.strict===!1?t.params:t._strictParams;return e.select?e.select(s):s}})}function vr(e){return _e({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function Sr(e){const t=Z();return R.useCallback(s=>t.navigate({...s,from:s.from??e?.from}),[e?.from,t])}function yr(e){return _e({...e,select:t=>e.select?e.select(t.context):t.context})}var Cr=zn(Vr(),1);function Ho(e,t){const s=Z(),n=wi(t),r=!1,{activeProps:i,inactiveProps:o,activeOptions:a,to:u,preload:l,preloadDelay:h,preloadIntentProximity:c,hashScrollIntoView:d,replace:f,startTransition:g,resetScroll:p,viewTransition:v,children:m,target:y,disabled:C,style:S,className:w,onClick:_,onBlur:P,onFocus:b,onMouseEnter:I,onMouseLeave:x,onTouchStart:M,ignoreBlocker:A,params:D,search:ee,hash:K,state:oe,mask:J,reloadDocument:Ve,unsafeRelative:xs,from:Es,_fromLocation:st,...Ie}=e;if(r){const F=_n(u);if(typeof u=="string"&&!F&&u.indexOf(":")>-1)try{return new URL(u),Ce(u,s.protocolAllowlist)?{...Ie,ref:n,href:void 0,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}}:{...Ie,ref:n,href:u,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}}}catch{}const O=s.buildLocation({...e,from:e.from}),Y=Mn(O.maskedLocation?O.maskedLocation.publicHref:O.publicHref,O.maskedLocation?O.maskedLocation.external:O.external,s.history,C),Ue=(()=>{if(Y?.external)return Ce(Y.href,s.protocolAllowlist)?void 0:Y.href;if(!F&&typeof u=="string"&&u.indexOf(":")>-1)try{return new URL(u),Ce(u,s.protocolAllowlist)?void 0:u}catch{}})(),Tt=(()=>{if(Ue)return!1;const N=s.stores.location.get(),j=a?.exact??!1;if(j){if(!rn(N.pathname,O.pathname,s.basepath))return!1}else{const V=Fe(N.pathname,s.basepath),G=Fe(O.pathname,s.basepath);if(!(V.startsWith(G)&&(V.length===G.length||V[G.length]==="/")))return!1}if((a?.includeSearch??!0)&&N.search!==O.search){const V=!N.search||typeof N.search=="object"&&Object.keys(N.search).length===0,G=!O.search||typeof O.search=="object"&&Object.keys(O.search).length===0;if(!(V&&G)&&!fe(N.search,O.search,{partial:!j,ignoreUndefined:!a?.explicitUndefined}))return!1}return!a?.includeHash})();if(Ue)return{...Ie,ref:n,href:Ue,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}};const Ot=Tt?ne(i,{})??wn:Ee,Ft=Tt?Ee:ne(o,{})??Ee,Ns=(()=>{const N=S,j=Ot.style,V=Ft.style;if(!(!N&&!j&&!V))return N&&!j&&!V?N:!N&&j&&!V?j:!N&&!j&&V?V:{...N,...j,...V}})(),Vs=(()=>{const N=w,j=Ot.className,V=Ft.className;if(!N&&!j&&!V)return"";let G="";return N&&(G=N),j&&(G=G?`${G} ${j}`:j),V&&(G=G?`${G} ${V}`:V),G})();return{...Ie,...Ot,...Ft,href:Y?.href,ref:n,disabled:!!C,target:y,...Ns&&{style:Ns},...Vs&&{className:Vs},...C&&bn,...Tt&&Pn}}const xt=ur(),Be=R.useMemo(()=>e,[s,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),ve=W(s.stores.location,F=>F,(F,O)=>F.href===O.href),H=R.useMemo(()=>{const F={_fromLocation:ve,...Be};return s.buildLocation(F)},[s,ve,Be]),Ls=H.maskedLocation?H.maskedLocation.publicHref:H.publicHref,Ts=H.maskedLocation?H.maskedLocation.external:H.external,ze=R.useMemo(()=>Mn(Ls,Ts,s.history,C),[C,Ts,Ls,s.history]),He=R.useMemo(()=>{if(ze?.external)return Ce(ze.href,s.protocolAllowlist)?void 0:ze.href;if(!_n(u)&&!(typeof u!="string"||u.indexOf(":")===-1))try{return new URL(u),Ce(u,s.protocolAllowlist)?void 0:u}catch{}},[u,ze,s.protocolAllowlist]),Et=R.useMemo(()=>{if(He)return!1;if(a?.exact){if(!rn(ve.pathname,H.pathname,s.basepath))return!1}else{const F=Fe(ve.pathname,s.basepath),O=Fe(H.pathname,s.basepath);if(!(F.startsWith(O)&&(F.length===O.length||F[O.length]==="/")))return!1}return(a?.includeSearch??!0)&&!fe(ve.search,H.search,{partial:!a?.exact,ignoreUndefined:!a?.explicitUndefined})?!1:a?.includeHash?xt&&ve.hash===H.hash:!0},[a?.exact,a?.explicitUndefined,a?.includeHash,a?.includeSearch,ve,He,xt,H.hash,H.pathname,H.search,s.basepath]),nt=Et?ne(i,{})??wn:Ee,rt=Et?Ee:ne(o,{})??Ee,Os=[w,nt.className,rt.className].filter(Boolean).join(" "),Fs=(S||nt.style||rt.style)&&{...S,...nt.style,...rt.style},[Dr,As]=R.useState(!1),ks=R.useRef(!1),xe=e.reloadDocument||He?!1:l??s.options.defaultPreload,Lt=h??s.options.defaultPreloadDelay??0,Se=R.useCallback(()=>{s.preloadRoute({...Be,_builtLocation:H}).catch(F=>{console.warn(F),console.warn(bo)})},[s,Be,H]);Ri(n,R.useCallback(F=>{F?.isIntersecting&&Se()},[Se]),jo,{disabled:!!C||xe!=="viewport"}),R.useEffect(()=>{ks.current||!C&&xe==="render"&&(Se(),ks.current=!0)},[C,Se,xe]);const $r=F=>{const O=F.currentTarget.getAttribute("target"),Y=y!==void 0?y:O;if(!C&&!Go(F)&&!F.defaultPrevented&&(!Y||Y==="_self")&&F.button===0){F.preventDefault(),(0,Cr.flushSync)(()=>{As(!0)});const Ue=s.subscribe("onResolved",()=>{Ue(),As(!1)});s.navigate({...Be,replace:f,resetScroll:p,hashScrollIntoView:d,startTransition:g,viewTransition:v,ignoreBlocker:A})}};if(He)return{...Ie,ref:n,href:He,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w},..._&&{onClick:_},...P&&{onBlur:P},...b&&{onFocus:b},...I&&{onMouseEnter:I},...x&&{onMouseLeave:x},...M&&{onTouchStart:M}};const Ds=F=>{if(C||xe!=="intent")return;if(!Lt){Se();return}const O=F.currentTarget;if(We.has(O))return;const Y=setTimeout(()=>{We.delete(O),Se()},Lt);We.set(O,Y)},Nr=F=>{C||xe!=="intent"||Se()},$s=F=>{if(C||!xe||!Lt)return;const O=F.currentTarget,Y=We.get(O);Y&&(clearTimeout(Y),We.delete(O))};return{...Ie,...nt,...rt,href:ze?.href,ref:n,onClick:Le([_,$r]),onBlur:Le([P,$s]),onFocus:Le([b,Ds]),onMouseEnter:Le([I,Ds]),onMouseLeave:Le([x,$s]),onTouchStart:Le([M,Nr]),disabled:!!C,target:y,...Fs&&{style:Fs},...Os&&{className:Os},...C&&bn,...Et&&Pn,...xt&&Dr&&Uo}}var Ee={},wn={className:"active"},bn={role:"link","aria-disabled":!0},Pn={"data-status":"active","aria-current":"page"},Uo={"data-transitioning":"transitioning"},We=new WeakMap,jo={rootMargin:"100px"},Le=e=>t=>{for(const s of e)if(s){if(t.defaultPrevented)return;s(t)}};function Mn(e,t,s,n){if(!n)return t?{href:e,external:!0}:{href:s.createHref(e)||"/",external:!1}}function _n(e){if(typeof e!="string")return!1;const t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Rr=R.forwardRef((e,t)=>{const{_asChild:s,...n}=e,{type:r,...i}=Ho(n,t),o=typeof n.children=="function"?n.children({isActive:i["data-status"]==="active"}):n.children;if(!s){const{disabled:a,...u}=i;return R.createElement("a",u,o)}return R.createElement(s,i,o)});function Go(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var qo=class extends lr{constructor(e){super(e),this.useMatch=t=>_e({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>yr({...t,from:this.id}),this.useSearch=t=>vr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>mr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>pr({...t,from:this.id}),this.useLoaderData=t=>gr({...t,from:this.id}),this.useNavigate=()=>Sr({from:this.fullPath}),this.Link=R.forwardRef((t,s)=>(0,E.jsx)(Rr,{ref:s,from:this.fullPath,...t}))}};function Wo(e){return new qo(e)}var Ko=class extends Po{constructor(e){super(e),this.useMatch=t=>_e({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>yr({...t,from:this.id}),this.useSearch=t=>vr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>mr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>pr({...t,from:this.id}),this.useLoaderData=t=>gr({...t,from:this.id}),this.useNavigate=()=>Sr({from:this.fullPath}),this.Link=R.forwardRef((t,s)=>(0,E.jsx)(Rr,{ref:s,from:this.fullPath,...t}))}};function Bl(e){return new Ko(e)}function zl(e){return new Qo(e,{silent:!0}).createRoute}var Qo=class{constructor(e,t){this.path=e,this.createRoute=s=>{const n=Wo(s);return n.isRoot=!1,n},this.silent=t?.silent}};function Hl(e,t){let s,n,r,i;const o=()=>(s||(s=e().then(u=>{s=void 0,n=u[t??"default"]}).catch(u=>{if(r=u,_i(r)&&r instanceof Error&&typeof window<"u"&&typeof sessionStorage<"u"){const l=`tanstack_router_reload:${r.message}`;sessionStorage.getItem(l)||(sessionStorage.setItem(l,"1"),i=!0)}})),s),a=function(l){if(i)throw window.location.reload(),new Promise(()=>{});if(r)throw r;if(!n)if(Ys)Ys(o());else throw o();return R.createElement(n,l)};return a.preload=o,a}function Jo(e){const t=Z(),s=`not-found-${W(t.stores.location,n=>n.pathname)}-${W(t.stores.status,n=>n)}`;return(0,E.jsx)(bs,{getResetKey:()=>s,onCatch:(n,r)=>{if(z(n))e.onCatch?.(n,r);else throw n},errorComponent:({error:n})=>{if(z(n))return e.fallback?.(n);throw n},children:e.children})}function Yo(){return(0,E.jsx)("p",{children:"Not Found"})}function Oe(e){return(0,E.jsx)(E.Fragment,{children:e.children})}function wr(e,t,s){return t.options.notFoundComponent?(0,E.jsx)(t.options.notFoundComponent,{...s}):e.options.defaultNotFoundComponent?(0,E.jsx)(e.options.defaultNotFoundComponent,{...s}):(0,E.jsx)(Yo,{})}var br=R.memo(function({matchId:t}){const s=Z(),n=s.stores.matchStores.get(t);n||ie();const r=W(s.stores.loadedAt,o=>o),i=W(n,o=>o);return(0,E.jsx)(Xo,{router:s,matchId:t,resetKey:r,matchState:R.useMemo(()=>{const o=i.routeId,a=s.routesById[o].parentRoute?.id;return{routeId:o,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:a}},[i._displayPending,i.routeId,i.ssr,s.routesById])})});function Xo({router:e,matchId:t,resetKey:s,matchState:n}){const r=e.routesById[n.routeId],i=r.options.pendingComponent??e.options.defaultPendingComponent,o=i?(0,E.jsx)(i,{}):null,a=r.options.errorComponent??e.options.defaultErrorComponent,u=r.options.onCatch??e.options.defaultOnCatch,l=r.isRoot?r.options.notFoundComponent??e.options.notFoundRoute?.options.component:r.options.notFoundComponent,h=n.ssr===!1||n.ssr==="data-only",c=(!r.isRoot||r.options.wrapInSuspense||h)&&(r.options.wrapInSuspense??i??(r.options.errorComponent?.preload||h))?R.Suspense:Oe,d=a?bs:Oe,f=l?Jo:Oe;return(0,E.jsxs)(r.isRoot?r.options.shellComponent??Oe:Oe,{children:[(0,E.jsx)(_t.Provider,{value:t,children:(0,E.jsx)(c,{fallback:o,children:(0,E.jsx)(d,{getResetKey:()=>s,errorComponent:a||Ps,onCatch:(g,p)=>{if(z(g))throw g.routeId??=n.routeId,g;u?.(g,p)},children:(0,E.jsx)(f,{fallback:g=>{if(g.routeId??=n.routeId,!l||g.routeId&&g.routeId!==n.routeId||!g.routeId&&!r.isRoot)throw g;return R.createElement(l,g)},children:h||n._displayPending?(0,E.jsx)(Io,{fallback:o,children:(0,E.jsx)(In,{matchId:t})}):(0,E.jsx)(In,{matchId:t})})})})}),n.parentRouteId==="__root__"?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Zo,{resetKey:s}),(e.options.scrollRestoration,null)]}):null]})}function Zo({resetKey:e}){const t=Z(),s=R.useRef(void 0);return Qe(()=>{const n=t.latestLocation.href;(s.current===void 0||s.current!==n)&&(t.emit({type:"onRendered",...Ae(t.stores.location.get(),t.stores.resolvedLocation.get())}),s.current=n)},[t.latestLocation.state.__TSR_key,e,t]),null}var In=R.memo(function({matchId:t}){const s=Z(),n=(h,c)=>s.getMatch(h.id)?._nonReactive[c]??h._nonReactive[c],r=s.stores.matchStores.get(t);r||ie();const i=W(r,h=>h),o=i.routeId,a=s.routesById[o],u=R.useMemo(()=>{const h=(s.routesById[o].options.remountDeps??s.options.defaultRemountDeps)?.({routeId:o,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return h?JSON.stringify(h):void 0},[o,i.loaderDeps,i._strictParams,i._strictSearch,s.options.defaultRemountDeps,s.routesById]),l=R.useMemo(()=>{const h=a.options.component??s.options.defaultComponent;return h?(0,E.jsx)(h,{},u):(0,E.jsx)(ea,{})},[u,a.options.component,s.options.defaultComponent]);if(i._displayPending)throw n(i,"displayPendingPromise");if(i._forcePending)throw n(i,"minPendingPromise");if(i.status==="pending"){const h=a.options.pendingMinMs??s.options.defaultPendingMinMs;if(h){const c=s.getMatch(i.id);if(c&&!c._nonReactive.minPendingPromise){const d=De();c._nonReactive.minPendingPromise=d,setTimeout(()=>{d.resolve(),c._nonReactive.minPendingPromise=void 0},h)}}throw n(i,"loadPromise")}if(i.status==="notFound")return z(i.error)||ie(),wr(s,a,i.error);if(i.status==="redirected")throw q(i.error)||ie(),n(i,"loadPromise");if(i.status==="error")throw i.error;return l}),ea=R.memo(function(){const t=Z(),s=R.useContext(_t);let n,r=!1,i;{const l=s?t.stores.matchStores.get(s):void 0;[n,r]=W(l,h=>[h?.routeId,h?.globalNotFound??!1]),i=W(t.stores.matchesId,h=>h[h.findIndex(c=>c===s)+1])}const o=n?t.routesById[n]:void 0,a=t.options.defaultPendingComponent?(0,E.jsx)(t.options.defaultPendingComponent,{}):null;if(r)return o||ie(),wr(t,o,void 0);if(!i)return null;const u=(0,E.jsx)(br,{matchId:i});return n==="__root__"?(0,E.jsx)(R.Suspense,{fallback:a,children:u}):u});function ta(){const e=Z(),t=R.useRef({router:e,mounted:!1}),[s,n]=R.useState(!1),r=W(e.stores.isLoading,c=>c),i=W(e.stores.hasPending,c=>c),o=At(r),a=r||s||i,u=At(a),l=r||i,h=At(l);return e.startTransition=c=>{n(!0),R.startTransition(()=>{c(),n(!1)})},R.useEffect(()=>{const c=e.history.subscribe(e.load),d=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return ge(e.latestLocation.publicHref)!==ge(d.publicHref)&&e.commitLocation({...d,replace:!0}),()=>{c()}},[e,e.history]),Qe(()=>{if(typeof window<"u"&&e.ssr||t.current.router===e&&t.current.mounted)return;t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(d){console.error(d)}})()},[e]),Qe(()=>{o&&!r&&e.emit({type:"onLoad",...Ae(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,r]),Qe(()=>{h&&!l&&e.emit({type:"onBeforeRouteMount",...Ae(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,h,e]),Qe(()=>{if(u&&!a){const c=Ae(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:"onResolved",...c}),hr(()=>{e.stores.status.set("idle"),e.stores.resolvedLocation.set(e.stores.location.get())}),c.hrefChanged&&Mo(e)}},[a,u,e]),null}function sa(){const e=Z(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,s=t?(0,E.jsx)(t,{}):null,n=(0,E.jsxs)(typeof document<"u"&&e.ssr?Oe:R.Suspense,{fallback:s,children:[(0,E.jsx)(ta,{}),(0,E.jsx)(na,{})]});return e.options.InnerWrap?(0,E.jsx)(e.options.InnerWrap,{children:n}):n}function na(){const e=Z(),t=!1,s=t?e.stores.firstId.get():W(e.stores.firstId,i=>i),n=t?e.stores.loadedAt.get():W(e.stores.loadedAt,i=>i),r=s?(0,E.jsx)(br,{matchId:s}):null;return(0,E.jsx)(_t.Provider,{value:s,children:e.options.disableGlobalCatchBoundary?r:(0,E.jsx)(bs,{getResetKey:()=>n,errorComponent:Ps,onCatch:void 0,children:r})})}var ra=e=>({createMutableStore:Rn,createReadonlyStore:Rn,batch:hr}),Ul=e=>new ia(e),ia=class extends mo{constructor(e){super(e,ra)}};function oa({router:e,children:t,...s}){Object.keys(s).length>0&&e.update({...e.options,...s,context:{...e.options.context,...s.context}});const n=(0,E.jsx)(cr.Provider,{value:e,children:t});return e.options.Wrap?(0,E.jsx)(e.options.Wrap,{children:n}):n}function jl({router:e,...t}){return(0,E.jsx)(oa,{router:e,...t,children:(0,E.jsx)(sa,{})})}function Gl(e){const t=Z(),s=(0,R.useRef)(void 0);return W(t.stores.location,n=>{const r=e?.select?e.select(n):n;if(e?.structuralSharing??t.options.defaultStructuralSharing){const i=le(s.current,r);return s.current=i,i}return r})}var aa=class{#t=!0;#e;#s;#r;#n;#a;#i;#o;#g=0;#p=5;#u=!1;#c=!1;#l=null;#d=()=>{this.debugLog("Connected to event bus"),this.#a=!0,this.#u=!1,this.debugLog("Emitting queued events",this.#n),this.#n.forEach(e=>this.emitEventToBus(e)),this.#n=[],this.stopConnectLoop(),this.#s().removeEventListener("tanstack-connect-success",this.#d)};#h=()=>{if(this.#g<this.#p){this.#g++,this.dispatchCustomEvent("tanstack-connect",{});return}this.#s().removeEventListener("tanstack-connect",this.#h),this.#c=!0,this.debugLog("Max retries reached, giving up on connection"),this.stopConnectLoop()};#f=()=>{this.#u||(this.#u=!0,this.#s().addEventListener("tanstack-connect-success",this.#d),this.#h())};constructor({pluginId:e,debug:t=!1,enabled:s=!0,reconnectEveryMs:n=300}){this.#e=e,this.#t=s,this.#s=this.getGlobalTarget,this.#r=t,this.debugLog(" Initializing event subscription for plugin",this.#e),this.#n=[],this.#a=!1,this.#c=!1,this.#i=null,this.#o=n}startConnectLoop(){this.#i!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#o}ms)`),this.#i=setInterval(this.#h,this.#o))}stopConnectLoop(){this.#u=!1,this.#i!==null&&(clearInterval(this.#i),this.#i=null,this.#n=[],this.debugLog("Stopped connect loop"))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#e}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<"u"&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog("Using global event target"),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<"u"&&typeof window.addEventListener<"u")return this.debugLog("Using window as event target"),window;const e=typeof EventTarget<"u"?new EventTarget:void 0;return typeof e>"u"||typeof e.addEventListener>"u"?(this.debugLog("No event mechanism available, running in non-web environment"),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog("Using new EventTarget as fallback"),e)}getPluginId(){return this.#e}dispatchCustomEventShim(e,t){try{const s=new Event(e,{detail:t});this.#s().dispatchEvent(s)}catch{this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,t){try{this.#s().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}createEventPayload(e,t){return{type:`${this.#e}:${e}`,payload:t,pluginId:this.#e}}emit(e,t){if(!this.#t){this.debugLog("Event bus client is disabled, not emitting event",e,t);return}if(this.#l&&(this.debugLog("Emitting event to internal event target",e,t),this.#l.dispatchEvent(new CustomEvent(`${this.#e}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#c){this.debugLog("Previously failed to connect, not emitting to bus");return}if(!this.#a){this.debugLog("Bus not available, will be pushed as soon as connected"),this.#n.push(this.createEventPayload(e,t)),typeof CustomEvent<"u"&&!this.#u&&(this.#f(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,s){const n=s?.withEventTarget??!1,r=`${this.#e}:${e}`;if(n&&(this.#l||(this.#l=new EventTarget),this.#l.addEventListener(r,o=>{t(o.detail)})),!this.#t)return this.debugLog("Event bus client is disabled, not registering event",r),()=>{};const i=o=>{this.debugLog("Received event from bus",o.detail),t(o.detail)};return this.#s().addEventListener(r,i),this.debugLog("Registered event to bus",r),()=>{n&&this.#l?.removeEventListener(r,i),this.#s().removeEventListener(r,i)}}onAll(e){if(!this.#t)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};const t=s=>{const n=s.detail;e(n)};return this.#s().addEventListener("tanstack-devtools-global",t),()=>this.#s().removeEventListener("tanstack-devtools-global",t)}onAllPluginEvents(e){if(!this.#t)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};const t=s=>{const n=s.detail;this.#e&&n.pluginId!==this.#e||e(n)};return this.#s().addEventListener("tanstack-devtools-global",t),()=>this.#s().removeEventListener("tanstack-devtools-global",t)}},la=class extends aa{constructor(){super({pluginId:"tanstack-ai-devtools"})}},xn=new la;function ua(e){return e.type==="text"||e.type==="image"||e.type==="audio"||e.type==="video"||e.type==="document"}function Pr(e){return e.length===0?null:e.every(t=>t.type==="text")?e.map(t=>t.content).join("")||null:e}function En(e){return e===null?"":typeof e=="string"?e:e.filter(t=>t.type==="text").map(t=>t.content).join("")}function ca(e){return e.role==="system"?[]:e.role!=="assistant"?[da(e)]:fa(e)}function da(e){const t=[];for(const s of e.parts)ua(s)&&t.push(s);return{role:e.role,content:Pr(t)}}function Ln(){return{contentParts:[],toolCalls:[]}}function ha(e){return e.state==="input-complete"||e.state==="approval-responded"||e.output!==void 0}function fa(e){const t=[];let s=Ln();const n=new Set;function r(){const i=Pr(s.contentParts),o=i!==null,a=s.toolCalls.length>0;(o||a)&&t.push({role:"assistant",content:i,...a&&{toolCalls:s.toolCalls}}),s=Ln()}for(const i of e.parts)switch(i.type){case"text":case"image":case"audio":case"video":case"document":s.contentParts.push(i);break;case"tool-call":ha(i)&&s.toolCalls.push({id:i.id,type:"function",function:{name:i.name,arguments:i.arguments}});break;case"tool-result":r(),(i.state==="complete"||i.state==="error")&&!n.has(i.toolCallId)&&(t.push({role:"tool",content:i.content,toolCallId:i.toolCallId}),n.add(i.toolCallId));break}r();for(const i of e.parts)if(i.type==="tool-call"&&(i.output!==void 0&&!n.has(i.id)&&(t.push({role:"tool",content:JSON.stringify(i.output),toolCallId:i.id}),n.add(i.id)),i.output===void 0&&i.state==="approval-responded"&&i.approval?.approved!==void 0&&!n.has(i.id))){const o=i.approval.approved;t.push({role:"tool",content:JSON.stringify({approved:o,...o&&{pendingExecution:!0},message:o?"User approved this action":"User denied this action"}),toolCallId:i.id}),n.add(i.id)}return t.length===0&&t.push({role:"assistant",content:null}),t}function ga(e,t){const s=[];if(e.role==="tool"&&e.toolCallId)s.push({type:"tool-result",toolCallId:e.toolCallId,content:En(e.content),state:"complete"});else if(Array.isArray(e.content))for(const n of e.content)s.push(n);else{const n=En(e.content);n&&s.push({type:"text",content:n})}if(e.toolCalls&&e.toolCalls.length>0)for(const n of e.toolCalls)s.push({type:"tool-call",id:n.id,name:n.function.name,arguments:n.function.arguments,state:"input-complete"});return{id:t||bt(),role:e.role==="tool"?"assistant":e.role,parts:s}}function pa(e,t){return"parts"in e?{...e,id:e.id||t(),createdAt:e.createdAt||new Date}:{...ga(e,t()),createdAt:new Date}}function bt(){return`msg-${Date.now()}-${Math.random().toString(36).substring(7)}`}var Tn=$e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.ALL=e.COLLECTION=e.ATOM=e.SPECIAL=e.INF=e._INFINITY=e.INFINITY=e.NAN=e.BOOL=e.NULL=e.OBJ=e.ARR=e.NUM=e.STR=void 0,e.STR=1,e.NUM=2,e.ARR=4,e.OBJ=8,e.NULL=16,e.BOOL=32,e.NAN=64,e.INFINITY=128,e._INFINITY=256,e.INF=e.INFINITY|e._INFINITY,e.SPECIAL=e.NULL|e.BOOL|e.INF|e.NAN,e.ATOM=e.STR|e.NUM|e.SPECIAL,e.COLLECTION=e.ARR|e.OBJ,e.ALL=e.ATOM|e.COLLECTION,e.Allow={STR:e.STR,NUM:e.NUM,ARR:e.ARR,OBJ:e.OBJ,NULL:e.NULL,BOOL:e.BOOL,NAN:e.NAN,INFINITY:e.INFINITY,_INFINITY:e._INFINITY,INF:e.INF,SPECIAL:e.SPECIAL,ATOM:e.ATOM,COLLECTION:e.COLLECTION,ALL:e.ALL},e.default=e.Allow})),ma=$e((e=>{var t=e&&e.__createBinding||(Object.create?(function(l,h,c,d){d===void 0&&(d=c);var f=Object.getOwnPropertyDescriptor(h,c);(!f||("get"in f?!h.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return h[c]}}),Object.defineProperty(l,d,f)}):(function(l,h,c,d){d===void 0&&(d=c),l[d]=h[c]})),s=e&&e.__exportStar||function(l,h){for(var c in l)c!=="default"&&!Object.prototype.hasOwnProperty.call(h,c)&&t(h,l,c)};Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.MalformedJSON=e.PartialJSON=e.parseJSON=e.parse=void 0;var n=Tn();Object.defineProperty(e,"Allow",{enumerable:!0,get:function(){return n.Allow}}),s(Tn(),e);var r=class extends Error{};e.PartialJSON=r;var i=class extends Error{};e.MalformedJSON=i;function o(l,h=n.Allow.ALL){if(typeof l!="string")throw new TypeError(`expecting str, got ${typeof l}`);if(!l.trim())throw new Error(`${l} is empty`);return a(l.trim(),h)}e.parseJSON=o;var a=(l,h)=>{const c=l.length;let d=0;const f=w=>{throw new r(`${w} at position ${d}`)},g=w=>{throw new i(`${w} at position ${d}`)},p=()=>(S(),d>=c&&f("Unexpected end of input"),l[d]==='"'?v():l[d]==="{"?m():l[d]==="["?y():l.substring(d,d+4)==="null"||n.Allow.NULL&h&&c-d<4&&"null".startsWith(l.substring(d))?(d+=4,null):l.substring(d,d+4)==="true"||n.Allow.BOOL&h&&c-d<4&&"true".startsWith(l.substring(d))?(d+=4,!0):l.substring(d,d+5)==="false"||n.Allow.BOOL&h&&c-d<5&&"false".startsWith(l.substring(d))?(d+=5,!1):l.substring(d,d+8)==="Infinity"||n.Allow.INFINITY&h&&c-d<8&&"Infinity".startsWith(l.substring(d))?(d+=8,1/0):l.substring(d,d+9)==="-Infinity"||n.Allow._INFINITY&h&&1<c-d&&c-d<9&&"-Infinity".startsWith(l.substring(d))?(d+=9,-1/0):l.substring(d,d+3)==="NaN"||n.Allow.NAN&h&&c-d<3&&"NaN".startsWith(l.substring(d))?(d+=3,NaN):C()),v=()=>{const w=d;let _=!1;for(d++;d<c&&(l[d]!=='"'||_&&l[d-1]==="\\");)_=l[d]==="\\"?!_:!1,d++;if(l.charAt(d)=='"')try{return JSON.parse(l.substring(w,++d-Number(_)))}catch(P){g(String(P))}else if(n.Allow.STR&h)try{return JSON.parse(l.substring(w,d-Number(_))+'"')}catch{return JSON.parse(l.substring(w,l.lastIndexOf("\\"))+'"')}f("Unterminated string literal")},m=()=>{d++,S();const w={};try{for(;l[d]!=="}";){if(S(),d>=c&&n.Allow.OBJ&h)return w;const _=v();S(),d++;try{w[_]=p()}catch(P){if(n.Allow.OBJ&h)return w;throw P}S(),l[d]===","&&d++}}catch{if(n.Allow.OBJ&h)return w;f("Expected '}' at end of object")}return d++,w},y=()=>{d++;const w=[];try{for(;l[d]!=="]";)w.push(p()),S(),l[d]===","&&d++}catch{if(n.Allow.ARR&h)return w;f("Expected ']' at end of array")}return d++,w},C=()=>{if(d===0){l==="-"&&g("Not sure what '-' is");try{return JSON.parse(l)}catch(_){if(n.Allow.NUM&h)try{return JSON.parse(l.substring(0,l.lastIndexOf("e")))}catch{}g(String(_))}}const w=d;for(l[d]==="-"&&d++;l[d]&&",]}".indexOf(l[d])===-1;)d++;d==c&&!(n.Allow.NUM&h)&&f("Unterminated number literal");try{return JSON.parse(l.substring(w,d))}catch{l.substring(w,d)==="-"&&f("Not sure what '-' is");try{return JSON.parse(l.substring(w,l.lastIndexOf("e")))}catch(P){g(String(P))}}},S=()=>{for(;d<c&&`
2
+ \r `.includes(l[d]);)d++};return p()},u=o;e.parse=u})),va=ma(),Sa=class{parse(e){if(!(!e||e.trim()===""))try{return(0,va.parse)(e)}catch{return}}},ya=new Sa;function Ca(e,t,s){return e.map(n=>{if(n.id!==t)return n;const r=[...n.parts],i=r.length>0?r[r.length-1]:null;return i&&i.type==="text"?r[r.length-1]={type:"text",content:s}:r.push({type:"text",content:s}),{...n,parts:r}})}function zt(e,t,s){return e.map(n=>{if(n.id!==t)return n;const r=[...n.parts],i=r.find(a=>a.type==="tool-call"&&a.id===s.id),o={type:"tool-call",id:s.id,name:s.name,arguments:s.arguments,state:s.state,...i?.approval&&{approval:{...i.approval}},...i?.output!==void 0&&{output:i.output}};return i?r[r.indexOf(i)]=o:r.push(o),{...n,parts:r}})}function Ht(e,t,s,n,r,i){return e.map(o=>{if(o.id!==t)return o;const a=[...o.parts],u=a.findIndex(h=>h.type==="tool-result"&&h.toolCallId===s),l={type:"tool-result",toolCallId:s,content:n,state:r,...i&&{error:i}};return u>=0?a[u]=l:a.push(l),{...o,parts:a}})}function Ra(e,t,s,n){return e.map(r=>{if(r.id!==t)return r;const i=[...r.parts],o=i.find(a=>a.type==="tool-call"&&a.id===s);return o&&(o.state="approval-requested",o.approval={id:n,needsApproval:!0}),{...r,parts:i}})}function Ut(e,t,s,n,r){return e.map(i=>{const o=[...i.parts],a=o.find(u=>u.type==="tool-call"&&u.id===t);return a&&(a.output=r?{error:r}:s,n?a.state=n:a.state="input-complete"),{...i,parts:o}})}function wa(e,t,s){return e.map(n=>{const r=[...n.parts],i=r.find(o=>o.type==="tool-call"&&o.approval?.id===t);return i&&i.approval&&(i.approval.approved=s,i.state="approval-responded"),{...n,parts:r}})}function On(e,t,s){return e.map(n=>{if(n.id!==t)return n;const r=[...n.parts],i=r.findIndex(a=>a.type==="thinking"),o={type:"thinking",content:s};return i>=0?r[i]=o:r.push(o),{...n,parts:r}})}var ba=class{shouldEmit(e,t){return!0}},Pa=class Mr{constructor(t={}){this.messages=[],this.messageStates=new Map,this.activeMessageIds=new Set,this.toolCallToMessage=new Map,this.pendingManualMessageId=null,this.activeRuns=new Set,this.finishReason=null,this.hasError=!1,this.isDone=!1,this.recording=null,this.recordingStartTime=0,this.chunkStrategy=t.chunkStrategy||new ba,this.events=t.events||{},this.jsonParser=t.jsonParser||ya,this.recordingEnabled=t.recording??!1,t.initialMessages&&(this.messages=[...t.initialMessages])}setMessages(t){this.messages=[...t],this.emitMessagesChange()}addUserMessage(t,s){const n=typeof t=="string"?[{type:"text",content:t}]:t.map(i=>i),r={id:s??bt(),role:"user",parts:n,createdAt:new Date};return this.messages=[...this.messages,r],this.emitMessagesChange(),r}prepareAssistantMessage(){this.resetStreamState()}startAssistantMessage(t){this.prepareAssistantMessage();const{messageId:s}=this.ensureAssistantMessage(t);return this.pendingManualMessageId=s,s}getCurrentAssistantMessageId(){let t=null;for(const[s,n]of this.messageStates)n.role==="assistant"&&(t=s);return t}addToolResult(t,s,n){const r=this.messages.find(u=>u.parts.some(l=>l.type==="tool-call"&&l.id===t));if(!r){console.warn(`[StreamProcessor] Could not find message with tool call ${t}`);return}let i=Ut(this.messages,t,s,n?"input-complete":void 0,n);const o=typeof s=="string"?s:JSON.stringify(s),a=n?"error":"complete";i=Ht(i,r.id,t,o,a,n),this.messages=i,this.emitMessagesChange()}addToolApprovalResponse(t,s){this.messages=wa(this.messages,t,s),this.emitMessagesChange()}toModelMessages(){const t=[];for(const s of this.messages)t.push(...ca(s));return t}getMessages(){return this.messages}areAllToolsComplete(){const t=this.messages.findLast(r=>r.role==="assistant");if(!t)return!0;const s=t.parts.filter(r=>r.type==="tool-call");if(s.length===0)return!0;const n=new Set(t.parts.filter(r=>r.type==="tool-result").map(r=>r.toolCallId));return s.every(r=>r.state==="approval-responded"||r.output!==void 0&&!r.approval||n.has(r.id))}removeMessagesAfter(t){this.messages=this.messages.slice(0,t+1),this.emitMessagesChange()}clearMessages(){this.messages=[],this.messageStates.clear(),this.activeMessageIds.clear(),this.toolCallToMessage.clear(),this.pendingManualMessageId=null,this.emitMessagesChange()}async process(t){this.resetStreamState(),this.recordingEnabled&&this.startRecording();for await(const s of t)this.processChunk(s);return this.finalizeStream(),this.recording&&(this.recording.result=this.getResult()),this.getResult()}processChunk(t){switch(this.recording&&this.recording.chunks.push({chunk:t,timestamp:Date.now(),index:this.recording.chunks.length}),t.type){case"TEXT_MESSAGE_START":this.handleTextMessageStartEvent(t);break;case"TEXT_MESSAGE_CONTENT":this.handleTextMessageContentEvent(t);break;case"TEXT_MESSAGE_END":this.handleTextMessageEndEvent(t);break;case"TOOL_CALL_START":this.handleToolCallStartEvent(t);break;case"TOOL_CALL_ARGS":this.handleToolCallArgsEvent(t);break;case"TOOL_CALL_END":this.handleToolCallEndEvent(t);break;case"RUN_FINISHED":this.handleRunFinishedEvent(t);break;case"RUN_ERROR":this.handleRunErrorEvent(t);break;case"STEP_FINISHED":this.handleStepFinishedEvent(t);break;case"MESSAGES_SNAPSHOT":this.handleMessagesSnapshotEvent(t);break;case"CUSTOM":this.handleCustomEvent(t);break;case"RUN_STARTED":this.handleRunStartedEvent(t);break;case"REASONING_START":case"REASONING_MESSAGE_START":case"REASONING_MESSAGE_END":case"REASONING_END":break;case"REASONING_MESSAGE_CONTENT":this.handleReasoningMessageContentEvent(t);break;case"TOOL_CALL_RESULT":this.handleToolCallResultEvent(t);break}}createMessageState(t,s){const n={id:t,role:s,totalTextContent:"",currentSegmentText:"",lastEmittedText:"",thinkingContent:"",hasSeenReasoningEvents:!1,toolCalls:new Map,toolCallOrder:[],hasToolCallsSinceTextStart:!1,isComplete:!1};return this.messageStates.set(t,n),n}getMessageState(t){return this.messageStates.get(t)}getActiveAssistantMessageId(){const t=Array.from(this.activeMessageIds);for(let s=t.length-1;s>=0;s--){const n=t[s],r=this.messageStates.get(n);if(r&&r.role==="assistant")return n}return null}ensureAssistantMessage(t){if(t){const o=this.getMessageState(t);if(o)return{messageId:t,state:o}}const s=this.getActiveAssistantMessageId();if(s)return{messageId:s,state:this.getMessageState(s)};if(t){const o=this.messages.find(a=>a.id===t);if(o){const a=this.createMessageState(t,o.role);this.activeMessageIds.add(t);const u=o.parts.length>0?o.parts[o.parts.length-1]:null;return u&&u.type==="text"&&(a.currentSegmentText=u.content,a.lastEmittedText=u.content,a.totalTextContent=u.content),{messageId:t,state:a}}}const n=t||bt(),r={id:n,role:"assistant",parts:[],createdAt:new Date};this.messages=[...this.messages,r];const i=this.createMessageState(n,"assistant");return this.activeMessageIds.add(n),this.pendingManualMessageId=n,this.events.onStreamStart?.(),this.emitMessagesChange(),{messageId:n,state:i}}handleTextMessageStartEvent(t){const{messageId:s,role:n}=t,r=n==="user"||n==="system"?n:"assistant";if(this.pendingManualMessageId){const o=this.pendingManualMessageId;if(this.pendingManualMessageId=null,o!==s){this.messages=this.messages.map(u=>u.id===o?{...u,id:s}:u);const a=this.messageStates.get(o);a&&(a.id=s,this.messageStates.delete(o),this.messageStates.set(s,a)),this.activeMessageIds.delete(o),this.activeMessageIds.add(s)}this.messageStates.has(s)||(this.createMessageState(s,r),this.activeMessageIds.add(s)),this.emitMessagesChange();return}if(this.messages.find(o=>o.id===s)){if(this.activeMessageIds.add(s),!this.messageStates.has(s))this.createMessageState(s,r);else{const o=this.messageStates.get(s);o.hasToolCallsSinceTextStart&&(o.currentSegmentText!==o.lastEmittedText&&this.emitTextUpdateForMessage(s),o.currentSegmentText="",o.lastEmittedText="",o.hasToolCallsSinceTextStart=!1)}return}const i={id:s,role:r,parts:[],createdAt:new Date};this.messages=[...this.messages,i],this.createMessageState(s,r),this.activeMessageIds.add(s),this.events.onStreamStart?.(),this.emitMessagesChange()}handleTextMessageEndEvent(t){const{messageId:s}=t,n=this.getMessageState(s);n&&(n.isComplete||(n.currentSegmentText!==n.lastEmittedText&&this.emitTextUpdateForMessage(s),this.completeAllToolCallsForMessage(s)))}handleMessagesSnapshotEvent(t){this.resetStreamState(),this.messages=[...t.messages],this.emitMessagesChange()}handleTextMessageContentEvent(t){const{messageId:s,state:n}=this.ensureAssistantMessage(t.messageId);this.completeAllToolCallsForMessage(s);const r=n.currentSegmentText;n.hasToolCallsSinceTextStart&&r.length>0&&this.isNewTextSegment(t,r)&&(r!==n.lastEmittedText&&this.emitTextUpdateForMessage(s),n.currentSegmentText="",n.lastEmittedText="",n.hasToolCallsSinceTextStart=!1);const i=n.currentSegmentText;let o=i;const a=t.delta||"";a!==""?o=i+a:t.content!==void 0&&t.content!==""&&(t.content.startsWith(i)?o=t.content:i.startsWith(t.content)?o=i:o=i+t.content);const u=o.slice(i.length);n.currentSegmentText=o,n.totalTextContent+=u;const l=t.delta||t.content||"";this.chunkStrategy.shouldEmit(l,n.currentSegmentText)&&n.currentSegmentText!==n.lastEmittedText&&this.emitTextUpdateForMessage(s)}handleToolCallStartEvent(t){const s=t.parentMessageId??this.getActiveAssistantMessageId(),{messageId:n,state:r}=this.ensureAssistantMessage(s??void 0);r.hasToolCallsSinceTextStart=!0;const i=t.toolCallId;if(!r.toolCalls.get(i)){const o="awaiting-input",a=t.toolCallName,u={id:t.toolCallId,name:a,arguments:"",state:o,parsedArguments:void 0,index:t.index??r.toolCalls.size};r.toolCalls.set(i,u),r.toolCallOrder.push(i),this.toolCallToMessage.set(i,n),this.messages=zt(this.messages,n,{id:t.toolCallId,name:a,arguments:"",state:o}),this.emitMessagesChange(),this.events.onToolCallStateChange?.(n,t.toolCallId,o,"")}}handleToolCallArgsEvent(t){const s=t.toolCallId,n=this.toolCallToMessage.get(s);if(!n)return;const r=this.getMessageState(n);if(!r)return;const i=r.toolCalls.get(s);if(!i)return;const o=i.state==="awaiting-input";i.arguments+=t.delta||"",o&&t.delta&&(i.state="input-streaming"),i.parsedArguments=this.jsonParser.parse(i.arguments),this.messages=zt(this.messages,n,{id:i.id,name:i.name,arguments:i.arguments,state:i.state}),this.emitMessagesChange(),this.events.onToolCallStateChange?.(n,i.id,i.state,i.arguments)}handleToolCallEndEvent(t){const s=this.toolCallToMessage.get(t.toolCallId);if(!s)return;const n=this.getMessageState(s);if(!n)return;const r=n.toolCalls.get(t.toolCallId);if(r&&r.state!=="input-complete"){t.input!==void 0&&!r.arguments&&(r.arguments=JSON.stringify(t.input));const i=n.toolCallOrder.indexOf(t.toolCallId);this.completeToolCall(s,i,r),t.input!==void 0&&(r.parsedArguments=t.input)}if(t.result){let i;try{i=JSON.parse(t.result)}catch{i=t.result}this.messages=Ut(this.messages,t.toolCallId,i);const o="complete";this.messages=Ht(this.messages,s,t.toolCallId,t.result,o),this.emitMessagesChange()}}handleToolCallResultEvent(t){const s=this.toolCallToMessage.get(t.toolCallId);if(!s)return;let n;try{n=JSON.parse(t.content)}catch{n=t.content}this.messages=Ut(this.messages,t.toolCallId,n);const r="complete";this.messages=Ht(this.messages,s,t.toolCallId,t.content,r),this.emitMessagesChange()}handleRunStartedEvent(t){this.activeRuns.add(t.runId)}handleRunFinishedEvent(t){this.finishReason=t.finishReason??null,this.activeRuns.delete(t.runId),this.activeRuns.size===0&&(this.isDone=!0,this.completeAllToolCalls(),this.finalizeStream())}handleRunErrorEvent(t){this.hasError=!0;const s=t.runId;s?this.activeRuns.delete(s):this.activeRuns.clear(),this.ensureAssistantMessage();const n=t.message||t.error?.message||"An error occurred";this.events.onError?.(new Error(n))}handleStepFinishedEvent(t){const{messageId:s,state:n}=this.ensureAssistantMessage(this.getActiveAssistantMessageId()??void 0);if(n.hasSeenReasoningEvents)return;const r=n.thinkingContent;let i=r;t.delta&&t.delta!==""?i=r+t.delta:t.content&&t.content!==""&&(t.content.startsWith(r)?i=t.content:r.startsWith(t.content)?i=r:i=r+t.content),n.thinkingContent=i,this.messages=On(this.messages,s,n.thinkingContent),this.emitMessagesChange(),this.events.onThinkingUpdate?.(s,n.thinkingContent)}handleReasoningMessageContentEvent(t){const{messageId:s,state:n}=this.ensureAssistantMessage(this.getActiveAssistantMessageId()??void 0);n.hasSeenReasoningEvents=!0;const r=t.delta||"";n.thinkingContent=n.thinkingContent+r,this.messages=On(this.messages,s,n.thinkingContent),this.emitMessagesChange(),this.events.onThinkingUpdate?.(s,n.thinkingContent)}handleCustomEvent(t){const s=this.getActiveAssistantMessageId();if(t.name==="tool-input-available"&&t.value){const{toolCallId:n,toolName:r,input:i}=t.value;this.events.onToolCall?.({toolCallId:n,toolName:r,input:i});return}if(t.name==="approval-requested"&&t.value){const{toolCallId:n,toolName:r,input:i,approval:o}=t.value,a=s??this.toolCallToMessage.get(n);a&&(this.messages=Ra(this.messages,a,n,o.id),this.emitMessagesChange()),this.events.onApprovalRequest?.({toolCallId:n,toolName:r,input:i,approvalId:o.id});return}if(this.events.onCustomEvent){const n=t.value&&typeof t.value=="object"?t.value.toolCallId:void 0;this.events.onCustomEvent(t.name,t.value,{toolCallId:n})}}isNewTextSegment(t,s){return t.content!==void 0&&(t.content.length<s.length||!t.content.startsWith(s)&&!s.startsWith(t.content))}completeAllToolCalls(){for(const t of this.activeMessageIds)this.completeAllToolCallsForMessage(t)}completeAllToolCallsForMessage(t){const s=this.getMessageState(t);s&&s.toolCalls.forEach((n,r)=>{if(n.state!=="input-complete"){const i=s.toolCallOrder.indexOf(r);this.completeToolCall(t,i,n)}})}completeToolCall(t,s,n){n.state="input-complete",n.parsedArguments=this.jsonParser.parse(n.arguments),this.messages=zt(this.messages,t,{id:n.id,name:n.name,arguments:n.arguments,state:"input-complete"}),this.emitMessagesChange(),this.events.onToolCallStateChange?.(t,n.id,"input-complete",n.arguments)}emitTextUpdateForMessage(t){const s=this.getMessageState(t);s&&(s.lastEmittedText=s.currentSegmentText,this.messages=Ca(this.messages,t,s.currentSegmentText),this.emitMessagesChange(),this.events.onTextUpdate?.(t,s.currentSegmentText))}emitMessagesChange(){this.events.onMessagesChange?.([...this.messages])}finalizeStream(){let t;for(const s of this.activeMessageIds){const n=this.getMessageState(s);if(!n)continue;this.completeAllToolCallsForMessage(s),n.currentSegmentText!==n.lastEmittedText&&this.emitTextUpdateForMessage(s),n.isComplete=!0;const r=this.messages.find(i=>i.id===s);r&&r.role==="assistant"&&(t=r)}if(this.activeMessageIds.clear(),t&&!this.hasError&&this.isWhitespaceOnlyMessage(t)){this.messages=this.messages.filter(s=>s.id!==t.id),this.emitMessagesChange();return}t&&this.events.onStreamEnd?.(t)}getCompletedToolCalls(){const t=[];for(const s of this.messageStates.values())for(const n of s.toolCalls.values())n.state==="input-complete"&&t.push({id:n.id,type:"function",function:{name:n.name,arguments:n.arguments}});return t}getResult(){const t=this.getCompletedToolCalls();let s="",n="";for(const r of this.messageStates.values())s+=r.totalTextContent,n+=r.thinkingContent;return{content:s,thinking:n||void 0,toolCalls:t.length>0?t:void 0,finishReason:this.finishReason}}getState(){let t="",s="";const n=new Map,r=[];for(const i of this.messageStates.values()){t+=i.totalTextContent,s+=i.thinkingContent;for(const[o,a]of i.toolCalls)n.set(o,a);r.push(...i.toolCallOrder)}return{content:t,thinking:s,toolCalls:n,toolCallOrder:r,finishReason:this.finishReason,done:this.isDone}}startRecording(){this.recordingEnabled=!0,this.recordingStartTime=Date.now(),this.recording={version:"1.0",timestamp:this.recordingStartTime,chunks:[]}}getRecording(){return this.recording}resetStreamState(){this.messageStates.clear(),this.activeMessageIds.clear(),this.activeRuns.clear(),this.toolCallToMessage.clear(),this.pendingManualMessageId=null,this.finishReason=null,this.hasError=!1,this.isDone=!1,this.chunkStrategy.reset?.()}reset(){this.resetStreamState(),this.messages=[]}isWhitespaceOnlyMessage(t){return t.parts.length===0?!1:t.parts.every(s=>s.type==="text"&&s.content.trim()==="")}static async replay(t,s){return new Mr(s).process(Ma(t))}};function Ma(e){return{async*[Symbol.asyncIterator](){for(const{chunk:t}of e.chunks)yield t}}}var _a=class{constructor(e){this.clientId=e}clientCreated(e){this.emitEvent("client:created",{initialMessageCount:e})}loadingChanged(e){this.emitEvent("client:loading:changed",{isLoading:e})}errorChanged(e){this.emitEvent("client:error:changed",{error:e})}textUpdated(e,t,s){this.emitEvent("text:chunk:content",{streamId:e,messageId:t,content:s})}toolCallStateChanged(e,t,s,n,r,i){this.emitEvent("tools:call:updated",{streamId:e,messageId:t,toolCallId:s,toolName:n,state:r,arguments:i})}thinkingUpdated(e,t,s,n){this.emitEvent("text:chunk:thinking",{streamId:e,messageId:t,content:s,delta:n})}approvalRequested(e,t,s,n,r,i){this.emitEvent("tools:approval:requested",{streamId:e,messageId:t,toolCallId:s,toolName:n,input:r,approvalId:i})}messageAppended(e,t){const s=e.parts.filter(n=>n.type==="text").map(n=>n.content).join(" ");this.emitEvent("text:message:created",{streamId:t,messageId:e.id,role:e.role,content:s,parts:e.parts})}messageSent(e,t){const s=typeof t=="string"?t:t.filter(n=>n.type==="text").map(n=>n.content).join("");this.emitEvent("text:message:created",{messageId:e,role:"user",content:s,...Array.isArray(t)&&{parts:t}}),this.emitEvent("text:message:user",{messageId:e,role:"user",content:s,...Array.isArray(t)&&{parts:t}})}reloaded(e){this.emitEvent("client:reloaded",{fromMessageIndex:e})}stopped(){this.emitEvent("client:stopped")}messagesCleared(){this.emitEvent("client:messages:cleared")}toolResultAdded(e,t,s,n){this.emitEvent("tools:result:added",{toolCallId:e,toolName:t,output:s,state:n})}toolApprovalResponded(e,t,s){this.emitEvent("tools:approval:responded",{approvalId:e,toolCallId:t,approved:s})}},Ia=class extends _a{emitEvent(e,t){e.startsWith("client:")||e.startsWith("tools:")||e.startsWith("text:")?xn.emit(e,{...t,clientId:this.clientId,source:"client",timestamp:Date.now()}):xn.emit(e,{...t,timestamp:Date.now()})}};function xa(e){if(!e)return{};if(e instanceof Headers){const t={};return e.forEach((s,n)=>{t[n]=s}),t}return e}async function*Ea(e,t){try{const s=new TextDecoder;let n="";for(;!t?.aborted;){const{done:r,value:i}=await e.read();if(r)break;n+=s.decode(i,{stream:!0});const o=n.split(`
3
+ `);n=o.pop()||"";for(const a of o)a.trim()&&(yield a)}n.trim()&&(yield n)}finally{e.releaseLock()}}function Fn(e){if(!e)throw new Error("Connection adapter is required");const t="connect"in e,s="subscribe"in e,n="send"in e;if(t&&(s||n))throw new Error("Connection adapter must provide either connect or both subscribe and send, not both modes");if(s&&n)return{subscribe:e.subscribe.bind(e),send:e.send.bind(e)};if(!t)throw new Error("Connection adapter must provide either connect or both subscribe and send");let r=[],i=[];function o(a){const u=i.shift();u?u(a):r.push(a)}return{subscribe(a){const u=r.splice(0),l=[];return r=u,i=l,(async function*(){for(;!a?.aborted;){let h;u.length>0?h=u.shift():h=await new Promise(c=>{const d=()=>c(null);l.push(f=>{a?.removeEventListener("abort",d),c(f)}),a?.addEventListener("abort",d,{once:!0})}),h!==null&&(yield h)}})()},async send(a,u,l){let h=!1;try{const c=e.connect(a,u,l);for await(const d of c)(d.type==="RUN_FINISHED"||d.type==="RUN_ERROR")&&(h=!0),o(d);!l?.aborted&&!h&&o({type:"RUN_FINISHED",runId:`run-${Date.now()}`,model:"connect-wrapper",timestamp:Date.now(),finishReason:"stop"})}catch(c){throw!l?.aborted&&!h&&o({type:"RUN_ERROR",timestamp:Date.now(),message:c instanceof Error?c.message:"Unknown error in connect()",error:{message:c instanceof Error?c.message:"Unknown error in connect()"}}),c}}}}function ql(e,t={}){return{async*connect(s,n,r){const i=typeof e=="function"?e():e,o=typeof t=="function"?await t():t,a={"Content-Type":"application/json",...xa(o.headers)},u={messages:s,data:n,...o.body},l=await(o.fetchClient??fetch)(i,{method:"POST",headers:a,body:JSON.stringify(u),credentials:o.credentials||"same-origin",signal:r||o.signal});if(!l.ok)throw new Error(`HTTP error! status: ${l.status} ${l.statusText}`);const h=l.body?.getReader();if(!h)throw new Error("Response body is not readable");for await(const c of Ea(h,r)){const d=c.startsWith("data: ")?c.slice(6):c;if(d==="[DONE]"){console.warn("[@tanstack/ai-client] Received [DONE] sentinel. This is deprecated — upgrade your @tanstack/ai server package. RUN_FINISHED is the stream terminator.");continue}try{yield JSON.parse(d)}catch{console.warn("Failed to parse SSE chunk:",d)}}}}}var La=class{constructor(e){if(this.body={},this.pendingMessageBody=void 0,this.isLoading=!1,this.isSubscribed=!1,this.error=void 0,this.status="ready",this.connectionStatus="disconnected",this.abortController=null,this.currentStreamId=null,this.currentMessageId=null,this.postStreamActions=[],this.pendingToolExecutions=new Map,this.continuationPending=!1,this.subscriptionAbortController=null,this.processingResolve=null,this.errorReportedGeneration=null,this.streamGeneration=0,this.continuationSkipped=!1,this.draining=!1,this.sessionGenerating=!1,this.activeRunIds=new Set,this.uniqueId=e.id||this.generateUniqueId("chat"),this.body=e.body||{},this.connection=Fn(e.connection),this.events=new Ia(this.uniqueId),this.clientToolsRef={current:new Map},e.tools)for(const t of e.tools)this.clientToolsRef.current.set(t.name,t);this.callbacksRef={current:{onResponse:e.onResponse||(()=>{}),onChunk:e.onChunk||(()=>{}),onFinish:e.onFinish||(()=>{}),onError:e.onError||(()=>{}),onMessagesChange:e.onMessagesChange||(()=>{}),onLoadingChange:e.onLoadingChange||(()=>{}),onErrorChange:e.onErrorChange||(()=>{}),onStatusChange:e.onStatusChange||(()=>{}),onSubscriptionChange:e.onSubscriptionChange||(()=>{}),onConnectionStatusChange:e.onConnectionStatusChange||(()=>{}),onSessionGeneratingChange:e.onSessionGeneratingChange||(()=>{}),onCustomEvent:e.onCustomEvent||(()=>{})}},this.processor=new Pa({chunkStrategy:e.streamProcessor?.chunkStrategy,initialMessages:e.initialMessages,events:{onMessagesChange:t=>{this.callbacksRef.current.onMessagesChange(t)},onStreamStart:()=>{this.setStatus("streaming");const t=this.processor.getCurrentAssistantMessageId();if(!t)return;const s=this.processor.getMessages().find(n=>n.id===t);s&&(this.currentMessageId=s.id,this.events.messageAppended(s,this.currentStreamId||void 0))},onStreamEnd:t=>{this.callbacksRef.current.onFinish(t),this.setStatus("ready"),this.resolveProcessing()},onError:t=>{this.reportStreamError(t)},onTextUpdate:(t,s)=>{this.currentStreamId&&this.events.textUpdated(this.currentStreamId,t,s)},onThinkingUpdate:(t,s)=>{this.currentStreamId&&this.events.thinkingUpdated(this.currentStreamId,t,s)},onToolCallStateChange:(t,s,n,r)=>{const i=this.processor.getMessages().find(o=>o.id===t)?.parts.find(o=>o.type==="tool-call"&&o.id===s)?.name||"unknown";this.currentStreamId&&this.events.toolCallStateChanged(this.currentStreamId,t,s,i,n,r)},onToolCall:t=>{const s=this.clientToolsRef.current.get(t.toolName)?.execute;if(s){const n=(async()=>{try{const r=await s(t.input);await this.addToolResult({toolCallId:t.toolCallId,tool:t.toolName,output:r,state:"output-available"})}catch(r){await this.addToolResult({toolCallId:t.toolCallId,tool:t.toolName,output:null,state:"output-error",errorText:r.message})}finally{this.pendingToolExecutions.delete(t.toolCallId)}})();this.pendingToolExecutions.set(t.toolCallId,n)}},onApprovalRequest:t=>{this.currentStreamId&&this.events.approvalRequested(this.currentStreamId,this.currentMessageId||"",t.toolCallId,t.toolName,t.input,t.approvalId)},onCustomEvent:(t,s,n)=>{this.callbacksRef.current.onCustomEvent(t,s,n)}}}),this.events.clientCreated(this.processor.getMessages().length)}generateUniqueId(e){return`${e}-${Date.now()}-${Math.random().toString(36).substring(7)}`}setIsLoading(e){this.isLoading=e,this.callbacksRef.current.onLoadingChange(e),this.events.loadingChanged(e)}setStatus(e){this.status=e,this.callbacksRef.current.onStatusChange(e)}setIsSubscribed(e){this.isSubscribed=e,this.callbacksRef.current.onSubscriptionChange(e)}setConnectionStatus(e){this.connectionStatus=e,this.callbacksRef.current.onConnectionStatusChange(e)}setSessionGenerating(e){this.sessionGenerating!==e&&(this.sessionGenerating=e,this.callbacksRef.current.onSessionGeneratingChange(e))}resetSessionGenerating(){this.activeRunIds.clear(),this.setSessionGenerating(!1)}setError(e){this.error=e,this.callbacksRef.current.onErrorChange(e),this.events.errorChanged(e?.message||null)}abortSubscriptionLoop(){this.subscriptionAbortController?.abort(),this.subscriptionAbortController=null}resolveProcessing(){this.processingResolve?.(),this.processingResolve=null}cancelInFlightStream(e){this.abortController?.abort(),this.abortController=null,e?.abortSubscription&&this.abortSubscriptionLoop(),this.resolveProcessing(),this.setIsLoading(!1),e?.setReadyStatus&&this.setStatus("ready")}reportStreamError(e){const t=this.errorReportedGeneration===this.streamGeneration;this.setError(e),(this.isLoading||this.status==="submitted"||this.status==="streaming")&&this.setStatus("error"),t||(this.errorReportedGeneration=this.streamGeneration,this.callbacksRef.current.onError(e))}startSubscription(){this.subscriptionAbortController=new AbortController;const e=this.subscriptionAbortController.signal;this.consumeSubscription(e).catch(t=>{t instanceof Error&&t.name!=="AbortError"&&(this.setConnectionStatus("error"),this.resetSessionGenerating(),this.setIsSubscribed(!1),this.reportStreamError(t)),this.resolveProcessing()}).finally(()=>{this.subscriptionAbortController?.signal===e&&(this.subscriptionAbortController=null,!e.aborted&&this.isSubscribed&&(this.setIsSubscribed(!1),this.connectionStatus!=="error"&&this.setConnectionStatus("disconnected")))})}async consumeSubscription(e){const t=this.connection.subscribe(e);for await(const s of t){if(e.aborted)break;if(this.connectionStatus==="connecting"&&this.setConnectionStatus("connected"),this.callbacksRef.current.onChunk(s),this.processor.processChunk(s),s.type==="RUN_STARTED"&&(this.activeRunIds.add(s.runId),this.setSessionGenerating(!0)),s.type==="RUN_FINISHED"||s.type==="RUN_ERROR"){const n=s.type==="RUN_FINISHED"?s.runId:void 0;n?this.activeRunIds.delete(n):s.type==="RUN_ERROR"&&this.activeRunIds.clear(),this.setSessionGenerating(this.activeRunIds.size>0),this.resolveProcessing()}await new Promise(n=>setTimeout(n,0))}}ensureSubscription(){if(!this.isSubscribed){this.subscribe();return}(!this.subscriptionAbortController||this.subscriptionAbortController.signal.aborted)&&this.subscribe({restart:!0})}waitForProcessing(){return this.resolveProcessing(),new Promise(e=>{this.processingResolve=e})}async sendMessage(e,t){if(typeof e=="string"&&!e.trim()||this.isLoading)return;const s=this.normalizeMessageInput(e);this.pendingMessageBody=t;const n=this.processor.addUserMessage(s.content,s.id);this.events.messageSent(n.id,s.content),await this.streamResponse()}normalizeMessageInput(e){return typeof e=="string"?{content:e.trim()}:{content:e.content,id:e.id}}async append(e){const t=pa(e,bt);if(t.role==="system")return;const s=t;this.events.messageAppended(s);const n=this.processor.getMessages();if(this.processor.setMessages([...n,s]),this.isLoading){this.queuePostStreamAction(async()=>{await this.streamResponse()});return}await this.streamResponse()}async streamResponse(){if(this.isLoading)return!1;const e=++this.streamGeneration;this.setIsLoading(!0),this.setStatus("submitted"),this.setError(void 0),this.errorReportedGeneration=null,this.abortController=new AbortController,this.pendingToolExecutions.clear();let t=!1;try{const s=this.processor.getMessages();await this.callbacksRef.current.onResponse();const n={...this.body,...this.pendingMessageBody,conversationId:this.uniqueId};this.pendingMessageBody=void 0,this.currentStreamId=this.generateUniqueId("stream"),this.currentMessageId=null,this.processor.prepareAssistantMessage(),this.ensureSubscription();const r=this.waitForProcessing();if(await this.connection.send(s,n,this.abortController.signal),await r,e!==this.streamGeneration||this.status==="error")return!1;this.pendingToolExecutions.size>0&&await Promise.all(this.pendingToolExecutions.values()),this.processor.finalizeStream(),t=!0}catch(s){if(s instanceof Error){if(s.name==="AbortError")return!1;e===this.streamGeneration&&this.reportStreamError(s)}}finally{if(e===this.streamGeneration&&(this.currentStreamId=null,this.currentMessageId=null,this.abortController=null,this.setIsLoading(!1),this.pendingMessageBody=void 0,await this.drainPostStreamActions(),t)){const s=this.processor.getMessages().at(-1)?.parts.at(-1),{finishReason:n}=this.processor.getState();if(s?.type==="tool-result"&&n!=="stop"&&this.shouldAutoSend())try{await this.checkForContinuation()}catch(r){console.error("Failed to continue flow after tool result:",r)}}}return t}subscribe(e){const t=e?.restart===!0;this.isSubscribed&&!t||(this.isSubscribed&&t&&this.abortSubscriptionLoop(),this.setIsSubscribed(!0),this.setConnectionStatus("connecting"),this.startSubscription())}unsubscribe(){this.cancelInFlightStream({setReadyStatus:!0,abortSubscription:!0}),this.resetSessionGenerating(),this.setIsSubscribed(!1),this.setConnectionStatus("disconnected")}async reload(){const e=this.processor.getMessages();if(e.length===0)return;const t=e.findLastIndex(s=>s.role==="user");t!==-1&&(this.isLoading&&this.cancelInFlightStream(),this.events.reloaded(t),this.processor.removeMessagesAfter(t),await this.streamResponse())}stop(){this.cancelInFlightStream({setReadyStatus:!0}),this.events.stopped()}clear(){this.processor.clearMessages(),this.setError(void 0),this.events.messagesCleared()}async addToolResult(e){if(this.events.toolResultAdded(e.toolCallId,e.tool,e.output,e.state||"output-available"),this.processor.addToolResult(e.toolCallId,e.output,e.errorText),this.isLoading){this.queuePostStreamAction(()=>this.checkForContinuation());return}await this.checkForContinuation()}async addToolApprovalResponse(e){const t=this.processor.getMessages();let s;for(const n of t){const r=n.parts.find(i=>i.type==="tool-call"&&i.approval?.id===e.id);if(r){s=r.id;break}}if(s&&this.events.toolApprovalResponded(e.id,s,e.approved),this.processor.addToolApprovalResponse(e.id,e.approved),this.isLoading){this.queuePostStreamAction(()=>this.checkForContinuation());return}await this.checkForContinuation()}queuePostStreamAction(e){this.postStreamActions.push(e)}async drainPostStreamActions(){if(!this.draining){this.draining=!0;try{for(;this.postStreamActions.length>0;)await this.postStreamActions.shift()()}finally{this.draining=!1}}}async checkForContinuation(){if(this.continuationPending||this.isLoading){this.continuationSkipped=!0;return}if(this.shouldAutoSend()){this.continuationPending=!0,this.continuationSkipped=!1;let e=!1;try{e=await this.streamResponse()}finally{this.continuationPending=!1}this.continuationSkipped&&e&&(this.continuationSkipped=!1,await this.checkForContinuation())}}shouldAutoSend(){const e=this.processor.getMessages().findLast(t=>t.role==="assistant");return!e||!e.parts.some(t=>t.type==="tool-call")?!1:this.processor.areAllToolsComplete()}getMessages(){return this.processor.getMessages()}getIsLoading(){return this.isLoading}getStatus(){return this.status}getIsSubscribed(){return this.isSubscribed}getConnectionStatus(){return this.connectionStatus}getSessionGenerating(){return this.sessionGenerating}getError(){return this.error}setMessagesManually(e){this.processor.setMessages(e)}updateOptions(e){if(e.connection!==void 0){const t=this.isSubscribed;this.isLoading?this.cancelInFlightStream({setReadyStatus:!0,abortSubscription:!0}):t&&this.abortSubscriptionLoop(),this.resetSessionGenerating(),this.setIsSubscribed(!1),this.setConnectionStatus("disconnected"),this.connection=Fn(e.connection),t&&this.subscribe()}if(e.body!==void 0&&(this.body=e.body),e.tools!==void 0){this.clientToolsRef.current=new Map;for(const t of e.tools)this.clientToolsRef.current.set(t.name,t)}e.onResponse!==void 0&&(this.callbacksRef.current.onResponse=e.onResponse),e.onChunk!==void 0&&(this.callbacksRef.current.onChunk=e.onChunk),e.onFinish!==void 0&&(this.callbacksRef.current.onFinish=e.onFinish),e.onError!==void 0&&(this.callbacksRef.current.onError=e.onError),e.onSubscriptionChange!==void 0&&(this.callbacksRef.current.onSubscriptionChange=e.onSubscriptionChange),e.onConnectionStatusChange!==void 0&&(this.callbacksRef.current.onConnectionStatusChange=e.onConnectionStatusChange),e.onSessionGeneratingChange!==void 0&&(this.callbacksRef.current.onSessionGeneratingChange=e.onSessionGeneratingChange),e.onCustomEvent!==void 0&&(this.callbacksRef.current.onCustomEvent=e.onCustomEvent)}};function Wl(e){const t=(0,R.useId)(),s=e.id||t,[n,r]=(0,R.useState)(e.initialMessages||[]),[i,o]=(0,R.useState)(!1),[a,u]=(0,R.useState)(void 0),[l,h]=(0,R.useState)("ready"),[c,d]=(0,R.useState)(!1),[f,g]=(0,R.useState)("disconnected"),[p,v]=(0,R.useState)(!1),m=(0,R.useRef)(e.initialMessages||[]),y=(0,R.useRef)(!0);m.current=n;const C=(0,R.useRef)(e);C.current=e;const S=(0,R.useMemo)(()=>{const x=y.current?e.initialMessages||[]:m.current;return y.current=!1,new La({connection:C.current.connection,id:s,initialMessages:x,body:C.current.body,onResponse:M=>C.current.onResponse?.(M),onChunk:M=>C.current.onChunk?.(M),onFinish:M=>{C.current.onFinish?.(M)},onError:M=>{C.current.onError?.(M)},tools:C.current.tools,onCustomEvent:(M,A,D)=>C.current.onCustomEvent?.(M,A,D),streamProcessor:e.streamProcessor,onMessagesChange:M=>{r(M)},onLoadingChange:M=>{o(M)},onErrorChange:M=>{u(M)},onStatusChange:M=>{h(M)},onSubscriptionChange:M=>{d(M)},onConnectionStatusChange:M=>{g(M)},onSessionGeneratingChange:M=>{v(M)}})},[s]);(0,R.useEffect)(()=>{S.updateOptions({body:e.body})},[S,e.body]),(0,R.useEffect)(()=>{e.initialMessages&&e.initialMessages.length>0&&n.length===0&&S.setMessagesManually(e.initialMessages)},[]),(0,R.useEffect)(()=>{e.live?S.subscribe():S.unsubscribe()},[S,e.live]),(0,R.useEffect)(()=>()=>{e.live?S.unsubscribe():S.stop()},[S,e.live]);const w=(0,R.useCallback)(async x=>{await S.sendMessage(x)},[S]),_=(0,R.useCallback)(async x=>{await S.append(x)},[S]),P=(0,R.useCallback)(async()=>{await S.reload()},[S]),b=(0,R.useCallback)(()=>{S.stop()},[S]),I=(0,R.useCallback)(()=>{S.clear()},[S]);return{messages:n,sendMessage:w,append:_,reload:P,stop:b,isLoading:i,error:a,status:l,isSubscribed:c,connectionStatus:f,sessionGenerating:p,setMessages:(0,R.useCallback)(x=>{S.setMessagesManually(x)},[S]),clear:I,addToolResult:(0,R.useCallback)(async x=>{await S.addToolResult(x)},[S]),addToolApprovalResponse:(0,R.useCallback)(async x=>{await S.addToolApprovalResponse(x)},[S])}}var Kl=new Uint8Array(128).fill(128);function de(e,t){return typeof e=="function"?e(t):e}function Q(e,t){return s=>{t.setState(n=>({...n,[e]:de(s,n[e])}))}}function It(e){return e instanceof Function}function Ta(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function Oa(e,t){const s=[],n=r=>{r.forEach(i=>{s.push(i);const o=t(i);o!=null&&o.length&&n(o)})};return n(e),s}function L(e,t,s){let n=[],r;return i=>{let o;s.key&&s.debug&&(o=Date.now());const a=e(i);if(!(a.length!==n.length||a.some((l,h)=>n[h]!==l)))return r;n=a;let u;if(s.key&&s.debug&&(u=Date.now()),r=t(...a),s==null||s.onChange==null||s.onChange(r),s.key&&s.debug&&s!=null&&s.debug()){const l=Math.round((Date.now()-o)*100)/100,h=Math.round((Date.now()-u)*100)/100,c=h/16,d=(f,g)=>{for(f=String(f);f.length<g;)f=" "+f;return f};console.info(`%c⏱ ${d(h,5)} /${d(l,5)} ms`,`
4
+ font-size: .6rem;
5
+ font-weight: bold;
6
+ color: hsl(${Math.max(0,Math.min(120-120*c,120))}deg 100% 31%);`,s?.key)}return r}}function T(e,t,s,n){return{debug:()=>{var r;return(r=e?.debugAll)!=null?r:e[t]},key:!1,onChange:n}}function Fa(e,t,s,n){const r=()=>{var o;return(o=i.getValue())!=null?o:e.options.renderFallbackValue},i={id:`${t.id}_${s.id}`,row:t,column:s,getValue:()=>t.getValue(n),renderValue:r,getContext:L(()=>[e,s,t,i],(o,a,u,l)=>({table:o,column:a,row:u,cell:l,getValue:l.getValue,renderValue:l.renderValue}),T(e.options,"debugCells","cell.getContext"))};return e._features.forEach(o=>{o.createCell==null||o.createCell(i,s,t,e)},{}),i}function Aa(e,t,s,n){var r,i;const o={...e._getDefaultColumnDef(),...t},a=o.accessorKey;let u=(r=(i=o.id)!=null?i:a?typeof String.prototype.replaceAll=="function"?a.replaceAll(".","_"):a.replace(/\./g,"_"):void 0)!=null?r:typeof o.header=="string"?o.header:void 0,l;if(o.accessorFn?l=o.accessorFn:a&&(a.includes(".")?l=c=>{let d=c;for(const g of a.split(".")){var f;d=(f=d)==null?void 0:f[g]}return d}:l=c=>c[o.accessorKey]),!u)throw new Error;let h={id:`${String(u)}`,accessorFn:l,parent:n,depth:s,columnDef:o,columns:[],getFlatColumns:L(()=>[!0],()=>{var c;return[h,...(c=h.columns)==null?void 0:c.flatMap(d=>d.getFlatColumns())]},T(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:L(()=>[e._getOrderColumnsFn()],c=>{var d;return(d=h.columns)!=null&&d.length?c(h.columns.flatMap(f=>f.getLeafColumns())):[h]},T(e.options,"debugColumns","column.getLeafColumns"))};for(const c of e._features)c.createColumn==null||c.createColumn(h,e);return h}var B="debugHeaders";function An(e,t,s){var n;let r={id:(n=s.id)!=null?n:t.id,column:t,index:s.index,isPlaceholder:!!s.isPlaceholder,placeholderId:s.placeholderId,depth:s.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const i=[],o=a=>{a.subHeaders&&a.subHeaders.length&&a.subHeaders.map(o),i.push(a)};return o(r),i},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(i=>{i.createHeader==null||i.createHeader(r,e)}),r}var ka={createTable:e=>{e.getHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,s,n,r)=>{var i,o;const a=(i=n?.map(h=>s.find(c=>c.id===h)).filter(Boolean))!=null?i:[],u=(o=r?.map(h=>s.find(c=>c.id===h)).filter(Boolean))!=null?o:[],l=s.filter(h=>!(n!=null&&n.includes(h.id))&&!(r!=null&&r.includes(h.id)));return ct(t,[...a,...l,...u],e)},T(e.options,B,"getHeaderGroups")),e.getCenterHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,s,n,r)=>(s=s.filter(i=>!(n!=null&&n.includes(i.id))&&!(r!=null&&r.includes(i.id))),ct(t,s,e,"center")),T(e.options,B,"getCenterHeaderGroups")),e.getLeftHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,s,n)=>{var r;return ct(t,(r=n?.map(i=>s.find(o=>o.id===i)).filter(Boolean))!=null?r:[],e,"left")},T(e.options,B,"getLeftHeaderGroups")),e.getRightHeaderGroups=L(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,s,n)=>{var r;return ct(t,(r=n?.map(i=>s.find(o=>o.id===i)).filter(Boolean))!=null?r:[],e,"right")},T(e.options,B,"getRightHeaderGroups")),e.getFooterGroups=L(()=>[e.getHeaderGroups()],t=>[...t].reverse(),T(e.options,B,"getFooterGroups")),e.getLeftFooterGroups=L(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),T(e.options,B,"getLeftFooterGroups")),e.getCenterFooterGroups=L(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),T(e.options,B,"getCenterFooterGroups")),e.getRightFooterGroups=L(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),T(e.options,B,"getRightFooterGroups")),e.getFlatHeaders=L(()=>[e.getHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,B,"getFlatHeaders")),e.getLeftFlatHeaders=L(()=>[e.getLeftHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,B,"getLeftFlatHeaders")),e.getCenterFlatHeaders=L(()=>[e.getCenterHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,B,"getCenterFlatHeaders")),e.getRightFlatHeaders=L(()=>[e.getRightHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,B,"getRightFlatHeaders")),e.getCenterLeafHeaders=L(()=>[e.getCenterFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,B,"getCenterLeafHeaders")),e.getLeftLeafHeaders=L(()=>[e.getLeftFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,B,"getLeftLeafHeaders")),e.getRightLeafHeaders=L(()=>[e.getRightFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,B,"getRightLeafHeaders")),e.getLeafHeaders=L(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,s,n)=>{var r,i,o,a,u,l;return[...(r=(i=t[0])==null?void 0:i.headers)!=null?r:[],...(o=(a=s[0])==null?void 0:a.headers)!=null?o:[],...(u=(l=n[0])==null?void 0:l.headers)!=null?u:[]].map(h=>h.getLeafHeaders()).flat()},T(e.options,B,"getLeafHeaders"))}};function ct(e,t,s,n){var r,i;let o=0;const a=function(c,d){d===void 0&&(d=1),o=Math.max(o,d),c.filter(f=>f.getIsVisible()).forEach(f=>{var g;(g=f.columns)!=null&&g.length&&a(f.columns,d+1)},0)};a(e);let u=[];const l=(c,d)=>{const f={depth:d,id:[n,`${d}`].filter(Boolean).join("_"),headers:[]},g=[];c.forEach(p=>{const v=[...g].reverse()[0],m=p.column.depth===f.depth;let y,C=!1;if(m&&p.column.parent?y=p.column.parent:(y=p.column,C=!0),v&&v?.column===y)v.subHeaders.push(p);else{const S=An(s,y,{id:[n,d,y.id,p?.id].filter(Boolean).join("_"),isPlaceholder:C,placeholderId:C?`${g.filter(w=>w.column===y).length}`:void 0,depth:d,index:g.length});S.subHeaders.push(p),g.push(S)}f.headers.push(p),p.headerGroup=f}),u.push(f),d>0&&l(g,d-1)};l(t.map((c,d)=>An(s,c,{depth:o,index:d})),o-1),u.reverse();const h=c=>c.filter(d=>d.column.getIsVisible()).map(d=>{let f=0,g=0,p=[0];d.subHeaders&&d.subHeaders.length?(p=[],h(d.subHeaders).forEach(m=>{let{colSpan:y,rowSpan:C}=m;f+=y,p.push(C)})):f=1;const v=Math.min(...p);return g=g+v,d.colSpan=f,d.rowSpan=g,{colSpan:f,rowSpan:g}});return h((r=(i=u[0])==null?void 0:i.headers)!=null?r:[]),u}var Da=(e,t,s,n,r,i,o)=>{let a={id:t,index:n,original:s,depth:r,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:u=>{if(a._valuesCache.hasOwnProperty(u))return a._valuesCache[u];const l=e.getColumn(u);if(l!=null&&l.accessorFn)return a._valuesCache[u]=l.accessorFn(a.original,n),a._valuesCache[u]},getUniqueValues:u=>{if(a._uniqueValuesCache.hasOwnProperty(u))return a._uniqueValuesCache[u];const l=e.getColumn(u);if(l!=null&&l.accessorFn)return l.columnDef.getUniqueValues?(a._uniqueValuesCache[u]=l.columnDef.getUniqueValues(a.original,n),a._uniqueValuesCache[u]):(a._uniqueValuesCache[u]=[a.getValue(u)],a._uniqueValuesCache[u])},renderValue:u=>{var l;return(l=a.getValue(u))!=null?l:e.options.renderFallbackValue},subRows:i??[],getLeafRows:()=>Oa(a.subRows,u=>u.subRows),getParentRow:()=>a.parentId?e.getRow(a.parentId,!0):void 0,getParentRows:()=>{let u=[],l=a;for(;;){const h=l.getParentRow();if(!h)break;u.push(h),l=h}return u.reverse()},getAllCells:L(()=>[e.getAllLeafColumns()],u=>u.map(l=>Fa(e,a,l,l.id)),T(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:L(()=>[a.getAllCells()],u=>u.reduce((l,h)=>(l[h.column.id]=h,l),{}),T(e.options,"debugRows","getAllCellsByColumnId"))};for(let u=0;u<e._features.length;u++){const l=e._features[u];l==null||l.createRow==null||l.createRow(a,e)}return a},$a={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},_r=(e,t,s)=>{var n,r;const i=s==null||(n=s.toString())==null?void 0:n.toLowerCase();return!!(!((r=e.getValue(t))==null||(r=r.toString())==null||(r=r.toLowerCase())==null)&&r.includes(i))};_r.autoRemove=e=>te(e);var Ir=(e,t,s)=>{var n;return!!(!((n=e.getValue(t))==null||(n=n.toString())==null)&&n.includes(s))};Ir.autoRemove=e=>te(e);var xr=(e,t,s)=>{var n;return((n=e.getValue(t))==null||(n=n.toString())==null?void 0:n.toLowerCase())===s?.toLowerCase()};xr.autoRemove=e=>te(e);var Er=(e,t,s)=>{var n;return(n=e.getValue(t))==null?void 0:n.includes(s)};Er.autoRemove=e=>te(e);var Lr=(e,t,s)=>!s.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});Lr.autoRemove=e=>te(e)||!(e!=null&&e.length);var Tr=(e,t,s)=>s.some(n=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)});Tr.autoRemove=e=>te(e)||!(e!=null&&e.length);var Or=(e,t,s)=>e.getValue(t)===s;Or.autoRemove=e=>te(e);var Fr=(e,t,s)=>e.getValue(t)==s;Fr.autoRemove=e=>te(e);var Ms=(e,t,s)=>{let[n,r]=s;const i=e.getValue(t);return i>=n&&i<=r};Ms.resolveFilterValue=e=>{let[t,s]=e,n=typeof t!="number"?parseFloat(t):t,r=typeof s!="number"?parseFloat(s):s,i=t===null||Number.isNaN(n)?-1/0:n,o=s===null||Number.isNaN(r)?1/0:r;if(i>o){const a=i;i=o,o=a}return[i,o]};Ms.autoRemove=e=>te(e)||te(e[0])&&te(e[1]);var re={includesString:_r,includesStringSensitive:Ir,equalsString:xr,arrIncludes:Er,arrIncludesAll:Lr,arrIncludesSome:Tr,equals:Or,weakEquals:Fr,inNumberRange:Ms};function te(e){return e==null||e===""}var Na={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:Q("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const s=t.getCoreRowModel().flatRows[0],n=s?.getValue(e.id);return typeof n=="string"?re.includesString:typeof n=="number"?re.inNumberRange:typeof n=="boolean"||n!==null&&typeof n=="object"?re.equals:Array.isArray(n)?re.arrIncludes:re.weakEquals},e.getFilterFn=()=>{var s,n;return It(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(s=(n=t.options.filterFns)==null?void 0:n[e.columnDef.filterFn])!=null?s:re[e.columnDef.filterFn]},e.getCanFilter=()=>{var s,n,r;return((s=e.columnDef.enableColumnFilter)!=null?s:!0)&&((n=t.options.enableColumnFilters)!=null?n:!0)&&((r=t.options.enableFilters)!=null?r:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var s;return(s=t.getState().columnFilters)==null||(s=s.find(n=>n.id===e.id))==null?void 0:s.value},e.getFilterIndex=()=>{var s,n;return(s=(n=t.getState().columnFilters)==null?void 0:n.findIndex(r=>r.id===e.id))!=null?s:-1},e.setFilterValue=s=>{t.setColumnFilters(n=>{const r=e.getFilterFn(),i=n?.find(h=>h.id===e.id),o=de(s,i?i.value:void 0);if(kn(r,o,e)){var a;return(a=n?.filter(h=>h.id!==e.id))!=null?a:[]}const u={id:e.id,value:o};if(i){var l;return(l=n?.map(h=>h.id===e.id?u:h))!=null?l:[]}return n!=null&&n.length?[...n,u]:[u]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const s=e.getAllLeafColumns(),n=r=>{var i;return(i=de(t,r))==null?void 0:i.filter(o=>{const a=s.find(u=>u.id===o.id);return!(a&&kn(a.getFilterFn(),o.value,a))})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(n)},e.resetColumnFilters=t=>{var s,n;e.setColumnFilters(t?[]:(s=(n=e.initialState)==null?void 0:n.columnFilters)!=null?s:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function kn(e,t,s){return(e&&e.autoRemove?e.autoRemove(t,s):!1)||typeof t>"u"||typeof t=="string"&&!t}var Va=(e,t,s)=>s.reduce((n,r)=>{const i=r.getValue(e);return n+(typeof i=="number"?i:0)},0),Ba=(e,t,s)=>{let n;return s.forEach(r=>{const i=r.getValue(e);i!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}),n},za=(e,t,s)=>{let n;return s.forEach(r=>{const i=r.getValue(e);i!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}),n},Ha=(e,t,s)=>{let n,r;return s.forEach(i=>{const o=i.getValue(e);o!=null&&(n===void 0?o>=o&&(n=r=o):(n>o&&(n=o),r<o&&(r=o)))}),[n,r]},Ua=(e,t)=>{let s=0,n=0;if(t.forEach(r=>{let i=r.getValue(e);i!=null&&(i=+i)>=i&&(++s,n+=i)}),s)return n/s},ja=(e,t)=>{if(!t.length)return;const s=t.map(i=>i.getValue(e));if(!Ta(s))return;if(s.length===1)return s[0];const n=Math.floor(s.length/2),r=s.sort((i,o)=>i-o);return s.length%2!==0?r[n]:(r[n-1]+r[n])/2},Ga=(e,t)=>Array.from(new Set(t.map(s=>s.getValue(e))).values()),qa=(e,t)=>new Set(t.map(s=>s.getValue(e))).size,Wa=(e,t)=>t.length,jt={sum:Va,min:Ba,max:za,extent:Ha,mean:Ua,median:ja,unique:Ga,uniqueCount:qa,count:Wa},Ka={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,s;return(t=(s=e.getValue())==null||s.toString==null?void 0:s.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:Q("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(s=>s!=null&&s.includes(e.id)?s.filter(n=>n!==e.id):[...s??[],e.id])},e.getCanGroup=()=>{var s,n;return((s=e.columnDef.enableGrouping)!=null?s:!0)&&((n=t.options.enableGrouping)!=null?n:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var s;return(s=t.getState().grouping)==null?void 0:s.includes(e.id)},e.getGroupedIndex=()=>{var s;return(s=t.getState().grouping)==null?void 0:s.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const s=e.getCanGroup();return()=>{s&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const s=t.getCoreRowModel().flatRows[0],n=s?.getValue(e.id);if(typeof n=="number")return jt.sum;if(Object.prototype.toString.call(n)==="[object Date]")return jt.extent},e.getAggregationFn=()=>{var s,n;if(!e)throw new Error;return It(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(s=(n=t.options.aggregationFns)==null?void 0:n[e.columnDef.aggregationFn])!=null?s:jt[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var s,n;e.setGrouping(t?[]:(s=(n=e.initialState)==null?void 0:n.grouping)!=null?s:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=s=>{if(e._groupingValuesCache.hasOwnProperty(s))return e._groupingValuesCache[s];const n=t.getColumn(s);return n!=null&&n.columnDef.getGroupingValue?(e._groupingValuesCache[s]=n.columnDef.getGroupingValue(e.original),e._groupingValuesCache[s]):e.getValue(s)},e._groupingValuesCache={}},createCell:(e,t,s,n)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===s.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var r;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((r=s.subRows)!=null&&r.length)}}};function Qa(e,t,s){if(!(t!=null&&t.length)||!s)return e;const n=e.filter(r=>!t.includes(r.id));return s==="remove"?n:[...t.map(r=>e.find(i=>i.id===r)).filter(Boolean),...n]}var Ja={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:Q("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=L(s=>[Je(t,s)],s=>s.findIndex(n=>n.id===e.id),T(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=s=>{var n;return((n=Je(t,s)[0])==null?void 0:n.id)===e.id},e.getIsLastColumn=s=>{var n;const r=Je(t,s);return((n=r[r.length-1])==null?void 0:n.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var s;e.setColumnOrder(t?[]:(s=e.initialState.columnOrder)!=null?s:[])},e._getOrderColumnsFn=L(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,s,n)=>r=>{let i=[];if(!(t!=null&&t.length))i=r;else{const o=[...t],a=[...r];for(;a.length&&o.length;){const u=o.shift(),l=a.findIndex(h=>h.id===u);l>-1&&i.push(a.splice(l,1)[0])}i=[...i,...a]}return Qa(i,s,n)},T(e.options,"debugTable","_getOrderColumnsFn"))}},Gt=()=>({left:[],right:[]}),Ya={getInitialState:e=>({columnPinning:Gt(),...e}),getDefaultOptions:e=>({onColumnPinningChange:Q("columnPinning",e)}),createColumn:(e,t)=>{e.pin=s=>{const n=e.getLeafColumns().map(r=>r.id).filter(Boolean);t.setColumnPinning(r=>{var i,o;if(s==="right"){var a,u;return{left:((a=r?.left)!=null?a:[]).filter(c=>!(n!=null&&n.includes(c))),right:[...((u=r?.right)!=null?u:[]).filter(c=>!(n!=null&&n.includes(c))),...n]}}if(s==="left"){var l,h;return{left:[...((l=r?.left)!=null?l:[]).filter(c=>!(n!=null&&n.includes(c))),...n],right:((h=r?.right)!=null?h:[]).filter(c=>!(n!=null&&n.includes(c)))}}return{left:((i=r?.left)!=null?i:[]).filter(c=>!(n!=null&&n.includes(c))),right:((o=r?.right)!=null?o:[]).filter(c=>!(n!=null&&n.includes(c)))}})},e.getCanPin=()=>e.getLeafColumns().some(s=>{var n,r,i;return((n=s.columnDef.enablePinning)!=null?n:!0)&&((r=(i=t.options.enableColumnPinning)!=null?i:t.options.enablePinning)!=null?r:!0)}),e.getIsPinned=()=>{const s=e.getLeafColumns().map(a=>a.id),{left:n,right:r}=t.getState().columnPinning,i=s.some(a=>n?.includes(a)),o=s.some(a=>r?.includes(a));return i?"left":o?"right":!1},e.getPinnedIndex=()=>{var s,n;const r=e.getIsPinned();return r?(s=(n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))!=null?s:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=L(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(s,n,r)=>{const i=[...n??[],...r??[]];return s.filter(o=>!i.includes(o.column.id))},T(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=L(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(s,n)=>(n??[]).map(r=>s.find(i=>i.column.id===r)).filter(Boolean).map(r=>({...r,position:"left"})),T(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=L(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(s,n)=>(n??[]).map(r=>s.find(i=>i.column.id===r)).filter(Boolean).map(r=>({...r,position:"right"})),T(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var s,n;return e.setColumnPinning(t?Gt():(s=(n=e.initialState)==null?void 0:n.columnPinning)!=null?s:Gt())},e.getIsSomeColumnsPinned=t=>{var s;const n=e.getState().columnPinning;if(!t){var r,i;return!!((r=n.left)!=null&&r.length||(i=n.right)!=null&&i.length)}return!!((s=n[t])!=null&&s.length)},e.getLeftLeafColumns=L(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,s)=>(s??[]).map(n=>t.find(r=>r.id===n)).filter(Boolean),T(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=L(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,s)=>(s??[]).map(n=>t.find(r=>r.id===n)).filter(Boolean),T(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=L(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,s,n)=>{const r=[...s??[],...n??[]];return t.filter(i=>!r.includes(i.id))},T(e.options,"debugColumns","getCenterLeafColumns"))}};function Xa(e){return e||(typeof document<"u"?document:null)}var dt={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},qt=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),Za={getDefaultColumnDef:()=>dt,getInitialState:e=>({columnSizing:{},columnSizingInfo:qt(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:Q("columnSizing",e),onColumnSizingInfoChange:Q("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var s,n,r;const i=t.getState().columnSizing[e.id];return Math.min(Math.max((s=e.columnDef.minSize)!=null?s:dt.minSize,(n=i??e.columnDef.size)!=null?n:dt.size),(r=e.columnDef.maxSize)!=null?r:dt.maxSize)},e.getStart=L(s=>[s,Je(t,s),t.getState().columnSizing],(s,n)=>n.slice(0,e.getIndex(s)).reduce((r,i)=>r+i.getSize(),0),T(t.options,"debugColumns","getStart")),e.getAfter=L(s=>[s,Je(t,s),t.getState().columnSizing],(s,n)=>n.slice(e.getIndex(s)+1).reduce((r,i)=>r+i.getSize(),0),T(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(s=>{let{[e.id]:n,...r}=s;return r})},e.getCanResize=()=>{var s,n;return((s=e.columnDef.enableResizing)!=null?s:!0)&&((n=t.options.enableColumnResizing)!=null?n:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let s=0;const n=r=>{if(r.subHeaders.length)r.subHeaders.forEach(n);else{var i;s+=(i=r.column.getSize())!=null?i:0}};return n(e),s},e.getStart=()=>{if(e.index>0){const s=e.headerGroup.headers[e.index-1];return s.getStart()+s.getSize()}return 0},e.getResizeHandler=s=>{const n=t.getColumn(e.column.id),r=n?.getCanResize();return i=>{if(!n||!r||(i.persist==null||i.persist(),Wt(i)&&i.touches&&i.touches.length>1))return;const o=e.getSize(),a=e?e.getLeafHeaders().map(m=>[m.column.id,m.column.getSize()]):[[n.id,n.getSize()]],u=Wt(i)?Math.round(i.touches[0].clientX):i.clientX,l={},h=(m,y)=>{typeof y=="number"&&(t.setColumnSizingInfo(C=>{var S,w;const _=t.options.columnResizeDirection==="rtl"?-1:1,P=(y-((S=C?.startOffset)!=null?S:0))*_,b=Math.max(P/((w=C?.startSize)!=null?w:0),-.999999);return C.columnSizingStart.forEach(I=>{let[x,M]=I;l[x]=Math.round(Math.max(M+M*b,0)*100)/100}),{...C,deltaOffset:P,deltaPercentage:b}}),(t.options.columnResizeMode==="onChange"||m==="end")&&t.setColumnSizing(C=>({...C,...l})))},c=m=>h("move",m),d=m=>{h("end",m),t.setColumnSizingInfo(y=>({...y,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},f=Xa(s),g={moveHandler:m=>c(m.clientX),upHandler:m=>{f?.removeEventListener("mousemove",g.moveHandler),f?.removeEventListener("mouseup",g.upHandler),d(m.clientX)}},p={moveHandler:m=>(m.cancelable&&(m.preventDefault(),m.stopPropagation()),c(m.touches[0].clientX),!1),upHandler:m=>{var y;f?.removeEventListener("touchmove",p.moveHandler),f?.removeEventListener("touchend",p.upHandler),m.cancelable&&(m.preventDefault(),m.stopPropagation()),d((y=m.touches[0])==null?void 0:y.clientX)}},v=el()?{passive:!1}:!1;Wt(i)?(f?.addEventListener("touchmove",p.moveHandler,v),f?.addEventListener("touchend",p.upHandler,v)):(f?.addEventListener("mousemove",g.moveHandler,v),f?.addEventListener("mouseup",g.upHandler,v)),t.setColumnSizingInfo(m=>({...m,startOffset:u,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:a,isResizingColumn:n.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var s;e.setColumnSizing(t?{}:(s=e.initialState.columnSizing)!=null?s:{})},e.resetHeaderSizeInfo=t=>{var s;e.setColumnSizingInfo(t?qt():(s=e.initialState.columnSizingInfo)!=null?s:qt())},e.getTotalSize=()=>{var t,s;return(t=(s=e.getHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,s;return(t=(s=e.getLeftHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,s;return(t=(s=e.getCenterHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,s;return(t=(s=e.getRightHeaderGroups()[0])==null?void 0:s.headers.reduce((n,r)=>n+r.getSize(),0))!=null?t:0}}},ht=null;function el(){if(typeof ht=="boolean")return ht;let e=!1;try{const t={get passive(){return e=!0,!1}},s=()=>{};window.addEventListener("test",s,t),window.removeEventListener("test",s)}catch{e=!1}return ht=e,ht}function Wt(e){return e.type==="touchstart"}var tl={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:Q("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=s=>{e.getCanHide()&&t.setColumnVisibility(n=>({...n,[e.id]:s??!e.getIsVisible()}))},e.getIsVisible=()=>{var s,n;const r=e.columns;return(s=r.length?r.some(i=>i.getIsVisible()):(n=t.getState().columnVisibility)==null?void 0:n[e.id])!=null?s:!0},e.getCanHide=()=>{var s,n;return((s=e.columnDef.enableHiding)!=null?s:!0)&&((n=t.options.enableHiding)!=null?n:!0)},e.getToggleVisibilityHandler=()=>s=>{e.toggleVisibility==null||e.toggleVisibility(s.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=L(()=>[e.getAllCells(),t.getState().columnVisibility],s=>s.filter(n=>n.column.getIsVisible()),T(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=L(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(s,n,r)=>[...s,...n,...r],T(t.options,"debugRows","getVisibleCells"))},createTable:e=>{const t=(s,n)=>L(()=>[n(),n().filter(r=>r.getIsVisible()).map(r=>r.id).join("_")],r=>r.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),T(e.options,"debugColumns",s));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=s=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(s),e.resetColumnVisibility=s=>{var n;e.setColumnVisibility(s?{}:(n=e.initialState.columnVisibility)!=null?n:{})},e.toggleAllColumnsVisible=s=>{var n;s=(n=s)!=null?n:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((r,i)=>({...r,[i.id]:s||!(i.getCanHide!=null&&i.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(s=>!(s.getIsVisible!=null&&s.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(s=>s.getIsVisible==null?void 0:s.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>s=>{var n;e.toggleAllColumnsVisible((n=s.target)==null?void 0:n.checked)}}};function Je(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var sl={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},nl={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:Q("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var s;const n=(s=e.getCoreRowModel().flatRows[0])==null||(s=s._getAllCellsByColumnId()[t.id])==null?void 0:s.getValue();return typeof n=="string"||typeof n=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var s,n,r,i;return((s=e.columnDef.enableGlobalFilter)!=null?s:!0)&&((n=t.options.enableGlobalFilter)!=null?n:!0)&&((r=t.options.enableFilters)!=null?r:!0)&&((i=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?i:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>re.includesString,e.getGlobalFilterFn=()=>{var t,s;const{globalFilterFn:n}=e.options;return It(n)?n:n==="auto"?e.getGlobalAutoFilterFn():(t=(s=e.options.filterFns)==null?void 0:s[n])!=null?t:re[n]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},rl={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:Q("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,s=!1;e._autoResetExpanded=()=>{var n,r;if(!t){e._queue(()=>{t=!0});return}if((n=(r=e.options.autoResetAll)!=null?r:e.options.autoResetExpanded)!=null?n:!e.options.manualExpanding){if(s)return;s=!0,e._queue(()=>{e.resetExpanded(),s=!1})}},e.setExpanded=n=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(n),e.toggleAllRowsExpanded=n=>{n??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=n=>{var r,i;e.setExpanded(n?{}:(r=(i=e.initialState)==null?void 0:i.expanded)!=null?r:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(n=>n.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>n=>{n.persist==null||n.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const n=e.getState().expanded;return n===!0||Object.values(n).some(Boolean)},e.getIsAllRowsExpanded=()=>{const n=e.getState().expanded;return typeof n=="boolean"?n===!0:!(!Object.keys(n).length||e.getRowModel().flatRows.some(r=>!r.getIsExpanded()))},e.getExpandedDepth=()=>{let n=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(r=>{const i=r.split(".");n=Math.max(n,i.length)}),n},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=s=>{t.setExpanded(n=>{var r;const i=n===!0?!0:!!(n!=null&&n[e.id]);let o={};if(n===!0?Object.keys(t.getRowModel().rowsById).forEach(a=>{o[a]=!0}):o=n,s=(r=s)!=null?r:!i,!i&&s)return{...o,[e.id]:!0};if(i&&!s){const{[e.id]:a,...u}=o;return u}return n})},e.getIsExpanded=()=>{var s;const n=t.getState().expanded;return!!((s=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?s:n===!0||n?.[e.id])},e.getCanExpand=()=>{var s,n,r;return(s=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?s:((n=t.options.enableExpanding)!=null?n:!0)&&!!((r=e.subRows)!=null&&r.length)},e.getIsAllParentsExpanded=()=>{let s=!0,n=e;for(;s&&n.parentId;)n=t.getRow(n.parentId,!0),s=n.getIsExpanded();return s},e.getToggleExpandedHandler=()=>{const s=e.getCanExpand();return()=>{s&&e.toggleExpanded()}}}},ls=0,us=10,Kt=()=>({pageIndex:ls,pageSize:us}),il={getInitialState:e=>({...e,pagination:{...Kt(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:Q("pagination",e)}),createTable:e=>{let t=!1,s=!1;e._autoResetPageIndex=()=>{var n,r;if(!t){e._queue(()=>{t=!0});return}if((n=(r=e.options.autoResetAll)!=null?r:e.options.autoResetPageIndex)!=null?n:!e.options.manualPagination){if(s)return;s=!0,e._queue(()=>{e.resetPageIndex(),s=!1})}},e.setPagination=n=>{const r=i=>de(n,i);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(r)},e.resetPagination=n=>{var r;e.setPagination(n?Kt():(r=e.initialState.pagination)!=null?r:Kt())},e.setPageIndex=n=>{e.setPagination(r=>{let i=de(n,r.pageIndex);const o=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return i=Math.max(0,Math.min(i,o)),{...r,pageIndex:i}})},e.resetPageIndex=n=>{var r,i;e.setPageIndex(n?ls:(r=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageIndex)!=null?r:ls)},e.resetPageSize=n=>{var r,i;e.setPageSize(n?us:(r=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageSize)!=null?r:us)},e.setPageSize=n=>{e.setPagination(r=>{const i=Math.max(1,de(n,r.pageSize)),o=r.pageSize*r.pageIndex,a=Math.floor(o/i);return{...r,pageIndex:a,pageSize:i}})},e.setPageCount=n=>e.setPagination(r=>{var i;let o=de(n,(i=e.options.pageCount)!=null?i:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...r,pageCount:o}}),e.getPageOptions=L(()=>[e.getPageCount()],n=>{let r=[];return n&&n>0&&(r=[...new Array(n)].fill(null).map((i,o)=>o)),r},T(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:n}=e.getState().pagination,r=e.getPageCount();return r===-1?!0:r===0?!1:n<r-1},e.previousPage=()=>e.setPageIndex(n=>n-1),e.nextPage=()=>e.setPageIndex(n=>n+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var n;return(n=e.options.pageCount)!=null?n:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var n;return(n=e.options.rowCount)!=null?n:e.getPrePaginationRowModel().rows.length}}},Qt=()=>({top:[],bottom:[]}),ol={getInitialState:e=>({rowPinning:Qt(),...e}),getDefaultOptions:e=>({onRowPinningChange:Q("rowPinning",e)}),createRow:(e,t)=>{e.pin=(s,n,r)=>{const i=n?e.getLeafRows().map(u=>{let{id:l}=u;return l}):[],o=r?e.getParentRows().map(u=>{let{id:l}=u;return l}):[],a=new Set([...o,e.id,...i]);t.setRowPinning(u=>{var l,h;if(s==="bottom"){var c,d;return{top:((c=u?.top)!=null?c:[]).filter(p=>!(a!=null&&a.has(p))),bottom:[...((d=u?.bottom)!=null?d:[]).filter(p=>!(a!=null&&a.has(p))),...Array.from(a)]}}if(s==="top"){var f,g;return{top:[...((f=u?.top)!=null?f:[]).filter(p=>!(a!=null&&a.has(p))),...Array.from(a)],bottom:((g=u?.bottom)!=null?g:[]).filter(p=>!(a!=null&&a.has(p)))}}return{top:((l=u?.top)!=null?l:[]).filter(p=>!(a!=null&&a.has(p))),bottom:((h=u?.bottom)!=null?h:[]).filter(p=>!(a!=null&&a.has(p)))}})},e.getCanPin=()=>{var s;const{enableRowPinning:n,enablePinning:r}=t.options;return typeof n=="function"?n(e):(s=n??r)!=null?s:!0},e.getIsPinned=()=>{const s=[e.id],{top:n,bottom:r}=t.getState().rowPinning,i=s.some(a=>n?.includes(a)),o=s.some(a=>r?.includes(a));return i?"top":o?"bottom":!1},e.getPinnedIndex=()=>{var s,n;const r=e.getIsPinned();if(!r)return-1;const i=(s=r==="top"?t.getTopRows():t.getBottomRows())==null?void 0:s.map(o=>{let{id:a}=o;return a});return(n=i?.indexOf(e.id))!=null?n:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var s,n;return e.setRowPinning(t?Qt():(s=(n=e.initialState)==null?void 0:n.rowPinning)!=null?s:Qt())},e.getIsSomeRowsPinned=t=>{var s;const n=e.getState().rowPinning;if(!t){var r,i;return!!((r=n.top)!=null&&r.length||(i=n.bottom)!=null&&i.length)}return!!((s=n[t])!=null&&s.length)},e._getPinnedRows=(t,s,n)=>{var r;return((r=e.options.keepPinnedRows)==null||r?(s??[]).map(i=>{const o=e.getRow(i,!0);return o.getIsAllParentsExpanded()?o:null}):(s??[]).map(i=>t.find(o=>o.id===i))).filter(Boolean).map(i=>({...i,position:n}))},e.getTopRows=L(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,s)=>e._getPinnedRows(t,s,"top"),T(e.options,"debugRows","getTopRows")),e.getBottomRows=L(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,s)=>e._getPinnedRows(t,s,"bottom"),T(e.options,"debugRows","getBottomRows")),e.getCenterRows=L(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,s,n)=>{const r=new Set([...s??[],...n??[]]);return t.filter(i=>!r.has(i.id))},T(e.options,"debugRows","getCenterRows"))}},al={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:Q("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var s;return e.setRowSelection(t?{}:(s=e.initialState.rowSelection)!=null?s:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(s=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const n={...s},r=e.getPreGroupedRowModel().flatRows;return t?r.forEach(i=>{i.getCanSelect()&&(n[i.id]=!0)}):r.forEach(i=>{delete n[i.id]}),n})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(s=>{const n=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),r={...s};return e.getRowModel().rows.forEach(i=>{cs(r,i.id,n,!0,e)}),r}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=L(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,s)=>Object.keys(t).length?Jt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=L(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,s)=>Object.keys(t).length?Jt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=L(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,s)=>Object.keys(t).length?Jt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:s}=e.getState();let n=!!(t.length&&Object.keys(s).length);return n&&t.some(r=>r.getCanSelect()&&!s[r.id])&&(n=!1),n},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(r=>r.getCanSelect()),{rowSelection:s}=e.getState();let n=!!t.length;return n&&t.some(r=>!s[r.id])&&(n=!1),n},e.getIsSomeRowsSelected=()=>{var t;const s=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return s>0&&s<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(s=>s.getCanSelect()).some(s=>s.getIsSelected()||s.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(s,n)=>{const r=e.getIsSelected();t.setRowSelection(i=>{var o;if(s=typeof s<"u"?s:!r,e.getCanSelect()&&r===s)return i;const a={...i};return cs(a,e.id,s,(o=n?.selectChildren)!=null?o:!0,t),a})},e.getIsSelected=()=>{const{rowSelection:s}=t.getState();return _s(e,s)},e.getIsSomeSelected=()=>{const{rowSelection:s}=t.getState();return ds(e,s)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:s}=t.getState();return ds(e,s)==="all"},e.getCanSelect=()=>{var s;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(s=t.options.enableRowSelection)!=null?s:!0},e.getCanSelectSubRows=()=>{var s;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(s=t.options.enableSubRowSelection)!=null?s:!0},e.getCanMultiSelect=()=>{var s;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(s=t.options.enableMultiRowSelection)!=null?s:!0},e.getToggleSelectedHandler=()=>{const s=e.getCanSelect();return n=>{var r;s&&e.toggleSelected((r=n.target)==null?void 0:r.checked)}}}},cs=(e,t,s,n,r)=>{var i;const o=r.getRow(t,!0);s?(o.getCanMultiSelect()||Object.keys(e).forEach(a=>delete e[a]),o.getCanSelect()&&(e[t]=!0)):delete e[t],n&&(i=o.subRows)!=null&&i.length&&o.getCanSelectSubRows()&&o.subRows.forEach(a=>cs(e,a.id,s,n,r))};function Jt(e,t){const s=e.getState().rowSelection,n=[],r={},i=function(o,a){return o.map(u=>{var l;const h=_s(u,s);if(h&&(n.push(u),r[u.id]=u),(l=u.subRows)!=null&&l.length&&(u={...u,subRows:i(u.subRows)}),h)return u}).filter(Boolean)};return{rows:i(t.rows),flatRows:n,rowsById:r}}function _s(e,t){var s;return(s=t[e.id])!=null?s:!1}function ds(e,t,s){var n;if(!((n=e.subRows)!=null&&n.length))return!1;let r=!0,i=!1;return e.subRows.forEach(o=>{if(!(i&&!r)&&(o.getCanSelect()&&(_s(o,t)?i=!0:r=!1),o.subRows&&o.subRows.length)){const a=ds(o,t);a==="all"?i=!0:(a==="some"&&(i=!0),r=!1)}}),r?"all":i?"some":!1}var hs=/([0-9]+)/gm,ll=(e,t,s)=>Ar(me(e.getValue(s)).toLowerCase(),me(t.getValue(s)).toLowerCase()),ul=(e,t,s)=>Ar(me(e.getValue(s)),me(t.getValue(s))),cl=(e,t,s)=>Is(me(e.getValue(s)).toLowerCase(),me(t.getValue(s)).toLowerCase()),dl=(e,t,s)=>Is(me(e.getValue(s)),me(t.getValue(s))),hl=(e,t,s)=>{const n=e.getValue(s),r=t.getValue(s);return n>r?1:n<r?-1:0},fl=(e,t,s)=>Is(e.getValue(s),t.getValue(s));function Is(e,t){return e===t?0:e>t?1:-1}function me(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Ar(e,t){const s=e.split(hs).filter(Boolean),n=t.split(hs).filter(Boolean);for(;s.length&&n.length;){const r=s.shift(),i=n.shift(),o=parseInt(r,10),a=parseInt(i,10),u=[o,a].sort();if(isNaN(u[0])){if(r>i)return 1;if(i>r)return-1;continue}if(isNaN(u[1]))return isNaN(o)?-1:1;if(o>a)return 1;if(a>o)return-1}return s.length-n.length}var Ke={alphanumeric:ll,alphanumericCaseSensitive:ul,text:cl,textCaseSensitive:dl,datetime:hl,basic:fl},gl={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:Q("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const s=t.getFilteredRowModel().flatRows.slice(10);let n=!1;for(const r of s){const i=r?.getValue(e.id);if(Object.prototype.toString.call(i)==="[object Date]")return Ke.datetime;if(typeof i=="string"&&(n=!0,i.split(hs).length>1))return Ke.alphanumeric}return n?Ke.text:Ke.basic},e.getAutoSortDir=()=>{const s=t.getFilteredRowModel().flatRows[0];return typeof s?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var s,n;if(!e)throw new Error;return It(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(s=(n=t.options.sortingFns)==null?void 0:n[e.columnDef.sortingFn])!=null?s:Ke[e.columnDef.sortingFn]},e.toggleSorting=(s,n)=>{const r=e.getNextSortingOrder(),i=typeof s<"u"&&s!==null;t.setSorting(o=>{const a=o?.find(f=>f.id===e.id),u=o?.findIndex(f=>f.id===e.id);let l=[],h,c=i?s:r==="desc";if(o!=null&&o.length&&e.getCanMultiSort()&&n?a?h="toggle":h="add":o!=null&&o.length&&u!==o.length-1?h="replace":a?h="toggle":h="replace",h==="toggle"&&(i||r||(h="remove")),h==="add"){var d;l=[...o,{id:e.id,desc:c}],l.splice(0,l.length-((d=t.options.maxMultiSortColCount)!=null?d:Number.MAX_SAFE_INTEGER))}else h==="toggle"?l=o.map(f=>f.id===e.id?{...f,desc:c}:f):h==="remove"?l=o.filter(f=>f.id!==e.id):l=[{id:e.id,desc:c}];return l})},e.getFirstSortDir=()=>{var s,n;return((s=(n=e.columnDef.sortDescFirst)!=null?n:t.options.sortDescFirst)!=null?s:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=s=>{var n,r;const i=e.getFirstSortDir(),o=e.getIsSorted();return o?o!==i&&((n=t.options.enableSortingRemoval)==null||n)&&(!(s&&(r=t.options.enableMultiRemove)!=null)||r)?!1:o==="desc"?"asc":"desc":i},e.getCanSort=()=>{var s,n;return((s=e.columnDef.enableSorting)!=null?s:!0)&&((n=t.options.enableSorting)!=null?n:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var s,n;return(s=(n=e.columnDef.enableMultiSort)!=null?n:t.options.enableMultiSort)!=null?s:!!e.accessorFn},e.getIsSorted=()=>{var s;const n=(s=t.getState().sorting)==null?void 0:s.find(r=>r.id===e.id);return n?n.desc?"desc":"asc":!1},e.getSortIndex=()=>{var s,n;return(s=(n=t.getState().sorting)==null?void 0:n.findIndex(r=>r.id===e.id))!=null?s:-1},e.clearSorting=()=>{t.setSorting(s=>s!=null&&s.length?s.filter(n=>n.id!==e.id):[])},e.getToggleSortingHandler=()=>{const s=e.getCanSort();return n=>{s&&(n.persist==null||n.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(n):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var s,n;e.setSorting(t?[]:(s=(n=e.initialState)==null?void 0:n.sorting)!=null?s:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},pl=[ka,tl,Ja,Ya,$a,Na,sl,nl,gl,Ka,rl,il,ol,al,Za];function ml(e){var t,s;const n=[...pl,...(t=e._features)!=null?t:[]];let r={_features:n};const i=r._features.reduce((c,d)=>Object.assign(c,d.getDefaultOptions==null?void 0:d.getDefaultOptions(r)),{}),o=c=>r.options.mergeOptions?r.options.mergeOptions(i,c):{...i,...c};let a={...(s=e.initialState)!=null?s:{}};r._features.forEach(c=>{var d;a=(d=c.getInitialState==null?void 0:c.getInitialState(a))!=null?d:a});const u=[];let l=!1;const h={_features:n,options:{...i,...e},initialState:a,_queue:c=>{u.push(c),l||(l=!0,Promise.resolve().then(()=>{for(;u.length;)u.shift()();l=!1}).catch(d=>setTimeout(()=>{throw d})))},reset:()=>{r.setState(r.initialState)},setOptions:c=>{r.options=o(de(c,r.options))},getState:()=>r.options.state,setState:c=>{r.options.onStateChange==null||r.options.onStateChange(c)},_getRowId:(c,d,f)=>{var g;return(g=r.options.getRowId==null?void 0:r.options.getRowId(c,d,f))!=null?g:`${f?[f.id,d].join("."):d}`},getCoreRowModel:()=>(r._getCoreRowModel||(r._getCoreRowModel=r.options.getCoreRowModel(r)),r._getCoreRowModel()),getRowModel:()=>r.getPaginationRowModel(),getRow:(c,d)=>{let f=(d?r.getPrePaginationRowModel():r.getRowModel()).rowsById[c];if(!f&&(f=r.getCoreRowModel().rowsById[c],!f))throw new Error;return f},_getDefaultColumnDef:L(()=>[r.options.defaultColumn],c=>{var d;return c=(d=c)!=null?d:{},{header:f=>{const g=f.header.column.columnDef;return g.accessorKey?g.accessorKey:g.accessorFn?g.id:null},cell:f=>{var g,p;return(g=(p=f.renderValue())==null||p.toString==null?void 0:p.toString())!=null?g:null},...r._features.reduce((f,g)=>Object.assign(f,g.getDefaultColumnDef==null?void 0:g.getDefaultColumnDef()),{}),...c}},T(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>r.options.columns,getAllColumns:L(()=>[r._getColumnDefs()],c=>{const d=function(f,g,p){return p===void 0&&(p=0),f.map(v=>{const m=Aa(r,v,p,g),y=v;return m.columns=y.columns?d(y.columns,m,p+1):[],m})};return d(c)},T(e,"debugColumns","getAllColumns")),getAllFlatColumns:L(()=>[r.getAllColumns()],c=>c.flatMap(d=>d.getFlatColumns()),T(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:L(()=>[r.getAllFlatColumns()],c=>c.reduce((d,f)=>(d[f.id]=f,d),{}),T(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:L(()=>[r.getAllColumns(),r._getOrderColumnsFn()],(c,d)=>d(c.flatMap(f=>f.getLeafColumns())),T(e,"debugColumns","getAllLeafColumns")),getColumn:c=>r._getAllFlatColumnsById()[c]};Object.assign(r,h);for(let c=0;c<r._features.length;c++){const d=r._features[c];d==null||d.createTable==null||d.createTable(r)}return r}function Ql(){return e=>L(()=>[e.options.data],t=>{const s={rows:[],flatRows:[],rowsById:{}},n=function(r,i,o){i===void 0&&(i=0);const a=[];for(let l=0;l<r.length;l++){const h=Da(e,e._getRowId(r[l],l,o),r[l],l,i,void 0,o?.id);if(s.flatRows.push(h),s.rowsById[h.id]=h,a.push(h),e.options.getSubRows){var u;h.originalSubRows=e.options.getSubRows(r[l],l),(u=h.originalSubRows)!=null&&u.length&&(h.subRows=n(h.originalSubRows,i+1,h))}}return a};return s.rows=n(t),s},T(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Jl(){return e=>L(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,s)=>{if(!s.rows.length||!(t!=null&&t.length))return s;const n=e.getState().sorting,r=[],i=n.filter(u=>{var l;return(l=e.getColumn(u.id))==null?void 0:l.getCanSort()}),o={};i.forEach(u=>{const l=e.getColumn(u.id);l&&(o[u.id]={sortUndefined:l.columnDef.sortUndefined,invertSorting:l.columnDef.invertSorting,sortingFn:l.getSortingFn()})});const a=u=>{const l=u.map(h=>({...h}));return l.sort((h,c)=>{for(let f=0;f<i.length;f+=1){var d;const g=i[f],p=o[g.id],v=p.sortUndefined,m=(d=g?.desc)!=null?d:!1;let y=0;if(v){const C=h.getValue(g.id),S=c.getValue(g.id),w=C===void 0,_=S===void 0;if(w||_){if(v==="first")return w?-1:1;if(v==="last")return w?1:-1;y=w&&_?0:w?v:-v}}if(y===0&&(y=p.sortingFn(h,c,g.id)),y!==0)return m&&(y*=-1),p.invertSorting&&(y*=-1),y}return h.index-c.index}),l.forEach(h=>{var c;r.push(h),(c=h.subRows)!=null&&c.length&&(h.subRows=a(h.subRows))}),l};return{rows:a(s.rows),flatRows:r,rowsById:s.rowsById}},T(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function Yl(e,t){return e?vl(e)?R.createElement(e,t):e:null}function vl(e){return Sl(e)||typeof e=="function"||yl(e)}function Sl(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function yl(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function Xl(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[s]=R.useState(()=>({current:ml(t)})),[n,r]=R.useState(()=>s.current.initialState);return s.current.setOptions(i=>({...i,...e,state:{...n,...e.state},onStateChange:o=>{r(o),e.onStateChange==null||e.onStateChange(o)}})),s.current}function Te(e,t,s){let n=s.initialDeps??[],r,i=!0;function o(){var a,u,l;let h;s.key&&((a=s.debug)!=null&&a.call(s))&&(h=Date.now());const c=e();if(!(c.length!==n.length||c.some((f,g)=>n[g]!==f)))return r;n=c;let d;if(s.key&&((u=s.debug)!=null&&u.call(s))&&(d=Date.now()),r=t(...c),s.key&&((l=s.debug)!=null&&l.call(s))){const f=Math.round((Date.now()-h)*100)/100,g=Math.round((Date.now()-d)*100)/100,p=g/16,v=(m,y)=>{for(m=String(m);m.length<y;)m=" "+m;return m};console.info(`%c⏱ ${v(g,5)} /${v(f,5)} ms`,`
7
+ font-size: .6rem;
8
+ font-weight: bold;
9
+ color: hsl(${Math.max(0,Math.min(120-120*p,120))}deg 100% 31%);`,s?.key)}return s?.onChange&&!(i&&s.skipInitialOnChange)&&s.onChange(r),i=!1,r}return o.updateDeps=a=>{n=a},o}function Dn(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var Cl=(e,t)=>Math.abs(e-t)<1.01,Rl=(e,t,s)=>{let n;return function(...r){e.clearTimeout(n),n=e.setTimeout(()=>t.apply(this,r),s)}},$n=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},wl=e=>e,bl=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1),n=[];for(let r=t;r<=s;r++)n.push(r);return n},Pl=(e,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const r=o=>{const{width:a,height:u}=o;t({width:Math.round(a),height:Math.round(u)})};if(r($n(s)),!n.ResizeObserver)return()=>{};const i=new n.ResizeObserver(o=>{const a=()=>{const u=o[0];if(u?.borderBoxSize){const l=u.borderBoxSize[0];if(l){r({width:l.inlineSize,height:l.blockSize});return}}r($n(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},Nn={passive:!0},Vn=typeof window>"u"?!0:"onscrollend"in window,Ml=(e,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;let r=0;const i=e.options.useScrollendEvent&&Vn?()=>{}:Rl(n,()=>{t(r,!1)},e.options.isScrollingResetDelay),o=h=>()=>{const{horizontal:c,isRtl:d}=e.options;r=c?s.scrollLeft*(d&&-1||1):s.scrollTop,i(),t(r,h)},a=o(!0),u=o(!1);s.addEventListener("scroll",a,Nn);const l=e.options.useScrollendEvent&&Vn;return l&&s.addEventListener("scrollend",u,Nn),()=>{s.removeEventListener("scroll",a),l&&s.removeEventListener("scrollend",u)}},_l=(e,t,s)=>{if(t?.borderBoxSize){const n=t.borderBoxSize[0];if(n)return Math.round(n[s.options.horizontal?"inlineSize":"blockSize"])}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},Il=(e,{adjustments:t=0,behavior:s},n)=>{var r,i;const o=e+t;(i=(r=n.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[n.options.horizontal?"left":"top"]:o,behavior:s})},xl=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(r=>{const i=()=>{this._measureElement(r.target,r)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var r;return(r=s())==null?void 0:r.observe(n,{box:"border-box"})},unobserve:n=>{var r;return(r=s())==null?void 0:r.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([s,n])=>{typeof n>"u"&&delete t[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:wl,rangeExtractor:bl,onChange:()=>{},measureElement:_l,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Te(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=r,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,s)=>{const n=new Map,r=new Map;for(let i=s-1;i>=0;i--){const o=t[i];if(n.has(o.lane))continue;const a=r.get(o.lane);if(a==null||o.end>a.end?r.set(o.lane,o):o.end<a.end&&n.set(o.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((i,o)=>i.end===o.end?i.index-o.index:i.end-o.end)[0]:void 0},this.getMeasurementOptions=Te(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,s,n,r,i,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:s,scrollMargin:n,getItemKey:r,enabled:i,lanes:o}),{key:!1}),this.getMeasurements=Te(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:s,scrollMargin:n,getItemKey:r,enabled:i,lanes:o},a)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const c of this.laneAssignments.keys())c>=t&&this.laneAssignments.delete(c);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const l=this.measurementsCache.slice(0,u),h=new Array(o).fill(void 0);for(let c=0;c<u;c++){const d=l[c];d&&(h[d.lane]=c)}for(let c=u;c<t;c++){const d=r(c),f=this.laneAssignments.get(c);let g,p;if(f!==void 0&&this.options.lanes>1){g=f;const C=h[g],S=C!==void 0?l[C]:void 0;p=S?S.end+this.options.gap:s+n}else{const C=this.options.lanes===1?l[c-1]:this.getFurthestMeasurement(l,c);p=C?C.end+this.options.gap:s+n,g=C?C.lane:c%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(c,g)}const v=a.get(d),m=typeof v=="number"?v:this.options.estimateSize(c),y=p+m;l[c]={index:c,start:p,size:m,end:y,key:d,lane:g},h[g]=c}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Te(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,r)=>this.range=t.length>0&&s>0?El({measurements:t,outerSize:s,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Te(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,r,i)=>r===null||i===null?[]:t({startIndex:r,endIndex:i,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this._measureElement=(t,s)=>{const n=this.indexFromElement(t),r=this.measurementsCache[n];if(!r)return;const i=r.key,o=this.elementsCache.get(i);o!==t&&(o&&this.observer.unobserve(o),this.observer.observe(t),this.elementsCache.set(i,t)),t.isConnected&&this.resizeItem(n,this.options.measureElement(t,s,this))},this.resizeItem=(t,s)=>{const n=this.measurementsCache[t];if(!n)return;const r=s-(this.itemSizeCache.get(n.key)??n.size);r!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,s)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((s,n)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(n))});return}this._measureElement(t,void 0)},this.getVirtualItems=Te(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let r=0,i=t.length;r<i;r++){const o=s[t[r]];n.push(o)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length!==0)return Dn(s[kr(0,s.length-1,n=>Dn(s[n]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const r=this.getSize(),i=this.getScrollOffset();s==="auto"&&(s=t>=i+r?"end":"start"),s==="center"?t+=(n-r)/2:s==="end"&&(t-=r);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.measurementsCache[t];if(!n)return;const r=this.getSize(),i=this.getScrollOffset();if(s==="auto")if(n.end>=i+r-this.options.scrollPaddingEnd)s="end";else if(n.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const o=s==="end"?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,s,n.size),s]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:s="start",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,s),{adjustments:void 0,behavior:n})},this.scrollToIndex=(t,{align:s="auto",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1)),this.currentScrollToIndex=t;let r=0;const i=10,o=u=>{if(!this.targetWindow)return;const l=this.getOffsetForIndex(t,u);if(!l){console.warn("Failed to get offset for index:",t);return}const[h,c]=l;this._scrollToOffset(h,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{const d=()=>{if(this.currentScrollToIndex!==t)return;const f=this.getScrollOffset(),g=this.getOffsetForIndex(t,c);if(!g){console.warn("Failed to get offset for index:",t);return}Cl(g[0],f)||a(c)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(d):d()})},a=u=>{this.targetWindow&&this.currentScrollToIndex===t&&(r++,r<i?this.targetWindow.requestAnimationFrame(()=>o(u)):console.warn(`Failed to scroll to index ${t} after ${i} attempts.`))};o(s)},this.scrollBy=(t,{behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:s})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((t=s[s.length-1])==null?void 0:t.end)??0;else{const r=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&r.some(o=>o===null);){const o=s[i];r[o.lane]===null&&(r[o.lane]=o.end),i--}n=Math.max(...r.filter(o=>o!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}},kr=(e,t,s,n)=>{for(;e<=t;){const r=(e+t)/2|0,i=s(r);if(i<n)e=r+1;else if(i>n)t=r-1;else return r}return e>0?e-1:0};function El({measurements:e,outerSize:t,scrollOffset:s,lanes:n}){const r=e.length-1,i=u=>e[u].start;if(e.length<=n)return{startIndex:0,endIndex:r};let o=kr(0,r,i,s),a=o;if(n===1)for(;a<r&&e[a].end<s+t;)a++;else if(n>1){const u=Array(n).fill(0);for(;a<r&&u.some(h=>h<s+t);){const h=e[a];u[h.lane]=h.end,a++}const l=Array(n).fill(s+t);for(;o>=0&&l.some(h=>h>=s);){const h=e[o];l[h.lane]=h.start,o--}o=Math.max(0,o-o%n),a=Math.min(r,a+(n-1-a%n))}return{startIndex:o,endIndex:a}}var Bn=typeof document<"u"?R.useLayoutEffect:R.useEffect;function Ll({useFlushSync:e=!0,...t}){const s=R.useReducer(()=>({}),{})[1],n={...t,onChange:(i,o)=>{var a;e&&o?(0,Cr.flushSync)(s):s(),(a=t.onChange)==null||a.call(t,i,o)}},[r]=R.useState(()=>new xl(n));return r.setOptions(n),Bn(()=>r._didMount(),[]),Bn(()=>r._willUpdate()),r}function Zl(e){return Ll({observeElementRect:Pl,observeElementOffset:Ml,scrollToFn:Il,...e})}export{Al as C,kl as S,mr as _,Jl as a,Dl as b,Gl as c,ea as d,Hl as f,Sr as g,Rr as h,Ql as i,jl as l,Bl as m,Yl as n,Wl as o,zl as p,Xl as r,ql as s,Zl as t,Ul as u,Vl as v,Yn as x,Nl as y};