db-studio 1.7.12 → 1.8.0

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 (22) hide show
  1. package/dist/core-dist/assets/{_pathlessLayout-XL9BaZh5.js → _pathlessLayout-CaHwrd7d.js} +2 -2
  2. package/dist/core-dist/assets/{_queryId-CAjVLs-F.js → _queryId-BvXfDRyN.js} +1 -1
  3. package/dist/core-dist/assets/{_table-DKnSwqFc.js → _table-C-cjSgPo.js} +1 -1
  4. package/dist/core-dist/assets/{_table-BI_XiC1K.js → _table-Dswhig7K.js} +1 -1
  5. package/dist/core-dist/assets/{cdoe-editor-Lwkji0wU.js → cdoe-editor-CiltAc4h.js} +1 -1
  6. package/dist/core-dist/assets/{chat-sidebar-DTwB3fym.js → chat-sidebar-_lfj2Fbh.js} +1 -1
  7. package/dist/core-dist/assets/{dist-C6mIPWhR.js → dist-BXjtz0JN.js} +1 -1
  8. package/dist/core-dist/assets/{dist-UBwYqP_w.js → dist-D2fkvd0U.js} +1 -1
  9. package/dist/core-dist/assets/{index-B8u-3J3b.js → index-B6AC45mT.js} +3 -3
  10. package/dist/core-dist/assets/{queries.store-BTgqNNws.js → queries.store-DHVvJtBW.js} +1 -1
  11. package/dist/core-dist/assets/{runner-CJikZjx7.js → runner-BMuLDN6J.js} +1 -1
  12. package/dist/core-dist/assets/{runner-tab-CSDL4L8O.js → runner-tab-DvRyphpg.js} +3 -3
  13. package/dist/core-dist/assets/{scroll-area-CnrU1Pgb.js → scroll-area-CUkrAzp4.js} +1 -1
  14. package/dist/core-dist/assets/tanstack-CGK2_6ff.js +9 -0
  15. package/dist/core-dist/assets/{tooltip-DttVuH4f.js → tooltip-Bl2D-B_-.js} +1 -1
  16. package/dist/core-dist/assets/{use-delete-column-CA96Lesz.js → use-delete-column-Bj0kvje3.js} +1 -1
  17. package/dist/core-dist/assets/{use-rate-limit-B1ivFudi.js → use-rate-limit-BLoyDbp7.js} +1 -1
  18. package/dist/core-dist/index.html +2 -2
  19. package/dist/index.js +291 -607
  20. package/dist/index.js.map +1 -1
  21. package/package.json +3 -3
  22. package/dist/core-dist/assets/tanstack-CJpNvQIy.js +0 -9
