forked from duneanalytics/DuneQueryRepo
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path777-f1c6ff295997ae3b.js.download
2 lines (2 loc) · 7.49 KB
/
777-f1c6ff295997ae3b.js.download
1
2
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[777],{10777:function(t,e,s){let r;s.d(e,{a:function(){return T}});var i=s(24139),n=s(27037),u=s(66474),h=s(7506),a=s(56888),c=class extends h.l{constructor(t,e){super(),this.options=e,this.#t=t,this.#e=null,this.bindMethods(),this.setOptions(e)}#t;#s=void 0;#r=void 0;#i=void 0;#n;#u;#e;#h;#a;#c;#o;#l;#d;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#s.addObserver(this),o(this.#s,this.options)?this.#f():this.updateResult(),this.#R())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return l(this.#s,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return l(this.#s,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#v(),this.#s.removeObserver(this)}setOptions(t,e){let s=this.options,r=this.#s;if(this.options=this.#t.defaultQueryOptions(t),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw Error("Expected enabled to be a boolean");this.#b(),this.#s.setOptions(this.options),s._defaulted&&!(0,i.VS)(this.options,s)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#s,observer:this});let n=this.hasListeners();n&&d(this.#s,r,this.options,s)&&this.#f(),this.updateResult(e),n&&(this.#s!==r||this.options.enabled!==s.enabled||this.options.staleTime!==s.staleTime)&&this.#Q();let u=this.#m();n&&(this.#s!==r||this.options.enabled!==s.enabled||u!==this.#d)&&this.#O(u)}getOptimisticResult(t){let e=this.#t.getQueryCache().build(this.#t,t),s=this.createResult(e,t);return(0,i.VS)(this.getCurrentResult(),s)||(this.#i=s,this.#u=this.options,this.#n=this.#s.state),s}getCurrentResult(){return this.#i}trackResult(t,e){let s={};return Object.keys(t).forEach(r=>{Object.defineProperty(s,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),e?.(r),t[r])})}),s}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#s}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#t.defaultQueryOptions(t),s=this.#t.getQueryCache().build(this.#t,e);return s.isFetchingOptimistic=!0,s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#f(t){this.#b();let e=this.#s.fetch(this.options,t);return t?.throwOnError||(e=e.catch(i.ZT)),e}#Q(){if(this.#y(),i.sk||this.#i.isStale||!(0,i.PN)(this.options.staleTime))return;let t=(0,i.Kp)(this.#i.dataUpdatedAt,this.options.staleTime);this.#o=setTimeout(()=>{this.#i.isStale||this.updateResult()},t+1)}#m(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#s):this.options.refetchInterval)??!1}#O(t){this.#v(),this.#d=t,!i.sk&&!1!==this.options.enabled&&(0,i.PN)(this.#d)&&0!==this.#d&&(this.#l=setInterval(()=>{(this.options.refetchIntervalInBackground||u.j.isFocused())&&this.#f()},this.#d))}#R(){this.#Q(),this.#O(this.#m())}#y(){this.#o&&(clearTimeout(this.#o),this.#o=void 0)}#v(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let s;let r=this.#s,n=this.options,u=this.#i,h=this.#n,c=this.#u,l=t!==r,f=l?t.state:this.#r,{state:R}=t,y={...R},v=!1;if(e._optimisticResults){let s=this.hasListeners(),i=!s&&o(t,e),u=s&&d(t,r,e,n);(i||u)&&(y={...y,...(0,a.z)(R.data,t.options)}),"isRestoring"===e._optimisticResults&&(y.fetchStatus="idle")}let{error:b,errorUpdatedAt:Q,status:m}=y;if(e.select&&void 0!==y.data){if(u&&y.data===h?.data&&e.select===this.#h)s=this.#a;else try{this.#h=e.select,s=e.select(y.data),s=(0,i.oE)(u?.data,s,e),this.#a=s,this.#e=null}catch(t){this.#e=t}}else s=y.data;if(void 0!==e.placeholderData&&void 0===s&&"pending"===m){let t;if(u?.isPlaceholderData&&e.placeholderData===c?.placeholderData)t=u.data;else if(t="function"==typeof e.placeholderData?e.placeholderData(this.#c?.state.data,this.#c):e.placeholderData,e.select&&void 0!==t)try{t=e.select(t),this.#e=null}catch(t){this.#e=t}void 0!==t&&(m="success",s=(0,i.oE)(u?.data,t,e),v=!0)}this.#e&&(b=this.#e,s=this.#a,Q=Date.now(),m="error");let O="fetching"===y.fetchStatus,I="pending"===m,C="error"===m,S=I&&O,g=void 0!==s,E={status:m,fetchStatus:y.fetchStatus,isPending:I,isSuccess:"success"===m,isError:C,isInitialLoading:S,isLoading:S,data:s,dataUpdatedAt:y.dataUpdatedAt,error:b,errorUpdatedAt:Q,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:y.dataUpdateCount>0||y.errorUpdateCount>0,isFetchedAfterMount:y.dataUpdateCount>f.dataUpdateCount||y.errorUpdateCount>f.errorUpdateCount,isFetching:O,isRefetching:O&&!I,isLoadingError:C&&!g,isPaused:"paused"===y.fetchStatus,isPlaceholderData:v,isRefetchError:C&&g,isStale:p(t,e),refetch:this.refetch};return E}updateResult(t){let e=this.#i,s=this.createResult(this.#s,this.options);if(this.#n=this.#s.state,this.#u=this.options,void 0!==this.#n.data&&(this.#c=this.#s),(0,i.VS)(s,e))return;this.#i=s;let r={};t?.listeners!==!1&&(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,s="function"==typeof t?t():t;if("all"===s||!s&&!this.#p.size)return!0;let r=new Set(s??this.#p);return this.options.throwOnError&&r.add("error"),Object.keys(this.#i).some(t=>{let s=this.#i[t]!==e[t];return s&&r.has(t)})})()&&(r.listeners=!0),this.#I({...r,...t})}#b(){let t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#s)return;let e=this.#s;this.#s=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#R()}#I(t){n.V.batch(()=>{t.listeners&&this.listeners.forEach(t=>{t(this.#i)}),this.#t.getQueryCache().notify({query:this.#s,type:"observerResultsUpdated"})})}};function o(t,e){return!1!==e.enabled&&void 0===t.state.data&&!("error"===t.state.status&&!1===e.retryOnMount)||void 0!==t.state.data&&l(t,e,e.refetchOnMount)}function l(t,e,s){if(!1!==e.enabled){let r="function"==typeof s?s(t):s;return"always"===r||!1!==r&&p(t,e)}return!1}function d(t,e,s,r){return(t!==e||!1===r.enabled)&&(!s.suspense||"error"!==t.state.status)&&p(t,s)}function p(t,e){return!1!==e.enabled&&t.isStaleByTime(e.staleTime)}var f=s(67294);s(85893);var R=f.createContext((r=!1,{clearReset:()=>{r=!1},reset:()=>{r=!0},isReset:()=>r})),y=()=>f.useContext(R),v=s(30202),b=f.createContext(!1),Q=()=>f.useContext(b);b.Provider;var m=s(86290),O=(t,e)=>{(t.suspense||t.throwOnError)&&!e.isReset()&&(t.retryOnMount=!1)},I=t=>{f.useEffect(()=>{t.clearReset()},[t])},C=({result:t,errorResetBoundary:e,throwOnError:s,query:r})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(0,m.L)(s,[t.error,r]),S=t=>{t.suspense&&"number"!=typeof t.staleTime&&(t.staleTime=1e3)},g=(t,e)=>t?.suspense&&e.isPending,E=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function T(t,e){return function(t,e,s){let r=(0,v.NL)(s),i=Q(),u=y(),h=r.defaultQueryOptions(t);h._optimisticResults=i?"isRestoring":"optimistic",S(h),O(h,u),I(u);let[a]=f.useState(()=>new e(r,h)),c=a.getOptimisticResult(h);if(f.useSyncExternalStore(f.useCallback(t=>{let e=i?()=>void 0:a.subscribe(n.V.batchCalls(t));return a.updateResult(),e},[a,i]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),f.useEffect(()=>{a.setOptions(h,{listeners:!1})},[h,a]),g(h,c))throw E(h,a,u);if(C({result:c,errorResetBoundary:u,throwOnError:h.throwOnError,query:r.getQueryCache().get(h.queryHash)}))throw c.error;return h.notifyOnChangeProps?c:a.trackResult(c)}(t,c,e)}},86290:function(t,e,s){function r(t,e){return"function"==typeof t?t(...e):!!t}function i(){}s.d(e,{L:function(){return r},Z:function(){return i}})}}]);
//# sourceMappingURL=777-f1c6ff295997ae3b.js.map