@tanstack/solid-query
Advanced tools
Comparing version 4.4.0 to 4.5.0
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("solid-js"),require("solid-js/store")):"function"==typeof define&&define.amd?define(["exports","solid-js","solid-js/store"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SolidQuery={},t.Solid,t.SolidStore)}(this,(function(t,e,s){"use strict";class i{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.push(t),this.onSubscribe(),()=>{this.listeners=this.listeners.filter((e=>e!==t)),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const r="undefined"==typeof window;function n(){}function o(t){return"number"==typeof t&&t>=0&&t!==1/0}function a(t,e){return t.filter((t=>-1===e.indexOf(t)))}function u(t,e){return Math.max(t+(e||0)-Date.now(),0)}function c(t,e,s){return P(t)?"function"==typeof e?{...s,queryKey:t,queryFn:e}:{...e,queryKey:t}:t}function h(t,e,s){return P(t)?"function"==typeof e?{...s,mutationKey:t,mutationFn:e}:{...e,mutationKey:t}:"function"==typeof t?{...e,mutationFn:t}:{...t}}function l(t,e,s){return P(t)?[{...e,queryKey:t},s]:[t||{},e]}function d(t,e,s){return P(t)?[{...e,mutationKey:t},s]:[t||{},e]}function f(t,e){const{type:s="all",exact:i,fetchStatus:r,predicate:n,queryKey:o,stale:a}=t;if(P(o))if(i){if(e.queryHash!==y(o,e.options))return!1}else if(!m(e.queryKey,o))return!1;if("all"!==s){const t=e.isActive();if("active"===s&&!t)return!1;if("inactive"===s&&t)return!1}return("boolean"!=typeof a||e.isStale()===a)&&((void 0===r||r===e.state.fetchStatus)&&!(n&&!n(e)))}function p(t,e){const{exact:s,fetching:i,predicate:r,mutationKey:n}=t;if(P(n)){if(!e.options.mutationKey)return!1;if(s){if(v(e.options.mutationKey)!==v(n))return!1}else if(!m(e.options.mutationKey,n))return!1}return("boolean"!=typeof i||"loading"===e.state.status===i)&&!(r&&!r(e))}function y(t,e){return((null==e?void 0:e.queryKeyHashFn)||v)(t)}function v(t){return JSON.stringify(t,((t,e)=>q(e)?Object.keys(e).sort().reduce(((t,s)=>(t[s]=e[s],t)),{}):e))}function m(t,e){return b(t,e)}function b(t,e){return t===e||typeof t==typeof e&&(!(!t||!e||"object"!=typeof t||"object"!=typeof e)&&!Object.keys(e).some((s=>!b(t[s],e[s]))))}function g(t,e){if(t===e)return t;const s=C(t)&&C(e);if(s||q(t)&&q(e)){const i=s?t.length:Object.keys(t).length,r=s?e:Object.keys(e),n=r.length,o=s?[]:{};let a=0;for(let i=0;i<n;i++){const n=s?i:r[i];o[n]=g(t[n],e[n]),o[n]===t[n]&&a++}return i===n&&a===i?t:o}return e}function O(t,e){if(t&&!e||e&&!t)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function C(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function q(t){if(!R(t))return!1;const e=t.constructor;if(void 0===e)return!0;const s=e.prototype;return!!R(s)&&!!s.hasOwnProperty("isPrototypeOf")}function R(t){return"[object Object]"===Object.prototype.toString.call(t)}function P(t){return Array.isArray(t)}function Q(t){return new Promise((e=>{setTimeout(e,t)}))}function S(t){Q(0).then(t)}function w(t,e,s){return null!=s.isDataEqual&&s.isDataEqual(t,e)?t:"function"==typeof s.structuralSharing?s.structuralSharing(t,e):!1!==s.structuralSharing?g(t,e):e}const M=new class extends i{constructor(){super(),this.setup=t=>{if(!r&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",e,!1),()=>{window.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){this.focused=t,t&&this.onFocus()}onFocus(){this.listeners.forEach((t=>{t()}))}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}};const x=new class extends i{constructor(){super(),this.setup=t=>{if(!r&&window.addEventListener){const e=()=>t();return window.addEventListener("online",e,!1),window.addEventListener("offline",e,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setOnline(t):this.onOnline()}))}setOnline(t){this.online=t,t&&this.onOnline()}onOnline(){this.listeners.forEach((t=>{t()}))}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}};function E(t){return Math.min(1e3*2**t,3e4)}function F(t){return"online"!==(null!=t?t:"online")||x.isOnline()}class A{constructor(t){this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}}function K(t){return t instanceof A}function D(t){let e,s,i,r=!1,n=0,o=!1;const a=new Promise(((t,e)=>{s=t,i=e})),u=()=>!M.isFocused()||"always"!==t.networkMode&&!x.isOnline(),c=i=>{o||(o=!0,null==t.onSuccess||t.onSuccess(i),null==e||e(),s(i))},h=s=>{o||(o=!0,null==t.onError||t.onError(s),null==e||e(),i(s))},l=()=>new Promise((s=>{e=t=>{if(o||!u())return s(t)},null==t.onPause||t.onPause()})).then((()=>{e=void 0,o||null==t.onContinue||t.onContinue()})),d=()=>{if(o)return;let e;try{e=t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(c).catch((e=>{var s,i;if(o)return;const a=null!=(s=t.retry)?s:3,c=null!=(i=t.retryDelay)?i:E,f="function"==typeof c?c(n,e):c,p=!0===a||"number"==typeof a&&n<a||"function"==typeof a&&a(n,e);!r&&p?(n++,null==t.onFail||t.onFail(n,e),Q(f).then((()=>{if(u())return l()})).then((()=>{r?h(e):d()}))):h(e)}))};return F(t.networkMode)?d():l().then(d),{promise:a,cancel:e=>{o||(h(new A(e)),null==t.abort||t.abort())},continue:()=>{null==e||e()},cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1}}}const U=console;const I=function(){let t=[],e=0,s=t=>{t()},i=t=>{t()};const r=i=>{e?t.push(i):S((()=>{s(i)}))},n=()=>{const e=t;t=[],e.length&&S((()=>{i((()=>{e.forEach((t=>{s(t)}))}))}))};return{batch:t=>{let s;e++;try{s=t()}finally{e--,e||n()}return s},batchCalls:t=>(...e)=>{r((()=>{t(...e)}))},schedule:r,setNotifyFunction:t=>{s=t},setBatchNotifyFunction:t=>{i=t}}}();class T{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),o(this.cacheTime)&&(this.gcTimeout=setTimeout((()=>{this.optionalRemove()}),this.cacheTime))}updateCacheTime(t){this.cacheTime=Math.max(this.cacheTime||0,null!=t?t:r?1/0:3e5)}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class L extends T{constructor(t){super(),this.abortSignalConsumed=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.logger=t.logger||U,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||function(t){const e="function"==typeof t.initialData?t.initialData():t.initialData,s=void 0!==t.initialData?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0,i=void 0!==e;return{data:e,dataUpdateCount:0,dataUpdatedAt:i?null!=s?s:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchMeta:null,isInvalidated:!1,status:i?"success":"loading",fetchStatus:"idle"}}(this.options),this.state=this.initialState,this.meta=t.meta}setOptions(t){this.options={...this.defaultOptions,...t},this.meta=null==t?void 0:t.meta,this.updateCacheTime(this.options.cacheTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.cache.remove(this)}setData(t,e){const s=w(this.state.data,t,this.options);return this.dispatch({data:s,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),s}setState(t,e){this.dispatch({type:"setState",state:t,setStateOptions:e})}cancel(t){var e;const s=this.promise;return null==(e=this.retryer)||e.cancel(t),s?s.then(n).catch(n):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some((t=>!1!==t.options.enabled))}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some((t=>t.getCurrentResult().isStale))}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!u(this.state.dataUpdatedAt,t)}onFocus(){var t;const e=this.observers.find((t=>t.shouldFetchOnWindowFocus()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}onOnline(){var t;const e=this.observers.find((t=>t.shouldFetchOnReconnect()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){-1!==this.observers.indexOf(t)&&(this.observers=this.observers.filter((e=>e!==t)),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(t,e){var s,i;if("idle"!==this.state.fetchStatus)if(this.state.dataUpdatedAt&&null!=e&&e.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var r;return null==(r=this.retryer)||r.continueRetry(),this.promise}if(t&&this.setOptions(t),!this.options.queryFn){const t=this.observers.find((t=>t.options.queryFn));t&&this.setOptions(t.options)}Array.isArray(this.options.queryKey);const n=function(){if("function"==typeof AbortController)return new AbortController}(),o={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},a=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>{if(n)return this.abortSignalConsumed=!0,n.signal}})};a(o);const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(o)):Promise.reject("Missing queryFn"),meta:this.meta};var c;(a(u),null==(s=this.options.behavior)||s.onFetch(u),this.revertState=this.state,"idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(i=u.fetchOptions)?void 0:i.meta))&&this.dispatch({type:"fetch",meta:null==(c=u.fetchOptions)?void 0:c.meta});const h=t=>{var e,s;(K(t)&&t.silent||this.dispatch({type:"error",error:t}),K(t))||(null==(e=(s=this.cache.config).onError)||e.call(s,t,this));this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=D({fn:u.fetchFn,abort:null==n?void 0:n.abort.bind(n),onSuccess:t=>{var e,s;void 0!==t?(this.setData(t),null==(e=(s=this.cache.config).onSuccess)||e.call(s,t,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1):h(new Error("Query data cannot be undefined"))},onError:h,onFail:()=>{this.dispatch({type:"failed"})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(t){this.state=(e=>{var s,i;switch(t.type){case"failed":return{...e,fetchFailureCount:e.fetchFailureCount+1};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,fetchFailureCount:0,fetchMeta:null!=(s=t.meta)?s:null,fetchStatus:F(this.options.networkMode)?"fetching":"paused",...!e.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(i=t.dataUpdatedAt)?i:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0}};case"error":const r=t.error;return K(r)&&r.revert&&this.revertState?{...this.revertState}:{...e,error:r,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}})(this.state),I.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate(t)})),this.cache.notify({query:this,type:"updated",action:t})}))}}class k extends i{constructor(t){super(),this.config=t||{},this.queries=[],this.queriesMap={}}build(t,e,s){var i;const r=e.queryKey,n=null!=(i=e.queryHash)?i:y(r,e);let o=this.get(n);return o||(o=new L({cache:this,logger:t.getLogger(),queryKey:r,queryHash:n,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(r),meta:e.meta}),this.add(o)),o}add(t){this.queriesMap[t.queryHash]||(this.queriesMap[t.queryHash]=t,this.queries.push(t),this.notify({type:"added",query:t}))}remove(t){const e=this.queriesMap[t.queryHash];e&&(t.destroy(),this.queries=this.queries.filter((e=>e!==t)),e===t&&delete this.queriesMap[t.queryHash],this.notify({type:"removed",query:t}))}clear(){I.batch((()=>{this.queries.forEach((t=>{this.remove(t)}))}))}get(t){return this.queriesMap[t]}getAll(){return this.queries}find(t,e){const[s]=l(t,e);return void 0===s.exact&&(s.exact=!0),this.queries.find((t=>f(s,t)))}findAll(t,e){const[s]=l(t,e);return Object.keys(s).length>0?this.queries.filter((t=>f(s,t))):this.queries}notify(t){I.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}onFocus(){I.batch((()=>{this.queries.forEach((t=>{t.onFocus()}))}))}onOnline(){I.batch((()=>{this.queries.forEach((t=>{t.onOnline()}))}))}}class j extends T{constructor(t){super(),this.options={...t.defaultOptions,...t.options},this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.logger=t.logger||U,this.observers=[],this.state=t.state||H(),this.meta=t.meta,this.updateCacheTime(this.options.cacheTime),this.scheduleGc()}setState(t){this.dispatch({type:"setState",state:t})}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.observers=this.observers.filter((e=>e!==t)),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.observers.length||("loading"===this.state.status?this.scheduleGc():this.mutationCache.remove(this))}continue(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()}async execute(){const t=()=>{var t;return this.retryer=D({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:()=>{this.dispatch({type:"failed"})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:null!=(t=this.options.retry)?t:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},e="loading"===this.state.status;try{var s,i,r,n,o,a;if(!e){var u,c,h,l;this.dispatch({type:"loading",variables:this.options.variables}),null==(u=(c=this.mutationCache.config).onMutate)||u.call(c,this.state.variables,this);const t=await(null==(h=(l=this.options).onMutate)?void 0:h.call(l,this.state.variables));t!==this.state.context&&this.dispatch({type:"loading",context:t,variables:this.state.variables})}const d=await t();return null==(s=(i=this.mutationCache.config).onSuccess)||s.call(i,d,this.state.variables,this.state.context,this),await(null==(r=(n=this.options).onSuccess)?void 0:r.call(n,d,this.state.variables,this.state.context)),await(null==(o=(a=this.options).onSettled)?void 0:o.call(a,d,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:d}),d}catch(t){try{var d,f,p,y,v,m;throw null==(d=(f=this.mutationCache.config).onError)||d.call(f,t,this.state.variables,this.state.context,this),await(null==(p=(y=this.options).onError)?void 0:p.call(y,t,this.state.variables,this.state.context)),await(null==(v=(m=this.options).onSettled)?void 0:v.call(m,void 0,t,this.state.variables,this.state.context)),t}finally{this.dispatch({type:"error",error:t})}}}dispatch(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:e.failureCount+1};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"loading":return{...e,context:t.context,data:void 0,error:null,isPaused:!F(this.options.networkMode),status:"loading",variables:t.variables};case"success":return{...e,data:t.data,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,isPaused:!1,status:"error"};case"setState":return{...e,...t.state}}})(this.state),I.batch((()=>{this.observers.forEach((e=>{e.onMutationUpdate(t)})),this.mutationCache.notify({mutation:this,type:"updated",action:t})}))}}function H(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}class N extends i{constructor(t){super(),this.config=t||{},this.mutations=[],this.mutationId=0}build(t,e,s){const i=new j({mutationCache:this,logger:t.getLogger(),mutationId:++this.mutationId,options:t.defaultMutationOptions(e),state:s,defaultOptions:e.mutationKey?t.getMutationDefaults(e.mutationKey):void 0,meta:e.meta});return this.add(i),i}add(t){this.mutations.push(t),this.notify({type:"added",mutation:t})}remove(t){this.mutations=this.mutations.filter((e=>e!==t)),this.notify({type:"removed",mutation:t})}clear(){I.batch((()=>{this.mutations.forEach((t=>{this.remove(t)}))}))}getAll(){return this.mutations}find(t){return void 0===t.exact&&(t.exact=!0),this.mutations.find((e=>p(t,e)))}findAll(t){return this.mutations.filter((e=>p(t,e)))}notify(t){I.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}resumePausedMutations(){const t=this.mutations.filter((t=>t.state.isPaused));return I.batch((()=>t.reduce(((t,e)=>t.then((()=>e.continue().catch(n)))),Promise.resolve())))}}function G(){return{onFetch:t=>{t.fetchFn=()=>{var e,s,i,r,n,o;const a=null==(e=t.fetchOptions)||null==(s=e.meta)?void 0:s.refetchPage,u=null==(i=t.fetchOptions)||null==(r=i.meta)?void 0:r.fetchMore,c=null==u?void 0:u.pageParam,h="forward"===(null==u?void 0:u.direction),l="backward"===(null==u?void 0:u.direction),d=(null==(n=t.state.data)?void 0:n.pages)||[],f=(null==(o=t.state.data)?void 0:o.pageParams)||[];let p=f,y=!1;const v=t.options.queryFn||(()=>Promise.reject("Missing queryFn")),m=(t,e,s,i)=>(p=i?[e,...p]:[...p,e],i?[s,...t]:[...t,s]),b=(e,s,i,r)=>{if(y)return Promise.reject("Cancelled");if(void 0===i&&!s&&e.length)return Promise.resolve(e);const n={queryKey:t.queryKey,pageParam:i,meta:t.meta};var o;o=n,Object.defineProperty(o,"signal",{enumerable:!0,get:()=>{var e,s;return null!=(e=t.signal)&&e.aborted?y=!0:null==(s=t.signal)||s.addEventListener("abort",(()=>{y=!0})),t.signal}});const a=v(n);return Promise.resolve(a).then((t=>m(e,i,t,r)))};let g;if(d.length)if(h){const e=void 0!==c,s=e?c:B(t.options,d);g=b(d,e,s)}else if(l){const e=void 0!==c,s=e?c:_(t.options,d);g=b(d,e,s,!0)}else{p=[];const e=void 0===t.options.getNextPageParam;g=!a||!d[0]||a(d[0],0,d)?b([],e,f[0]):Promise.resolve(m([],f[0],d[0]));for(let s=1;s<d.length;s++)g=g.then((i=>{if(!a||!d[s]||a(d[s],s,d)){const r=e?f[s]:B(t.options,i);return b(i,e,r)}return Promise.resolve(m(i,f[s],d[s]))}))}else g=b([]);return g.then((t=>({pages:t,pageParams:p})))}}}}function B(t,e){return null==t.getNextPageParam?void 0:t.getNextPageParam(e[e.length-1],e)}function _(t,e){return null==t.getPreviousPageParam?void 0:t.getPreviousPageParam(e[0],e)}function W(t,e){if(t.getNextPageParam&&Array.isArray(e)){const s=B(t,e);return null!=s&&!1!==s}}function z(t,e){if(t.getPreviousPageParam&&Array.isArray(e)){const s=_(t,e);return null!=s&&!1!==s}}class J extends i{constructor(t,e){super(),this.client=t,this.options=e,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.length&&(this.currentQuery.addObserver(this),V(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.listeners.length||this.destroy()}shouldFetchOnReconnect(){return X(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return X(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=[],this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(t,e){const s=this.options,i=this.currentQuery;if(this.options=this.client.defaultQueryOptions(t),O(s,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=s.queryKey),this.updateQuery();const r=this.hasListeners();r&&Y(this.currentQuery,i,this.options,s)&&this.executeFetch(),this.updateResult(e),!r||this.currentQuery===i&&this.options.enabled===s.enabled&&this.options.staleTime===s.staleTime||this.updateStaleTimeout();const n=this.computeRefetchInterval();!r||this.currentQuery===i&&this.options.enabled===s.enabled&&n===this.currentRefetchInterval||this.updateRefetchInterval(n)}getOptimisticResult(t){const e=this.client.getQueryCache().build(this.client,t);return this.createResult(e,t)}getCurrentResult(){return this.currentResult}trackResult(t){const e={};return Object.keys(t).forEach((s=>{Object.defineProperty(e,s,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(s),t[s])})})),e}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:t,...e}={}){return this.fetch({...e,meta:{refetchPage:t}})}fetchOptimistic(t){const e=this.client.defaultQueryOptions(t),s=this.client.getQueryCache().build(this.client,e);return s.isFetchingOptimistic=!0,s.fetch().then((()=>this.createResult(s,e)))}fetch(t){var e;return this.executeFetch({...t,cancelRefetch:null==(e=t.cancelRefetch)||e}).then((()=>(this.updateResult(),this.currentResult)))}executeFetch(t){this.updateQuery();let e=this.currentQuery.fetch(this.options,t);return null!=t&&t.throwOnError||(e=e.catch(n)),e}updateStaleTimeout(){if(this.clearStaleTimeout(),r||this.currentResult.isStale||!o(this.options.staleTime))return;const t=u(this.currentResult.dataUpdatedAt,this.options.staleTime)+1;this.staleTimeoutId=setTimeout((()=>{this.currentResult.isStale||this.updateResult()}),t)}computeRefetchInterval(){var t;return"function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.currentResult.data,this.currentQuery):null!=(t=this.options.refetchInterval)&&t}updateRefetchInterval(t){this.clearRefetchInterval(),this.currentRefetchInterval=t,!r&&!1!==this.options.enabled&&o(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval((()=>{(this.options.refetchIntervalInBackground||M.isFocused())&&this.executeFetch()}),this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(t,e){const s=this.currentQuery,i=this.options,r=this.currentResult,n=this.currentResultState,o=this.currentResultOptions,a=t!==s,u=a?t.state:this.currentQueryInitialState,c=a?this.currentResult:this.previousQueryResult,{state:h}=t;let l,{dataUpdatedAt:d,error:f,errorUpdatedAt:p,fetchStatus:y,status:v}=h,m=!1,b=!1;if(e._optimisticResults){const r=this.hasListeners(),n=!r&&V(t,e),o=r&&Y(t,s,e,i);(n||o)&&(y=F(t.options.networkMode)?"fetching":"paused",d||(v="loading")),"isRestoring"===e._optimisticResults&&(y="idle")}if(e.keepPreviousData&&!h.dataUpdateCount&&null!=c&&c.isSuccess&&"error"!==v)l=c.data,d=c.dataUpdatedAt,v=c.status,m=!0;else if(e.select&&void 0!==h.data)if(r&&h.data===(null==n?void 0:n.data)&&e.select===this.selectFn)l=this.selectResult;else try{this.selectFn=e.select,l=e.select(h.data),l=w(null==r?void 0:r.data,l,e),this.selectResult=l,this.selectError=null}catch(t){this.selectError=t}else l=h.data;if(void 0!==e.placeholderData&&void 0===l&&"loading"===v){let t;if(null!=r&&r.isPlaceholderData&&e.placeholderData===(null==o?void 0:o.placeholderData))t=r.data;else if(t="function"==typeof e.placeholderData?e.placeholderData():e.placeholderData,e.select&&void 0!==t)try{t=e.select(t),t=w(null==r?void 0:r.data,t,e),this.selectError=null}catch(t){this.selectError=t}void 0!==t&&(v="success",l=t,b=!0)}this.selectError&&(f=this.selectError,l=this.selectResult,p=Date.now(),v="error");const g="fetching"===y;return{status:v,fetchStatus:y,isLoading:"loading"===v,isSuccess:"success"===v,isError:"error"===v,data:l,dataUpdatedAt:d,error:f,errorUpdatedAt:p,failureCount:h.fetchFailureCount,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&"loading"!==v,isLoadingError:"error"===v&&0===h.dataUpdatedAt,isPaused:"paused"===y,isPlaceholderData:b,isPreviousData:m,isRefetchError:"error"===v&&0!==h.dataUpdatedAt,isStale:Z(t,e),refetch:this.refetch,remove:this.remove}}updateResult(t){const e=this.currentResult,s=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,O(s,e))return;this.currentResult=s;const i={cache:!0};!1!==(null==t?void 0:t.listeners)&&(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options;if("all"===t||!t&&!this.trackedProps.size)return!0;const s=new Set(null!=t?t:this.trackedProps);return this.options.useErrorBoundary&&s.add("error"),Object.keys(this.currentResult).some((t=>{const i=t;return this.currentResult[i]!==e[i]&&s.has(i)}))})()&&(i.listeners=!0),this.notify({...i,...t})}updateQuery(){const t=this.client.getQueryCache().build(this.client,this.options);if(t===this.currentQuery)return;const e=this.currentQuery;this.currentQuery=t,this.currentQueryInitialState=t.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(null==e||e.removeObserver(this),t.addObserver(this))}onQueryUpdate(t){const e={};"success"===t.type?e.onSuccess=!t.manual:"error"!==t.type||K(t.error)||(e.onError=!0),this.updateResult(e),this.hasListeners()&&this.updateTimers()}notify(t){I.batch((()=>{var e,s,i,r;if(t.onSuccess)null==(e=(s=this.options).onSuccess)||e.call(s,this.currentResult.data),null==(i=(r=this.options).onSettled)||i.call(r,this.currentResult.data,null);else if(t.onError){var n,o,a,u;null==(n=(o=this.options).onError)||n.call(o,this.currentResult.error),null==(a=(u=this.options).onSettled)||a.call(u,void 0,this.currentResult.error)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)})),t.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})}))}}function V(t,e){return function(t,e){return!(!1===e.enabled||t.state.dataUpdatedAt||"error"===t.state.status&&!1===e.retryOnMount)}(t,e)||t.state.dataUpdatedAt>0&&X(t,e,e.refetchOnMount)}function X(t,e,s){if(!1!==e.enabled){const i="function"==typeof s?s(t):s;return"always"===i||!1!==i&&Z(t,e)}return!1}function Y(t,e,s,i){return!1!==s.enabled&&(t!==e||!1===i.enabled)&&(!s.suspense||"error"!==t.state.status)&&Z(t,s)}function Z(t,e){return t.isStaleByTime(e.staleTime)}class $ extends i{constructor(t,e){super(),this.client=t,this.queries=[],this.result=[],this.observers=[],this.observersMap={},e&&this.setQueries(e)}onSubscribe(){1===this.listeners.length&&this.observers.forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))}))}onUnsubscribe(){this.listeners.length||this.destroy()}destroy(){this.listeners=[],this.observers.forEach((t=>{t.destroy()}))}setQueries(t,e){this.queries=t,I.batch((()=>{const t=this.observers,s=this.findMatchingObservers(this.queries);s.forEach((t=>t.observer.setOptions(t.defaultedQueryOptions,e)));const i=s.map((t=>t.observer)),r=Object.fromEntries(i.map((t=>[t.options.queryHash,t]))),n=i.map((t=>t.getCurrentResult())),o=i.some(((e,s)=>e!==t[s]));(t.length!==i.length||o)&&(this.observers=i,this.observersMap=r,this.result=n,this.hasListeners()&&(a(t,i).forEach((t=>{t.destroy()})),a(i,t).forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))})),this.notify()))}))}getCurrentResult(){return this.result}getOptimisticResult(t){return this.findMatchingObservers(t).map((t=>t.observer.getOptimisticResult(t.defaultedQueryOptions)))}findMatchingObservers(t){const e=this.observers,s=t.map((t=>this.client.defaultQueryOptions(t))),i=s.flatMap((t=>{const s=e.find((e=>e.options.queryHash===t.queryHash));return null!=s?[{defaultedQueryOptions:t,observer:s}]:[]})),r=i.map((t=>t.defaultedQueryOptions.queryHash)),n=s.filter((t=>!r.includes(t.queryHash))),o=e.filter((t=>!i.some((e=>e.observer===t)))),a=t=>{const e=this.client.defaultQueryOptions(t),s=this.observersMap[e.queryHash];return null!=s?s:new J(this.client,e)},u=n.map(((t,e)=>{if(t.keepPreviousData){const s=o[e];if(void 0!==s)return{defaultedQueryOptions:t,observer:s}}return{defaultedQueryOptions:t,observer:a(t)}}));return i.concat(u).sort(((t,e)=>s.indexOf(t.defaultedQueryOptions)-s.indexOf(e.defaultedQueryOptions)))}onUpdate(t,e){const s=this.observers.indexOf(t);-1!==s&&(this.result=function(t,e,s){const i=t.slice(0);return i[e]=s,i}(this.result,s,e),this.notify())}notify(){I.batch((()=>{this.listeners.forEach((t=>{t(this.result)}))}))}}class tt extends J{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t,e){super.setOptions({...t,behavior:G()},e)}getOptimisticResult(t){return t.behavior=G(),super.getOptimisticResult(t)}fetchNextPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"forward",pageParam:t}}})}fetchPreviousPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"backward",pageParam:t}}})}createResult(t,e){var s,i,r,n,o,a;const{state:u}=t;return{...super.createResult(t,e),fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:W(e,null==(s=u.data)?void 0:s.pages),hasPreviousPage:z(e,null==(i=u.data)?void 0:i.pages),isFetchingNextPage:"fetching"===u.fetchStatus&&"forward"===(null==(r=u.fetchMeta)||null==(n=r.fetchMore)?void 0:n.direction),isFetchingPreviousPage:"fetching"===u.fetchStatus&&"backward"===(null==(o=u.fetchMeta)||null==(a=o.fetchMore)?void 0:a.direction)}}}class et extends i{constructor(t,e){super(),this.client=t,this.setOptions(e),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.client.defaultMutationOptions(t),O(e,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this})}onUnsubscribe(){var t;this.listeners.length||(null==(t=this.currentMutation)||t.removeObserver(this))}onMutationUpdate(t){this.updateResult();const e={listeners:!0};"success"===t.type?e.onSuccess=!0:"error"===t.type&&(e.onError=!0),this.notify(e)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(t,e){return this.mutateOptions=e,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:void 0!==t?t:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const t=this.currentMutation?this.currentMutation.state:{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0},e={...t,isLoading:"loading"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset};this.currentResult=e}notify(t){I.batch((()=>{var e,s,i,r;if(this.mutateOptions)if(t.onSuccess)null==(e=(s=this.mutateOptions).onSuccess)||e.call(s,this.currentResult.data,this.currentResult.variables,this.currentResult.context),null==(i=(r=this.mutateOptions).onSettled)||i.call(r,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context);else if(t.onError){var n,o,a,u;null==(n=(o=this.mutateOptions).onError)||n.call(o,this.currentResult.error,this.currentResult.variables,this.currentResult.context),null==(a=(u=this.mutateOptions).onSettled)||a.call(u,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)}))}))}}function st(t){return t.state.isPaused}function it(t){return"success"===t.state.status}function rt(t){return"function"==typeof t}function nt(t,e,s){if(!rt(t)){const{queryKey:e,...s}=t;return e?{...s,queryKey:e()}:t}return"function"==typeof e?{...s,queryKey:t(),queryFn:e}:{...e,queryKey:t()}}function ot(t,e,s){return rt(t)?[{...e,queryKey:t()},s]:[{...t,queryKey:null==t||null==t.queryKey?void 0:t.queryKey()},e]}function at(t,e){return"function"==typeof t?t(...e):!!t}function ut(t){var e;(e=0,new Promise((t=>{setTimeout(t,e)}))).then(t)}const ct=e.createContext(void 0),ht=e.createContext(!1);function lt(t,e){return t||(e&&"undefined"!=typeof window?(window.SolidQueryClientContext||(window.SolidQueryClientContext=ct),window.SolidQueryClientContext):ct)}const dt=({context:t}={})=>{const s=e.useContext(lt(t,e.useContext(ht)));if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s};function ft(t,i){const r=dt({context:t.context}),n=r.defaultQueryOptions(t);n._optimisticResults="optimistic";const o=new i(r,n),[a,u]=s.createStore(o.getOptimisticResult(n)),[c,{refetch:h,mutate:l}]=e.createResource((()=>new Promise((t=>{a.isFetching&&a.isLoading||t(s.unwrap(a.data))}))));e.batch((()=>{l((()=>s.unwrap(a.data))),h()}));let d=[];const f=o.subscribe((t=>{d.push((()=>{e.batch((()=>{u(s.unwrap(t)),l((()=>s.unwrap(t.data))),h()}))})),queueMicrotask((()=>{const t=d.pop();t&&t(),d=[]}))}));e.onCleanup((()=>f())),e.onMount((()=>{o.setOptions(n,{listeners:!1})})),e.createComputed((()=>{const e=r.defaultQueryOptions(t);o.setOptions(e)})),e.createComputed(e.on((()=>a.status),(()=>{if(a.isError&&!a.isFetching&&at(o.options.useErrorBoundary,[a.error,o.getCurrentQuery()]))throw a.error})));return new Proxy(a,{get:(t,e)=>"data"===e&&t.isLoading&&t.isFetching?c():Reflect.get(t,e)})}function pt(){}t.CancelledError=A,t.InfiniteQueryObserver=tt,t.MutationCache=N,t.MutationObserver=et,t.QueriesObserver=$,t.QueryCache=k,t.QueryClient=class{constructor(t={}){this.queryCache=t.queryCache||new k,this.mutationCache=t.mutationCache||new N,this.logger=t.logger||U,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}mount(){this.unsubscribeFocus=M.subscribe((()=>{M.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())})),this.unsubscribeOnline=x.subscribe((()=>{x.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var t,e;null==(t=this.unsubscribeFocus)||t.call(this),null==(e=this.unsubscribeOnline)||e.call(this)}isFetching(t,e){const[s]=l(t,e);return s.fetchStatus="fetching",this.queryCache.findAll(s).length}isMutating(t){return this.mutationCache.findAll({...t,fetching:!0}).length}getQueryData(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state.data}getQueriesData(t){return this.getQueryCache().findAll(t).map((({queryKey:t,state:e})=>[t,e.data]))}setQueryData(t,e,s){const i=this.queryCache.find(t),r=function(t,e){return"function"==typeof t?t(e):t}(e,null==i?void 0:i.state.data);if(void 0===r)return;const n=c(t),o=this.defaultQueryOptions(n);return this.queryCache.build(this,o).setData(r,{...s,manual:!0})}setQueriesData(t,e,s){return I.batch((()=>this.getQueryCache().findAll(t).map((({queryKey:t})=>[t,this.setQueryData(t,e,s)]))))}getQueryState(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state}removeQueries(t,e){const[s]=l(t,e),i=this.queryCache;I.batch((()=>{i.findAll(s).forEach((t=>{i.remove(t)}))}))}resetQueries(t,e,s){const[i,r]=l(t,e,s),n=this.queryCache,o={type:"active",...i};return I.batch((()=>(n.findAll(i).forEach((t=>{t.reset()})),this.refetchQueries(o,r))))}cancelQueries(t,e,s){const[i,r={}]=l(t,e,s);void 0===r.revert&&(r.revert=!0);const o=I.batch((()=>this.queryCache.findAll(i).map((t=>t.cancel(r)))));return Promise.all(o).then(n).catch(n)}invalidateQueries(t,e,s){const[i,r]=l(t,e,s);return I.batch((()=>{var t,e;if(this.queryCache.findAll(i).forEach((t=>{t.invalidate()})),"none"===i.refetchType)return Promise.resolve();const s={...i,type:null!=(t=null!=(e=i.refetchType)?e:i.type)?t:"active"};return this.refetchQueries(s,r)}))}refetchQueries(t,e,s){const[i,r]=l(t,e,s),o=I.batch((()=>this.queryCache.findAll(i).filter((t=>!t.isDisabled())).map((t=>{var e;return t.fetch(void 0,{...r,cancelRefetch:null==(e=null==r?void 0:r.cancelRefetch)||e,meta:{refetchPage:i.refetchPage}})}))));let a=Promise.all(o).then(n);return null!=r&&r.throwOnError||(a=a.catch(n)),a}fetchQuery(t,e,s){const i=c(t,e,s),r=this.defaultQueryOptions(i);void 0===r.retry&&(r.retry=!1);const n=this.queryCache.build(this,r);return n.isStaleByTime(r.staleTime)?n.fetch(r):Promise.resolve(n.state.data)}prefetchQuery(t,e,s){return this.fetchQuery(t,e,s).then(n).catch(n)}fetchInfiniteQuery(t,e,s){const i=c(t,e,s);return i.behavior=G(),this.fetchQuery(i)}prefetchInfiniteQuery(t,e,s){return this.fetchInfiniteQuery(t,e,s).then(n).catch(n)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(t){this.defaultOptions=t}setQueryDefaults(t,e){const s=this.queryDefaults.find((e=>v(t)===v(e.queryKey)));s?s.defaultOptions=e:this.queryDefaults.push({queryKey:t,defaultOptions:e})}getQueryDefaults(t){if(!t)return;const e=this.queryDefaults.find((e=>m(t,e.queryKey)));return null==e?void 0:e.defaultOptions}setMutationDefaults(t,e){const s=this.mutationDefaults.find((e=>v(t)===v(e.mutationKey)));s?s.defaultOptions=e:this.mutationDefaults.push({mutationKey:t,defaultOptions:e})}getMutationDefaults(t){if(!t)return;const e=this.mutationDefaults.find((e=>m(t,e.mutationKey)));return null==e?void 0:e.defaultOptions}defaultQueryOptions(t){if(null!=t&&t._defaulted)return t;const e={...this.defaultOptions.queries,...this.getQueryDefaults(null==t?void 0:t.queryKey),...t,_defaulted:!0};return!e.queryHash&&e.queryKey&&(e.queryHash=y(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.useErrorBoundary&&(e.useErrorBoundary=!!e.suspense),e}defaultMutationOptions(t){return null!=t&&t._defaulted?t:{...this.defaultOptions.mutations,...this.getMutationDefaults(null==t?void 0:t.mutationKey),...t,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}},t.QueryClientProvider=t=>{const s=e.mergeProps({contextSharing:!1},t);e.onMount((()=>s.client.mount())),e.onCleanup((()=>s.client.unmount()));const i=lt(s.context,s.contextSharing);return e.createComponent(ht.Provider,{get value(){return!s.context&&s.contextSharing},get children(){return e.createComponent(i.Provider,{get value(){return s.client},get children(){return s.children}})}})},t.QueryObserver=J,t.createInfiniteQuery=function(t,i,r){const[n,o]=s.createStore(nt(t,i,r));return e.createComputed((()=>{const e=nt(t,i,r);o(e)})),ft(n,tt)},t.createMutation=function(t,i,r){const[n,o]=s.createStore(h(t,i,r)),a=dt({context:n.context}),u=new et(a,n),c=(t,e)=>{u.mutate(t,e).catch(pt)},[l,d]=s.createStore({...u.getCurrentResult(),mutate:c,mutateAsync:u.getCurrentResult().mutate});e.createComputed((()=>{const e=h(t,i,r);o(e),u.setOptions(e)})),e.createComputed(e.on((()=>l.status),(()=>{if(l.isError&&at(u.options.useErrorBoundary,[l.error]))throw l.error})));const f=u.subscribe((t=>{d({...t,mutate:c,mutateAsync:t.mutate})}));return e.onCleanup(f),l},t.createQueries=function(t){const i=dt({context:t.context}),r=t=>{const e={...t,queryKey:null==t.queryKey?void 0:t.queryKey()},s=i.defaultQueryOptions(e);return s._optimisticResults="optimistic",s},n=t.queries.map((t=>r(t))),o=new $(i,n),[a,u]=s.createStore(o.getOptimisticResult(n)),c=[],h=o.subscribe((t=>{c.push((()=>{u(s.unwrap(t))})),ut((()=>{const t=c.pop();t&&(t(),c.splice(0,c.length))}))}));return e.onCleanup(h),e.onMount((()=>{o.setQueries(n,{listeners:!1})})),e.createComputed((()=>{const e=t.queries.map((t=>r(t)));o.setQueries(e)})),a},t.createQuery=function(t,i,r){const[n,o]=s.createStore(nt(t,i,r));return e.createComputed((()=>{const e=nt(t,i,r);o(e)})),ft(n,J)},t.defaultContext=ct,t.dehydrate=function(t,e={}){const s=[],i=[];if(!1!==e.dehydrateMutations){const i=e.shouldDehydrateMutation||st;t.getMutationCache().getAll().forEach((t=>{i(t)&&s.push(function(t){return{mutationKey:t.options.mutationKey,state:t.state}}(t))}))}if(!1!==e.dehydrateQueries){const s=e.shouldDehydrateQuery||it;t.getQueryCache().getAll().forEach((t=>{s(t)&&i.push(function(t){return{state:t.state,queryKey:t.queryKey,queryHash:t.queryHash}}(t))}))}return{mutations:s,queries:i}},t.focusManager=M,t.hashQueryKey=v,t.hydrate=function(t,e,s){if("object"!=typeof e||null===e)return;const i=t.getMutationCache(),r=t.getQueryCache(),n=e.mutations||[],o=e.queries||[];n.forEach((e=>{var r;i.build(t,{...null==s||null==(r=s.defaultOptions)?void 0:r.mutations,mutationKey:e.mutationKey},e.state)})),o.forEach((e=>{var i;const n=r.get(e.queryHash);n?n.state.dataUpdatedAt<e.state.dataUpdatedAt&&n.setState(e.state):r.build(t,{...null==s||null==(i=s.defaultOptions)?void 0:i.queries,queryKey:e.queryKey,queryHash:e.queryHash},e.state)}))},t.isCancelledError=K,t.isError=function(t){return t instanceof Error},t.isServer=r,t.notifyManager=I,t.onlineManager=x,t.parseFilterArgs=l,t.parseMutationArgs=h,t.parseMutationFilterArgs=d,t.parseQueryArgs=c,t.useIsFetching=function(t,s,i){const[r,n={}]=ot(t,s,i),[o,a]=e.createSignal(r),[u,c]=e.createSignal(n),h=e.createMemo((()=>dt({context:u().context}))),l=e.createMemo((()=>h().getQueryCache())),[d,f]=e.createSignal(h().isFetching(o));e.createComputed((()=>{const[e,r={}]=ot(t,s,i);a(e),c(r)}));const p=l().subscribe((()=>{f(h().isFetching(o()))}));return e.onCleanup((()=>{p()})),d},t.useIsMutating=function(t,s,i){const[r,n={}]=d(t,s,i),o=dt({context:n.context}),a=o.getMutationCache(),[u,c]=e.createSignal(o.isMutating(r)),h=a.subscribe((t=>{c(o.isMutating(r))}));return e.onCleanup((()=>{h()})),u},t.useQueryClient=dt,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("solid-js"),require("solid-js/store")):"function"==typeof define&&define.amd?define(["exports","solid-js","solid-js/store"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SolidQuery={},t.Solid,t.SolidStore)}(this,(function(t,e,s){"use strict";class i{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.push(t),this.onSubscribe(),()=>{this.listeners=this.listeners.filter((e=>e!==t)),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const r="undefined"==typeof window;function n(){}function o(t){return"number"==typeof t&&t>=0&&t!==1/0}function a(t,e){return t.filter((t=>-1===e.indexOf(t)))}function u(t,e){return Math.max(t+(e||0)-Date.now(),0)}function c(t,e,s){return P(t)?"function"==typeof e?{...s,queryKey:t,queryFn:e}:{...e,queryKey:t}:t}function h(t,e,s){return P(t)?"function"==typeof e?{...s,mutationKey:t,mutationFn:e}:{...e,mutationKey:t}:"function"==typeof t?{...e,mutationFn:t}:{...t}}function l(t,e,s){return P(t)?[{...e,queryKey:t},s]:[t||{},e]}function d(t,e,s){return P(t)?[{...e,mutationKey:t},s]:[t||{},e]}function f(t,e){const{type:s="all",exact:i,fetchStatus:r,predicate:n,queryKey:o,stale:a}=t;if(P(o))if(i){if(e.queryHash!==y(o,e.options))return!1}else if(!m(e.queryKey,o))return!1;if("all"!==s){const t=e.isActive();if("active"===s&&!t)return!1;if("inactive"===s&&t)return!1}return("boolean"!=typeof a||e.isStale()===a)&&((void 0===r||r===e.state.fetchStatus)&&!(n&&!n(e)))}function p(t,e){const{exact:s,fetching:i,predicate:r,mutationKey:n}=t;if(P(n)){if(!e.options.mutationKey)return!1;if(s){if(v(e.options.mutationKey)!==v(n))return!1}else if(!m(e.options.mutationKey,n))return!1}return("boolean"!=typeof i||"loading"===e.state.status===i)&&!(r&&!r(e))}function y(t,e){return((null==e?void 0:e.queryKeyHashFn)||v)(t)}function v(t){return JSON.stringify(t,((t,e)=>q(e)?Object.keys(e).sort().reduce(((t,s)=>(t[s]=e[s],t)),{}):e))}function m(t,e){return b(t,e)}function b(t,e){return t===e||typeof t==typeof e&&(!(!t||!e||"object"!=typeof t||"object"!=typeof e)&&!Object.keys(e).some((s=>!b(t[s],e[s]))))}function g(t,e){if(t===e)return t;const s=C(t)&&C(e);if(s||q(t)&&q(e)){const i=s?t.length:Object.keys(t).length,r=s?e:Object.keys(e),n=r.length,o=s?[]:{};let a=0;for(let i=0;i<n;i++){const n=s?i:r[i];o[n]=g(t[n],e[n]),o[n]===t[n]&&a++}return i===n&&a===i?t:o}return e}function O(t,e){if(t&&!e||e&&!t)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function C(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function q(t){if(!R(t))return!1;const e=t.constructor;if(void 0===e)return!0;const s=e.prototype;return!!R(s)&&!!s.hasOwnProperty("isPrototypeOf")}function R(t){return"[object Object]"===Object.prototype.toString.call(t)}function P(t){return Array.isArray(t)}function Q(t){return new Promise((e=>{setTimeout(e,t)}))}function S(t){Q(0).then(t)}function w(t,e,s){return null!=s.isDataEqual&&s.isDataEqual(t,e)?t:"function"==typeof s.structuralSharing?s.structuralSharing(t,e):!1!==s.structuralSharing?g(t,e):e}const M=new class extends i{constructor(){super(),this.setup=t=>{if(!r&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",e,!1),()=>{window.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){this.focused=t,t&&this.onFocus()}onFocus(){this.listeners.forEach((t=>{t()}))}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}};const x=new class extends i{constructor(){super(),this.setup=t=>{if(!r&&window.addEventListener){const e=()=>t();return window.addEventListener("online",e,!1),window.addEventListener("offline",e,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setOnline(t):this.onOnline()}))}setOnline(t){this.online=t,t&&this.onOnline()}onOnline(){this.listeners.forEach((t=>{t()}))}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}};function E(t){return Math.min(1e3*2**t,3e4)}function F(t){return"online"!==(null!=t?t:"online")||x.isOnline()}class A{constructor(t){this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}}function K(t){return t instanceof A}function D(t){let e,s,i,r=!1,n=0,o=!1;const a=new Promise(((t,e)=>{s=t,i=e})),u=()=>!M.isFocused()||"always"!==t.networkMode&&!x.isOnline(),c=i=>{o||(o=!0,null==t.onSuccess||t.onSuccess(i),null==e||e(),s(i))},h=s=>{o||(o=!0,null==t.onError||t.onError(s),null==e||e(),i(s))},l=()=>new Promise((s=>{e=t=>{if(o||!u())return s(t)},null==t.onPause||t.onPause()})).then((()=>{e=void 0,o||null==t.onContinue||t.onContinue()})),d=()=>{if(o)return;let e;try{e=t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(c).catch((e=>{var s,i;if(o)return;const a=null!=(s=t.retry)?s:3,c=null!=(i=t.retryDelay)?i:E,f="function"==typeof c?c(n,e):c,p=!0===a||"number"==typeof a&&n<a||"function"==typeof a&&a(n,e);!r&&p?(n++,null==t.onFail||t.onFail(n,e),Q(f).then((()=>{if(u())return l()})).then((()=>{r?h(e):d()}))):h(e)}))};return F(t.networkMode)?d():l().then(d),{promise:a,cancel:e=>{o||(h(new A(e)),null==t.abort||t.abort())},continue:()=>{null==e||e()},cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1}}}const U=console;const I=function(){let t=[],e=0,s=t=>{t()},i=t=>{t()};const r=i=>{e?t.push(i):S((()=>{s(i)}))},n=()=>{const e=t;t=[],e.length&&S((()=>{i((()=>{e.forEach((t=>{s(t)}))}))}))};return{batch:t=>{let s;e++;try{s=t()}finally{e--,e||n()}return s},batchCalls:t=>(...e)=>{r((()=>{t(...e)}))},schedule:r,setNotifyFunction:t=>{s=t},setBatchNotifyFunction:t=>{i=t}}}();class T{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),o(this.cacheTime)&&(this.gcTimeout=setTimeout((()=>{this.optionalRemove()}),this.cacheTime))}updateCacheTime(t){this.cacheTime=Math.max(this.cacheTime||0,null!=t?t:r?1/0:3e5)}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class L extends T{constructor(t){super(),this.abortSignalConsumed=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.logger=t.logger||U,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||function(t){const e="function"==typeof t.initialData?t.initialData():t.initialData,s=void 0!==t.initialData?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0,i=void 0!==e;return{data:e,dataUpdateCount:0,dataUpdatedAt:i?null!=s?s:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchMeta:null,isInvalidated:!1,status:i?"success":"loading",fetchStatus:"idle"}}(this.options),this.state=this.initialState,this.meta=t.meta}setOptions(t){this.options={...this.defaultOptions,...t},this.meta=null==t?void 0:t.meta,this.updateCacheTime(this.options.cacheTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.cache.remove(this)}setData(t,e){const s=w(this.state.data,t,this.options);return this.dispatch({data:s,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),s}setState(t,e){this.dispatch({type:"setState",state:t,setStateOptions:e})}cancel(t){var e;const s=this.promise;return null==(e=this.retryer)||e.cancel(t),s?s.then(n).catch(n):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some((t=>!1!==t.options.enabled))}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some((t=>t.getCurrentResult().isStale))}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!u(this.state.dataUpdatedAt,t)}onFocus(){var t;const e=this.observers.find((t=>t.shouldFetchOnWindowFocus()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}onOnline(){var t;const e=this.observers.find((t=>t.shouldFetchOnReconnect()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){-1!==this.observers.indexOf(t)&&(this.observers=this.observers.filter((e=>e!==t)),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(t,e){var s,i;if("idle"!==this.state.fetchStatus)if(this.state.dataUpdatedAt&&null!=e&&e.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var r;return null==(r=this.retryer)||r.continueRetry(),this.promise}if(t&&this.setOptions(t),!this.options.queryFn){const t=this.observers.find((t=>t.options.queryFn));t&&this.setOptions(t.options)}Array.isArray(this.options.queryKey);const n=function(){if("function"==typeof AbortController)return new AbortController}(),o={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},a=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>{if(n)return this.abortSignalConsumed=!0,n.signal}})};a(o);const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(o)):Promise.reject("Missing queryFn"),meta:this.meta};var c;(a(u),null==(s=this.options.behavior)||s.onFetch(u),this.revertState=this.state,"idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(i=u.fetchOptions)?void 0:i.meta))&&this.dispatch({type:"fetch",meta:null==(c=u.fetchOptions)?void 0:c.meta});const h=t=>{var e,s;(K(t)&&t.silent||this.dispatch({type:"error",error:t}),K(t))||(null==(e=(s=this.cache.config).onError)||e.call(s,t,this));this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=D({fn:u.fetchFn,abort:null==n?void 0:n.abort.bind(n),onSuccess:t=>{var e,s;void 0!==t?(this.setData(t),null==(e=(s=this.cache.config).onSuccess)||e.call(s,t,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1):h(new Error("Query data cannot be undefined - affected query key: "+this.queryHash))},onError:h,onFail:()=>{this.dispatch({type:"failed"})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(t){this.state=(e=>{var s,i;switch(t.type){case"failed":return{...e,fetchFailureCount:e.fetchFailureCount+1};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,fetchFailureCount:0,fetchMeta:null!=(s=t.meta)?s:null,fetchStatus:F(this.options.networkMode)?"fetching":"paused",...!e.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(i=t.dataUpdatedAt)?i:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0}};case"error":const r=t.error;return K(r)&&r.revert&&this.revertState?{...this.revertState}:{...e,error:r,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}})(this.state),I.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate(t)})),this.cache.notify({query:this,type:"updated",action:t})}))}}class k extends i{constructor(t){super(),this.config=t||{},this.queries=[],this.queriesMap={}}build(t,e,s){var i;const r=e.queryKey,n=null!=(i=e.queryHash)?i:y(r,e);let o=this.get(n);return o||(o=new L({cache:this,logger:t.getLogger(),queryKey:r,queryHash:n,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(r),meta:e.meta}),this.add(o)),o}add(t){this.queriesMap[t.queryHash]||(this.queriesMap[t.queryHash]=t,this.queries.push(t),this.notify({type:"added",query:t}))}remove(t){const e=this.queriesMap[t.queryHash];e&&(t.destroy(),this.queries=this.queries.filter((e=>e!==t)),e===t&&delete this.queriesMap[t.queryHash],this.notify({type:"removed",query:t}))}clear(){I.batch((()=>{this.queries.forEach((t=>{this.remove(t)}))}))}get(t){return this.queriesMap[t]}getAll(){return this.queries}find(t,e){const[s]=l(t,e);return void 0===s.exact&&(s.exact=!0),this.queries.find((t=>f(s,t)))}findAll(t,e){const[s]=l(t,e);return Object.keys(s).length>0?this.queries.filter((t=>f(s,t))):this.queries}notify(t){I.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}onFocus(){I.batch((()=>{this.queries.forEach((t=>{t.onFocus()}))}))}onOnline(){I.batch((()=>{this.queries.forEach((t=>{t.onOnline()}))}))}}class j extends T{constructor(t){super(),this.options={...t.defaultOptions,...t.options},this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.logger=t.logger||U,this.observers=[],this.state=t.state||H(),this.meta=t.meta,this.updateCacheTime(this.options.cacheTime),this.scheduleGc()}setState(t){this.dispatch({type:"setState",state:t})}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.observers=this.observers.filter((e=>e!==t)),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.observers.length||("loading"===this.state.status?this.scheduleGc():this.mutationCache.remove(this))}continue(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()}async execute(){const t=()=>{var t;return this.retryer=D({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:()=>{this.dispatch({type:"failed"})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:null!=(t=this.options.retry)?t:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},e="loading"===this.state.status;try{var s,i,r,n,o,a;if(!e){var u,c,h,l;this.dispatch({type:"loading",variables:this.options.variables}),null==(u=(c=this.mutationCache.config).onMutate)||u.call(c,this.state.variables,this);const t=await(null==(h=(l=this.options).onMutate)?void 0:h.call(l,this.state.variables));t!==this.state.context&&this.dispatch({type:"loading",context:t,variables:this.state.variables})}const d=await t();return null==(s=(i=this.mutationCache.config).onSuccess)||s.call(i,d,this.state.variables,this.state.context,this),await(null==(r=(n=this.options).onSuccess)?void 0:r.call(n,d,this.state.variables,this.state.context)),await(null==(o=(a=this.options).onSettled)?void 0:o.call(a,d,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:d}),d}catch(t){try{var d,f,p,y,v,m;throw null==(d=(f=this.mutationCache.config).onError)||d.call(f,t,this.state.variables,this.state.context,this),await(null==(p=(y=this.options).onError)?void 0:p.call(y,t,this.state.variables,this.state.context)),await(null==(v=(m=this.options).onSettled)?void 0:v.call(m,void 0,t,this.state.variables,this.state.context)),t}finally{this.dispatch({type:"error",error:t})}}}dispatch(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:e.failureCount+1};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"loading":return{...e,context:t.context,data:void 0,error:null,isPaused:!F(this.options.networkMode),status:"loading",variables:t.variables};case"success":return{...e,data:t.data,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,isPaused:!1,status:"error"};case"setState":return{...e,...t.state}}})(this.state),I.batch((()=>{this.observers.forEach((e=>{e.onMutationUpdate(t)})),this.mutationCache.notify({mutation:this,type:"updated",action:t})}))}}function H(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}class N extends i{constructor(t){super(),this.config=t||{},this.mutations=[],this.mutationId=0}build(t,e,s){const i=new j({mutationCache:this,logger:t.getLogger(),mutationId:++this.mutationId,options:t.defaultMutationOptions(e),state:s,defaultOptions:e.mutationKey?t.getMutationDefaults(e.mutationKey):void 0,meta:e.meta});return this.add(i),i}add(t){this.mutations.push(t),this.notify({type:"added",mutation:t})}remove(t){this.mutations=this.mutations.filter((e=>e!==t)),this.notify({type:"removed",mutation:t})}clear(){I.batch((()=>{this.mutations.forEach((t=>{this.remove(t)}))}))}getAll(){return this.mutations}find(t){return void 0===t.exact&&(t.exact=!0),this.mutations.find((e=>p(t,e)))}findAll(t){return this.mutations.filter((e=>p(t,e)))}notify(t){I.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}resumePausedMutations(){const t=this.mutations.filter((t=>t.state.isPaused));return I.batch((()=>t.reduce(((t,e)=>t.then((()=>e.continue().catch(n)))),Promise.resolve())))}}function G(){return{onFetch:t=>{t.fetchFn=()=>{var e,s,i,r,n,o;const a=null==(e=t.fetchOptions)||null==(s=e.meta)?void 0:s.refetchPage,u=null==(i=t.fetchOptions)||null==(r=i.meta)?void 0:r.fetchMore,c=null==u?void 0:u.pageParam,h="forward"===(null==u?void 0:u.direction),l="backward"===(null==u?void 0:u.direction),d=(null==(n=t.state.data)?void 0:n.pages)||[],f=(null==(o=t.state.data)?void 0:o.pageParams)||[];let p=f,y=!1;const v=t.options.queryFn||(()=>Promise.reject("Missing queryFn")),m=(t,e,s,i)=>(p=i?[e,...p]:[...p,e],i?[s,...t]:[...t,s]),b=(e,s,i,r)=>{if(y)return Promise.reject("Cancelled");if(void 0===i&&!s&&e.length)return Promise.resolve(e);const n={queryKey:t.queryKey,pageParam:i,meta:t.meta};var o;o=n,Object.defineProperty(o,"signal",{enumerable:!0,get:()=>{var e,s;return null!=(e=t.signal)&&e.aborted?y=!0:null==(s=t.signal)||s.addEventListener("abort",(()=>{y=!0})),t.signal}});const a=v(n);return Promise.resolve(a).then((t=>m(e,i,t,r)))};let g;if(d.length)if(h){const e=void 0!==c,s=e?c:B(t.options,d);g=b(d,e,s)}else if(l){const e=void 0!==c,s=e?c:_(t.options,d);g=b(d,e,s,!0)}else{p=[];const e=void 0===t.options.getNextPageParam;g=!a||!d[0]||a(d[0],0,d)?b([],e,f[0]):Promise.resolve(m([],f[0],d[0]));for(let s=1;s<d.length;s++)g=g.then((i=>{if(!a||!d[s]||a(d[s],s,d)){const r=e?f[s]:B(t.options,i);return b(i,e,r)}return Promise.resolve(m(i,f[s],d[s]))}))}else g=b([]);return g.then((t=>({pages:t,pageParams:p})))}}}}function B(t,e){return null==t.getNextPageParam?void 0:t.getNextPageParam(e[e.length-1],e)}function _(t,e){return null==t.getPreviousPageParam?void 0:t.getPreviousPageParam(e[0],e)}function W(t,e){if(t.getNextPageParam&&Array.isArray(e)){const s=B(t,e);return null!=s&&!1!==s}}function z(t,e){if(t.getPreviousPageParam&&Array.isArray(e)){const s=_(t,e);return null!=s&&!1!==s}}class J extends i{constructor(t,e){super(),this.client=t,this.options=e,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.length&&(this.currentQuery.addObserver(this),V(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.listeners.length||this.destroy()}shouldFetchOnReconnect(){return X(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return X(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=[],this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(t,e){const s=this.options,i=this.currentQuery;if(this.options=this.client.defaultQueryOptions(t),O(s,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=s.queryKey),this.updateQuery();const r=this.hasListeners();r&&Y(this.currentQuery,i,this.options,s)&&this.executeFetch(),this.updateResult(e),!r||this.currentQuery===i&&this.options.enabled===s.enabled&&this.options.staleTime===s.staleTime||this.updateStaleTimeout();const n=this.computeRefetchInterval();!r||this.currentQuery===i&&this.options.enabled===s.enabled&&n===this.currentRefetchInterval||this.updateRefetchInterval(n)}getOptimisticResult(t){const e=this.client.getQueryCache().build(this.client,t);return this.createResult(e,t)}getCurrentResult(){return this.currentResult}trackResult(t){const e={};return Object.keys(t).forEach((s=>{Object.defineProperty(e,s,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(s),t[s])})})),e}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:t,...e}={}){return this.fetch({...e,meta:{refetchPage:t}})}fetchOptimistic(t){const e=this.client.defaultQueryOptions(t),s=this.client.getQueryCache().build(this.client,e);return s.isFetchingOptimistic=!0,s.fetch().then((()=>this.createResult(s,e)))}fetch(t){var e;return this.executeFetch({...t,cancelRefetch:null==(e=t.cancelRefetch)||e}).then((()=>(this.updateResult(),this.currentResult)))}executeFetch(t){this.updateQuery();let e=this.currentQuery.fetch(this.options,t);return null!=t&&t.throwOnError||(e=e.catch(n)),e}updateStaleTimeout(){if(this.clearStaleTimeout(),r||this.currentResult.isStale||!o(this.options.staleTime))return;const t=u(this.currentResult.dataUpdatedAt,this.options.staleTime)+1;this.staleTimeoutId=setTimeout((()=>{this.currentResult.isStale||this.updateResult()}),t)}computeRefetchInterval(){var t;return"function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.currentResult.data,this.currentQuery):null!=(t=this.options.refetchInterval)&&t}updateRefetchInterval(t){this.clearRefetchInterval(),this.currentRefetchInterval=t,!r&&!1!==this.options.enabled&&o(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval((()=>{(this.options.refetchIntervalInBackground||M.isFocused())&&this.executeFetch()}),this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(t,e){const s=this.currentQuery,i=this.options,r=this.currentResult,n=this.currentResultState,o=this.currentResultOptions,a=t!==s,u=a?t.state:this.currentQueryInitialState,c=a?this.currentResult:this.previousQueryResult,{state:h}=t;let l,{dataUpdatedAt:d,error:f,errorUpdatedAt:p,fetchStatus:y,status:v}=h,m=!1,b=!1;if(e._optimisticResults){const r=this.hasListeners(),n=!r&&V(t,e),o=r&&Y(t,s,e,i);(n||o)&&(y=F(t.options.networkMode)?"fetching":"paused",d||(v="loading")),"isRestoring"===e._optimisticResults&&(y="idle")}if(e.keepPreviousData&&!h.dataUpdateCount&&null!=c&&c.isSuccess&&"error"!==v)l=c.data,d=c.dataUpdatedAt,v=c.status,m=!0;else if(e.select&&void 0!==h.data)if(r&&h.data===(null==n?void 0:n.data)&&e.select===this.selectFn)l=this.selectResult;else try{this.selectFn=e.select,l=e.select(h.data),l=w(null==r?void 0:r.data,l,e),this.selectResult=l,this.selectError=null}catch(t){this.selectError=t}else l=h.data;if(void 0!==e.placeholderData&&void 0===l&&"loading"===v){let t;if(null!=r&&r.isPlaceholderData&&e.placeholderData===(null==o?void 0:o.placeholderData))t=r.data;else if(t="function"==typeof e.placeholderData?e.placeholderData():e.placeholderData,e.select&&void 0!==t)try{t=e.select(t),t=w(null==r?void 0:r.data,t,e),this.selectError=null}catch(t){this.selectError=t}void 0!==t&&(v="success",l=t,b=!0)}this.selectError&&(f=this.selectError,l=this.selectResult,p=Date.now(),v="error");const g="fetching"===y;return{status:v,fetchStatus:y,isLoading:"loading"===v,isSuccess:"success"===v,isError:"error"===v,data:l,dataUpdatedAt:d,error:f,errorUpdatedAt:p,failureCount:h.fetchFailureCount,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&"loading"!==v,isLoadingError:"error"===v&&0===h.dataUpdatedAt,isPaused:"paused"===y,isPlaceholderData:b,isPreviousData:m,isRefetchError:"error"===v&&0!==h.dataUpdatedAt,isStale:Z(t,e),refetch:this.refetch,remove:this.remove}}updateResult(t){const e=this.currentResult,s=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,O(s,e))return;this.currentResult=s;const i={cache:!0};!1!==(null==t?void 0:t.listeners)&&(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options;if("all"===t||!t&&!this.trackedProps.size)return!0;const s=new Set(null!=t?t:this.trackedProps);return this.options.useErrorBoundary&&s.add("error"),Object.keys(this.currentResult).some((t=>{const i=t;return this.currentResult[i]!==e[i]&&s.has(i)}))})()&&(i.listeners=!0),this.notify({...i,...t})}updateQuery(){const t=this.client.getQueryCache().build(this.client,this.options);if(t===this.currentQuery)return;const e=this.currentQuery;this.currentQuery=t,this.currentQueryInitialState=t.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(null==e||e.removeObserver(this),t.addObserver(this))}onQueryUpdate(t){const e={};"success"===t.type?e.onSuccess=!t.manual:"error"!==t.type||K(t.error)||(e.onError=!0),this.updateResult(e),this.hasListeners()&&this.updateTimers()}notify(t){I.batch((()=>{var e,s,i,r;if(t.onSuccess)null==(e=(s=this.options).onSuccess)||e.call(s,this.currentResult.data),null==(i=(r=this.options).onSettled)||i.call(r,this.currentResult.data,null);else if(t.onError){var n,o,a,u;null==(n=(o=this.options).onError)||n.call(o,this.currentResult.error),null==(a=(u=this.options).onSettled)||a.call(u,void 0,this.currentResult.error)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)})),t.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})}))}}function V(t,e){return function(t,e){return!(!1===e.enabled||t.state.dataUpdatedAt||"error"===t.state.status&&!1===e.retryOnMount)}(t,e)||t.state.dataUpdatedAt>0&&X(t,e,e.refetchOnMount)}function X(t,e,s){if(!1!==e.enabled){const i="function"==typeof s?s(t):s;return"always"===i||!1!==i&&Z(t,e)}return!1}function Y(t,e,s,i){return!1!==s.enabled&&(t!==e||!1===i.enabled)&&(!s.suspense||"error"!==t.state.status)&&Z(t,s)}function Z(t,e){return t.isStaleByTime(e.staleTime)}class $ extends i{constructor(t,e){super(),this.client=t,this.queries=[],this.result=[],this.observers=[],this.observersMap={},e&&this.setQueries(e)}onSubscribe(){1===this.listeners.length&&this.observers.forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))}))}onUnsubscribe(){this.listeners.length||this.destroy()}destroy(){this.listeners=[],this.observers.forEach((t=>{t.destroy()}))}setQueries(t,e){this.queries=t,I.batch((()=>{const t=this.observers,s=this.findMatchingObservers(this.queries);s.forEach((t=>t.observer.setOptions(t.defaultedQueryOptions,e)));const i=s.map((t=>t.observer)),r=Object.fromEntries(i.map((t=>[t.options.queryHash,t]))),n=i.map((t=>t.getCurrentResult())),o=i.some(((e,s)=>e!==t[s]));(t.length!==i.length||o)&&(this.observers=i,this.observersMap=r,this.result=n,this.hasListeners()&&(a(t,i).forEach((t=>{t.destroy()})),a(i,t).forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))})),this.notify()))}))}getCurrentResult(){return this.result}getOptimisticResult(t){return this.findMatchingObservers(t).map((t=>t.observer.getOptimisticResult(t.defaultedQueryOptions)))}findMatchingObservers(t){const e=this.observers,s=t.map((t=>this.client.defaultQueryOptions(t))),i=s.flatMap((t=>{const s=e.find((e=>e.options.queryHash===t.queryHash));return null!=s?[{defaultedQueryOptions:t,observer:s}]:[]})),r=i.map((t=>t.defaultedQueryOptions.queryHash)),n=s.filter((t=>!r.includes(t.queryHash))),o=e.filter((t=>!i.some((e=>e.observer===t)))),a=t=>{const e=this.client.defaultQueryOptions(t),s=this.observersMap[e.queryHash];return null!=s?s:new J(this.client,e)},u=n.map(((t,e)=>{if(t.keepPreviousData){const s=o[e];if(void 0!==s)return{defaultedQueryOptions:t,observer:s}}return{defaultedQueryOptions:t,observer:a(t)}}));return i.concat(u).sort(((t,e)=>s.indexOf(t.defaultedQueryOptions)-s.indexOf(e.defaultedQueryOptions)))}onUpdate(t,e){const s=this.observers.indexOf(t);-1!==s&&(this.result=function(t,e,s){const i=t.slice(0);return i[e]=s,i}(this.result,s,e),this.notify())}notify(){I.batch((()=>{this.listeners.forEach((t=>{t(this.result)}))}))}}class tt extends J{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t,e){super.setOptions({...t,behavior:G()},e)}getOptimisticResult(t){return t.behavior=G(),super.getOptimisticResult(t)}fetchNextPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"forward",pageParam:t}}})}fetchPreviousPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"backward",pageParam:t}}})}createResult(t,e){var s,i,r,n,o,a;const{state:u}=t;return{...super.createResult(t,e),fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:W(e,null==(s=u.data)?void 0:s.pages),hasPreviousPage:z(e,null==(i=u.data)?void 0:i.pages),isFetchingNextPage:"fetching"===u.fetchStatus&&"forward"===(null==(r=u.fetchMeta)||null==(n=r.fetchMore)?void 0:n.direction),isFetchingPreviousPage:"fetching"===u.fetchStatus&&"backward"===(null==(o=u.fetchMeta)||null==(a=o.fetchMore)?void 0:a.direction)}}}class et extends i{constructor(t,e){super(),this.client=t,this.setOptions(e),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.client.defaultMutationOptions(t),O(e,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this})}onUnsubscribe(){var t;this.listeners.length||(null==(t=this.currentMutation)||t.removeObserver(this))}onMutationUpdate(t){this.updateResult();const e={listeners:!0};"success"===t.type?e.onSuccess=!0:"error"===t.type&&(e.onError=!0),this.notify(e)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(t,e){return this.mutateOptions=e,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:void 0!==t?t:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const t=this.currentMutation?this.currentMutation.state:{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0},e={...t,isLoading:"loading"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset};this.currentResult=e}notify(t){I.batch((()=>{var e,s,i,r;if(this.mutateOptions)if(t.onSuccess)null==(e=(s=this.mutateOptions).onSuccess)||e.call(s,this.currentResult.data,this.currentResult.variables,this.currentResult.context),null==(i=(r=this.mutateOptions).onSettled)||i.call(r,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context);else if(t.onError){var n,o,a,u;null==(n=(o=this.mutateOptions).onError)||n.call(o,this.currentResult.error,this.currentResult.variables,this.currentResult.context),null==(a=(u=this.mutateOptions).onSettled)||a.call(u,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)}))}))}}function st(t){return t.state.isPaused}function it(t){return"success"===t.state.status}function rt(t){return"function"==typeof t}function nt(t,e,s){if(!rt(t)){const{queryKey:e,...s}=t;return e?{...s,queryKey:e()}:t}return"function"==typeof e?{...s,queryKey:t(),queryFn:e}:{...e,queryKey:t()}}function ot(t,e,s){return rt(t)?[{...e,queryKey:t()},s]:[{...t,queryKey:null==t||null==t.queryKey?void 0:t.queryKey()},e]}function at(t,e){return"function"==typeof t?t(...e):!!t}function ut(t){var e;(e=0,new Promise((t=>{setTimeout(t,e)}))).then(t)}const ct=e.createContext(void 0),ht=e.createContext(!1);function lt(t,e){return t||(e&&"undefined"!=typeof window?(window.SolidQueryClientContext||(window.SolidQueryClientContext=ct),window.SolidQueryClientContext):ct)}const dt=({context:t}={})=>{const s=e.useContext(lt(t,e.useContext(ht)));if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s};function ft(t,i){const r=dt({context:t.context}),n=r.defaultQueryOptions(t);n._optimisticResults="optimistic";const o=new i(r,n),[a,u]=s.createStore(o.getOptimisticResult(n)),[c,{refetch:h,mutate:l}]=e.createResource((()=>new Promise((t=>{a.isFetching&&a.isLoading||t(s.unwrap(a.data))}))));e.batch((()=>{l((()=>s.unwrap(a.data))),h()}));let d=[];const f=o.subscribe((t=>{d.push((()=>{e.batch((()=>{u(s.unwrap(t)),l((()=>s.unwrap(t.data))),h()}))})),queueMicrotask((()=>{const t=d.pop();t&&t(),d=[]}))}));e.onCleanup((()=>f())),e.onMount((()=>{o.setOptions(n,{listeners:!1})})),e.createComputed((()=>{const e=r.defaultQueryOptions(t);o.setOptions(e)})),e.createComputed(e.on((()=>a.status),(()=>{if(a.isError&&!a.isFetching&&at(o.options.useErrorBoundary,[a.error,o.getCurrentQuery()]))throw a.error})));return new Proxy(a,{get:(t,e)=>"data"===e&&t.isLoading&&t.isFetching?c():Reflect.get(t,e)})}function pt(){}t.CancelledError=A,t.InfiniteQueryObserver=tt,t.MutationCache=N,t.MutationObserver=et,t.QueriesObserver=$,t.QueryCache=k,t.QueryClient=class{constructor(t={}){this.queryCache=t.queryCache||new k,this.mutationCache=t.mutationCache||new N,this.logger=t.logger||U,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}mount(){this.unsubscribeFocus=M.subscribe((()=>{M.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())})),this.unsubscribeOnline=x.subscribe((()=>{x.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var t,e;null==(t=this.unsubscribeFocus)||t.call(this),null==(e=this.unsubscribeOnline)||e.call(this)}isFetching(t,e){const[s]=l(t,e);return s.fetchStatus="fetching",this.queryCache.findAll(s).length}isMutating(t){return this.mutationCache.findAll({...t,fetching:!0}).length}getQueryData(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state.data}getQueriesData(t){return this.getQueryCache().findAll(t).map((({queryKey:t,state:e})=>[t,e.data]))}setQueryData(t,e,s){const i=this.queryCache.find(t),r=function(t,e){return"function"==typeof t?t(e):t}(e,null==i?void 0:i.state.data);if(void 0===r)return;const n=c(t),o=this.defaultQueryOptions(n);return this.queryCache.build(this,o).setData(r,{...s,manual:!0})}setQueriesData(t,e,s){return I.batch((()=>this.getQueryCache().findAll(t).map((({queryKey:t})=>[t,this.setQueryData(t,e,s)]))))}getQueryState(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state}removeQueries(t,e){const[s]=l(t,e),i=this.queryCache;I.batch((()=>{i.findAll(s).forEach((t=>{i.remove(t)}))}))}resetQueries(t,e,s){const[i,r]=l(t,e,s),n=this.queryCache,o={type:"active",...i};return I.batch((()=>(n.findAll(i).forEach((t=>{t.reset()})),this.refetchQueries(o,r))))}cancelQueries(t,e,s){const[i,r={}]=l(t,e,s);void 0===r.revert&&(r.revert=!0);const o=I.batch((()=>this.queryCache.findAll(i).map((t=>t.cancel(r)))));return Promise.all(o).then(n).catch(n)}invalidateQueries(t,e,s){const[i,r]=l(t,e,s);return I.batch((()=>{var t,e;if(this.queryCache.findAll(i).forEach((t=>{t.invalidate()})),"none"===i.refetchType)return Promise.resolve();const s={...i,type:null!=(t=null!=(e=i.refetchType)?e:i.type)?t:"active"};return this.refetchQueries(s,r)}))}refetchQueries(t,e,s){const[i,r]=l(t,e,s),o=I.batch((()=>this.queryCache.findAll(i).filter((t=>!t.isDisabled())).map((t=>{var e;return t.fetch(void 0,{...r,cancelRefetch:null==(e=null==r?void 0:r.cancelRefetch)||e,meta:{refetchPage:i.refetchPage}})}))));let a=Promise.all(o).then(n);return null!=r&&r.throwOnError||(a=a.catch(n)),a}fetchQuery(t,e,s){const i=c(t,e,s),r=this.defaultQueryOptions(i);void 0===r.retry&&(r.retry=!1);const n=this.queryCache.build(this,r);return n.isStaleByTime(r.staleTime)?n.fetch(r):Promise.resolve(n.state.data)}prefetchQuery(t,e,s){return this.fetchQuery(t,e,s).then(n).catch(n)}fetchInfiniteQuery(t,e,s){const i=c(t,e,s);return i.behavior=G(),this.fetchQuery(i)}prefetchInfiniteQuery(t,e,s){return this.fetchInfiniteQuery(t,e,s).then(n).catch(n)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(t){this.defaultOptions=t}setQueryDefaults(t,e){const s=this.queryDefaults.find((e=>v(t)===v(e.queryKey)));s?s.defaultOptions=e:this.queryDefaults.push({queryKey:t,defaultOptions:e})}getQueryDefaults(t){if(!t)return;const e=this.queryDefaults.find((e=>m(t,e.queryKey)));return null==e?void 0:e.defaultOptions}setMutationDefaults(t,e){const s=this.mutationDefaults.find((e=>v(t)===v(e.mutationKey)));s?s.defaultOptions=e:this.mutationDefaults.push({mutationKey:t,defaultOptions:e})}getMutationDefaults(t){if(!t)return;const e=this.mutationDefaults.find((e=>m(t,e.mutationKey)));return null==e?void 0:e.defaultOptions}defaultQueryOptions(t){if(null!=t&&t._defaulted)return t;const e={...this.defaultOptions.queries,...this.getQueryDefaults(null==t?void 0:t.queryKey),...t,_defaulted:!0};return!e.queryHash&&e.queryKey&&(e.queryHash=y(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.useErrorBoundary&&(e.useErrorBoundary=!!e.suspense),e}defaultMutationOptions(t){return null!=t&&t._defaulted?t:{...this.defaultOptions.mutations,...this.getMutationDefaults(null==t?void 0:t.mutationKey),...t,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}},t.QueryClientProvider=t=>{const s=e.mergeProps({contextSharing:!1},t);e.onMount((()=>s.client.mount())),e.onCleanup((()=>s.client.unmount()));const i=lt(s.context,s.contextSharing);return e.createComponent(ht.Provider,{get value(){return!s.context&&s.contextSharing},get children(){return e.createComponent(i.Provider,{get value(){return s.client},get children(){return s.children}})}})},t.QueryObserver=J,t.createInfiniteQuery=function(t,i,r){const[n,o]=s.createStore(nt(t,i,r));return e.createComputed((()=>{const e=nt(t,i,r);o(e)})),ft(n,tt)},t.createMutation=function(t,i,r){const[n,o]=s.createStore(h(t,i,r)),a=dt({context:n.context}),u=new et(a,n),c=(t,e)=>{u.mutate(t,e).catch(pt)},[l,d]=s.createStore({...u.getCurrentResult(),mutate:c,mutateAsync:u.getCurrentResult().mutate});e.createComputed((()=>{const e=h(t,i,r);o(e),u.setOptions(e)})),e.createComputed(e.on((()=>l.status),(()=>{if(l.isError&&at(u.options.useErrorBoundary,[l.error]))throw l.error})));const f=u.subscribe((t=>{d({...t,mutate:c,mutateAsync:t.mutate})}));return e.onCleanup(f),l},t.createQueries=function(t){const i=dt({context:t.context}),r=t=>{const e={...t,queryKey:null==t.queryKey?void 0:t.queryKey()},s=i.defaultQueryOptions(e);return s._optimisticResults="optimistic",s},n=t.queries.map((t=>r(t))),o=new $(i,n),[a,u]=s.createStore(o.getOptimisticResult(n)),c=[],h=o.subscribe((t=>{c.push((()=>{u(s.unwrap(t))})),ut((()=>{const t=c.pop();t&&(t(),c.splice(0,c.length))}))}));return e.onCleanup(h),e.onMount((()=>{o.setQueries(n,{listeners:!1})})),e.createComputed((()=>{const e=t.queries.map((t=>r(t)));o.setQueries(e)})),a},t.createQuery=function(t,i,r){const[n,o]=s.createStore(nt(t,i,r));return e.createComputed((()=>{const e=nt(t,i,r);o(e)})),ft(n,J)},t.defaultContext=ct,t.dehydrate=function(t,e={}){const s=[],i=[];if(!1!==e.dehydrateMutations){const i=e.shouldDehydrateMutation||st;t.getMutationCache().getAll().forEach((t=>{i(t)&&s.push(function(t){return{mutationKey:t.options.mutationKey,state:t.state}}(t))}))}if(!1!==e.dehydrateQueries){const s=e.shouldDehydrateQuery||it;t.getQueryCache().getAll().forEach((t=>{s(t)&&i.push(function(t){return{state:t.state,queryKey:t.queryKey,queryHash:t.queryHash}}(t))}))}return{mutations:s,queries:i}},t.focusManager=M,t.hashQueryKey=v,t.hydrate=function(t,e,s){if("object"!=typeof e||null===e)return;const i=t.getMutationCache(),r=t.getQueryCache(),n=e.mutations||[],o=e.queries||[];n.forEach((e=>{var r;i.build(t,{...null==s||null==(r=s.defaultOptions)?void 0:r.mutations,mutationKey:e.mutationKey},e.state)})),o.forEach((e=>{var i;const n=r.get(e.queryHash);n?n.state.dataUpdatedAt<e.state.dataUpdatedAt&&n.setState(e.state):r.build(t,{...null==s||null==(i=s.defaultOptions)?void 0:i.queries,queryKey:e.queryKey,queryHash:e.queryHash},e.state)}))},t.isCancelledError=K,t.isError=function(t){return t instanceof Error},t.isServer=r,t.notifyManager=I,t.onlineManager=x,t.parseFilterArgs=l,t.parseMutationArgs=h,t.parseMutationFilterArgs=d,t.parseQueryArgs=c,t.useIsFetching=function(t,s,i){const[r,n={}]=ot(t,s,i),[o,a]=e.createSignal(r),[u,c]=e.createSignal(n),h=e.createMemo((()=>dt({context:u().context}))),l=e.createMemo((()=>h().getQueryCache())),[d,f]=e.createSignal(h().isFetching(o));e.createComputed((()=>{const[e,r={}]=ot(t,s,i);a(e),c(r)}));const p=l().subscribe((()=>{f(h().isFetching(o()))}));return e.onCleanup((()=>{p()})),d},t.useIsMutating=function(t,s,i){const[r,n={}]=d(t,s,i),o=dt({context:n.context}),a=o.getMutationCache(),[u,c]=e.createSignal(o.isMutating(r)),h=a.subscribe((t=>{c(o.isMutating(r))}));return e.onCleanup((()=>{h()})),u},t.useQueryClient=dt,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/solid-query", | ||
"version": "4.4.0", | ||
"version": "4.5.0", | ||
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid", | ||
@@ -46,3 +46,3 @@ "author": "tannerlinsley", | ||
"dependencies": { | ||
"@tanstack/query-core": "4.4.0" | ||
"@tanstack/query-core": "4.5.0" | ||
}, | ||
@@ -49,0 +49,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1151156
+ Added@tanstack/query-core@4.5.0(transitive)
- Removed@tanstack/query-core@4.4.0(transitive)
Updated@tanstack/query-core@4.5.0