var nt=i=>{throw TypeError(i)};var q=(i,t,s)=>t.has(i)||nt("Cannot "+s);var e=(i,t,s)=>(q(i,t,"read from private field"),s?s.call(i):t.get(i)),b=(i,t,s)=>t.has(i)?nt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),u=(i,t,s,r)=>(q(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),f=(i,t,s)=>(q(i,t,"access private method"),s);import{as as vt,by as C,at as G,bz as B,bA as mt,bB as ot,bC as ht,bD as yt,bE as Rt,bF as Ot,bG as ct,aw as Ct,z as St,aC as wt,ax as Qt,E as z,ay as ut,az as Et,aD as lt,aA as Dt,aB as Ft}from"./DtdvSNjU.js";import{u as It}from"./6G5LWOrd.js";var v,a,x,g,Q,T,O,j,k,L,E,D,w,M,n,A,K,H,J,X,Y,Z,$,bt,pt,Ut=(pt=class extends vt{constructor(t,s){super();b(this,n);b(this,v);b(this,a);b(this,x);b(this,g);b(this,Q);b(this,T);b(this,O);b(this,j);b(this,k);b(this,L);b(this,E);b(this,D);b(this,w);b(this,M,new Set);this.options=s,u(this,v,t),u(this,O,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(e(this,a).addObserver(this),dt(e(this,a),this.options)?f(this,n,A).call(this):this.updateResult(),f(this,n,X).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return tt(e(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return tt(e(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,f(this,n,Y).call(this),f(this,n,Z).call(this),e(this,a).removeObserver(this)}setOptions(t,s){const r=this.options,c=e(this,a);if(this.options=e(this,v).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof C(this.options.enabled,e(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");f(this,n,$).call(this),e(this,a).setOptions(this.options),r._defaulted&&!G(this.options,r)&&e(this,v).getQueryCache().notify({type:"observerOptionsUpdated",query:e(this,a),observer:this});const o=this.hasListeners();o&&ft(e(this,a),c,this.options,r)&&f(this,n,A).call(this),this.updateResult(s),o&&(e(this,a)!==c||C(this.options.enabled,e(this,a))!==C(r.enabled,e(this,a))||B(this.options.staleTime,e(this,a))!==B(r.staleTime,e(this,a)))&&f(this,n,K).call(this);const d=f(this,n,H).call(this);o&&(e(this,a)!==c||C(this.options.enabled,e(this,a))!==C(r.enabled,e(this,a))||d!==e(this,w))&&f(this,n,J).call(this,d)}getOptimisticResult(t){const s=e(this,v).getQueryCache().build(e(this,v),t),r=this.createResult(s,t);return Tt(this,r)&&(u(this,g,r),u(this,T,this.options),u(this,Q,e(this,a).state)),r}getCurrentResult(){return e(this,g)}trackResult(t,s){const r={};return Object.keys(t).forEach(c=>{Object.defineProperty(r,c,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(c),s==null||s(c),t[c])})}),r}trackProp(t){e(this,M).add(t)}getCurrentQuery(){return e(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=e(this,v).defaultQueryOptions(t),r=e(this,v).getQueryCache().build(e(this,v),s);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,s))}fetch(t){return f(this,n,A).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),e(this,g)))}createResult(t,s){var at;const r=e(this,a),c=this.options,o=e(this,g),d=e(this,Q),y=e(this,T),I=t!==r?t.state:e(this,x),{state:S}=t;let h={...S},l=!1,p;if(s._optimisticResults){const m=this.hasListeners(),V=!m&&dt(t,s),gt=m&&ft(t,r,s,c);(V||gt)&&(h={...h,...Ot(S.data,t.options)}),s._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:U,errorUpdatedAt:P,status:R}=h;if(s.select&&h.data!==void 0)if(o&&h.data===(d==null?void 0:d.data)&&s.select===e(this,j))p=e(this,k);else try{u(this,j,s.select),p=s.select(h.data),p=ct(o==null?void 0:o.data,p,s),u(this,k,p),u(this,O,null)}catch(m){u(this,O,m)}else p=h.data;if(s.placeholderData!==void 0&&p===void 0&&R==="pending"){let m;if(o!=null&&o.isPlaceholderData&&s.placeholderData===(y==null?void 0:y.placeholderData))m=o.data;else if(m=typeof s.placeholderData=="function"?s.placeholderData((at=e(this,L))==null?void 0:at.state.data,e(this,L)):s.placeholderData,s.select&&m!==void 0)try{m=s.select(m),u(this,O,null)}catch(V){u(this,O,V)}m!==void 0&&(R="success",p=ct(o==null?void 0:o.data,m,s),l=!0)}e(this,O)&&(U=e(this,O),p=e(this,k),P=Date.now(),R="error");const _=h.fetchStatus==="fetching",W=R==="pending",N=R==="error",it=W&&_,rt=p!==void 0;return{status:R,fetchStatus:h.fetchStatus,isPending:W,isSuccess:R==="success",isError:N,isInitialLoading:it,isLoading:it,data:p,dataUpdatedAt:h.dataUpdatedAt,error:U,errorUpdatedAt:P,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>I.dataUpdateCount||h.errorUpdateCount>I.errorUpdateCount,isFetching:_,isRefetching:_&&!W,isLoadingError:N&&!rt,isPaused:h.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:N&&rt,isStale:et(t,s),refetch:this.refetch}}updateResult(t){const s=e(this,g),r=this.createResult(e(this,a),this.options);if(u(this,Q,e(this,a).state),u(this,T,this.options),e(this,Q).data!==void 0&&u(this,L,e(this,a)),G(r,s))return;u(this,g,r);const c={},o=()=>{if(!s)return!0;const{notifyOnChangeProps:d}=this.options,y=typeof d=="function"?d():d;if(y==="all"||!y&&!e(this,M).size)return!0;const F=new Set(y??e(this,M));return this.options.throwOnError&&F.add("error"),Object.keys(e(this,g)).some(I=>{const S=I;return e(this,g)[S]!==s[S]&&F.has(S)})};(t==null?void 0:t.listeners)!==!1&&o()&&(c.listeners=!0),f(this,n,bt).call(this,{...c,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&f(this,n,X).call(this)}},v=new WeakMap,a=new WeakMap,x=new WeakMap,g=new WeakMap,Q=new WeakMap,T=new WeakMap,O=new WeakMap,j=new WeakMap,k=new WeakMap,L=new WeakMap,E=new WeakMap,D=new WeakMap,w=new WeakMap,M=new WeakMap,n=new WeakSet,A=function(t){f(this,n,$).call(this);let s=e(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(mt)),s},K=function(){f(this,n,Y).call(this);const t=B(this.options.staleTime,e(this,a));if(ot||e(this,g).isStale||!ht(t))return;const r=yt(e(this,g).dataUpdatedAt,t)+1;u(this,E,setTimeout(()=>{e(this,g).isStale||this.updateResult()},r))},H=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(e(this,a)):this.options.refetchInterval)??!1},J=function(t){f(this,n,Z).call(this),u(this,w,t),!(ot||C(this.options.enabled,e(this,a))===!1||!ht(e(this,w))||e(this,w)===0)&&u(this,D,setInterval(()=>{(this.options.refetchIntervalInBackground||Rt.isFocused())&&f(this,n,A).call(this)},e(this,w)))},X=function(){f(this,n,K).call(this),f(this,n,J).call(this,f(this,n,H).call(this))},Y=function(){e(this,E)&&(clearTimeout(e(this,E)),u(this,E,void 0))},Z=function(){e(this,D)&&(clearInterval(e(this,D)),u(this,D,void 0))},$=function(){const t=e(this,v).getQueryCache().build(e(this,v),this.options);if(t===e(this,a))return;const s=e(this,a);u(this,a,t),u(this,x,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},bt=function(t){Ct.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(e(this,g))}),e(this,v).getQueryCache().notify({query:e(this,a),type:"observerResultsUpdated"})})},pt);function _t(i,t){return C(t.enabled,i)!==!1&&i.state.data===void 0&&!(i.state.status==="error"&&t.retryOnMount===!1)}function dt(i,t){return _t(i,t)||i.state.data!==void 0&&tt(i,t,t.refetchOnMount)}function tt(i,t,s){if(C(t.enabled,i)!==!1){const r=typeof s=="function"?s(i):s;return r==="always"||r!==!1&&et(i,t)}return!1}function ft(i,t,s,r){return(i!==t||C(r.enabled,i)===!1)&&(!s.suspense||i.state.status!=="error")&&et(i,s)}function et(i,t){return C(t.enabled,i)!==!1&&i.isStaleByTime(B(t.staleTime,i))}function Tt(i,t){return!G(i.getCurrentResult(),t)}function kt(i,t,s){const r=It(),c=St(()=>{const l=wt(t);typeof l.enabled=="function"&&(l.enabled=l.enabled());const p=r.defaultQueryOptions(l);return p._optimisticResults=r.isRestoring.value?"isRestoring":"optimistic",p}),o=new i(r,c.value),d=Qt(o.getCurrentResult());let y=()=>{};z(r.isRestoring,l=>{l||(y(),y=o.subscribe(p=>{ut(d,p)}))},{immediate:!0});const F=()=>{o.setOptions(c.value),ut(d,o.getCurrentResult())};z(c,F),Et(()=>{y()});const I=(...l)=>(F(),d.refetch(...l)),S=()=>new Promise((l,p)=>{let U=()=>{};const P=()=>{if(c.value.enabled!==!1){o.setOptions(c.value);const R=o.getOptimisticResult(c.value);R.isStale?(U(),o.fetchOptimistic(c.value).then(l,_=>{lt(c.value.throwOnError,[_,o.getCurrentQuery()])?p(_):l(o.getCurrentResult())})):(U(),l(R))}};P(),U=z(c,P)});z(()=>d.error,l=>{if(d.isError&&!d.isFetching&<(c.value.throwOnError,[l,o.getCurrentQuery()]))throw l});const h=Dt(Ft(d));for(const l in d)typeof d[l]=="function"&&(h[l]=d[l]);return h.suspense=S,h.refetch=I,h}function jt(i,t){return kt(Ut,i)}const zt=["user","subscriptions"],Bt=["discord","permissions"],Lt=["guilds"],st=i=>Lt.concat(i),Wt=i=>st(i).concat("errors"),Nt=i=>st(i).concat("channels"),Vt=i=>st(i).concat("roles");export{st as a,Nt as b,zt as c,Bt as d,Vt as e,Lt as f,Wt as g,jt as u};