@@ -0,0 +1,9 @@
1
+ import{r as zn,t as ke}from"./rolldown-runtime-Bnw7wDfq.js";import{nt as gs}from"./icons-BywMJ5og.js";import{Dt as Hr,Ot as Ur}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(){}},jr={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Gr=class{#t=jr;#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)}},Ce=new Gr;function qr(e){setTimeout(e,0)}var be=typeof window>"u"||"Deno"in globalThis;function H(){}function Wr(e,t){return typeof e=="function"?e(t):e}function Xt(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!==ps(o,t.options))return!1}else if(!Je(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(!Je(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||r&&!r(t))}function ps(e,t){return(t?.queryKeyHashFn||Me)(e)}function Me(e){return JSON.stringify(e,(t,s)=>Zt(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Je(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>Je(e[s],t[s])):!1}var Kr=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&&!(Zt(e)&&Zt(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 d=n?l:i[l],c=e[d],h=t[d];if(c===h){a[d]=c,(n?l<r:Kr.call(e,d))&&u++;continue}if(c===null||h===null||typeof c!="object"||typeof h!="object"){a[d]=h;continue}const f=Un(c,h,s+1);a[d]=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 Zt(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=>{Ce.setTimeout(t,e)})}function es(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?Un(e,t):t}function Jr(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function Yr(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var ms=Symbol();function jn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ms?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function vs(e,t){return typeof e=="function"?e(...t):!!e}function Xr(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 Zr=class extends Ne{#t;#e;#s;constructor(){super(),this.#s=e=>{if(!be&&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"}},Ss=new Zr;function ts(){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 Dl(e){return e.state.status==="success"}var ei=qr;function ti(){let e=[],t=0,s=a=>{a()},n=a=>{a()},r=ei;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 k=ti(),si=class extends Ne{#t=!0;#e;#s;constructor(){super(),this.#s=e=>{if(!be&&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 si;function ni(e){return Math.min(1e3*2**e,3e4)}function Gn(e){return(e??"online")==="online"?yt.isOnline():!0}var ss=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=ts(),i=()=>r.status!=="pending",o=p=>{if(!i()){const v=new ss(p);h(v),e.onCancel?.(v)}},a=()=>{t=!0},u=()=>{t=!1},l=()=>Ss.isFocused()&&(e.networkMode==="always"||yt.isOnline())&&e.canRun(),d=()=>Gn(e.networkMode)&&e.canRun(),c=p=>{i()||(n?.(),r.resolve(p))},h=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??(be?0:3),C=e.retryDelay??ni,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){h(m);return}s++,e.onFail?.(s,m),Qr(S).then(()=>l()?void 0:f()).then(()=>{t?h(m):g()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(n?.(),r),cancelRetry:a,continueRetry:u,canStart:d,start:()=>(d()?g():f().then(g),r)}}var Wn=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Xt(this.gcTime)&&(this.#t=Ce.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(be?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Ce.clearTimeout(this.#t),this.#t=void 0)}},ri=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=es(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(H).catch(H):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===ms||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 d={client:this.#r,queryKey:this.queryKey,meta:this.meta};return n(d),d})();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 ss&&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 ss){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),k.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 ii=class extends Ne{constructor(e,t){super(),this.options=t,this.#t=e,this.#o=null,this.#i=ts(),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 ns(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ns(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 ai(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(H)),t}#m(){this.#C();const e=he(this.options.staleTime,this.#e);if(be||this.#r.isStale||!Xt(e))return;const t=Hn(this.#r.dataUpdatedAt,e)+1;this.#c=Ce.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,!(be||X(this.options.enabled,this.#e)===!1||!Xt(this.#d)||this.#d===0)&&(this.#l=Ce.setInterval(()=>{(this.options.refetchIntervalInBackground||Ss.isFocused())&&this.#f()},this.#d))}#y(){this.#m(),this.#S(this.#v())}#C(){this.#c&&(Ce.clearTimeout(this.#c),this.#c=void 0)}#R(){this.#l&&(Ce.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},d=!1,c;if(t._optimisticResults){const _=this.hasListeners(),b=!_&&qs(e,t),M=_&&Ws(e,s,t,n);(b||M)&&(l={...l,...Kn(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:h,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=es(r?.data,_,t),d=!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=es(r?.data,c,t),this.#p=c,this.#o=null}catch(_){this.#o=_}this.#o&&(h=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:h,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:d,isRefetchError:y&&S,isStale:ys(e,t),refetch:this.refetch,promise:this.#i,isEnabled:X(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const _=w.data!==void 0,b=w.status==="error"&&!_,M=P=>{b?P.reject(w.error):_&&P.resolve(w.data)},I=()=>{M(this.#i=w.promise=ts())},x=this.#i;switch(x.status){case"pending":e.queryHash===s.queryHash&&M(x);break;case"fulfilled":(b||w.data!==x.value)&&I();break;case"rejected":(!b||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){k.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function oi(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 oi(e,t)||e.state.data!==void 0&&ns(e,t,t.refetchOnMount)}function ns(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&&ys(e,t)}return!1}function Ws(e,t,s,n){return(e!==t||X(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ys(e,s)}function ys(e,t){return X(t.enabled,e)!==!1&&e.isStaleByTime(he(t.staleTime,e))}function ai(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 d=!1;const c=g=>{Xr(g,()=>t.signal,()=>d=!0)},h=jn(t.options,t.fetchOptions),f=async(g,p,v)=>{if(d)return Promise.reject();if(p==null&&g.pages.length)return Promise.resolve(g);const y=await h((()=>{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?Yr:Jr;return{pages:S(g.pages,y,C),pageParams:S(g.pageParams,p,C)}};if(r&&i.length){const g=r==="backward",p=g?li: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 li(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var ui=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),k.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 ci=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 ui({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(){k.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){k.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return k.batch(()=>Promise.all(e.map(t=>t.continue().catch(H))))}};function it(e){return e.options.scope?.id}var di=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){k.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)})})}},hi=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??ps(n,t);let i=this.get(r);return i||(i=new ri({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(){k.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){k.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){k.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){k.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},kl=class{#t;#e;#s;#r;#n;#a;#i;#o;constructor(e={}){this.#t=e.queryCache||new hi,this.#e=e.mutationCache||new ci,this.#s=e.defaultOptions||{},this.#r=new Map,this.#n=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#i=Ss.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=Wr(t,r);if(i!==void 0)return this.#t.build(this,n).setData(i,{...s,manual:!0})}setQueriesData(e,t,s){return k.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;k.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#t;return k.batch(()=>(s.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},n=k.batch(()=>this.#t.findAll(e).map(r=>r.cancel(s)));return Promise.all(n).then(H).catch(H)}invalidateQueries(e,t={}){return k.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=k.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(H)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(H)}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(H).catch(H)}fetchInfiniteQuery(e){return e.behavior=Ks(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(H).catch(H)}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=>{Je(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=>{Je(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=ps(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===ms&&(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(gs(),1),E=Ur(),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},Nl=({client:e,children:t})=>(R.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,E.jsx)(Jn.Provider,{value:e,children:t})),Xn=R.createContext(!1),fi=()=>R.useContext(Xn),$l=Xn.Provider;function gi(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var pi=R.createContext(gi()),mi=()=>R.useContext(pi),vi=(e,t,s)=>{const n=s?.state.error&&typeof e.throwOnError=="function"?vs(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},Si=e=>{R.useEffect(()=>{e.clearReset()},[e])},yi=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(r&&e.data===void 0||vs(s,[e.error,n])),Ci=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))}},Ri=(e,t)=>e.isLoading&&e.isFetching&&!t,wi=(e,t)=>e?.suspense&&t.isPending,Js=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function bi(e,t,s){const n=fi(),r=mi(),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",Ci(o),vi(o,r,a),Si(r);const u=!i.getQueryCache().get(o.queryHash),[l]=R.useState(()=>new t(i,o)),d=l.getOptimisticResult(o),c=!n&&e.subscribed!==!1;if(R.useSyncExternalStore(R.useCallback(h=>{const f=c?l.subscribe(k.batchCalls(h)):H;return l.updateResult(),f},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),R.useEffect(()=>{l.setOptions(o)},[o,l]),wi(o,d))throw Js(o,l,r);if(yi({result:d,errorResetBoundary:r,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw d.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!be&&Ri(d,n)&&(u?Js(o,l,r):a?.promise)?.catch(H).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?d:l.trackResult(d)}function Vl(e,t){return bi(e,ii,t)}function Bl(e,t){const s=Yn(t),[n]=R.useState(()=>new di(s,e));R.useEffect(()=>{n.setOptions(e)},[n,e]);const r=R.useSyncExternalStore(R.useCallback(o=>n.subscribe(k.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=R.useCallback((o,a)=>{n.mutate(o,a).catch(H)},[n]);if(r.error&&vs(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}var Ys=R.use,Ke=typeof window<"u"?R.useLayoutEffect:R.useEffect;function Dt(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 Mi(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 _i(e){const t=R.useRef(null);return R.useImperativeHandle(e,()=>t.current,[]),t}function Ye(e){return e[e.length-1]}function Pi(e){return typeof e=="function"}function se(e,t){return Pi(e)?e(t):e}var Zn=Object.prototype.hasOwnProperty,Xs=Object.prototype.propertyIsEnumerable;function Ct(e){for(const t in e)if(Zn.call(e,t))return!0;return!1}var Ii=()=>Object.create(null),Se=(e,t)=>le(e,t,Ii);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&&!(Ae(e)&&Ae(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,d=i?new Array(l):s();let c=0;for(let h=0;h<l;h++){const f=i?h:a[h],g=e[f],p=r[f];if(g===p){d[f]=g,(i?h<u:Zn.call(e,f))&&c++;continue}if(g===null||p===null||typeof g!="object"||typeof p!="object"){d[f]=p;continue}const v=le(g,p,s,n+1);d[f]=v,v===g&&c++}return u===l&&c===u?e:d}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 Ae(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(Ae(e)&&Ae(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 xi(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 Xe(e){return!!(e&&typeof e=="object"&&typeof e.then=="function")}function Ei(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 Ei(t)}var Li=["http:","https:","mailto:","tel:"];function ye(e,t){if(!e)return!1;try{const s=new URL(e);return!t.has(s.protocol)}catch{return!1}}function Ue(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 Ti(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Fi(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 oe(){throw new Error("Invariant failed")}function Ze(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,er=5;function Oi(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 tr(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=Oi(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 d=a+3,c=u;if(d<c)return s[0]=3,s[1]=t+a,s[2]=t+d,s[3]=t+c,s[4]=t+u+1,s[5]=r,s}}else if(l===36){const d=a+1,c=a+2;return c===u?(s[0]=2,s[1]=t+a,s[2]=t+d,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 _t(e,t,s,n,r,i,o){o?.(s);let a=n;{const u=s.fullPath??s.from,l=u.length,d=s.options?.caseSensitive??e,c=s.options?.params?.parse??s.options?.parseParams;for(;a<l;){const f=tr(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(d){const y=r.static?.get(m);if(y)g=y;else{r.static??=new Map;const C=Re(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=Re(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=d&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,_=!c&&r.dynamic?.find(b=>!b.parse&&b.caseSensitive===C&&b.prefix===S&&b.suffix===w);if(_)g=_;else{const b=Nt(1,s.fullPath??s.from,C,S,w);g=b,b.depth=i,b.parent=r,r.dynamic??=[],r.dynamic.push(b)}break}case 3:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=d&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,_=!c&&r.optional?.find(b=>!b.parse&&b.caseSensitive===C&&b.prefix===S&&b.suffix===w);if(_)g=_;else{const b=Nt(3,s.fullPath??s.from,C,S,w);g=b,b.parent=r,b.depth=i,r.optional??=[],r.optional.push(b)}break}case 2:{const m=u.substring(p,f[1]),y=u.substring(f[4],v),C=d&&!!(m||y),S=m?C?m:m.toLowerCase():void 0,w=y?C?y:y.toLowerCase():void 0,_=Nt(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=Re(s.fullPath??s.from);f.kind=er,f.parent=r,i++,f.depth=i,r.pathless??=[],r.pathless.push(f),r=f}const h=(s.path||!s.children)&&!s.isRoot;if(h&&u.endsWith("/")){const f=Re(s.fullPath??s.from);f.kind=ue,f.parent=r,i++,f.depth=i,r.index=f,r=f}r.parse=c??null,h&&!r.route&&(r.route=s,r.fullPath=s.fullPath??s.from)}if(s.children)for(const u of s.children)_t(e,t,u,a,r,i,o)}function kt(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;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 Re(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}}function Nt(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,caseSensitive:s,prefix:n,suffix:r}}function Ai(e,t){const s=Re("/"),n=new Uint16Array(6);for(const r of e)_t(!1,n,r,1,s,0);ae(s),t.masksTree=s,t.flatCache=Ze(1e3)}function Di(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 ki(e,t,s,n,r){e||="/",n||="/";const i=t?`case\0${e}`:e;let o=r.singleCache.get(i);return o||(o=Re("/"),_t(t,new Uint16Array(6),{from:e},1,o,0),r.singleCache.set(i,o)),Cs(n,o,s)}function Ni(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=nr(i.route)),t.matchCache.set(n,i),i}function $i(e){return e==="/"?e:e.replace(/\/{1,}$/,"")}function Vi(e,t=!1,s){const n=Re(e.fullPath),r=new Uint16Array(6),i={},o={};let a=0;return _t(t,r,e,1,n,0,u=>{if(s?.(u,a),u.id in i&&oe(),i[u.id]=u,a!==0&&u.path){const l=$i(u.fullPath);(!o[l]||u.fullPath.endsWith("/"))&&(o[l]=u)}a++}),ae(n),{processedTree:{segmentTree:n,singleCache:Ze(1e3),matchCache:Ze(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:o}}function Cs(e,t,s=!1){const n=e.split("/"),r=zi(e,n,t,s);if(!r)return null;const[i]=sr(e,n,r);return{route:r.node.route,rawParams:i}}function sr(e,t,s){const n=Bi(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 d=n[a];if(d.kind===ue)break;if(d.kind===er){l--,o--,u--;continue}const c=t[o],h=u;if(c&&(u+=c.length),d.kind===1){r??=s.node.fullPath.split("/");const f=r[l],g=d.prefix?.length??0;if(f.charCodeAt(g)===123){const p=d.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(d.kind===3){if(s.skipped&1<<a){o--,u=h-1;continue}r??=s.node.fullPath.split("/");const f=r[l],g=d.prefix?.length??0,p=d.suffix?.length??0,v=f.substring(g+3,f.length-p-1),m=d.suffix||d.prefix?c.substring(g,c.length-p):c;m&&(i[v]=decodeURIComponent(m))}else if(d.kind===2){const f=d,g=e.substring(h+(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 nr(e){const t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Bi(e){const t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function zi(e,t,s,n){if(e==="/"&&s.index)return{node:s.index,skipped:0};const r=!Ye(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 d=a.pop(),{node:c,index:h,skipped:f,depth:g,statics:p,dynamics:v,optionals:m}=d;let{extract:y,rawParams:C}=d;if(c.kind===2&&c.route&&!at(l,d))continue;if(c.parse){if(!nn(e,t,d))continue;C=d.rawParams,y=d.extract}n&&c.route&&c.kind!==ue&&at(u,d)&&(u=d);const S=h===o;if(S&&(c.route&&(!i||c.kind===ue||c.kind===2)&&at(l,d)&&(l=d),!c.optional&&!c.wildcard&&!c.index&&!c.pathless))continue;const w=S?void 0:t[h];let _;if(S&&c.index){const b={node:c.index,index:h,skipped:f,depth:g+1,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C};let M=!0;if(c.index.parse&&(nn(e,t,b)||(M=!1)),M){if(!v&&!m&&!f&&Hi(p,o))return b;at(l,b)&&(l=b)}}if(c.wildcard)for(let b=c.wildcard.length-1;b>=0;b--){const M=c.wildcard[b],{prefix:I,suffix:x}=M;if(!(I&&(S||!(M.caseSensitive?w:_??=w.toLowerCase()).startsWith(I)))){if(x){if(S)continue;const P=t.slice(h).join("/").slice(-x.length);if((M.caseSensitive?P:P.toLowerCase())!==x)continue}a.push({node:M,index:o,skipped:f,depth:g+1,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C})}}if(c.optional){const b=f|1<<g,M=g+1;for(let I=c.optional.length-1;I>=0;I--){const x=c.optional[I];a.push({node:x,index:h,skipped:b,depth:M,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C})}if(!S)for(let I=c.optional.length-1;I>=0;I--){const x=c.optional[I],{prefix:P,suffix:F}=x;if(P||F){const Q=x.caseSensitive?w:_??=w.toLowerCase();if(P&&!Q.startsWith(P)||F&&!Q.endsWith(F))continue}a.push({node:x,index:h+1,skipped:f,depth:M,statics:p,dynamics:v,optionals:m+ot(o,h),extract:y,rawParams:C})}}if(!S&&c.dynamic&&w)for(let b=c.dynamic.length-1;b>=0;b--){const M=c.dynamic[b],{prefix:I,suffix:x}=M;if(I||x){const P=M.caseSensitive?w:_??=w.toLowerCase();if(I&&!P.startsWith(I)||x&&!P.endsWith(x))continue}a.push({node:M,index:h+1,skipped:f,depth:g+1,statics:p,dynamics:v+ot(o,h),optionals:m,extract:y,rawParams:C})}if(!S&&c.staticInsensitive){const b=c.staticInsensitive.get(_??=w.toLowerCase());b&&a.push({node:b,index:h+1,skipped:f,depth:g+1,statics:p+ot(o,h),dynamics:v,optionals:m,extract:y,rawParams:C})}if(!S&&c.static){const b=c.static.get(w);b&&a.push({node:b,index:h+1,skipped:f,depth:g+1,statics:p+ot(o,h),dynamics:v,optionals:m,extract:y,rawParams:C})}if(c.pathless){const b=g+1;for(let M=c.pathless.length-1;M>=0;M--){const I=c.pathless[M];a.push({node:I,index:h,skipped:f,depth:b,statics:p,dynamics:v,optionals:m,extract:y,rawParams:C})}}}if(l)return l;if(n&&u){let d=u.index;for(let h=0;h<u.index;h++)d+=t[h].length;const c=d===e.length?"/":e.slice(d);return u.rawParams??=Object.create(null),u.rawParams["**"]=decodeURIComponent(c),u}return null}function ot(e,t){return 2**(e-t-1)}function Hi(e,t){return e===2**(t-1)-1}function nn(e,t,s){let n,r;try{[n,r]=sr(e,t,s)}catch{return null}if(s.rawParams=n,s.extract=r,!s.node.parse)return!0;try{if(s.node.parse(n)===!1)return null}catch{}return!0}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 rr(e){return e==="/"?e:e.replace(/^\/{1,}/,"")}function ie(e){const t=e.length;return t>1&&e[t-1]==="/"?e.replace(/\/{1,}$/,""):e}function ir(e){return ie(rr(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 Ui({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 l=n.get(o);if(l)return l}let a;if(i)a=e.split("/");else if(r)a=t.split("/");else{for(a=e.split("/");a.length>1&&Ye(a)==="";)a.pop();const l=t.split("/");for(let d=0,c=l.length;d<c;d++){const h=l[d];h===""?d?d===c-1&&a.push(h):a=[h]:h===".."?a.pop():h==="."||a.push(h)}}a.length>1&&(Ye(a)===""?s==="never"&&a.pop():s==="always"&&a.push(""));const u=Rs(a.join("/"))||"/";return o&&n&&n.set(o,u),u}function ji(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 d=a;u=tr(e,d,u);const c=u[5];if(a=c+1,d===c)continue;const h=u[0];if(h===0){l+="/"+e.substring(d,c);continue}if(h===2){const f=t._splat;i._splat=f,i["*"]=f;const g=e.substring(d,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(h===1){const f=e.substring(u[2],u[3]);!r&&!(f in t)&&(r=!0),i[f]=t[f];const g=e.substring(d,u[1]),p=e.substring(u[4],c),v=$t(f,t,s)??"undefined";l+="/"+g+v+p;continue}if(h===3){const f=e.substring(u[2],u[3]),g=t[f];if(g==null)continue;i[f]=g;const p=e.substring(d,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 B(e){return e?.isNotFound===!0}function Gi(){try{return typeof window<"u"&&typeof window.sessionStorage=="object"?window.sessionStorage:void 0}catch{return}}var qi="tsr-scroll-restoration-v1_3";function Wi(){const e=Gi();if(!e)return null;let t={};try{const n=JSON.parse(e.getItem("tsr-scroll-restoration-v1_3")||"{}");Ae(n)&&(t=n)}catch{}return{get state(){return t},set:n=>{t=se(n,t)||t},persist:()=>{try{e.setItem(qi,JSON.stringify(t))}catch{}}}}var ln=Wi(),Ki=e=>e.state.__TSR_key||e.href;function Qi(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,je="window",un="data-scroll-restoration-id";function Ji(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||Ki,r=new Map;window.history.scrollRestoration="manual";const i=a=>{if(!(lt||!e.isScrollRestoring))if(a.target===document||a.target===window)r.set(je,{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,d]of r){let c;if(l===je)c=je;else if(l.isConnected){const h=l.getAttribute(un);c=h?`[${un}="${h}"]`:Qi(l)}c&&(u[c]=d)}};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,d=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 h=!1;if(c)for(const f in c){const g=c[f];if(!Ae(g))continue;const{scrollX:p,scrollY:v}=g;if(!(!Number.isFinite(p)||!Number.isFinite(v))){if(f===je)window.scrollTo({top:v,left:p,behavior:l}),h=!0;else if(f){let m;try{m=document.querySelector(f)}catch{continue}m&&(m.scrollLeft=p,m.scrollTop=v,h=!0)}}}if(!h){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),d)for(const p of d){if(p===je)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 Yi(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 Vt(e){return e?e==="false"?!1:e==="true"?!0:+e*0===0&&+e+""===e?+e:e:""}function Xi(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]=Vt(r):Array.isArray(i)?i.push(Vt(r)):s[n]=[i,Vt(r)]}return s}var Zi=to(JSON.parse),eo=so(JSON.stringify,JSON.parse);function to(e){return t=>{t[0]==="?"&&(t=t.substring(1));const s=Xi(t);for(const n in s){const r=s[n];if(typeof r=="string")try{s[n]=e(r)}catch{}}return s}}function so(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=Yi(r,n);return i?`?${i}`:""}}var gt="__root__";function no(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 ro(e){return{input:({url:t})=>{for(const s of e)t=rs(s,t);return t},output:({url:t})=>{for(let s=e.length-1;s>=0;s--)t=or(e[s],t);return t}}}function io(e){const t=ir(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 rs(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 or(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 oo(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),d=s(e.loadedAt),c=s(e.isLoading),h=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(()=>Bt(o,m.get())),w=n(()=>Bt(a,y.get())),_=n(()=>Bt(u,C.get())),b=n(()=>m.get()[0]),M=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:d.get(),isLoading:c.get(),isTransitioning:h.get(),matches:S.get(),location:f.get(),resolvedLocation:g.get(),statusCode:p.get(),redirect:v.get()})),P=Ze(64);function F(J){let $e=P.get(J);return $e||($e=n(()=>{const xs=m.get();for(const Es of xs){const st=o.get(Es);if(st&&st.routeId===J)return st.get()}}),P.set(J,$e)),$e}const Q={status:l,loadedAt:d,isLoading:c,isTransitioning:h,location:f,resolvedLocation:g,statusCode:p,redirect:v,matchesId:m,pendingIds:y,cachedIds:C,matches:S,pendingMatches:w,cachedMatches:_,firstId:b,hasPending:M,matchRouteDeps:I,matchStores:o,pendingMatchStores:a,cachedMatchStores:u,__store:x,getRouteMatchStore:F,setMatches:U,setPending:ne,setCached:tt};U(e.matches),i?.(Q);function U(J){zt(J,o,m,s,r)}function ne(J){zt(J,a,y,s,r)}function tt(J){zt(J,u,C,s,r)}return Q}function Bt(e,t){const s=[];for(const n of t){const r=e.get(n);r&&s.push(r.get())}return s}function zt(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)}Fi(s.get(),i)||s.set(i)})}var is=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},ao=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),Pt=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),we=(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)&&!B(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":B(s)?"notFound":n.status==="pending"?"success":n.status,context:we(e,t.index),isFetching:!1,error:s})),B(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},ar=(e,t)=>{const s=e.router.getMatch(t);return!!(!s||s._nonReactive.dehydrated)},dn=(e,t,s)=>{const n=we(e,s);e.updateMatch(t,r=>({...r,context:n}))},Ge=(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)&&!B(s)&&(e.serialError??=s)};var lr=(e,t,s,n)=>{if(n._nonReactive.pendingTimeout!==void 0)return;const r=s.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!Pt(e,t)&&(s.options.loader||s.options.beforeLoad||cr(s))&&typeof r=="number"&&r!==1/0&&(s.options.pendingComponent??e.router.options?.defaultPendingComponent)){const i=setTimeout(()=>{is(e)},r);n._nonReactive.pendingTimeout=i}},lo=(e,t,s)=>{const n=e.router.getMatch(t);if(!n._nonReactive.beforeLoadPromise&&!n._nonReactive.loaderPromise)return;lr(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()},uo=(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&&Ge(e,s,o,"PARSE_PARAMS"),a&&Ge(e,s,a,"VALIDATE_SEARCH"),lr(e,t,n,r);const u=new AbortController;let l=!1;const d=()=>{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(()=>{d(),c()});return}r._nonReactive.beforeLoadPromise=De();const h={...we(e,s,!1),...r.__routeContext},{search:f,params:g,cause:p}=r,v=Pt(e,t),m={search:f,abortController:u,params:g,preload:v,context:h,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(()=>{d(),c()});return}(q(S)||B(S))&&(d(),Ge(e,s,S,"BEFORE_LOAD")),e.router.batch(()=>{d(),e.updateMatch(t,w=>({...w,__beforeLoadContext:S})),c()})};let C;try{if(C=n.options.beforeLoad(m),Xe(C))return d(),C.catch(S=>{Ge(e,s,S,"BEFORE_LOAD")}).then(y)}catch(S){d(),Ge(e,s,S,"BEFORE_LOAD")}y(C)},co=(e,t)=>{const{id:s,routeId:n}=e.matches[t],r=e.router.looseRoutesById[n],i=()=>a(),o=()=>uo(e,s,t,r),a=()=>{if(ar(e,s))return;const u=lo(e,s,r);return Xe(u)?u.then(o):o()};return i()},ho=(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}))},ur=(e,t,s,n,r)=>{const i=t[n-1],{params:o,loaderDeps:a,abortController:u,cause:l}=e.router.getMatch(s),d=we(e,n),c=Pt(e,s);return{params:o,deps:a,preload:!!c,parentMatchPromise:i,abortController:u,context:d,location:e.location,navigate:h=>e.router.navigate({...h,_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{et(r);const o=r.options.loader,a=typeof o=="function"?o:o?.handler,u=a?.(ur(e,t,s,n,r)),l=!!a&&Xe(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,h=>({...h,loaderData:c}))}r._lazyPromise&&await r._lazyPromise;const d=i._nonReactive.minPendingPromise;d&&await d,r._componentsPromise&&await r._componentsPromise,e.updateMatch(s,c=>({...c,error:void 0,context:we(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:we(e,n)}));return}const u=i._nonReactive.minPendingPromise;u&&await u,B(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)&&!B(a)&&await et(r,["errorComponent"]),e.updateMatch(s,l=>({...l,error:a,context:we(e,n),status:"error",isFetching:!1}))}}catch(i){const o=e.router.getMatch(s);o&&(o._nonReactive.loaderPromise=void 0),ce(e,o,i)}},fo=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(ur(e,t,r,s,m)):S,{status:_,invalid:b}=v,M=y>=C&&(!!e.forceStaleReload||v.cause==="enter"||p!==void 0&&p!==v.id);o=_==="success"&&(b||(w??M)),f&&m.options.preload===!1||(o&&!e.sync&&d?(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,d=((typeof l=="function"?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!=="blocking";if(ar(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=Pt(e,r);if(f._nonReactive.loaderPromise){if(f.status==="success"&&!e.sync&&!f.preload&&d)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 h=a?c.isFetching:!1;return h!==c.isFetching||c.invalid!==!1?(e.updateMatch(r,f=>({...f,isFetching:h,invalid:!1})),e.router.getMatch(r)):c};async function fn(e){const t=e,s=[];ao(t.router)&&is(t);let n;for(let h=0;h<t.matches.length;h++){try{const f=co(t,h);Xe(f)&&await f}catch(f){if(q(f))throw f;if(B(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 h=0;h<o;h++)s.push(fo(t,s,h));try{await Promise.all(s)}catch{const h=await Promise.allSettled(s);for(const f of h){if(f.status!=="rejected")continue;const g=f.reason;if(q(g))throw g;B(g)?a??=g:u??=g}if(u!==void 0)throw u}const l=a??(n&&!t.preload?n:void 0);let d=t.firstBadMatchIndex!==void 0?t.firstBadMatchIndex:t.matches.length-1;if(!l&&n&&t.preload)return t.matches;if(l){const h=cn(t,l);h===void 0&&oe();const f=t.matches[h],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})),d=h,await et(g,["notFoundComponent"])}else if(!t.preload){const h=t.matches[0];h.globalNotFound||t.router.getMatch(h.id)?.globalNotFound&&t.updateMatch(h.id,f=>({...f,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){const h=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await et(h,["errorComponent"])}for(let h=0;h<=d;h++){const{id:f,routeId:g}=t.matches[h],p=t.router.looseRoutesById[g];try{const v=ho(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=is(t);if(Xe(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 et(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 cr(e){for(const t of pt)if(e.options[t]?.preload)return!0;return!1}var pt=["component","errorComponent","pendingComponent","notFoundComponent"],ge="__TSR_index",pn="popstate",mn="beforeunload";function go(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?.()??[],d=u.type==="PUSH"||u.type==="REPLACE";if(typeof document<"u"&&l.length&&d)for(const c of l){const h=Rt(u.path,u.state);if(await c.blockerFn({currentLocation:t,nextLocation:h,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[ge];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[ge];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[ge]!==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,[ge]:e}}function po(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=M=>r=M,a=e?.createHref??(M=>M),u=e?.parseLocation??(()=>Rt(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){const M=ws();t.history.replaceState({[ge]:0,key:M,__TSR_key:M},"")}let l=u(),d,c=!1,h=!1,f=!1,g=!1;const p=()=>l;let v,m;const y=()=>{v&&(b._ignoreSubscribers=!0,(v.isPush?t.history.pushState:t.history.replaceState)(v.state,"",v.href),b._ignoreSubscribers=!1,v=void 0,m=void 0,d=void 0)},C=(M,I,x)=>{const P=a(I);m||(d=l),l=Rt(I,x),v={href:P,state:x,isPush:v?.isPush||M==="push"},m||(m=Promise.resolve().then(()=>y()))},S=M=>{l=u(),b.notify({type:M})},w=async()=>{if(h){h=!1;return}const M=u(),I=M.state[ge]-l.state[ge],x=I===1,P=I===-1,F=!x&&!P||c;c=!1;const Q=F?"GO":P?"BACK":"FORWARD",U=F?{type:"GO",index:I}:{type:P?"BACK":"FORWARD"};if(f)f=!1;else{const ne=i();if(typeof document<"u"&&ne.length){for(const tt of ne)if(await tt.blockerFn({currentLocation:l,nextLocation:M,action:Q})){h=!0,t.history.go(1),b.notify(U);return}}}l=u(),b.notify(U)},_=M=>{if(g){g=!1;return}let I=!1;const x=i();if(typeof document<"u"&&x.length)for(const P of x){const F=P.enableBeforeUnload??!0;if(F===!0){I=!0;break}if(typeof F=="function"&&F()===!0){I=!0;break}}if(I)return M.preventDefault(),M.returnValue=""},b=go({getLocation:p,getLength:()=>t.history.length,pushState:(M,I)=>C("push",M,I),replaceState:(M,I)=>C("replace",M,I),back:M=>(M&&(f=!0),g=!0,t.history.back()),forward:M=>{M&&(f=!0),g=!0,t.history.forward()},go:M=>{c=!0,t.history.go(M)},createHref:M=>a(M),flush:y,destroy:()=>{t.history.pushState=s,t.history.replaceState=n,t.removeEventListener(mn,_,{capture:!0}),t.removeEventListener(pn,w)},onBlocked:()=>{d&&l!==d&&(l=d)},getBlockers:i,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(mn,_,{capture:!0}),t.addEventListener(pn,w),t.history.pushState=function(...M){const I=s.apply(t.history,M);return b._ignoreSubscribers||S("PUSH"),I},t.history.replaceState=function(...M){const I=n.apply(t.history,M);return b._ignoreSubscribers||S("REPLACE"),I},b}function mo(e){let t=e.replace(/[\x00-\x1f\x7f]/g,"");return t.startsWith("//")&&(t="/"+t.replace(/^\/+/,"")),t}function Rt(e,t){const s=mo(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||{[ge]:0,key:i,__TSR_key:i}}}function ws(){return(Math.random()+1).toString(36).substring(7)}function Oe(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 vo=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.routeBranchCache=new WeakMap,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=ji(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=po()),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 d;this.resolvePathCache=Ze(1e3),d=this.buildRouteTree(),this.setRoutes(d)}if(!this.stores&&this.latestLocation){const d=this.getStoreConfig(this);this.batch=d.batch,this.stores=oo(yo(this.latestLocation),d),Ji(this)}let a=!1;const u=this.options.basepath??"/",l=this.options.rewrite;if(i||r!==u||o!==l){this.basepath=u;const d=[],c=ir(u);c&&c!=="/"&&d.push(io({basepath:u})),l&&d.push(l),this.rewrite=d.length===0?void 0:d.length===1?d[0]:ro(d),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=Vi(this.routeTree,this.options.caseSensitive,(n,r)=>{n.init({originalIndex:r})});return this.options.routeMasks&&Ai(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:d,href:c,state:h})=>{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+d,publicHref:u+y+d,pathname:Ue(u).path,external:!1,searchStr:y,search:Se(n?.search,m),hash:Ue(d.slice(1)).path,state:le(n?.state,h)}}const f=new URL(c,this.origin),g=rs(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:Ue(g.pathname).path,external:!!this.rewrite&&g.origin!==this.origin,searchStr:v,search:Se(n?.search,p),hash:Ue(g.hash.slice(1)).path,state:le(n?.state,h)}},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)=>Ui({base:s,to:n.includes("//")?Rs(n):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=>Co({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=i.to?`${i.to}`:void 0,d=a.search,c=Object.assign(Object.create(null),a.params),h=l?.charCodeAt(0)===47?"/":this.resolvePathWithBase(u,"."),f=l?this.resolvePathWithBase(h,l):h,g=i.params===!1||i.params===null?Object.create(null):(i.params??!0)===!0?c:Object.assign(c,se(i.params,c)),p=this.routesByPath[ie(f)];let v;if(p)v=this.getRouteBranch(p);else if(f.includes("$"))v=[];else{const P=this.getMatchedRoutes(f);v=P.matchedRoutes,this.options.notFoundRoute&&(!P.foundRoute||P.foundRoute.path!=="/"&&P.routeParams["**"])&&(v=[...v,this.options.notFoundRoute])}if(v.length&&Ct(g))for(const P of v){const F=P.options.params?.stringify??P.options.stringifyParams;if(F)try{Object.assign(g,F(g))}catch{}}const m=s.leaveParams?f:Ue(on({path:f,params:g,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path;let y=d;if(s._includeValidateSearch&&this.options.search?.strict){const P={};v.forEach(F=>{if(F.options.validateSearch)try{Object.assign(P,mt(F.options.validateSearch,{...P,...y}))}catch{}}),y=P}y=Ro({search:y,dest:i,destRoutes:v,_includeValidateSearch:s._includeValidateSearch}),y=Se(d,y);const C=this.options.stringifySearch(y),S=i.hash===!0?o.hash:i.hash?se(i.hash,o.hash):void 0,w=S?`#${S}`:"";let _=i.state===!0?o.state:i.state?se(i.state,o.state):{};_=le(o.state,_);const b=`${m}${C}${w}`;let M,I,x=!1;if(this.rewrite){const P=new URL(b,this.origin),F=or(this.rewrite,P);M=P.href.replace(P.origin,""),F.origin!==this.origin?(I=F.href,x=!0):I=F.pathname+F.search+F.hash}else M=Ti(b),I=M;return{publicHref:I,href:M,pathname:m,search:y,searchStr:C,state:_,hash:S??"",external:x,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 d=Di(a.pathname,this.processedTree);if(d){Object.assign(l,d.rawParams);const{from:c,params:h,...f}=d.route,g=h===!1||h===null?Object.create(null):(h??!0)===!0?l:Object.assign(l,se(h,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(d=>{r.state[d]=this.latestLocation.state[d]});const l=fe(r.state,this.latestLocation.state);return u.forEach(d=>{delete r.state[d]}),l},o=ie(this.latestLocation.href)===ie(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,...d}=r;u&&(d={...u,state:{...u.state,__tempKey:void 0,__tempLocation:{...d,search:d.searchStr,state:{...d.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(d.unmaskOnReload??this.options.unmaskOnReload??!1)&&(d.state.__tempKey=this.tempLocationKey)),d.state.__hashScrollIntoViewOptions=l??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=s,this.history[r.replace?"replace":"push"](d.publicHref,d.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,h=Rt(a,{__TSR_index:s?c:c+1}),f=new URL(h.pathname,this.origin);u.to=rs(this.rewrite,f).pathname,u.search=this.options.parseSearch(h.search),u.hash=h.hash.slice(1)}const l=this.buildLocation({...u,_includeValidateSearch:!0});this.pendingBuiltLocation=l;const d=this.commitLocation({...l,viewTransition:i,replace:s,resetScroll:n,hashScrollIntoView:r,ignoreBlocker:o});return Promise.resolve().then(()=>{this.pendingBuiltLocation===l&&(this.pendingBuiltLocation=void 0)}),d},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(ye(u,this.protocolAllowlist))return Promise.resolve();if(!o.ignoreBlocker){const l=this.history.getBlockers?.()??[];for(const d of l)if(d?.blockerFn&&await d.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,d=Oe(l,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:"onBeforeNavigate",...d}),this.emit({type:"onBeforeLoad",...d}),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,h=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);h=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[[h,"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})):B(l)&&(r=l);const d=n?n.status:r?404:this.stores.matches.get().some(c=>c.status==="error")?500:200;this.batch(()=>{this.stores.statusCode.set(d),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(Oe(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&&ye(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=et,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(d=>d.id===u?l(d):d):this.updateMatch(u,l)}}),r}catch(u){if(q(u))return u.options.reloadDocument?void 0:await this.preloadRoute({...u.options,_fromLocation:n});B(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=ki(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??eo,parseSearch:e.parseSearch??Zi,protocolAllowlist:e.protocolAllowlist??Li}),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)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=nr(e),this.routeBranchCache.set(e,t)),t}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}=s;let{matchedRoutes:i}=s,o=!1;(n?n.path!=="/"&&r["**"]:ie(e.pathname))&&(this.options.notFoundRoute?i=[...i,this.options.notFoundRoute]:o=!0);const a=o?bo(this.options.notFoundMode,i):void 0,u=new Array(i.length),l=new Map;for(const d of this.stores.matchStores.values())d.routeId&&l.set(d.routeId,d.get());for(let d=0;d<i.length;d++){const c=i[d],h=u[d-1];let f,g,p;{const F=h?.search??e.search,Q=h?._strictSearch??void 0;try{const U=mt(c.options.validateSearch,{...F})??void 0;f={...F,...U},g={...Q,...U},p=void 0}catch(U){let ne=U;if(U instanceof wt||(ne=new wt(U.message,{cause:U})),t?.throwOnError)throw ne;f=F,g={},p=ne}}const v=c.options.loaderDeps?.({search:f})??"",m=v?JSON.stringify(v):"",{interpolatedPath:y,usedParams:C}=on({path:c.fullPath,params:r,decoder:this.pathParamsDecoder,server:this.isServer}),S=c.id+y+m,w=this.getMatch(S),_=l.get(c.id),b=w?._strictParams??C;let M;if(!w)try{Sn(c,b)}catch(F){if(B(F)||q(F)?M=F:M=new So(F.message,{cause:F}),t?.throwOnError)throw M}Object.assign(r,b);const I=_?"stay":"enter";let x;if(w)x={...w,cause:I,params:_?.params??r,_strictParams:b,search:Se(_?_.search:w.search,f),_strictSearch:g};else{const F=c.options.loader||c.options.beforeLoad||c.lazyFn||cr(c)?"pending":"success";x={id:S,ssr:c.options.ssr,index:d,routeId:c.id,params:_?.params??r,_strictParams:b,pathname:y,updatedAt:Date.now(),search:_?Se(_.search,f):f,_strictSearch:g,searchError:void 0,status:F,isFetching:!1,error:void 0,paramsError:M,__routeContext:void 0,_nonReactive:{loadPromise:De()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:I,loaderDeps:_?le(_.loaderDeps,v):v,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:c.options.staticData||{},fullPath:c.fullPath}}t?.preload||(x.globalNotFound=a===c.id),x.searchError=p;const P=this.getParentContext(h);x.context={...P,...x.__routeContext,...x.__beforeLoadContext},u[d]=x}for(let d=0;d<u.length;d++){const c=u[d],h=this.looseRoutesById[c.routeId],f=this.getMatch(c.id),g=l.get(c.routeId);if(c.params=g?Se(g.params,r):r,!f){const p=u[d-1],v=this.getParentContext(p);if(h.options.context){const m={deps:c.loaderDeps,params:c.params,context:v??{},location:e,navigate:y=>this.navigate({...y,_fromLocation:e}),buildLocation:this.buildLocation,cause:c.cause,abortController:c.abortController,preload:!!c.preload,matches:u,routeId:h.id};c.__routeContext=h.options.context(m)??void 0}c.context={...v,...c.__routeContext,...c.__beforeLoadContext}}}return u}matchRoutesLightweight(e){const{matchedRoutes:t,routeParams:s}=this.getMatchedRoutes(e.pathname),n=Ye(t),r={...e.search};for(const l of t)try{Object.assign(r,mt(l.options.validateSearch,r))}catch{}const i=Ye(this.stores.matchesId.get()),o=i&&this.stores.matchStores.get(i)?.get(),a=o&&o.routeId===n.id&&o.pathname===e.pathname;let u;if(a)u=o.params;else{const l=Object.assign(Object.create(null),s);for(const d of t)try{Sn(d,l)}catch{}u=l}return{matchedRoutes:t,fullPath:n.fullPath,search:r,params:u}}},wt=class extends Error{},So=class extends Error{};function yo(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 wt("Async validation not supported");if(s.issues)throw new wt(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 Co({pathname:e,routesById:t,processedTree:s}){const n=Object.create(null),r=ie(e);let i;const o=Ni(r,s,!0);return o&&(i=o.route,Object.assign(n,o.rawParams)),{matchedRoutes:o?.branch||[t.__root__],routeParams:n,foundRoute:i}}function Ro({search:e,dest:t,destRoutes:s,_includeValidateSearch:n}){return wo(s)(e,t,n??!1)}function wo(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((d,c)=>c(d),o));const l=a(u);return"postSearchFilters"in r.options&&r.options.postSearchFilters?r.options.postSearchFilters.reduce((d,c)=>c(d),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:se(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 bo(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){const s=e.options.params?.parse??e.options.parseParams;if(s){const n=s(t);if(n===!1)throw new Error("Route params.parse returned false for a matched route");Object.assign(t,n)}}var Mo="Error preloading route! ☝️",dr=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||oe();let r=n?gt:s?.path;r&&r!=="/"&&(r=rr(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=ie(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=>no({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.")}},_o=class extends dr{constructor(e){super(e)}};function Po(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??Ms;return(0,E.jsx)(Io,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:s,reset:n})=>s?R.createElement(t,{error:s,reset:n}):e.children})}var Io=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 Ms({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 xo({children:e,fallback:t=null}){return hr()?(0,E.jsx)(R.Fragment,{children:e}):(0,E.jsx)(R.Fragment,{children:t})}function hr(){return R.useSyncExternalStore(Eo,()=>!0,()=>!1)}function Eo(){return()=>{}}var fr=R.createContext(null);function Z(e){return R.useContext(fr)}var It=R.createContext(void 0),Lo=R.createContext(void 0),D=(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))(D||{});function To({update:e,notify:t,unwatched:s}){return{link:n,unlink:r,propagate:i,checkDirty:o,shallowPropagate:a};function n(l,d,c){const h=d.depsTail;if(h!==void 0&&h.dep===l)return;const f=h!==void 0?h.nextDep:d.deps;if(f!==void 0&&f.dep===l){f.version=c,d.depsTail=f;return}const g=l.subsTail;if(g!==void 0&&g.version===c&&g.sub===d)return;const p=d.depsTail=l.subsTail={version:c,dep:l,sub:d,prevDep:h,nextDep:f,prevSub:g,nextSub:void 0};f!==void 0&&(f.prevDep=p),h!==void 0?h.nextDep=p:d.deps=p,g!==void 0?g.nextSub=p:l.subs=p}function r(l,d=l.sub){const c=l.dep,h=l.prevDep,f=l.nextDep,g=l.nextSub,p=l.prevSub;return f!==void 0?f.prevDep=h:d.depsTail=h,h!==void 0?h.nextDep=f:d.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 d=l.nextSub,c;e:do{const h=l.sub;let f=h.flags;if(f&60?f&12?f&4?!(f&48)&&u(l,h)?(h.flags=f|40,f&=1):f=0:h.flags=f&-9|32:f=0:h.flags=f|32,f&2&&t(h),f&1){const g=h.subs;if(g!==void 0){const p=(l=g).nextSub;p!==void 0&&(c={value:d,prev:c},d=p);continue}}if((l=d)!==void 0){d=l.nextSub;continue}for(;c!==void 0;)if(l=c.value,c=c.prev,l!==void 0){d=l.nextSub;continue e}break}while(!0)}function o(l,d){let c,h=0,f=!1;e:do{const g=l.dep,p=g.flags;if(d.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,d=g,++h;continue}if(!f){const v=l.nextDep;if(v!==void 0){l=v;continue}}for(;h--;){const v=d.subs,m=v.nextSub!==void 0;if(m?(l=c.value,c=c.prev):l=v,f){if(e(d)){m&&a(v),d=l.sub;continue}f=!1}else d.flags&=-33;d=l.sub;const y=l.nextDep;if(y!==void 0){l=y;continue e}}return f}while(!0)}function a(l){do{const d=l.sub,c=d.flags;(c&48)===32&&(d.flags=c|16,(c&6)===2&&t(d))}while((l=l.nextSub)!==void 0)}function u(l,d){let c=d.depsTail;for(;c!==void 0;){if(c===l)return!0;c=c.prevDep}return!1}}function Fo(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 os=[],vt=0,{link:yn,unlink:Oo,propagate:Ao,checkDirty:gr,shallowPropagate:Cn}=To({update(e){return e._update()},notify(e){os[as++]=e,e.flags&=~D.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=D.Mutable|D.Dirty,bt(e))}}),ut=0,as=0,te,ls=0;function pr(e){try{++ls,e()}finally{--ls||mr()}}function bt(e){const t=e.depsTail;let s=t!==void 0?t.nextDep:e.deps;for(;s!==void 0;)s=Oo(s,e)}function mr(){if(!(ls>0)){for(;ut<as;){const e=os[ut];os[ut++]=void 0,e.notify()}ut=0,as=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?D.None:D.Mutable,get(){return te!==void 0&&yn(r,te,vt),r._snapshot},subscribe(i){const o=Fo(i),a={current:!1},u=Do(()=>{r.get(),a.current?o.next?.(r._snapshot):a.current=!0});return{unsubscribe:()=>{u.stop()}}},_update(i){const o=te,a=t?.compare??Object.is;if(s)te=r,++vt,r.depsTail=void 0;else if(i===void 0)return!1;s&&(r.flags=D.Mutable|D.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{te=o,s&&(r.flags&=~D.RecursedCheck),bt(r)}}};return s?(r.flags=D.Mutable|D.Dirty,r.get=function(){const i=r.flags;if(i&D.Dirty||i&D.Pending&&gr(r.deps,r)){if(r._update()){const o=r.subs;o!==void 0&&Cn(o)}}else i&D.Pending&&(r.flags=i&~D.Pending);return te!==void 0&&yn(r,te,vt),r._snapshot}):r.set=function(i){if(r._update(i)){const o=r.subs;o!==void 0&&(Ao(o),Cn(o),mr())}},r}function Do(e){const t=()=>{const n=te;te=s,++vt,s.depsTail=void 0,s.flags=D.Watching|D.RecursedCheck;try{return e()}finally{te=n,s.flags&=~D.RecursedCheck,bt(s)}},s={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:D.Watching|D.RecursedCheck,notify(){const n=this.flags;n&D.Dirty||n&D.Pending&&gr(this.deps,this)?t():this.flags=D.Watching},stop(){this.flags=D.None,this.depsTail=void 0,bt(this)}};return t(),s}var ko=ke((e=>{var t=gs();function s(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&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(h,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})},[h,g,f]),i(function(){return l(v)&&m({inst:v}),h(function(){l(v)&&m({inst:v})})},[h]),a(g),g}function l(h){var f=h.getSnapshot;h=h.value;try{var g=f();return!n(h,g)}catch{return!0}}function d(h,f){return f()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:u;e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:c})),No=ke(((e,t)=>{t.exports=ko()})),$o=ke((e=>{var t=gs(),s=No();function n(d,c){return d===c&&(d!==0||1/d===1/c)||d!==d&&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(d,c,h,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(b){if(!C){if(C=!0,S=b,b=f(b),g!==void 0&&v.hasValue){var M=v.value;if(g(M,b))return w=M}return w=b}if(M=w,r(S,b))return M;var I=f(b);return g!==void 0&&g(M,I)?(S=b,M):(S=b,w=I)}var C=!1,S,w,_=h===void 0?null:h;return[function(){return y(c())},_===null?void 0:function(){return y(_())}]},[c,h,f,g]);var m=i(d,p[0],p[1]);return a(function(){v.hasValue=!0,v.value=m},[m]),l(m),m}})),Vo=ke(((e,t)=>{t.exports=$o()})),Bo=Vo();function zo(e,t){return e===t}function W(e,t,s=zo){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,Bo.useSyncExternalStoreWithSelector)(n,r,r,t,s)}var Ho={get:()=>{},subscribe:()=>({unsubscribe:()=>{}})};function _e(e){const t=Z(),s=R.useContext(e.from?Lo:It),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??Ho,o=>{if((e.shouldThrow??!0)&&!o&&oe(),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 vr(e){return _e({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function Sr(e){const{select:t,...s}=e;return _e({...s,select:n=>t?t(n.loaderDeps):n.loaderDeps})}function yr(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 Cr(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 Rr(e){const t=Z();return R.useCallback(s=>t.navigate({...s,from:s.from??e?.from}),[e?.from,t])}function wr(e){return _e({...e,select:t=>e.select?e.select(t.context):t.context})}var br=zn(Hr(),1);function Uo(e,t){const s=Z(),n=_i(t),r=!1,{activeProps:i,inactiveProps:o,activeOptions:a,to:u,preload:l,preloadDelay:d,preloadIntentProximity:c,hashScrollIntoView:h,replace:f,startTransition:g,resetScroll:p,viewTransition:v,children:m,target:y,disabled:C,style:S,className:w,onClick:_,onBlur:b,onFocus:M,onMouseEnter:I,onMouseLeave:x,onTouchStart:P,ignoreBlocker:F,params:Q,search:U,hash:ne,state:tt,mask:J,reloadDocument:$e,unsafeRelative:xs,from:Es,_fromLocation:st,...Pe}=e;if(r){const A=Pn(u);if(typeof u=="string"&&!A&&u.indexOf(":")>-1)try{return new URL(u),ye(u,s.protocolAllowlist)?{...Pe,ref:n,href:void 0,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}}:{...Pe,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=_n(O.maskedLocation?O.maskedLocation.publicHref:O.publicHref,O.maskedLocation?O.maskedLocation.external:O.external,s.history,C),He=(()=>{if(Y?.external)return ye(Y.href,s.protocolAllowlist)?void 0:Y.href;if(!A&&typeof u=="string"&&u.indexOf(":")>-1)try{return new URL(u),ye(u,s.protocolAllowlist)?void 0:u}catch{}})(),Ft=(()=>{if(He)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 $=Fe(N.pathname,s.basepath),G=Fe(O.pathname,s.basepath);if(!($.startsWith(G)&&($.length===G.length||$[G.length]==="/")))return!1}if((a?.includeSearch??!0)&&N.search!==O.search){const $=!N.search||typeof N.search=="object"&&!Ct(N.search),G=!O.search||typeof O.search=="object"&&!Ct(O.search);if(!($&&G)&&!fe(N.search,O.search,{partial:!j,ignoreUndefined:!a?.explicitUndefined}))return!1}return!a?.includeHash})();if(He)return{...Pe,ref:n,href:He,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w}};const Ot=Ft?se(i,{})??wn:xe,At=Ft?xe:se(o,{})??xe,$s=(()=>{const N=S,j=Ot.style,$=At.style;if(!(!N&&!j&&!$))return N&&!j&&!$?N:!N&&j&&!$?j:!N&&!j&&$?$:{...N,...j,...$}})(),Vs=(()=>{const N=w,j=Ot.className,$=At.className;if(!N&&!j&&!$)return"";let G="";return N&&(G=N),j&&(G=G?`${G} ${j}`:j),$&&(G=G?`${G} ${$}`:$),G})();return{...Pe,...Ot,...At,href:Y?.href,ref:n,disabled:!!C,target:y,...$s&&{style:$s},...Vs&&{className:Vs},...C&&bn,...Ft&&Mn}}const Et=hr(),Ve=R.useMemo(()=>e,[s,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),me=W(s.stores.location,A=>A,(A,O)=>A.href===O.href),z=R.useMemo(()=>{const A={_fromLocation:me,...Ve};return s.buildLocation(A)},[s,me,Ve]),Ls=z.maskedLocation?z.maskedLocation.publicHref:z.publicHref,Ts=z.maskedLocation?z.maskedLocation.external:z.external,Be=R.useMemo(()=>_n(Ls,Ts,s.history,C),[C,Ts,Ls,s.history]),ze=R.useMemo(()=>{if(Be?.external)return ye(Be.href,s.protocolAllowlist)?void 0:Be.href;if(!Pn(u)&&!(typeof u!="string"||u.indexOf(":")===-1))try{return new URL(u),ye(u,s.protocolAllowlist)?void 0:u}catch{}},[u,Be,s.protocolAllowlist]),Lt=R.useMemo(()=>{if(ze)return!1;if(a?.exact){if(!rn(me.pathname,z.pathname,s.basepath))return!1}else{const A=Fe(me.pathname,s.basepath),O=Fe(z.pathname,s.basepath);if(!(A.startsWith(O)&&(A.length===O.length||A[O.length]==="/")))return!1}return(a?.includeSearch??!0)&&!fe(me.search,z.search,{partial:!a?.exact,ignoreUndefined:!a?.explicitUndefined})?!1:a?.includeHash?Et&&me.hash===z.hash:!0},[a?.exact,a?.explicitUndefined,a?.includeHash,a?.includeSearch,me,ze,Et,z.hash,z.pathname,z.search,s.basepath]),nt=Lt?se(i,{})??wn:xe,rt=Lt?xe:se(o,{})??xe,Fs=[w,nt.className,rt.className].filter(Boolean).join(" "),Os=(S||nt.style||rt.style)&&{...S,...nt.style,...rt.style},[Vr,As]=R.useState(!1),Ds=R.useRef(!1),Ie=e.reloadDocument||ze?!1:l??s.options.defaultPreload,Tt=d??s.options.defaultPreloadDelay??0,ve=R.useCallback(()=>{s.preloadRoute({...Ve,_builtLocation:z}).catch(A=>{console.warn(A),console.warn(Mo)})},[s,Ve,z]);Mi(n,R.useCallback(A=>{A?.isIntersecting&&ve()},[ve]),Go,{disabled:!!C||Ie!=="viewport"}),R.useEffect(()=>{Ds.current||!C&&Ie==="render"&&(ve(),Ds.current=!0)},[C,ve,Ie]);const Br=A=>{const O=A.currentTarget.getAttribute("target"),Y=y!==void 0?y:O;if(!C&&!qo(A)&&!A.defaultPrevented&&(!Y||Y==="_self")&&A.button===0){A.preventDefault(),(0,br.flushSync)(()=>{As(!0)});const He=s.subscribe("onResolved",()=>{He(),As(!1)});s.navigate({...Ve,replace:f,resetScroll:p,hashScrollIntoView:h,startTransition:g,viewTransition:v,ignoreBlocker:F})}};if(ze)return{...Pe,ref:n,href:ze,...m&&{children:m},...y&&{target:y},...C&&{disabled:C},...S&&{style:S},...w&&{className:w},..._&&{onClick:_},...b&&{onBlur:b},...M&&{onFocus:M},...I&&{onMouseEnter:I},...x&&{onMouseLeave:x},...P&&{onTouchStart:P}};const ks=A=>{if(C||Ie!=="intent")return;if(!Tt){ve();return}const O=A.currentTarget;if(qe.has(O))return;const Y=setTimeout(()=>{qe.delete(O),ve()},Tt);qe.set(O,Y)},zr=A=>{C||Ie!=="intent"||ve()},Ns=A=>{if(C||!Ie||!Tt)return;const O=A.currentTarget,Y=qe.get(O);Y&&(clearTimeout(Y),qe.delete(O))};return{...Pe,...nt,...rt,href:Be?.href,ref:n,onClick:Ee([_,Br]),onBlur:Ee([b,Ns]),onFocus:Ee([M,ks]),onMouseEnter:Ee([I,ks]),onMouseLeave:Ee([x,Ns]),onTouchStart:Ee([P,zr]),disabled:!!C,target:y,...Os&&{style:Os},...Fs&&{className:Fs},...C&&bn,...Lt&&Mn,...Et&&Vr&&jo}}var xe={},wn={className:"active"},bn={role:"link","aria-disabled":!0},Mn={"data-status":"active","aria-current":"page"},jo={"data-transitioning":"transitioning"},qe=new WeakMap,Go={rootMargin:"100px"},Ee=e=>t=>{for(const s of e)if(s){if(t.defaultPrevented)return;s(t)}};function _n(e,t,s,n){if(!n)return t?{href:e,external:!0}:{href:s.createHref(e)||"/",external:!1}}function Pn(e){if(typeof e!="string")return!1;const t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Mr=R.forwardRef((e,t)=>{const{_asChild:s,...n}=e,{type:r,...i}=Uo(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 qo(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var Wo=class extends dr{constructor(e){super(e),this.useMatch=t=>_e({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>wr({...t,from:this.id}),this.useSearch=t=>Cr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>yr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>Sr({...t,from:this.id}),this.useLoaderData=t=>vr({...t,from:this.id}),this.useNavigate=()=>Rr({from:this.fullPath}),this.Link=R.forwardRef((t,s)=>(0,E.jsx)(Mr,{ref:s,from:this.fullPath,...t}))}};function Ko(e){return new Wo(e)}var Qo=class extends _o{constructor(e){super(e),this.useMatch=t=>_e({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>wr({...t,from:this.id}),this.useSearch=t=>Cr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>yr({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>Sr({...t,from:this.id}),this.useLoaderData=t=>vr({...t,from:this.id}),this.useNavigate=()=>Rr({from:this.fullPath}),this.Link=R.forwardRef((t,s)=>(0,E.jsx)(Mr,{ref:s,from:this.fullPath,...t}))}};function zl(e){return new Qo(e)}function Hl(e){return new Jo(e,{silent:!0}).createRoute}var Jo=class{constructor(e,t){this.path=e,this.createRoute=s=>{const n=Ko(s);return n.isRoot=!1,n},this.silent=t?.silent}};function Ul(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,xi(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 Yo(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(B(n))e.onCatch?.(n,r);else throw n},errorComponent:({error:n})=>{if(B(n))return e.fallback?.(n);throw n},children:e.children})}function Xo(){return(0,E.jsx)("p",{children:"Not Found"})}function Te(e){return(0,E.jsx)(E.Fragment,{children:e.children})}function _r(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)(Xo,{})}var Pr=R.memo(function({matchId:t}){const s=Z(),n=s.stores.matchStores.get(t);n||oe();const r=W(s.stores.loadedAt,o=>o),i=W(n,o=>o);return(0,E.jsx)(Zo,{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 Zo({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,d=n.ssr===!1||n.ssr==="data-only",c=(!r.isRoot||r.options.wrapInSuspense||d)&&(r.options.wrapInSuspense??i??(r.options.errorComponent?.preload||d))?R.Suspense:Te,h=a?bs:Te,f=l?Yo:Te;return(0,E.jsxs)(r.isRoot?r.options.shellComponent??Te:Te,{children:[(0,E.jsx)(It.Provider,{value:t,children:(0,E.jsx)(c,{fallback:o,children:(0,E.jsx)(h,{getResetKey:()=>s,errorComponent:a||Ms,onCatch:(g,p)=>{if(B(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:d||n._displayPending?(0,E.jsx)(xo,{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)(ea,{resetKey:s}),(e.options.scrollRestoration,null)]}):null]})}function ea({resetKey:e}){const t=Z(),s=R.useRef(void 0);return Ke(()=>{const n=t.latestLocation.href;(s.current===void 0||s.current!==n)&&(t.emit({type:"onRendered",...Oe(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=(d,c)=>s.getMatch(d.id)?._nonReactive[c]??d._nonReactive[c],r=s.stores.matchStores.get(t);r||oe();const i=W(r,d=>d),o=i.routeId,a=s.routesById[o],u=R.useMemo(()=>{const d=(s.routesById[o].options.remountDeps??s.options.defaultRemountDeps)?.({routeId:o,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return d?JSON.stringify(d):void 0},[o,i.loaderDeps,i._strictParams,i._strictSearch,s.options.defaultRemountDeps,s.routesById]),l=R.useMemo(()=>{const d=a.options.component??s.options.defaultComponent;return d?(0,E.jsx)(d,{},u):(0,E.jsx)(ta,{})},[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 d=a.options.pendingMinMs??s.options.defaultPendingMinMs;if(d){const c=s.getMatch(i.id);if(c&&!c._nonReactive.minPendingPromise){const h=De();c._nonReactive.minPendingPromise=h,setTimeout(()=>{h.resolve(),c._nonReactive.minPendingPromise=void 0},d)}}throw n(i,"loadPromise")}if(i.status==="notFound")return B(i.error)||oe(),_r(s,a,i.error);if(i.status==="redirected")throw q(i.error)||oe(),n(i,"loadPromise");if(i.status==="error")throw i.error;return l}),ta=R.memo(function(){const t=Z(),s=R.useContext(It);let n,r=!1,i;{const l=s?t.stores.matchStores.get(s):void 0;[n,r]=W(l,d=>[d?.routeId,d?.globalNotFound??!1]),i=W(t.stores.matchesId,d=>d[d.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||oe(),_r(t,o,void 0);if(!i)return null;const u=(0,E.jsx)(Pr,{matchId:i});return n==="__root__"?(0,E.jsx)(R.Suspense,{fallback:a,children:u}):u});function sa(){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=Dt(r),a=r||s||i,u=Dt(a),l=r||i,d=Dt(l);return e.startTransition=c=>{n(!0),R.startTransition(()=>{c(),n(!1)})},R.useEffect(()=>{const c=e.history.subscribe(e.load),h=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return ie(e.latestLocation.publicHref)!==ie(h.publicHref)&&e.commitLocation({...h,replace:!0}),()=>{c()}},[e,e.history]),Ke(()=>{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(h){console.error(h)}})()},[e]),Ke(()=>{o&&!r&&e.emit({type:"onLoad",...Oe(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,r]),Ke(()=>{d&&!l&&e.emit({type:"onBeforeRouteMount",...Oe(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,d,e]),Ke(()=>{if(u&&!a){const c=Oe(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:"onResolved",...c}),pr(()=>{e.stores.status.set("idle"),e.stores.resolvedLocation.set(e.stores.location.get())}),c.hrefChanged&&Po(e)}},[a,u,e]),null}function na(){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?Te:R.Suspense,{fallback:s,children:[(0,E.jsx)(sa,{}),(0,E.jsx)(ra,{})]});return e.options.InnerWrap?(0,E.jsx)(e.options.InnerWrap,{children:n}):n}function ra(){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)(Pr,{matchId:s}):null;return(0,E.jsx)(It.Provider,{value:s,children:e.options.disableGlobalCatchBoundary?r:(0,E.jsx)(bs,{getResetKey:()=>n,errorComponent:Ms,onCatch:void 0,children:r})})}var ia=e=>({createMutableStore:Rn,createReadonlyStore:Rn,batch:pr}),jl=e=>new oa(e),oa=class extends vo{constructor(e){super(e,ia)}};function aa({router:e,children:t,...s}){Ct(s)&&e.update({...e.options,...s,context:{...e.options.context,...s.context}});const n=(0,E.jsx)(fr.Provider,{value:e,children:t});return e.options.Wrap?(0,E.jsx)(e.options.Wrap,{children:n}):n}function Gl({router:e,...t}){return(0,E.jsx)(aa,{router:e,...t,children:(0,E.jsx)(na,{})})}function ql(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 la=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)}},ua=class extends la{constructor(){super({pluginId:"tanstack-ai-devtools"})}},xn=new ua;function ca(e){return e.type==="text"||e.type==="image"||e.type==="audio"||e.type==="video"||e.type==="document"}function Ir(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 da(e){return e.role==="system"?[]:e.role!=="assistant"?[ha(e)]:ga(e)}function ha(e){const t=[];for(const s of e.parts)ca(s)&&t.push(s);return{role:e.role,content:Ir(t)}}function Ln(){return{contentParts:[],toolCalls:[]}}function fa(e){return e.state==="input-complete"||e.state==="approval-responded"||e.output!==void 0}function ga(e){const t=[];let s=Ln();const n=new Set;function r(){const i=Ir(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":fa(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 pa(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||Mt(),role:e.role==="tool"?"assistant":e.role,parts:s}}function ma(e,t){return"parts"in e?{...e,id:e.id||t(),createdAt:e.createdAt||new Date}:{...pa(e,t()),createdAt:new Date}}function Mt(){return`msg-${Date.now()}-${Math.random().toString(36).substring(7)}`}var Tn=ke((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})),va=ke((e=>{var t=e&&e.__createBinding||(Object.create?(function(l,d,c,h){h===void 0&&(h=c);var f=Object.getOwnPropertyDescriptor(d,c);(!f||("get"in f?!d.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return d[c]}}),Object.defineProperty(l,h,f)}):(function(l,d,c,h){h===void 0&&(h=c),l[h]=d[c]})),s=e&&e.__exportStar||function(l,d){for(var c in l)c!=="default"&&!Object.prototype.hasOwnProperty.call(d,c)&&t(d,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,d=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(),d)}e.parseJSON=o;var a=(l,d)=>{const c=l.length;let h=0;const f=w=>{throw new r(`${w} at position ${h}`)},g=w=>{throw new i(`${w} at position ${h}`)},p=()=>(S(),h>=c&&f("Unexpected end of input"),l[h]==='"'?v():l[h]==="{"?m():l[h]==="["?y():l.substring(h,h+4)==="null"||n.Allow.NULL&d&&c-h<4&&"null".startsWith(l.substring(h))?(h+=4,null):l.substring(h,h+4)==="true"||n.Allow.BOOL&d&&c-h<4&&"true".startsWith(l.substring(h))?(h+=4,!0):l.substring(h,h+5)==="false"||n.Allow.BOOL&d&&c-h<5&&"false".startsWith(l.substring(h))?(h+=5,!1):l.substring(h,h+8)==="Infinity"||n.Allow.INFINITY&d&&c-h<8&&"Infinity".startsWith(l.substring(h))?(h+=8,1/0):l.substring(h,h+9)==="-Infinity"||n.Allow._INFINITY&d&&1<c-h&&c-h<9&&"-Infinity".startsWith(l.substring(h))?(h+=9,-1/0):l.substring(h,h+3)==="NaN"||n.Allow.NAN&d&&c-h<3&&"NaN".startsWith(l.substring(h))?(h+=3,NaN):C()),v=()=>{const w=h;let _=!1;for(h++;h<c&&(l[h]!=='"'||_&&l[h-1]==="\\");)_=l[h]==="\\"?!_:!1,h++;if(l.charAt(h)=='"')try{return JSON.parse(l.substring(w,++h-Number(_)))}catch(b){g(String(b))}else if(n.Allow.STR&d)try{return JSON.parse(l.substring(w,h-Number(_))+'"')}catch{return JSON.parse(l.substring(w,l.lastIndexOf("\\"))+'"')}f("Unterminated string literal")},m=()=>{h++,S();const w={};try{for(;l[h]!=="}";){if(S(),h>=c&&n.Allow.OBJ&d)return w;const _=v();S(),h++;try{w[_]=p()}catch(b){if(n.Allow.OBJ&d)return w;throw b}S(),l[h]===","&&h++}}catch{if(n.Allow.OBJ&d)return w;f("Expected '}' at end of object")}return h++,w},y=()=>{h++;const w=[];try{for(;l[h]!=="]";)w.push(p()),S(),l[h]===","&&h++}catch{if(n.Allow.ARR&d)return w;f("Expected ']' at end of array")}return h++,w},C=()=>{if(h===0){l==="-"&&g("Not sure what '-' is");try{return JSON.parse(l)}catch(_){if(n.Allow.NUM&d)try{return JSON.parse(l.substring(0,l.lastIndexOf("e")))}catch{}g(String(_))}}const w=h;for(l[h]==="-"&&h++;l[h]&&",]}".indexOf(l[h])===-1;)h++;h==c&&!(n.Allow.NUM&d)&&f("Unterminated number literal");try{return JSON.parse(l.substring(w,h))}catch{l.substring(w,h)==="-"&&f("Not sure what '-' is");try{return JSON.parse(l.substring(w,l.lastIndexOf("e")))}catch(b){g(String(b))}}},S=()=>{for(;h<c&&`
2
+ \r `.includes(l[h]);)h++};return p()},u=o;e.parse=u})),Sa=va(),ya=class{parse(e){if(!(!e||e.trim()===""))try{return(0,Sa.parse)(e)}catch{return}}},Ca=new ya;function Ra(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 Ht(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 Ut(e,t,s,n,r,i){return e.map(o=>{if(o.id!==t)return o;const a=[...o.parts],u=a.findIndex(d=>d.type==="tool-result"&&d.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 wa(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 jt(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 ba(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 Fn(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 Ma=class{shouldEmit(e,t){return!0}},_a=class xr{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 Ma,this.events=t.events||{},this.jsonParser=t.jsonParser||Ca,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??Mt(),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=jt(this.messages,t,s,n?"input-complete":void 0,n);const o=typeof s=="string"?s:JSON.stringify(s),a=n?"error":"complete";i=Ut(i,r.id,t,o,a,n),this.messages=i,this.emitMessagesChange()}addToolApprovalResponse(t,s){this.messages=ba(this.messages,t,s),this.emitMessagesChange()}toModelMessages(){const t=[];for(const s of this.messages)t.push(...da(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||Mt(),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=Ht(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=Ht(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=jt(this.messages,t.toolCallId,i);const o="complete";this.messages=Ut(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=jt(this.messages,t.toolCallId,n);const r="complete";this.messages=Ut(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=Fn(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=Fn(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=wa(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=Ht(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=Ra(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 xr(s).process(Pa(t))}};function Pa(e){return{async*[Symbol.asyncIterator](){for(const{chunk:t}of e.chunks)yield t}}}var Ia=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})}},xa=class extends Ia{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 Ea(e){if(!e)return{};if(e instanceof Headers){const t={};return e.forEach((s,n)=>{t[n]=s}),t}return e}async function*La(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 On(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 d;u.length>0?d=u.shift():d=await new Promise(c=>{const h=()=>c(null);l.push(f=>{a?.removeEventListener("abort",h),c(f)}),a?.addEventListener("abort",h,{once:!0})}),d!==null&&(yield d)}})()},async send(a,u,l){let d=!1;try{const c=e.connect(a,u,l);for await(const h of c)(h.type==="RUN_FINISHED"||h.type==="RUN_ERROR")&&(d=!0),o(h);!l?.aborted&&!d&&o({type:"RUN_FINISHED",runId:`run-${Date.now()}`,model:"connect-wrapper",timestamp:Date.now(),finishReason:"stop"})}catch(c){throw!l?.aborted&&!d&&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 Wl(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",...Ea(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 d=l.body?.getReader();if(!d)throw new Error("Response body is not readable");for await(const c of La(d,r)){const h=c.startsWith("data: ")?c.slice(6):c;if(h==="[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(h)}catch{console.warn("Failed to parse SSE chunk:",h)}}}}}var Ta=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=On(e.connection),this.events=new xa(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 _a({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=ma(e,Mt);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=On(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 Kl(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,d]=(0,R.useState)("ready"),[c,h]=(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 Ta({connection:C.current.connection,id:s,initialMessages:x,body:C.current.body,onResponse:P=>C.current.onResponse?.(P),onChunk:P=>C.current.onChunk?.(P),onFinish:P=>{C.current.onFinish?.(P)},onError:P=>{C.current.onError?.(P)},tools:C.current.tools,onCustomEvent:(P,F,Q)=>C.current.onCustomEvent?.(P,F,Q),streamProcessor:e.streamProcessor,onMessagesChange:P=>{r(P)},onLoadingChange:P=>{o(P)},onErrorChange:P=>{u(P)},onStatusChange:P=>{d(P)},onSubscriptionChange:P=>{h(P)},onConnectionStatusChange:P=>{g(P)},onSessionGeneratingChange:P=>{v(P)}})},[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]),b=(0,R.useCallback)(async()=>{await S.reload()},[S]),M=(0,R.useCallback)(()=>{S.stop()},[S]),I=(0,R.useCallback)(()=>{S.clear()},[S]);return{messages:n,sendMessage:w,append:_,reload:b,stop:M,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 Ql=new Uint8Array(128).fill(128);function de(e,t){return typeof e=="function"?e(t):e}function K(e,t){return s=>{t.setState(n=>({...n,[e]:de(s,n[e])}))}}function xt(e){return e instanceof Function}function Fa(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,d)=>n[d]!==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,d=Math.round((Date.now()-u)*100)/100,c=d/16,h=(f,g)=>{for(f=String(f);f.length<g;)f=" "+f;return f};console.info(`%c⏱ ${h(d,5)} /${h(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 Aa(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 Da(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 h=c;for(const g of a.split(".")){var f;h=(f=h)==null?void 0:f[g]}return h}:l=c=>c[o.accessorKey]),!u)throw new Error;let d={id:`${String(u)}`,accessorFn:l,parent:n,depth:s,columnDef:o,columns:[],getFlatColumns:L(()=>[!0],()=>{var c;return[d,...(c=d.columns)==null?void 0:c.flatMap(h=>h.getFlatColumns())]},T(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:L(()=>[e._getOrderColumnsFn()],c=>{var h;return(h=d.columns)!=null&&h.length?c(d.columns.flatMap(f=>f.getLeafColumns())):[d]},T(e.options,"debugColumns","column.getLeafColumns"))};for(const c of e._features)c.createColumn==null||c.createColumn(d,e);return d}var V="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(d=>s.find(c=>c.id===d)).filter(Boolean))!=null?i:[],u=(o=r?.map(d=>s.find(c=>c.id===d)).filter(Boolean))!=null?o:[],l=s.filter(d=>!(n!=null&&n.includes(d.id))&&!(r!=null&&r.includes(d.id)));return ct(t,[...a,...l,...u],e)},T(e.options,V,"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,V,"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,V,"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,V,"getRightHeaderGroups")),e.getFooterGroups=L(()=>[e.getHeaderGroups()],t=>[...t].reverse(),T(e.options,V,"getFooterGroups")),e.getLeftFooterGroups=L(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),T(e.options,V,"getLeftFooterGroups")),e.getCenterFooterGroups=L(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),T(e.options,V,"getCenterFooterGroups")),e.getRightFooterGroups=L(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),T(e.options,V,"getRightFooterGroups")),e.getFlatHeaders=L(()=>[e.getHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,V,"getFlatHeaders")),e.getLeftFlatHeaders=L(()=>[e.getLeftHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,V,"getLeftFlatHeaders")),e.getCenterFlatHeaders=L(()=>[e.getCenterHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,V,"getCenterFlatHeaders")),e.getRightFlatHeaders=L(()=>[e.getRightHeaderGroups()],t=>t.map(s=>s.headers).flat(),T(e.options,V,"getRightFlatHeaders")),e.getCenterLeafHeaders=L(()=>[e.getCenterFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,V,"getCenterLeafHeaders")),e.getLeftLeafHeaders=L(()=>[e.getLeftFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,V,"getLeftLeafHeaders")),e.getRightLeafHeaders=L(()=>[e.getRightFlatHeaders()],t=>t.filter(s=>{var n;return!((n=s.subHeaders)!=null&&n.length)}),T(e.options,V,"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(d=>d.getLeafHeaders()).flat()},T(e.options,V,"getLeafHeaders"))}};function ct(e,t,s,n){var r,i;let o=0;const a=function(c,h){h===void 0&&(h=1),o=Math.max(o,h),c.filter(f=>f.getIsVisible()).forEach(f=>{var g;(g=f.columns)!=null&&g.length&&a(f.columns,h+1)},0)};a(e);let u=[];const l=(c,h)=>{const f={depth:h,id:[n,`${h}`].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,h,y.id,p?.id].filter(Boolean).join("_"),isPlaceholder:C,placeholderId:C?`${g.filter(w=>w.column===y).length}`:void 0,depth:h,index:g.length});S.subHeaders.push(p),g.push(S)}f.headers.push(p),p.headerGroup=f}),u.push(f),h>0&&l(g,h-1)};l(t.map((c,h)=>An(s,c,{depth:o,index:h})),o-1),u.reverse();const d=c=>c.filter(h=>h.column.getIsVisible()).map(h=>{let f=0,g=0,p=[0];h.subHeaders&&h.subHeaders.length?(p=[],d(h.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,h.colSpan=f,h.rowSpan=g,{colSpan:f,rowSpan:g}});return d((r=(i=u[0])==null?void 0:i.headers)!=null?r:[]),u}var Na=(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 d=l.getParentRow();if(!d)break;u.push(d),l=d}return u.reverse()},getAllCells:L(()=>[e.getAllLeafColumns()],u=>u.map(l=>Aa(e,a,l,l.id)),T(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:L(()=>[a.getAllCells()],u=>u.reduce((l,d)=>(l[d.column.id]=d,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()}}},Er=(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))};Er.autoRemove=e=>ee(e);var Lr=(e,t,s)=>{var n;return!!(!((n=e.getValue(t))==null||(n=n.toString())==null)&&n.includes(s))};Lr.autoRemove=e=>ee(e);var Tr=(e,t,s)=>{var n;return((n=e.getValue(t))==null||(n=n.toString())==null?void 0:n.toLowerCase())===s?.toLowerCase()};Tr.autoRemove=e=>ee(e);var Fr=(e,t,s)=>{var n;return(n=e.getValue(t))==null?void 0:n.includes(s)};Fr.autoRemove=e=>ee(e);var Or=(e,t,s)=>!s.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});Or.autoRemove=e=>ee(e)||!(e!=null&&e.length);var Ar=(e,t,s)=>s.some(n=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)});Ar.autoRemove=e=>ee(e)||!(e!=null&&e.length);var Dr=(e,t,s)=>e.getValue(t)===s;Dr.autoRemove=e=>ee(e);var kr=(e,t,s)=>e.getValue(t)==s;kr.autoRemove=e=>ee(e);var _s=(e,t,s)=>{let[n,r]=s;const i=e.getValue(t);return i>=n&&i<=r};_s.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]};_s.autoRemove=e=>ee(e)||ee(e[0])&&ee(e[1]);var re={includesString:Er,includesStringSensitive:Lr,equalsString:Tr,arrIncludes:Fr,arrIncludesAll:Or,arrIncludesSome:Ar,equals:Dr,weakEquals:kr,inNumberRange:_s};function ee(e){return e==null||e===""}var Va={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:K("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 xt(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(d=>d.id===e.id),o=de(s,i?i.value:void 0);if(Dn(r,o,e)){var a;return(a=n?.filter(d=>d.id!==e.id))!=null?a:[]}const u={id:e.id,value:o};if(i){var l;return(l=n?.map(d=>d.id===e.id?u:d))!=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&&Dn(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 Dn(e,t,s){return(e&&e.autoRemove?e.autoRemove(t,s):!1)||typeof t>"u"||typeof t=="string"&&!t}var Ba=(e,t,s)=>s.reduce((n,r)=>{const i=r.getValue(e);return n+(typeof i=="number"?i:0)},0),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;return s.forEach(r=>{const i=r.getValue(e);i!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}),n},Ua=(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]},ja=(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},Ga=(e,t)=>{if(!t.length)return;const s=t.map(i=>i.getValue(e));if(!Fa(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},qa=(e,t)=>Array.from(new Set(t.map(s=>s.getValue(e))).values()),Wa=(e,t)=>new Set(t.map(s=>s.getValue(e))).size,Ka=(e,t)=>t.length,Gt={sum:Ba,min:za,max:Ha,extent:Ua,mean:ja,median:Ga,unique:qa,uniqueCount:Wa,count:Ka},Qa={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:K("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 Gt.sum;if(Object.prototype.toString.call(n)==="[object Date]")return Gt.extent},e.getAggregationFn=()=>{var s,n;if(!e)throw new Error;return xt(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:Gt[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 Ja(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 Ya={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:K("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=L(s=>[Qe(t,s)],s=>s.findIndex(n=>n.id===e.id),T(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=s=>{var n;return((n=Qe(t,s)[0])==null?void 0:n.id)===e.id},e.getIsLastColumn=s=>{var n;const r=Qe(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(d=>d.id===u);l>-1&&i.push(a.splice(l,1)[0])}i=[...i,...a]}return Ja(i,s,n)},T(e.options,"debugTable","_getOrderColumnsFn"))}},qt=()=>({left:[],right:[]}),Xa={getInitialState:e=>({columnPinning:qt(),...e}),getDefaultOptions:e=>({onColumnPinningChange:K("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,d;return{left:[...((l=r?.left)!=null?l:[]).filter(c=>!(n!=null&&n.includes(c))),...n],right:((d=r?.right)!=null?d:[]).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?qt():(s=(n=e.initialState)==null?void 0:n.columnPinning)!=null?s:qt())},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 Za(e){return e||(typeof document<"u"?document:null)}var dt={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},Wt=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),el={getDefaultColumnDef:()=>dt,getInitialState:e=>({columnSizing:{},columnSizingInfo:Wt(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:K("columnSizing",e),onColumnSizingInfoChange:K("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,Qe(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,Qe(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(),Kt(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=Kt(i)?Math.round(i.touches[0].clientX):i.clientX,l={},d=(m,y)=>{typeof y=="number"&&(t.setColumnSizingInfo(C=>{var S,w;const _=t.options.columnResizeDirection==="rtl"?-1:1,b=(y-((S=C?.startOffset)!=null?S:0))*_,M=Math.max(b/((w=C?.startSize)!=null?w:0),-.999999);return C.columnSizingStart.forEach(I=>{let[x,P]=I;l[x]=Math.round(Math.max(P+P*M,0)*100)/100}),{...C,deltaOffset:b,deltaPercentage:M}}),(t.options.columnResizeMode==="onChange"||m==="end")&&t.setColumnSizing(C=>({...C,...l})))},c=m=>d("move",m),h=m=>{d("end",m),t.setColumnSizingInfo(y=>({...y,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},f=Za(s),g={moveHandler:m=>c(m.clientX),upHandler:m=>{f?.removeEventListener("mousemove",g.moveHandler),f?.removeEventListener("mouseup",g.upHandler),h(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()),h((y=m.touches[0])==null?void 0:y.clientX)}},v=tl()?{passive:!1}:!1;Kt(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?Wt():(s=e.initialState.columnSizingInfo)!=null?s:Wt())},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 tl(){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 Kt(e){return e.type==="touchstart"}var sl={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:K("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 Qe(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var nl={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()}}},rl={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:K("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 xt(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)}}},il={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:K("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()}}}},us=0,cs=10,Qt=()=>({pageIndex:us,pageSize:cs}),ol={getInitialState:e=>({...e,pagination:{...Qt(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:K("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?Qt():(r=e.initialState.pagination)!=null?r:Qt())},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?us:(r=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageIndex)!=null?r:us)},e.resetPageSize=n=>{var r,i;e.setPageSize(n?cs:(r=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageSize)!=null?r:cs)},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}}},Jt=()=>({top:[],bottom:[]}),al={getInitialState:e=>({rowPinning:Jt(),...e}),getDefaultOptions:e=>({onRowPinningChange:K("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,d;if(s==="bottom"){var c,h;return{top:((c=u?.top)!=null?c:[]).filter(p=>!(a!=null&&a.has(p))),bottom:[...((h=u?.bottom)!=null?h:[]).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:((d=u?.bottom)!=null?d:[]).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?Jt():(s=(n=e.initialState)==null?void 0:n.rowPinning)!=null?s:Jt())},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"))}},ll={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:K("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=>{ds(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?Yt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=L(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,s)=>Object.keys(t).length?Yt(e,s):{rows:[],flatRows:[],rowsById:{}},T(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=L(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,s)=>Object.keys(t).length?Yt(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 ds(a,e.id,s,(o=n?.selectChildren)!=null?o:!0,t),a})},e.getIsSelected=()=>{const{rowSelection:s}=t.getState();return Ps(e,s)},e.getIsSomeSelected=()=>{const{rowSelection:s}=t.getState();return hs(e,s)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:s}=t.getState();return hs(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)}}}},ds=(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=>ds(e,a.id,s,n,r))};function Yt(e,t){const s=e.getState().rowSelection,n=[],r={},i=function(o,a){return o.map(u=>{var l;const d=Ps(u,s);if(d&&(n.push(u),r[u.id]=u),(l=u.subRows)!=null&&l.length&&(u={...u,subRows:i(u.subRows)}),d)return u}).filter(Boolean)};return{rows:i(t.rows),flatRows:n,rowsById:r}}function Ps(e,t){var s;return(s=t[e.id])!=null?s:!1}function hs(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()&&(Ps(o,t)?i=!0:r=!1),o.subRows&&o.subRows.length)){const a=hs(o,t);a==="all"?i=!0:(a==="some"&&(i=!0),r=!1)}}),r?"all":i?"some":!1}var fs=/([0-9]+)/gm,ul=(e,t,s)=>Nr(pe(e.getValue(s)).toLowerCase(),pe(t.getValue(s)).toLowerCase()),cl=(e,t,s)=>Nr(pe(e.getValue(s)),pe(t.getValue(s))),dl=(e,t,s)=>Is(pe(e.getValue(s)).toLowerCase(),pe(t.getValue(s)).toLowerCase()),hl=(e,t,s)=>Is(pe(e.getValue(s)),pe(t.getValue(s))),fl=(e,t,s)=>{const n=e.getValue(s),r=t.getValue(s);return n>r?1:n<r?-1:0},gl=(e,t,s)=>Is(e.getValue(s),t.getValue(s));function Is(e,t){return e===t?0:e>t?1:-1}function pe(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Nr(e,t){const s=e.split(fs).filter(Boolean),n=t.split(fs).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 We={alphanumeric:ul,alphanumericCaseSensitive:cl,text:dl,textCaseSensitive:hl,datetime:fl,basic:gl},pl={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:K("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 We.datetime;if(typeof i=="string"&&(n=!0,i.split(fs).length>1))return We.alphanumeric}return n?We.text:We.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 xt(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:We[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=[],d,c=i?s:r==="desc";if(o!=null&&o.length&&e.getCanMultiSort()&&n?a?d="toggle":d="add":o!=null&&o.length&&u!==o.length-1?d="replace":a?d="toggle":d="replace",d==="toggle"&&(i||r||(d="remove")),d==="add"){var h;l=[...o,{id:e.id,desc:c}],l.splice(0,l.length-((h=t.options.maxMultiSortColCount)!=null?h:Number.MAX_SAFE_INTEGER))}else d==="toggle"?l=o.map(f=>f.id===e.id?{...f,desc:c}:f):d==="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())}},ml=[ka,sl,Ya,Xa,$a,Va,nl,rl,pl,Qa,il,ol,al,ll,el];function vl(e){var t,s;const n=[...ml,...(t=e._features)!=null?t:[]];let r={_features:n};const i=r._features.reduce((c,h)=>Object.assign(c,h.getDefaultOptions==null?void 0:h.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 h;a=(h=c.getInitialState==null?void 0:c.getInitialState(a))!=null?h:a});const u=[];let l=!1;const d={_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(h=>setTimeout(()=>{throw h})))},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,h,f)=>{var g;return(g=r.options.getRowId==null?void 0:r.options.getRowId(c,h,f))!=null?g:`${f?[f.id,h].join("."):h}`},getCoreRowModel:()=>(r._getCoreRowModel||(r._getCoreRowModel=r.options.getCoreRowModel(r)),r._getCoreRowModel()),getRowModel:()=>r.getPaginationRowModel(),getRow:(c,h)=>{let f=(h?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 h;return c=(h=c)!=null?h:{},{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 h=function(f,g,p){return p===void 0&&(p=0),f.map(v=>{const m=Da(r,v,p,g),y=v;return m.columns=y.columns?h(y.columns,m,p+1):[],m})};return h(c)},T(e,"debugColumns","getAllColumns")),getAllFlatColumns:L(()=>[r.getAllColumns()],c=>c.flatMap(h=>h.getFlatColumns()),T(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:L(()=>[r.getAllFlatColumns()],c=>c.reduce((h,f)=>(h[f.id]=f,h),{}),T(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:L(()=>[r.getAllColumns(),r._getOrderColumnsFn()],(c,h)=>h(c.flatMap(f=>f.getLeafColumns())),T(e,"debugColumns","getAllLeafColumns")),getColumn:c=>r._getAllFlatColumnsById()[c]};Object.assign(r,d);for(let c=0;c<r._features.length;c++){const h=r._features[c];h==null||h.createTable==null||h.createTable(r)}return r}function Jl(){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 d=Na(e,e._getRowId(r[l],l,o),r[l],l,i,void 0,o?.id);if(s.flatRows.push(d),s.rowsById[d.id]=d,a.push(d),e.options.getSubRows){var u;d.originalSubRows=e.options.getSubRows(r[l],l),(u=d.originalSubRows)!=null&&u.length&&(d.subRows=n(d.originalSubRows,i+1,d))}}return a};return s.rows=n(t),s},T(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Yl(){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(d=>({...d}));return l.sort((d,c)=>{for(let f=0;f<i.length;f+=1){var h;const g=i[f],p=o[g.id],v=p.sortUndefined,m=(h=g?.desc)!=null?h:!1;let y=0;if(v){const C=d.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(d,c,g.id)),y!==0)return m&&(y*=-1),p.invertSorting&&(y*=-1),y}return d.index-c.index}),l.forEach(d=>{var c;r.push(d),(c=d.subRows)!=null&&c.length&&(d.subRows=a(d.subRows))}),l};return{rows:a(s.rows),flatRows:r,rowsById:s.rowsById}},T(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function Xl(e,t){return e?Sl(e)?R.createElement(e,t):e:null}function Sl(e){return yl(e)||typeof e=="function"||Cl(e)}function yl(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Cl(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function Zl(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[s]=R.useState(()=>({current:vl(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 Le(e,t,s){let n=s.initialDeps??[],r,i=!0;function o(){var a,u,l;let d;s.key&&((a=s.debug)!=null&&a.call(s))&&(d=Date.now());const c=e();if(!(c.length!==n.length||c.some((f,g)=>n[g]!==f)))return r;n=c;let h;if(s.key&&((u=s.debug)!=null&&u.call(s))&&(h=Date.now()),r=t(...c),s.key&&((l=s.debug)!=null&&l.call(s))){const f=Math.round((Date.now()-d)*100)/100,g=Math.round((Date.now()-h)*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 kn(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var Rl=(e,t)=>Math.abs(e-t)<1.01,wl=(e,t,s)=>{let n;return function(...r){e.clearTimeout(n),n=e.setTimeout(()=>t.apply(this,r),s)}},Nn=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},bl=e=>e,Ml=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},_l=(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(Nn(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(Nn(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},$n={passive:!0},Vn=typeof window>"u"?!0:"onscrollend"in window,Pl=(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?()=>{}:wl(n,()=>{t(r,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:c,isRtl:h}=e.options;r=c?s.scrollLeft*(h&&-1||1):s.scrollTop,i(),t(r,d)},a=o(!0),u=o(!1);s.addEventListener("scroll",a,$n);const l=e.options.useScrollendEvent&&Vn;return l&&s.addEventListener("scrollend",u,$n),()=>{s.removeEventListener("scroll",a),l&&s.removeEventListener("scrollend",u)}},Il=(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"]},xl=(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})},El=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:bl,rangeExtractor:Ml,onChange:()=>{},measureElement:Il,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=Le(()=>(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=Le(()=>[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=Le(()=>[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),d=new Array(o).fill(void 0);for(let c=0;c<u;c++){const h=l[c];h&&(d[h.lane]=c)}for(let c=u;c<t;c++){const h=r(c),f=this.laneAssignments.get(c);let g,p;if(f!==void 0&&this.options.lanes>1){g=f;const C=d[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(h),m=typeof v=="number"?v:this.options.estimateSize(c),y=p+m;l[c]={index:c,start:p,size:m,end:y,key:h,lane:g},d[g]=c}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Le(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,r)=>this.range=t.length>0&&s>0?Ll({measurements:t,outerSize:s,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Le(()=>{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=Le(()=>[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 kn(s[$r(0,s.length-1,n=>kn(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[d,c]=l;this._scrollToOffset(d,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{const h=()=>{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}Rl(g[0],f)||a(c)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(h):h()})},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)}},$r=(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 Ll({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=$r(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(d=>d<s+t);){const d=e[a];u[d.lane]=d.end,a++}const l=Array(n).fill(s+t);for(;o>=0&&l.some(d=>d>=s);){const d=e[o];l[d.lane]=d.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 Tl({useFlushSync:e=!0,...t}){const s=R.useReducer(()=>({}),{})[1],n={...t,onChange:(i,o)=>{var a;e&&o?(0,br.flushSync)(s):s(),(a=t.onChange)==null||a.call(t,i,o)}},[r]=R.useState(()=>new El(n));return r.setOptions(n),Bn(()=>r._didMount(),[]),Bn(()=>r._willUpdate()),r}function eu(e){return Tl({observeElementRect:_l,observeElementOffset:Pl,scrollToFn:xl,...e})}export{Dl as C,kl as S,yr as _,Yl as a,Nl as b,ql as c,ta as d,Ul as f,Rr as g,Mr as h,Jl as i,Gl as l,zl as m,Xl as n,Kl as o,Hl as p,Zl as r,Wl as s,eu as t,jl as u,Bl as v,Yn as x,Vl as y};