import{$d as e,Cu as t,Su as n,Xd as r,Yd as i,_u as a,au as o,bu as s,cu as c,du as l,fu as u,gu as d,hu as f,lu as p,mu as m,ou as h,pu as g,su as _,uu as v,vu as y,xu as b,yu as x}from"./messages-kZy_2fG-.js";import{t as ee}from"./with-selector-Bq6p_41G.js";import{n as S,r as te,t as C}from"./cookies-C6BqVyqT.js";import{n as w}from"./dist-A3SZ_duZ.js";var T=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},E=new class extends T{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},D={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},O=new class{#e=D;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function k(e){setTimeout(e,0)}var A=typeof window>`u`||`Deno`in globalThis;function j(){}function M(e,t){return typeof e==`function`?e(t):e}function N(e){return typeof e==`number`&&e>=0&&e!==1/0}function P(e,t){return Math.max(e+(t||0)-Date.now(),0)}function F(e,t){return typeof e==`function`?e(t):e}function I(e,t){return typeof e==`function`?e(t):e}function ne(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ie(o,t.options))return!1}else if(!ae(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function re(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(L(t.options.mutationKey)!==L(a))return!1}else if(!ae(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ie(e,t){return(t?.queryKeyHashFn||L)(e)}function L(e){return JSON.stringify(e,(e,t)=>le(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ae(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ae(e[n],t[n])):!1}var oe=Object.prototype.hasOwnProperty;function se(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ce(e)&&ce(t);if(!r&&!(le(e)&&le(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l{O.setTimeout(t,e)})}function fe(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:se(e,t)}function pe(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function me(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var he=Symbol();function ge(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===he?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function _e(e,t){return typeof e==`function`?e(...t):!!e}function ve(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var z=(()=>{let e=()=>A;return{isServer(){return e()},setIsServer(t){e=t}}})();function ye(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var be=k;function xe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=be,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var B=xe(),Se=new class extends T{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Ce(e){return Math.min(1e3*2**e,3e4)}function we(e){return(e??`online`)===`online`?Se.isOnline():!0}var Te=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ee(e){let t=!1,n=0,r,i=ye(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Te(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>E.isFocused()&&(e.networkMode===`always`||Se.isOnline())&&e.canRun(),u=()=>we(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(z.isServer()?0:3),o=e.retryDelay??Ce,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&nl()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var De=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),N(this.gcTime)&&(this.#e=O.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(z.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(O.clearTimeout(this.#e),this.#e=void 0)}},Oe=class extends De{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=je(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=je(this.options);e.data!==void 0&&(this.setState(Ae(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=fe(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(j).catch(j):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>I(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===he||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>F(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!P(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=ge(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=Ee({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Te&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Te){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...ke(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ae(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),B.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function ke(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:we(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ae(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function je(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Me=class extends T{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=ye(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Pe(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Fe(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Fe(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof I(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!R(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ie(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||F(this.options.staleTime,this.#t)!==F(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Re(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(j)),t}#g(){this.#b();let e=F(this.options.staleTime,this.#t);if(z.isServer()||this.#r.isStale||!N(e))return;let t=P(this.#r.dataUpdatedAt,e)+1;this.#d=O.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(z.isServer()||I(this.options.enabled,this.#t)===!1||!N(this.#p)||this.#p===0)&&(this.#f=O.setInterval(()=>{(this.options.refetchIntervalInBackground||E.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(O.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(O.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Pe(e,t),o=i&&Ie(e,n,t,r);(a||o)&&(l={...l,...ke(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=fe(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=fe(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Le(e,t),refetch:this.refetch,promise:this.#o,isEnabled:I(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=ye())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!R(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){B.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Ne(e,t){return I(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function Pe(e,t){return Ne(e,t)||e.state.data!==void 0&&Fe(e,t,t.refetchOnMount)}function Fe(e,t,n){if(I(t.enabled,e)!==!1&&F(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Le(e,t)}return!1}function Ie(e,t,n,r){return(e!==t||I(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Le(e,n)}function Le(e,t){return I(t.enabled,e)!==!1&&e.isStaleByTime(F(t.staleTime,e))}function Re(e,t){return!R(e.getCurrentResult(),t)}function ze(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ve(e,()=>t.signal,()=>n=!0)},u=ge(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?me:pe;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Ve:Be,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Be(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(ct.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Be(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ve(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function He(e,t){return t?Be(e,t)!=null:!1}function Ue(e,t){return!t||!e.getPreviousPageParam?!1:Ve(e,t)!=null}var We=class extends Me{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ze()})}getOptimisticResult(e){return e.behavior=ze(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:He(t,n.data),hasPreviousPage:Ue(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Ge=class extends De{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ke(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Ee({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),B.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ke(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var qe=class extends T{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),R(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&L(t.mutationKey)!==L(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ke();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){B.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},V=e(r(),1),Je=i(),Ye=V.createContext(void 0),Xe=e=>{let t=V.useContext(Ye);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Ze=({client:e,children:t})=>(V.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Je.jsx)(Ye.Provider,{value:e,children:t})),Qe=V.createContext(!1),$e=()=>V.useContext(Qe);Qe.Provider;function et(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var tt=V.createContext(et()),nt=()=>V.useContext(tt),rt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?_e(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},it=e=>{V.useEffect(()=>{e.clearReset()},[e])},at=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||_e(n,[e.error,r])),ot=(e,t)=>t.state.data===void 0,st=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},ct=(e,t)=>e.isLoading&&e.isFetching&&!t,lt=(e,t)=>e?.suspense&&t.isPending,ut=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function dt(e,t,n){let r=$e(),i=nt(),a=Xe(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,st(o),rt(o,i,s),it(i);let c=!a.getQueryCache().get(o.queryHash),[l]=V.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(V.useSyncExternalStore(V.useCallback(e=>{let t=d?l.subscribe(B.batchCalls(e)):j;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),V.useEffect(()=>{l.setOptions(o)},[o,l]),lt(o,u))throw ut(o,l,i);if(at({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!z.isServer()&&ct(u,r)&&(c?ut(o,l,i):s?.promise)?.catch(j).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function ft(e,t){return dt(e,Me,t)}function pt(e,t){return dt({...e,enabled:!0,suspense:!0,throwOnError:ot,placeholderData:void 0},Me,t)}function mt(e,t){let n=Xe(t),[r]=V.useState(()=>new qe(n,e));V.useEffect(()=>{r.setOptions(e)},[r,e]);let i=V.useSyncExternalStore(V.useCallback(e=>r.subscribe(B.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=V.useCallback((e,t)=>{r.mutate(e,t).catch(j)},[r]);if(i.error&&_e(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function ht(e,t){return dt(e,We,t)}var gt=ee();function _t(e,t){return e===t}function vt(e,t,n=_t){let r=(0,V.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,V.useCallback)(()=>e?.get(),[e]);return(0,gt.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var H=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function yt({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&(H.RecursedCheck|H.Recursed|H.Dirty|H.Pending)?a&(H.RecursedCheck|H.Recursed)?a&H.RecursedCheck?!(a&(H.Dirty|H.Pending))&&c(e,i)?(i.flags=a|(H.Recursed|H.Pending),a&=H.Mutable):a=H.None:i.flags=a&~H.Recursed|H.Pending:a=H.None:i.flags=a|H.Pending,a&H.Watching&&t(i),a&H.Mutable){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&H.Dirty)a=!0;else if((c&(H.Mutable|H.Dirty))===(H.Mutable|H.Dirty)){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&(H.Mutable|H.Pending))===(H.Mutable|H.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=~H.Pending;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&(H.Pending|H.Dirty))===H.Pending&&(n.flags=r|H.Dirty,(r&(H.Watching|H.RecursedCheck))===H.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function bt(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var xt=[],U=0,{link:St,unlink:Ct,propagate:wt,checkDirty:Tt,shallowPropagate:Et}=yt({update(e){return e._update()},notify(e){xt[Dt++]=e,e.flags&=~H.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=H.Mutable|H.Dirty,K(e))}}),W=0,Dt=0,G,Ot=0;function K(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Ct(n,e)}function kt(){if(!(Ot>0)){for(;W{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=G,o=t?.compare??Object.is;if(n)G=i,++U,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=H.Mutable|H.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{G=a,n&&(i.flags&=~H.RecursedCheck),K(i)}}};return n?(i.flags=H.Mutable|H.Dirty,i.get=function(){let e=i.flags;if(e&H.Dirty||e&H.Pending&&Tt(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Et(e)}}else e&H.Pending&&(i.flags=e&~H.Pending);return G!==void 0&&St(i,G,U),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(wt(e),Et(e),kt())}},i}function jt(e){let t=()=>{let t=G;G=n,++U,n.depsTail=void 0,n.flags=H.Watching|H.RecursedCheck;try{return e()}finally{G=t,n.flags&=~H.RecursedCheck,K(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:H.Watching|H.RecursedCheck,notify(){let e=this.flags;e&H.Dirty||e&H.Pending&&Tt(this.deps,this)?t():this.flags=H.Watching},stop(){this.flags=H.None,this.depsTail=void 0,K(this)}};return t(),n}var Mt=class{constructor(e){this.atom=At(e)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(bt(e))}},q=`access_token`,Nt=`auth_user`,Pt=`sidebar_state`,Ft=3600*24*7,It=/\{[^{}]+\}/g,Lt=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function Rt(){return Math.random().toString(36).slice(2,11)}function zt(e){let{baseUrl:t=``,Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:a,pathSerializer:o,headers:s,requestInitExt:c=void 0,...l}={...e};c=Lt()?c:void 0,t=qt(t);let u=[];async function d(e,d){let{baseUrl:f,fetch:p=r,Request:m=n,headers:h,params:g={},parseAs:_=`json`,querySerializer:v,bodySerializer:y=a??Wt,pathSerializer:b,body:x,middleware:ee=[],...S}=d||{},te=t;f&&(te=qt(f)??t);let C=typeof i==`function`?i:Ht(i);v&&(C=typeof v==`function`?v:Ht({...typeof i==`object`?i:{},...v}));let w=b||o||Ut,T=x===void 0?void 0:y(x,Kt(s,h,g.header)),E=Kt(T===void 0||T instanceof FormData?{}:{"Content-Type":`application/json`},s,h,g.header),D=[...u,...ee],O={redirect:`follow`,...l,...S,body:T,headers:E},k,A,j=new m(Gt(e,{baseUrl:te,params:g,querySerializer:C,pathSerializer:w}),O),M;for(let e in S)e in j||(j[e]=S[e]);if(D.length){k=Rt(),A=Object.freeze({baseUrl:te,fetch:p,parseAs:_,querySerializer:C,bodySerializer:y,pathSerializer:w});for(let t of D)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:j,schemaPath:e,params:g,options:A,id:k});if(n)if(n instanceof m)j=n;else if(n instanceof Response){M=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}if(!M){try{M=await p(j,c)}catch(t){let n=t;if(D.length)for(let t=D.length-1;t>=0;t--){let r=D[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:j,error:n,schemaPath:e,params:g,options:A,id:k});if(t){if(t instanceof Response){n=void 0,M=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(D.length)for(let t=D.length-1;t>=0;t--){let n=D[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:j,response:M,schemaPath:e,params:g,options:A,id:k});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);M=t}}}}let N=M.headers.get(`Content-Length`);if(M.status===204||j.method===`HEAD`||N===`0`&&!M.headers.get(`Transfer-Encoding`)?.includes(`chunked`))return M.ok?{data:void 0,response:M}:{error:void 0,response:M};if(M.ok)return{data:await(async()=>{if(_===`stream`)return M.body;if(_===`json`&&!N){let e=await M.text();return e?JSON.parse(e):void 0}return await M[_]()})(),response:M};let P=await M.text();try{P=JSON.parse(P)}catch{}return{error:P,response:M}}return{request(e,t,n){return d(t,{...n,method:e.toUpperCase()})},GET(e,t){return d(e,{...t,method:`GET`})},PUT(e,t){return d(e,{...t,method:`PUT`})},POST(e,t){return d(e,{...t,method:`POST`})},DELETE(e,t){return d(e,{...t,method:`DELETE`})},OPTIONS(e,t){return d(e,{...t,method:`OPTIONS`})},HEAD(e,t){return d(e,{...t,method:`HEAD`})},PATCH(e,t){return d(e,{...t,method:`PATCH`})},TRACE(e,t){return d(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(t)}},eject(...e){for(let t of e){let e=u.indexOf(t);e!==-1&&u.splice(e,1)}}}}function J(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function Bt(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(J(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function Vt(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(J(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function Ht(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(Vt(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof i==`object`){n.push(Bt(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(J(r,i,e))}}return n.join(`&`)}}function Ut(e,t){let n=e;for(let r of e.match(It)??[]){let e=r.substring(1,r.length-1),i=!1,a=`simple`;if(e.endsWith(`*`)&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!t||t[e]===void 0||t[e]===null)continue;let o=t[e];if(Array.isArray(o)){n=n.replace(r,Vt(e,o,{style:a,explode:i}));continue}if(typeof o==`object`){n=n.replace(r,Bt(e,o,{style:a,explode:i}));continue}if(a===`matrix`){n=n.replace(r,`;${J(e,o)}`);continue}n=n.replace(r,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return n}function Wt(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function Gt(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function Kt(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function qt(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}function Jt(e){let t=async({queryKey:[t,n,r],signal:i})=>{let a=e[t.toUpperCase()],{data:o,error:s,response:c}=await a(n,{signal:i,...r});if(s)throw s;return c.status===204||c.headers.get(`Content-Length`)===`0`?o??null:o},n=(e,n,...[r,i])=>({queryKey:r===void 0?[e,n]:[e,n,r],queryFn:t,...i});return{queryOptions:n,useQuery:(e,t,...[r,i,a])=>ft(n(e,t,r,i),a),useSuspenseQuery:(e,t,...[r,i,a])=>pt(n(e,t,r,i),a),useInfiniteQuery:(t,r,i,a,o)=>{let{pageParamName:s=`cursor`,...c}=a,{queryKey:l}=n(t,r,i);return ht({queryKey:l,queryFn:async({queryKey:[t,n,r],pageParam:i=0,signal:a})=>{let o=e[t.toUpperCase()],{data:c,error:l}=await o(n,{...r,signal:a,params:{...r?.params||{},query:{...r?.params?.query,[s]:i}}});if(l)throw l;return c},...c},o)},useMutation:(t,n,r,i)=>mt({mutationKey:[t,n],mutationFn:async r=>{let i=e[t.toUpperCase()],{data:a,error:o}=await i(n,r);if(o)throw o;return a},...r},i)}}var Yt={0:h,400:t,500:o,10001:n,10002:b,10003:s,10004:x,10005:y,10006:a,10007:d,10008:f,10009:m,10010:g,10011:u,10012:l,10013:v,10014:p,10015:c,10016:_};function Y(e){return Yt[e]?.()??Yt[0]()}var Xt={onRequest({request:e}){let t=C(q);if(t)try{let n=JSON.parse(t);n&&e.headers.set(`Authorization`,`Bearer ${n}`)}catch{}return e},async onResponse({response:e}){if(e.status===401){sn();let t=encodeURIComponent(window.location.pathname+window.location.search);return window.location.replace(`/sign-in?redirect=${t}`),e}if(e.status===400)try{let t=await e.clone().json(),n=t.status_code&&Y(t.status_code)||t.message||Y(0);w.error(n)}catch{w.error(Y(0))}return e.status>=500&&w.error(Y(500)),e}},X=zt({baseUrl:`/`});X.use(Xt);var Zt=Jt(X);function Qt(e,t){try{return JSON.parse(e)}catch{return t}}function $t(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function en(e){return $t()?.getItem(e)??void 0}function tn(e,t){$t()?.setItem(e,t)}function nn(e){$t()?.removeItem(e)}var Z={getToken:()=>Qt(C(`access_token`)||``,``),getUser:()=>Qt(en(`auth_user`)||``,null),setToken:e=>e?te(q,JSON.stringify(e)):S(q),setUser:e=>e?tn(Nt,JSON.stringify(e)):nn(Nt),clear:()=>{S(q),nn(Nt)}},rn=Z.getToken(),Q=new Mt({accessToken:rn,user:rn?Z.getUser():null}),$=null;function an(e){Z.setUser(e),Q.setState(t=>({...t,user:e}))}function on(e){let t=Q.state.accessToken;Z.setToken(e);let n=t!==e;n&&(Z.setUser(null),$=null),Q.setState(t=>({...t,accessToken:e,user:n?null:t.user})),e&&cn()}function sn(){Z.clear(),$=null,Q.setState(()=>({accessToken:``,user:null}))}function cn(){let{user:e,accessToken:t}=Q.state;return e?Promise.resolve(e):t?$||($=X.GET(`/admin/api/v1/auth/me`).then(({data:e})=>{let t=e?.data??null;return t&&an(t),t}).catch(()=>(sn(),null)).finally(()=>{$=null}),$):Promise.resolve(null)}function ln(){return vt(Q,e=>e)}export{ne as C,he as D,F as E,E as O,re as S,ae as T,Se as _,Zt as a,L as b,Ft as c,vt as d,ft as f,Oe as g,ze as h,ln as i,T as k,Pt as l,Ge as m,sn as n,X as o,Ze as p,on as r,q as s,Q as t,Mt as u,B as v,j as w,ie as x,M as y};