1import{o as e}from"./rolldown-runtime-CoV_I8sK.js";import{t}from"./rwgpsNamespace-CFcYWu5p.js";import{a as n,i as r,n as i,o as a,r as o,t as s}from"./camelcase-keys-DrA0nbZZ.js";import{t as c}from"./react-CpBNgyEA.js";import{t as l}from"./jsx-runtime-CFmj9-ij.js";import{n as u,t as d}from"./isObjectLike-DsV7sDD6.js";import{a as f,t as p}from"./memoize-DLnnnNF9.js";import{a as m,t as h}from"./queryUtils-KRoOkLjf.js";import{n as g}from"./conf-WCky0Xnd.js";import{t as _}from"./defineProperty-DFkOFzet.js";var v=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(){}},y=typeof window>`u`||`Deno`in globalThis;function b(){}function x(e,t){return typeof e==`function`?e(t):e}function S(e){return typeof e==`number`&&e>=0&&e!==1/0}function ee(e,t){return Math.max(e+(t||0)-Date.now(),0)}function te(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==re(o,t.options))return!1}else if(!w(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 ne(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(C(t.options.mutationKey)!==C(a))return!1}else if(!w(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function re(e,t){return(t?.queryKeyHashFn||C)(e)}function C(e){return JSON.stringify(e,(e,t)=>oe(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function w(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?!Object.keys(t).some(n=>!w(e[n],t[n])):!1}function ie(e,t){if(e===t)return e;let n=ae(e)&&ae(t);if(n||oe(e)&&oe(t)){let r=n?e:Object.keys(e),i=r.length,a=n?t:Object.keys(t),o=a.length,s=n?[]:{},c=0;for(let i=0;i<o;i++){let o=n?i:a[i];(!n&&r.includes(o)||n)&&e[o]===void 0&&t[o]===void 0?(s[o]=void 0,c++):(s[o]=ie(e[o],t[o]),s[o]===e[o]&&e[o]!==void 0&&c++)}return i===o&&c===i?e:s}return t}function T(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 ae(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function oe(e){if(!se(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!se(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function se(e){return Object.prototype.toString.call(e)===`[object Object]`}function ce(e){return new Promise(t=>{setTimeout(t,e)})}function le(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ie(e,t)}function ue(e){return e}function de(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function fe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var pe=Symbol(),me=(e,t)=>
1!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===pe?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn,E,D,he,ge=new(E=new WeakMap,D=new WeakMap,he=new WeakMap,class extends v{constructor(){super(),a(this,E,void 0),a(this,D,void 0),a(this,he,void 0),r(he,this,e=>{if(!y&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}})}onSubscribe(){o(D,this)||this.setEventListener(o(he,this))}onUnsubscribe(){this.hasListeners()||(o(D,this)?.call(this),r(D,this,void 0))}setEventListener(e){r(he,this,e),o(D,this)?.call(this),r(D,this,e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()}))}setFocused(e){o(E,this)!==e&&(r(E,this,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof o(E,this)==`boolean`?o(E,this):globalThis.document?.visibilityState!==`hidden`}}),O,k,A,_e=new(O=new WeakMap,k=new WeakMap,A=new WeakMap,class extends v{constructor(){super(),a(this,O,!0),a(this,k,void 0),a(this,A,void 0),r(A,this,e=>{if(!y&&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(){o(k,this)||this.setEventListener(o(A,this))}onUnsubscribe(){this.hasListeners()||(o(k,this)?.call(this),r(k,this,void 0))}setEventListener(e){r(A,this,e),o(k,this)?.call(this),r(k,this,e(this.setOnline.bind(this)))}setOnline(e){o(O,this)!==e&&(r(O,this,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return o(O,this)}});function ve(e){return Math.min(1e3*2**e,3e4)}function ye(e){return(e??`online`)===`online`?_e.isOnline():!0}var be=class{constructor(e){this.revert=e?.revert,this.silent=e?.silent}};function xe(e){return e instanceof be}function Se(e){let t=!1,n=0,r=!1,i,a,o,s=new Promise((e,t)=>{a=e,o=t}),c=t=>{r||(m(new be(t)),e.abort?.())},l=()=>{t=!0},u=()=>{t=!1},d=()=>ge.isFocused()&&(e.networkMode===`always`||_e.isOnline())&&e.canRun(),f=()=>ye(e.networkMode)&&e.canRun(),p=t=>{r||(r=!0,e.onSuccess?.(t),i?.(),a(t))},m=t=>{r||(r=!0,e.onError?.(t),i?.(),o(t))},h=()=>new Promise(t=>{i=e=>{(r||d())&&t(e)},e.onPause?.()}).then(()=>{i=void 0,r||e.onContinue?.()}),g=()=>{if(r)return;let i,a=n===0?e.initialPromise:void 0;try{i=a??e.fn()}catch(e){i=Promise.reject(e)}Promise.resolve(i).then(p).catch(i=>{if(r)return;let a=e.retry??(y?0:3),o=e.retryDelay??ve,s=typeof o==`function`?o(n,i):o,c=a===!0||typeof a==`number`&&n<a||typeof a==`function`&&a(n,i);if(t||!c){m(i);return}n++,e.onFail?.(n,i),ce(s).then(()=>d()?void 0:h()).then(()=>{t?m(i):g()})})};return{promise:s,cancel:c,continue:()=>(i?.(),s),cancelRetry:l,continueRetry:u,canStart:f,start:()=>(f()?g():h().then(g),s)}}function Ce(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=e=>setTimeout(e,0),a=e=>{i=e},o=e=>{let n;t++;try{n=e()}finally{t--,t||l()}return n},s=r=>{t?e.push(r):i(()=>{n(r)})},c=e=>(...t)=>{s(()=>{e(...t)})},l=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:o,batchCalls:c,schedule:s,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:a}}var we=Ce(),j,Te=(j=new WeakMap,class{constructor(){a(this,j,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),S(this.gcTime)&&r(j,this,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(y?1/0:300*1e3))}clearGcTimeout(){o(j,this)&&(clearTimeout(o(j,this)),r(j,this,void 0))}}),M,N,P,F,Ee,I,L,De=(M=new WeakMap,N=new WeakMap,P=new WeakMap,F=new WeakMap,Ee=new WeakMap,I=new WeakMap,L=new WeakSet,class extends Te{constructor(e){super(),i(this,L),a(this,M,void 0),a(this,N,void 0),a(this,P,void 0),a(this,F,void 0),a(this,Ee,void 0),a(this,I,void 0),r(I,this,!1),r(Ee,this,e.defaultOptions),this.setOptions(e.options),this.observers=[],r(P,this,e.cache),this.queryKey=e.queryKey,this.queryHash=e.queryHash,r(M,this,e.state||ke(this.options)),this.state=o(M,this),this.scheduleGc()}get meta(){return this.options.meta}get promise(){return o(F,this)?.promise}setOptions(e){this.options={...o(Ee,this),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&o(P,this).remove(this)}setData(e,t){let r=le(this.state.data,e,this.options);return n(L,this,R).call(this,{data:r,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){n(L,this,R).call(this,{type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=o(F,this)?.promise;return o(F,this)?.cancel(e),t?t.then(b).catch(b):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(o(M,this))}isActive(){return this.observers.some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!ee(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),o(F,this)?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),o(F,this)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),o(P,this).notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(o(F,this)&&(o(I,this)?o(F,this).cancel({revert:!0}):o(F,this).cancelRetry()),this.scheduleGc()),o(P,this).notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||n(L,this,R).call(this,{type:`invalidate`})}fetch(e,t){if(this.state.fetchStatus!==`idle`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(o(F,this))return o(F,this).continueRetry(),o(F,this).promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let i=new AbortController,a=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(r(I,this,!0),i.signal)}
1)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:()=>{let e=me(this.options,t),n={queryKey:this.queryKey,meta:this.meta};return a(n),r(I,this,!1),this.options.persister?this.options.persister(e,n,this):e(n)}};a(s),this.options.behavior?.onFetch(s,this),r(N,this,this.state),(this.state.fetchStatus===`idle`||this.state.fetchMeta!==s.fetchOptions?.meta)&&n(L,this,R).call(this,{type:`fetch`,meta:s.fetchOptions?.meta});let c=e=>{xe(e)&&e.silent||n(L,this,R).call(this,{type:`error`,error:e}),xe(e)||(o(P,this).config.onError?.(e,this),o(P,this).config.onSettled?.(this.state.data,e,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return r(F,this,Se({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:i.abort.bind(i),onSuccess:e=>{if(e===void 0){c(Error(`${this.queryHash} data is undefined`));return}this.setData(e),o(P,this).config.onSuccess?.(e,this),o(P,this).config.onSettled?.(e,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:c,onFail:(e,t)=>{n(L,this,R).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{n(L,this,R).call(this,{type:`pause`})},onContinue:()=>{n(L,this,R).call(this,{type:`continue`})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),o(F,this).start()}});function R(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,...Oe(t.data,this.options),fetchMeta:e.meta??null};case`success`:return{...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:`success`,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};case`error`:let n=e.error;return xe(n)&&n.revert&&o(N,this)?{...o(N,this),fetchStatus:`idle`}:{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:`idle`,status:`error`};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),we.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),o(P,this).notify({query:this,type:`updated`,action:e})})}function Oe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ye(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ke(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 z,B,Ae,V,H,U,W,je,G,K,q,J,Y,X,Z,Me=(z=new WeakMap,B=new WeakMap,Ae=new WeakMap,V=new WeakMap,H=new WeakMap,U=new WeakMap,W=new WeakMap,je=new WeakMap,G=new WeakMap,K=new WeakMap,q=new WeakMap,J=new WeakMap,Y=new WeakMap,X=new WeakMap,Z=new WeakSet,class extends v{constructor(e,t){super(),i(this,Z),a(this,z,void 0),a(this,B,void 0),a(this,Ae,void 0),a(this,V,void 0),a(this,H,void 0),a(this,U,void 0),a(this,W,void 0),a(this,je,void 0),a(this,G,void 0),a(this,K,void 0),a(this,q,void 0),a(this,J,void 0),a(this,Y,void 0),a(this,X,new Set),this.options=t,r(z,this,e),r(W,this,null),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(o(B,this).addObserver(this),Ue(o(B,this),this.options)?n(Z,this,Ne).call(this):this.updateResult(),n(Z,this,Le).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return We(o(B,this),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return We(o(B,this),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,n(Z,this,Re).call(this),n(Z,this,ze).call(this),o(B,this).removeObserver(this)}setOptions(e,t){let r=this.options,i=o(B,this);if(this.options=o(z,this).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`)throw Error(`Expected enabled to be a boolean`);n(Z,this,Be).call(this),o(B,this).setOptions(this.options),r._defaulted&&!T(this.options,r)&&o(z,this).getQueryCache().notify({type:`observerOptionsUpdated`,query:o(B,this),observer:this});let a=this.hasListeners();a&&Ge(o(B,this),i,this.options,r)&&n(Z,this,Ne).call(this),this.updateResult(t),a&&(o(B,this)!==i||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&n(Z,this,Pe).call(this);let s=n(Z,this,Fe).call(this);a&&(o(B,this)!==i||this.options.enabled!==r.enabled||s!==o(Y,this))&&n(Z,this,Ie).call(this,s)}getOptimisticResult(e){let t=o(z,this).getQueryCache().build(o(z,this),e),n=this.createResult(t,e);return qe(this,n)&&(r(V,this,n),r(U,this,this.options),r(H,this,o(B,this).state)),n}getCurrentResult(){return o(V,this)}trackResult(e,t){let n={};return Object.keys(e).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})}),n}trackProp(e){o(X,this).add(e)}getCurrentQuery(){return o(B,this)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=o(z,this).defaultQueryOptions(e),n=o(z,this).getQueryCache().build(o(z,this),t);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,t))}fetch(e){return n(Z,this,Ne).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),o(V,this)))}createResult(e,t){let n=o(B,this),i=this.options,a=o(V,this),s=o(H,this),c=o(U,this),l=e===n?o(Ae,this):e.state,{state:u}=e,d={...u},f=!1,p;if(t._optimisticResults){let r=this.hasListeners(),a=!r&&Ue(e,t),o=r&&Ge(e,n,t,i);(a||o)&&(d={...d,...Oe(u.data,e.options)}),t._optimisticResults===`isRestoring`&&(d.fetchStatus=`idle`)}let{error:m,errorUpdatedAt:h,status:g}=d;if(t.select&&d.data!==void 0)if(a&&d.data===s?.data&&t.select===o(je,this))p=o(G,this);else try{r(je,this,t.select),p=t.select(d.data),p=le(a?.data,p,t),r(G,this,p),r(W,this,null)}catch(e){r(W,this,e)}else p=d.data;if(t.placeholderData!==void 0&&p===void 0&&g===`pending`){let e;if(a?.isPlaceholderData&&t.placeholderData===c?.placeholderData)e=a.data;else if(e=typeof t.placeholderData==`function`?t.placeholderData(o(K,this)?.state.data,o(K,this)):t.placeholderData,t.select&&e!==void 0)try{e=t.select(e),r(W,this,null)}catch(e){r(W,this,e)}e!==void 0&&(g=`success`,p=le(a?.data,e,t),f=!0)}o(W,this)&&(m=o(W,this),p=o(G,this),h=Date.now(),g=`error`);let _=d.fetchStatus===`fetching`,v=g===`pending`,y=g===`error`,b=v&&_,x=p!==void 0;return{status:g,fetchStatus:d.fetchStatus,isPending:v,isSuccess:g===`success`,isError:y,isInitialLoading:b,isLoading:b,data:p,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:h,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdate
1Count:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:d.fetchStatus===`paused`,isPlaceholderData:f,isRefetchError:y&&x,isStale:Ke(e,t),refetch:this.refetch}}updateResult(e){let t=o(V,this),i=this.createResult(o(B,this),this.options);if(r(H,this,o(B,this).state),r(U,this,this.options),o(H,this).data!==void 0&&r(K,this,o(B,this)),T(i,t))return;r(V,this,i);let a={};e?.listeners!==!1&&(()=>{if(!t)return!0;let{notifyOnChangeProps:e}=this.options,n=typeof e==`function`?e():e;if(n===`all`||!n&&!o(X,this).size)return!0;let r=new Set(n??o(X,this));return this.options.throwOnError&&r.add(`error`),Object.keys(o(V,this)).some(e=>{let n=e;return o(V,this)[n]!==t[n]&&r.has(n)})})()&&(a.listeners=!0),n(Z,this,Ve).call(this,{...a,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&n(Z,this,Le).call(this)}});function Ne(e){n(Z,this,Be).call(this);let t=o(B,this).fetch(this.options,e);return e?.throwOnError||(t=t.catch(b)),t}function Pe(){if(n(Z,this,Re).call(this),y||o(V,this).isStale||!S(this.options.staleTime))return;let e=ee(o(V,this).dataUpdatedAt,this.options.staleTime)+1;r(q,this,setTimeout(()=>{o(V,this).isStale||this.updateResult()},e))}function Fe(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(o(B,this)):this.options.refetchInterval)??!1}function Ie(e){n(Z,this,ze).call(this),r(Y,this,e),!(y||this.options.enabled===!1||!S(o(Y,this))||o(Y,this)===0)&&r(J,this,setInterval(()=>{(this.options.refetchIntervalInBackground||ge.isFocused())&&n(Z,this,Ne).call(this)},o(Y,this)))}function Le(){n(Z,this,Pe).call(this),n(Z,this,Ie).call(this,n(Z,this,Fe).call(this))}function Re(){o(q,this)&&(clearTimeout(o(q,this)),r(q,this,void 0))}function ze(){o(J,this)&&(clearInterval(o(J,this)),r(J,this,void 0))}function Be(){let e=o(z,this).getQueryCache().build(o(z,this),this.options);if(e===o(B,this))return;let t=o(B,this);r(B,this,e),r(Ae,this,e.state),this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}function Ve(e){we.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(o(V,this))}),o(z,this).getQueryCache().notify({query:o(B,this),type:`observerResultsUpdated`})})}function He(e,t){return t.enabled!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function Ue(e,t){return He(e,t)||e.state.data!==void 0&&We(e,t,t.refetchOnMount)}function We(e,t,n){if(t.enabled!==!1){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ke(e,t)}return!1}function Ge(e,t,n,r){return(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!==`error`)&&Ke(e,n)}function Ke(e,t){return t.enabled!==!1&&e.isStaleByTime(t.staleTime)}function qe(e,t){return!T(e.getCurrentResult(),t)}var Q=e(c(),1),Je=l(),Ye=Q.createContext(void 0),Xe=e=>{let t=Q.useContext(Ye);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Ze=({client:e,children:t})=>(Q.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Je.jsx)(Ye.Provider,{value:e,children:t})),Qe=Q.createContext(!1),$e=()=>Q.useContext(Qe);Qe.Provider;function et(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var tt=Q.createContext(et()),nt=()=>Q.useContext(tt);function rt(e,t){return typeof e==`function`?e(...t):!!e}function it(){}var at=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},ot=e=>{Q.useEffect(()=>{e.clearReset()},[e])},st=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&rt(n,[e.error,r]),ct=(e,t)=>t.state.data===void 0,lt=e=>{e.suspense&&typeof e.staleTime!=`number`&&(e.staleTime=1e3)},ut=(e,t)=>e.isLoading&&e.isFetching&&!t,dt=(e,t)=>e?.suspense&&t.isPending,ft=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function pt(e,t,n){let r=Xe(n),i=$e(),a=nt(),o=r.defaultQueryOptions(e);o._optimisticResults=i?`isRestoring`:`optimistic`,lt(o),at(o,a),ot(a);let[s]=Q.useState(()=>new t(r,o)),c=s.getOptimisticResult(o);if(Q.useSyncExternalStore(Q.useCallback(e=>{let t=i?()=>void 0:s.subscribe(we.batchCalls(e));return s.updateResult(),t},[s,i]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),Q.useEffect(()=>{s.setOptions(o,{listeners:!1})}
1,[o,s]),dt(o,c))throw ft(o,s,a);if(st({result:c,errorResetBoundary:a,throwOnError:o.throwOnError,query:r.getQueryCache().get(o.queryHash)}))throw c.error;return o.notifyOnChangeProps?c:s.trackResult(c)}function mt(e,t){return pt(e,Me,t)}function ht(e){return e}var gt=f(Object.getPrototypeOf,Object),_t=`[object Object]`,vt=Function.prototype,yt=Object.prototype,bt=vt.toString,xt=yt.hasOwnProperty,St=bt.call(Object);function Ct(e){if(!d(e)||u(e)!=_t)return!1;var t=gt(e);if(t===null)return!0;var n=xt.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&bt.call(n)==St}var wt=()=>typeof CompressionStream<`u`,Tt=async e=>{let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`));return new Response(t).blob()},Et=e=>({credentials:`same-origin`,headers:Object.assign({Accept:`application/json`,"X-Requested-With":`XMLHttpRequest`},e?{"Content-Type":`application/json`}:void 0)});async function Dt(e,t=!1,n={},{parseErrors:r=!0,compress:i=!1,opaque:a=!1}={}){return n={...Et(!!t),...n},a&&(n.headers=Object.assign({},n.headers,{"x-rwgps-ui-opaque":`true`})),t&&(n.body=JSON.stringify(t),n.headers=n.headers?Object.assign({},n.headers):{},n.method=n.method||`POST`,i&&wt()&&(n.body=await Tt(n.body),n.headers=Object.assign(n.headers,{"Content-Encoding":`gzip`}))),(await(e=>e.ok?e:r?e.json().then(e=>Promise.reject(e)):Promise.reject(e))(await window.fetch(e,n))).json()}var Ot=e=>e+`_PENDING`,kt=e=>e+`_FULFILLED`,At=e=>e+`_REJECTED`,jt={pending:`pending`,fulfilled:`fulfilled`,rejected:`rejected`},Mt=`currentUser/SET_PREFERENCE`,Nt=(e=Gn(),t)=>{switch(t.type){case Mt:case Ot(Mt):{let{key:n,value:r}=t.meta;return{...e,preferences:e.id?{...e.preferences,[n]:r}:void 0}}default:return e}},Pt={"x-rwgps-api-key":g,"x-rwgps-api-version":`3`,Accept:`application/json`},Ft=class extends Error{constructor(...e){super(...e),_(this,`response`,void 0),_(this,`status`,void 0)}},It=class extends Ft{constructor(...e){super(...e),_(this,`body`,void 0)}},Lt=e=>e instanceof Ft,Rt=e=>e instanceof Ft&&e.response.status===403,zt=e=>{if(!(typeof e!=`object`||!e))return e.body},Bt=e=>zt(e)?.errors?.[0]?.error_code??null,Vt=e=>zt(e)?.errors?.[0]?.error_info??null,Ht=(e,t)=>{let n=zt(e)?.errors?.[0]?.error_message;return typeof n==`string`&&n?n:e instanceof Error?e.message||t||`Something went wrong.`:typeof e==`string`?e:t??String(e)};async function Ut(e,t={}){let{opaque:n,camelizeResponse:r=!0,compress:i,...a}=t,o=!!i&&!!a.body&&wt(),s={...Pt,...Ct(a.body)?{"Content-Type":`application/json`}:{},...a.headers,...n?{"x-rwgps-ui-opaque":`true`}:{},...o?{"Content-Encoding":`gzip`}:{}},c={...a,...Ct(a.body)?{body:JSON.stringify(m(a.body,{deep:!0}))}:{},...a.body&&!a.method?{method:`POST`}:{},headers:s};o&&c.body&&(c.body=await Tt(c.body));let l=await fetch(e,c);if(!l.ok)if(l.headers.get(`Content-Type`)?.includes(`application/json`)){let t;try{let n=await l.json();t=new It(`request to ${e} failed with status code ${l.status} (${l.statusText})`),t.status=l.status,t.response=l,t.body=n}catch(t){throw Error(`Failed to parse JSON error response from ${e}`,{cause:t})}throw t}else{let t=new Ft(`request to ${e} failed with status code ${l.status} (${l.statusText})`);throw t.response=l,t.status=l.status,t}let u=await l.json();return r?Wt(u):u}var Wt=(e,t=[])=>s(e,{deep:!0,exclude:[/^_/],stopPaths:[`route.track_points`,`trip.track_points`,`routes_version.track_points`,`enabled_experiments`,...t]}),Gt=(e,t)=>t?`${e}?${h(m(t))}`:e,Kt=(e,t)=>{let n=typeof t==`string`?[t]:Array.isArray(t.path)?t.path:[t.path],r=typeof t==`object`?t.exact??!1:!1;return n.some(t=>{let n=t.split(`/`).filter(Boolean),i=e.split(`/`).filter(Boolean);return r&&n.length!==i.length||n.length>i.length?!1:n.every((e,t)=>e.startsWith(`:`)||e===i[t])})},qt=[`/routes/new`,`/routes/:id/edit`],Jt=({exact:e=!1}={})=>Kt(window.location.pathname,{path:qt,exact:e}),Yt=`free_premium_session`,Xt=2,Zt=30,Qt=86400,$t=24*3600,en=`planner_free_session_count`,tn=`planner_free_session_last_unlock_count`,nn=`planner_free_session_last_unlock_at`,rn=`free_premium_session`,an=`free_premium_session_counted`,on=0,sn=()=>t.config.currentUser?.id,cn=()=>Math.floor(Date.now()/1e3),ln=e=>{let t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):0},un=new Set,dn=e=>(un.add(e),()=>{un.delete(e)}),fn=()=>
1{un.forEach(e=>{try{e()}catch{}})},pn,mn=()=>{let e;try{e=window.sessionStorage.getItem(rn)}catch{return null}if(pn?.raw===e)return pn.latch;let t=null;try{if(e){let n=JSON.parse(e);t={...n,unlockedAt:ln(n.unlockedAt),saveCount:ln(n.saveCount)}}}catch{t=null}return pn={raw:e,latch:t},t},$=()=>{let e=mn(),t=sn();if(!(!e||t===void 0||e.userId!==t)&&!(e.unlockedAt!==0&&cn()-e.unlockedAt>86400))return e},hn=e=>{let t=zn();try{window.sessionStorage.setItem(rn,JSON.stringify(e))}catch{return!1}return!t&&zn()&&fn(),!0},gn=()=>{let e=t.config.currentUser;return!!e?.id&&e.account_level===on&&!t.config.surrogateLogin&&!(t.config.privileges||{}).advanced_planning},_n=e=>{let n=t.config.currentUser?.preferences;return ln(n?.[e])},vn=()=>_n(en),yn,bn=e=>{yn=e},xn=()=>yn??vn(),Sn=()=>_n(`planner_free_session_last_unlock_count`)||void 0,Cn=()=>Math.min(_n(nn),cn()),wn=()=>{let e=Cn();if(e===0)return!0;let t=cn()-e>=Zt*Qt,n=Sn();return(n===void 0||vn()-n>=Xt)&&t},Tn=()=>{try{let e=window.sessionStorage.getItem(an);return e!==null&&e===String(sn())}catch{return!0}},En=()=>{try{return window.sessionStorage.setItem(an,String(sn())),!0}catch{return!1}},Dn=()=>Jt({exact:!0})&&gn()&&!On()&&wn(),On=()=>gn()&&!!$()?.unlocked,kn=()=>{if(!Dn())return!1;let e=sn();return e===void 0?!1:hn({userId:e,unlocked:!0,announced:!1,upsellShown:!1,unlockedAt:cn(),saveCount:0,cadenceStamped:!1})},An=()=>!!$()?.announced,jn=()=>{let e=$();e&&hn({...e,announced:!0})},Mn=()=>!!$()?.upsellShown,Nn=()=>{let e=$();e&&hn({...e,upsellShown:!0})},Pn=()=>$()?.unlockedAt??0,Fn=()=>$()?.saveCount??0,In=()=>{let e=$();e&&hn({...e,saveCount:e.saveCount+1})},Ln=()=>!!$()?.cadenceStamped,Rn=()=>{let e=$();e&&hn({...e,cadenceStamped:!0})},zn=()=>Jt({exact:!0})&&On(),Bn=()=>t.config.currentUser??{},Vn=()=>t.config.baseCurrentUser,Hn=()=>t.config.surrogateLogin,Un=e=>!!(t.config.privileges||{})[e],Wn=e=>Un(e)||e===`advanced_planning`&&zn(),Gn=p(()=>{let{id:e,name:t,email:n,account_level:r,email_on_update:i,notifications_serialized:a,feature_flag_names:o,heatmaps:s,heatmap_optout:c,highlighted_photo_id:l,locality:u,administrative_area:d,country_code:f,preferences:p,profile_image_color:m,description:h,in_active_trial:g,trial_end_date:_,trial_show_banner:v,weeks_start_on:y,created_at:b,hr_max:x,metric_units:S,visibility:ee,lat:te,lng:ne,eligible_for_onetime_trial:re,has_installed_app:C}=Bn();return{id:e,name:t,email:n,locality:u,description:h,createdAt:b,heatmaps:s,heatmapOptout:c,highlightedPhotoId:l,adminArea:d,countryCode:f,featureFlags:o,notifications:a,accountLevel:r,preferences:e?p??{}:void 0,emailOnUpdate:i,profileImageColor:m||`#32309B`,inActiveTrial:g,trialEndDate:_,trialShowBanner:v,weeksStartOn:y,maxHR:x,metricUnits:S,visibility:ee,lat:te,lng:ne,eligibleForOnetimeTrial:re,hasInstalledApp:C}}),Kn=()=>{let e=Bn();if(!(`id`in e))return{id:void 0,heatmaps:[],preferences:void 0};let{id:t,name:n,visibility:r,first_name:i,last_name:a,email:o,lat:s,lng:c,preferences:l,has_set_location:u,feature_flag_names:d,location:f,locality:p,administrative_area:m,country_code:h,account_level:g,heatmaps:_,heatmap_optout:v,highlighted_photo_id:y,num_unread_messages:b,notifications_serialized:x,time_zone:S,weeks_start_on:ee,eligible_for_onetime_trial:te,eligible_for_premium_offer:ne,in_active_trial:re,trial_end_date:C,has_subscription:w,has_installed_app:ie,created_at:T,locale:ae,profile_image_color:oe}=e,se=x&&x.filter(e=>e.read_status===`unseen`).length||0;return{id:t,name:n,visibility:r,firstName:i,lastName:a,email:o,lat:s,lng:c,location:f,locality:p,adminArea:m,countryCode:h,heatmapOptout:v,hasSetLocation:u,featureFlags:d,preferences:l||{},accountLevel:g,heatmaps:_,highlightedPhotoId:y,notifications:x,timeZone:S,numUnreadMessages:b,numUnreadNotifications:se,weekStartsOn:ee,eligibleForOnetimeTrial:te,eligibleForPremiumOffer:ne,inActiveTrial:re,trialEndDate:C,hasSubscription:w,hasInstalledApp:ie,createdAt:T,locale:ae,profileImageColor:oe||`#32309B`}},qn=(e,t)=>({type:Mt,payload:Dt(`/set_preference.json`,{key:e,value:t}),meta:{key:e,value:t}});t.config.currentUser?.account_level===11&&(window.setPreference=qn);var Jn=()=>{let e=Kn().preferences?.dashboard_home||`dashboard`;return e===`friends`&&(e=`feed`),e},Yn={id:void 0,heatmaps:[],preferences:void 0},Xn=[`/users/current`],Zn=ht({queryKey:Xn,queryFn:async()=>{try{let{currentUser:e}=await Ut(`/users/current`);return s(Object.assign(e,{featureFlags:e.featureFlagNames,adminArea:e.administrativeArea}))}catch{return Yn}},gcTime:1/0,staleTime:1/0,initialData:()=>Kn()}),Qn=()=>{let{data:e}=mt(Zn);return e},$n=()=>{let e=Qn();return er(e)?e:void 0},er=e=>e?.id!==void 0&&`accountLevel`in e,tr=e=>er(e)&&e.accountLevel>=1,nr=e=>er(e)&&e.accountLevel>=2,rr=e=>e?.accountLevel===3,ir=t.config.currentUser?.account_level===11,ar=t.config.currentUser?.account_level===3,or=(()=>{let e=Kn();return er(e)?e:void 0})(),sr=or?or.accountLevel>0:!1,cr=or?or.accountLevel>1:!1,lr=()=>Wn(`advanced_planning`),ur=()=>(0,Q.useSyncExternalStore)(dn,lr,lr);export{Wt as $,v as $t,xn as A,Ze as At,En as B,fe as Bt,Zn as C,at as Ct,tn as D,rt as Dt,nn as E,it as Et,zn as F,we as Ft,An as G,ue as Gt,fn as H,x as Ht,Dn as I,Se as It,Tn as J,b as Jt,Ln as K,ne as Kt,jn as L,_e as Lt,Pn as M,Me as Mt,In as N,De as Nt,$t as O,nt as Ot,gn as P,Te as Pt,It as Q,pe as Qt,Rn as R,ge as Rt,ur as S,ut as St,Yt as T,ot as Tt,bn as U,C as Ut,kn as V,me as Vt,dn as W,re as Wt,Kt as X,ie as Xt,Jt as Y,w as Yt,Ft as Z,T as Zt,tr as _,pt as _t,cr as a,Rt as at,$n as b,ft as bt,ir as c,kt as ct,Kn as d,At as dt,Bt as et,Jn as f,Dt as ft,rr as g,mt as gt,er as h,ht,sr as i,Lt as it,Fn as j,Xe as jt,vn as k,$e as kt,ar as l,jt as lt,Hn as m,gt as mt,or as n,Ut as nt,Wn as o,Gt as ot,Bn as p,Ct as pt,Mn as q,te as qt,lr as r,Ht as rt,Un as s,Nt as st,Xn as t,Vt as tt,Vn as u,Ot as ut,nr as v,ct as vt,en as w,st as wt,Qn as x,dt as xt,qn as y,lt as yt,Nn as z,de as zt};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.