(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[888],{3454:function(t,e,r){"use strict";var n,i;t.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(i=r.g.process)?void 0:i.env)?r.g.process:r(7663)},6840:function(t,e,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_app",function(){return r(9044)}])},9044:function(t,e,r){"use strict";let n;r.r(e),r.d(e,{default:function(){return rt}});var i,s,o,u=r(5893);function a(t){let e={subscribe(e){let r=null,n=!1,i=!1,s=!1;function o(){if(null===r){s=!0;return}!i&&(i=!0,"function"==typeof r?r():r&&r.unsubscribe())}return r=t({next(t){n||e.next?.(t)},error(t){n||(n=!0,e.error?.(t),o())},complete(){n||(n=!0,e.complete?.(),o())}}),s&&o(),{unsubscribe:o}},pipe:(...t)=>(0===t.length?function(t){return t}:1===t.length?t[0]:function(e){return t.reduce((t,e)=>e(t),e)})(e)};return e}class l extends Error{constructor(t){super(t),this.name="ObservableAbortError",Object.setPrototypeOf(this,l.prototype)}}function c(t){let e=Object.create(null);for(let r in t)e[t[r]]=r;return e}let h={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};c(h),c(h);let f=()=>{},d=t=>(function t(e,r){return new Proxy(f,{get(n,i){if("string"==typeof i&&"then"!==i)return t(e,[...r,i])},apply(t,n,i){let s="apply"===r[r.length-1];return e({args:s?i.length>=2?i[1]:[]:i,path:s?r.slice(0,-1):r})}})})(t,[]),p=t=>new Proxy(f,{get(e,r){if("string"==typeof r&&"then"!==r)return t(r)}});class y extends Error{}function m(t){return!!t&&!Array.isArray(t)&&"object"==typeof t}class v extends Error{constructor(){super("Unable to transform response from server")}}function b(t,e){let r;try{r=function(t,e){if("error"in t){let r=e.transformer.deserialize(t.error);return{ok:!1,error:{...t,error:r}}}return{ok:!0,result:{...t.result,...(!t.result.type||"data"===t.result.type)&&{type:"data",data:e.transformer.deserialize(t.result.data)}}}}(t,e)}catch(t){throw new v}if(!r.ok&&(!m(r.error.error)||"number"!=typeof r.error.error.code)||r.ok&&!m(r.result))throw new v;return r}class g extends Error{static from(t,e={}){return t instanceof g||t instanceof Error&&"TRPCClientError"===t.name?(e.meta&&(t.meta={...t.meta,...e.meta}),t):m(t)&&m(t.error)&&"number"==typeof t.error.code&&"string"==typeof t.error.message?new g(t.error.message,{...e,result:t}):t instanceof Error?new g(t.message,{...e,cause:function(t){if(t instanceof Error)return t;let e=typeof t;if("undefined"!==e&&"function"!==e&&null!==t){if("object"!==e)return Error(String(t));if(t&&!Array.isArray(t)&&"object"==typeof t){let e=new y;for(let r in t)e[r]=t[r];return e}}}(t)}):new g("Unknown error",{...e,cause:t})}constructor(t,e){let r=e?.cause;super(t,{cause:r}),this.meta=e?.meta,this.cause=r,this.shape=e?.result?.error,this.data=e?.result?.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,g.prototype)}}let w=t=>"function"==typeof t;function O(t){var e;return{url:t.url.toString().replace(/\/$/,""),fetch:t.fetch,AbortController:(e=t.AbortController)?e:"undefined"!=typeof window&&window.AbortController?window.AbortController:"undefined"!=typeof globalThis&&globalThis.AbortController?globalThis.AbortController:null}}let C={query:"GET",mutation:"POST"};function E(t){return"input"in t?t.runtime.transformer.serialize(t.input):function(t){let e={};for(let r=0;rt.runtime.transformer.serialize(e)))}let R=t=>{let e=t.url+"/"+t.path,r=[];if("inputs"in t&&r.push("batch=1"),"query"===t.type){let e=E(t);void 0!==e&&r.push(`input=${encodeURIComponent(JSON.stringify(e))}`)}return r.length&&(e+="?"+r.join("&")),e},S=t=>{if("query"===t.type)return;let e=E(t);return void 0!==e?JSON.stringify(e):void 0},q=t=>P({...t,contentTypeHeader:"application/json",getUrl:R,getBody:S});async function x(t,e){let r=t.getUrl(t),n=t.getBody(t),{type:i}=t,s=await t.headers();/* istanbul ignore if -- @preserve */if("subscription"===i)throw Error("Subscriptions should use wsLink");let o={...t.contentTypeHeader?{"content-type":t.contentTypeHeader}:{},...t.batchModeHeader?{"trpc-batch-mode":t.batchModeHeader}:{},...s};return(function(t){if(t)return t;if("undefined"!=typeof window&&w(window.fetch))return window.fetch;if("undefined"!=typeof globalThis&&w(globalThis.fetch))return globalThis.fetch;throw Error("No fetch implementation found")})(t.fetch)(r,{method:C[i],signal:e?.signal,body:n,headers:o})}function P(t){let e=t.AbortController?new t.AbortController:null,r={},n=!1;return{promise:new Promise((i,s)=>{x(t,e).then(t=>(r.response=t,n=!0,t.json())).then(t=>{r.responseJSON=t,i({json:t,meta:r})}).catch(t=>{n=!0,s(g.from(t,{meta:r}))})}),cancel:()=>{n||e?.abort()}}}let Q=()=>{throw Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function T(t){let e=null,r=null,n=()=>{clearTimeout(r),r=null,e=null};function i(){let r=function(e){let r=[[]],n=0;for(;;){let i=e[n];if(!i)break;let s=r[r.length-1];if(i.aborted){i.reject?.(Error("Aborted")),n++;continue}if(t.validate(s.concat(i).map(t=>t.key))){s.push(i),n++;continue}if(0===s.length){i.reject?.(Error("Input is too big for a single dispatch")),n++;continue}r.push([])}return r}(e);for(let e of(n(),r)){if(!e.length)continue;let r={items:e,cancel:Q};for(let t of e)t.batch=r;let n=(t,e)=>{let n=r.items[t];n.resolve?.(e),n.batch=null,n.reject=null,n.resolve=null},{promise:i,cancel:s}=t.fetch(r.items.map(t=>t.key),n);r.cancel=s,i.then(t=>{for(let e=0;e{for(let e of r.items)e.reject?.(t),e.batch=null})}}return{load:function(t){let n={aborted:!1,key:t,batch:null,resolve:Q,reject:Q},s=new Promise((t,r)=>{n.reject=r,n.resolve=t,e||(e=[]),e.push(n)});return r||(r=setTimeout(i)),{promise:s,cancel:()=>{n.aborted=!0,n.batch?.items.every(t=>t.aborted)&&(n.batch.cancel(),n.batch=null)}}}}}function D(t){return function(e){let r=O(e),n=e.maxURLLength??1/0;return i=>{let s=s=>({validate:t=>{if(n===1/0)return!0;let e=t.map(t=>t.path).join(","),o=t.map(t=>t.input);return R({...r,runtime:i,type:s,path:e,inputs:o}).length<=n},fetch:t({...r,runtime:i,type:s,opts:e})}),o=T(s("query")),u=T(s("mutation")),l={query:o,subscription:T(s("subscription")),mutation:u};return({op:t})=>a(e=>{let r;let{promise:n,cancel:s}=l[t.type].load(t);return n.then(t=>{r=t;let n=b(t.json,i);if(!n.ok){e.error(g.from(n.error,{meta:t.meta}));return}e.next({context:t.meta,result:n.result}),e.complete()}).catch(t=>{e.error(g.from(t,{meta:r?.meta}))}),()=>{s()}})}}}let A=D(t=>e=>{let r=e.map(t=>t.path).join(","),n=e.map(t=>t.input),{promise:i,cancel:s}=q({...t,path:r,inputs:n,headers:()=>t.opts.headers?"function"==typeof t.opts.headers?t.opts.headers({opList:e}):t.opts.headers:{}});return{promise:i.then(t=>(Array.isArray(t.json)?t.json:e.map(()=>t.json)).map(e=>({meta:t.meta,json:e}))),cancel:s}});function I(t){return e=>{let r=O(e);return n=>({op:i})=>a(s=>{let o;let{path:u,input:a,type:l}=i,{promise:c,cancel:h}=t.requester({...r,runtime:n,type:l,path:u,input:a,headers:()=>e.headers?"function"==typeof e.headers?e.headers({op:i}):e.headers:{}});return c.then(t=>{o=t.meta;let e=b(t.json,n);if(!e.ok){s.error(g.from(e.error,{meta:o}));return}s.next({context:t.meta,result:e.result}),s.complete()}).catch(t=>{s.error(g.from(t,{meta:o}))}),()=>{h()}})}}I({requester:q});let M={css:{query:["72e3ff","3fb0d8"],mutation:["c5a3fc","904dfc"],subscription:["ff49e1","d83fbe"]},ansi:{regular:{query:["\x1b[30;46m","\x1b[97;46m"],mutation:["\x1b[30;45m","\x1b[97;45m"],subscription:["\x1b[30;42m","\x1b[97;42m"]},bold:{query:["\x1b[1;30;46m","\x1b[1;97;46m"],mutation:["\x1b[1;30;45m","\x1b[1;97;45m"],subscription:["\x1b[1;30;42m","\x1b[1;97;42m"]}}},k=({c:t=console,colorMode:e="css"})=>r=>{let n=r.input,i="undefined"!=typeof FormData&&n instanceof FormData?Object.fromEntries(n):n,{parts:s,args:o}=function(t){let{direction:e,type:r,path:n,id:i,input:s}=t,o=[],u=[];if("ansi"===t.colorMode){let[s,a]=M.ansi.regular[r],[l,c]=M.ansi.bold[r];return o.push("up"===e?s:a,"up"===e?">>":"<<",r,"up"===e?l:c,`#${i}`,n,"\x1b[0m"),"up"===e?u.push({input:t.input}):u.push({input:t.input,result:"result"in t.result?t.result.result:t.result,elapsedMs:t.elapsedMs}),{parts:o,args:u}}let[a,l]=M.css[r],c=` background-color: #${"up"===e?a:l}; color: ${"up"===e?"black":"white"}; padding: 2px; `;return o.push("%c","up"===e?">>":"<<",r,`#${i}`,`%c${n}%c`,"%O"),u.push(c,`${c}; font-weight: bold;`,`${c}; font-weight: normal;`),"up"===e?u.push({input:s,context:t.context}):u.push({input:s,result:t.result,elapsedMs:t.elapsedMs,context:t.context}),{parts:o,args:u}}({...r,colorMode:e,input:i});t["down"===r.direction&&r.result&&(r.result instanceof Error||"error"in r.result.result)?"error":"log"].apply(null,[s.join(" ")].concat(o))};class F{$request({type:t,input:e,path:r,context:n={}}){var i;return(i={links:this.links,op:{id:++this.requestId,type:t,path:r,input:e,context:n}},a(t=>(function t(e=0,r=i.op){let n=i.links[e];if(!n)throw Error("No more links to execute - did you forget to add an ending link?");return n({op:r,next:r=>t(e+1,r)})})().subscribe(t))).pipe(t=>{let e=0,r=null,n=[];return{subscribe:i=>(e++,n.push(i),r||(r=t.subscribe({next(t){for(let e of n)e.next?.(t)},error(t){for(let e of n)e.error?.(t)},complete(){for(let t of n)t.complete?.()}})),{unsubscribe(){e--,function(){if(0===e&&r){let t=r;r=null,t.unsubscribe()}}();let t=n.findIndex(t=>t===i);t>-1&&n.splice(t,1)}})}})}requestAsPromise(t){var e;let r;let{promise:n,abort:i}=(e=this.$request(t),{promise:new Promise((t,n)=>{let i=!1;function s(){i||(i=!0,n(new l("This operation was aborted.")),o.unsubscribe())}let o=e.subscribe({next(e){i=!0,t(e),s()},error(t){i=!0,n(t),s()},complete(){i=!0,s()}});r=s}),abort:r});return new Promise((e,r)=>{t.signal?.addEventListener("abort",i),n.then(t=>{e(t.result.data)}).catch(t=>{r(g.from(t))})})}query(t,e,r){return this.requestAsPromise({type:"query",path:t,input:e,context:r?.context,signal:r?.signal})}mutation(t,e,r){return this.requestAsPromise({type:"mutation",path:t,input:e,context:r?.context,signal:r?.signal})}subscription(t,e,r){return this.$request({type:"subscription",path:t,input:e,context:r?.context}).subscribe({next(t){"started"===t.result.type?r.onStarted?.():"stopped"===t.result.type?r.onStopped?.():r.onData?.(t.result.data)},error(t){r.onError?.(t)},complete(){r.onComplete?.()}})}constructor(t){this.requestId=0;let e=(()=>{let e=t.transformer;return e?"input"in e?t.transformer:{input:e,output:e}:{input:{serialize:t=>t,deserialize:t=>t},output:{serialize:t=>t,deserialize:t=>t}}})();this.runtime={transformer:{serialize:t=>e.input.serialize(t),deserialize:t=>e.output.deserialize(t)},combinedTransformer:e},this.links=t.links.map(t=>t(this.runtime))}}let j={query:"query",mutate:"mutation",subscribe:"subscription"},U=t=>j[t];async function K(t){let e=t.parse??JSON.parse;await N(t.readableStream,r=>{if(t.signal?.aborted||!r||"}"===r)return;let n=r.indexOf(":"),i=r.substring(2,n-1),s=r.substring(n+1);t.onSingle(Number(i),e(s))},t.textDecoder)}async function N(t,e,r){let n="",i=t=>{let i=r.decode(t).split("\n");if(1===i.length)n+=i[0];else if(i.length>1){e(n+i[0]);for(let t=1;t{t.on("data",i),t.on("end",e)}),e(n)}async function L(t,e){let r=t.getReader(),n=await r.read();for(;!n.done;)e(n.value),n=await r.read()}let _=(t,e)=>{let r=t.AbortController?new t.AbortController:null;return{cancel:()=>r?.abort(),promise:x({...t,contentTypeHeader:"application/json",batchModeHeader:"stream",getUrl:R,getBody:S},r).then(async n=>{if(!n.body)throw Error("Received response without body");let i={response:n};return K({readableStream:n.body,onSingle:e,parse:t=>({json:JSON.parse(t),meta:i}),signal:r?.signal,textDecoder:t.textDecoder})})}};D(t=>{let e=function(t){if(t)return t;if("undefined"!=typeof window&&window.TextDecoder)return new window.TextDecoder;if("undefined"!=typeof globalThis&&globalThis.TextDecoder)return new globalThis.TextDecoder;throw Error("No TextDecoder implementation found")}(t.opts.textDecoder);return(r,n)=>{let i=r.map(t=>t.path).join(","),s=r.map(t=>t.input),{cancel:o,promise:u}=_({...t,textDecoder:e,path:i,inputs:s,headers:()=>t.opts.headers?"function"==typeof t.opts.headers?t.opts.headers({opList:r}):t.opts.headers:{}},(t,e)=>{n(t,e)});return{promise:u.then(()=>[]),cancel:o}}});let z=t=>{if("input"in t){if(!(t.input instanceof FormData))throw Error("Input is not FormData");return t.input}};I({requester:t=>{if("mutation"!==t.type)throw Error("We only handle mutations with formdata");return P({...t,getUrl:()=>`${t.url}/${t.path}`,getBody:z})}});var H=r(7294);let B=H.createContext(void 0),V=H.createContext(!1);function G(t,e){return t||(e&&"undefined"!=typeof window?(window.ReactQueryClientContext||(window.ReactQueryClientContext=B),window.ReactQueryClientContext):B)}let $=({context:t}={})=>{let e=H.useContext(G(t,H.useContext(V)));if(!e)throw Error("No QueryClient set, use QueryClientProvider to set one");return e},J=({client:t,children:e,context:r,contextSharing:n=!1})=>{H.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]);let i=G(r,n);return H.createElement(V.Provider,{value:!r&&n},H.createElement(i.Provider,{value:t},e))};function W(t){return t.state.isPaused}function X(t){return"success"===t.state.status}let Y=({children:t,options:e,state:r})=>(!function(t,e={}){let r=$({context:e.context}),n=H.useRef(e);n.current=e,H.useMemo(()=>{t&&function(t,e,r){if("object"!=typeof e||null===e)return;let n=t.getMutationCache(),i=t.getQueryCache(),s=e.mutations||[],o=e.queries||[];s.forEach(e=>{var i;n.build(t,{...null==r?void 0:null==(i=r.defaultOptions)?void 0:i.mutations,mutationKey:e.mutationKey},e.state)}),o.forEach(({queryKey:e,state:n,queryHash:s})=>{var o;let u=i.get(s);if(u){if(u.state.dataUpdatedAt=0&&t!==1/0}function tn(t,e){return t.filter(t=>!e.includes(t))}function ti(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ts(t,e,r){return tm(t)?"function"==typeof e?{...r,queryKey:t,queryFn:e}:{...e,queryKey:t}:t}function to(t,e,r){return tm(t)?[{...e,queryKey:t},r]:[t||{},e]}function tu(t,e){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:o,stale:u}=t;if(tm(o)){if(n){if(e.queryHash!==tl(o,e.options))return!1}else{if(!th(e.queryKey,o))return!1}}if("all"!==r){let t=e.isActive();if("active"===r&&!t||"inactive"===r&&t)return!1}return("boolean"!=typeof u||e.isStale()===u)&&(void 0===i||i===e.state.fetchStatus)&&(!s||!!s(e))}function ta(t,e){let{exact:r,fetching:n,predicate:i,mutationKey:s}=t;if(tm(s)){if(!e.options.mutationKey)return!1;if(r){if(tc(e.options.mutationKey)!==tc(s))return!1}else{if(!th(e.options.mutationKey,s))return!1}}return("boolean"!=typeof n||"loading"===e.state.status===n)&&(!i||!!i(e))}function tl(t,e){return((null==e?void 0:e.queryKeyHashFn)||tc)(t)}function tc(t){return JSON.stringify(t,(t,e)=>tp(e)?Object.keys(e).sort().reduce((t,r)=>(t[r]=e[r],t),{}):e)}function th(t,e){return t===e||typeof t==typeof e&&!!t&&!!e&&"object"==typeof t&&"object"==typeof e&&!Object.keys(e).some(r=>!th(t[r],e[r]))}function tf(t,e){if(t&&!e||e&&!t)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}function td(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function tp(t){if(!ty(t))return!1;let e=t.constructor;if(void 0===e)return!0;let r=e.prototype;return!!(ty(r)&&r.hasOwnProperty("isPrototypeOf"))}function ty(t){return"[object Object]"===Object.prototype.toString.call(t)}function tm(t){return Array.isArray(t)}function tv(t){return new Promise(e=>{setTimeout(e,t)})}function tb(t){tv(0).then(t)}function tg(t,e,r){return null!=r.isDataEqual&&r.isDataEqual(t,e)?t:"function"==typeof r.structuralSharing?r.structuralSharing(t,e):!1!==r.structuralSharing?function t(e,r){if(e===r)return e;let n=td(e)&&td(r);if(n||tp(e)&&tp(r)){let i=n?e.length:Object.keys(e).length,s=n?r:Object.keys(r),o=s.length,u=n?[]:{},a=0;for(let i=0;i{t()},n=t=>{t()},i=n=>{e?t.push(n):tb(()=>{r(n)})},s=()=>{let e=t;t=[],e.length&&tb(()=>{n(()=>{e.forEach(t=>{r(t)})})})};return{batch:t=>{let r;e++;try{r=t()}finally{--e||s()}return r},batchCalls:t=>(...e)=>{i(()=>{t(...e)})},schedule:i,setNotifyFunction:t=>{r=t},setBatchNotifyFunction:t=>{n=t}}}();class tO{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){let e={listener:t};return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}class tC extends tO{constructor(){super(),this.setup=t=>{if(!tt&&window.addEventListener){let 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(){if(!this.hasListeners()){var t;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&&(this.focused=t,this.onFocus())}onFocus(){this.listeners.forEach(({listener:t})=>{t()})}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}}let tE=new tC,tR=["online","offline"];class tS extends tO{constructor(){super(),this.setup=t=>{if(!tt&&window.addEventListener){let e=()=>t();return tR.forEach(t=>{window.addEventListener(t,e,!1)}),()=>{tR.forEach(t=>{window.removeEventListener(t,e)})}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var t;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&&(this.online=t,this.onOnline())}onOnline(){this.listeners.forEach(({listener:t})=>{t()})}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}}let tq=new tS;function tx(t){return Math.min(1e3*2**t,3e4)}function tP(t){return(null!=t?t:"online")!=="online"||tq.isOnline()}class tQ{constructor(t){this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}}function tT(t){return t instanceof tQ}function tD(t){let e,r,n,i=!1,s=0,o=!1,u=new Promise((t,e)=>{r=t,n=e}),a=()=>!tE.isFocused()||"always"!==t.networkMode&&!tq.isOnline(),l=n=>{o||(o=!0,null==t.onSuccess||t.onSuccess(n),null==e||e(),r(n))},c=r=>{o||(o=!0,null==t.onError||t.onError(r),null==e||e(),n(r))},h=()=>new Promise(r=>{e=t=>{let e=o||!a();return e&&r(t),e},null==t.onPause||t.onPause()}).then(()=>{e=void 0,o||null==t.onContinue||t.onContinue()}),f=()=>{let e;if(!o){try{e=t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(l).catch(e=>{var r,n;if(o)return;let u=null!=(r=t.retry)?r:3,l=null!=(n=t.retryDelay)?n:tx,d="function"==typeof l?l(s,e):l,p=!0===u||"number"==typeof u&&s{if(a())return h()}).then(()=>{i?c(e):f()})})}};return tP(t.networkMode)?f():h().then(f),{promise:u,cancel:e=>{o||(c(new tQ(e)),null==t.abort||t.abort())},continue:()=>(null==e?void 0:e())?u:Promise.resolve(),cancelRetry:()=>{i=!0},continueRetry:()=>{i=!1}}}class tA extends tO{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.size&&(this.currentQuery.addObserver(this),tI(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return tM(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return tM(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(t,e){let r=this.options,n=this.currentQuery;if(this.options=this.client.defaultQueryOptions(t),tf(r,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),this.updateQuery();let i=this.hasListeners();i&&tk(this.currentQuery,n,this.options,r)&&this.executeFetch(),this.updateResult(e),i&&(this.currentQuery!==n||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&this.updateStaleTimeout();let s=this.computeRefetchInterval();i&&(this.currentQuery!==n||this.options.enabled!==r.enabled||s!==this.currentRefetchInterval)&&this.updateRefetchInterval(s)}getOptimisticResult(t){let e=this.client.getQueryCache().build(this.client,t),r=this.createResult(e,t);return t.keepPreviousData||(void 0!==t.placeholderData?!r.isPlaceholderData:tf(this.getCurrentResult(),r))||(this.currentResult=r,this.currentResultOptions=this.options,this.currentResultState=this.currentQuery.state),r}getCurrentResult(){return this.currentResult}trackResult(t){let e={};return Object.keys(t).forEach(r=>{Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(r),t[r])})}),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){let e=this.client.defaultQueryOptions(t),r=this.client.getQueryCache().build(this.client,e);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,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(te)),e}updateStaleTimeout(){if(this.clearStaleTimeout(),tt||this.currentResult.isStale||!tr(this.options.staleTime))return;let t=ti(this.currentResult.dataUpdatedAt,this.options.staleTime);this.staleTimeoutId=setTimeout(()=>{this.currentResult.isStale||this.updateResult()},t+1)}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,!tt&&!1!==this.options.enabled&&tr(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval(()=>{(this.options.refetchIntervalInBackground||tE.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){let r;let n=this.currentQuery,i=this.options,s=this.currentResult,o=this.currentResultState,u=this.currentResultOptions,a=t!==n,l=a?t.state:this.currentQueryInitialState,c=a?this.currentResult:this.previousQueryResult,{state:h}=t,{dataUpdatedAt:f,error:d,errorUpdatedAt:p,fetchStatus:y,status:m}=h,v=!1,b=!1;if(e._optimisticResults){let r=this.hasListeners(),s=!r&&tI(t,e),o=r&&tk(t,n,e,i);(s||o)&&(y=tP(t.options.networkMode)?"fetching":"paused",f||(m="loading")),"isRestoring"===e._optimisticResults&&(y="idle")}if(e.keepPreviousData&&!h.dataUpdatedAt&&null!=c&&c.isSuccess&&"error"!==m)r=c.data,f=c.dataUpdatedAt,m=c.status,v=!0;else if(e.select&&void 0!==h.data){if(s&&h.data===(null==o?void 0:o.data)&&e.select===this.selectFn)r=this.selectResult;else try{this.selectFn=e.select,r=e.select(h.data),r=tg(null==s?void 0:s.data,r,e),this.selectResult=r,this.selectError=null}catch(t){this.selectError=t}}else r=h.data;if(void 0!==e.placeholderData&&void 0===r&&"loading"===m){let t;if(null!=s&&s.isPlaceholderData&&e.placeholderData===(null==u?void 0:u.placeholderData))t=s.data;else if(t="function"==typeof e.placeholderData?e.placeholderData():e.placeholderData,e.select&&void 0!==t)try{t=e.select(t),this.selectError=null}catch(t){this.selectError=t}void 0!==t&&(m="success",r=tg(null==s?void 0:s.data,t,e),b=!0)}this.selectError&&(d=this.selectError,r=this.selectResult,p=Date.now(),m="error");let g="fetching"===y,w="loading"===m,O="error"===m;return{status:m,fetchStatus:y,isLoading:w,isSuccess:"success"===m,isError:O,isInitialLoading:w&&g,data:r,dataUpdatedAt:f,error:d,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>l.dataUpdateCount||h.errorUpdateCount>l.errorUpdateCount,isFetching:g,isRefetching:g&&!w,isLoadingError:O&&0===h.dataUpdatedAt,isPaused:"paused"===y,isPlaceholderData:b,isPreviousData:v,isRefetchError:O&&0!==h.dataUpdatedAt,isStale:tF(t,e),refetch:this.refetch,remove:this.remove}}updateResult(t){let e=this.currentResult,r=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,tf(r,e))return;this.currentResult=r;let n={cache:!0};(null==t?void 0:t.listeners)!==!1&&(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.trackedProps.size)return!0;let n=new Set(null!=r?r:this.trackedProps);return this.options.useErrorBoundary&&n.add("error"),Object.keys(this.currentResult).some(t=>this.currentResult[t]!==e[t]&&n.has(t))})()&&(n.listeners=!0),this.notify({...n,...t})}updateQuery(){let t=this.client.getQueryCache().build(this.client,this.options);if(t===this.currentQuery)return;let 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){let e={};"success"===t.type?e.onSuccess=!t.manual:"error"!==t.type||tT(t.error)||(e.onError=!0),this.updateResult(e),this.hasListeners()&&this.updateTimers()}notify(t){tw.batch(()=>{var e,r,n,i,s,o,u,a;t.onSuccess?(null==(e=(r=this.options).onSuccess)||e.call(r,this.currentResult.data),null==(n=(i=this.options).onSettled)||n.call(i,this.currentResult.data,null)):t.onError&&(null==(s=(o=this.options).onError)||s.call(o,this.currentResult.error),null==(u=(a=this.options).onSettled)||u.call(a,void 0,this.currentResult.error)),t.listeners&&this.listeners.forEach(({listener:t})=>{t(this.currentResult)}),t.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})})}}function tI(t,e){return!1!==e.enabled&&!t.state.dataUpdatedAt&&!("error"===t.state.status&&!1===e.retryOnMount)||t.state.dataUpdatedAt>0&&tM(t,e,e.refetchOnMount)}function tM(t,e,r){if(!1!==e.enabled){let n="function"==typeof r?r(t):r;return"always"===n||!1!==n&&tF(t,e)}return!1}function tk(t,e,r,n){return!1!==r.enabled&&(t!==e||!1===n.enabled)&&(!r.suspense||"error"!==t.state.status)&&tF(t,r)}function tF(t,e){return t.isStaleByTime(e.staleTime)}let tj=r(1688).useSyncExternalStore,tU=H.createContext((n=!1,{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n})),tK=()=>H.useContext(tU),tN=H.createContext(!1),tL=()=>H.useContext(tN);function t_(t,e){return"function"==typeof t?t(...e):!!t}tN.Provider;let tz=(t,e)=>{(t.suspense||t.useErrorBoundary)&&!e.isReset()&&(t.retryOnMount=!1)},tH=t=>{H.useEffect(()=>{t.clearReset()},[t])},tB=({result:t,errorResetBoundary:e,useErrorBoundary:r,query:n})=>t.isError&&!e.isReset()&&!t.isFetching&&t_(r,[t.error,n]),tV=t=>{t.suspense&&"number"!=typeof t.staleTime&&(t.staleTime=1e3)},tG=(t,e)=>t.isLoading&&t.isFetching&&!e,t$=(t,e,r)=>(null==t?void 0:t.suspense)&&tG(e,r),tJ=(t,e,r)=>e.fetchOptimistic(t).then(({data:e})=>{null==t.onSuccess||t.onSuccess(e),null==t.onSettled||t.onSettled(e,null)}).catch(e=>{r.clearReset(),null==t.onError||t.onError(e),null==t.onSettled||t.onSettled(void 0,e)});function tW(t,e){let r=$({context:t.context}),n=tL(),i=tK(),s=r.defaultQueryOptions(t);s._optimisticResults=n?"isRestoring":"optimistic",s.onError&&(s.onError=tw.batchCalls(s.onError)),s.onSuccess&&(s.onSuccess=tw.batchCalls(s.onSuccess)),s.onSettled&&(s.onSettled=tw.batchCalls(s.onSettled)),tV(s),tz(s,i),tH(i);let[o]=H.useState(()=>new e(r,s)),u=o.getOptimisticResult(s);if(tj(H.useCallback(t=>{let e=n?()=>void 0:o.subscribe(tw.batchCalls(t));return o.updateResult(),e},[o,n]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),H.useEffect(()=>{o.setOptions(s,{listeners:!1})},[s,o]),t$(s,u,n))throw tJ(s,o,i);if(tB({result:u,errorResetBoundary:i,useErrorBoundary:s.useErrorBoundary,query:o.getCurrentQuery()}))throw u.error;return s.notifyOnChangeProps?u:o.trackResult(u)}let tX=console;class tY{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),tr(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(t){this.cacheTime=Math.max(this.cacheTime||0,null!=t?t:tt?1/0:3e5)}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class tZ extends tY{constructor(t){super(),this.defaultOptions=t.defaultOptions,this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.logger=t.logger||tX,this.observers=[],this.state=t.state||t0(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...this.defaultOptions,...t},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(t){this.dispatch({type:"setState",state:t})}addObserver(t){this.observers.includes(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(){var t,e;return null!=(t=null==(e=this.retryer)?void 0:e.continue())?t:this.execute()}async execute(){var t,e,r,n,i,s,o,u,a,l,c,h,f,d,p,y,m,v,b,g;let w="loading"===this.state.status;try{if(!w){this.dispatch({type:"loading",variables:this.options.variables}),await (null==(a=(l=this.mutationCache.config).onMutate)?void 0:a.call(l,this.state.variables,this));let t=await (null==(c=(h=this.options).onMutate)?void 0:c.call(h,this.state.variables));t!==this.state.context&&this.dispatch({type:"loading",context:t,variables:this.state.variables})}let f=await (()=>{var t;return this.retryer=tD({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(t,e)=>{this.dispatch({type:"failed",failureCount:t,error:e})},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})();return await (null==(t=(e=this.mutationCache.config).onSuccess)?void 0:t.call(e,f,this.state.variables,this.state.context,this)),await (null==(r=(n=this.options).onSuccess)?void 0:r.call(n,f,this.state.variables,this.state.context)),await (null==(i=(s=this.mutationCache.config).onSettled)?void 0:i.call(s,f,null,this.state.variables,this.state.context,this)),await (null==(o=(u=this.options).onSettled)?void 0:o.call(u,f,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:f}),f}catch(t){try{throw await (null==(f=(d=this.mutationCache.config).onError)?void 0:f.call(d,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==(m=(v=this.mutationCache.config).onSettled)?void 0:m.call(v,void 0,t,this.state.variables,this.state.context,this)),await (null==(b=(g=this.options).onSettled)?void 0:b.call(g,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:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"loading":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!tP(this.options.networkMode),status:"loading",variables:t.variables};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"};case"setState":return{...e,...t.state}}})(this.state),tw.batch(()=>{this.observers.forEach(e=>{e.onMutationUpdate(t)}),this.mutationCache.notify({mutation:this,type:"updated",action:t})})}}function t0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class t1 extends tO{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){var e;let r=this.options;this.options=this.client.defaultMutationOptions(t),tf(r,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this}),null==(e=this.currentMutation)||e.setOptions(this.options)}onUnsubscribe(){if(!this.hasListeners()){var t;null==(t=this.currentMutation)||t.removeObserver(this)}}onMutationUpdate(t){this.updateResult();let 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(){let t=this.currentMutation?this.currentMutation.state:t0(),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){tw.batch(()=>{if(this.mutateOptions&&this.hasListeners()){var e,r,n,i,s,o,u,a;t.onSuccess?(null==(e=(r=this.mutateOptions).onSuccess)||e.call(r,this.currentResult.data,this.currentResult.variables,this.currentResult.context),null==(n=(i=this.mutateOptions).onSettled)||n.call(i,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)):t.onError&&(null==(s=(o=this.mutateOptions).onError)||s.call(o,this.currentResult.error,this.currentResult.variables,this.currentResult.context),null==(u=(a=this.mutateOptions).onSettled)||u.call(a,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context))}t.listeners&&this.listeners.forEach(({listener:t})=>{t(this.currentResult)})})}}function t2(){}function t3(){return{onFetch:t=>{t.fetchFn=()=>{var e,r,n,i,s,o;let u;let a=null==(e=t.fetchOptions)?void 0:null==(r=e.meta)?void 0:r.refetchPage,l=null==(n=t.fetchOptions)?void 0:null==(i=n.meta)?void 0:i.fetchMore,c=null==l?void 0:l.pageParam,h=(null==l?void 0:l.direction)==="forward",f=(null==l?void 0:l.direction)==="backward",d=(null==(s=t.state.data)?void 0:s.pages)||[],p=(null==(o=t.state.data)?void 0:o.pageParams)||[],y=p,m=!1,v=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>{var e,r;return null!=(e=t.signal)&&e.aborted?m=!0:null==(r=t.signal)||r.addEventListener("abort",()=>{m=!0}),t.signal}})},b=t.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+t.options.queryHash+"'")),g=(t,e,r,n)=>(y=n?[e,...y]:[...y,e],n?[r,...t]:[...t,r]),w=(e,r,n,i)=>{if(m)return Promise.reject("Cancelled");if(void 0===n&&!r&&e.length)return Promise.resolve(e);let s={queryKey:t.queryKey,pageParam:n,meta:t.options.meta};return v(s),Promise.resolve(b(s)).then(t=>g(e,n,t,i))};if(d.length){if(h){let e=void 0!==c,r=e?c:t4(t.options,d);u=w(d,e,r)}else if(f){let e=void 0!==c,r=e?c:t9(t.options,d);u=w(d,e,r,!0)}else{y=[];let e=void 0===t.options.getNextPageParam;u=!a||!d[0]||a(d[0],0,d)?w([],e,p[0]):Promise.resolve(g([],p[0],d[0]));for(let r=1;r{if(!a||!d[r]||a(d[r],r,d)){let i=e?p[r]:t4(t.options,n);return w(n,e,i)}return Promise.resolve(g(n,p[r],d[r]))})}}else u=w([]);return u.then(t=>({pages:t,pageParams:y}))}}}}function t4(t,e){return null==t.getNextPageParam?void 0:t.getNextPageParam(e[e.length-1],e)}function t9(t,e){return null==t.getPreviousPageParam?void 0:t.getPreviousPageParam(e[0],e)}class t7 extends tA{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:t3()},e)}getOptimisticResult(t){return t.behavior=t3(),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 r,n,i,s,o,u;let{state:a}=t,l=super.createResult(t,e),{isFetching:c,isRefetching:h}=l,f=c&&(null==(r=a.fetchMeta)?void 0:null==(n=r.fetchMore)?void 0:n.direction)==="forward",d=c&&(null==(i=a.fetchMeta)?void 0:null==(s=i.fetchMore)?void 0:s.direction)==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:function(t,e){if(t.getNextPageParam&&Array.isArray(e)){let r=t4(t,e);return null!=r&&!1!==r}}(e,null==(o=a.data)?void 0:o.pages),hasPreviousPage:function(t,e){if(t.getPreviousPageParam&&Array.isArray(e)){let r=t9(t,e);return null!=r&&!1!==r}}(e,null==(u=a.data)?void 0:u.pages),isFetchingNextPage:f,isFetchingPreviousPage:d,isRefetching:h&&!f&&!d}}}class t6 extends tO{constructor(t,e){super(),this.client=t,this.queries=[],this.result=[],this.observers=[],this.observersMap={},e&&this.setQueries(e)}onSubscribe(){1===this.listeners.size&&this.observers.forEach(t=>{t.subscribe(e=>{this.onUpdate(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.observers.forEach(t=>{t.destroy()})}setQueries(t,e){this.queries=t,tw.batch(()=>{let t=this.observers,r=this.findMatchingObservers(this.queries);r.forEach(t=>t.observer.setOptions(t.defaultedQueryOptions,e));let n=r.map(t=>t.observer),i=Object.fromEntries(n.map(t=>[t.options.queryHash,t])),s=n.map(t=>t.getCurrentResult()),o=n.some((e,r)=>e!==t[r]);(t.length!==n.length||o)&&(this.observers=n,this.observersMap=i,this.result=s,this.hasListeners()&&(tn(t,n).forEach(t=>{t.destroy()}),tn(n,t).forEach(t=>{t.subscribe(e=>{this.onUpdate(t,e)})}),this.notify()))})}getCurrentResult(){return this.result}getQueries(){return this.observers.map(t=>t.getCurrentQuery())}getObservers(){return this.observers}getOptimisticResult(t){return this.findMatchingObservers(t).map(t=>t.observer.getOptimisticResult(t.defaultedQueryOptions))}findMatchingObservers(t){let e=this.observers,r=new Map(e.map(t=>[t.options.queryHash,t])),n=t.map(t=>this.client.defaultQueryOptions(t)),i=n.flatMap(t=>{let e=r.get(t.queryHash);return null!=e?[{defaultedQueryOptions:t,observer:e}]:[]}),s=new Set(i.map(t=>t.defaultedQueryOptions.queryHash)),o=n.filter(t=>!s.has(t.queryHash)),u=new Set(i.map(t=>t.observer)),a=e.filter(t=>!u.has(t)),l=t=>{let e=this.client.defaultQueryOptions(t),r=this.observersMap[e.queryHash];return null!=r?r:new tA(this.client,e)},c=o.map((t,e)=>{if(t.keepPreviousData){let r=a[e];if(void 0!==r)return{defaultedQueryOptions:t,observer:r}}return{defaultedQueryOptions:t,observer:l(t)}});return i.concat(c).sort((t,e)=>n.indexOf(t.defaultedQueryOptions)-n.indexOf(e.defaultedQueryOptions))}onUpdate(t,e){let r=this.observers.indexOf(t);-1!==r&&(this.result=function(t,e,r){let n=t.slice(0);return n[e]=r,n}(this.result,r,e),this.notify())}notify(){tw.batch(()=>{this.listeners.forEach(({listener:t})=>{t(this.result)})})}}function t8(t,e){return t.length?void 0===e?[t]:[t,e]:[]}function t5(t,e){return d(r=>{let n=r.args,i=[t,...r.path],s=i.pop(),o=i.join(".");if("useMutation"===s)return e[s](o,...n);let[u,...a]=n,l=t8(o,u);if("getQueryKey"===s)return Z(l,a[0]??"any");if("_def"===s)return{path:i};if(s.startsWith("useSuspense")){let t=a[0]||{},r=e["useSuspenseQuery"===s?"useQuery":"useInfiniteQuery"](l,{...t,suspense:!0,enabled:!0});return[r.data,r]}return e[s](l,...a)})}let et=["client","ssrContext","ssrState","abortOnUnmount"],ee=(0,H.createContext)(null);function er(t){return p(e=>{if("client"===e){var r;return r=t.client,p(t=>r.hasOwnProperty(t)?r[t]:"__untypedClient"===t?r:d(({path:e,args:n})=>{let i=[t,...e],s=U(i.pop()),o=i.join(".");return r[s](o,...n)}))}return et.includes(e)?t[e]:d(({path:r,args:n})=>{let i=[e,...r],s=i.pop(),o=i.join("."),{queryKey:u,rest:a,updater:l}=(t=>{if(["setData","setInfiniteData"].includes(t)){let[t,e,...r]=n;return{queryKey:t8(o,t),updater:e,rest:r}}let[e,...r]=n;return{queryKey:t8(o,e),rest:r}})(s);return({fetch:()=>t.fetchQuery(u,...a),fetchInfinite:()=>t.fetchInfiniteQuery(u,...a),prefetch:()=>t.prefetchQuery(u,...a),prefetchInfinite:()=>t.prefetchInfiniteQuery(u,...a),ensureData:()=>t.ensureQueryData(u,...a),invalidate:()=>t.invalidateQueries(u,...a),reset:()=>t.resetQueries(u,...a),refetch:()=>t.refetchQueries(u,...a),cancel:()=>t.cancelQuery(u,...a),setData:()=>{t.setQueryData(u,l,...a)},setInfiniteData:()=>{t.setInfiniteQueryData(u,l,...a)},getData:()=>t.getQueryData(u),getInfiniteData:()=>t.getInfiniteQueryData(u)})[s]()})})}function en(t,e){let[r,n]=t;return[r,n,e?.trpc]}function ei(t){let{path:e}=t;return(0,H.useMemo)(()=>({path:e}),[e])}function es(t){return function(t){let e=(t?.overrides??t?.unstable_overrides)?.useMutation?.onSuccess??(t=>t.originalFn()),r=t?.context??ee,n=t?.reactQueryContext;function i(){return H.useContext(r)}function s(t,e,r){let{queryClient:n,ssrState:s}=i();return s&&"mounted"!==s&&n.getQueryCache().find(Z(t,e))?.state.status==="error"?{retryOnMount:!1,...r}:r}return{Provider:t=>{let{abortOnUnmount:e=!1,client:n,queryClient:i,ssrContext:s}=t,[o,u]=(0,H.useState)(t.ssrState??!1);return(0,H.useEffect)(()=>{u(t=>!!t&&"mounted")},[]),H.createElement(r.Provider,{value:{abortOnUnmount:e,queryClient:i,client:n,ssrContext:s??null,ssrState:o,fetchQuery:(0,H.useCallback)((t,e)=>i.fetchQuery({...e,queryKey:Z(t,"query"),queryFn:()=>n.query(...en(t,e))}),[n,i]),fetchInfiniteQuery:(0,H.useCallback)((t,e)=>i.fetchInfiniteQuery({...e,queryKey:Z(t,"infinite"),queryFn:({pageParam:r})=>{let[i,s]=t,o={...s,cursor:r};return n.query(...en([i,o],e))}}),[n,i]),prefetchQuery:(0,H.useCallback)((t,e)=>i.prefetchQuery({...e,queryKey:Z(t,"query"),queryFn:()=>n.query(...en(t,e))}),[n,i]),prefetchInfiniteQuery:(0,H.useCallback)((t,e)=>i.prefetchInfiniteQuery({...e,queryKey:Z(t,"infinite"),queryFn:({pageParam:r})=>{let[i,s]=t,o={...s,cursor:r};return n.query(...en([i,o],e))}}),[n,i]),ensureQueryData:(0,H.useCallback)((t,e)=>i.ensureQueryData({...e,queryKey:Z(t,"query"),queryFn:()=>n.query(...en(t,e))}),[n,i]),invalidateQueries:(0,H.useCallback)((t,e,r)=>i.invalidateQueries({...e,queryKey:Z(t,"any")},r),[i]),resetQueries:(0,H.useCallback)((...t)=>{let[e,r,n]=t;return i.resetQueries({...r,queryKey:Z(e,"any")},n)},[i]),refetchQueries:(0,H.useCallback)((...t)=>{let[e,r,n]=t;return i.refetchQueries({...r,queryKey:Z(e,"any")},n)},[i]),cancelQuery:(0,H.useCallback)(t=>i.cancelQueries({queryKey:Z(t,"any")}),[i]),setQueryData:(0,H.useCallback)((...t)=>{let[e,...r]=t;return i.setQueryData(Z(e,"query"),...r)},[i]),getQueryData:(0,H.useCallback)((...t)=>{let[e,...r]=t;return i.getQueryData(Z(e,"query"),...r)},[i]),setInfiniteQueryData:(0,H.useCallback)((...t)=>{let[e,...r]=t;return i.setQueryData(Z(e,"infinite"),...r)},[i]),getInfiniteQueryData:(0,H.useCallback)((...t)=>{let[e,...r]=t;return i.getQueryData(Z(e,"infinite"),...r)},[i])}},t.children)},createClient:t=>new F(t),useContext:i,useUtils:i,useQuery:function(e,r){let o=i();if(!o)throw Error("Unable to retrieve application context. Did you forget to wrap your App inside `withTRPC` HoC?");let{abortOnUnmount:u,client:a,ssrState:l,queryClient:c,prefetchQuery:h}=o,f=c.getQueryDefaults(Z(e,"query"));"undefined"!=typeof window||"prepass"!==l||r?.trpc?.ssr===!1||(r?.enabled??f?.enabled)===!1||c.getQueryCache().find(Z(e,"query"))||h(e,r);let d=s(e,"query",{...f,...r}),p=r?.trpc?.abortOnUnmount??t?.abortOnUnmount??u,y=tW(ts({...d,queryKey:Z(e,"query"),queryFn:t=>{let r={...d,trpc:{...d?.trpc,...p?{signal:t.signal}:{}}};return a.query(...en(e,r))},context:n},void 0,void 0),tA);return y.trpc=ei({path:e[0]}),y},useQueries:(t,e)=>{let{ssrState:r,queryClient:n,prefetchQuery:s,client:o}=i(),u=t(d(t=>{let e=t.path.join("."),[r,n]=t.args;return{queryKey:t8(e,r),queryFn:()=>o.query(e,r,n?.trpc),...n}}));if("undefined"==typeof window&&"prepass"===r)for(let t of u)t.trpc?.ssr===!1||n.getQueryCache().find(Z(t.queryKey,"query"))||s(t.queryKey,t);return function({queries:t,context:e}){let r=$({context:e}),n=tL(),i=tK(),s=H.useMemo(()=>t.map(t=>{let e=r.defaultQueryOptions(t);return e._optimisticResults=n?"isRestoring":"optimistic",e}),[t,r,n]);s.forEach(t=>{tV(t),tz(t,i)}),tH(i);let[o]=H.useState(()=>new t6(r,s)),u=o.getOptimisticResult(s);tj(H.useCallback(t=>n?()=>void 0:o.subscribe(tw.batchCalls(t)),[o,n]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),H.useEffect(()=>{o.setQueries(s,{listeners:!1})},[s,o]);let a=u.some((t,e)=>t$(s[e],t,n))?u.flatMap((t,e)=>{let r=s[e],u=o.getObservers()[e];if(r&&u){if(t$(r,t,n))return tJ(r,u,i);tG(t,n)&&tJ(r,u,i)}return[]}):[];if(a.length>0)throw Promise.all(a);let l=o.getQueries(),c=u.find((t,e)=>{var r,n;return tB({result:t,errorResetBoundary:i,useErrorBoundary:null!=(r=null==(n=s[e])?void 0:n.useErrorBoundary)&&r,query:l[e]})});if(null!=c&&c.error)throw c.error;return u}({queries:u.map(t=>({...t,queryKey:Z(t.queryKey,"query")})),context:e})},useMutation:function(t,r){let{client:s}=i(),o=$({context:n}),u=Array.isArray(t)?t[0]:t,a=o.getMutationDefaults([u.split(".")]),l=function(t,e,r){var n,i;let s=(n=void 0,i=void 0,tm(t)?"function"==typeof n?{...i,mutationKey:t,mutationFn:n}:{...n,mutationKey:t}:"function"==typeof t?{...n,mutationFn:t}:{...t}),o=$({context:s.context}),[u]=H.useState(()=>new t1(o,s));H.useEffect(()=>{u.setOptions(s)},[u,s]);let a=tj(H.useCallback(t=>u.subscribe(tw.batchCalls(t)),[u]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l=H.useCallback((t,e)=>{u.mutate(t,e).catch(t2)},[u]);if(a.error&&t_(u.options.useErrorBoundary,[a.error]))throw a.error;return{...a,mutate:l,mutateAsync:a.mutate}}({...r,mutationKey:[u.split(".")],mutationFn:t=>s.mutation(...en([u,t],r)),context:n,onSuccess:(...t)=>e({originalFn:()=>r?.onSuccess?.(...t)??a?.onSuccess?.(...t),queryClient:o,meta:r?.meta??a?.meta??{}})});return l.trpc=ei({path:u}),l},useSubscription:/* istanbul ignore next -- @preserve */function(t,e){let r=e?.enabled??!0,n=tc(t),{client:s}=i(),o=(0,H.useRef)(e);o.current=e,(0,H.useEffect)(()=>{if(!r)return;let[e,n]=t,i=!1,u=s.subscription(e,n??void 0,{onStarted:()=>{i||o.current.onStarted?.()},onData:t=>{i||o.current.onData(t)},onError:t=>{i||o.current.onError?.(t)}});return()=>{i=!0,u.unsubscribe()}},[n,r])},useDehydratedState:(t,e)=>(0,H.useMemo)(()=>e?t.runtime.transformer.deserialize(e):e,[e,t]),useInfiniteQuery:function(t,e){let[r,o]=t,{client:u,ssrState:a,prefetchInfiniteQuery:l,queryClient:c,abortOnUnmount:h}=i(),f=c.getQueryDefaults(Z(t,"infinite"));"undefined"!=typeof window||"prepass"!==a||e?.trpc?.ssr===!1||(e?.enabled??f?.enabled)===!1||c.getQueryCache().find(Z(t,"infinite"))||l(t,{...f,...e});let d=s(t,"infinite",{...f,...e}),p=e?.trpc?.abortOnUnmount??h,y=tW(ts({...d,queryKey:Z(t,"infinite"),queryFn:t=>{let n={...d,trpc:{...d?.trpc,...p?{signal:t.signal}:{}}},i={...o??{},cursor:t.pageParam??e?.initialCursor};return u.query(...en([r,i],n))},context:n},void 0,void 0),t7);return y.trpc=ei({path:r}),y}}}(t)}class eo extends tY{constructor(t){super(),this.abortSignalConsumed=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.logger=t.logger||tX,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||function(t){let e="function"==typeof t.initialData?t.initialData():t.initialData,r=void 0!==e,n=r?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?null!=n?n:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"loading",fetchStatus:"idle"}}(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(t){this.options={...this.defaultOptions,...t},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.cache.remove(this)}setData(t,e){let r=tg(this.state.data,t,this.options);return this.dispatch({data:r,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),r}setState(t,e){this.dispatch({type:"setState",state:t,setStateOptions:e})}cancel(t){var e;let r=this.promise;return null==(e=this.retryer)||e.cancel(t),r?r.then(te).catch(te):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||!ti(this.state.dataUpdatedAt,t)}onFocus(){var t;let e=this.observers.find(t=>t.shouldFetchOnWindowFocus());e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}onOnline(){var t;let e=this.observers.find(t=>t.shouldFetchOnReconnect());e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(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 r,n,i,s;if("idle"!==this.state.fetchStatus){if(this.state.dataUpdatedAt&&null!=e&&e.cancelRefetch)this.cancel({silent:!0});else if(this.promise)return null==(i=this.retryer)||i.continueRetry(),this.promise}if(t&&this.setOptions(t),!this.options.queryFn){let t=this.observers.find(t=>t.options.queryFn);t&&this.setOptions(t.options)}let o=function(){if("function"==typeof AbortController)return new AbortController}(),u={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},a=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>{if(o)return this.abortSignalConsumed=!0,o.signal}})};a(u);let l={fetchOptions:e,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(u)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'")};a(l),null==(r=this.options.behavior)||r.onFetch(l),this.revertState=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(n=l.fetchOptions)?void 0:n.meta))&&this.dispatch({type:"fetch",meta:null==(s=l.fetchOptions)?void 0:s.meta});let c=t=>{if(tT(t)&&t.silent||this.dispatch({type:"error",error:t}),!tT(t)){var e,r,n,i;null==(e=(r=this.cache.config).onError)||e.call(r,t,this),null==(n=(i=this.cache.config).onSettled)||n.call(i,this.state.data,t,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=tD({fn:l.fetchFn,abort:null==o?void 0:o.abort.bind(o),onSuccess:t=>{var e,r,n,i;if(void 0===t){c(Error(this.queryHash+" data is undefined"));return}this.setData(t),null==(e=(r=this.cache.config).onSuccess)||e.call(r,t,this),null==(n=(i=this.cache.config).onSettled)||n.call(i,t,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:c,onFail:(t,e)=>{this.dispatch({type:"failed",failureCount:t,error:e})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(t){this.state=(e=>{var r,n;switch(t.type){case"failed":return{...e,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null!=(r=t.meta)?r:null,fetchStatus:tP(this.options.networkMode)?"fetching":"paused",...!e.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(n=t.dataUpdatedAt)?n:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let i=t.error;if(tT(i)&&i.revert&&this.revertState)return{...this.revertState,fetchStatus:"idle"};return{...e,error:i,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}})(this.state),tw.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate(t)}),this.cache.notify({query:this,type:"updated",action:t})})}}class eu extends tO{constructor(t){super(),this.config=t||{},this.queries=[],this.queriesMap={}}build(t,e,r){var n;let i=e.queryKey,s=null!=(n=e.queryHash)?n:tl(i,e),o=this.get(s);return o||(o=new eo({cache:this,logger:t.getLogger(),queryKey:i,queryHash:s,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(i)}),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){let 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(){tw.batch(()=>{this.queries.forEach(t=>{this.remove(t)})})}get(t){return this.queriesMap[t]}getAll(){return this.queries}find(t,e){let[r]=to(t,e);return void 0===r.exact&&(r.exact=!0),this.queries.find(t=>tu(r,t))}findAll(t,e){let[r]=to(t,e);return Object.keys(r).length>0?this.queries.filter(t=>tu(r,t)):this.queries}notify(t){tw.batch(()=>{this.listeners.forEach(({listener:e})=>{e(t)})})}onFocus(){tw.batch(()=>{this.queries.forEach(t=>{t.onFocus()})})}onOnline(){tw.batch(()=>{this.queries.forEach(t=>{t.onOnline()})})}}class ea extends tO{constructor(t){super(),this.config=t||{},this.mutations=[],this.mutationId=0}build(t,e,r){let n=new tZ({mutationCache:this,logger:t.getLogger(),mutationId:++this.mutationId,options:t.defaultMutationOptions(e),state:r,defaultOptions:e.mutationKey?t.getMutationDefaults(e.mutationKey):void 0});return this.add(n),n}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(){tw.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=>ta(t,e))}findAll(t){return this.mutations.filter(e=>ta(t,e))}notify(t){tw.batch(()=>{this.listeners.forEach(({listener:e})=>{e(t)})})}resumePausedMutations(){var t;return this.resuming=(null!=(t=this.resuming)?t:Promise.resolve()).then(()=>{let t=this.mutations.filter(t=>t.state.isPaused);return tw.batch(()=>t.reduce((t,e)=>t.then(()=>e.continue().catch(te)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}class el{constructor(t={}){this.queryCache=t.queryCache||new eu,this.mutationCache=t.mutationCache||new ea,this.logger=t.logger||tX,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,1===this.mountCount&&(this.unsubscribeFocus=tE.subscribe(()=>{tE.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=tq.subscribe(()=>{tq.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var t,e;this.mountCount--,0===this.mountCount&&(null==(t=this.unsubscribeFocus)||t.call(this),this.unsubscribeFocus=void 0,null==(e=this.unsubscribeOnline)||e.call(this),this.unsubscribeOnline=void 0)}isFetching(t,e){let[r]=to(t,e);return r.fetchStatus="fetching",this.queryCache.findAll(r).length}isMutating(t){return this.mutationCache.findAll({...t,fetching:!0}).length}getQueryData(t,e){var r;return null==(r=this.queryCache.find(t,e))?void 0:r.state.data}ensureQueryData(t,e,r){let n=ts(t,e,r),i=this.getQueryData(n.queryKey);return i?Promise.resolve(i):this.fetchQuery(n)}getQueriesData(t){return this.getQueryCache().findAll(t).map(({queryKey:t,state:e})=>[t,e.data])}setQueryData(t,e,r){let n=this.queryCache.find(t),i=null==n?void 0:n.state.data,s="function"==typeof e?e(i):e;if(void 0===s)return;let o=ts(t),u=this.defaultQueryOptions(o);return this.queryCache.build(this,u).setData(s,{...r,manual:!0})}setQueriesData(t,e,r){return tw.batch(()=>this.getQueryCache().findAll(t).map(({queryKey:t})=>[t,this.setQueryData(t,e,r)]))}getQueryState(t,e){var r;return null==(r=this.queryCache.find(t,e))?void 0:r.state}removeQueries(t,e){let[r]=to(t,e),n=this.queryCache;tw.batch(()=>{n.findAll(r).forEach(t=>{n.remove(t)})})}resetQueries(t,e,r){let[n,i]=to(t,e,r),s=this.queryCache,o={type:"active",...n};return tw.batch(()=>(s.findAll(n).forEach(t=>{t.reset()}),this.refetchQueries(o,i)))}cancelQueries(t,e,r){let[n,i={}]=to(t,e,r);return void 0===i.revert&&(i.revert=!0),Promise.all(tw.batch(()=>this.queryCache.findAll(n).map(t=>t.cancel(i)))).then(te).catch(te)}invalidateQueries(t,e,r){let[n,i]=to(t,e,r);return tw.batch(()=>{var t,e;if(this.queryCache.findAll(n).forEach(t=>{t.invalidate()}),"none"===n.refetchType)return Promise.resolve();let r={...n,type:null!=(t=null!=(e=n.refetchType)?e:n.type)?t:"active"};return this.refetchQueries(r,i)})}refetchQueries(t,e,r){let[n,i]=to(t,e,r),s=Promise.all(tw.batch(()=>this.queryCache.findAll(n).filter(t=>!t.isDisabled()).map(t=>{var e;return t.fetch(void 0,{...i,cancelRefetch:null==(e=null==i?void 0:i.cancelRefetch)||e,meta:{refetchPage:n.refetchPage}})}))).then(te);return null!=i&&i.throwOnError||(s=s.catch(te)),s}fetchQuery(t,e,r){let n=ts(t,e,r),i=this.defaultQueryOptions(n);void 0===i.retry&&(i.retry=!1);let s=this.queryCache.build(this,i);return s.isStaleByTime(i.staleTime)?s.fetch(i):Promise.resolve(s.state.data)}prefetchQuery(t,e,r){return this.fetchQuery(t,e,r).then(te).catch(te)}fetchInfiniteQuery(t,e,r){let n=ts(t,e,r);return n.behavior=t3(),this.fetchQuery(n)}prefetchInfiniteQuery(t,e,r){return this.fetchInfiniteQuery(t,e,r).then(te).catch(te)}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){let r=this.queryDefaults.find(e=>tc(t)===tc(e.queryKey));r?r.defaultOptions=e:this.queryDefaults.push({queryKey:t,defaultOptions:e})}getQueryDefaults(t){if(!t)return;let e=this.queryDefaults.find(e=>th(t,e.queryKey));return null==e?void 0:e.defaultOptions}setMutationDefaults(t,e){let r=this.mutationDefaults.find(e=>tc(t)===tc(e.mutationKey));r?r.defaultOptions=e:this.mutationDefaults.push({mutationKey:t,defaultOptions:e})}getMutationDefaults(t){if(!t)return;let e=this.mutationDefaults.find(e=>th(t,e.mutationKey));return null==e?void 0:e.defaultOptions}defaultQueryOptions(t){if(null!=t&&t._defaulted)return t;let e={...this.defaultOptions.queries,...this.getQueryDefaults(null==t?void 0:t.queryKey),...t,_defaulted:!0};return!e.queryHash&&e.queryKey&&(e.queryHash=tl(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()}}let ec=t=>t.queryClient??new el(t.queryClientConfig);function eh(t){let e=t.state.error;if(e instanceof Error&&"TRPCClientError"===e.name){let r={message:e.message,data:e.data,shape:e.shape};return{...t,state:{...t.state,error:r}}}return t}var ef=function(){function t(){this.keyToValue=new Map,this.valueToKey=new Map}return t.prototype.set=function(t,e){this.keyToValue.set(t,e),this.valueToKey.set(e,t)},t.prototype.getByKey=function(t){return this.keyToValue.get(t)},t.prototype.getByValue=function(t){return this.valueToKey.get(t)},t.prototype.clear=function(){this.keyToValue.clear(),this.valueToKey.clear()},t}(),ed=function(){function t(t){this.generateIdentifier=t,this.kv=new ef}return t.prototype.register=function(t,e){this.kv.getByValue(t)||(e||(e=this.generateIdentifier(t)),this.kv.set(e,t))},t.prototype.clear=function(){this.kv.clear()},t.prototype.getIdentifier=function(t){return this.kv.getByValue(t)},t.prototype.getValue=function(t){return this.kv.getByKey(t)},t}(),ep=(i=function(t,e){return(i=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),ey=function(t){function e(){var e=t.call(this,function(t){return t.name})||this;return e.classToAllowedProps=new Map,e}return ep(e,t),e.prototype.register=function(e,r){"object"==typeof r?(r.allowProps&&this.classToAllowedProps.set(e,r.allowProps),t.prototype.register.call(this,e,r.identifier)):t.prototype.register.call(this,e,r)},e.prototype.getAllowedProps=function(t){return this.classToAllowedProps.get(t)},e}(ed),em=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o};function ev(t,e){Object.entries(t).forEach(function(t){var r=em(t,2),n=r[0];return e(r[1],n)})}function eb(t,e){return -1!==t.indexOf(e)}function eg(t,e){for(var r=0;r0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o},ek=function(t,e){for(var r=0,n=e.length,i=t.length;r0?"Infinity":"-Infinity"},Number),eF(function(t){return 0===t&&1/t==-1/0},"number",function(){return"-0"},Number),eF(function(t){return t instanceof URL},"URL",function(t){return t.toString()},function(t){return new URL(t)})];function eU(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}var eK=eU(function(t,e){return!!ex(t)&&!!e.symbolRegistry.getIdentifier(t)},function(t,e){return["symbol",e.symbolRegistry.getIdentifier(t)]},function(t){return t.description},function(t,e,r){var n=r.symbolRegistry.getValue(e[1]);if(!n)throw Error("Trying to deserialize unknown symbol");return n}),eN=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce(function(t,e){return t[e.name]=e,t},{}),eL=eU(function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},function(t){return["typed-array",t.constructor.name]},function(t){return ek([],eM(t))},function(t,e){var r=eN[e[1]];if(!r)throw Error("Trying to deserialize unknown typed array");return new r(t)});function e_(t,e){return null!=t&&!!t.constructor&&!!e.classRegistry.getIdentifier(t.constructor)}var ez=eU(e_,function(t,e){return["class",e.classRegistry.getIdentifier(t.constructor)]},function(t,e){var r=e.classRegistry.getAllowedProps(t.constructor);if(!r)return eI({},t);var n={};return r.forEach(function(e){n[e]=t[e]}),n},function(t,e,r){var n=r.classRegistry.getValue(e[1]);if(!n)throw Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(n.prototype),t)}),eH=eU(function(t,e){return!!e.customTransformerRegistry.findApplicable(t)},function(t,e){return["custom",e.customTransformerRegistry.findApplicable(t).name]},function(t,e){return e.customTransformerRegistry.findApplicable(t).serialize(t)},function(t,e,r){var n=r.customTransformerRegistry.findByName(e[1]);if(!n)throw Error("Trying to deserialize unknown custom value");return n.deserialize(t)}),eB=[ez,eK,eH,eL],eV=function(t,e){var r=eg(eB,function(r){return r.isApplicable(t,e)});if(r)return{value:r.transform(t,e),type:r.annotation(t,e)};var n=eg(ej,function(r){return r.isApplicable(t,e)});if(n)return{value:n.transform(t,e),type:n.annotation}},eG={};ej.forEach(function(t){eG[t.annotation]=t});var e$=function(t,e,r){if(eR(e))switch(e[0]){case"symbol":return eK.untransform(t,e,r);case"class":return ez.untransform(t,e,r);case"custom":return eH.untransform(t,e,r);case"typed-array":return eL.untransform(t,e,r);default:throw Error("Unknown transformation: "+e)}else{var n=eG[e];if(!n)throw Error("Unknown transformation: "+e);return n.untransform(t,r)}},eJ=function(t,e){for(var r=t.keys();e>0;)r.next(),e--;return r.next().value};function eW(t){if(eb(t,"__proto__"))throw Error("__proto__ is not allowed as a property");if(eb(t,"prototype"))throw Error("prototype is not allowed as a property");if(eb(t,"constructor"))throw Error("constructor is not allowed as a property")}var eX=function(t,e){eW(e);for(var r=0;r0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o},e0=function(t,e){for(var r=0,n=e.length,i=t.length;rs(t)||o(t)||!1;var e4=function(){return(e4=Object.assign||function(t){for(var e,r=1,n=arguments.length;r0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o},e7=function(t,e){for(var r=0,n=e.length,i=t.length;rt(e,r)):!function(t){if("Object"!==e2(t))return!1;let e=Object.getPrototypeOf(t);return!!e&&e.constructor===Object&&e===Object.prototype}(e)?e:[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].reduce((n,i)=>{if(e3(r.props)&&!r.props.includes(i))return n;let s=t(e[i],r);return function(t,e,r,n,i){let s=({}).propertyIsEnumerable.call(n,e)?"enumerable":"nonenumerable";"enumerable"===s&&(t[e]=r),i&&"nonenumerable"===s&&Object.defineProperty(t,e,{value:r,enumerable:!1,writable:!0,configurable:!0})}(n,i,s,e,r.nonenumerable),n},{})}(i);return(null==s?void 0:s.values)&&(e=o,r=s.values,n=this,function t(e,r,n){if(void 0===n&&(n=[]),e){if(!eR(e)){ev(e,function(e,i){return t(e,r,e0(e0([],eZ(n)),eZ(eA(i))))});return}var i=eZ(e,2),s=i[0],o=i[1];o&&ev(o,function(e,i){t(e,r,e0(e0([],eZ(n)),eZ(eA(i))))}),r(s,n)}}(r,function(t,r){e=eY(e,r,function(e){return e$(e,t,n)})}),o=e),(null==s?void 0:s.referentialEqualities)&&(o=function(t,e){function r(e,r){var n=eX(t,eA(r));e.map(eA).forEach(function(e){t=eY(t,e,function(){return n})})}if(eR(e)){var n=eZ(e,2),i=n[0],s=n[1];i.forEach(function(e){t=eY(t,eA(e),function(){return t})}),s&&ev(s,r)}else ev(e,r);return t}(o,s.referentialEqualities)),o},t.prototype.stringify=function(t){return JSON.stringify(this.serialize(t))},t.prototype.parse=function(t){return this.deserialize(JSON.parse(t))},t.prototype.registerClass=function(t,e){this.classRegistry.register(t,e)},t.prototype.registerSymbol=function(t,e){this.symbolRegistry.register(t,e)},t.prototype.registerCustom=function(t,e){this.customTransformerRegistry.register(e4({name:e},t))},t.prototype.allowErrorProps=function(){for(var t,e=[],r=0;r"",e5=/* istanbul ignore file -- @preserve */function(t){let e=es(t),n=function(t){let{config:e}=t;return n=>{let i=function(t){let e=es(t),r=p(t=>"useContext"===t||"useUtils"===t?()=>{let t=e.useUtils();return(0,H.useMemo)(()=>er(t),[t])}:e.hasOwnProperty(t)?e[t]:t5(t,e));return{...e,proxy:r}}(t),s=r=>{let[s]=(0,H.useState)(()=>{if(r.trpc)return r.trpc;let n=e({}),s=ec(n),o=i.createClient(n);return{abortOnUnmount:n.abortOnUnmount,queryClient:s,trpcClient:o,ssrState:!!t.ssr&&"mounting",ssrContext:null}}),{queryClient:o,trpcClient:u,ssrState:a,ssrContext:l}=s,c=i.useDehydratedState(u,r.pageProps?.trpcState);return H.createElement(i.Provider,{abortOnUnmount:s.abortOnUnmount??!1,client:u,queryClient:o,ssrState:a,ssrContext:l},H.createElement(J,{client:o},H.createElement(Y,{state:c},H.createElement(n,Object.assign({},r)))))};(n.getInitialProps??t.ssr)&&(s.getInitialProps=async i=>{let s=async()=>{if("function"==typeof t.ssr){if("undefined"!=typeof window)return!1;try{return await t.ssr({ctx:i.ctx})}catch(t){return!1}}return t.ssr},o=await s(),u=i.AppTree,a=!!i.Component,l=a?i.ctx:i,c={};if(n.getInitialProps){let t=await n.getInitialProps(i);c={...a?t.pageProps??{}:t,...c}}let h=t=>a?{pageProps:t}:t;if("undefined"!=typeof window||!o)return h(c);let f=e({ctx:l}),d=new F(f),p=ec(f),y={pageProps:c,trpc:{config:f,trpcClient:d,queryClient:p,ssrState:"prepass",ssrContext:l}},m=await r.e(774).then(r.t.bind(r,7762,19));for(;m.renderToString((0,H.createElement)(u,y)),p.isFetching();)await new Promise(t=>{let e=p.getQueryCache().subscribe(r=>{r?.query.getObserversCount()===0&&(t(),e())})});let v=function(t,e={}){let r=[],n=[];if(!1!==e.dehydrateMutations){let n=e.shouldDehydrateMutation||W;t.getMutationCache().getAll().forEach(t=>{n(t)&&r.push({mutationKey:t.options.mutationKey,state:t.state})})}if(!1!==e.dehydrateQueries){let r=e.shouldDehydrateQuery||X;t.getQueryCache().getAll().forEach(t=>{r(t)&&n.push({state:t.state,queryKey:t.queryKey,queryHash:t.queryHash})})}return{mutations:r,queries:n}}(p,{shouldDehydrateQuery:t=>!("idle"===t.state.fetchStatus&&"loading"===t.state.status)}),b={...v,queries:v.queries.map(eh),mutations:v.mutations.map(eh)};c.trpcState=d.runtime.combinedTransformer.output.serialize(b);let g=h(c);if("responseMeta"in t){let e=t.responseMeta?.({ctx:l,clientErrors:[...v.queries,...v.mutations].map(t=>t.state.error).flatMap(t=>t instanceof Error&&"TRPCClientError"===t.name?[t]:[])})??{};for(let[t,r]of Object.entries(e.headers??{}))"string"==typeof r&&l.res?.setHeader(t,r);e.status&&l.res&&(l.res.statusCode=e.status)}return g});let o=n.displayName??n.name??"Component";return s.displayName=`withTRPC(${o})`,s}}(t);return p(t=>"useContext"===t||"useUtils"===t?()=>{let t=e.useUtils();return(0,H.useMemo)(()=>er(t),[t])}:"useQueries"===t?e.useQueries:"withTRPC"===t?n:t5(t,e))}({config:()=>({transformer:e6,links:[function(t={}){let{enabled:e=()=>!0}=t,r=t.colorMode??("undefined"==typeof window?"ansi":"css"),{logger:n=k({c:t.console,colorMode:r})}=t;return()=>({op:t,next:r})=>a(i=>{var s;e({...t,direction:"up"})&&n({...t,direction:"up"});let o=Date.now();function u(r){let i=Date.now()-o;e({...t,direction:"down",result:r})&&n({...t,direction:"down",elapsedMs:i,result:r})}return r(t).pipe((s={next(t){u(t)},error(t){u(t)}},t=>({subscribe:e=>t.subscribe({next(t){s.next?.(t),e.next?.(t)},error(t){s.error?.(t),e.error?.(t)},complete(){s.complete?.(),e.complete?.()}})}))).subscribe(i)})}({enabled:t=>"down"===t.direction&&t.result instanceof Error}),A({url:"".concat(e8(),"/api/trpc")})]}),ssr:!1});r(1784);var rt=e5.withTRPC(t=>{let{Component:e}=t;return(0,u.jsx)(e,{})})},1784:function(){},7663:function(t){!function(){var e={229:function(t){var e,r,n,i=t.exports={};function s(){throw Error("setTimeout has not been defined")}function o(){throw Error("clearTimeout has not been defined")}function u(t){if(e===setTimeout)return setTimeout(t,0);if((e===s||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:s}catch(t){e=s}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var a=[],l=!1,c=-1;function h(){l&&n&&(l=!1,n.length?a=n.concat(a):c=-1,a.length&&f())}function f(){if(!l){var t=u(h);l=!0;for(var e=a.length;e;){for(n=a,a=[];++c1)for(var r=1;r