oneshot-gtm-server 0.2.0 → 0.3.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.
- package/dist/bin.mjs +1602 -1127
- package/dist/bin.mjs.map +1 -1
- package/dist/web/assets/{Badge-DE7L41a6.js → Badge-Bl9eBoUa.js} +2 -2
- package/dist/web/assets/{Badge-DE7L41a6.js.map → Badge-Bl9eBoUa.js.map} +1 -1
- package/dist/web/assets/Button-D1rFtlez.js +2 -0
- package/dist/web/assets/Button-D1rFtlez.js.map +1 -0
- package/dist/web/assets/{EmptyNote-DkmaZWuo.js → EmptyNote-CZaRRtmD.js} +2 -2
- package/dist/web/assets/{EmptyNote-DkmaZWuo.js.map → EmptyNote-CZaRRtmD.js.map} +1 -1
- package/dist/web/assets/{Field-B4mT8TGa.js → Field-DJ9InfU_.js} +2 -2
- package/dist/web/assets/{Field-B4mT8TGa.js.map → Field-DJ9InfU_.js.map} +1 -1
- package/dist/web/assets/{Modal-frAt7msr.js → Modal-CturxR2v.js} +2 -2
- package/dist/web/assets/{Modal-frAt7msr.js.map → Modal-CturxR2v.js.map} +1 -1
- package/dist/web/assets/{Skeleton-d2p06ghN.js → Skeleton-CHzR-B21.js} +2 -2
- package/dist/web/assets/{Skeleton-d2p06ghN.js.map → Skeleton-CHzR-B21.js.map} +1 -1
- package/dist/web/assets/cadences-D9cvMlfq.js +2 -0
- package/dist/web/assets/cadences-D9cvMlfq.js.map +1 -0
- package/dist/web/assets/chevron-down-J-vUa4uQ.js +2 -0
- package/dist/web/assets/chevron-down-J-vUa4uQ.js.map +1 -0
- package/dist/web/assets/chevron-right-DAxZefV9.js +2 -0
- package/dist/web/assets/chevron-right-DAxZefV9.js.map +1 -0
- package/dist/web/assets/inbox-Dsg3_bXr.js +2 -0
- package/dist/web/assets/{inbox-Dzd9QYT4.js.map → inbox-Dsg3_bXr.js.map} +1 -1
- package/dist/web/assets/{index-CzTgATNQ.js → index-BVno9lTD.js} +4 -4
- package/dist/web/assets/index-BVno9lTD.js.map +1 -0
- package/dist/web/assets/index-Ya_svHJk.css +2 -0
- package/dist/web/assets/loader-circle-B_w_dqVu.js +2 -0
- package/dist/web/assets/{loader-circle-BylpxA-u.js.map → loader-circle-B_w_dqVu.js.map} +1 -1
- package/dist/web/assets/{measure-S3BWSb2L.js → measure-CV7Towgf.js} +2 -2
- package/dist/web/assets/{measure-S3BWSb2L.js.map → measure-CV7Towgf.js.map} +1 -1
- package/dist/web/assets/{plays-DHIZA49D.js → plays-BSlXDDDK.js} +2 -2
- package/dist/web/assets/plays-BSlXDDDK.js.map +1 -0
- package/dist/web/assets/queue-BHKT-qjx.js +2 -0
- package/dist/web/assets/queue-BHKT-qjx.js.map +1 -0
- package/dist/web/assets/{receipts-BgXV3-De.js → receipts-opTtY1t7.js} +2 -2
- package/dist/web/assets/{receipts-BgXV3-De.js.map → receipts-opTtY1t7.js.map} +1 -1
- package/dist/web/assets/{refresh-cw-BpMRSA9y.js → refresh-cw-BO0blIzU.js} +2 -2
- package/dist/web/assets/{refresh-cw-BpMRSA9y.js.map → refresh-cw-BO0blIzU.js.map} +1 -1
- package/dist/web/assets/routes-BgDvPuJP.js +2 -0
- package/dist/web/assets/{routes-B9L9tBMF.js.map → routes-BgDvPuJP.js.map} +1 -1
- package/dist/web/assets/run._playName-CQU-5e18.js +5 -0
- package/dist/web/assets/run._playName-CQU-5e18.js.map +1 -0
- package/dist/web/assets/send-9D8YeqmY.js +2 -0
- package/dist/web/assets/send-9D8YeqmY.js.map +1 -0
- package/dist/web/assets/setup-CqCzlBdR.js +2 -0
- package/dist/web/assets/setup-CqCzlBdR.js.map +1 -0
- package/dist/web/assets/{summarizeRun-BsPt7szF.js → summarizeRun-D5Pd2arb.js} +1 -1
- package/dist/web/assets/{summarizeRun-BsPt7szF.js.map → summarizeRun-D5Pd2arb.js.map} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/Button-NJ1UVzeB.js +0 -2
- package/dist/web/assets/Button-NJ1UVzeB.js.map +0 -1
- package/dist/web/assets/cadences-CsU8vKw2.js +0 -2
- package/dist/web/assets/cadences-CsU8vKw2.js.map +0 -1
- package/dist/web/assets/chevron-right-BXb7J1cp.js +0 -2
- package/dist/web/assets/chevron-right-BXb7J1cp.js.map +0 -1
- package/dist/web/assets/inbox-Dzd9QYT4.js +0 -2
- package/dist/web/assets/index-ByTPAanr.css +0 -2
- package/dist/web/assets/index-CzTgATNQ.js.map +0 -1
- package/dist/web/assets/loader-circle-BylpxA-u.js +0 -2
- package/dist/web/assets/plays-DHIZA49D.js.map +0 -1
- package/dist/web/assets/queue-ClVxfeJ0.js +0 -2
- package/dist/web/assets/queue-ClVxfeJ0.js.map +0 -1
- package/dist/web/assets/routes-B9L9tBMF.js +0 -2
- package/dist/web/assets/run._playName-a3eeybKs.js +0 -5
- package/dist/web/assets/run._playName-a3eeybKs.js.map +0 -1
- package/dist/web/assets/setup-fs0DMLq4.js +0 -2
- package/dist/web/assets/setup-fs0DMLq4.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-
|
|
2
|
-
import{a as e,c as t,d as n,l as r,n as i,o as a,s as o,t as s,u as c}from"./Button-NJ1UVzeB.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=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(){}},u=new class extends l{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},d={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},f=new class{#e=d;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function p(e){setTimeout(e,0)}var m=typeof window>`u`||`Deno`in globalThis;function h(){}function g(e,t){return typeof e==`function`?e(t):e}function _(e){return typeof e==`number`&&e>=0&&e!==1/0}function v(e,t){return Math.max(e+(t||0)-Date.now(),0)}function y(e,t){return typeof e==`function`?e(t):e}function b(e,t){return typeof e==`function`?e(t):e}function x(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==C(o,t.options))return!1}else if(!ee(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function S(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(w(t.options.mutationKey)!==w(a))return!1}else if(!ee(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function C(e,t){return(t?.queryKeyHashFn||w)(e)}function w(e){return JSON.stringify(e,(e,t)=>re(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ee(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ee(e[n],t[n])):!1}var T=Object.prototype.hasOwnProperty;function E(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ne(e)&&ne(t);if(!r&&!(re(e)&&re(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:T.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=E(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function te(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ne(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function re(e){if(!ie(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ie(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ie(e){return Object.prototype.toString.call(e)===`[object Object]`}function ae(e){return new Promise(t=>{f.setTimeout(t,e)})}function oe(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:E(e,t)}function D(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function O(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var se=Symbol();function ce(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===se?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function le(e,t){return typeof e==`function`?e(...t):!!e}function ue(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var k=(()=>{let e=()=>m;return{isServer(){return e()},setIsServer(t){e=t}}})();function A(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var de=p;function fe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=de,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var j=fe(),pe=new class extends l{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function me(e){return Math.min(1e3*2**e,3e4)}function he(e){return(e??`online`)===`online`?pe.isOnline():!0}var ge=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function _e(e){let t=!1,n=0,r,i=A(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ge(t);p(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>u.isFocused()&&(e.networkMode===`always`||pe.isOnline())&&e.canRun(),d=()=>he(e.networkMode)&&e.canRun(),f=e=>{a()||(r?.(),i.resolve(e))},p=e=>{a()||(r?.(),i.reject(e))},m=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),h=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(a())return;let i=e.retry??(k.isServer()?0:3),o=e.retryDelay??me,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),ae(s).then(()=>l()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:d,start:()=>(d()?h():m().then(h),i)}}var ve=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),_(this.gcTime)&&(this.#e=f.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(k.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(f.clearTimeout(this.#e),this.#e=void 0)}},ye=class extends ve{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Se(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Se(this.options);e.data!==void 0&&(this.setState(xe(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=oe(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(h).catch(h):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>b(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===se||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>y(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:!v(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.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.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=ce(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=_e({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ge&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ge){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...be(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...xe(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),j.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function be(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:he(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function xe(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Se(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Ce=class extends l{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=A(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Te(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ee(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ee(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof b(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!te(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&De(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||y(this.options.staleTime,this.#t)!==y(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ke(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(h)),t}#g(){this.#b();let e=y(this.options.staleTime,this.#t);if(k.isServer()||this.#r.isStale||!_(e))return;let t=v(this.#r.dataUpdatedAt,e)+1;this.#d=f.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(k.isServer()||b(this.options.enabled,this.#t)===!1||!_(this.#p)||this.#p===0)&&(this.#f=f.setInterval(()=>{(this.options.refetchIntervalInBackground||u.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(f.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(f.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Te(e,t),o=i&&De(e,n,t,r);(a||o)&&(l={...l,...be(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=oe(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=oe(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,x=d!==void 0,S={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&x,isStale:Oe(e,t),refetch:this.refetch,promise:this.#o,isEnabled:b(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{i(this.#o=S.promise=A())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!te(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){j.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function we(e,t){return b(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&b(t.retryOnMount,e)===!1)}function Te(e,t){return we(e,t)||e.state.data!==void 0&&Ee(e,t,t.refetchOnMount)}function Ee(e,t,n){if(b(t.enabled,e)!==!1&&y(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Oe(e,t)}return!1}function De(e,t,n,r){return(e!==t||b(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Oe(e,n)}function Oe(e,t){return b(t.enabled,e)!==!1&&e.isStaleByTime(y(t.staleTime,e))}function ke(e,t){return!te(e.getCurrentResult(),t)}function Ae(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ue(e,()=>t.signal,()=>n=!0)},u=ce(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?O:D;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Me:je,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:je(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function je(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Me(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Ne=class extends ve{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Pe(),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.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=_e({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,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{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),j.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Pe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Fe=class extends l{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Ne({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ie(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ie(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ie(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Ie(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){j.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>S(t,e))}findAll(e={}){return this.getAll().filter(t=>S(e,t))}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return j.batch(()=>Promise.all(e.map(e=>e.continue().catch(h))))}};function Ie(e){return e.options.scope?.id}var Le=class extends l{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),te(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&w(t.mutationKey)!==w(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Pe();this.#t={...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){j.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Re=class extends l{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??C(r,t),a=this.get(i);return a||(a=new ye({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>x(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>x(e,t)):t}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ze=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Re,this.#t=e.mutationCache||new Fe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=pe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(y(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=g(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return j.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;j.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return j.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=j.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(h).catch(h)}invalidateQueries(e,t={}){return j.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=j.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(h)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(h)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(y(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(h).catch(h)}fetchInfiniteQuery(e){return e.behavior=Ae(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(h).catch(h)}ensureInfiniteQueryData(e){return e.behavior=Ae(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return pe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(w(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ee(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(w(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ee(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=C(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===se&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},M=n(r(),1),N=t(),Be=M.createContext(void 0),Ve=e=>{let t=M.useContext(Be);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},He=({client:e,children:t})=>(M.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,N.jsx)(Be.Provider,{value:e,children:t})),Ue=M.createContext(!1),We=()=>M.useContext(Ue);Ue.Provider;function Ge(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ke=M.createContext(Ge()),qe=()=>M.useContext(Ke),Je=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?le(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ye=e=>{M.useEffect(()=>{e.clearReset()},[e])},Xe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||le(n,[e.error,r])),Ze=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Qe=(e,t)=>e.isLoading&&e.isFetching&&!t,$e=(e,t)=>e?.suspense&&t.isPending,et=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function tt(e,t,n){let r=We(),i=qe(),a=Ve(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Ze(o),Je(o,i,s),Ye(i);let c=!a.getQueryCache().get(o.queryHash),[l]=M.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(e=>{let t=d?l.subscribe(j.batchCalls(e)):h;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),M.useEffect(()=>{l.setOptions(o)},[o,l]),$e(o,u))throw et(o,l,i);if(Xe({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!k.isServer()&&Qe(u,r)&&(c?et(o,l,i):s?.promise)?.catch(h).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function nt(e,t){return tt(e,Ce,t)}function rt(e,t){let n=Ve(t),[r]=M.useState(()=>new Le(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(j.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(h)},[r]);if(i.error&&le(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var it=M.use,at=typeof window<`u`?M.useLayoutEffect:M.useEffect;function ot(e){let t=M.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function st(e,t,n={},r={}){M.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function ct(e){let t=M.useRef(null);return M.useImperativeHandle(e,()=>t.current,[]),t}function lt(e){return e[e.length-1]}function ut(e){return typeof e==`function`}function dt(e,t){return ut(e)?e(t):e}var ft=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,mt=()=>Object.create(null),ht=(e,t)=>gt(e,t,mt);function gt(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=bt(e)&&bt(i);if(!a&&!(vt(e)&&vt(i)))return i;let o=a?e:_t(e);if(!o)return i;let s=a?i:_t(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:ft.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=gt(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function _t(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!pt.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!pt.call(e,t))return!1;r.push(t)}return r}function vt(e){if(!yt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!yt(n)||!n.hasOwnProperty(`isPrototypeOf`))}function yt(e){return Object.prototype.toString.call(e)===`[object Object]`}function bt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function xt(e,t,n){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 r=0,i=e.length;r<i;r++)if(!xt(e[r],t[r],n))return!1;return!0}if(vt(e)&&vt(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!xt(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!xt(e[o],t[o],n)))return!1;return i===a}return!1}function St(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function Ct(e){return typeof e?.message==`string`?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`):!1}function wt(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}function Tt(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function Et(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Tt(t)}var Dt=[`http:`,`https:`,`mailto:`,`tel:`];function Ot(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function kt(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=Et(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=Et(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function At(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function jt(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Mt(){throw Error(`Invariant failed`)}function Nt(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var Pt=4,Ft=5;function It(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function Lt(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=It(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function Rt(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=!!(n.options?.params?.parse&&n.options?.skipRouteOnParseError?.params);for(;s<o;){let e=Lt(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=Vt(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=Vt(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ht(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ht(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=Ht(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=Vt(n.fullPath??n.from);e.kind=Ft,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=Vt(n.fullPath??n.from);e.kind=Pt,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=n.options?.params?.parse??null,i.skipOnParamError=l,i.parsingPriority=n.options?.skipRouteOnParseError?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)Rt(e,t,r,s,i,a,o)}function zt(e,t){if(e.skipOnParamError&&!t.skipOnParamError)return-1;if(!e.skipOnParamError&&t.skipOnParamError)return 1;if(e.skipOnParamError&&t.skipOnParamError&&(e.parsingPriority||t.parsingPriority))return t.parsingPriority-e.parsingPriority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function Bt(e){if(e.pathless)for(let t of e.pathless)Bt(t);if(e.static)for(let t of e.static.values())Bt(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())Bt(t);if(e.dynamic?.length){e.dynamic.sort(zt);for(let t of e.dynamic)Bt(t)}if(e.optional?.length){e.optional.sort(zt);for(let t of e.optional)Bt(t)}if(e.wildcard?.length){e.wildcard.sort(zt);for(let t of e.wildcard)Bt(t)}}function Vt(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0}}function Ht(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0,caseSensitive:n,prefix:r,suffix:i}}function Ut(e,t){let n=Vt(`/`),r=new Uint16Array(6);for(let t of e)Rt(!1,r,t,1,n,0);Bt(n),t.masksTree=n,t.flatCache=Nt(1e3)}function Wt(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=Yt(e,t.masksTree);return t.flatCache.set(e,r),r}function Gt(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=Vt(`/`),Rt(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),Yt(r,o,n)}function Kt(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=Yt(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=Zt(a.route)),t.matchCache.set(r,a),a}function qt(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function Jt(e,t=!1,n){let r=Vt(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return Rt(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&Mt(),a[e.id]=e,s!==0&&e.path){let t=qt(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),Bt(r),{processedTree:{segmentTree:r,singleCache:Nt(1e3),matchCache:Nt(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function Yt(e,t,n=!1){let r=e.split(`/`),i=$t(e,r,t,n);if(!i)return null;let[a]=Xt(e,r,i);return{route:i.node.route,rawParams:a,parsedParams:i.parsedParams}}function Xt(e,t,n){let r=Qt(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===Pt)break;if(u.kind===Ft){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function Zt(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Qt(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function $t(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!lt(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}],c=null,l=null,u=null;for(;s.length;){let n=s.pop(),{node:i,index:d,skipped:f,depth:p,statics:m,dynamics:h,optionals:g}=n,{extract:_,rawParams:v,parsedParams:y}=n;if(i.skipOnParamError){if(!en(e,t,n))continue;v=n.rawParams,_=n.extract,y=n.parsedParams}r&&i.route&&i.kind!==Pt&&tn(l,n)&&(l=n);let b=d===o;if(b&&(i.route&&!a&&tn(u,n)&&(u=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let x=b?void 0:t[d],S;if(b&&i.index){let n={node:i.index,index:d,skipped:f,depth:p+1,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y},r=!0;if(i.index.skipOnParamError&&(en(e,t,n)||(r=!1)),r){if(m===o&&!h&&!g&&!f)return n;tn(u,n)&&(u=n)}}if(i.wildcard&&tn(c,n))for(let n of i.wildcard){let{prefix:r,suffix:i}=n;if(r&&(b||!(n.caseSensitive?x:S??=x.toLowerCase()).startsWith(r)))continue;if(i){if(b)continue;let e=t.slice(d).join(`/`).slice(-i.length);if((n.caseSensitive?e:e.toLowerCase())!==i)continue}let a={node:n,index:o,skipped:f,depth:p,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y};if(!(n.skipOnParamError&&!en(e,t,a))){c=a;break}}if(i.optional){let e=f|1<<p,t=p+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:d,skipped:e,depth:t,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?x:S??=x.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:d+1,skipped:f,depth:t,statics:m,dynamics:h,optionals:g+1,extract:_,rawParams:v,parsedParams:y})}}if(!b&&i.dynamic&&x)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?x:S??=x.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:d+1,skipped:f,depth:p+1,statics:m,dynamics:h+1,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.staticInsensitive){let e=i.staticInsensitive.get(S??=x.toLowerCase());e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.static){let e=i.static.get(x);e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(i.pathless){let e=p+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:d,skipped:f,depth:e,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}}}if(u&&c)return tn(c,u)?u:c;if(u)return u;if(c)return c;if(r&&l){let n=l.index;for(let e=0;e<l.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return l.rawParams??=Object.create(null),l.rawParams[`**`]=decodeURIComponent(r),l}return null}function en(e,t,n){try{let[r,i]=Xt(e,t,n);n.rawParams=r,n.extract=i;let a=n.node.parse(r);return n.parsedParams=Object.assign(Object.create(null),n.parsedParams,a),!0}catch{return null}}function tn(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===Pt)>(e.node.kind===Pt)||t.node.kind===Pt==(e.node.kind===Pt)&&t.depth>e.depth))):!0}function nn(e){return rn(e.filter(e=>e!==void 0).join(`/`))}function rn(e){return e.replace(/\/{2,}/g,`/`)}function an(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function on(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function sn(e){return on(an(e))}function cn(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function ln(e,t,n){return cn(e,n)===cn(t,n)}function un({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&<(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(lt(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c,l=``;for(let e=0;e<s.length;e++){e>0&&(l+=`/`);let t=s[e];if(!t)continue;c=Lt(t,0,c);let n=c[0];if(n===0){l+=t;continue}let r=c[5],i=t.substring(0,c[1]),a=t.substring(c[4],r),o=t.substring(c[2],c[3]);n===1?l+=i||a?`${i}{$${o}}${a}`:`$${o}`:n===2?l+=i||a?`${i}{$}${a}`:`$`:l+=`${i}{-$${o}}${a}`}l=rn(l);let u=l||`/`;return o&&r&&r.set(o,u),u}function dn(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function fn(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>mn(e,n)).join(`/`):mn(r,n):r}function pn({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=Lt(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=fn(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fn(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fn(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function mn(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function hn(e){return e?.isNotFound===!0}function gn(){try{return typeof window<`u`&&typeof window.sessionStorage==`object`?window.sessionStorage:void 0}catch{return}}var _n=`tsr-scroll-restoration-v1_3`;function vn(){let e=gn();if(!e)return null;let t={};try{let n=JSON.parse(e.getItem(`tsr-scroll-restoration-v1_3`)||`{}`);vt(n)&&(t=n)}catch{}return{get state(){return t},set:e=>{t=dt(e,t)||t},persist:()=>{try{e.setItem(_n,JSON.stringify(t))}catch{}}}}var yn=vn(),bn=e=>e.state.__TSR_key||e.href;function xn(e){let t=[],n;for(;n=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(n.children,e)+1})`),e=n;return`${t.reverse().join(` > `)}`.toLowerCase()}var Sn=!1,Cn=`window`,wn=`data-scroll-restoration-id`;function Tn(e,t){if(!yn)return;let n=yn;if((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isScrollRestorationSetup||!n)return;e.isScrollRestorationSetup=!0,Sn=!1;let r=e.options.getScrollRestorationKey||bn,i=new Map;window.history.scrollRestoration=`manual`;let a=t=>{if(!(Sn||!e.isScrollRestoring))if(t.target===document||t.target===window)i.set(Cn,{scrollX:window.scrollX||0,scrollY:window.scrollY||0});else{let e=t.target;i.set(e,{scrollX:e.scrollLeft||0,scrollY:e.scrollTop||0})}},o=t=>{if(!e.isScrollRestoring||!t||i.size===0||!n)return;let r=n.state[t]||={};for(let[e,t]of i){let n;if(e===Cn)n=Cn;else if(e.isConnected){let t=e.getAttribute(wn);n=t?`[${wn}="${t}"]`:xn(e)}n&&(r[n]=t)}};document.addEventListener(`scroll`,a,!0),e.subscribe(`onBeforeLoad`,e=>{o(e.fromLocation?r(e.fromLocation):void 0),i.clear()}),window.addEventListener(`pagehide`,()=>{o(r(e.stores.resolvedLocation.get()??e.stores.location.get())),n.persist()}),e.subscribe(`onRendered`,t=>{let a=r(t.toLocation),o=e.options.scrollRestorationBehavior,s=e.options.scrollToTopSelectors;if(i.clear(),!e.resetNextScroll){e.resetNextScroll=!0;return}if(!(typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))){Sn=!0;try{let t=e.isScrollRestoring?n.state[a]:void 0,r=!1;if(t)for(let e in t){let n=t[e];if(!vt(n))continue;let{scrollX:i,scrollY:a}=n;if(!(!Number.isFinite(i)||!Number.isFinite(a))){if(e===Cn)window.scrollTo({top:a,left:i,behavior:o}),r=!0;else if(e){let t;try{t=document.querySelector(e)}catch{continue}t&&(t.scrollLeft=i,t.scrollTop=a,r=!0)}}}if(!r){let t=e.history.location.hash.slice(1);if(t){let e=window.history.state?.__hashScrollIntoViewOptions??!0;if(e){let n=document.getElementById(t);n&&n.scrollIntoView(e)}}else{let e={top:0,left:0,behavior:o};if(window.scrollTo(e),s)for(let t of s){if(t===Cn)continue;let n=typeof t==`function`?t():document.querySelector(t);n&&n.scrollTo(e)}}}}finally{Sn=!1}e.isScrollRestoring&&n.set(e=>(e[a]||={},e))}})}function En(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function Dn(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function On(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Dn(r):Array.isArray(t)?t.push(Dn(r)):n[e]=[t,Dn(r)]}return n}var kn=jn(JSON.parse),An=Mn(JSON.stringify,JSON.parse);function jn(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=On(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function Mn(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=En(e,r);return t?`?${t}`:``}}var Nn=`__root__`;function Pn(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{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Fn(e){return e instanceof Response&&!!e.options}function In(e){return{input:({url:t})=>{for(let n of e)t=Rn(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=zn(e[n],t);return t}}}function Ln(e){let t=sn(e.basepath),n=`/${t}`,r=`${n}/`,i=e.caseSensitive?n:n.toLowerCase(),a=e.caseSensitive?r:r.toLowerCase();return{input:({url:t})=>{let r=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return r===i?t.pathname=`/`:r.startsWith(a)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=nn([`/`,t,e.pathname]),e)}}function Rn(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function zn(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Bn(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>Vn(o,_.get())),x=r(()=>Vn(s,v.get())),S=r(()=>Vn(c,y.get())),C=r(()=>_.get()[0]),w=r(()=>_.get().some(e=>o.get(e)?.get().status===`pending`)),ee=r(()=>({locationHref:p.get().href,resolvedLocationHref:m.get()?.href,status:l.get()})),T=r(()=>({status:l.get(),loadedAt:u.get(),isLoading:d.get(),isTransitioning:f.get(),matches:b.get(),location:p.get(),resolvedLocation:m.get(),statusCode:h.get(),redirect:g.get()})),E=Nt(64);function te(e){let t=E.get(e);return t||(t=r(()=>{let t=_.get();for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.get()}}),E.set(e,t)),t}let ne={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingIds:v,cachedIds:y,matches:b,pendingMatches:x,cachedMatches:S,firstId:C,hasPending:w,matchRouteDeps:ee,matchStores:o,pendingMatchStores:s,cachedMatchStores:c,__store:T,getRouteMatchStore:te,setMatches:re,setPending:ie,setCached:ae};re(e.matches),a?.(ne);function re(e){Hn(e,o,_,n,i)}function ie(e){Hn(e,s,v,n,i)}function ae(e){Hn(e,c,y,n,i)}return ne}function Vn(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.get())}return n}function Hn(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.get()!==n&&e.set(n)}jt(n.get(),a)||n.set(a)})}var Un=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},Wn=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),Gn=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),Kn=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},qn=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},Jn=(e,t,n)=>{if(!(!Fn(n)&&!hn(n)))throw Fn(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:Fn(n)?`redirected`:hn(n)?`notFound`:r.status===`pending`?`success`:r.status,context:Kn(e,t.index),isFetching:!1,error:n})),hn(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),Fn(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},Yn=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},Xn=(e,t,n)=>{let r=Kn(e,n);e.updateMatch(t,e=>({...e,context:r}))},Zn=(e,t,n,r)=>{let{id:i,routeId:a}=e.matches[t],o=e.router.looseRoutesById[a];if(n instanceof Promise)throw n;n.routerCode=r,e.firstBadMatchIndex??=t,Jn(e,e.router.getMatch(i),n);try{o.options.onError?.(n)}catch(t){n=t,Jn(e,e.router.getMatch(i),n)}e.updateMatch(i,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!Fn(n)&&!hn(n)&&(e.serialError??=n)},Qn=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!Gn(e,t)&&(n.options.loader||n.options.beforeLoad||lr(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{Un(e)},i);r._nonReactive.pendingTimeout=t}},$n=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Qn(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Jn(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},er=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=St(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&Zn(e,n,o,`PARSE_PARAMS`),s&&Zn(e,n,s,`VALIDATE_SEARCH`),Qn(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=St();let f={...Kn(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=Gn(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(Fn(r)||hn(r))&&(u(),Zn(e,n,r,`BEFORE_LOAD`)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),wt(y))return u(),y.catch(t=>{Zn(e,n,t,`BEFORE_LOAD`)}).then(v)}catch(t){u(),Zn(e,n,t,`BEFORE_LOAD`)}v(y)},tr=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>er(e,n,t,i),s=()=>{if(Yn(e,n))return;let t=$n(e,n,i);return wt(t)?t.then(o):o()};return a()},nr=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},rr=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=Kn(e,r),d=Gn(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},ir=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{cr(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(rr(e,t,n,r,i)),l=!!s&&wt(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;Jn(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:Kn(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:Kn(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,hn(t)&&await i.options.notFoundComponent?.preload?.(),Jn(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,Jn(e,e.router.getMatch(n),t)}!Fn(o)&&!hn(o)&&await cr(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:Kn(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),Jn(e,r,t)}},ar=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(rr(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await ir(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){Fn(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await ir(e,t,i,n,d):Xn(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(Yn(e,i)){if(!e.router.getMatch(i))return e.matches[n];Xn(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.get()[n],s=(o&&e.router.stores.matchStores.get(o)||null)?.routeId===a?o:e.router.stores.matches.get().find(e=>e.routeId===a)?.id,l=Gn(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&Jn(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.matchStores.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=St(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function or(e){let t=e,n=[];Wn(t.router)&&Un(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=tr(t,e);wt(n)&&await n}catch(e){if(Fn(e))throw e;if(hn(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?qn(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(ar(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(Fn(e))throw e;hn(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=qn(t,l);e===void 0&&Mt();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await cr(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await cr(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=nr(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=Un(t);if(wt(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function sr(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function cr(e,t=ur){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===ur?(()=>{if(e._componentsPromise===void 0){let t=sr(e,ur);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():sr(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function lr(e){for(let t of ur)if(e.options[t]?.preload)return!0;return!1}var ur=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`],dr=`__TSR_index`,fr=`popstate`,pr=`beforeunload`;function mr(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=vr(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[dr];i=hr(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[dr];i=hr(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[dr]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function hr(e,t){t||={};let n=yr();return{...t,key:n,__TSR_key:n,[dr]:e}}function gr(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>vr(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=yr();t.history.replaceState({[dr]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=vr(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[dr]-l.state[dr],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=mr({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(pr,S,{capture:!0}),t.removeEventListener(fr,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(pr,S,{capture:!0}),t.addEventListener(fr,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function _r(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function vr(e,t){let n=_r(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=yr();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[dr]:0,key:a,__TSR_key:a}}}function yr(){return(Math.random()+1).toString(36).substring(7)}function br(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var xr=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=dn(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=gr()),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 e;this.resolvePathCache=Nt(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Bn(wr(this.latestLocation),e),Tn(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=sn(o);t&&t!==`/`&&e.push(Ln({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:In(e),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=()=>{let e=Jt(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&Ut(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:kt(e).path,external:!1,searchStr:o,search:ht(t?.search,i),hash:kt(r.slice(1)).path,state:gt(t?.state,a)}}let o=new URL(i,this.origin),s=Rn(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:kt(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:ht(t?.search,c),hash:kt(s.hash.slice(1)).path,state:gt(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>un({base:e,to:rn(t),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>Er({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.get().forEach(e=>{if(this.stores.pendingMatchStores.has(e))return;let t=this.stores.matchStores.get(e)?.get();t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=this.resolvePathWithBase(i,`.`),o=r.search,s=Object.assign(Object.create(null),r.params),c=t.to?this.resolvePathWithBase(a,`${t.to}`):this.resolvePathWithBase(a,`.`),l=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,dt(t.params,s)),u=this.getMatchedRoutes(c),d=u.matchedRoutes;if((!u.foundRoute||u.foundRoute.path!==`/`&&u.routeParams[`**`])&&this.options.notFoundRoute&&(d=[...d,this.options.notFoundRoute]),Object.keys(l).length>0)for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(l,t(l))}catch{}}let f=e.leaveParams?c:kt(pn({path:c,params:l,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,p=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,Tr(t.options.validateSearch,{...e,...p}))}catch{}}),p=e}p=Dr({search:p,dest:t,destRoutes:d,_includeValidateSearch:e._includeValidateSearch}),p=ht(o,p);let m=this.options.stringifySearch(p),h=t.hash===!0?n.hash:t.hash?dt(t.hash,n.hash):void 0,g=h?`#${h}`:``,_=t.state===!0?n.state:t.state?dt(t.state,n.state):{};_=gt(n.state,_);let v=`${f}${m}${g}`,y,b,x=!1;if(this.rewrite){let e=new URL(v,this.origin),t=zn(this.rewrite,e);y=e.href.replace(e.origin,``),t.origin===this.origin?b=t.pathname+t.search+t.hash:(b=t.href,x=!0)}else y=At(v),b=y;return{publicHref:b,href:y,pathname:f,search:p,searchStr:m,state:_,hash:h??``,external:x,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=Wt(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,dt(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=xt(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},i=on(this.latestLocation.href)===on(n.href),a=this.commitLocationPromise;if(this.commitLocationPromise=St(()=>{a?.resolve(),a=void 0}),i&&r())this.load();else{let{maskedLocation:r,hashScrollIntoView:i,...a}=n;r&&(a={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...a,search:a.searchStr,state:{...a.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(a.unmaskOnReload??this.options.unmaskOnReload??!1)&&(a.state.__tempKey=this.tempLocationKey)),a.state.__hashScrollIntoViewOptions=i??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,this.history[n.replace?`replace`:`push`](a.publicHref,a.state,{ignoreBlocker:t})}return this.resetNextScroll=n.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=vr(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=Rn(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(Ot(t,this.protocolAllowlist))return Promise.resolve();if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return i.replace?window.location.replace(t):window.location.href=t,Promise.resolve()}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatches.get().filter(t=>!e.some(e=>e.id===t.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(e),this.stores.setCached(t)})},this.load=async e=>{let t,n,r,i=this.stores.resolvedLocation.get()??this.stores.location.get();for(r=new Promise(a=>{this.startTransition(async()=>{try{this.beforeLoad();let t=this.latestLocation,n=br(t,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:`onBeforeNavigate`,...n}),this.emit({type:`onBeforeLoad`,...n}),await or({router:this,sync:e?.sync,forceStaleReload:i.href===t.href,matches:this.stores.pendingMatches.get(),location:t,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatches.get(),a=i.length,o=this.stores.matches.get();e=a?o.filter(e=>!this.stores.pendingMatchStores.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStores.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.matchStores.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),a&&(this.stores.setMatches(i),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){Fn(e)?(t=e,this.navigate({...t.options,replace:!0,ignoreBlocker:!0})):hn(e)&&(n=e);let r=t?t.status:n?404:this.stores.matches.get().some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.set(r),this.stores.redirect.set(t)})}this.latestLoadPromise===r&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),a()})}),this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise;let a;this.hasNotFoundMatch()?a=404:this.stores.matches.get().some(e=>e.status===`error`)&&(a=500),a!==void 0&&this.stores.statusCode.set(a)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(br(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStores.get(e);if(n){n.set(t);return}let r=this.stores.matchStores.get(e);if(r){r.set(t);return}let i=this.stores.cachedMatchStores.get(e);if(i){let n=t(i.get());n.status===`redirected`?this.stores.cachedMatchStores.delete(e)&&this.stores.cachedIds.set(t=>t.filter(t=>t!==e)):i.set(n)}})},this.getMatch=e=>this.stores.cachedMatchStores.get(e)?.get()??this.stores.pendingMatchStores.get(e)?.get()??this.stores.matchStores.get(e)?.get(),this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(t)),this.stores.setCached(this.stores.cachedMatches.get().map(t)),this.stores.setPending(this.stores.pendingMatches.get().map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&Ot(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCached([]):this.stores.setCached(this.stores.cachedMatches.get().filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`?!0:e-t.updatedAt>=r}})},this.loadRouteChunk=cr,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),i=new Set([...r,...this.stores.cachedIds.get()]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatches.get();this.stores.setCached([...e,...a])}try{return n=await or({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(Fn(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});hn(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.get()!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.get():t.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=Gt(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!xt(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?xt(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(e=>e.status===`notFound`||e.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??An,parseSearch:e.parseSearch??kn,protocolAllowlist:e.protocolAllowlist??Dt}),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:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}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){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i,parsedParams:a}=n,{matchedRoutes:o}=n,s=!1;(r?r.path!==`/`&&i[`**`]:on(e.pathname))&&(this.options.notFoundRoute?o=[...o,this.options.notFoundRoute]:s=!0);let c=s?kr(this.options.notFoundMode,o):void 0,l=Array(o.length),u=new Map;for(let e of this.stores.matchStores.values())e.routeId&&u.set(e.routeId,e.get());for(let n=0;n<o.length;n++){let r=o[n],s=l[n-1],d,f,p;{let n=s?.search??e.search,i=s?._strictSearch??void 0;try{let e=Tr(r.options.validateSearch,{...n})??void 0;d={...n,...e},f={...i,...e},p=void 0}catch(e){let r=e;if(e instanceof Sr||(r=new Sr(e.message,{cause:e})),t?.throwOnError)throw r;d=n,f={},p=r}}let m=r.options.loaderDeps?.({search:d})??``,h=m?JSON.stringify(m):``,{interpolatedPath:g,usedParams:_}=pn({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),v=r.id+g+h,y=this.getMatch(v),b=u.get(r.id),x=y?._strictParams??_,S;if(!y)try{Ar(r,_,a,x)}catch(e){if(S=hn(e)||Fn(e)?e:new Cr(e.message,{cause:e}),t?.throwOnError)throw S}Object.assign(i,x);let C=b?`stay`:`enter`,w;if(y)w={...y,cause:C,params:b?.params??i,_strictParams:x,search:ht(b?b.search:y.search,d),_strictSearch:f};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||lr(r)?`pending`:`success`;w={id:v,ssr:r.options.ssr,index:n,routeId:r.id,params:b?.params??i,_strictParams:x,pathname:g,updatedAt:Date.now(),search:b?ht(b.search,d):d,_strictSearch:f,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:S,__routeContext:void 0,_nonReactive:{loadPromise:St()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:C,loaderDeps:b?gt(b.loaderDeps,m):m,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(w.globalNotFound=c===r.id),w.searchError=p;let ee=this.getParentContext(s);w.context={...ee,...w.__routeContext,...w.__beforeLoadContext},l[n]=w}for(let t=0;t<l.length;t++){let n=l[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=u.get(n.routeId);if(n.params=o?ht(o.params,i):i,!a){let i=l[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:l,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return l}matchRoutesLightweight(e){let{matchedRoutes:t,routeParams:n,parsedParams:r}=this.getMatchedRoutes(e.pathname),i=lt(t),a={...e.search};for(let e of t)try{Object.assign(a,Tr(e.options.validateSearch,a))}catch{}let o=lt(this.stores.matchesId.get()),s=o&&this.stores.matchStores.get(o)?.get(),c=s&&s.routeId===i.id&&s.pathname===e.pathname,l;if(c)l=s.params;else{let e=Object.assign(Object.create(null),n);for(let i of t)try{Ar(i,n,r??{},e)}catch{}l=e}return{matchedRoutes:t,fullPath:i.fullPath,search:a,params:l}}},Sr=class extends Error{},Cr=class extends Error{};function wr(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function Tr(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new Sr(`Async validation not supported`);if(n.issues)throw new Sr(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Er({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=on(e),a,o,s=Kt(i,n,!0);return s&&(a=s.route,Object.assign(r,s.rawParams),o=Object.assign(Object.create(null),s.parsedParams)),{matchedRoutes:s?.branch||[t.__root__],routeParams:r,foundRoute:a,parsedParams:o}}function Dr({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return Or(n)(e,t,r??!1)}function Or(e){let t={dest:null,_includeValidateSearch:!1,middlewares:[]};for(let n of e)`search`in n.options?n.options.search?.middlewares&&t.middlewares.push(...n.options.search.middlewares):(n.options.preSearchFilters||n.options.postSearchFilters)&&t.middlewares.push(({search:e,next:t})=>{let r=e;`preSearchFilters`in n.options&&n.options.preSearchFilters&&(r=n.options.preSearchFilters.reduce((e,t)=>t(e),e));let i=t(r);return`postSearchFilters`in n.options&&n.options.postSearchFilters?n.options.postSearchFilters.reduce((e,t)=>t(e),i):i}),n.options.validateSearch&&t.middlewares.push(({search:e,next:r})=>{let i=r(e);if(!t._includeValidateSearch)return i;try{return{...i,...Tr(n.options.validateSearch,i)??void 0}}catch{return i}});t.middlewares.push(({search:e})=>{let n=t.dest;return n.search?n.search===!0?e:dt(n.search,e):{}});let n=(e,t,r)=>{if(e>=r.length)return t;let i=r[e];return i({search:t,next:t=>n(e+1,t,r)})};return function(e,r,i){return t.dest=r,t._includeValidateSearch=i,n(0,e,t.middlewares)}}function kr(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return Nn}function Ar(e,t,n,r){let i=e.options.params?.parse??e.options.parseParams;if(i)if(e.options.skipRouteOnParseError)for(let e in t)e in n&&(r[e]=n[e]);else{let e=i(r);Object.assign(r,e)}}var jr=`Error preloading route! ☝️`,Mr=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=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=Nn:this.parentRoute||Mt();let r=n?Nn:t?.path;r&&r!==`/`&&(r=an(r));let i=t?.id||r,a=n?Nn:nn([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=nn([`/`,a]));let o=a===`__root__`?`/`:nn([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=on(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>Pn({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},Nr=class extends Mr{constructor(e){super(e)}};function Pr(e){if(typeof document<`u`&&document.querySelector){let t=e.stores.location.get(),n=t.state.__hashScrollIntoViewOptions??!0;if(n&&t.hash!==``){let e=document.getElementById(t.hash);e&&e.scrollIntoView(n)}}}function Fr(e){let t=e.errorComponent??Lr;return(0,N.jsx)(Ir,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?M.createElement(t,{error:n,reset:r}):e.children})}var Ir=class extends M.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}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 Lr({error:e}){let[t,n]=M.useState(!1);return(0,N.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,N.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,N.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,N.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,N.jsx)(`div`,{children:(0,N.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,N.jsx)(`code`,{children:e.message}):null})}):null]})}function Rr({children:e,fallback:t=null}){return zr()?(0,N.jsx)(M.Fragment,{children:e}):(0,N.jsx)(M.Fragment,{children:t})}function zr(){return M.useSyncExternalStore(Br,()=>!0,()=>!1)}function Br(){return()=>{}}var Vr=M.createContext(null);function Hr(e){return M.useContext(Vr)}var Ur=M.createContext(void 0),Wr=M.createContext(void 0),P=(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))(P||{});function Gr({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Kr(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var qr=[],Jr=0,{link:Yr,unlink:Xr,propagate:Zr,checkDirty:Qr,shallowPropagate:$r}=Gr({update(e){return e._update()},notify(e){qr[ti++]=e,e.flags&=~P.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=P.Mutable|P.Dirty,ai(e))}}),ei=0,ti=0,ni,ri=0;function ii(e){try{++ri,e()}finally{--ri||oi()}}function ai(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Xr(n,e)}function oi(){if(!(ri>0)){for(;ei<ti;){let e=qr[ei];qr[ei++]=void 0,e.notify()}ei=0,ti=0}}function si(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?P.None:P.Mutable,get(){return ni!==void 0&&Yr(i,ni,Jr),i._snapshot},subscribe(e){let t=Kr(e),n={current:!1},r=ci(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=ni,o=t?.compare??Object.is;if(n)ni=i,++Jr,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=P.Mutable|P.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{ni=a,n&&(i.flags&=~P.RecursedCheck),ai(i)}}};return n?(i.flags=P.Mutable|P.Dirty,i.get=function(){let e=i.flags;if(e&P.Dirty||e&P.Pending&&Qr(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&$r(e)}}else e&P.Pending&&(i.flags=e&~P.Pending);return ni!==void 0&&Yr(i,ni,Jr),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Zr(e),$r(e),oi())}},i}function ci(e){let t=()=>{let t=ni;ni=n,++Jr,n.depsTail=void 0,n.flags=P.Watching|P.RecursedCheck;try{return e()}finally{ni=t,n.flags&=~P.RecursedCheck,ai(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:P.Watching|P.RecursedCheck,notify(){let e=this.flags;e&P.Dirty||e&P.Pending&&Qr(this.deps,this)?t():this.flags=P.Watching},stop(){this.flags=P.None,this.depsTail=void 0,ai(this)}};return t(),n}var li=c((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),ui=c(((e,t)=>{t.exports=li()})),di=c((e=>{var t=r(),n=ui();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),fi=c(((e,t)=>{t.exports=di()}))();function pi(e,t){return e===t}function mi(e,t,n=pi){let r=(0,M.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,M.useCallback)(()=>e?.get(),[e]);return(0,fi.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var hi={get:()=>void 0,subscribe:()=>({unsubscribe:()=>{}})};function gi(e){let t=Hr(),n=M.useContext(e.from?Wr:Ur),r=e.from??n,i=r?e.from?t.stores.getRouteMatchStore(r):t.stores.matchStores.get(r):void 0,a=M.useRef(void 0);return mi(i??hi,n=>{if((e.shouldThrow??!0)&&!n&&Mt(),n===void 0)return;let r=e.select?e.select(n):n;if(e.structuralSharing??t.options.defaultStructuralSharing){let e=gt(a.current,r);return a.current=e,e}return r})}function _i(e){return gi({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function vi(e){let{select:t,...n}=e;return gi({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function yi(e){return gi({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function bi(e){return gi({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function xi(e){let t=Hr();return M.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Si(e){return gi({...e,select:t=>e.select?e.select(t.context):t.context})}var Ci=c((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.5`})),wi=c(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ci()})),Ti=n(wi(),1);function Ei(e,t){let n=Hr(),r=ct(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:ee,onTouchStart:T,ignoreBlocker:E,params:te,search:ne,hash:re,state:ie,mask:ae,reloadDocument:oe,unsafeRelative:D,from:O,_fromLocation:se,...ce}=e,le=zr(),ue=M.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),k=mi(n.stores.location,e=>e,(e,t)=>e.href===t.href),A=M.useMemo(()=>{let e={_fromLocation:k,...ue};return n.buildLocation(e)},[n,k,ue]),de=A.maskedLocation?A.maskedLocation.publicHref:A.publicHref,fe=A.maskedLocation?A.maskedLocation.external:A.external,j=M.useMemo(()=>Fi(de,fe,n.history,v),[v,fe,de,n.history]),pe=M.useMemo(()=>{if(j?.external)return Ot(j.href,n.protocolAllowlist)?void 0:j.href;if(!Ii(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),Ot(s,n.protocolAllowlist)?void 0:s}catch{}},[s,j,n.protocolAllowlist]),me=M.useMemo(()=>{if(pe)return!1;if(o?.exact){if(!ln(k.pathname,A.pathname,n.basepath))return!1}else{let e=cn(k.pathname,n.basepath),t=cn(A.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!xt(k.search,A.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:o?.includeHash?le&&k.hash===A.hash:!0},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,k,pe,le,A.hash,A.pathname,A.search,n.basepath]),he=me?dt(i,{})??Oi:Di,ge=me?Di:dt(a,{})??Di,_e=[b,he.className,ge.className].filter(Boolean).join(` `),ve=(y||he.style||ge.style)&&{...y,...he.style,...ge.style},[ye,be]=M.useState(!1),xe=M.useRef(!1),Se=e.reloadDocument||pe?!1:c??n.options.defaultPreload,Ce=l??n.options.defaultPreloadDelay??0,we=M.useCallback(()=>{n.preloadRoute({...ue,_builtLocation:A}).catch(e=>{console.warn(e),console.warn(jr)})},[n,ue,A]);st(r,M.useCallback(e=>{e?.isIntersecting&&we()},[we]),Ni,{disabled:!!v||Se!==`viewport`}),M.useEffect(()=>{xe.current||!v&&Se===`render`&&(we(),xe.current=!0)},[v,we,Se]);let Te=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;if(!v&&!I(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Ti.flushSync)(()=>{be(!0)});let t=n.subscribe(`onResolved`,()=>{t(),be(!1)});n.navigate({...ue,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:E})}};if(pe)return{...ce,ref:r,href:pe,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...ee&&{onMouseLeave:ee},...T&&{onTouchStart:T}};let Ee=e=>{if(v||Se!==`intent`)return;if(!Ce){we();return}let t=e.currentTarget;if(Mi.has(t))return;let n=setTimeout(()=>{Mi.delete(t),we()},Ce);Mi.set(t,n)},De=e=>{v||Se!==`intent`||we()},Oe=e=>{if(v||!Se||!Ce)return;let t=e.currentTarget,n=Mi.get(t);n&&(clearTimeout(n),Mi.delete(t))};return{...ce,...he,...ge,href:j?.href,ref:r,onClick:Pi([x,Te]),onBlur:Pi([S,Oe]),onFocus:Pi([C,Ee]),onMouseEnter:Pi([w,Ee]),onMouseLeave:Pi([ee,Oe]),onTouchStart:Pi([T,De]),disabled:!!v,target:_,...ve&&{style:ve},..._e&&{className:_e},...v&&ki,...me&&Ai,...le&&ye&&ji}}var Di={},Oi={className:`active`},ki={role:`link`,"aria-disabled":!0},Ai={"data-status":`active`,"aria-current":`page`},ji={"data-transitioning":`transitioning`},Mi=new WeakMap,Ni={rootMargin:`100px`},Pi=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function Fi(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function Ii(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var F=M.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=Ei(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return M.createElement(`a`,t,o)}return M.createElement(n,a,o)});function I(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var Li=class extends Mr{constructor(e){super(e),this.useMatch=e=>gi({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Si({...e,from:this.id}),this.useSearch=e=>bi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>yi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>vi({...e,from:this.id}),this.useLoaderData=e=>_i({...e,from:this.id}),this.useNavigate=()=>xi({from:this.fullPath}),this.Link=M.forwardRef((e,t)=>(0,N.jsx)(F,{ref:t,from:this.fullPath,...e}))}};function Ri(e){return new Li(e)}function zi(){return e=>Vi(e)}var Bi=class extends Nr{constructor(e){super(e),this.useMatch=e=>gi({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Si({...e,from:this.id}),this.useSearch=e=>bi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>yi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>vi({...e,from:this.id}),this.useLoaderData=e=>_i({...e,from:this.id}),this.useNavigate=()=>xi({from:this.fullPath}),this.Link=M.forwardRef((e,t)=>(0,N.jsx)(F,{ref:t,from:this.fullPath,...e}))}};function Vi(e){return new Bi(e)}function Hi(e){return new Ui(e,{silent:!0}).createRoute}var Ui=class{constructor(e,t){this.path=e,this.createRoute=e=>{let t=Ri(e);return t.isRoot=!1,t},this.silent=t?.silent}};function Wi(e,t){let n,r,i,a,o=()=>(n||=e().then(e=>{n=void 0,r=e[t??`default`]}).catch(e=>{if(i=e,Ct(i)&&i instanceof Error&&typeof window<`u`&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${i.message}`;sessionStorage.getItem(e)||(sessionStorage.setItem(e,`1`),a=!0)}}),n),s=function(e){if(a)throw window.location.reload(),new Promise(()=>{});if(i)throw i;if(!r)if(it)it(o());else throw o();return M.createElement(r,e)};return s.preload=o,s}function Gi(e){let t=Hr(),n=`not-found-${mi(t.stores.location,e=>e.pathname)}-${mi(t.stores.status,e=>e)}`;return(0,N.jsx)(Fr,{getResetKey:()=>n,onCatch:(t,n)=>{if(hn(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(hn(t))return e.fallback?.(t);throw t},children:e.children})}function Ki(){return(0,N.jsx)(`p`,{children:`Not Found`})}function qi(e){return(0,N.jsx)(N.Fragment,{children:e.children})}function Ji(e,t,n){return t.options.notFoundComponent?(0,N.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,N.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,N.jsx)(Ki,{})}var Yi=M.memo(function({matchId:e}){let t=Hr(),n=t.stores.matchStores.get(e);n||Mt();let r=mi(t.stores.loadedAt,e=>e),i=mi(n,e=>e);return(0,N.jsx)(Xi,{router:t,matchId:e,resetKey:r,matchState:M.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function Xi({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,N.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?M.Suspense:qi,f=s?Fr:qi,p=l?Gi:qi;return(0,N.jsxs)(i.isRoot?i.options.shellComponent??qi:qi,{children:[(0,N.jsx)(Ur.Provider,{value:t,children:(0,N.jsx)(d,{fallback:o,children:(0,N.jsx)(f,{getResetKey:()=>n,errorComponent:s||Lr,onCatch:(e,t)=>{if(hn(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,N.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return M.createElement(l,e)},children:u||r._displayPending?(0,N.jsx)(Rr,{fallback:o,children:(0,N.jsx)(Qi,{matchId:t})}):(0,N.jsx)(Qi,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Zi,{resetKey:n}),(e.options.scrollRestoration,null)]}):null]})}function Zi({resetKey:e}){let t=Hr(),n=M.useRef(void 0);return at(()=>{let e=t.latestLocation.href;(n.current===void 0||n.current!==e)&&(t.emit({type:`onRendered`,...br(t.stores.location.get(),t.stores.resolvedLocation.get())}),n.current=e)},[t.latestLocation.state.__TSR_key,e,t]),null}var Qi=M.memo(function({matchId:e}){let t=Hr(),n=(e,n)=>t.getMatch(e.id)?._nonReactive[n]??e._nonReactive[n],r=t.stores.matchStores.get(e);r||Mt();let i=mi(r,e=>e),a=i.routeId,o=t.routesById[a],s=M.useMemo(()=>{let e=(t.routesById[a].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:a,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return e?JSON.stringify(e):void 0},[a,i.loaderDeps,i._strictParams,i._strictSearch,t.options.defaultRemountDeps,t.routesById]),c=M.useMemo(()=>{let e=o.options.component??t.options.defaultComponent;return e?(0,N.jsx)(e,{},s):(0,N.jsx)($i,{})},[s,o.options.component,t.options.defaultComponent]);if(i._displayPending)throw n(i,`displayPendingPromise`);if(i._forcePending)throw n(i,`minPendingPromise`);if(i.status===`pending`){let e=o.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(i.id);if(n&&!n._nonReactive.minPendingPromise){let t=St();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw n(i,`loadPromise`)}if(i.status===`notFound`)return hn(i.error)||Mt(),Ji(t,o,i.error);if(i.status===`redirected`)throw Fn(i.error)||Mt(),n(i,`loadPromise`);if(i.status===`error`)throw i.error;return c}),$i=M.memo(function(){let e=Hr(),t=M.useContext(Ur),n,r=!1,i;{let a=t?e.stores.matchStores.get(t):void 0;[n,r]=mi(a,e=>[e?.routeId,e?.globalNotFound??!1]),i=mi(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,N.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||Mt(),Ji(e,a,void 0);if(!i)return null;let s=(0,N.jsx)(Yi,{matchId:i});return n===`__root__`?(0,N.jsx)(M.Suspense,{fallback:o,children:s}):s});function ea(){let e=Hr(),t=M.useRef({router:e,mounted:!1}),[n,r]=M.useState(!1),i=mi(e.stores.isLoading,e=>e),a=mi(e.stores.hasPending,e=>e),o=ot(i),s=i||n||a,c=ot(s),l=i||a,u=ot(l);return e.startTransition=e=>{r(!0),M.startTransition(()=>{e(),r(!1)})},M.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return on(e.latestLocation.publicHref)!==on(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),at(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),at(()=>{o&&!i&&e.emit({type:`onLoad`,...br(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,i]),at(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...br(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,u,e]),at(()=>{if(c&&!s){let t=br(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:`onResolved`,...t}),ii(()=>{e.stores.status.set(`idle`),e.stores.resolvedLocation.set(e.stores.location.get())}),t.hrefChanged&&Pr(e)}},[s,c,e]),null}function ta(){let e=Hr(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,N.jsx)(t,{}):null,r=(0,N.jsxs)(typeof document<`u`&&e.ssr?qi:M.Suspense,{fallback:n,children:[(0,N.jsx)(ea,{}),(0,N.jsx)(na,{})]});return e.options.InnerWrap?(0,N.jsx)(e.options.InnerWrap,{children:r}):r}function na(){let e=Hr(),t=mi(e.stores.firstId,e=>e),n=mi(e.stores.loadedAt,e=>e),r=t?(0,N.jsx)(Yi,{matchId:t}):null;return(0,N.jsx)(Ur.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,N.jsx)(Fr,{getResetKey:()=>n,errorComponent:Lr,onCatch:void 0,children:r})})}var ra=e=>({createMutableStore:si,createReadonlyStore:si,batch:ii}),ia=e=>new aa(e),aa=class extends xr{constructor(e){super(e,ra)}};function oa({router:e,children:t,...n}){Object.keys(n).length>0&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,N.jsx)(Vr.Provider,{value:e,children:t});return e.options.Wrap?(0,N.jsx)(e.options.Wrap,{children:r}):r}function sa({router:e,...t}){return(0,N.jsx)(oa,{router:e,...t,children:(0,N.jsx)(ta,{})})}var ca=c((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,te());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}var S=!1,C=-1,w=5,ee=-1;function T(){return g?!0:!(e.unstable_now()-ee<w)}function E(){if(g=!1,S){var t=e.unstable_now();ee=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&T());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(E)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=E,te=function(){re.postMessage(null)}}else te=function(){_(E,0)};function ie(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),la=c(((e,t)=>{t.exports=ca()})),ua=c((e=>{var t=la(),n=r(),i=wi();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,D=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function k(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function A(e,t){le++,ce[le]=e.current,e.current=t}var de=ue(null),fe=ue(null),j=ue(null),pe=ue(null);function me(e,t){switch(A(j,t),A(fe,e),A(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ud(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ud(t),e=Wd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}k(de),A(de,e)}function he(){k(de),k(fe),k(j)}function ge(e){e.memoizedState!==null&&A(pe,e);var t=de.current,n=Wd(t,e.type);t!==n&&(A(fe,e),A(de,n))}function _e(e){fe.current===e&&(k(de),k(fe)),pe.current===e&&(k(pe),$f._currentValue=se)}var ve,ye;function be(e){if(ve===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ve=t&&t[1]||``,ye=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-CqCzlBdR.js","assets/Button-D1rFtlez.js","assets/Badge-Bl9eBoUa.js","assets/Field-DJ9InfU_.js","assets/receipts-opTtY1t7.js","assets/EmptyNote-CZaRRtmD.js","assets/Modal-CturxR2v.js","assets/Skeleton-CHzR-B21.js","assets/queue-BHKT-qjx.js","assets/summarizeRun-D5Pd2arb.js","assets/chevron-down-J-vUa4uQ.js","assets/chevron-right-DAxZefV9.js","assets/loader-circle-B_w_dqVu.js","assets/send-9D8YeqmY.js","assets/plays-BSlXDDDK.js","assets/measure-CV7Towgf.js","assets/inbox-Dsg3_bXr.js","assets/refresh-cw-BO0blIzU.js","assets/cadences-D9cvMlfq.js","assets/routes-BgDvPuJP.js","assets/run._playName-CQU-5e18.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,c as t,d as n,l as r,n as i,o as a,s as o,t as s,u as c}from"./Button-D1rFtlez.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=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(){}},u=new class extends l{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},d={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},f=new class{#e=d;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function p(e){setTimeout(e,0)}var m=typeof window>`u`||`Deno`in globalThis;function h(){}function g(e,t){return typeof e==`function`?e(t):e}function _(e){return typeof e==`number`&&e>=0&&e!==1/0}function v(e,t){return Math.max(e+(t||0)-Date.now(),0)}function y(e,t){return typeof e==`function`?e(t):e}function b(e,t){return typeof e==`function`?e(t):e}function x(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==C(o,t.options))return!1}else if(!ee(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function S(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(w(t.options.mutationKey)!==w(a))return!1}else if(!ee(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function C(e,t){return(t?.queryKeyHashFn||w)(e)}function w(e){return JSON.stringify(e,(e,t)=>re(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ee(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ee(e[n],t[n])):!1}var T=Object.prototype.hasOwnProperty;function E(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ne(e)&&ne(t);if(!r&&!(re(e)&&re(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:T.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=E(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function te(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ne(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function re(e){if(!ie(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ie(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ie(e){return Object.prototype.toString.call(e)===`[object Object]`}function ae(e){return new Promise(t=>{f.setTimeout(t,e)})}function oe(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:E(e,t)}function D(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function O(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var se=Symbol();function ce(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===se?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function le(e,t){return typeof e==`function`?e(...t):!!e}function ue(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var k=(()=>{let e=()=>m;return{isServer(){return e()},setIsServer(t){e=t}}})();function A(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var de=p;function fe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=de,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var j=fe(),pe=new class extends l{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function me(e){return Math.min(1e3*2**e,3e4)}function he(e){return(e??`online`)===`online`?pe.isOnline():!0}var ge=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function _e(e){let t=!1,n=0,r,i=A(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ge(t);p(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>u.isFocused()&&(e.networkMode===`always`||pe.isOnline())&&e.canRun(),d=()=>he(e.networkMode)&&e.canRun(),f=e=>{a()||(r?.(),i.resolve(e))},p=e=>{a()||(r?.(),i.reject(e))},m=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),h=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(a())return;let i=e.retry??(k.isServer()?0:3),o=e.retryDelay??me,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),ae(s).then(()=>l()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:d,start:()=>(d()?h():m().then(h),i)}}var ve=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),_(this.gcTime)&&(this.#e=f.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(k.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(f.clearTimeout(this.#e),this.#e=void 0)}},ye=class extends ve{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Se(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Se(this.options);e.data!==void 0&&(this.setState(xe(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=oe(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(h).catch(h):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>b(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===se||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>y(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:!v(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.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.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=ce(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=_e({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ge&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ge){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...be(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...xe(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),j.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function be(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:he(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function xe(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Se(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Ce=class extends l{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=A(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Te(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ee(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ee(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof b(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!te(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&De(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||y(this.options.staleTime,this.#t)!==y(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ke(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(h)),t}#g(){this.#b();let e=y(this.options.staleTime,this.#t);if(k.isServer()||this.#r.isStale||!_(e))return;let t=v(this.#r.dataUpdatedAt,e)+1;this.#d=f.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(k.isServer()||b(this.options.enabled,this.#t)===!1||!_(this.#p)||this.#p===0)&&(this.#f=f.setInterval(()=>{(this.options.refetchIntervalInBackground||u.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(f.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(f.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Te(e,t),o=i&&De(e,n,t,r);(a||o)&&(l={...l,...be(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=oe(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=oe(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,x=d!==void 0,S={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&x,isStale:Oe(e,t),refetch:this.refetch,promise:this.#o,isEnabled:b(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{i(this.#o=S.promise=A())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!te(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){j.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function we(e,t){return b(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&b(t.retryOnMount,e)===!1)}function Te(e,t){return we(e,t)||e.state.data!==void 0&&Ee(e,t,t.refetchOnMount)}function Ee(e,t,n){if(b(t.enabled,e)!==!1&&y(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Oe(e,t)}return!1}function De(e,t,n,r){return(e!==t||b(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Oe(e,n)}function Oe(e,t){return b(t.enabled,e)!==!1&&e.isStaleByTime(y(t.staleTime,e))}function ke(e,t){return!te(e.getCurrentResult(),t)}function Ae(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ue(e,()=>t.signal,()=>n=!0)},u=ce(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?O:D;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Me:je,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:je(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function je(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Me(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Ne=class extends ve{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Pe(),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.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=_e({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,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{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),j.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Pe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Fe=class extends l{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Ne({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ie(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ie(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ie(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Ie(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){j.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>S(t,e))}findAll(e={}){return this.getAll().filter(t=>S(e,t))}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return j.batch(()=>Promise.all(e.map(e=>e.continue().catch(h))))}};function Ie(e){return e.options.scope?.id}var Le=class extends l{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),te(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&w(t.mutationKey)!==w(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Pe();this.#t={...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){j.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Re=class extends l{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??C(r,t),a=this.get(i);return a||(a=new ye({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>x(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>x(e,t)):t}notify(e){j.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ze=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Re,this.#t=e.mutationCache||new Fe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=pe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(y(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=g(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return j.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;j.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return j.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=j.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(h).catch(h)}invalidateQueries(e,t={}){return j.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=j.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(h)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(h)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(y(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(h).catch(h)}fetchInfiniteQuery(e){return e.behavior=Ae(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(h).catch(h)}ensureInfiniteQueryData(e){return e.behavior=Ae(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return pe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(w(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ee(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(w(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ee(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=C(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===se&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},M=n(r(),1),N=t(),Be=M.createContext(void 0),Ve=e=>{let t=M.useContext(Be);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},He=({client:e,children:t})=>(M.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,N.jsx)(Be.Provider,{value:e,children:t})),Ue=M.createContext(!1),We=()=>M.useContext(Ue);Ue.Provider;function Ge(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ke=M.createContext(Ge()),qe=()=>M.useContext(Ke),Je=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?le(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ye=e=>{M.useEffect(()=>{e.clearReset()},[e])},Xe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||le(n,[e.error,r])),Ze=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Qe=(e,t)=>e.isLoading&&e.isFetching&&!t,$e=(e,t)=>e?.suspense&&t.isPending,et=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function tt(e,t,n){let r=We(),i=qe(),a=Ve(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Ze(o),Je(o,i,s),Ye(i);let c=!a.getQueryCache().get(o.queryHash),[l]=M.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(e=>{let t=d?l.subscribe(j.batchCalls(e)):h;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),M.useEffect(()=>{l.setOptions(o)},[o,l]),$e(o,u))throw et(o,l,i);if(Xe({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!k.isServer()&&Qe(u,r)&&(c?et(o,l,i):s?.promise)?.catch(h).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function nt(e,t){return tt(e,Ce,t)}function rt(e,t){let n=Ve(t),[r]=M.useState(()=>new Le(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(j.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(h)},[r]);if(i.error&&le(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var it=M.use,at=typeof window<`u`?M.useLayoutEffect:M.useEffect;function ot(e){let t=M.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function st(e,t,n={},r={}){M.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function ct(e){let t=M.useRef(null);return M.useImperativeHandle(e,()=>t.current,[]),t}function lt(e){return e[e.length-1]}function ut(e){return typeof e==`function`}function dt(e,t){return ut(e)?e(t):e}var ft=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,mt=()=>Object.create(null),ht=(e,t)=>gt(e,t,mt);function gt(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=bt(e)&&bt(i);if(!a&&!(vt(e)&&vt(i)))return i;let o=a?e:_t(e);if(!o)return i;let s=a?i:_t(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:ft.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=gt(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function _t(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!pt.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!pt.call(e,t))return!1;r.push(t)}return r}function vt(e){if(!yt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!yt(n)||!n.hasOwnProperty(`isPrototypeOf`))}function yt(e){return Object.prototype.toString.call(e)===`[object Object]`}function bt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function xt(e,t,n){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 r=0,i=e.length;r<i;r++)if(!xt(e[r],t[r],n))return!1;return!0}if(vt(e)&&vt(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!xt(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!xt(e[o],t[o],n)))return!1;return i===a}return!1}function St(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function Ct(e){return typeof e?.message==`string`?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`):!1}function wt(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}function Tt(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function Et(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Tt(t)}var Dt=[`http:`,`https:`,`mailto:`,`tel:`];function Ot(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function kt(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=Et(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=Et(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function At(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function jt(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Mt(){throw Error(`Invariant failed`)}function Nt(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var Pt=4,Ft=5;function It(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function Lt(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=It(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function Rt(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=!!(n.options?.params?.parse&&n.options?.skipRouteOnParseError?.params);for(;s<o;){let e=Lt(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=Vt(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=Vt(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ht(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ht(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=Ht(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=Vt(n.fullPath??n.from);e.kind=Ft,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=Vt(n.fullPath??n.from);e.kind=Pt,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=n.options?.params?.parse??null,i.skipOnParamError=l,i.parsingPriority=n.options?.skipRouteOnParseError?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)Rt(e,t,r,s,i,a,o)}function zt(e,t){if(e.skipOnParamError&&!t.skipOnParamError)return-1;if(!e.skipOnParamError&&t.skipOnParamError)return 1;if(e.skipOnParamError&&t.skipOnParamError&&(e.parsingPriority||t.parsingPriority))return t.parsingPriority-e.parsingPriority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function Bt(e){if(e.pathless)for(let t of e.pathless)Bt(t);if(e.static)for(let t of e.static.values())Bt(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())Bt(t);if(e.dynamic?.length){e.dynamic.sort(zt);for(let t of e.dynamic)Bt(t)}if(e.optional?.length){e.optional.sort(zt);for(let t of e.optional)Bt(t)}if(e.wildcard?.length){e.wildcard.sort(zt);for(let t of e.wildcard)Bt(t)}}function Vt(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0}}function Ht(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0,caseSensitive:n,prefix:r,suffix:i}}function Ut(e,t){let n=Vt(`/`),r=new Uint16Array(6);for(let t of e)Rt(!1,r,t,1,n,0);Bt(n),t.masksTree=n,t.flatCache=Nt(1e3)}function Wt(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=Yt(e,t.masksTree);return t.flatCache.set(e,r),r}function Gt(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=Vt(`/`),Rt(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),Yt(r,o,n)}function Kt(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=Yt(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=Zt(a.route)),t.matchCache.set(r,a),a}function qt(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function Jt(e,t=!1,n){let r=Vt(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return Rt(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&Mt(),a[e.id]=e,s!==0&&e.path){let t=qt(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),Bt(r),{processedTree:{segmentTree:r,singleCache:Nt(1e3),matchCache:Nt(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function Yt(e,t,n=!1){let r=e.split(`/`),i=$t(e,r,t,n);if(!i)return null;let[a]=Xt(e,r,i);return{route:i.node.route,rawParams:a,parsedParams:i.parsedParams}}function Xt(e,t,n){let r=Qt(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===Pt)break;if(u.kind===Ft){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function Zt(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Qt(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function $t(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!lt(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}],c=null,l=null,u=null;for(;s.length;){let n=s.pop(),{node:i,index:d,skipped:f,depth:p,statics:m,dynamics:h,optionals:g}=n,{extract:_,rawParams:v,parsedParams:y}=n;if(i.skipOnParamError){if(!en(e,t,n))continue;v=n.rawParams,_=n.extract,y=n.parsedParams}r&&i.route&&i.kind!==Pt&&tn(l,n)&&(l=n);let b=d===o;if(b&&(i.route&&!a&&tn(u,n)&&(u=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let x=b?void 0:t[d],S;if(b&&i.index){let n={node:i.index,index:d,skipped:f,depth:p+1,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y},r=!0;if(i.index.skipOnParamError&&(en(e,t,n)||(r=!1)),r){if(m===o&&!h&&!g&&!f)return n;tn(u,n)&&(u=n)}}if(i.wildcard&&tn(c,n))for(let n of i.wildcard){let{prefix:r,suffix:i}=n;if(r&&(b||!(n.caseSensitive?x:S??=x.toLowerCase()).startsWith(r)))continue;if(i){if(b)continue;let e=t.slice(d).join(`/`).slice(-i.length);if((n.caseSensitive?e:e.toLowerCase())!==i)continue}let a={node:n,index:o,skipped:f,depth:p,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y};if(!(n.skipOnParamError&&!en(e,t,a))){c=a;break}}if(i.optional){let e=f|1<<p,t=p+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:d,skipped:e,depth:t,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?x:S??=x.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:d+1,skipped:f,depth:t,statics:m,dynamics:h,optionals:g+1,extract:_,rawParams:v,parsedParams:y})}}if(!b&&i.dynamic&&x)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?x:S??=x.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:d+1,skipped:f,depth:p+1,statics:m,dynamics:h+1,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.staticInsensitive){let e=i.staticInsensitive.get(S??=x.toLowerCase());e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.static){let e=i.static.get(x);e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(i.pathless){let e=p+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:d,skipped:f,depth:e,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}}}if(u&&c)return tn(c,u)?u:c;if(u)return u;if(c)return c;if(r&&l){let n=l.index;for(let e=0;e<l.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return l.rawParams??=Object.create(null),l.rawParams[`**`]=decodeURIComponent(r),l}return null}function en(e,t,n){try{let[r,i]=Xt(e,t,n);n.rawParams=r,n.extract=i;let a=n.node.parse(r);return n.parsedParams=Object.assign(Object.create(null),n.parsedParams,a),!0}catch{return null}}function tn(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===Pt)>(e.node.kind===Pt)||t.node.kind===Pt==(e.node.kind===Pt)&&t.depth>e.depth))):!0}function nn(e){return rn(e.filter(e=>e!==void 0).join(`/`))}function rn(e){return e.replace(/\/{2,}/g,`/`)}function an(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function on(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function sn(e){return on(an(e))}function cn(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function ln(e,t,n){return cn(e,n)===cn(t,n)}function un({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&<(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(lt(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c,l=``;for(let e=0;e<s.length;e++){e>0&&(l+=`/`);let t=s[e];if(!t)continue;c=Lt(t,0,c);let n=c[0];if(n===0){l+=t;continue}let r=c[5],i=t.substring(0,c[1]),a=t.substring(c[4],r),o=t.substring(c[2],c[3]);n===1?l+=i||a?`${i}{$${o}}${a}`:`$${o}`:n===2?l+=i||a?`${i}{$}${a}`:`$`:l+=`${i}{-$${o}}${a}`}l=rn(l);let u=l||`/`;return o&&r&&r.set(o,u),u}function dn(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function fn(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>mn(e,n)).join(`/`):mn(r,n):r}function pn({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=Lt(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=fn(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fn(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fn(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function mn(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function hn(e){return e?.isNotFound===!0}function gn(){try{return typeof window<`u`&&typeof window.sessionStorage==`object`?window.sessionStorage:void 0}catch{return}}var _n=`tsr-scroll-restoration-v1_3`;function vn(){let e=gn();if(!e)return null;let t={};try{let n=JSON.parse(e.getItem(`tsr-scroll-restoration-v1_3`)||`{}`);vt(n)&&(t=n)}catch{}return{get state(){return t},set:e=>{t=dt(e,t)||t},persist:()=>{try{e.setItem(_n,JSON.stringify(t))}catch{}}}}var yn=vn(),bn=e=>e.state.__TSR_key||e.href;function xn(e){let t=[],n;for(;n=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(n.children,e)+1})`),e=n;return`${t.reverse().join(` > `)}`.toLowerCase()}var Sn=!1,Cn=`window`,wn=`data-scroll-restoration-id`;function Tn(e,t){if(!yn)return;let n=yn;if((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isScrollRestorationSetup||!n)return;e.isScrollRestorationSetup=!0,Sn=!1;let r=e.options.getScrollRestorationKey||bn,i=new Map;window.history.scrollRestoration=`manual`;let a=t=>{if(!(Sn||!e.isScrollRestoring))if(t.target===document||t.target===window)i.set(Cn,{scrollX:window.scrollX||0,scrollY:window.scrollY||0});else{let e=t.target;i.set(e,{scrollX:e.scrollLeft||0,scrollY:e.scrollTop||0})}},o=t=>{if(!e.isScrollRestoring||!t||i.size===0||!n)return;let r=n.state[t]||={};for(let[e,t]of i){let n;if(e===Cn)n=Cn;else if(e.isConnected){let t=e.getAttribute(wn);n=t?`[${wn}="${t}"]`:xn(e)}n&&(r[n]=t)}};document.addEventListener(`scroll`,a,!0),e.subscribe(`onBeforeLoad`,e=>{o(e.fromLocation?r(e.fromLocation):void 0),i.clear()}),window.addEventListener(`pagehide`,()=>{o(r(e.stores.resolvedLocation.get()??e.stores.location.get())),n.persist()}),e.subscribe(`onRendered`,t=>{let a=r(t.toLocation),o=e.options.scrollRestorationBehavior,s=e.options.scrollToTopSelectors;if(i.clear(),!e.resetNextScroll){e.resetNextScroll=!0;return}if(!(typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))){Sn=!0;try{let t=e.isScrollRestoring?n.state[a]:void 0,r=!1;if(t)for(let e in t){let n=t[e];if(!vt(n))continue;let{scrollX:i,scrollY:a}=n;if(!(!Number.isFinite(i)||!Number.isFinite(a))){if(e===Cn)window.scrollTo({top:a,left:i,behavior:o}),r=!0;else if(e){let t;try{t=document.querySelector(e)}catch{continue}t&&(t.scrollLeft=i,t.scrollTop=a,r=!0)}}}if(!r){let t=e.history.location.hash.slice(1);if(t){let e=window.history.state?.__hashScrollIntoViewOptions??!0;if(e){let n=document.getElementById(t);n&&n.scrollIntoView(e)}}else{let e={top:0,left:0,behavior:o};if(window.scrollTo(e),s)for(let t of s){if(t===Cn)continue;let n=typeof t==`function`?t():document.querySelector(t);n&&n.scrollTo(e)}}}}finally{Sn=!1}e.isScrollRestoring&&n.set(e=>(e[a]||={},e))}})}function En(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function Dn(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function On(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Dn(r):Array.isArray(t)?t.push(Dn(r)):n[e]=[t,Dn(r)]}return n}var kn=jn(JSON.parse),An=Mn(JSON.stringify,JSON.parse);function jn(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=On(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function Mn(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=En(e,r);return t?`?${t}`:``}}var Nn=`__root__`;function Pn(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{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Fn(e){return e instanceof Response&&!!e.options}function In(e){return{input:({url:t})=>{for(let n of e)t=Rn(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=zn(e[n],t);return t}}}function Ln(e){let t=sn(e.basepath),n=`/${t}`,r=`${n}/`,i=e.caseSensitive?n:n.toLowerCase(),a=e.caseSensitive?r:r.toLowerCase();return{input:({url:t})=>{let r=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return r===i?t.pathname=`/`:r.startsWith(a)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=nn([`/`,t,e.pathname]),e)}}function Rn(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function zn(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Bn(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>Vn(o,_.get())),x=r(()=>Vn(s,v.get())),S=r(()=>Vn(c,y.get())),C=r(()=>_.get()[0]),w=r(()=>_.get().some(e=>o.get(e)?.get().status===`pending`)),ee=r(()=>({locationHref:p.get().href,resolvedLocationHref:m.get()?.href,status:l.get()})),T=r(()=>({status:l.get(),loadedAt:u.get(),isLoading:d.get(),isTransitioning:f.get(),matches:b.get(),location:p.get(),resolvedLocation:m.get(),statusCode:h.get(),redirect:g.get()})),E=Nt(64);function te(e){let t=E.get(e);return t||(t=r(()=>{let t=_.get();for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.get()}}),E.set(e,t)),t}let ne={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingIds:v,cachedIds:y,matches:b,pendingMatches:x,cachedMatches:S,firstId:C,hasPending:w,matchRouteDeps:ee,matchStores:o,pendingMatchStores:s,cachedMatchStores:c,__store:T,getRouteMatchStore:te,setMatches:re,setPending:ie,setCached:ae};re(e.matches),a?.(ne);function re(e){Hn(e,o,_,n,i)}function ie(e){Hn(e,s,v,n,i)}function ae(e){Hn(e,c,y,n,i)}return ne}function Vn(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.get())}return n}function Hn(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.get()!==n&&e.set(n)}jt(n.get(),a)||n.set(a)})}var Un=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},Wn=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),Gn=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),Kn=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},qn=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},Jn=(e,t,n)=>{if(!(!Fn(n)&&!hn(n)))throw Fn(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:Fn(n)?`redirected`:hn(n)?`notFound`:r.status===`pending`?`success`:r.status,context:Kn(e,t.index),isFetching:!1,error:n})),hn(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),Fn(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},Yn=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},Xn=(e,t,n)=>{let r=Kn(e,n);e.updateMatch(t,e=>({...e,context:r}))},Zn=(e,t,n,r)=>{let{id:i,routeId:a}=e.matches[t],o=e.router.looseRoutesById[a];if(n instanceof Promise)throw n;n.routerCode=r,e.firstBadMatchIndex??=t,Jn(e,e.router.getMatch(i),n);try{o.options.onError?.(n)}catch(t){n=t,Jn(e,e.router.getMatch(i),n)}e.updateMatch(i,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!Fn(n)&&!hn(n)&&(e.serialError??=n)},Qn=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!Gn(e,t)&&(n.options.loader||n.options.beforeLoad||lr(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{Un(e)},i);r._nonReactive.pendingTimeout=t}},$n=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Qn(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Jn(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},er=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=St(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&Zn(e,n,o,`PARSE_PARAMS`),s&&Zn(e,n,s,`VALIDATE_SEARCH`),Qn(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=St();let f={...Kn(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=Gn(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(Fn(r)||hn(r))&&(u(),Zn(e,n,r,`BEFORE_LOAD`)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),wt(y))return u(),y.catch(t=>{Zn(e,n,t,`BEFORE_LOAD`)}).then(v)}catch(t){u(),Zn(e,n,t,`BEFORE_LOAD`)}v(y)},tr=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>er(e,n,t,i),s=()=>{if(Yn(e,n))return;let t=$n(e,n,i);return wt(t)?t.then(o):o()};return a()},nr=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},rr=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=Kn(e,r),d=Gn(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},ir=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{cr(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(rr(e,t,n,r,i)),l=!!s&&wt(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;Jn(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:Kn(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:Kn(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,hn(t)&&await i.options.notFoundComponent?.preload?.(),Jn(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,Jn(e,e.router.getMatch(n),t)}!Fn(o)&&!hn(o)&&await cr(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:Kn(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),Jn(e,r,t)}},ar=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(rr(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await ir(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){Fn(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await ir(e,t,i,n,d):Xn(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(Yn(e,i)){if(!e.router.getMatch(i))return e.matches[n];Xn(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.get()[n],s=(o&&e.router.stores.matchStores.get(o)||null)?.routeId===a?o:e.router.stores.matches.get().find(e=>e.routeId===a)?.id,l=Gn(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&Jn(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.matchStores.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=St(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function or(e){let t=e,n=[];Wn(t.router)&&Un(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=tr(t,e);wt(n)&&await n}catch(e){if(Fn(e))throw e;if(hn(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?qn(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(ar(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(Fn(e))throw e;hn(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=qn(t,l);e===void 0&&Mt();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await cr(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await cr(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=nr(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=Un(t);if(wt(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function sr(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function cr(e,t=ur){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===ur?(()=>{if(e._componentsPromise===void 0){let t=sr(e,ur);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():sr(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function lr(e){for(let t of ur)if(e.options[t]?.preload)return!0;return!1}var ur=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`],dr=`__TSR_index`,fr=`popstate`,pr=`beforeunload`;function mr(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=vr(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[dr];i=hr(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[dr];i=hr(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[dr]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function hr(e,t){t||={};let n=yr();return{...t,key:n,__TSR_key:n,[dr]:e}}function gr(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>vr(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=yr();t.history.replaceState({[dr]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=vr(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[dr]-l.state[dr],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=mr({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(pr,S,{capture:!0}),t.removeEventListener(fr,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(pr,S,{capture:!0}),t.addEventListener(fr,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function _r(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function vr(e,t){let n=_r(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=yr();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[dr]:0,key:a,__TSR_key:a}}}function yr(){return(Math.random()+1).toString(36).substring(7)}function br(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var xr=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=dn(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=gr()),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 e;this.resolvePathCache=Nt(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Bn(wr(this.latestLocation),e),Tn(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=sn(o);t&&t!==`/`&&e.push(Ln({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:In(e),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=()=>{let e=Jt(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&Ut(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:kt(e).path,external:!1,searchStr:o,search:ht(t?.search,i),hash:kt(r.slice(1)).path,state:gt(t?.state,a)}}let o=new URL(i,this.origin),s=Rn(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:kt(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:ht(t?.search,c),hash:kt(s.hash.slice(1)).path,state:gt(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>un({base:e,to:rn(t),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>Er({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.get().forEach(e=>{if(this.stores.pendingMatchStores.has(e))return;let t=this.stores.matchStores.get(e)?.get();t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=this.resolvePathWithBase(i,`.`),o=r.search,s=Object.assign(Object.create(null),r.params),c=t.to?this.resolvePathWithBase(a,`${t.to}`):this.resolvePathWithBase(a,`.`),l=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,dt(t.params,s)),u=this.getMatchedRoutes(c),d=u.matchedRoutes;if((!u.foundRoute||u.foundRoute.path!==`/`&&u.routeParams[`**`])&&this.options.notFoundRoute&&(d=[...d,this.options.notFoundRoute]),Object.keys(l).length>0)for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(l,t(l))}catch{}}let f=e.leaveParams?c:kt(pn({path:c,params:l,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,p=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,Tr(t.options.validateSearch,{...e,...p}))}catch{}}),p=e}p=Dr({search:p,dest:t,destRoutes:d,_includeValidateSearch:e._includeValidateSearch}),p=ht(o,p);let m=this.options.stringifySearch(p),h=t.hash===!0?n.hash:t.hash?dt(t.hash,n.hash):void 0,g=h?`#${h}`:``,_=t.state===!0?n.state:t.state?dt(t.state,n.state):{};_=gt(n.state,_);let v=`${f}${m}${g}`,y,b,x=!1;if(this.rewrite){let e=new URL(v,this.origin),t=zn(this.rewrite,e);y=e.href.replace(e.origin,``),t.origin===this.origin?b=t.pathname+t.search+t.hash:(b=t.href,x=!0)}else y=At(v),b=y;return{publicHref:b,href:y,pathname:f,search:p,searchStr:m,state:_,hash:h??``,external:x,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=Wt(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,dt(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=xt(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},i=on(this.latestLocation.href)===on(n.href),a=this.commitLocationPromise;if(this.commitLocationPromise=St(()=>{a?.resolve(),a=void 0}),i&&r())this.load();else{let{maskedLocation:r,hashScrollIntoView:i,...a}=n;r&&(a={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...a,search:a.searchStr,state:{...a.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(a.unmaskOnReload??this.options.unmaskOnReload??!1)&&(a.state.__tempKey=this.tempLocationKey)),a.state.__hashScrollIntoViewOptions=i??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,this.history[n.replace?`replace`:`push`](a.publicHref,a.state,{ignoreBlocker:t})}return this.resetNextScroll=n.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=vr(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=Rn(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(Ot(t,this.protocolAllowlist))return Promise.resolve();if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return i.replace?window.location.replace(t):window.location.href=t,Promise.resolve()}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatches.get().filter(t=>!e.some(e=>e.id===t.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(e),this.stores.setCached(t)})},this.load=async e=>{let t,n,r,i=this.stores.resolvedLocation.get()??this.stores.location.get();for(r=new Promise(a=>{this.startTransition(async()=>{try{this.beforeLoad();let t=this.latestLocation,n=br(t,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:`onBeforeNavigate`,...n}),this.emit({type:`onBeforeLoad`,...n}),await or({router:this,sync:e?.sync,forceStaleReload:i.href===t.href,matches:this.stores.pendingMatches.get(),location:t,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatches.get(),a=i.length,o=this.stores.matches.get();e=a?o.filter(e=>!this.stores.pendingMatchStores.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStores.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.matchStores.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),a&&(this.stores.setMatches(i),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){Fn(e)?(t=e,this.navigate({...t.options,replace:!0,ignoreBlocker:!0})):hn(e)&&(n=e);let r=t?t.status:n?404:this.stores.matches.get().some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.set(r),this.stores.redirect.set(t)})}this.latestLoadPromise===r&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),a()})}),this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise;let a;this.hasNotFoundMatch()?a=404:this.stores.matches.get().some(e=>e.status===`error`)&&(a=500),a!==void 0&&this.stores.statusCode.set(a)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(br(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStores.get(e);if(n){n.set(t);return}let r=this.stores.matchStores.get(e);if(r){r.set(t);return}let i=this.stores.cachedMatchStores.get(e);if(i){let n=t(i.get());n.status===`redirected`?this.stores.cachedMatchStores.delete(e)&&this.stores.cachedIds.set(t=>t.filter(t=>t!==e)):i.set(n)}})},this.getMatch=e=>this.stores.cachedMatchStores.get(e)?.get()??this.stores.pendingMatchStores.get(e)?.get()??this.stores.matchStores.get(e)?.get(),this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(t)),this.stores.setCached(this.stores.cachedMatches.get().map(t)),this.stores.setPending(this.stores.pendingMatches.get().map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&Ot(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCached([]):this.stores.setCached(this.stores.cachedMatches.get().filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`?!0:e-t.updatedAt>=r}})},this.loadRouteChunk=cr,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),i=new Set([...r,...this.stores.cachedIds.get()]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatches.get();this.stores.setCached([...e,...a])}try{return n=await or({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(Fn(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});hn(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.get()!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.get():t.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=Gt(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!xt(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?xt(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(e=>e.status===`notFound`||e.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??An,parseSearch:e.parseSearch??kn,protocolAllowlist:e.protocolAllowlist??Dt}),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:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}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){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i,parsedParams:a}=n,{matchedRoutes:o}=n,s=!1;(r?r.path!==`/`&&i[`**`]:on(e.pathname))&&(this.options.notFoundRoute?o=[...o,this.options.notFoundRoute]:s=!0);let c=s?kr(this.options.notFoundMode,o):void 0,l=Array(o.length),u=new Map;for(let e of this.stores.matchStores.values())e.routeId&&u.set(e.routeId,e.get());for(let n=0;n<o.length;n++){let r=o[n],s=l[n-1],d,f,p;{let n=s?.search??e.search,i=s?._strictSearch??void 0;try{let e=Tr(r.options.validateSearch,{...n})??void 0;d={...n,...e},f={...i,...e},p=void 0}catch(e){let r=e;if(e instanceof Sr||(r=new Sr(e.message,{cause:e})),t?.throwOnError)throw r;d=n,f={},p=r}}let m=r.options.loaderDeps?.({search:d})??``,h=m?JSON.stringify(m):``,{interpolatedPath:g,usedParams:_}=pn({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),v=r.id+g+h,y=this.getMatch(v),b=u.get(r.id),x=y?._strictParams??_,S;if(!y)try{Ar(r,_,a,x)}catch(e){if(S=hn(e)||Fn(e)?e:new Cr(e.message,{cause:e}),t?.throwOnError)throw S}Object.assign(i,x);let C=b?`stay`:`enter`,w;if(y)w={...y,cause:C,params:b?.params??i,_strictParams:x,search:ht(b?b.search:y.search,d),_strictSearch:f};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||lr(r)?`pending`:`success`;w={id:v,ssr:r.options.ssr,index:n,routeId:r.id,params:b?.params??i,_strictParams:x,pathname:g,updatedAt:Date.now(),search:b?ht(b.search,d):d,_strictSearch:f,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:S,__routeContext:void 0,_nonReactive:{loadPromise:St()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:C,loaderDeps:b?gt(b.loaderDeps,m):m,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(w.globalNotFound=c===r.id),w.searchError=p;let ee=this.getParentContext(s);w.context={...ee,...w.__routeContext,...w.__beforeLoadContext},l[n]=w}for(let t=0;t<l.length;t++){let n=l[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=u.get(n.routeId);if(n.params=o?ht(o.params,i):i,!a){let i=l[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:l,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return l}matchRoutesLightweight(e){let{matchedRoutes:t,routeParams:n,parsedParams:r}=this.getMatchedRoutes(e.pathname),i=lt(t),a={...e.search};for(let e of t)try{Object.assign(a,Tr(e.options.validateSearch,a))}catch{}let o=lt(this.stores.matchesId.get()),s=o&&this.stores.matchStores.get(o)?.get(),c=s&&s.routeId===i.id&&s.pathname===e.pathname,l;if(c)l=s.params;else{let e=Object.assign(Object.create(null),n);for(let i of t)try{Ar(i,n,r??{},e)}catch{}l=e}return{matchedRoutes:t,fullPath:i.fullPath,search:a,params:l}}},Sr=class extends Error{},Cr=class extends Error{};function wr(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function Tr(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new Sr(`Async validation not supported`);if(n.issues)throw new Sr(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Er({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=on(e),a,o,s=Kt(i,n,!0);return s&&(a=s.route,Object.assign(r,s.rawParams),o=Object.assign(Object.create(null),s.parsedParams)),{matchedRoutes:s?.branch||[t.__root__],routeParams:r,foundRoute:a,parsedParams:o}}function Dr({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return Or(n)(e,t,r??!1)}function Or(e){let t={dest:null,_includeValidateSearch:!1,middlewares:[]};for(let n of e)`search`in n.options?n.options.search?.middlewares&&t.middlewares.push(...n.options.search.middlewares):(n.options.preSearchFilters||n.options.postSearchFilters)&&t.middlewares.push(({search:e,next:t})=>{let r=e;`preSearchFilters`in n.options&&n.options.preSearchFilters&&(r=n.options.preSearchFilters.reduce((e,t)=>t(e),e));let i=t(r);return`postSearchFilters`in n.options&&n.options.postSearchFilters?n.options.postSearchFilters.reduce((e,t)=>t(e),i):i}),n.options.validateSearch&&t.middlewares.push(({search:e,next:r})=>{let i=r(e);if(!t._includeValidateSearch)return i;try{return{...i,...Tr(n.options.validateSearch,i)??void 0}}catch{return i}});t.middlewares.push(({search:e})=>{let n=t.dest;return n.search?n.search===!0?e:dt(n.search,e):{}});let n=(e,t,r)=>{if(e>=r.length)return t;let i=r[e];return i({search:t,next:t=>n(e+1,t,r)})};return function(e,r,i){return t.dest=r,t._includeValidateSearch=i,n(0,e,t.middlewares)}}function kr(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return Nn}function Ar(e,t,n,r){let i=e.options.params?.parse??e.options.parseParams;if(i)if(e.options.skipRouteOnParseError)for(let e in t)e in n&&(r[e]=n[e]);else{let e=i(r);Object.assign(r,e)}}var jr=`Error preloading route! ☝️`,Mr=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=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=Nn:this.parentRoute||Mt();let r=n?Nn:t?.path;r&&r!==`/`&&(r=an(r));let i=t?.id||r,a=n?Nn:nn([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=nn([`/`,a]));let o=a===`__root__`?`/`:nn([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=on(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>Pn({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},Nr=class extends Mr{constructor(e){super(e)}};function Pr(e){if(typeof document<`u`&&document.querySelector){let t=e.stores.location.get(),n=t.state.__hashScrollIntoViewOptions??!0;if(n&&t.hash!==``){let e=document.getElementById(t.hash);e&&e.scrollIntoView(n)}}}function Fr(e){let t=e.errorComponent??Lr;return(0,N.jsx)(Ir,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?M.createElement(t,{error:n,reset:r}):e.children})}var Ir=class extends M.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}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 Lr({error:e}){let[t,n]=M.useState(!1);return(0,N.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,N.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,N.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,N.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,N.jsx)(`div`,{children:(0,N.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,N.jsx)(`code`,{children:e.message}):null})}):null]})}function Rr({children:e,fallback:t=null}){return zr()?(0,N.jsx)(M.Fragment,{children:e}):(0,N.jsx)(M.Fragment,{children:t})}function zr(){return M.useSyncExternalStore(Br,()=>!0,()=>!1)}function Br(){return()=>{}}var Vr=M.createContext(null);function Hr(e){return M.useContext(Vr)}var Ur=M.createContext(void 0),Wr=M.createContext(void 0),P=(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))(P||{});function Gr({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Kr(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var qr=[],Jr=0,{link:Yr,unlink:Xr,propagate:Zr,checkDirty:Qr,shallowPropagate:$r}=Gr({update(e){return e._update()},notify(e){qr[ti++]=e,e.flags&=~P.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=P.Mutable|P.Dirty,ai(e))}}),ei=0,ti=0,ni,ri=0;function ii(e){try{++ri,e()}finally{--ri||oi()}}function ai(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Xr(n,e)}function oi(){if(!(ri>0)){for(;ei<ti;){let e=qr[ei];qr[ei++]=void 0,e.notify()}ei=0,ti=0}}function si(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?P.None:P.Mutable,get(){return ni!==void 0&&Yr(i,ni,Jr),i._snapshot},subscribe(e){let t=Kr(e),n={current:!1},r=ci(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=ni,o=t?.compare??Object.is;if(n)ni=i,++Jr,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=P.Mutable|P.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{ni=a,n&&(i.flags&=~P.RecursedCheck),ai(i)}}};return n?(i.flags=P.Mutable|P.Dirty,i.get=function(){let e=i.flags;if(e&P.Dirty||e&P.Pending&&Qr(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&$r(e)}}else e&P.Pending&&(i.flags=e&~P.Pending);return ni!==void 0&&Yr(i,ni,Jr),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Zr(e),$r(e),oi())}},i}function ci(e){let t=()=>{let t=ni;ni=n,++Jr,n.depsTail=void 0,n.flags=P.Watching|P.RecursedCheck;try{return e()}finally{ni=t,n.flags&=~P.RecursedCheck,ai(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:P.Watching|P.RecursedCheck,notify(){let e=this.flags;e&P.Dirty||e&P.Pending&&Qr(this.deps,this)?t():this.flags=P.Watching},stop(){this.flags=P.None,this.depsTail=void 0,ai(this)}};return t(),n}var li=c((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),ui=c(((e,t)=>{t.exports=li()})),di=c((e=>{var t=r(),n=ui();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),fi=c(((e,t)=>{t.exports=di()}))();function pi(e,t){return e===t}function mi(e,t,n=pi){let r=(0,M.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,M.useCallback)(()=>e?.get(),[e]);return(0,fi.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var hi={get:()=>void 0,subscribe:()=>({unsubscribe:()=>{}})};function gi(e){let t=Hr(),n=M.useContext(e.from?Wr:Ur),r=e.from??n,i=r?e.from?t.stores.getRouteMatchStore(r):t.stores.matchStores.get(r):void 0,a=M.useRef(void 0);return mi(i??hi,n=>{if((e.shouldThrow??!0)&&!n&&Mt(),n===void 0)return;let r=e.select?e.select(n):n;if(e.structuralSharing??t.options.defaultStructuralSharing){let e=gt(a.current,r);return a.current=e,e}return r})}function _i(e){return gi({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function vi(e){let{select:t,...n}=e;return gi({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function yi(e){return gi({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function bi(e){return gi({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function xi(e){let t=Hr();return M.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Si(e){return gi({...e,select:t=>e.select?e.select(t.context):t.context})}var Ci=c((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.5`})),wi=c(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ci()})),Ti=n(wi(),1);function Ei(e,t){let n=Hr(),r=ct(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:ee,onTouchStart:T,ignoreBlocker:E,params:te,search:ne,hash:re,state:ie,mask:ae,reloadDocument:oe,unsafeRelative:D,from:O,_fromLocation:se,...ce}=e,le=zr(),ue=M.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),k=mi(n.stores.location,e=>e,(e,t)=>e.href===t.href),A=M.useMemo(()=>{let e={_fromLocation:k,...ue};return n.buildLocation(e)},[n,k,ue]),de=A.maskedLocation?A.maskedLocation.publicHref:A.publicHref,fe=A.maskedLocation?A.maskedLocation.external:A.external,j=M.useMemo(()=>Fi(de,fe,n.history,v),[v,fe,de,n.history]),pe=M.useMemo(()=>{if(j?.external)return Ot(j.href,n.protocolAllowlist)?void 0:j.href;if(!Ii(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),Ot(s,n.protocolAllowlist)?void 0:s}catch{}},[s,j,n.protocolAllowlist]),me=M.useMemo(()=>{if(pe)return!1;if(o?.exact){if(!ln(k.pathname,A.pathname,n.basepath))return!1}else{let e=cn(k.pathname,n.basepath),t=cn(A.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!xt(k.search,A.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:o?.includeHash?le&&k.hash===A.hash:!0},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,k,pe,le,A.hash,A.pathname,A.search,n.basepath]),he=me?dt(i,{})??Oi:Di,ge=me?Di:dt(a,{})??Di,_e=[b,he.className,ge.className].filter(Boolean).join(` `),ve=(y||he.style||ge.style)&&{...y,...he.style,...ge.style},[ye,be]=M.useState(!1),xe=M.useRef(!1),Se=e.reloadDocument||pe?!1:c??n.options.defaultPreload,Ce=l??n.options.defaultPreloadDelay??0,we=M.useCallback(()=>{n.preloadRoute({...ue,_builtLocation:A}).catch(e=>{console.warn(e),console.warn(jr)})},[n,ue,A]);st(r,M.useCallback(e=>{e?.isIntersecting&&we()},[we]),Ni,{disabled:!!v||Se!==`viewport`}),M.useEffect(()=>{xe.current||!v&&Se===`render`&&(we(),xe.current=!0)},[v,we,Se]);let Te=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;if(!v&&!I(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Ti.flushSync)(()=>{be(!0)});let t=n.subscribe(`onResolved`,()=>{t(),be(!1)});n.navigate({...ue,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:E})}};if(pe)return{...ce,ref:r,href:pe,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...ee&&{onMouseLeave:ee},...T&&{onTouchStart:T}};let Ee=e=>{if(v||Se!==`intent`)return;if(!Ce){we();return}let t=e.currentTarget;if(Mi.has(t))return;let n=setTimeout(()=>{Mi.delete(t),we()},Ce);Mi.set(t,n)},De=e=>{v||Se!==`intent`||we()},Oe=e=>{if(v||!Se||!Ce)return;let t=e.currentTarget,n=Mi.get(t);n&&(clearTimeout(n),Mi.delete(t))};return{...ce,...he,...ge,href:j?.href,ref:r,onClick:Pi([x,Te]),onBlur:Pi([S,Oe]),onFocus:Pi([C,Ee]),onMouseEnter:Pi([w,Ee]),onMouseLeave:Pi([ee,Oe]),onTouchStart:Pi([T,De]),disabled:!!v,target:_,...ve&&{style:ve},..._e&&{className:_e},...v&&ki,...me&&Ai,...le&&ye&&ji}}var Di={},Oi={className:`active`},ki={role:`link`,"aria-disabled":!0},Ai={"data-status":`active`,"aria-current":`page`},ji={"data-transitioning":`transitioning`},Mi=new WeakMap,Ni={rootMargin:`100px`},Pi=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function Fi(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function Ii(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var F=M.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=Ei(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return M.createElement(`a`,t,o)}return M.createElement(n,a,o)});function I(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var Li=class extends Mr{constructor(e){super(e),this.useMatch=e=>gi({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Si({...e,from:this.id}),this.useSearch=e=>bi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>yi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>vi({...e,from:this.id}),this.useLoaderData=e=>_i({...e,from:this.id}),this.useNavigate=()=>xi({from:this.fullPath}),this.Link=M.forwardRef((e,t)=>(0,N.jsx)(F,{ref:t,from:this.fullPath,...e}))}};function Ri(e){return new Li(e)}function zi(){return e=>Vi(e)}var Bi=class extends Nr{constructor(e){super(e),this.useMatch=e=>gi({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Si({...e,from:this.id}),this.useSearch=e=>bi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>yi({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>vi({...e,from:this.id}),this.useLoaderData=e=>_i({...e,from:this.id}),this.useNavigate=()=>xi({from:this.fullPath}),this.Link=M.forwardRef((e,t)=>(0,N.jsx)(F,{ref:t,from:this.fullPath,...e}))}};function Vi(e){return new Bi(e)}function Hi(e){return new Ui(e,{silent:!0}).createRoute}var Ui=class{constructor(e,t){this.path=e,this.createRoute=e=>{let t=Ri(e);return t.isRoot=!1,t},this.silent=t?.silent}};function Wi(e,t){let n,r,i,a,o=()=>(n||=e().then(e=>{n=void 0,r=e[t??`default`]}).catch(e=>{if(i=e,Ct(i)&&i instanceof Error&&typeof window<`u`&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${i.message}`;sessionStorage.getItem(e)||(sessionStorage.setItem(e,`1`),a=!0)}}),n),s=function(e){if(a)throw window.location.reload(),new Promise(()=>{});if(i)throw i;if(!r)if(it)it(o());else throw o();return M.createElement(r,e)};return s.preload=o,s}function Gi(e){let t=Hr(),n=`not-found-${mi(t.stores.location,e=>e.pathname)}-${mi(t.stores.status,e=>e)}`;return(0,N.jsx)(Fr,{getResetKey:()=>n,onCatch:(t,n)=>{if(hn(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(hn(t))return e.fallback?.(t);throw t},children:e.children})}function Ki(){return(0,N.jsx)(`p`,{children:`Not Found`})}function qi(e){return(0,N.jsx)(N.Fragment,{children:e.children})}function Ji(e,t,n){return t.options.notFoundComponent?(0,N.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,N.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,N.jsx)(Ki,{})}var Yi=M.memo(function({matchId:e}){let t=Hr(),n=t.stores.matchStores.get(e);n||Mt();let r=mi(t.stores.loadedAt,e=>e),i=mi(n,e=>e);return(0,N.jsx)(Xi,{router:t,matchId:e,resetKey:r,matchState:M.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function Xi({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,N.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?M.Suspense:qi,f=s?Fr:qi,p=l?Gi:qi;return(0,N.jsxs)(i.isRoot?i.options.shellComponent??qi:qi,{children:[(0,N.jsx)(Ur.Provider,{value:t,children:(0,N.jsx)(d,{fallback:o,children:(0,N.jsx)(f,{getResetKey:()=>n,errorComponent:s||Lr,onCatch:(e,t)=>{if(hn(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,N.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return M.createElement(l,e)},children:u||r._displayPending?(0,N.jsx)(Rr,{fallback:o,children:(0,N.jsx)(Qi,{matchId:t})}):(0,N.jsx)(Qi,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Zi,{resetKey:n}),(e.options.scrollRestoration,null)]}):null]})}function Zi({resetKey:e}){let t=Hr(),n=M.useRef(void 0);return at(()=>{let e=t.latestLocation.href;(n.current===void 0||n.current!==e)&&(t.emit({type:`onRendered`,...br(t.stores.location.get(),t.stores.resolvedLocation.get())}),n.current=e)},[t.latestLocation.state.__TSR_key,e,t]),null}var Qi=M.memo(function({matchId:e}){let t=Hr(),n=(e,n)=>t.getMatch(e.id)?._nonReactive[n]??e._nonReactive[n],r=t.stores.matchStores.get(e);r||Mt();let i=mi(r,e=>e),a=i.routeId,o=t.routesById[a],s=M.useMemo(()=>{let e=(t.routesById[a].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:a,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return e?JSON.stringify(e):void 0},[a,i.loaderDeps,i._strictParams,i._strictSearch,t.options.defaultRemountDeps,t.routesById]),c=M.useMemo(()=>{let e=o.options.component??t.options.defaultComponent;return e?(0,N.jsx)(e,{},s):(0,N.jsx)($i,{})},[s,o.options.component,t.options.defaultComponent]);if(i._displayPending)throw n(i,`displayPendingPromise`);if(i._forcePending)throw n(i,`minPendingPromise`);if(i.status===`pending`){let e=o.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(i.id);if(n&&!n._nonReactive.minPendingPromise){let t=St();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw n(i,`loadPromise`)}if(i.status===`notFound`)return hn(i.error)||Mt(),Ji(t,o,i.error);if(i.status===`redirected`)throw Fn(i.error)||Mt(),n(i,`loadPromise`);if(i.status===`error`)throw i.error;return c}),$i=M.memo(function(){let e=Hr(),t=M.useContext(Ur),n,r=!1,i;{let a=t?e.stores.matchStores.get(t):void 0;[n,r]=mi(a,e=>[e?.routeId,e?.globalNotFound??!1]),i=mi(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,N.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||Mt(),Ji(e,a,void 0);if(!i)return null;let s=(0,N.jsx)(Yi,{matchId:i});return n===`__root__`?(0,N.jsx)(M.Suspense,{fallback:o,children:s}):s});function ea(){let e=Hr(),t=M.useRef({router:e,mounted:!1}),[n,r]=M.useState(!1),i=mi(e.stores.isLoading,e=>e),a=mi(e.stores.hasPending,e=>e),o=ot(i),s=i||n||a,c=ot(s),l=i||a,u=ot(l);return e.startTransition=e=>{r(!0),M.startTransition(()=>{e(),r(!1)})},M.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return on(e.latestLocation.publicHref)!==on(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),at(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),at(()=>{o&&!i&&e.emit({type:`onLoad`,...br(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,i]),at(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...br(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,u,e]),at(()=>{if(c&&!s){let t=br(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:`onResolved`,...t}),ii(()=>{e.stores.status.set(`idle`),e.stores.resolvedLocation.set(e.stores.location.get())}),t.hrefChanged&&Pr(e)}},[s,c,e]),null}function ta(){let e=Hr(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,N.jsx)(t,{}):null,r=(0,N.jsxs)(typeof document<`u`&&e.ssr?qi:M.Suspense,{fallback:n,children:[(0,N.jsx)(ea,{}),(0,N.jsx)(na,{})]});return e.options.InnerWrap?(0,N.jsx)(e.options.InnerWrap,{children:r}):r}function na(){let e=Hr(),t=mi(e.stores.firstId,e=>e),n=mi(e.stores.loadedAt,e=>e),r=t?(0,N.jsx)(Yi,{matchId:t}):null;return(0,N.jsx)(Ur.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,N.jsx)(Fr,{getResetKey:()=>n,errorComponent:Lr,onCatch:void 0,children:r})})}var ra=e=>({createMutableStore:si,createReadonlyStore:si,batch:ii}),ia=e=>new aa(e),aa=class extends xr{constructor(e){super(e,ra)}};function oa({router:e,children:t,...n}){Object.keys(n).length>0&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,N.jsx)(Vr.Provider,{value:e,children:t});return e.options.Wrap?(0,N.jsx)(e.options.Wrap,{children:r}):r}function sa({router:e,...t}){return(0,N.jsx)(oa,{router:e,...t,children:(0,N.jsx)(ta,{})})}var ca=c((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,te());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}var S=!1,C=-1,w=5,ee=-1;function T(){return g?!0:!(e.unstable_now()-ee<w)}function E(){if(g=!1,S){var t=e.unstable_now();ee=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&T());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(E)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=E,te=function(){re.postMessage(null)}}else te=function(){_(E,0)};function ie(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),la=c(((e,t)=>{t.exports=ca()})),ua=c((e=>{var t=la(),n=r(),i=wi();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,D=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function k(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function A(e,t){le++,ce[le]=e.current,e.current=t}var de=ue(null),fe=ue(null),j=ue(null),pe=ue(null);function me(e,t){switch(A(j,t),A(fe,e),A(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ud(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ud(t),e=Wd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}k(de),A(de,e)}function he(){k(de),k(fe),k(j)}function ge(e){e.memoizedState!==null&&A(pe,e);var t=de.current,n=Wd(t,e.type);t!==n&&(A(fe,e),A(de,n))}function _e(e){fe.current===e&&(k(de),k(fe)),pe.current===e&&(k(pe),$f._currentValue=se)}var ve,ye;function be(e){if(ve===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ve=t&&t[1]||``,ye=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ve+e+ye}var xe=!1;function Se(e,t){if(!e||xe)return``;xe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -56,5 +56,5 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
56
56
|
`),fm=Yf(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),pm=`__optimistic__`,mm=()=>`${pm}${fm()}`,hm=Symbol(`autoStatus`),gm=Object.freeze(Object.assign({type:`running`},{[hm]:!0})),_m=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[hm]:!0})),vm=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[hm]:!0})),ym=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[hm]:!0})),bm=(e,t,n,r,i)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[hm]:!0}):e&&t?gm:n?ym:r?vm:_m,xm=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},Sm=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>e.match(/^data:image\/(png|jpeg|jpg|gif|webp);base64,(.*)$/)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null);if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`reasoning`:return e.text.trim().length===0?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId??`tool-${fm()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:Ff(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=xm(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=xm(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>xm(e.type,e.data)??e)})),metadata:{custom:c?.custom??{}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},Cm={fromArray:e=>{let t=e.map(e=>Sm(e,fm(),bm(!1,!1,!1,!1,void 0)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>{let n=bm(!1,!1,!1,!1,void 0);return{...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:Sm(e,e.id,n)}})}}},wm=e=>e.next?wm(e.next):`current`in e?e:null,Tm=class{func;_value=null;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Em=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){e.level=t;for(let n of e.children){let e=this.messages.get(n);e&&this.updateLevels(e,t+1)}}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(!(n===`relink`&&r===i)){if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`);i.children=[...i.children,t.current.id],(wm(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new Tm(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}appendOptimisticMessage(e,t){let n;do n=mm();while(this.messages.has(n));return this.addOrUpdateMessage(e,Sm(t,n,{type:`running`})),n}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=wm(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=t.prev??this.root;n.next=t,this.head=wm(t),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);if(t.children.length>0){let e=t=>{for(let n of t.children){let t=this.messages.get(n);t&&(e(t),this.messages.delete(n))}};e(t),t.children=[],t.next=null}this.head=t;for(let e=t;e;e=e.prev)e.prev?e.prev.next=e:this.root.next=e;this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[];for(let[,t]of this.messages)e.push({message:t.current,parentId:t.prev?.current.id??null});return{headId:this.head?.current.id??null,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}};function Dm(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=`.${e.name.split(`.`).pop().toLowerCase()}`,i=e.type.toLowerCase();for(let e of n){if(e.startsWith(`.`)&&e===r||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}var Om=e=>e.status.type===`complete`,km=class extends im{isEditing=!0;get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){if(this._text!==e){if(this._text=e,this._dictation){this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}this._notifySubscribers()}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!Om(e));await Promise.all(t.map(t=>e.remove(t)))}}async reset(){if(this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(this.isEmpty)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());let t=this.getAttachmentAdapter(),n=this.attachments.length>0?Promise.all(this.attachments.map(async e=>{if(Om(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)})):[],r=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();let a={createdAt:new Date,role:this.role,content:r?[{type:`text`,text:r}]:[],attachments:await n,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(a,e),this._notifyEventSubscribers(`send`)}cancel(){this.handleCancel()}async addAttachment(e){if(!(e instanceof File)){let t={id:e.id??fm(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,t],this._notifyEventSubscribers(`attachmentAdd`),this._notifySubscribers();return}let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);if(!Dm({name:e.name,type:e.type},t.accept))throw Error(`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`);let n=e=>{let t=this._attachments.findIndex(t=>t.id===e.id);t===-1?this._attachments=[...this._attachments,e]:this._attachments=[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers()},r;try{let i=t.add({file:e});if(Symbol.asyncIterator in i)for await(let e of i)r=e,n(e);else r=await i,n(r)}catch(e){r&&n({...r,status:{type:`incomplete`,reason:`error`}});try{this._notifyEventSubscribers(`attachmentAddError`)}catch{}throw e}let i=r?.status.type===`incomplete`&&r.status.reason===`error`;this._notifyEventSubscribers(i?`attachmentAddError`:`attachmentAdd`)}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(!Om(n)){let e=this.getAttachmentAdapter();if(!e)throw Error(`Attachments are not supported`);await e.remove(n)}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);if(this._dictationSession){for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}let t=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let n=e.listen();this._dictationSession=n;let r=++this._dictationSessionIdCounter;this._activeDictationSessionId=r,this._dictation={status:n.status,inputDisabled:t},this._notifySubscribers();let i=n.onSpeech(e=>{if(!this._isActiveSession(r,n))return;let t=e.isFinal!==!1,i=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+i+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=i+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(i);let a=n.onSpeechStart(()=>{this._isActiveSession(r,n)&&(this._dictation={status:{type:`running`},inputDisabled:t,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);let o=n.onSpeechEnd(()=>{this._cleanupDictation({sessionId:r})});this._dictationUnsubscribes.push(o);let s=setInterval(()=>{this._isActiveSession(r,n)&&n.status.type===`ended`&&this._cleanupDictation({sessionId:r})},100);this._dictationUnsubscribes.push(()=>clearInterval(s))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;e.stop().finally(()=>{this._cleanupDictation({sessionId:t})})}_cleanupDictation(e){if(!(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``,this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(e){let t=this._eventSubscribers.get(e);if(t)for(let e of t)e()}unstable_on(e,t){let n=this._eventSubscribers.get(e);return n?n.add(t):this._eventSubscribers.set(e,new Set([t])),()=>{let n=this._eventSubscribers.get(e);n&&n.delete(t)}}},Am=class extends km{runtime;_canCancel=!1;get canCancel(){return this._canCancel}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}constructor(e){super(),this.runtime=e,this.connect()}connect(){return this.runtime.subscribe(()=>{this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,this._notifySubscribers())})}async handleSend(e,t){this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun})}async handleCancel(){this.runtime.cancelRun()}},jm=class extends km{runtime;endEditCallback;get canCancel(){return!0}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextParts;_previousText;_parentId;_sourceId;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e,this.endEditCallback=t,this._parentId=n,this._sourceId=r.id,this._previousText=dm(r),this.setText(this._previousText),this.setRole(r.role),this.setAttachments(r.attachments??[]),this._nonTextParts=r.content.filter(e=>e.type!==`text`),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){(dm(e)!==this._previousText||t?.startRun)&&this.runtime.append({...e,content:[...e.content,...this._nonTextParts],parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun}),this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},Mm=class{_contextProvider;_subscriptions=new Set;_isInitialized=!1;repository=new Em;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new Am(this);constructor(e){this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new jm(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(let e of this._subscriptions)e()}_notifyEventSubscribers(e){let t=this._eventSubscribers.get(e);if(t)for(let e of t)e()}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){let n=this.adapters?.feedback;if(!n)throw Error(`Feedback adapter not configured`);let{message:r,parentId:i}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role===`assistant`){let e={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(i,e)}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();let r=t.speak(dm(n)),i=r.subscribe(()=>{r.status.type===`ended`?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);this.disconnectVoice();let t=e.connect({});this._voiceSession=t;let n=[],r=`listening`;this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(e=>{e.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:e,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(e=>{r=e,this.voice&&(this.voice={...this.voice,mode:e},this._notifySubscribers())})),n.push(t.onVolumeChange(e=>{this._voiceVolume=e;for(let e of this._voiceVolumeSubscribers)e()})),n.push(t.onTranscript(e=>{this._handleVoiceTranscript(e)})),this._voiceUnsubs=n}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:fm(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:fm(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:`running`},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;let n={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],...e.isFinal?{status:{type:`complete`,reason:`stop`}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){let e=this._voiceMessages.at(-1);if(e?.role===`assistant`&&e.status.type===`running`){let t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:`complete`,reason:`stop`}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(let e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(let e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(Cm.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(t)??(()=>{});let n=this._eventSubscribers.get(e);return n?n.add(t):this._eventSubscribers.set(e,new Set([t])),()=>{this._eventSubscribers.get(e).delete(t)}}},Nm=class{_core;_threadListBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(){let e=this._core.getState();return this._threadListBinding.switchToThread(e.id)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){let e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;n===a&&r===o||(n=a,r=o,!(e===`switchedTo`&&!a)&&(e===`switchedAway`&&a||t()))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},Pm=Symbol(`innerMessage`),Fm=class{_core;get path(){return this._core.path}constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},Im=class extends Fm{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},Lm=class extends Im{get source(){return`thread-composer`}},Rm=class extends Im{get source(){return`edit-composer`}},zm=class extends Fm{get source(){return`message`}constructor(e){super(e)}remove(){throw Error(`Message attachments cannot be removed`)}},Bm=Object.freeze([]),Vm=Object.freeze({}),Hm=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??Bm,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??Vm,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,value:e?.text??``}),Um=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??Bm,runConfig:e?.runConfig??Vm,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),Wm=class{_core;get path(){return this._core.path}constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new lm({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},Gm=class extends Wm{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new sm({path:e.path,getState:()=>Hm(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new Lm(new om({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:nm},subscribe:e=>this._core.subscribe(e)}),this._core)}},Km=class extends Wm{_beginEdit;get path(){return this._core.path}get type(){return`edit`}_getState;constructor(e,t){let n=new sm({path:e.path,getState:()=>Um(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new Rm(new om({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:nm},subscribe:e=>this._core.subscribe(e)}),this._core)}},qm=class{contentBinding;messageApi;threadApi;get path(){return this.contentBinding.path}constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=Pp.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,artifact:a.artifact,isError:a.isError})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}subscribe(e){return this.contentBinding.subscribe(e)}},Jm=Object.freeze({type:`complete`}),Ym=(e,t,n)=>{if(e.role!==`assistant`)return Jm;if(n.type===`tool-call`)return n.result?Jm:e.status;let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?Jm:r?e.status:Jm},Xm=(e,t)=>{let n=e.content[t];if(!n)return nm;let r=Ym(e,t,n);return Object.freeze({...n,[Pm]:n[Pm],status:r})},Zm=class{_core;_threadBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new Km(new cm({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e}){let t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return dm(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new qm(new om({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>Xm(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new qm(new om({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?nm:Xm(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new zm(new om({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:nm},subscribe:e=>this._core.subscribe(e)}))}},Qm=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),$m=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),eh=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},th=(e,t)=>{let n=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:n?.role===`assistant`?n.status.type===`running`:!1,messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})},nh=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(e,t){let n=new om({path:e.path,getState:()=>th(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>{r(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new Gm(new cm({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.resumeRun=this.resumeRun.bind(this),this.unstable_resumeRun=this.unstable_resumeRun.bind(this),this.unstable_loadExternalState=this.unstable_loadExternalState.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getModelConfig=this.getModelConfig.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(eh(this._threadBinding.getState().messages,e))}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}getModelConfig(){return this.getModelContext()}startRun(e){let t=e===null||typeof e==`string`?{parentId:e}:e;return this._threadBinding.getState().startRun($m(t))}resumeRun(e){return this._threadBinding.getState().resumeRun(Qm(e))}unstable_resumeRun(e){return this.resumeRun(e)}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}unstable_loadExternalState(e){this._threadBinding.getState().unstable_loadExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new Zm(new om({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return nm;let o=this._threadBinding.getState().getBranches(e.id),s=e.metadata.submittedFeedback;return{...e,[Pm]:e[Pm],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0,submittedFeedback:s}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new lm({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},rh=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,threadItems:e.threadItems}),ih=(e,t)=>{if(t===void 0)return nm;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,isMain:n.id===e.mainThreadId}:nm},ah=class{_core;_runtimeFactory;_getState;constructor(e,t=nh){this._core=e,this._runtimeFactory=t;let n=new sm({path:{},getState:()=>rh(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new Nm(new om({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>ih(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new cm({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e){return this._core.switchToThread(e)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new cm({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(e){return new Nm(new om({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>ih(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new Nm(new om({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>ih(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new Nm(new om({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>ih(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},oh=class{_core;threads;get threadList(){return this.threads}_thread;constructor(e){this._core=e,this.threads=new ah(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.switchToNewThread=this.switchToNewThread.bind(this),this.switchToThread=this.switchToThread.bind(this),this.registerModelContextProvider=this.registerModelContextProvider.bind(this),this.registerModelConfigProvider=this.registerModelConfigProvider.bind(this),this.reset=this.reset.bind(this)}get thread(){return this._thread}switchToNewThread(){return this._core.threads.switchToNewThread()}switchToThread(e){return this._core.threads.switchToThread(e)}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}registerModelConfigProvider(e){return this.registerModelContextProvider(e)}reset({initialMessages:e}={}){return this._core.threads.getMainThreadRuntimeCore().import(Cm.fromArray(e??[]))}},sh=q(e=>rd(Jp(e)));Gd(sh,(e,t)=>{Yp(e,t),!e.tools&&t.tools.source===null&&(e.tools=lp({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=up())});var ch=(0,M.createContext)(null),lh=({adapters:e,children:t})=>{let n=(0,M.useContext)(ch);return(0,N.jsx)(ch.Provider,{value:{...n,...e},children:t})},uh=()=>(0,M.useContext)(ch);function dh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fh(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>fh(e,t+1)):dh(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&fh(n,t+1)):!1}var ph=(e,t)=>t===void 0?e.status?.type===`requires-action`&&e.status.reason===`tool-calls`&&e.content.every(e=>e.type!==`tool-call`||!!e.result):e.status?.type===`requires-action`&&e.status.reason===`tool-calls`&&e.content.every(e=>e.type!==`tool-call`||!!e.result||!t.includes(e.toolName)),mh=class extends Error{name=`AbortError`;detach;constructor(e,t){super(t),this.detach=e}},hh=class extends Mm{capabilities={switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,reload:!0,cancel:!0,unstable_copy:!0,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};abortController=null;isDisabled=!1;_isLoading=!1;get isLoading(){return this._isLoading}_suggestions=[];_suggestionsController=null;get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}constructor(e,t){super(e),this.__internal_setOptions(t)}_options;_lastRunConfig={};_getThreadId;__internal_setGetThreadId(e){this._getThreadId=e}_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}get extras(){}__internal_setOptions(e){if(this._options===e)return;this._options=e;let t=!1,n=e.adapters?.speech!==void 0;this.capabilities.speech!==n&&(this.capabilities.speech=n,t=!0);let r=e.adapters?.dictation!==void 0;this.capabilities.dictation!==r&&(this.capabilities.dictation=r,t=!0);let i=e.adapters?.voice!==void 0;this.capabilities.voice!==i&&(this.capabilities.voice=i,t=!0);let a=e.adapters?.attachments!==void 0;this.capabilities.attachments!==a&&(this.capabilities.attachments=a,t=!0);let o=e.adapters?.feedback!==void 0;this.capabilities.feedback!==o&&(this.capabilities.feedback=o,t=!0),t&&this._notifySubscribers()}_loadPromise;__internal_load(){if(this._loadPromise)return this._loadPromise;let e=this.adapters.history?.load()??Promise.resolve(null);return this._isLoading=!0,this._notifySubscribers(),this._loadPromise=e.then(e=>{if(!e)return;this.repository.import(e),e.messages.length>0&&this.ensureInitialized(),this._notifySubscribers();let t=this.adapters.history?.resume?.bind(this.adapters.history);e.unstable_resume&&t&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},t).catch(()=>{})}).finally(()=>{this._isLoading=!1,this._notifySubscribers()}),this._loadPromise}async append(e){this.ensureInitialized();let t=this._getInitializePromise?.();t&&await t;let n=Sm(e,fm(),{type:`complete`,reason:`unknown`});this.repository.addOrUpdateMessage(e.parentId,n),this._options.adapters.history?.append({parentId:e.parentId,message:n,...e.runConfig!==void 0&&{runConfig:e.runConfig}}),e.startRun??e.role===`user`?await this.startRun({parentId:n.id,sourceId:e.sourceId,runConfig:e.runConfig??{}}):(this.repository.resetHead(n.id),this._notifySubscribers())}resumeRun({stream:e,...t}){if(!e)throw Error(`You must pass a stream parameter to resume runs.`);return this.startRun(t,e)}exportExternalState(){throw Error(`Runtime does not support exporting external states.`)}importExternalState(){throw Error(`Runtime does not support importing external states.`)}unstable_loadExternalState(){throw Error(`Runtime does not support importing external states.`)}async startRun({parentId:e,runConfig:t},n){this.ensureInitialized();let r={id:fm(),role:`assistant`,status:{type:`running`},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};this._notifyEventSubscribers(`runStart`);try{this._suggestions=[],this._suggestionsController?.abort(),this._suggestionsController=null,this._notifySubscribers();do r=await this.performRoundtrip(e,r,t,n),n=void 0;while(ph(r,this._options.unstable_humanToolNames))}finally{this._notifyEventSubscribers(`runEnd`)}this._suggestionsController=new AbortController;let i=this._suggestionsController.signal;if(this.adapters.suggestion&&r.status?.type!==`requires-action`){let e=this.adapters.suggestion?.generate({messages:this.messages});if(Symbol.asyncIterator in e)for await(let t of e){if(i.aborted)break;this._suggestions=t,this._notifySubscribers()}else{let t=await e;if(i.aborted)return;this._suggestions=t,this._notifySubscribers()}}}async performRoundtrip(e,t,n,r){let i=e?this.repository.getMessages(e):[];this.abortController?.abort(),this.abortController=new AbortController;let a=t.content,o=t.metadata?.unstable_annotations,s=t.metadata?.unstable_data,c=t.metadata?.steps,l=t.metadata?.custom,u=n=>{let r=n.metadata?.steps,i=r?[...c??[],...r]:void 0,u=n.metadata?.unstable_annotations,d=n.metadata?.unstable_data,f=u?[...o??[],...u]:void 0,p=d?[...s??[],...d]:void 0;t={...t,...n.content?{content:[...a,...n.content??[]]}:void 0,status:n.status??t.status,...n.metadata?{metadata:{...t.metadata,...n.metadata.unstable_state?{unstable_state:n.metadata.unstable_state}:void 0,...f?{unstable_annotations:f}:void 0,...p?{unstable_data:p}:void 0,...i?{steps:i}:void 0,...n.metadata?.timing?{timing:n.metadata.timing}:void 0,...n.metadata?.custom?{custom:{...l??{},...n.metadata.custom}}:void 0}}:void 0},this.repository.addOrUpdateMessage(e,t),this._notifySubscribers()},d=this._options.maxSteps??2;if((t.metadata?.steps?.length??0)>=d)return u({status:{type:`incomplete`,reason:`tool-calls`}}),t;u({status:{type:`running`}}),this.repository.resetHead(t.id),this._notifySubscribers();try{this._lastRunConfig=n??{};let a=this.getModelContext();r??=this.adapters.chatModel.run.bind(this.adapters.chatModel);let o=this.abortController.signal,s=this._getThreadId?.(),c=r({messages:i,runConfig:this._lastRunConfig,abortSignal:o,context:a,config:a,unstable_assistantMessageId:t.id,unstable_threadId:s,unstable_parentId:e,unstable_getMessage(){return t}});if(Symbol.asyncIterator in c)for await(let e of c){if(o.aborted){u({status:{type:`incomplete`,reason:`cancelled`}});break}u(e)}else u(await c);t.status.type===`running`&&u({status:{type:`complete`,reason:`unknown`}})}catch(e){if(e instanceof mh)u({status:{type:`incomplete`,reason:`cancelled`}});else if(e instanceof Error&&e.name===`AbortError`)u({status:{type:`incomplete`,reason:`cancelled`}});else throw u({status:{type:`incomplete`,reason:`error`,error:e instanceof Error?e.message:`[${typeof e}] ${new String(e).toString()}`}}),e}finally{this.abortController=null,(t.status.type===`complete`||t.status.type===`incomplete`)&&await this._options.adapters.history?.append({parentId:e,message:t,runConfig:this._lastRunConfig})}return t}detach(){let e=new mh(!0);this.abortController?.abort(e),this.abortController=null}cancelRun(){let e=new mh(!1);this.abortController?.abort(e),this.abortController=null}addToolResult({messageId:e,toolCallId:t,result:n,isError:r,artifact:i}){let a=this.repository.getMessage(e),{parentId:o}=a,{message:s}=a;if(s.role!==`assistant`)throw Error(`Tried to add tool result to non-assistant message`);let c=!1,l=!1,u=s.content.map(e=>e.type!==`tool-call`||e.toolCallId!==t?e:(l=!0,e.result||(c=!0),{...e,result:n,artifact:i,isError:r}));if(!l)throw Error(`Tried to add tool result to non-existing tool call`);s={...s,content:u},this.repository.addOrUpdateMessage(o,s),c&&ph(s,this._options.unstable_humanToolNames)&&this.performRoundtrip(o,s,this._lastRunConfig).catch(()=>{})}resumeToolCall(e){throw Error(`Local runtime does not support resuming tool calls.`)}},gh=Object.freeze([]),_h=`__DEFAULT_ID__`,vh=Object.freeze({[_h]:{id:_h,remoteId:void 0,externalId:void 0,status:`regular`,title:void 0}}),yh=class extends im{_mainThread;constructor(e){super(),this._mainThread=e()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){}get threadIds(){return gh}get archivedThreadIds(){return gh}get mainThreadId(){return _h}get threadItems(){return vh}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getLoadThreadsPromise(){return Promise.resolve()}getItemById(e){if(e===this.mainThreadId)return{status:`regular`,id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw Error(`Method not implemented`)}async switchToThread(){throw Error(`Method not implemented.`)}switchToNewThread(){throw Error(`Method not implemented.`)}rename(){throw Error(`Method not implemented.`)}archive(){throw Error(`Method not implemented.`)}detach(){throw Error(`Method not implemented.`)}unarchive(){throw Error(`Method not implemented.`)}delete(){throw Error(`Method not implemented.`)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},bh=class extends um{threads;Provider=void 0;_options;constructor(e,t){super(),this._options=e,this.threads=new yh(()=>new hh(this._contextProvider,this._options)),t&&this.threads.getMainThreadRuntimeCore().import(Cm.fromArray(t))}},xh=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),Sh=class extends im{_pendingTransforms=[];_completedOptimistics=[];_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){this._cachedValue=this._pendingTransforms.reduce((e,t)=>xh(e,t.task,[t.loading,t.optimistic]),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}async optimisticUpdate(e){let t=e.execute(),n={...e,task:t};try{this._pendingTransforms.push(n),this._updateState();let r=await t;this._baseValue=xh(this._baseValue,r,[e.optimistic,e.then]);for(let e of this._completedOptimistics)this._baseValue=e(this._baseValue);return e.optimistic&&this._completedOptimistics.push(e.optimistic),r}finally{let e=this._pendingTransforms.indexOf(n);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},$=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),Ch={getMessageById(){},getBranches(){return[]},switchToBranch(){throw $},append(){throw $},startRun(){throw $},resumeRun(){throw $},cancelRun(){throw $},addToolResult(){throw $},resumeToolCall(){throw $},speak(){throw $},stopSpeaking(){throw $},connectVoice(){throw $},disconnectVoice(){throw $},getVoiceVolume:()=>0,subscribeVoiceVolume:()=>()=>{},muteVoice(){throw $},unmuteVoice(){throw $},submitFeedback(){throw $},getModelContext(){return{}},exportExternalState(){throw $},importExternalState(){throw $},unstable_loadExternalState(){throw $},composer:{attachments:[],attachmentAccept:`*`,async addAttachment(){throw $},async removeAttachment(){throw $},isEditing:!0,canCancel:!1,isEmpty:!0,text:``,setText(){throw $},role:`user`,setRole(){throw $},runConfig:{},setRunConfig(){throw $},async reset(){},async clearAttachments(){},send(){throw $},cancel(){},dictation:void 0,startDictation(){throw $},stopDictation(){},quote:void 0,setQuote(){throw $},subscribe(){return()=>{}},unstable_on(){return()=>{}}},getEditComposer(){},beginEdit(){throw $},speech:void 0,voice:void 0,capabilities:{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1},isDisabled:!1,isLoading:!0,messages:[],state:null,suggestions:[],extras:void 0,subscribe(){return()=>{}},import(){throw $},export(){return{messages:[]}},reset(){throw $},unstable_on(){return()=>{}}};function wh(e){return e}var Th=(e,t)=>{let n=e.threadIdMap[t];if(n!==void 0)return e.threadData[n]},Eh=(e,t,n)=>{let r=Th(e,t);if(!r)return e;let{id:i,remoteId:a,status:o}=r;if(o===n)return e;let s={...e};switch(o){case`new`:s.newThreadId=void 0;break;case`regular`:s.threadIds=s.threadIds.filter(e=>e!==i);break;case`archived`:s.archivedThreadIds=s.archivedThreadIds.filter(e=>e!==i);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:s.threadIds=[i,...s.threadIds];break;case`archived`:s.archivedThreadIds=[i,...s.archivedThreadIds];break;case`deleted`:s.threadData=Object.fromEntries(Object.entries(s.threadData).filter(([e])=>e!==i)),s.threadIdMap=Object.fromEntries(Object.entries(s.threadIdMap).filter(([e])=>e!==i&&e!==a));break;default:throw Error(`Unsupported state: ${n}`)}return n!==`deleted`&&(s.threadData={...s.threadData,[i]:{...r,status:n}}),s},Dh=class extends im{useRuntimeHook;instances=new Map;useAliveThreadsKeysChanged=Af(()=>({}));parent;constructor(e,t){super(),this.parent=t,this.useRuntimeHook=Af(()=>({useRuntime:e}))}startThreadRuntime(e){return this.instances.has(e)||(this.instances.set(e,{}),this.useAliveThreadsKeysChanged.setState({},!0)),new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(r.runtime)i(),t(r.runtime);else return},i=this.subscribe(r);r()})}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}stopThreadRuntime(e){this.instances.delete(e),this.useAliveThreadsKeysChanged.setState({},!0)}setRuntimeHook(e){this.useRuntimeHook.getState().useRuntime!==e&&this.useRuntimeHook.setState({useRuntime:e},!0)}_InnerActiveThreadProvider=({threadId:e})=>{let{useRuntime:t}=this.useRuntimeHook(),n=t(),r=n.thread.__internal_threadBinding,i=(0,M.useCallback)(()=>{let t=this.instances.get(e);if(!t)throw Error(`Thread not found. This is a bug in assistant-ui.`);t.runtime=r.getState(),this._notifySubscribers()},[e,r]),a=(0,M.useRef)(!1);a.current||i(),(0,M.useEffect)(()=>(a.current=!0,i(),r.outerSubscribe(i)),[r,i]);let o=pf(),s=(0,M.useRef)(void 0);return(0,M.useEffect)(()=>{let e=r.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,()=>s.current)},[r]),(0,M.useEffect)(()=>n.threads.main.unstable_on(`initialize`,()=>{if(o.threadListItem().getState().status===`new`){s.current=o.threadListItem().initialize();let e=n.thread.unstable_on(`runEnd`,()=>{e(),o.threadListItem().generateTitle()})}}),[n,o]),null};_OuterActiveThreadProvider=(0,M.memo)(({threadId:e,provider:t})=>(0,N.jsx)(Xp,{runtime:(0,M.useMemo)(()=>new ah(this.parent).getItemById(e),[e]),children:(0,N.jsx)(t,{children:(0,N.jsx)(this._InnerActiveThreadProvider,{threadId:e})})}));__internal_RenderThreadRuntimes=({provider:e})=>(this.useAliveThreadsKeysChanged(),Array.from(this.instances.keys()).map(t=>(0,N.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},t)))},Oh=class extends im{_options;_hookManager;_loadThreadsPromise;_mainThreadId;_state=new Sh({isLoading:!0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}});get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){return this._loadThreadsPromise||=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:e=>({...e,isLoading:!0}),then:(e,t)=>{let n=[],r=[],i={},a={};for(let e of t.threads){switch(e.status){case`regular`:n.push(e.remoteId);break;case`archived`:r.push(e.remoteId);break;default:{let t=e.status;throw Error(`Unsupported state: ${t}`)}}let t=wh(e.remoteId);i[e.remoteId]=t,a[t]={id:e.remoteId,remoteId:e.remoteId,externalId:e.externalId,status:e.status,title:e.title,initializeTask:Promise.resolve({remoteId:e.remoteId,externalId:e.externalId})}}return{...e,isLoading:!1,threadIds:n,archivedThreadIds:r,threadIdMap:{...e.threadIdMap,...i},threadData:{...e.threadData,...a}}}}).catch(()=>{this._loadThreadsPromise=void 0,this._state.update({...this._state.baseValue,isLoading:!1})}).then(()=>{}),this._loadThreadsPromise}contextProvider;constructor(e,t){super(),this.contextProvider=t,this._state.subscribe(()=>this._notifySubscribers()),this._hookManager=new Dh(e.runtimeHook,this),this.useProvider=Af(()=>({Provider:e.adapter.unstable_Provider??M.Fragment})),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;useProvider;__internal_setOptions(e){if(this._options===e)return;this._options=e;let t=e.adapter.unstable_Provider??M.Fragment;t!==this.useProvider.getState().Provider&&this.useProvider.setState({Provider:t},!0),this._hookManager.setRuntimeHook(e.runtimeHook)}__internal_load(){this.getLoadThreadsPromise();let e=this._options.threadId??this._options.initialThreadId;!this._initialThreadLoaded&&e&&(this._initialThreadLoaded=!0,this.switchToThread(e).catch(()=>{}))}get isLoading(){return this._state.value.isLoading}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||Ch}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw Error(`Thread not found`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Thread not found`);return n}getItemById(e){return Th(this._state.value,e)}async switchToThread(e){let t=this.getItemById(e);if(!t){let n=await this._options.adapter.fetch(e),r=this._state.value,i=wh(n.remoteId),a={...r.threadData,[i]:{id:i,initializeTask:Promise.resolve({remoteId:n.remoteId,externalId:n.externalId}),remoteId:n.remoteId,externalId:n.externalId,status:n.status,title:n.title}},o={...r.threadIdMap,[n.remoteId]:i},s=n.status===`regular`?[...r.threadIds,n.remoteId]:r.threadIds,c=n.status===`archived`?[...r.archivedThreadIds,n.remoteId]:r.archivedThreadIds;this._state.update({...r,threadIds:s,archivedThreadIds:c,threadIdMap:o,threadData:a}),t=this.getItemById(e)}if(!t)throw Error(`Thread not found`);if(this._mainThreadId===t.id)return;let n=this._hookManager.startThreadRuntime(t.id);this.mainThreadId===void 0?n.then(()=>this._notifySubscribers()):await n,t.status===`archived`&&await this.unarchive(t.id),this._mainThreadId=t.id,this._notifySubscribers()}async switchToNewThread(){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)await this._state.waitForUpdate();let e=this._state.value,t=this._state.value.newThreadId;if(t===void 0){do t=`__LOCALID_${fm()}`;while(e.threadIdMap[t]);let n=wh(t);this._state.update({...e,newThreadId:t,threadIdMap:{...e.threadIdMap,[t]:n},threadData:{...e.threadData,[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0}}})}return this.switchToThread(t)}initialize=async e=>{if(this._state.value.newThreadId!==e){let t=this.getItemById(e);if(!t)throw Error(`Thread not found`);if(t.status===`new`)throw Error(`Unexpected new state`);return t.initializeTask}return this._state.optimisticUpdate({execute:()=>this._options.adapter.initialize(e),optimistic:t=>Eh(t,e,`regular`),loading:(t,n)=>{let r=wh(e);return{...t,threadData:{...t.threadData,[r]:{...t.threadData[r],initializeTask:n}}}},then:(t,{remoteId:n,externalId:r})=>{let i=Th(t,e);if(!i)return t;let a=wh(e);return{...t,threadIdMap:{...t.threadIdMap,[n]:a},threadData:{...t.threadData,[a]:{...i,initializeTask:Promise.resolve({remoteId:n,externalId:r}),remoteId:n,externalId:r}}}}})};generateTitle=async e=>{let t=this.getItemById(e);if(!t)throw Error(`Thread not found`);if(t.status===`new`)throw Error(`Thread is not yet initialized`);let{remoteId:n}=await t.initializeTask,r=this._hookManager.getThreadRuntimeCore(t.id);if(!r)return;let i=r.messages,a=await this._options.adapter.generateTitle(n,i),o=Mp.fromAssistantStream(a);for await(let e of o){let n=e.parts.filter(e=>e.type===`text`)[0]?.text,r=this._state.baseValue,i=Th(r,t.id);i&&this._state.update({...r,threadData:{...r.threadData,[i.id]:{...i,title:n}}})}};rename(e,t){let n=this.getItemById(e);if(!n)throw Error(`Thread not found`);if(n.status===`new`)throw Error(`Thread is not yet initialized`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await n.initializeTask;return this._options.adapter.rename(e,t)},optimistic:n=>{let r=Th(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);e===this._mainThreadId&&await this.switchToNewThread()}async archive(e){let t=this.getItemById(e);if(!t)throw Error(`Thread not found`);if(t.status!==`regular`)throw Error(`Thread is not yet initialized or already archived`);return await this._ensureThreadIsNotMain(t.id),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await t.initializeTask;return this._options.adapter.archive(e)},optimistic:e=>Eh(e,t.id,`archived`)})}unarchive(e){let t=this.getItemById(e);if(!t)throw Error(`Thread not found`);if(t.status!==`archived`)throw Error(`Thread is not archived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await t.initializeTask;return await this._options.adapter.unarchive(e)}catch(e){throw await this._ensureThreadIsNotMain(t.id),e}},optimistic:e=>Eh(e,t.id,`regular`)})}async delete(e){let t=this.getItemById(e);if(!t)throw Error(`Thread not found`);if(t.status!==`regular`&&t.status!==`archived`)throw Error(`Thread is not yet initialized`);return await this._ensureThreadIsNotMain(t.id),this._hookManager.stopThreadRuntime(t.id),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await t.initializeTask;return await this._options.adapter.delete(e)},optimistic:e=>Eh(e,t.id,`deleted`)})}async detach(e){let t=this.getItemById(e);if(!t)throw Error(`Thread not found`);if(t.status!==`regular`&&t.status!==`archived`)throw Error(`Thread is not yet initialized`);await this._ensureThreadIsNotMain(t.id),this._hookManager.stopThreadRuntime(t.id)}useBoundIds=Af(()=>[]);__internal_RenderComponent=()=>{let e=(0,M.useId)();(0,M.useEffect)(()=>(this.useBoundIds.setState(t=>[...t,e],!0),()=>{this.useBoundIds.setState(t=>t.filter(t=>t!==e),!0)}),[e]);let t=this.useBoundIds(),{Provider:n}=this.useProvider(),r={modelContext:this.contextProvider};return(t.length===0||t[0]===e)&&(0,N.jsx)(lh,{adapters:r,children:(0,N.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n})})}},kh=class extends um{threads;constructor(e){super(),this.threads=new Oh(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},Ah=e=>{let[t]=(0,M.useState)(()=>new kh(e));return(0,M.useEffect)(()=>{t.threads.__internal_setOptions(e),t.threads.__internal_load()},[t,e]),(0,M.useMemo)(()=>new oh(t),[t])},jh=e=>{let t=(0,M.useRef)(e.runtimeHook);t.current=e.runtimeHook;let n=(0,M.useRef)(e.threadId??e.initialThreadId),r=(0,M.useCallback)(()=>t.current(),[]),i=(0,M.useMemo)(()=>({adapter:e.adapter,allowNesting:e.allowNesting,initialThreadId:n.current,runtimeHook:r}),[e.adapter,e.allowNesting,r]);if(pf().threadListItem.source!==null){if(!i.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return r()}let a=Ah(i),o=(0,M.useRef)(e.threadId);return(0,M.useEffect)(()=>{e.threadId!==o.current&&(o.current=e.threadId,e.threadId?a.threads.switchToThread(e.threadId).catch(()=>{}):a.threads.switchToNewThread().catch(()=>{}))},[a,e.threadId]),a},Mh=e=>{try{let t=e.split(`.`)[1];if(!t)throw Error(`Invalid JWT format`);let n=t.replace(/-/g,`+`).replace(/_/g,`/`);for(;n.length%4!=0;)n+=`=`;let r=atob(n),i=JSON.parse(r).exp;if(!i||typeof i!=`number`)throw Error(`JWT does not contain a valid "exp" field`);return i*1e3}catch(e){throw Error(`Unable to determine the token expiry: ${e}`)}},Nh=class{strategy=`jwt`;cachedToken=null;tokenExpiry=null;#e;constructor(e){this.#e=e}async getAuthHeaders(){let e=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-e>30*1e3)return{Authorization:`Bearer ${this.cachedToken}`};let t=await this.#e();return t?(this.cachedToken=t,this.tokenExpiry=Mh(t),{Authorization:`Bearer ${t}`}):!1}readAuthHeaders(e){let t=e.get(`Authorization`);if(!t)return;let[n,r]=t.split(` `);if(n!==`Bearer`||!r)throw Error(`Invalid auth header received`);this.cachedToken=r,this.tokenExpiry=Mh(r)}},Ph=class{strategy=`api-key`;#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async getAuthHeaders(){return{Authorization:`Bearer ${this.#e}`,"Aui-User-Id":this.#t,"Aui-Workspace-Id":this.#n}}readAuthHeaders(){}},Fh=`aui:refresh_token`,Ih=class{strategy=`anon`;baseUrl;jwtStrategy;constructor(e){this.baseUrl=e,this.jwtStrategy=new Nh(async()=>{let e=Date.now(),t=localStorage.getItem(Fh),n=t?JSON.parse(t):void 0;if(n)if(new Date(n.expires_at).getTime()-e>30*1e3){let e=await fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refresh_token:n.token})});if(e.ok){let{access_token:t,refresh_token:n}=await e.json();return n&&localStorage.setItem(Fh,JSON.stringify(n)),t}}else localStorage.removeItem(Fh);let r=await fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:`POST`});if(!r.ok)return null;let{access_token:i,refresh_token:a}=await r.json();return!i||!a?null:(localStorage.setItem(Fh,JSON.stringify(a)),i)})}async getAuthHeaders(){return this.jwtStrategy.getAuthHeaders()}readAuthHeaders(e){this.jwtStrategy.readAuthHeaders(e)}},Lh=class extends Error{constructor(e){super(e),this.name=`APIError`}},Rh=class{_auth;_baseUrl;constructor(e){if(`authToken`in e)this._baseUrl=e.baseUrl,this._auth=new Nh(e.authToken);else if(`apiKey`in e)this._baseUrl=`https://backend.assistant-api.com`,this._auth=new Ph(e.apiKey,e.userId,e.workspaceId);else if(`anonymous`in e)this._baseUrl=e.baseUrl,this._auth=new Ih(e.baseUrl);else throw Error(`Invalid configuration: Must provide authToken, apiKey, or anonymous configuration`)}async initializeAuth(){return!!this._auth.getAuthHeaders()}async makeRawRequest(e,t={}){let n=await this._auth.getAuthHeaders();if(!n)throw Error(`Authorization failed`);let r={...n,...t.headers,"Content-Type":`application/json`},i=new URLSearchParams;if(t.query)for(let[e,n]of Object.entries(t.query))n!==!1&&(n===!0?i.set(e,`true`):i.set(e,n.toString()));let a=new URL(`${this._baseUrl}/v1${e}`);a.search=i.toString();let o=await fetch(a,{method:t.method??`GET`,headers:r,body:t.body?JSON.stringify(t.body):null});if(this._auth.readAuthHeaders(o.headers),!o.ok){let e=await o.text();try{throw new Lh(JSON.parse(e).message)}catch(t){throw t instanceof Lh?t:Error(`Request failed with status ${o.status}, ${e}`)}}return o}async makeRequest(e,t={}){return(await this.makeRawRequest(e,t)).json()}},zh=class{cloud;constructor(e){this.cloud=e}async create(){return this.cloud.makeRequest(`/auth/tokens`,{method:`POST`})}},Bh=class{cloud;constructor(e){this.cloud=e}__internal_getAssistantOptions(e){return{api:`${this.cloud._baseUrl}/v1/runs/stream`,headers:async()=>{let e=await this.cloud._auth.getAuthHeaders();if(!e)throw Error(`Authorization failed`);return{...e,Accept:`text/plain`}},body:{assistant_id:e,response_format:`vercel-ai-data-stream/v1`,thread_id:`unstable_todo`}}}async stream(e){let t=await this.cloud.makeRawRequest(`/runs/stream`,{method:`POST`,headers:{Accept:`text/plain`},body:e});return If.fromResponse(t,new jp)}async report(e){return this.cloud.makeRequest(`/runs`,{method:`POST`,body:e})}},Vh=class{cloud;constructor(e){this.cloud=e}async list(e,t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{query:t})}async create(e,t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{method:`POST`,body:t})}async update(e,t,n){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}`,{method:`PUT`,body:n})}},Hh=class{cloud;messages;constructor(e){this.cloud=e,this.messages=new Vh(e)}async list(e){return this.cloud.makeRequest(`/threads`,{query:e})}async get(e){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`)}async create(e){return this.cloud.makeRequest(`/threads`,{method:`POST`,body:e})}async update(e,t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`PUT`,body:t})}async delete(e){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`DELETE`})}},Uh=class{cloud;constructor(e){this.cloud=e}async pdfToImages(e){return this.cloud.makeRequest(`/files/pdf-to-images`,{method:`POST`,body:e})}async generatePresignedUploadUrl(e){return this.cloud.makeRequest(`/files/attachments/generate-presigned-upload-url`,{method:`POST`,body:e})}},Wh=class{threads;auth;runs;files;telemetry;constructor(e){let t=new Rh(e);this.threads=new Hh(t),this.auth={tokens:new zh(t)},this.runs=new Bh(t),this.files=new Uh(t);let n=e.telemetry;this.telemetry=n===!1?{enabled:!1}:n===!0||n===void 0?{enabled:!0}:{enabled:n.enabled!==!1,...n}}},Gh=class{cloud;idMapping={};constructor(e){this.cloud=e}async append(e,t,n,r,i){let a=n?await this.idMapping[n]??n:null,o=this.cloud.threads.messages.create(e,{parent_id:a,format:r,content:i}).then(({message_id:e})=>(this.idMapping[t]=e,e)).catch(e=>{throw this.idMapping[t]===o&&delete this.idMapping[t],e});return this.idMapping[t]=o,o.then(()=>{})}async update(e,t,n,r){let i=await this.getRemoteId(t);i&&await this.cloud.threads.messages.update(e,i,{content:r})}isPersisted(e){return e in this.idMapping}async getRemoteId(e){let t=this.idMapping[e];if(t)return t}async load(e,t){let{messages:n}=await this.cloud.threads.messages.list(e,t?{format:t}:void 0);for(let e of n)this.idMapping[e.id]=e.id;return n}reset(){this.idMapping={}}},Kh=(e,t)=>({append:async(n,r)=>{let i=t.getId(r.message),a=t.encode(r);return e.append(n,i,r.parentId,t.format,a)},update:e.update?async(n,r,i)=>{let a=t.encode(r);return e.update(n,i,t.format,a)}:void 0,load:async n=>({messages:(await e.load(n,t.format)).filter(e=>e.format===t.format).map(e=>t.decode({id:e.id,parent_id:e.parent_id,format:e.format,content:e.content})).reverse()}),isPersisted:t=>e.isPersisted(t)}),qh=class{list(){return Promise.resolve({threads:[]})}rename(){return Promise.resolve()}archive(){return Promise.resolve()}unarchive(){return Promise.resolve()}delete(){return Promise.resolve()}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){return Promise.resolve(new ReadableStream)}fetch(e){return Promise.reject(Error(`Thread not found`))}};function Jh(e){let t=e.status?.type===`running`?{type:`incomplete`,reason:`cancelled`}:e.status;return{role:e.role,content:e.content.map(e=>{let t=e.type;switch(t){case`text`:return{type:`text`,text:e.text};case`reasoning`:return{type:`reasoning`,text:e.text};case`source`:return{type:`source`,sourceType:e.sourceType,id:e.id,url:e.url,...e.title?{title:e.title}:void 0};case`tool-call`:return fh(e.result)||console.warn(`tool-call result is not JSON! ${JSON.stringify(e)}`),{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,...JSON.stringify(e.args)===e.argsText?{args:e.args}:{argsText:e.argsText},...e.result?{result:e.result}:void 0,...e.isError?{isError:!0}:void 0};case`image`:return{type:`image`,image:e.image};case`file`:return{type:`file`,data:e.data,mimeType:e.mimeType,...e.filename?{filename:e.filename}:void 0};default:throw Error(`Message part type not supported by aui/v0: ${t}`)}}),metadata:e.metadata,...t?{status:t}:void 0}}function Yh(e){let t=e.content,n=Sm({id:e.id,createdAt:e.created_at,...t},e.id,{type:`complete`,reason:`unknown`});return{parentId:e.parent_id,message:n}}var Xh=new WeakMap,Zh=class{cloudRef;aui;constructor(e,t){this.cloudRef=e,this.aui=t}get _persistence(){let e=this.aui.threadListItem();return Xh.has(e)||Xh.set(e,new Gh(this.cloudRef.current)),Xh.get(e)}withFormat(e){let t=this,n=Kh(this._persistence,e);return{async append(e){let{remoteId:r}=await t.aui.threadListItem().initialize();await n.append(r,e)},async update(e,r){let i=t.aui.threadListItem().getState().remoteId;i&&await n.update?.(i,e,r)},reportTelemetry(n,r){let i=n.map(t=>e.encode(t));t._reportRunTelemetry(e.format,i,r)},async load(){let e=t.aui.threadListItem().getState().remoteId;return e?n.load(e):{messages:[]}}}}async append({parentId:e,message:t}){let{remoteId:n}=await this.aui.threadListItem().initialize(),r=Jh(t);await this._persistence.append(n,t.id,e,`aui/v0`,r),this.cloudRef.current.telemetry.enabled&&this._maybeReportRun(n,`aui/v0`,r)}async load(){let e=this.aui.threadListItem().getState().remoteId;return e?{messages:(await this._persistence.load(e,`aui/v0`)).filter(e=>e.format===`aui/v0`).map(Yh).reverse()}:{messages:[]}}_reportRunTelemetry(e,t,n){if(!this.cloudRef.current.telemetry.enabled)return;let r=this.aui.threadListItem().getState().remoteId;if(!r)return;let i=og(e,t);i&&this._sendReport(r,i,n?.durationMs,n?.stepTimestamps)}_maybeReportRun(e,t,n){let r=ag(t,n);r&&this._sendReport(e,r)}_sendReport(e,t,n,r){let i=ig(t.steps,r),a={thread_id:e,status:t.status,...t.totalSteps==null?void 0:{total_steps:t.totalSteps},...t.toolCalls?{tool_calls:t.toolCalls}:void 0,...i?{steps:i}:void 0,...t.inputTokens==null?void 0:{input_tokens:t.inputTokens},...t.outputTokens==null?void 0:{output_tokens:t.outputTokens},...t.reasoningTokens==null?void 0:{reasoning_tokens:t.reasoningTokens},...t.cachedInputTokens==null?void 0:{cached_input_tokens:t.cachedInputTokens},...n==null?void 0:{duration_ms:n},...t.outputText==null?void 0:{output_text:t.outputText},...t.metadata?{metadata:t.metadata}:void 0,...t.modelId?{model_id:t.modelId}:void 0},{beforeReport:o}=this.cloudRef.current.telemetry,s=o?o(a):a;s&&this.cloudRef.current.runs.report(s).catch(()=>{})}},Qh=5e4;function $h(e){return e.length<=Qh?e:e.slice(0,Qh)}function eg(e){if(e!=null)try{return $h(JSON.stringify(e))}catch{return}}var tg=/^[A-Za-z0-9+/]{100,}={0,2}$/;function ng(e){if(e!=null){try{let t=typeof e==`string`?JSON.parse(e):e;if(Array.isArray(t)){let e=t.map(e=>{if(e&&typeof e==`object`&&e.type&&(e.type===`image`||e.type===`audio`)&&typeof e.data==`string`&&tg.test(e.data.slice(0,200))){let t=(e.data.length*3/4/1024).toFixed(1);return{...e,data:`[${e.type}: ${t}KB]`}}return e});return $h(JSON.stringify(e))}}catch{}return eg(e)}}function rg(e,t,n,r,i,a){let o={tool_name:e,tool_call_id:t},s=i??eg(n);s!==void 0&&(o.tool_args=s);let c=a===`mcp`?ng(r):eg(r);return c!==void 0&&(o.tool_result=c),a&&(o.tool_source=a),o}function ig(e,t){if(!t)return e;if(!e)return t.map(e=>({...e}));let n=Math.min(e.length,t.length);return e.map((e,r)=>({...e,...r<n?t[r]:void 0}))}function ag(e,t){switch(e){case`aui/v0`:return cg(t);case`ai-sdk/v6`:return _g(t);default:return null}}function og(e,t){if(e===`ai-sdk/v6`)return vg(t);for(let n=t.length-1;n>=0;n--){let r=ag(e,t[n]);if(r)return r}return null}var sg={error:`error`,incomplete:`incomplete`};function cg(e){let t=e;if(t.role!==`assistant`)return null;let n=t.content?.filter(e=>e.type===`tool-call`&&e.toolName&&e.toolCallId).map(e=>rg(e.toolName,e.toolCallId,e.args,e.result,e.argsText)),r=t.content?.filter(e=>e.type===`text`&&e.text),i=r&&r.length>0?$h(r.map(e=>e.text).join(``)):void 0,a=t.metadata?.steps,o,s,c,l;if(a&&a.length>0){let e=0,t=0,n=0,r=0,i=!1,u=!1,d=!1,f=!1;for(let o of a)o.usage?.inputTokens!=null&&(e+=o.usage.inputTokens,i=!0),o.usage?.outputTokens!=null&&(t+=o.usage.outputTokens,u=!0),o.usage?.reasoningTokens!=null&&(n+=o.usage.reasoningTokens,d=!0),o.usage?.cachedInputTokens!=null&&(r+=o.usage.cachedInputTokens,f=!0);o=i?e:void 0,s=u?t:void 0,c=d?n:void 0,l=f?r:void 0}let u=t.status?.type,d=u&&sg[u]||`completed`,f=t.metadata?.custom,p=t.metadata?.modelId??(typeof t.metadata?.custom?.modelId==`string`?t.metadata.custom.modelId:void 0),m=a&&a.length>1?a.map(e=>({...e.usage?.inputTokens==null?void 0:{input_tokens:e.usage.inputTokens},...e.usage?.outputTokens==null?void 0:{output_tokens:e.usage.outputTokens},...e.usage?.reasoningTokens==null?void 0:{reasoning_tokens:e.usage.reasoningTokens},...e.usage?.cachedInputTokens==null?void 0:{cached_input_tokens:e.usage.cachedInputTokens}})):void 0;return{status:d,...n&&n.length>0?{toolCalls:n}:void 0,...a?.length?{totalSteps:a.length}:void 0,...o==null?void 0:{inputTokens:o},...s==null?void 0:{outputTokens:s},...c==null?void 0:{reasoningTokens:c},...l==null?void 0:{cachedInputTokens:l},...i==null?void 0:{outputText:i},...f?{metadata:f}:void 0,...m?{steps:m}:void 0,...p?{modelId:p}:void 0}}function lg(e){return e.toolCallId?e.type===`tool-call`||e.type===`dynamic-tool`?!!e.toolName:e.type.startsWith(`tool-`)||e.type.startsWith(`dynamic-tool-`):!1}function ug(e){return e.type===`dynamic-tool`||e.type.startsWith(`dynamic-tool-`)}function dg(e){let t=ug(e)?`mcp`:void 0;return rg(e.toolName??e.type.slice(5),e.toolCallId,e.args??e.input,e.result??e.output,void 0,t)}function fg(e){let t=[],n=[],r=[],i=null;for(let a of e)if(a.type===`step-start`)i!==null&&r.push({tool_calls:i}),i=[];else if(a.type===`text`&&a.text)t.push(a.text);else if(lg(a)){let e=dg(a);n.push(e),i!==null&&i.push(e)}return i!==null&&r.push({tool_calls:i}),{textParts:t,toolCalls:n,stepsData:r}}function pg(e){if(!e)return;if(typeof e.modelId==`string`)return e.modelId;let t=e.custom;if(typeof t?.modelId==`string`)return t.modelId}function mg(e,t,n,r,i,a){let o=e.length>0,s=o?$h(e.join(``)):void 0,c=pg(r),l=i&&i.length>1?i.map(e=>({...e.tool_calls.length>0?{tool_calls:e.tool_calls}:void 0})):void 0;return{status:o?`completed`:`incomplete`,...t.length>0?{toolCalls:t}:void 0,...n>0?{totalSteps:n}:void 0,...a?.inputTokens==null?void 0:{inputTokens:a.inputTokens},...a?.outputTokens==null?void 0:{outputTokens:a.outputTokens},...a?.reasoningTokens==null?void 0:{reasoningTokens:a.reasoningTokens},...a?.cachedInputTokens==null?void 0:{cachedInputTokens:a.cachedInputTokens},...s==null?void 0:{outputText:s},...r?{metadata:r}:void 0,...l?{steps:l}:void 0,...c?{modelId:c}:void 0}}function hg(e){let t=e.inputTokens??e.promptTokens,n=e.outputTokens??e.completionTokens;if(!(t==null&&n==null&&e.reasoningTokens==null&&e.cachedInputTokens==null))return{...t==null?void 0:{inputTokens:t},...n==null?void 0:{outputTokens:n},...e.reasoningTokens==null?void 0:{reasoningTokens:e.reasoningTokens},...e.cachedInputTokens==null?void 0:{cachedInputTokens:e.cachedInputTokens}}}function gg(e){let t=e?.usage;if(t){let e=hg(t);if(e)return e}let n=e?.steps;if(n&&n.length>0){let e=0,t=0,r=0,i=0,a=!1,o=!1,s=!1,c=!1,l=!1;for(let u of n){if(!u.usage)continue;let n=hg(u.usage);n&&(n.inputTokens!=null&&(e+=n.inputTokens,a=!0),n.outputTokens!=null&&(t+=n.outputTokens,o=!0),n.reasoningTokens!=null&&(r+=n.reasoningTokens,s=!0),n.cachedInputTokens!=null&&(i+=n.cachedInputTokens,c=!0),l=!0)}if(l)return{...a?{inputTokens:e}:void 0,...o?{outputTokens:t}:void 0,...s?{reasoningTokens:r}:void 0,...c?{cachedInputTokens:i}:void 0}}}function _g(e){let t=e;if(t.role!==`assistant`)return null;let{textParts:n,toolCalls:r,stepsData:i}=fg(t.parts??[]);return mg(n,r,i.length,t.metadata,i,gg(t.metadata))}function vg(e){let t=[],n=[],r=[],i=!1,a,o=0,s=0,c=0,l=0,u=!1,d=!1,f=!1,p=!1;for(let m of e){let e=m;if(e.role!==`assistant`)continue;i=!0;let{textParts:h,toolCalls:g,stepsData:_}=fg(e.parts??[]);t.push(...h),n.push(...g),r.push(..._),e.metadata&&(a=e.metadata);let v=gg(e.metadata);v&&(v.inputTokens!=null&&(o+=v.inputTokens,u=!0),v.outputTokens!=null&&(s+=v.outputTokens,d=!0),v.reasoningTokens!=null&&(c+=v.reasoningTokens,f=!0),v.cachedInputTokens!=null&&(l+=v.cachedInputTokens,p=!0))}return i?mg(t,n,r.length,a,r,{...u?{inputTokens:o}:void 0,...d?{outputTokens:s}:void 0,...f?{reasoningTokens:c}:void 0,...p?{cachedInputTokens:l}:void 0}):null}function yg(e){let t=pf(),[n]=(0,M.useState)(()=>new Zh(e,t));return n}var bg=e=>e.startsWith(`image/`)?`image`:e.startsWith(`text/`)?`document`:`file`,xg=class{cloud;accept=`*`;constructor(e){this.cloud=e}uploadedUrls=new Map;async*add({file:e}){let t=crypto.randomUUID(),n={id:t,type:bg(e.type),name:e.name,contentType:e.type,file:e,status:{type:`running`,reason:`uploading`,progress:0}};yield n;try{let{signedUrl:r,publicUrl:i}=await this.cloud.files.generatePresignedUploadUrl({filename:e.name});await fetch(r,{method:`PUT`,body:e,headers:{"Content-Type":e.type},mode:`cors`}),this.uploadedUrls.set(t,i),n={...n,status:{type:`requires-action`,reason:`composer-send`}},yield n}catch{n={...n,status:{type:`incomplete`,reason:`error`}},yield n}}async remove(e){this.uploadedUrls.delete(e.id)}async send(e){let t=this.uploadedUrls.get(e.id);if(!t)throw Error(`Attachment not uploaded`);this.uploadedUrls.delete(e.id);let n;return n=e.type===`image`?[{type:`image`,image:t,filename:e.name}]:[{type:`file`,data:t,mimeType:e.contentType??``,filename:e.name}],{...e,status:{type:`complete`},content:n}}},Sg=typeof process<`u`&&{}?.NEXT_PUBLIC_ASSISTANT_BASE_URL,Cg=Sg?new Wh({baseUrl:Sg,anonymous:!0}):void 0,wg=e=>{let t=(0,M.useRef)(e);(0,M.useEffect)(()=>{t.current=e},[e]);let n=(0,M.useCallback)(function({children:e}){let n=yg({get current(){return t.current.cloud??Cg}}),r=t.current.cloud??Cg,i=(0,M.useMemo)(()=>new xg(r),[r]);return(0,N.jsx)(lh,{adapters:(0,M.useMemo)(()=>({history:n,attachments:i}),[n,i]),children:e})},[]),r=e.cloud??Cg;if(!r){let e=t,n=new qh;return n.initialize=async t=>({remoteId:t,externalId:(await e.current.create?.())?.externalId}),n}return{list:async()=>{let{threads:e}=await r.threads.list();return{threads:e.map(e=>({status:e.is_archived?`archived`:`regular`,remoteId:e.id,title:e.title,externalId:e.external_id??void 0}))}},initialize:async()=>{let t=await(e.create?.()??Promise.resolve()),n=t?t.externalId:void 0,{thread_id:i}=await r.threads.create({last_message_at:new Date,external_id:n});return{externalId:n,remoteId:i}},rename:async(e,t)=>r.threads.update(e,{title:t}),archive:async e=>r.threads.update(e,{is_archived:!0}),unarchive:async e=>r.threads.update(e,{is_archived:!1}),delete:async t=>(await e.delete?.(t),r.threads.delete(t)),generateTitle:async(e,t)=>{let n=t.map(e=>({...e,content:e.content.filter(e=>e.type===`text`||e.type===`tool-call`)}));return r.runs.stream({thread_id:e,assistant_id:`system/thread_title`,messages:n})},fetch:async e=>{let t=await r.threads.get(e);return{status:t.is_archived?`archived`:`regular`,remoteId:t.id,title:t.title,externalId:t.external_id??void 0}},unstable_Provider:n}},Tg=e=>e._core?.RenderComponent,Eg=(0,M.memo)(({runtime:e,aui:t=null,children:n})=>{let r=pf({threads:sh(e)},{parent:t}),i=Tg(e);return(0,N.jsxs)(Hd,{value:r,children:[i&&(0,N.jsx)(i,{}),n]})}),Dg=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,Og=()=>null,kg=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message:e.SystemMessage??e.Message??Og;default:throw Error(`Unknown message role: ${t}`)}},Ag=({components:e})=>(0,N.jsx)(kg(e,Q(e=>e.message.role),Q(e=>e.message.composer.isEditing)),{}),jg=(0,M.memo)(({index:e,components:t})=>(0,N.jsx)(Zp,{index:e,children:(0,N.jsx)(Ag,{components:t})}),(e,t)=>e.index===t.index&&Dg(e.components,t.components));jg.displayName=`ThreadPrimitive.MessageByIndex`;var Mg=({children:e})=>{let t=Q(e=>e.thread.messages.length);return(0,M.useMemo)(()=>t===0?null:Array.from({length:t},(t,n)=>(0,N.jsx)(Zp,{index:n,children:(0,N.jsx)(xf,{getItemState:e=>e.thread().message({index:n}).getState(),children:t=>e({get message(){return t()}})})},n)),[t,e])},Ng=({components:e,children:t})=>e?(0,N.jsx)(Mg,{children:()=>(0,N.jsx)(Ag,{components:e})}):(0,N.jsx)(Mg,{children:t});Ng.displayName=`ThreadPrimitive.Messages`;var Pg=(0,M.memo)(Ng,(e,t)=>e.children||t.children?e.children===t.children:Dg(e.components,t.components)),Fg=e=>{let t=e.message.metadata;if(!(!t||typeof t!=`object`))return t.custom?.quote},Ig=e=>Symbol.iterator in e,Lg=e=>`entries`in e,Rg=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},zg=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function Bg(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Ig(e)&&Ig(t)?Lg(e)&&Lg(t)?Rg(e,t):zg(e,t):Rg({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Vg(e){let t=M.useRef(void 0);return n=>{let r=e(n);return Bg(t.current,r)?t.current:t.current=r}}var Hg=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},Ug=(e,t)=>{let n=[];if(t){let t=Hg(`chainOfThoughtGroup`);for(let r=0;r<e.length;r++){let i=e[r];i===`tool-call`||i===`reasoning`?t.startGroup(r):(t.endGroup(r-1,n),n.push({type:`single`,index:r}))}t.finalize(e.length-1,n)}else{let t=Hg(`toolGroup`),r=Hg(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(r.endGroup(i-1,n),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,n),r.startGroup(i)):(t.endGroup(i-1,n),r.endGroup(i-1,n),n.push({type:`single`,index:i}))}t.finalize(e.length-1,n),r.finalize(e.length-1,n)}return n},Wg=e=>{let t=Q(Vg(e=>e.message.parts.map(e=>e.type)));return(0,M.useMemo)(()=>t.length===0?[]:Ug(t,e),[t,e])},Gg=({Fallback:e,...t})=>{let n=Q(n=>{let r=n.tools.tools[t.toolName]??e;return Array.isArray(r)?r[0]??e:r});return n?(0,N.jsx)(n,{...t}):null},Kg=({Fallback:e,...t})=>{let n=Q(n=>{let r=n.dataRenderers.renderers[t.name]??e;return Array.isArray(r)?r[0]??e:r});return n?(0,N.jsx)(n,{...t}):null},qg={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},Jg=({components:{Text:e=qg.Text,Reasoning:t=qg.Reasoning,Image:n=qg.Image,Source:r=qg.Source,File:i=qg.File,Unstable_Audio:a=qg.Unstable_Audio,tools:o={},data:s}={}})=>{let c=pf(),l=Q(e=>e.part),u=l.type;if(u===`tool-call`){let e=c.part().addToolResult,t=c.part().resumeToolCall;if(`Override`in o)return(0,N.jsx)(o.Override,{...l,addResult:e,resume:t});let n=o.by_name?.[l.toolName]??o.Fallback;return(0,N.jsx)(Gg,{...l,Fallback:n,addResult:e,resume:t})}if(l.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(u){case`text`:return(0,N.jsx)(e,{...l});case`reasoning`:return(0,N.jsx)(t,{...l});case`source`:return(0,N.jsx)(r,{...l});case`image`:return(0,N.jsx)(n,{...l});case`file`:return(0,N.jsx)(i,{...l});case`audio`:return(0,N.jsx)(a,{...l});case`data`:{let e=s?.by_name?.[l.name]??s?.Fallback;return(0,N.jsx)(Kg,{...l,Fallback:e})}default:return console.warn(`Unknown message part type: ${u}`),null}},Yg=(0,M.memo)(({index:e,components:t})=>(0,N.jsx)(Qp,{index:e,children:(0,N.jsx)(Jg,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);Yg.displayName=`MessagePrimitive.PartByIndex`;var Xg=({status:e,component:t})=>(0,N.jsx)(em,{text:``,isRunning:e.type===`running`,children:(0,N.jsx)(t,{type:`text`,text:``,status:e})}),Zg=Object.freeze({type:`complete`}),Qg=(0,M.memo)(({components:e})=>{let t=Q(e=>e.message.status??Zg);return e?.Empty?(0,N.jsx)(e.Empty,{status:t}):t.type===`running`?(0,N.jsx)(Xg,{status:t,component:e?.Text??qg.Text}):null},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),$g=(0,M.memo)(({components:e,enabled:t})=>Q(e=>{if(!t||e.message.parts.length===0)return!1;let n=e.message.parts[e.message.parts.length-1];return n?.type!==`text`&&n?.type!==`reasoning`})?(0,N.jsx)(Qg,{components:e}):null,(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),e_=(0,M.memo)(({Quote:e})=>{let t=Q(Fg);return t?(0,N.jsx)(e,{text:t.text,messageId:t.messageId}):null}),t_=()=>{let e=pf(),t=Q(e=>e.part),n=Q(e=>{if(e.part.type!==`tool-call`)return null;let t=e.tools.tools[e.part.toolName];return Array.isArray(t)?t[0]??null:t??null});return!n||t.type!==`tool-call`?null:(0,N.jsx)(n,{...t,addResult:e.part().addToolResult,resume:e.part().resumeToolCall})},n_=()=>{let e=Q(e=>e.part),t=Q(e=>{if(e.part.type!==`data`)return null;let t=e.dataRenderers.renderers[e.part.name];return Array.isArray(t)?t[0]??null:t??null});return!t||e.type!==`data`?null:(0,N.jsx)(t,{...e})},r_=()=>{let e=Q(e=>e.part.type);return e===`tool-call`?(0,N.jsx)(t_,{}):e===`data`?(0,N.jsx)(n_,{}):null},i_=({children:e})=>{let t=pf(),n=Q(e=>e.message.parts.length);return(0,M.useMemo)(()=>Array.from({length:n},(n,r)=>(0,N.jsx)(Qp,{index:r,children:(0,N.jsx)(xf,{getItemState:e=>e.message().part({index:r}).getState(),children:n=>{let i=e({get part(){let e=n();if(e.type===`tool-call`){let n=t.tools().getState().tools[e.toolName],i=Array.isArray(n)?!!n[0]:!!n,a=t.message().part({index:r});return{...e,toolUI:i?(0,N.jsx)(t_,{}):null,addResult:a.addToolResult,resume:a.resumeToolCall}}if(e.type===`data`){let n=t.dataRenderers().getState().renderers[e.name],r=Array.isArray(n)?!!n[0]:!!n;return{...e,dataRendererUI:r?(0,N.jsx)(n_,{}):null}}return e}});return i===null?(0,N.jsx)(r_,{}):i}})},r)),[n,e])},a_=({components:e,unstable_showEmptyOnNonTextEnd:t=!0,children:n})=>n?(0,N.jsx)(i_,{children:n}):(0,N.jsx)(o_,{components:e,unstable_showEmptyOnNonTextEnd:t});a_.displayName=`MessagePrimitive.Parts`;var o_=({components:e,unstable_showEmptyOnNonTextEnd:t})=>{let n=Q(e=>e.message.parts.length),r=Wg(!!e?.ChainOfThought),i=(0,M.useMemo)(()=>n===0?(0,N.jsx)(Qg,{components:e}):r.map(t=>{if(t.type===`single`)return(0,N.jsx)(Yg,{index:t.index,components:e},t.index);if(t.type===`chainOfThoughtGroup`){let n=e?.ChainOfThought;return n?(0,N.jsx)(tm,{startIndex:t.startIndex,endIndex:t.endIndex,children:(0,N.jsx)(n,{})},`chainOfThought-${t.startIndex}`):null}else if(t.type===`toolGroup`)return(0,N.jsx)(e?.ToolGroup??qg.ToolGroup,{startIndex:t.startIndex,endIndex:t.endIndex,children:Array.from({length:t.endIndex-t.startIndex+1},(n,r)=>(0,N.jsx)(Yg,{index:t.startIndex+r,components:e},r))},`tool-${t.startIndex}`);else return(0,N.jsx)(e?.ReasoningGroup??qg.ReasoningGroup,{startIndex:t.startIndex,endIndex:t.endIndex,children:Array.from({length:t.endIndex-t.startIndex+1},(n,r)=>(0,N.jsx)(Yg,{index:t.startIndex+r,components:e},r))},`reasoning-${t.startIndex}`)}),[r,e,n]);return(0,N.jsxs)(N.Fragment,{children:[e?.Quote&&(0,N.jsx)(e_,{Quote:e.Quote}),i,(0,N.jsx)($g,{components:e,enabled:t})]})},s_=()=>{let e=pf(),t=Q(e=>e.thread.isRunning&&!e.thread.capabilities.queue||!e.composer.isEditing||e.composer.isEmpty);return{send:(0,M.useCallback)(t=>{e.composer().send(t)},[e]),disabled:t}},c_=({prompt:e,send:t,clearComposer:n=!0})=>{let r=pf(),i=Q(e=>e.thread.isDisabled),a=t??!1;return{trigger:(0,M.useCallback)(()=>{let t=r.thread().getState().isRunning;if(a&&!t)r.thread().append({content:[{type:`text`,text:e}],runConfig:r.composer().getState().runConfig}),n&&r.composer().setText(``);else if(n)r.composer().setText(e);else{let t=r.composer().getState().text;r.composer().setText(t.trim()?`${t} ${e}`:e)}},[r,a,n,e]),disabled:i}},l_=(e,{initialMessages:t,...n})=>{let{modelContext:r,...i}=uh()??{},a={...n,adapters:{...i,...n.adapters,chatModel:e}},[o]=(0,M.useState)(()=>new bh(a,t)),s=(0,M.useRef)(void 0);return s.current=Q(e=>e.threadListItem.remoteId),(0,M.useEffect)(()=>{o.threads.getMainThreadRuntimeCore().__internal_setGetThreadId(()=>s.current)},[o]),(0,M.useEffect)(()=>()=>{o.threads.getMainThreadRuntimeCore().detach()},[o]),(0,M.useEffect)(()=>{o.threads.getMainThreadRuntimeCore().__internal_setOptions(a),o.threads.getMainThreadRuntimeCore().__internal_load()}),(0,M.useEffect)(()=>{if(r)return o.registerModelContextProvider(r)},[r,o]),(0,M.useMemo)(()=>new oh(o),[o])},u_=(e,{cloud:t,...n}={})=>jh({runtimeHook:function(){return l_(e,n)},adapter:wg({cloud:t}),allowNesting:!0}),d_=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},f_=(e={})=>{let t=new Set,n=d_(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=d_(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=d_(e=>{a.setState({height:{...a.getState().height,userMessage:e}})}),a=Af(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{for(let n of t)n({behavior:e})},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,height:{viewport:0,inset:0,userMessage:0},registerViewport:n.register,registerContentInset:r.register,registerUserMessageHeight:i.register}));return a};function p_(e,t){function n(n){let r=(0,M.useContext)(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function m_(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var h_=(0,M.createContext)(null),{useThreadViewport:g_,useThreadViewportStore:__}=m_(p_(h_,`ThreadPrimitive.Viewport`),`useThreadViewport`),v_=e=>e,y_=e=>{let t=__({optional:!0}),[n]=(0,M.useState)(()=>f_(e));return(0,M.useEffect)(()=>t?.getState().onScrollToBottom(()=>{n.getState().scrollToBottom()}),[t,n]),(0,M.useEffect)(()=>{if(t)return n.subscribe(e=>{t.getState().isAtBottom!==e.isAtBottom&&v_(t).setState({isAtBottom:e.isAtBottom})})},[n,t]),(0,M.useEffect)(()=>{let t={turnAnchor:e.turnAnchor??`bottom`};n.getState().turnAnchor!==t.turnAnchor&&v_(n).setState(t)},[n,e.turnAnchor]),n},b_=({children:e,options:t={}})=>{let n=y_(t),[r]=(0,M.useState)(()=>({useThreadViewport:n}));return(0,N.jsx)(h_.Provider,{value:r,children:e})},x_=()=>((0,M.useEffect)(()=>{},[pf()]),null),S_=(0,M.memo)(({children:e,aui:t,runtime:n})=>(0,N.jsxs)(Eg,{runtime:n,aui:t??null,children:[(0,N.jsx)(x_,{}),(0,N.jsx)(b_,{children:e})]})),C_=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function w_(e){let t=Il[e],n=(0,M.forwardRef)(({render:e,asChild:n,children:r,...i},a)=>{if(e&&(0,M.isValidElement)(e)){let n=r===void 0?e.props.children:r;return(0,N.jsx)(t,{asChild:!0,...i,ref:a,children:(0,M.cloneElement)(e,void 0,n)})}return(0,N.jsx)(t,{asChild:n,...i,ref:a,children:r})});return n.displayName=`Primitive.${e}`,n}var T_=C_.reduce((e,t)=>(e[t]=w_(t),e),{}),E_=(e,t,n=[])=>{let r=(0,M.forwardRef)((e,r)=>{let i={},a={};Object.keys(e).forEach(t=>{n.includes(t)?i[t]=e[t]:a[t]=e[t]});let o=t(i)??void 0;return(0,N.jsx)(T_.button,{...a,type:`button`,ref:r,disabled:a.disabled||!o,onClick:R(a.onClick,o)})});return r.displayName=e,r},D_=()=>{let{disabled:e,send:t}=s_(),n=(0,M.useCallback)(()=>t(),[t]);return e?null:n},O_=E_(`ComposerPrimitive.Send`,D_),k_=(0,M.forwardRef)(({onSubmit:e,...t},n)=>{let r=D_(),i=e=>{e.preventDefault(),r&&r()};return(0,N.jsx)(T_.form,{...t,ref:n,onSubmit:R(e,i)})});k_.displayName=`ComposerPrimitive.Root`;function A_(){return A_=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A_.apply(null,arguments)}function j_(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var M_=M.useLayoutEffect,N_=function(e){var t=M.useRef(e);return M_(function(){t.current=e}),t},P_=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},F_=function(e,t){var n=M.useRef();return M.useCallback(function(r){e.current=r,n.current&&P_(n.current,null),n.current=t,t&&P_(t,r)},[t])},I_={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},L_=function(e){Object.keys(I_).forEach(function(t){e.style.setProperty(t,I_[t],`important`)})},R_=null,z_=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function B_(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),R_||(R_=document.createElement(`textarea`),R_.setAttribute(`tabindex`,`-1`),R_.setAttribute(`aria-hidden`,`true`),L_(R_)),R_.parentNode===null&&document.body.appendChild(R_);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;R_.style[t]=o[t]}),L_(R_),R_.value=t;var c=z_(R_,e);R_.value=t,c=z_(R_,e),R_.value=`x`;var l=R_.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var V_=function(){},H_=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},U_=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],W_=!!document.documentElement.currentStyle,G_=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=H_(U_,t),r=n.boxSizing;return r===``?null:(W_&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function K_(e,t,n){var r=N_(n);M.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var q_=function(e,t){K_(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},J_=function(e){K_(window,`resize`,e)},Y_=function(e){K_(document.fonts,`loadingdone`,e)},X_=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],Z_=M.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?V_:a,s=e.onHeightChange,c=s===void 0?V_:s,l=j_(e,X_),u=l.value!==void 0,d=M.useRef(null),f=F_(d,t),p=M.useRef(0),m=M.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:G_(e);if(t){m.current=t;var a=B_(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return M.useLayoutEffect(h),q_(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),J_(h),Y_(h),M.createElement(`textarea`,A_({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),Q_=e=>{let t=Bo(e),n=g_(e=>e.onScrollToBottom);(0,M.useEffect)(()=>n(t),[n,t])},$_=(0,M.createContext)(null),ev=()=>(0,M.useContext)($_),tv=(0,M.forwardRef)(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:p=!0,addAttachmentOnPaste:m=!0,...h},g)=>{let _=pf(),v=ev(),y=l??(c===!1?`none`:`enter`),b=Q(e=>e.composer.isEditing?e.composer.text:``),x=Q(e=>e.thread.isDisabled||e.composer.dictation?.inputDisabled)||r,S=(0,M.useRef)(null),C=yo(g,S);Vo(e=>{if(!S.current?.contains(e.target))return;if(v){for(let t of v.getPlugins())if(t.handleKeyDown(e))return}if(!u)return;let t=_.composer();t.getState().canCancel&&(t.cancel(),e.preventDefault())});let w=e=>{if(!x&&!e.nativeEvent.isComposing){if(v){for(let t of v.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=_.thread().getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&y!==`none`&&!_.composer().getState().isEmpty){e.preventDefault(),_.composer().send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;y===`ctrlEnter`?r=e.ctrlKey||e.metaKey:y===`enter`&&(r=!0),r&&(e.preventDefault(),S.current?.closest(`form`)?.requestSubmit())}}},ee=async e=>{if(!m)return;let t=_.thread().getState().capabilities,n=Array.from(e.clipboardData?.files||[]);if(t.attachments&&n.length>0)try{e.preventDefault(),await Promise.all(n.map(e=>_.composer().addAttachment(e)))}catch(e){console.error(`Error adding attachment:`,e)}},T=e&&!x,E=(0,M.useCallback)(()=>{let e=S.current;!e||!T||(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[T]);(0,M.useEffect)(()=>E(),[E]),Q_(()=>{_.composer().getState().type===`thread`&&f&&E()}),(0,M.useEffect)(()=>{if(!(_.composer().getState().type!==`thread`||!d))return _.on(`thread.runStart`,E)},[d,E,_]),(0,M.useEffect)(()=>{if(!(_.composer().getState().type!==`thread`||!p))return _.on(`threadListItem.switchedTo`,E)},[p,E,_]);let te={name:`input`,value:b,...h,ref:C,disabled:x,onChange:R(i,e=>{if(!_.composer().getState().isEditing)return;dd(()=>{_.composer().setText(e.target.value)});let t=e.target.selectionStart??e.target.value.length;if(v)for(let e of v.getPlugins())e.setCursorPosition(t)}),onKeyDown:R(a,w),onSelect:R(s,e=>{let t=e.target,n=t.selectionStart??t.value.length;if(v)for(let e of v.getPlugins())e.setCursorPosition(n)}),onPaste:R(o,ee)};if(n&&(0,M.isValidElement)(n)){let e=h.children===void 0?n.props.children:h.children;return(0,N.jsx)(Mo,{...te,children:(0,M.cloneElement)(n,void 0,e)})}return(0,N.jsx)(t?Mo:Z_,{...te})});tv.displayName=`ComposerPrimitive.Input`;var nv=()=>Q(e=>{if(e.part.type!==`text`&&e.part.type!==`reasoning`)throw Error(`MessagePartText can only be used inside text or reasoning message parts.`);return e.part}),rv=(0,M.createContext)(null);function iv(e){let t=(0,M.useContext)(rv);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:av,useSmoothStatusStore:ov}=m_(iv,`useSmoothStatus`),sv=class{currentText;setText;animationFrameId=null;lastUpdateTime=Date.now();targetText=``;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(5,250/n),i=0;for(;t>=r&&i<n;)i++,t-=r;i===n?this.animationFrameId=null:this.animationFrameId=requestAnimationFrame(this.animate),i!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+i),this.lastUpdateTime=e-t,this.setText(this.currentText))}},cv=Object.freeze({type:`running`}),lv=(e,t=!1)=>{let{text:n}=e,r=Q(e=>e.message.id),i=(0,M.useRef)(r),[a,o]=(0,M.useState)(e.status.type===`running`?``:n),s=ov({optional:!0}),c=Bo(t=>{if(o(t),s){let n=a!==t||e.status.type===`running`?cv:e.status;v_(s).setState(n,!0)}});(0,M.useEffect)(()=>{if(s){let r=t&&(a!==n||e.status.type===`running`)?cv:e.status;v_(s).setState(r,!0)}},[s,t,n,a,e.status]);let[l]=(0,M.useState)(new sv(a,c));return(0,M.useEffect)(()=>{if(!t){l.stop();return}if(i.current!==r||!n.startsWith(l.targetText)){i.current=r,e.status.type===`running`?(c(``),l.currentText=``,l.targetText=n,l.start()):(c(n),l.currentText=n,l.targetText=n,l.stop());return}l.targetText=n,l.start()},[c,l,r,t,n,e.status.type]),(0,M.useEffect)(()=>()=>{l.stop()},[l]),(0,M.useMemo)(()=>t?{type:`text`,text:a,status:n===a?e.status:cv}:e,[t,a,e,n])},uv=(0,M.forwardRef)(({smooth:e=!0,component:t=`span`,...n},r)=>{let{text:i,status:a}=lv(nv(),e);return(0,N.jsx)(t,{"data-status":a.type,...n,ref:r,children:i})});uv.displayName=`MessagePartPrimitive.Text`;var dv=()=>Q(e=>{if(e.part.type!==`image`)throw Error(`MessagePartImage can only be used inside image message parts.`);return e.part}),fv=(0,M.forwardRef)((e,t)=>{let{image:n}=dv();return(0,N.jsx)(T_.img,{src:n,...e,ref:t})});fv.displayName=`MessagePartPrimitive.Image`;var pv=({children:e})=>Q(e=>e.part.status.type===`running`)?e:null;pv.displayName=`MessagePartPrimitive.InProgress`;var mv=e=>{let t=(0,M.useRef)(void 0);return(0,M.useCallback)(n=>{t.current&&t.current(),n&&(t.current=e(n))},[e])},hv=(e,t)=>mv((0,M.useCallback)(n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},[e,t])),gv=(0,M.createContext)(!1),_v=(e,t)=>{let n=e.match(/^([\d.]+)(em|px|rem)$/);if(!n)return 0;let r=parseFloat(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):0},vv=({children:e,fillClampThreshold:t=`10em`,fillClampOffset:n=`6em`})=>{let r=Q(e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`),i=__({optional:!0}),a=(0,M.useContext)(gv),o=mv((0,M.useCallback)(e=>{if(!i||a)return;let o=()=>{let a=i.getState();if(a.turnAnchor===`top`&&r){let{viewport:r,inset:i,userMessage:o}=a.height,s=_v(t,e),c=_v(n,e),l=o<=s?o:c,u=Math.max(0,r-i-l);e.style.minHeight=`${u}px`,e.style.flexShrink=`0`,e.style.transition=`min-height 0s`}else e.style.minHeight=``,e.style.flexShrink=``,e.style.transition=``};return o(),i.subscribe(o)},[i,r,a,t,n]));return(0,N.jsx)(gv.Provider,{value:!0,children:(0,N.jsx)(Mo,{ref:o,children:e})})};vv.displayName=`ThreadPrimitive.ViewportSlack`;var yv=()=>{let e=pf(),t=Q(()=>e.message());return mv((0,M.useCallback)(e=>{let n=()=>{t.setIsHovering(!0)},r=()=>{t.setIsHovering(!1)};return e.addEventListener(`mouseenter`,n),e.addEventListener(`mouseleave`,r),e.matches(`:hover`)&&queueMicrotask(()=>t.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,n),e.removeEventListener(`mouseleave`,r),t.setIsHovering(!1)}},[t]))},bv=()=>{let e=g_(e=>e.turnAnchor),t=g_(e=>e.registerUserMessageHeight),n=Q(t=>e===`top`&&t.message.role===`user`&&t.message.index===t.thread.messages.length-2&&t.thread.messages.at(-1)?.role===`assistant`),r=(0,M.useCallback)(e=>e.offsetHeight,[]);return hv(n?t:null,r)},xv=(0,M.forwardRef)(({fillClampThreshold:e,fillClampOffset:t,...n},r)=>{let i=yo(r,yv(),bv()),a=Q(e=>e.message.id);return(0,N.jsx)(vv,{fillClampThreshold:e,fillClampOffset:t,children:(0,N.jsx)(T_.div,{...n,ref:i,"data-message-id":a})})});xv.displayName=`MessagePrimitive.Root`;var Sv={...qg,Text:()=>(0,N.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,N.jsx)(uv,{}),(0,N.jsx)(pv,{children:(0,N.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,N.jsx)(fv,{})},Cv=e=>{if(`children`in e)return(0,N.jsx)(a_,{children:e.children});let{components:t,...n}=e;return(0,N.jsx)(a_,{components:t?{Text:t.Text??Sv.Text,Image:t.Image??Sv.Image,Reasoning:t.Reasoning??qg.Reasoning,Source:t.Source??qg.Source,File:t.File??qg.File,Unstable_Audio:t.Unstable_Audio??qg.Unstable_Audio,...`ChainOfThought`in t?{ChainOfThought:t.ChainOfThought}:{tools:t.tools,data:t.data,ToolGroup:t.ToolGroup??qg.ToolGroup,ReasoningGroup:t.ReasoningGroup??qg.ReasoningGroup},Empty:t.Empty,Quote:t.Quote}:Sv,...n})};Cv.displayName=`MessagePrimitive.Parts`;var wv=(0,M.forwardRef)((e,t)=>(0,N.jsx)(T_.div,{...e,ref:t}));wv.displayName=`ThreadPrimitive.Root`;var Tv=({children:e})=>Q(e=>e.thread.isEmpty)?e:null;Tv.displayName=`ThreadPrimitive.Empty`;var Ev=e=>{let t=Bo(e);return mv((0,M.useCallback)(e=>{let n=new ResizeObserver(()=>{t()}),r=new MutationObserver(e=>{e.some(e=>e.type!==`attributes`||e.attributeName!==`style`)&&t()});return n.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{n.disconnect(),r.disconnect()}},[t]))},Dv=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=(0,M.useRef)(null),a=__();e===void 0&&(e=a.getState().turnAnchor!==`top`);let o=(0,M.useRef)(0),s=(0,M.useRef)(null),c=(0,M.useCallback)(e=>{let t=i.current;t&&(s.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),l=()=>{let e=i.current;if(!e)return;let t=a.getState().isAtBottom,n=Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<1||e.scrollHeight<=e.clientHeight;!n&&o.current<e.scrollTop||(n&&(s.current=null),(n||s.current===null)&&n!==t&&v_(a).setState({isAtBottom:n})),o.current=e.scrollTop},u=Ev(()=>{let t=s.current;t?c(t):e&&a.getState().isAtBottom&&c(`instant`),l()}),d=mv(e=>(e.addEventListener(`scroll`,l),()=>{e.removeEventListener(`scroll`,l)}));return Q_(({behavior:e})=>{c(e)}),vf(`thread.runStart`,()=>{t&&(s.current=`auto`,requestAnimationFrame(()=>{c(`auto`)}))}),vf(`thread.initialize`,()=>{n&&(s.current=`instant`,requestAnimationFrame(()=>{c(`instant`)}))}),vf(`threadListItem.switchedTo`,()=>{r&&(s.current=`instant`,requestAnimationFrame(()=>{c(`instant`)}))}),yo(u,d,i)},Ov=()=>hv(g_(e=>e.registerViewport),(0,M.useCallback)(e=>e.clientHeight,[])),kv=(0,M.forwardRef)(({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r,children:i,...a},o)=>{let s=yo(o,Dv({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r}),Ov());return(0,N.jsx)(T_.div,{...a,ref:s,children:i})});kv.displayName=`ThreadPrimitive.ViewportScrollable`;var Av=(0,M.forwardRef)(({turnAnchor:e,...t},n)=>(0,N.jsx)(b_,{options:{turnAnchor:e},children:(0,N.jsx)(kv,{...t,ref:n})}));Av.displayName=`ThreadPrimitive.Viewport`;var jv=E_(`ThreadPrimitive.Suggestion`,({prompt:e,send:t,clearComposer:n,autoSend:r,method:i})=>{let{disabled:a,trigger:o}=c_({prompt:e,send:t??r??!1,clearComposer:n});return a?null:o},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),Mv=`/api/strategist/stream`;function Nv(){return{async*run({messages:e,abortSignal:t}){let n=[];for(let t of e){if(t.role!==`user`&&t.role!==`assistant`)continue;let e=(t.content??[]).filter(e=>e.type===`text`).map(e=>e.text).join(``);e.length!==0&&n.push({role:t.role,content:e})}let r;try{r=await fetch(Mv,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({messages:n}),signal:t})}catch(e){yield{content:[{type:`text`,text:`Error contacting strategist: ${e.message}`}]};return}if(!r.ok){let e=``;try{e=(await r.json()).error??``}catch{e=await r.text().catch(()=>``)}yield{content:[{type:`text`,text:`Error: ${e||`${r.status} ${r.statusText}`}`}]};return}let i=r.body?.getReader();if(!i){yield{content:[{type:`text`,text:`Error: no response stream`}]};return}let a=new TextDecoder,o=``,s=``;for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.split(`
|
|
57
57
|
|
|
58
58
|
`);o=n.pop()??``;for(let e of n){let t=Pv(e);if(t){if(t.kind===`delta`)s+=t.text,yield{content:[{type:`text`,text:s}]};else if(t.kind===`error`)s+=`\n\nError: ${t.message}`,yield{content:[{type:`text`,text:s}]};else if(t.kind===`done`)return}}}}}}function Pv(e){let t=``,n=``;for(let r of e.split(`
|
|
59
|
-
`))r.startsWith(`event: `)?t=r.slice(7).trim():r.startsWith(`data: `)&&(n=r.slice(6));if(!t||!n)return null;try{return JSON.parse(n)}catch{return null}}var Fv=/<!--ACTION:(enable|disable|apply-config):([^:>]+?)(?::([\s\S]*?))?-->/,Iv=/<!--ACTION:[\s\S]*$/;function Lv(e){let t=e.match(Fv);if(!t)return null;let n=t[1],r=(t[2]??``).trim();if(!r)return null;let i=t[3]??``;if(n===`apply-config`)try{let e=JSON.parse(i);return!e||typeof e!=`object`||Array.isArray(e)?null:{kind:n,trigger:r,config:e}}catch{return null}return{kind:n,trigger:r}}function Rv(e){return e.replace(Fv,``).replace(Iv,``).trim()}var zv=[`Which triggers fit my ICP?`,`Propose github-topics topics + vendors`,`Pick an accelerator-batch cohort for my ICP`,`Audit my current trigger config`];function Bv(){let[e,t]=(0,M.useState)(!1);return(0,N.jsxs)(S_,{runtime:u_((0,M.useMemo)(()=>Nv(),[])),children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(e=>!e),"aria-label":e?`Close strategist`:`Open strategist`,className:`fixed bottom-5 right-5 z-40 flex items-center gap-2 rounded-full border border-ink-rule bg-ink-surface px-4 py-2.5 font-mono text-[11px] uppercase tracking-wider text-ink-cream shadow-lg transition-colors hover:border-ink-rule-2 hover:bg-ink-surface-2`,children:[(0,N.jsx)(Ca,{size:14}),`Strategist`]}),e&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-40 bg-ink-bg/60 backdrop-blur-sm`,onClick:()=>t(!1),"aria-hidden":`true`}),(0,N.jsxs)(`aside`,{className:`fixed right-0 top-0 z-50 flex h-full w-full flex-col border-l border-ink-rule bg-ink-bg-deep shadow-2xl transition-transform duration-200 sm:w-[440px] `+(e?`translate-x-0`:`translate-x-full`),"aria-hidden":!e,children:[(0,N.jsx)(Vv,{onClose:()=>t(!1)}),(0,N.jsx)(Hv,{})]})]})}function Vv({onClose:e}){return(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-ink-rule px-5 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(Ca,{size:14,className:`text-ink-cream-2`}),(0,N.jsx)(`div`,{className:`ln-eyebrow`,children:`Strategist`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Close strategist`,className:`cursor-pointer rounded-full p-1 text-ink-faint transition-colors hover:bg-ink-surface hover:text-ink-cream`,children:(0,N.jsx)(wa,{size:14})})]})}function Hv(){return(0,N.jsxs)(wv,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsx)(Tv,{children:(0,N.jsx)(`div`,{className:`border-b border-ink-rule/60 px-5 py-4`,children:(0,N.jsx)(`p`,{className:`text-sm text-ink-cream-2`,children:`Tell me what to set up. I'll propose configs anchored in your ICP + product and ask before applying anything. Try a chip below or ask anything.`})})}),(0,N.jsx)(Av,{className:`flex-1 space-y-3 overflow-y-auto px-5 py-4`,children:(0,N.jsx)(Pg,{components:{UserMessage:Uv,AssistantMessage:Wv}})}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2 border-t border-ink-rule/60 px-5 py-2`,children:zv.map(e=>(0,N.jsx)(jv,{prompt:e,send:!0,className:`cursor-pointer rounded-full border border-ink-rule px-3 py-1 font-mono text-[10px] uppercase tracking-wider text-ink-muted transition-colors hover:border-ink-rule-2 hover:text-ink-cream-2`,children:e},e))}),(0,N.jsx)(`div`,{className:`border-t border-ink-rule px-5 py-3`,children:(0,N.jsxs)(k_,{className:`flex items-center gap-2`,children:[(0,N.jsx)(tv,{placeholder:`Ask the strategist...`,className:`flex-1 rounded-[var(--radius-sm)] border border-ink-rule bg-ink-bg px-3 py-2 font-mono text-[13px] text-ink-cream outline-none placeholder:text-ink-faint focus:border-ink-rule-2`}),(0,N.jsx)(O_,{asChild:!0,children:(0,N.jsx)(s,{size:`sm`,variant:`primary`,children:`Send`})})]})})]})}function Uv(){return(0,N.jsx)(xv,{className:`flex justify-end`,children:(0,N.jsx)(`div`,{className:`max-w-[80%] rounded-[var(--radius-sm)] border border-ink-rule bg-ink-surface px-3 py-2`,children:(0,N.jsx)(Cv,{components:{Text:({text:e})=>(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-ink-cream`,children:e})}})})})}function Wv(){return(0,N.jsx)(xv,{className:`flex justify-start`,children:(0,N.jsx)(`div`,{className:`max-w-[90%] rounded-[var(--radius-sm)] border border-ink-rule bg-ink-surface px-3 py-2`,children:(0,N.jsx)(Cv,{components:{Text:({text:e})=>(0,N.jsx)(Gv,{text:e})}})})})}function Gv({text:e}){let t=Lv(e);return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink-cream-2`,children:Rv(e)}),t&&(0,N.jsx)(Kv,{action:t})]})}function Kv({action:e}){let t=Ve(),[n,r]=(0,M.useState)(!1),[i,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(null),l=(0,M.useCallback)(async()=>{r(!0),c(null);try{e.kind===`enable`?(await a.setTriggerEnabled(e.trigger,!0),o(`enabled · ${e.trigger}`),Ba.success(`enabled · ${e.trigger}`)):e.kind===`disable`?(await a.setTriggerEnabled(e.trigger,!1),o(`disabled · ${e.trigger}`),Ba.success(`disabled · ${e.trigger}`)):e.kind===`apply-config`&&e.config&&(await a.setTriggerConfig(e.trigger,e.config),o(`config saved · ${e.trigger}`),Ba.success(`config saved · ${e.trigger}`)),t.invalidateQueries({queryKey:[`triggers`]}),t.invalidateQueries({queryKey:[`queue`]})}catch(e){c(e.message)}finally{r(!1)}},[e,t]);if(i)return(0,N.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-2 rounded-[var(--radius-sm)] border border-ink-rule bg-ink-bg-deep px-2.5 py-1.5 font-mono text-[11px] text-ink-receipt-2`,children:[`✓ `,i]});let u=e.kind===`enable`?`Enable ${e.trigger}`:e.kind===`disable`?`Disable ${e.trigger}`:`Apply config to ${e.trigger}`;return(0,N.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,N.jsx)(`button`,{onClick:l,disabled:n,className:`cursor-pointer rounded-[var(--radius-sm)] border border-ink-rule bg-ink-surface px-3 py-1.5 font-mono text-[11px] text-ink-cream transition-colors hover:border-ink-rule-2 disabled:cursor-not-allowed disabled:opacity-60`,children:n?`Applying…`:u}),s&&(0,N.jsxs)(`span`,{className:`font-mono text-[11px] text-ink-blocked-2`,children:[`err: `,s]})]})}var qv=800,Jv={h:`/`,q:`/queue`,c:`/cadences`,r:`/receipts`,m:`/measure`,p:`/plays`,s:`/setup`};function Yv(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function Xv(e){let t=xi(),n=(0,M.useRef)(e);n.current=e,(0,M.useEffect)(()=>{let e=!1,r=null,i=i=>{let a=n.current;if((i.metaKey||i.ctrlKey)&&i.key.toLowerCase()===`k`){i.preventDefault(),a.paletteOpen?a.closePalette():a.openPalette();return}if(i.key===`Escape`&&a.paletteOpen){a.closePalette();return}if(!Yv(i.target)&&!(i.metaKey||i.ctrlKey||i.altKey)){if(e){let n=Jv[i.key.toLowerCase()];n&&(i.preventDefault(),t({to:n})),e=!1,r&&clearTimeout(r);return}i.key.toLowerCase()===`g`&&(e=!0,r&&clearTimeout(r),r=setTimeout(()=>{e=!1},qv))}};return window.addEventListener(`keydown`,i),()=>{window.removeEventListener(`keydown`,i),r&&clearTimeout(r)}},[t])}var Zv=zi()({component:$v}),Qv=[{to:`/`,label:`Today`,icon:fa},{to:`/queue`,label:`Queue`,icon:_a,alert:`queue-pending`},{to:`/inbox`,label:`Replies`,icon:ya},{to:`/cadences`,label:`Cadences`,icon:va},{to:`/receipts`,label:`Receipts`,icon:xa},{to:`/measure`,label:`Measure`,icon:pa},{to:`/plays`,label:`Plays`,icon:ga},{to:`/setup`,label:`Setup`,icon:Sa,alert:`doctor-fail`}];function $v(){let[e,t]=(0,M.useState)(!1);Xv({paletteOpen:e,openPalette:()=>t(!0),closePalette:()=>t(!1)});let n=nt({queryKey:[`queue`,`pending`,`all`],queryFn:()=>a.queue({status:`pending`,limit:1}),refetchInterval:6e4}),r=nt({queryKey:[`doctor`],queryFn:a.doctor,refetchInterval:6e4}),o={"queue-pending":(n.data?.counts.pending??0)>0,"doctor-fail":(r.data?.checks??[]).some(e=>e.severity===`fail`)};return(0,N.jsxs)(`div`,{className:`grid h-full grid-cols-[224px_1fr] grid-rows-[auto_1fr_auto] bg-ink-bg text-ink-cream`,children:[(0,N.jsxs)(`aside`,{className:`row-span-3 flex flex-col border-r border-ink-rule bg-ink-bg/60 px-3 py-5 backdrop-blur-[2px]`,children:[(0,N.jsxs)(`div`,{className:`mb-7 px-2`,children:[(0,N.jsxs)(`div`,{className:`text-ink-cream`,style:{fontFamily:`var(--font-display)`,fontSize:19,letterSpacing:`-0.01em`,lineHeight:1.1},children:[`oneshot`,(0,N.jsx)(`span`,{className:`text-[color:var(--ink-spend-2)]`,children:`·`}),`gtm`]}),(0,N.jsx)(`div`,{className:`mt-0.5 text-[10.5px] uppercase tracking-[0.14em] text-ink-faint`,children:`Founder's ledger`})]}),(0,N.jsx)(`nav`,{className:`flex flex-col gap-0.5`,"aria-label":`primary`,children:Qv.map(({to:e,label:t,icon:n,alert:r})=>{let a=r?o[r]:!1;return(0,N.jsxs)(F,{to:e,activeOptions:{exact:e===`/`},className:i(`group relative flex items-center gap-2.5 rounded-[var(--radius-sm)] px-2.5 py-1.5`,`font-sans text-[13px] text-ink-cream-2`,`transition-colors duration-[var(--dur-stamp)]`,`hover:bg-ink-surface hover:text-ink-cream`),activeProps:{className:`bg-ink-surface text-ink-cream`,"data-active":`true`},children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:i(`pointer-events-none absolute bottom-1 left-0 top-1 w-[2px] rounded-full`,`bg-[color:var(--ink-signal)]`,`opacity-0 transition-opacity duration-[var(--dur-stamp)]`,`group-data-[active=true]:opacity-100`)}),(0,N.jsx)(n,{size:14,className:i(`text-ink-muted transition-colors`,`group-hover:text-ink-cream-2`,`group-data-[active=true]:text-[color:var(--ink-signal-2)]`)}),(0,N.jsx)(`span`,{className:`flex-1`,children:t}),a&&(0,N.jsx)(`span`,{"aria-label":ey(r),title:ey(r),className:i(`h-[6px] w-[6px] shrink-0 rounded-full`,r===`doctor-fail`?`bg-[color:var(--ink-blocked)]`:`bg-[color:var(--ink-spend)]`,`shadow-[0_0_0_2px_color-mix(in_oklch,currentColor_0%,var(--ink-bg)_100%)]`)})]},e)})}),(0,N.jsxs)(`div`,{className:`mt-auto border-t border-ink-rule pt-4 px-2`,children:[(0,N.jsx)(`div`,{className:`ln-eyebrow mb-2`,style:{fontSize:10},children:`Keys`}),(0,N.jsxs)(`div`,{className:`space-y-1 font-mono text-[11px] text-ink-faint`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`group flex w-full items-center justify-between rounded-[var(--radius-xs)] px-1 py-0.5 text-left transition-colors hover:bg-ink-surface/80`,"aria-label":`open command palette`,children:[(0,N.jsx)(`span`,{className:`group-hover:text-ink-cream-2`,children:`palette`}),(0,N.jsx)(`kbd`,{className:`rounded border border-ink-rule px-1 text-ink-cream-2`,children:`⌘K`})]}),(0,N.jsxs)(`div`,{className:`flex justify-between px-1`,children:[(0,N.jsx)(`span`,{children:`queue`}),(0,N.jsx)(`kbd`,{className:`rounded border border-ink-rule px-1 text-ink-cream-2`,children:`g q`})]}),(0,N.jsxs)(`div`,{className:`flex justify-between px-1`,children:[(0,N.jsx)(`span`,{children:`home`}),(0,N.jsx)(`kbd`,{className:`rounded border border-ink-rule px-1 text-ink-cream-2`,children:`g h`})]})]})]})]}),(0,N.jsxs)(`header`,{className:`flex items-center justify-between border-b border-ink-rule bg-ink-bg/70 px-6 py-2.5 backdrop-blur-[2px]`,children:[(0,N.jsxs)(`div`,{className:`text-[11.5px] text-ink-faint ln-mono`,children:[`single user · local-first · bound to `,(0,N.jsx)(`span`,{className:`text-ink-muted`,children:`127.0.0.1`})]}),(0,N.jsx)(gu,{})]}),(0,N.jsx)(`main`,{className:`overflow-y-auto px-6 py-6`,children:(0,N.jsx)($i,{})}),(0,N.jsxs)(`footer`,{className:`border-t border-ink-rule bg-ink-bg/70 px-6 py-2 text-[11px] text-ink-faint backdrop-blur-[2px]`,children:[`Built on OneShot · Read every prompt · Fork every play ·`,` `,(0,N.jsx)(`span`,{className:`text-ink-muted`,children:`MIT`})]}),(0,N.jsx)(fu,{open:e,onOpenChange:t}),(0,N.jsx)(Bv,{}),(0,N.jsx)(to,{position:`bottom-right`,theme:`dark`,richColors:!1,toastOptions:{className:[`!bg-[color:var(--ink-surface)]`,`!text-[color:var(--ink-cream)]`,`!border-[color:var(--ink-rule)]`,`!font-sans`,`!shadow-[var(--shadow-ink-bleed)]`].join(` `),style:{borderRadius:`var(--radius-md)`}}})]})}function ey(e){return e===`queue-pending`?`pending candidates waiting for review`:e===`doctor-fail`?`doctor has a failing check`:``}var ty=`modulepreload`,ny=function(e){return`/`+e},ry={},iy=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ny(t,n),t in ry)return;ry[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:ty,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ay=Hi(`/setup`)({component:Wi(()=>iy(()=>import(`./setup-fs0DMLq4.js`),__vite__mapDeps([0,1,2,3])),`component`)}),oy=Hi(`/receipts`)({component:Wi(()=>iy(()=>import(`./receipts-BgXV3-De.js`),__vite__mapDeps([4,1,5,6,7])),`component`)}),sy=Hi(`/queue`)({component:Wi(()=>iy(()=>import(`./queue-ClVxfeJ0.js`),__vite__mapDeps([8,1,2,5,3,6,7,9,10,11])),`component`)}),cy=Hi(`/plays`)({component:Wi(()=>iy(()=>import(`./plays-DHIZA49D.js`),__vite__mapDeps([12,1,3,7])),`component`)}),ly=Hi(`/measure`)({component:Wi(()=>iy(()=>import(`./measure-S3BWSb2L.js`),__vite__mapDeps([13,1,5,7])),`component`)}),uy=Hi(`/inbox`)({component:Wi(()=>iy(()=>import(`./inbox-Dzd9QYT4.js`),__vite__mapDeps([14,1,2,5,7,10,11,15])),`component`)}),dy=Hi(`/cadences`)({component:Wi(()=>iy(()=>import(`./cadences-CsU8vKw2.js`),__vite__mapDeps([16,1,2,5,3,6,7])),`component`)}),fy=Hi(`/`)({component:Wi(()=>iy(()=>import(`./routes-B9L9tBMF.js`),__vite__mapDeps([17,1,2,5,7,9,10])),`component`)}),py=Hi(`/run/$playName`)({component:Wi(()=>iy(()=>import(`./run._playName-a3eeybKs.js`),__vite__mapDeps([18,1,2,3,15])),`component`),validateSearch:e=>{let t={};return e.fromQueue===`1`&&(t.fromQueue=`1`),typeof e.limit==`number`?t.limit=e.limit:typeof e.limit==`string`&&/^\d+$/.test(e.limit)&&(t.limit=Number.parseInt(e.limit,10)),(e.dryRun===`0`||e.dryRun===`1`)&&(t.dryRun=e.dryRun),typeof e.senderCohort==`string`&&(t.senderCohort=e.senderCohort),typeof e.freeForCohortOffer==`string`&&(t.freeForCohortOffer=e.freeForCohortOffer),t}}),my=ay.update({id:`/setup`,path:`/setup`,getParentRoute:()=>Zv}),hy=oy.update({id:`/receipts`,path:`/receipts`,getParentRoute:()=>Zv}),gy=sy.update({id:`/queue`,path:`/queue`,getParentRoute:()=>Zv}),_y=cy.update({id:`/plays`,path:`/plays`,getParentRoute:()=>Zv}),vy=ly.update({id:`/measure`,path:`/measure`,getParentRoute:()=>Zv}),yy=uy.update({id:`/inbox`,path:`/inbox`,getParentRoute:()=>Zv}),by=dy.update({id:`/cadences`,path:`/cadences`,getParentRoute:()=>Zv}),xy={IndexRoute:fy.update({id:`/`,path:`/`,getParentRoute:()=>Zv}),CadencesRoute:by,InboxRoute:yy,MeasureRoute:vy,PlaysRoute:_y,QueueRoute:gy,ReceiptsRoute:hy,SetupRoute:my,RunPlayNameRoute:py.update({id:`/run/$playName`,path:`/run/$playName`,getParentRoute:()=>Zv})},Sy=Zv._addFileChildren(xy)._addFileTypes(),Cy=new ze({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!0}}}),wy=ia({routeTree:Sy,context:{queryClient:Cy},defaultPreload:`intent`}),Ty=document.getElementById(`root`);if(!Ty)throw Error(`missing #root element`);(0,Ta.createRoot)(Ty).render((0,N.jsx)(M.StrictMode,{children:(0,N.jsx)(He,{client:Cy,children:(0,N.jsx)(sa,{router:wy})})}));export{ba as a,ha as c,xi as d,rt as f,xa as i,ma as l,Ve as m,Ba as n,ya as o,nt as p,wa as r,_a as s,py as t,F as u};
|
|
60
|
-
//# sourceMappingURL=index-
|
|
59
|
+
`))r.startsWith(`event: `)?t=r.slice(7).trim():r.startsWith(`data: `)&&(n=r.slice(6));if(!t||!n)return null;try{return JSON.parse(n)}catch{return null}}var Fv=/<!--ACTION:(enable|disable|apply-config):([^:>]+?)(?::([\s\S]*?))?-->/,Iv=/<!--ACTION:[\s\S]*$/;function Lv(e){let t=e.match(Fv);if(!t)return null;let n=t[1],r=(t[2]??``).trim();if(!r)return null;let i=t[3]??``;if(n===`apply-config`)try{let e=JSON.parse(i);return!e||typeof e!=`object`||Array.isArray(e)?null:{kind:n,trigger:r,config:e}}catch{return null}return{kind:n,trigger:r}}function Rv(e){return e.replace(Fv,``).replace(Iv,``).trim()}var zv=[`Which triggers fit my ICP?`,`Propose github-topics topics + vendors`,`Pick an accelerator-batch cohort for my ICP`,`Audit my current trigger config`];function Bv(){let[e,t]=(0,M.useState)(!1);return(0,N.jsxs)(S_,{runtime:u_((0,M.useMemo)(()=>Nv(),[])),children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(e=>!e),"aria-label":e?`Close strategist`:`Open strategist`,className:`fixed bottom-5 right-5 z-40 flex items-center gap-2 rounded-full border border-ink-rule bg-ink-surface px-4 py-2.5 font-mono text-[11px] uppercase tracking-wider text-ink-cream shadow-lg transition-colors hover:border-ink-rule-2 hover:bg-ink-surface-2`,children:[(0,N.jsx)(Ca,{size:14}),`Strategist`]}),e&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-40 bg-ink-bg/60 backdrop-blur-sm`,onClick:()=>t(!1),"aria-hidden":`true`}),(0,N.jsxs)(`aside`,{className:`fixed right-0 top-0 z-50 flex h-full w-full flex-col border-l border-ink-rule bg-ink-bg-deep shadow-2xl transition-transform duration-200 sm:w-[440px] `+(e?`translate-x-0`:`translate-x-full`),"aria-hidden":!e,children:[(0,N.jsx)(Vv,{onClose:()=>t(!1)}),(0,N.jsx)(Hv,{})]})]})}function Vv({onClose:e}){return(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-ink-rule px-5 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(Ca,{size:14,className:`text-ink-cream-2`}),(0,N.jsx)(`div`,{className:`ln-eyebrow`,children:`Strategist`})]}),(0,N.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Close strategist`,className:`cursor-pointer rounded-full p-1 text-ink-faint transition-colors hover:bg-ink-surface hover:text-ink-cream`,children:(0,N.jsx)(wa,{size:14})})]})}function Hv(){return(0,N.jsxs)(wv,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsx)(Tv,{children:(0,N.jsx)(`div`,{className:`border-b border-ink-rule/60 px-5 py-4`,children:(0,N.jsx)(`p`,{className:`text-sm text-ink-cream-2`,children:`Tell me what to set up. I'll propose configs anchored in your ICP + product and ask before applying anything. Try a chip below or ask anything.`})})}),(0,N.jsx)(Av,{className:`flex-1 space-y-3 overflow-y-auto px-5 py-4`,children:(0,N.jsx)(Pg,{components:{UserMessage:Uv,AssistantMessage:Wv}})}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2 border-t border-ink-rule/60 px-5 py-2`,children:zv.map(e=>(0,N.jsx)(jv,{prompt:e,send:!0,className:`cursor-pointer rounded-full border border-ink-rule px-3 py-1 font-mono text-[10px] uppercase tracking-wider text-ink-muted transition-colors hover:border-ink-rule-2 hover:text-ink-cream-2`,children:e},e))}),(0,N.jsx)(`div`,{className:`border-t border-ink-rule px-5 py-3`,children:(0,N.jsxs)(k_,{className:`flex items-center gap-2`,children:[(0,N.jsx)(tv,{placeholder:`Ask the strategist...`,className:`flex-1 rounded-[var(--radius-sm)] border border-ink-rule bg-ink-bg px-3 py-2 font-mono text-[13px] text-ink-cream outline-none placeholder:text-ink-faint focus:border-ink-rule-2`}),(0,N.jsx)(O_,{asChild:!0,children:(0,N.jsx)(s,{size:`sm`,variant:`primary`,children:`Send`})})]})})]})}function Uv(){return(0,N.jsx)(xv,{className:`flex justify-end`,children:(0,N.jsx)(`div`,{className:`max-w-[80%] rounded-[var(--radius-sm)] border border-ink-rule bg-ink-surface px-3 py-2`,children:(0,N.jsx)(Cv,{components:{Text:({text:e})=>(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-ink-cream`,children:e})}})})})}function Wv(){return(0,N.jsx)(xv,{className:`flex justify-start`,children:(0,N.jsx)(`div`,{className:`max-w-[90%] rounded-[var(--radius-sm)] border border-ink-rule bg-ink-surface px-3 py-2`,children:(0,N.jsx)(Cv,{components:{Text:({text:e})=>(0,N.jsx)(Gv,{text:e})}})})})}function Gv({text:e}){let t=Lv(e);return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-ink-cream-2`,children:Rv(e)}),t&&(0,N.jsx)(Kv,{action:t})]})}function Kv({action:e}){let t=Ve(),[n,r]=(0,M.useState)(!1),[i,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(null),l=(0,M.useCallback)(async()=>{r(!0),c(null);try{e.kind===`enable`?(await a.setTriggerEnabled(e.trigger,!0),o(`enabled · ${e.trigger}`),Ba.success(`enabled · ${e.trigger}`)):e.kind===`disable`?(await a.setTriggerEnabled(e.trigger,!1),o(`disabled · ${e.trigger}`),Ba.success(`disabled · ${e.trigger}`)):e.kind===`apply-config`&&e.config&&(await a.setTriggerConfig(e.trigger,e.config),o(`config saved · ${e.trigger}`),Ba.success(`config saved · ${e.trigger}`)),t.invalidateQueries({queryKey:[`triggers`]}),t.invalidateQueries({queryKey:[`queue`]})}catch(e){c(e.message)}finally{r(!1)}},[e,t]);if(i)return(0,N.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-2 rounded-[var(--radius-sm)] border border-ink-rule bg-ink-bg-deep px-2.5 py-1.5 font-mono text-[11px] text-ink-receipt-2`,children:[`✓ `,i]});let u=e.kind===`enable`?`Enable ${e.trigger}`:e.kind===`disable`?`Disable ${e.trigger}`:`Apply config to ${e.trigger}`;return(0,N.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,N.jsx)(`button`,{onClick:l,disabled:n,className:`cursor-pointer rounded-[var(--radius-sm)] border border-ink-rule bg-ink-surface px-3 py-1.5 font-mono text-[11px] text-ink-cream transition-colors hover:border-ink-rule-2 disabled:cursor-not-allowed disabled:opacity-60`,children:n?`Applying…`:u}),s&&(0,N.jsxs)(`span`,{className:`font-mono text-[11px] text-ink-blocked-2`,children:[`err: `,s]})]})}var qv=800,Jv={h:`/`,q:`/queue`,c:`/cadences`,r:`/receipts`,m:`/measure`,p:`/plays`,s:`/setup`};function Yv(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function Xv(e){let t=xi(),n=(0,M.useRef)(e);n.current=e,(0,M.useEffect)(()=>{let e=!1,r=null,i=i=>{let a=n.current;if((i.metaKey||i.ctrlKey)&&i.key.toLowerCase()===`k`){i.preventDefault(),a.paletteOpen?a.closePalette():a.openPalette();return}if(i.key===`Escape`&&a.paletteOpen){a.closePalette();return}if(!Yv(i.target)&&!(i.metaKey||i.ctrlKey||i.altKey)){if(e){let n=Jv[i.key.toLowerCase()];n&&(i.preventDefault(),t({to:n})),e=!1,r&&clearTimeout(r);return}i.key.toLowerCase()===`g`&&(e=!0,r&&clearTimeout(r),r=setTimeout(()=>{e=!1},qv))}};return window.addEventListener(`keydown`,i),()=>{window.removeEventListener(`keydown`,i),r&&clearTimeout(r)}},[t])}var Zv=zi()({component:$v}),Qv=[{to:`/`,label:`Today`,icon:fa},{to:`/queue`,label:`Queue`,icon:_a,alert:`queue-pending`},{to:`/inbox`,label:`Replies`,icon:ya},{to:`/cadences`,label:`Cadences`,icon:va},{to:`/receipts`,label:`Receipts`,icon:xa},{to:`/measure`,label:`Measure`,icon:pa},{to:`/plays`,label:`Plays`,icon:ga},{to:`/setup`,label:`Setup`,icon:Sa,alert:`doctor-fail`}];function $v(){let[e,t]=(0,M.useState)(!1);Xv({paletteOpen:e,openPalette:()=>t(!0),closePalette:()=>t(!1)});let n=nt({queryKey:[`queue`,`pending`,`all`],queryFn:()=>a.queue({status:`pending`,limit:1}),refetchInterval:6e4}),r=nt({queryKey:[`doctor`],queryFn:a.doctor,refetchInterval:6e4}),o={"queue-pending":(n.data?.counts.pending??0)>0,"doctor-fail":(r.data?.checks??[]).some(e=>e.severity===`fail`)};return(0,N.jsxs)(`div`,{className:`grid h-full grid-cols-[224px_1fr] grid-rows-[auto_1fr_auto] bg-ink-bg text-ink-cream`,children:[(0,N.jsxs)(`aside`,{className:`row-span-3 flex flex-col border-r border-ink-rule bg-ink-bg/60 px-3 py-5 backdrop-blur-[2px]`,children:[(0,N.jsxs)(`div`,{className:`mb-7 px-2`,children:[(0,N.jsxs)(`div`,{className:`text-ink-cream`,style:{fontFamily:`var(--font-display)`,fontSize:19,letterSpacing:`-0.01em`,lineHeight:1.1},children:[`oneshot`,(0,N.jsx)(`span`,{className:`text-[color:var(--ink-spend-2)]`,children:`·`}),`gtm`]}),(0,N.jsx)(`div`,{className:`mt-0.5 text-[10.5px] uppercase tracking-[0.14em] text-ink-faint`,children:`Founder's ledger`})]}),(0,N.jsx)(`nav`,{className:`flex flex-col gap-0.5`,"aria-label":`primary`,children:Qv.map(({to:e,label:t,icon:n,alert:r})=>{let a=r?o[r]:!1;return(0,N.jsxs)(F,{to:e,activeOptions:{exact:e===`/`},className:i(`group relative flex items-center gap-2.5 rounded-[var(--radius-sm)] px-2.5 py-1.5`,`font-sans text-[13px] text-ink-cream-2`,`transition-colors duration-[var(--dur-stamp)]`,`hover:bg-ink-surface hover:text-ink-cream`),activeProps:{className:`bg-ink-surface text-ink-cream`,"data-active":`true`},children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:i(`pointer-events-none absolute bottom-1 left-0 top-1 w-[2px] rounded-full`,`bg-[color:var(--ink-signal)]`,`opacity-0 transition-opacity duration-[var(--dur-stamp)]`,`group-data-[active=true]:opacity-100`)}),(0,N.jsx)(n,{size:14,className:i(`text-ink-muted transition-colors`,`group-hover:text-ink-cream-2`,`group-data-[active=true]:text-[color:var(--ink-signal-2)]`)}),(0,N.jsx)(`span`,{className:`flex-1`,children:t}),a&&(0,N.jsx)(`span`,{"aria-label":ey(r),title:ey(r),className:i(`h-[6px] w-[6px] shrink-0 rounded-full`,r===`doctor-fail`?`bg-[color:var(--ink-blocked)]`:`bg-[color:var(--ink-spend)]`,`shadow-[0_0_0_2px_color-mix(in_oklch,currentColor_0%,var(--ink-bg)_100%)]`)})]},e)})}),(0,N.jsxs)(`div`,{className:`mt-auto border-t border-ink-rule pt-4 px-2`,children:[(0,N.jsx)(`div`,{className:`ln-eyebrow mb-2`,style:{fontSize:10},children:`Keys`}),(0,N.jsxs)(`div`,{className:`space-y-1 font-mono text-[11px] text-ink-faint`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`group flex w-full items-center justify-between rounded-[var(--radius-xs)] px-1 py-0.5 text-left transition-colors hover:bg-ink-surface/80`,"aria-label":`open command palette`,children:[(0,N.jsx)(`span`,{className:`group-hover:text-ink-cream-2`,children:`palette`}),(0,N.jsx)(`kbd`,{className:`rounded border border-ink-rule px-1 text-ink-cream-2`,children:`⌘K`})]}),(0,N.jsxs)(`div`,{className:`flex justify-between px-1`,children:[(0,N.jsx)(`span`,{children:`queue`}),(0,N.jsx)(`kbd`,{className:`rounded border border-ink-rule px-1 text-ink-cream-2`,children:`g q`})]}),(0,N.jsxs)(`div`,{className:`flex justify-between px-1`,children:[(0,N.jsx)(`span`,{children:`home`}),(0,N.jsx)(`kbd`,{className:`rounded border border-ink-rule px-1 text-ink-cream-2`,children:`g h`})]})]})]})]}),(0,N.jsxs)(`header`,{className:`flex items-center justify-between border-b border-ink-rule bg-ink-bg/70 px-6 py-2.5 backdrop-blur-[2px]`,children:[(0,N.jsxs)(`div`,{className:`text-[11.5px] text-ink-faint ln-mono`,children:[`single user · local-first · bound to `,(0,N.jsx)(`span`,{className:`text-ink-muted`,children:`127.0.0.1`})]}),(0,N.jsx)(gu,{})]}),(0,N.jsx)(`main`,{className:`overflow-y-auto px-6 py-6`,children:(0,N.jsx)($i,{})}),(0,N.jsxs)(`footer`,{className:`border-t border-ink-rule bg-ink-bg/70 px-6 py-2 text-[11px] text-ink-faint backdrop-blur-[2px]`,children:[`Built on OneShot · Read every prompt · Fork every play ·`,` `,(0,N.jsx)(`span`,{className:`text-ink-muted`,children:`MIT`})]}),(0,N.jsx)(fu,{open:e,onOpenChange:t}),(0,N.jsx)(Bv,{}),(0,N.jsx)(to,{position:`bottom-right`,theme:`dark`,richColors:!1,toastOptions:{className:[`!bg-[color:var(--ink-surface)]`,`!text-[color:var(--ink-cream)]`,`!border-[color:var(--ink-rule)]`,`!font-sans`,`!shadow-[var(--shadow-ink-bleed)]`].join(` `),style:{borderRadius:`var(--radius-md)`}}})]})}function ey(e){return e===`queue-pending`?`pending candidates waiting for review`:e===`doctor-fail`?`doctor has a failing check`:``}var ty=`modulepreload`,ny=function(e){return`/`+e},ry={},iy=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ny(t,n),t in ry)return;ry[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:ty,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ay=Hi(`/setup`)({component:Wi(()=>iy(()=>import(`./setup-CqCzlBdR.js`),__vite__mapDeps([0,1,2,3])),`component`)}),oy=Hi(`/receipts`)({component:Wi(()=>iy(()=>import(`./receipts-opTtY1t7.js`),__vite__mapDeps([4,1,5,6,7])),`component`)}),sy=Hi(`/queue`)({component:Wi(()=>iy(()=>import(`./queue-BHKT-qjx.js`),__vite__mapDeps([8,1,2,5,3,6,7,9,10,11,12,13])),`component`)}),cy=Hi(`/plays`)({component:Wi(()=>iy(()=>import(`./plays-BSlXDDDK.js`),__vite__mapDeps([14,1,3,7])),`component`)}),ly=Hi(`/measure`)({component:Wi(()=>iy(()=>import(`./measure-CV7Towgf.js`),__vite__mapDeps([15,1,5,7])),`component`)}),uy=Hi(`/inbox`)({component:Wi(()=>iy(()=>import(`./inbox-Dsg3_bXr.js`),__vite__mapDeps([16,1,2,5,7,10,11,12,17])),`component`)}),dy=Hi(`/cadences`)({component:Wi(()=>iy(()=>import(`./cadences-D9cvMlfq.js`),__vite__mapDeps([18,1,2,5,3,6,7,10,13])),`component`)}),fy=Hi(`/`)({component:Wi(()=>iy(()=>import(`./routes-BgDvPuJP.js`),__vite__mapDeps([19,1,2,5,7,9,10,11])),`component`)}),py=Hi(`/run/$playName`)({component:Wi(()=>iy(()=>import(`./run._playName-CQU-5e18.js`),__vite__mapDeps([20,1,2,3,17])),`component`),validateSearch:e=>{let t={};return e.fromQueue===`1`&&(t.fromQueue=`1`),typeof e.limit==`number`?t.limit=e.limit:typeof e.limit==`string`&&/^\d+$/.test(e.limit)&&(t.limit=Number.parseInt(e.limit,10)),(e.dryRun===`0`||e.dryRun===`1`)&&(t.dryRun=e.dryRun),typeof e.senderCohort==`string`&&(t.senderCohort=e.senderCohort),typeof e.freeForCohortOffer==`string`&&(t.freeForCohortOffer=e.freeForCohortOffer),t}}),my=ay.update({id:`/setup`,path:`/setup`,getParentRoute:()=>Zv}),hy=oy.update({id:`/receipts`,path:`/receipts`,getParentRoute:()=>Zv}),gy=sy.update({id:`/queue`,path:`/queue`,getParentRoute:()=>Zv}),_y=cy.update({id:`/plays`,path:`/plays`,getParentRoute:()=>Zv}),vy=ly.update({id:`/measure`,path:`/measure`,getParentRoute:()=>Zv}),yy=uy.update({id:`/inbox`,path:`/inbox`,getParentRoute:()=>Zv}),by=dy.update({id:`/cadences`,path:`/cadences`,getParentRoute:()=>Zv}),xy={IndexRoute:fy.update({id:`/`,path:`/`,getParentRoute:()=>Zv}),CadencesRoute:by,InboxRoute:yy,MeasureRoute:vy,PlaysRoute:_y,QueueRoute:gy,ReceiptsRoute:hy,SetupRoute:my,RunPlayNameRoute:py.update({id:`/run/$playName`,path:`/run/$playName`,getParentRoute:()=>Zv})},Sy=Zv._addFileChildren(xy)._addFileTypes(),Cy=new ze({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!0}}}),wy=ia({routeTree:Sy,context:{queryClient:Cy},defaultPreload:`intent`}),Ty=document.getElementById(`root`);if(!Ty)throw Error(`missing #root element`);(0,Ta.createRoot)(Ty).render((0,N.jsx)(M.StrictMode,{children:(0,N.jsx)(He,{client:Cy,children:(0,N.jsx)(sa,{router:wy})})}));export{ba as a,ha as c,xi as d,rt as f,xa as i,ma as l,Ve as m,Ba as n,ya as o,nt as p,wa as r,_a as s,py as t,F as u};
|
|
60
|
+
//# sourceMappingURL=index-BVno9lTD.js.map
|