@shiftengineering/folio 0.0.89 → 0.0.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3966,10 +3966,24 @@ function zo(t, e) {
|
|
|
3966
3966
|
})) };
|
|
3967
3967
|
};
|
|
3968
3968
|
return {
|
|
3969
|
-
getProjectsForUser: async () =>
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3969
|
+
getProjectsForUser: async () => {
|
|
3970
|
+
const s = await r.projectRouter.getAllProjects.query();
|
|
3971
|
+
if (s.length === 0) {
|
|
3972
|
+
const a = await r.projectRouter.createProject.mutate({
|
|
3973
|
+
name: "Default Project"
|
|
3974
|
+
});
|
|
3975
|
+
return [
|
|
3976
|
+
{
|
|
3977
|
+
name: a.name,
|
|
3978
|
+
id: a.id
|
|
3979
|
+
}
|
|
3980
|
+
];
|
|
3981
|
+
}
|
|
3982
|
+
return s.map((a) => ({
|
|
3983
|
+
name: a.name,
|
|
3984
|
+
id: a.id
|
|
3985
|
+
}));
|
|
3986
|
+
},
|
|
3973
3987
|
addProjectForUser: async (s) => {
|
|
3974
3988
|
const a = await r.projectRouter.createProject.mutate({
|
|
3975
3989
|
name: s
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(A,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],k):(A=typeof globalThis<"u"?globalThis:A||self,k(A.FolioEmbedComponent={},A.React))})(this,function(A,k){"use strict";var ps=A=>{throw TypeError(A)};var wr=(A,k,H)=>k.has(A)||ps("Cannot "+H);var o=(A,k,H)=>(wr(A,k,"read from private field"),H?H.call(A):k.get(A)),w=(A,k,H)=>k.has(A)?ps("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(A):k.set(A,H),m=(A,k,H,N)=>(wr(A,k,"write to private field"),N?N.call(A,H):k.set(A,H),H),R=(A,k,H)=>(wr(A,k,"access private method"),H);var Kt=(A,k,H,N)=>({set _(ht){m(A,k,ht,H)},get _(){return o(A,k,N)}});var De,ve,Xe,An,Je,we,Ze,_n,qe,kn,et,tt,ne,Me,B,Pt,Ne,oe,me,
|
|
1
|
+
(function(A,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],k):(A=typeof globalThis<"u"?globalThis:A||self,k(A.FolioEmbedComponent={},A.React))})(this,function(A,k){"use strict";var ps=A=>{throw TypeError(A)};var wr=(A,k,H)=>k.has(A)||ps("Cannot "+H);var o=(A,k,H)=>(wr(A,k,"read from private field"),H?H.call(A):k.get(A)),w=(A,k,H)=>k.has(A)?ps("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(A):k.set(A,H),m=(A,k,H,N)=>(wr(A,k,"write to private field"),N?N.call(A,H):k.set(A,H),H),R=(A,k,H)=>(wr(A,k,"access private method"),H);var Kt=(A,k,H,N)=>({set _(ht){m(A,k,ht,H)},get _(){return o(A,k,N)}});var De,ve,Xe,An,Je,we,Ze,_n,qe,kn,et,tt,ne,Me,B,Pt,Ne,oe,me,jn,ce,In,le,W,Ue,fe,_e,Dn,de,ae,Rt,qn,L,Ee,Oe,rt,nt,Pe,st,it,Mn,J,T,St,G,Le,ot,Re,he,Ct,at,ut,Qe,$e,Se,ct,j,Ft,Er,Or,Pr,Rr,Sr,Cr,Tr,ms,Nn,Ce,Te,Z,ye,pe,Vt,xr,Un,Ln,Qn,$n,Kn,Vn,zn;function H(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const N=H(k);var ht={exports:{}},dt={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -14,21 +14,21 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Ar;function bs(){return Ar||(Ar=1,process.env.NODE_ENV!=="production"&&function(){var t=k,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),P=Symbol.iterator,v="@@iterator";function O(i){if(i===null||typeof i!="object")return null;var y=P&&i[P]||i[v];return typeof y=="function"?y:null}var _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(i){{for(var y=arguments.length,b=new Array(y>1?y-1:0),E=1;E<y;E++)b[E-1]=arguments[E];M("error",i,b)}}function M(i,y,b){{var E=_.ReactDebugCurrentFrame,
|
|
18
|
-
`+dr+i}}var yr=!1,Lt;{var So=typeof WeakMap=="function"?WeakMap:Map;Lt=new So}function es(i,y){if(!i||yr)return"";{var b=Lt.get(i);if(b!==void 0)return b}var E;yr=!0;var
|
|
17
|
+
*/var Ar;function bs(){return Ar||(Ar=1,process.env.NODE_ENV!=="production"&&function(){var t=k,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),P=Symbol.iterator,v="@@iterator";function O(i){if(i===null||typeof i!="object")return null;var y=P&&i[P]||i[v];return typeof y=="function"?y:null}var _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(i){{for(var y=arguments.length,b=new Array(y>1?y-1:0),E=1;E<y;E++)b[E-1]=arguments[E];M("error",i,b)}}function M(i,y,b){{var E=_.ReactDebugCurrentFrame,I=E.getStackAddendum();I!==""&&(y+="%s",b=b.concat([I]));var D=b.map(function(F){return String(F)});D.unshift("Warning: "+y),Function.prototype.apply.call(console[i],console,D)}}var V=!1,Y=!1,te=!1,z=!1,U=!1,q;q=Symbol.for("react.module.reference");function xe(i){return!!(typeof i=="string"||typeof i=="function"||i===n||i===a||U||i===s||i===d||i===h||z||i===g||V||Y||te||typeof i=="object"&&i!==null&&(i.$$typeof===p||i.$$typeof===f||i.$$typeof===u||i.$$typeof===l||i.$$typeof===c||i.$$typeof===q||i.getModuleId!==void 0))}function Fe(i,y,b){var E=i.displayName;if(E)return E;var I=y.displayName||y.name||"";return I!==""?b+"("+I+")":b}function Ke(i){return i.displayName||"Context"}function Ae(i){if(i==null)return null;if(typeof i.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case n:return"Fragment";case r:return"Portal";case a:return"Profiler";case s:return"StrictMode";case d:return"Suspense";case h:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case l:var y=i;return Ke(y)+".Consumer";case u:var b=i;return Ke(b._context)+".Provider";case c:return Fe(i,i.render,"ForwardRef");case f:var E=i.displayName||null;return E!==null?E:Ae(i.type)||"Memo";case p:{var I=i,D=I._payload,F=I._init;try{return Ae(F(D))}catch{return null}}}return null}var Ve=Object.assign,Tt=0,Hn,Bn,Wn,Gn,Yn,Xn,Jn;function Zn(){}Zn.__reactDisabledLog=!0;function Po(){{if(Tt===0){Hn=console.log,Bn=console.info,Wn=console.warn,Gn=console.error,Yn=console.group,Xn=console.groupCollapsed,Jn=console.groupEnd;var i={configurable:!0,enumerable:!0,value:Zn,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}Tt++}}function Ro(){{if(Tt--,Tt===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ve({},i,{value:Hn}),info:Ve({},i,{value:Bn}),warn:Ve({},i,{value:Wn}),error:Ve({},i,{value:Gn}),group:Ve({},i,{value:Yn}),groupCollapsed:Ve({},i,{value:Xn}),groupEnd:Ve({},i,{value:Jn})})}Tt<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var hr=_.ReactCurrentDispatcher,dr;function Ut(i,y,b){{if(dr===void 0)try{throw Error()}catch(I){var E=I.stack.trim().match(/\n( *(at )?)/);dr=E&&E[1]||""}return`
|
|
18
|
+
`+dr+i}}var yr=!1,Lt;{var So=typeof WeakMap=="function"?WeakMap:Map;Lt=new So}function es(i,y){if(!i||yr)return"";{var b=Lt.get(i);if(b!==void 0)return b}var E;yr=!0;var I=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var D;D=hr.current,hr.current=null,Po();try{if(y){var F=function(){throw Error()};if(Object.defineProperty(F.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(F,[])}catch(ee){E=ee}Reflect.construct(i,[],F)}else{try{F.call()}catch(ee){E=ee}i.call(F.prototype)}}else{try{throw Error()}catch(ee){E=ee}i()}}catch(ee){if(ee&&E&&typeof ee.stack=="string"){for(var S=ee.stack.split(`
|
|
19
19
|
`),X=E.stack.split(`
|
|
20
20
|
`),Q=S.length-1,$=X.length-1;Q>=1&&$>=0&&S[Q]!==X[$];)$--;for(;Q>=1&&$>=0;Q--,$--)if(S[Q]!==X[$]){if(Q!==1||$!==1)do if(Q--,$--,$<0||S[Q]!==X[$]){var se=`
|
|
21
|
-
`+S[Q].replace(" at new "," at ");return i.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",i.displayName)),typeof i=="function"&&Lt.set(i,se),se}while(Q>=1&&$>=0);break}}}finally{yr=!1,hr.current=D,Ro(),Error.prepareStackTrace=
|
|
21
|
+
`+S[Q].replace(" at new "," at ");return i.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",i.displayName)),typeof i=="function"&&Lt.set(i,se),se}while(Q>=1&&$>=0);break}}}finally{yr=!1,hr.current=D,Ro(),Error.prepareStackTrace=I}var ft=i?i.displayName||i.name:"",ze=ft?Ut(ft):"";return typeof i=="function"&&Lt.set(i,ze),ze}function Co(i,y,b){return es(i,!1)}function To(i){var y=i.prototype;return!!(y&&y.isReactComponent)}function Qt(i,y,b){if(i==null)return"";if(typeof i=="function")return es(i,To(i));if(typeof i=="string")return Ut(i);switch(i){case d:return Ut("Suspense");case h:return Ut("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case c:return Co(i.render);case f:return Qt(i.type,y,b);case p:{var E=i,I=E._payload,D=E._init;try{return Qt(D(I),y,b)}catch{}}}return""}var xt=Object.prototype.hasOwnProperty,ts={},rs=_.ReactDebugCurrentFrame;function $t(i){if(i){var y=i._owner,b=Qt(i.type,i._source,y?y.type:null);rs.setExtraStackFrame(b)}else rs.setExtraStackFrame(null)}function xo(i,y,b,E,I){{var D=Function.call.bind(xt);for(var F in i)if(D(i,F)){var S=void 0;try{if(typeof i[F]!="function"){var X=Error((E||"React class")+": "+b+" type `"+F+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[F]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw X.name="Invariant Violation",X}S=i[F](y,F,E,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Q){S=Q}S&&!(S instanceof Error)&&($t(I),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",E||"React class",b,F,typeof S),$t(null)),S instanceof Error&&!(S.message in ts)&&(ts[S.message]=!0,$t(I),x("Failed %s type: %s",b,S.message),$t(null))}}}var Fo=Array.isArray;function pr(i){return Fo(i)}function Ao(i){{var y=typeof Symbol=="function"&&Symbol.toStringTag,b=y&&i[Symbol.toStringTag]||i.constructor.name||"Object";return b}}function _o(i){try{return ns(i),!1}catch{return!0}}function ns(i){return""+i}function ss(i){if(_o(i))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ao(i)),ns(i)}var is=_.ReactCurrentOwner,ko={key:!0,ref:!0,__self:!0,__source:!0},os,as;function jo(i){if(xt.call(i,"ref")){var y=Object.getOwnPropertyDescriptor(i,"ref").get;if(y&&y.isReactWarning)return!1}return i.ref!==void 0}function Io(i){if(xt.call(i,"key")){var y=Object.getOwnPropertyDescriptor(i,"key").get;if(y&&y.isReactWarning)return!1}return i.key!==void 0}function Do(i,y){typeof i.ref=="string"&&is.current}function qo(i,y){{var b=function(){os||(os=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",y))};b.isReactWarning=!0,Object.defineProperty(i,"key",{get:b,configurable:!0})}}function Mo(i,y){{var b=function(){as||(as=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",y))};b.isReactWarning=!0,Object.defineProperty(i,"ref",{get:b,configurable:!0})}}var No=function(i,y,b,E,I,D,F){var S={$$typeof:e,type:i,key:y,ref:b,props:F,_owner:D};return S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(S,"_self",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.defineProperty(S,"_source",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function Uo(i,y,b,E,I){{var D,F={},S=null,X=null;b!==void 0&&(ss(b),S=""+b),Io(y)&&(ss(y.key),S=""+y.key),jo(y)&&(X=y.ref,Do(y,I));for(D in y)xt.call(y,D)&&!ko.hasOwnProperty(D)&&(F[D]=y[D]);if(i&&i.defaultProps){var Q=i.defaultProps;for(D in Q)F[D]===void 0&&(F[D]=Q[D])}if(S||X){var $=typeof i=="function"?i.displayName||i.name||"Unknown":i;S&&qo(F,$),X&&Mo(F,$)}return No(i,S,X,I,E,is.current,F)}}var mr=_.ReactCurrentOwner,us=_.ReactDebugCurrentFrame;function lt(i){if(i){var y=i._owner,b=Qt(i.type,i._source,y?y.type:null);us.setExtraStackFrame(b)}else us.setExtraStackFrame(null)}var gr;gr=!1;function br(i){return typeof i=="object"&&i!==null&&i.$$typeof===e}function cs(){{if(mr.current){var i=Ae(mr.current.type);if(i)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+i+"`."}return""}}function Lo(i){return""}var ls={};function Qo(i){{var y=cs();if(!y){var b=typeof i=="string"?i:i.displayName||i.name;b&&(y=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+b+">.")}return y}}function fs(i,y){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var b=Qo(y);if(ls[b])return;ls[b]=!0;var E="";i&&i._owner&&i._owner!==mr.current&&(E=" It was passed a child from "+Ae(i._owner.type)+"."),lt(i),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,E),lt(null)}}function hs(i,y){{if(typeof i!="object")return;if(pr(i))for(var b=0;b<i.length;b++){var E=i[b];br(E)&&fs(E,y)}else if(br(i))i._store&&(i._store.validated=!0);else if(i){var
|
|
25
|
+
Check the top-level render call using <`+b+">.")}return y}}function fs(i,y){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var b=Qo(y);if(ls[b])return;ls[b]=!0;var E="";i&&i._owner&&i._owner!==mr.current&&(E=" It was passed a child from "+Ae(i._owner.type)+"."),lt(i),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,E),lt(null)}}function hs(i,y){{if(typeof i!="object")return;if(pr(i))for(var b=0;b<i.length;b++){var E=i[b];br(E)&&fs(E,y)}else if(br(i))i._store&&(i._store.validated=!0);else if(i){var I=O(i);if(typeof I=="function"&&I!==i.entries)for(var D=I.call(i),F;!(F=D.next()).done;)br(F.value)&&fs(F.value,y)}}}function $o(i){{var y=i.type;if(y==null||typeof y=="string")return;var b;if(typeof y=="function")b=y.propTypes;else if(typeof y=="object"&&(y.$$typeof===c||y.$$typeof===f))b=y.propTypes;else return;if(b){var E=Ae(y);xo(b,i.props,"prop",E,i)}else if(y.PropTypes!==void 0&&!gr){gr=!0;var I=Ae(y);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof y.getDefaultProps=="function"&&!y.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ko(i){{for(var y=Object.keys(i.props),b=0;b<y.length;b++){var E=y[b];if(E!=="children"&&E!=="key"){lt(i),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),lt(null);break}}i.ref!==null&&(lt(i),x("Invalid attribute `ref` supplied to `React.Fragment`."),lt(null))}}var ds={};function ys(i,y,b,E,I,D){{var F=xe(i);if(!F){var S="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var X=Lo();X?S+=X:S+=cs();var Q;i===null?Q="null":pr(i)?Q="array":i!==void 0&&i.$$typeof===e?(Q="<"+(Ae(i.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):Q=typeof i,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Q,S)}var $=Uo(i,y,b,I,D);if($==null)return $;if(F){var se=y.children;if(se!==void 0)if(E)if(pr(se)){for(var ft=0;ft<se.length;ft++)hs(se[ft],i);Object.freeze&&Object.freeze(se)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else hs(se,i)}if(xt.call(y,"key")){var ze=Ae(i),ee=Object.keys(y).filter(function(Go){return Go!=="key"}),vr=ee.length>0?"{key: someKey, "+ee.join(": ..., ")+": ...}":"{key: someKey}";if(!ds[ze+vr]){var Wo=ee.length>0?"{"+ee.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,vr,ze,Wo,ze),ds[ze+vr]=!0}}return i===n?Ko($):$o($),$}}function Vo(i,y,b){return ys(i,y,b,!0)}function zo(i,y,b){return ys(i,y,b,!1)}var Ho=zo,Bo=Vo;yt.Fragment=n,yt.jsx=Ho,yt.jsxs=Bo}()),yt}process.env.NODE_ENV==="production"?ht.exports=gs():ht.exports=bs();var pt=ht.exports,_r=(t=>(t.NOT_CHUNKED="NOT_CHUNKED",t.PROCESSING="PROCESSING",t.CHUNKED="CHUNKED",t.ERROR_CHUNKING="ERROR_CHUNKING",t))(_r||{}),zt=(t=>(t.PDF="application/pdf",t.TXT="text/plain",t.CSV="text/csv",t))(zt||{});const Ht=4e3*1024*1024;Object.entries({"application/pdf":{extensions:[".pdf"],maxSize:Ht},"text/plain":{extensions:[".txt",".json",".py",".ts",".tsx"],maxSize:Ht},"text/csv":{extensions:[".csv"],maxSize:Ht}}).reduce((t,[e,r])=>({...t,[e]:r.extensions}),{}),new Set(Object.values(zt));var He=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ke=typeof window>"u"||"Deno"in globalThis;function re(){}function vs(t,e){return typeof t=="function"?t(e):t}function Bt(t){return typeof t=="number"&&t>=0&&t!==1/0}function kr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Be(t,e){return typeof t=="function"?t(e):t}function ie(t,e){return typeof t=="function"?t(e):t}function Ir(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:u,stale:l}=t;if(u){if(n){if(e.queryHash!==Wt(u,e.options))return!1}else if(!mt(e.queryKey,u))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||s&&s!==e.state.fetchStatus||a&&!a(e))}function jr(t,e){const{exact:r,status:n,predicate:s,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(r){if(Ie(e.options.mutationKey)!==Ie(a))return!1}else if(!mt(e.options.mutationKey,a))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Wt(t,e){return((e==null?void 0:e.queryKeyHashFn)||Ie)(t)}function Ie(t){return JSON.stringify(t,(e,r)=>Yt(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function mt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(r=>!mt(t[r],e[r])):!1}function Gt(t,e){if(t===e)return t;const r=Dr(t)&&Dr(e);if(r||Yt(t)&&Yt(e)){const n=r?t:Object.keys(t),s=n.length,a=r?e:Object.keys(e),u=a.length,l=r?[]:{};let c=0;for(let d=0;d<u;d++){const h=r?d:a[d];(!r&&n.includes(h)||r)&&t[h]===void 0&&e[h]===void 0?(l[h]=void 0,c++):(l[h]=Gt(t[h],e[h]),l[h]===t[h]&&t[h]!==void 0&&c++)}return s===u&&c===s?t:l}return e}function At(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function Dr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Yt(t){if(!qr(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!qr(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function qr(t){return Object.prototype.toString.call(t)==="[object Object]"}function ws(t){return new Promise(e=>{setTimeout(e,t)})}function Xt(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Gt(t,e)}catch(n){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`)}return Gt(t,e)}return e}function Es(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function Os(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var _t=Symbol();function Mr(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===_t&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===_t?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Ps=(An=class extends He{constructor(){super();w(this,De);w(this,ve);w(this,Xe);m(this,Xe,e=>{if(!ke&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){o(this,ve)||this.setEventListener(o(this,Xe))}onUnsubscribe(){var e;this.hasListeners()||((e=o(this,ve))==null||e.call(this),m(this,ve,void 0))}setEventListener(e){var r;m(this,Xe,e),(r=o(this,ve))==null||r.call(this),m(this,ve,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){o(this,De)!==e&&(m(this,De,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof o(this,De)=="boolean"?o(this,De):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},De=new WeakMap,ve=new WeakMap,Xe=new WeakMap,An),Jt=new Ps,Rs=(_n=class extends He{constructor(){super();w(this,Je,!0);w(this,we);w(this,Ze);m(this,Ze,e=>{if(!ke&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){o(this,we)||this.setEventListener(o(this,Ze))}onUnsubscribe(){var e;this.hasListeners()||((e=o(this,we))==null||e.call(this),m(this,we,void 0))}setEventListener(e){var r;m(this,Ze,e),(r=o(this,we))==null||r.call(this),m(this,we,e(this.setOnline.bind(this)))}setOnline(e){o(this,Je)!==e&&(m(this,Je,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return o(this,Je)}},Je=new WeakMap,we=new WeakMap,Ze=new WeakMap,_n),kt=new Rs;function Zt(){let t,e;const r=new Promise((s,a)=>{t=s,e=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function Ss(t){return Math.min(1e3*2**t,3e4)}function Nr(t){return(t??"online")==="online"?kt.isOnline():!0}var Ur=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function er(t){return t instanceof Ur}function Lr(t){let e=!1,r=0,n=!1,s;const a=Zt(),u=v=>{var O;n||(p(new Ur(v)),(O=t.abort)==null||O.call(t))},l=()=>{e=!0},c=()=>{e=!1},d=()=>Jt.isFocused()&&(t.networkMode==="always"||kt.isOnline())&&t.canRun(),h=()=>Nr(t.networkMode)&&t.canRun(),f=v=>{var O;n||(n=!0,(O=t.onSuccess)==null||O.call(t,v),s==null||s(),a.resolve(v))},p=v=>{var O;n||(n=!0,(O=t.onError)==null||O.call(t,v),s==null||s(),a.reject(v))},g=()=>new Promise(v=>{var O;s=_=>{(n||d())&&v(_)},(O=t.onPause)==null||O.call(t)}).then(()=>{var v;s=void 0,n||(v=t.onContinue)==null||v.call(t)}),P=()=>{if(n)return;let v;const O=r===0?t.initialPromise:void 0;try{v=O??t.fn()}catch(_){v=Promise.reject(_)}Promise.resolve(v).then(f).catch(_=>{var te;if(n)return;const x=t.retry??(ke?0:3),M=t.retryDelay??Ss,V=typeof M=="function"?M(r,_):M,Y=x===!0||typeof x=="number"&&r<x||typeof x=="function"&&x(r,_);if(e||!Y){p(_);return}r++,(te=t.onFail)==null||te.call(t,r,_),ws(V).then(()=>d()?void 0:g()).then(()=>{e?p(_):P()})})};return{promise:a,cancel:u,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:h,start:()=>(h()?P():g().then(P),a)}}function Cs(){let t=[],e=0,r=l=>{l()},n=l=>{l()},s=l=>setTimeout(l,0);const a=l=>{e?t.push(l):s(()=>{r(l)})},u=()=>{const l=t;t=[],l.length&&s(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||u()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{s=l}}}var K=Cs(),Qr=(kn=class{constructor(){w(this,qe)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bt(this.gcTime)&&m(this,qe,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(ke?1/0:5*60*1e3))}clearGcTimeout(){o(this,qe)&&(clearTimeout(o(this,qe)),m(this,qe,void 0))}},qe=new WeakMap,kn),Ts=(In=class extends Qr{constructor(e){super();w(this,oe);w(this,et);w(this,tt);w(this,ne);w(this,Me);w(this,B);w(this,Pt);w(this,Ne);m(this,Ne,!1),m(this,Pt,e.defaultOptions),this.setOptions(e.options),this.observers=[],m(this,Me,e.client),m(this,ne,o(this,Me).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,m(this,et,xs(this.options)),this.state=e.state??o(this,et),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=o(this,B))==null?void 0:e.promise}setOptions(e){this.options={...o(this,Pt),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&o(this,ne).remove(this)}setData(e,r){const n=Xt(this.state.data,e,this.options);return R(this,oe,me).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){R(this,oe,me).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=o(this,B))==null?void 0:n.promise;return(s=o(this,B))==null||s.cancel(e),r?r.then(re).catch(re):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(o(this,et))}isActive(){return this.observers.some(e=>ie(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_t||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!kr(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,B))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,B))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),o(this,ne).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(o(this,B)&&(o(this,Ne)?o(this,B).cancel({revert:!0}):o(this,B).cancelRetry()),this.scheduleGc()),o(this,ne).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||R(this,oe,me).call(this,{type:"invalidate"})}fetch(e,r){var c,d,h;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(o(this,B))return o(this,B).continueRetry(),o(this,B).promise}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,s=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(m(this,Ne,!0),n.signal)})},a=()=>{const f=Mr(this.options,r),p={client:o(this,Me),queryKey:this.queryKey,meta:this.meta};return s(p),m(this,Ne,!1),this.options.persister?this.options.persister(f,p,this):f(p)},u={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:o(this,Me),state:this.state,fetchFn:a};s(u),(c=this.options.behavior)==null||c.onFetch(u,this),m(this,tt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=u.fetchOptions)==null?void 0:d.meta))&&R(this,oe,me).call(this,{type:"fetch",meta:(h=u.fetchOptions)==null?void 0:h.meta});const l=f=>{var p,g,P,v;er(f)&&f.silent||R(this,oe,me).call(this,{type:"error",error:f}),er(f)||((g=(p=o(this,ne).config).onError)==null||g.call(p,f,this),(v=(P=o(this,ne).config).onSettled)==null||v.call(P,this.state.data,f,this)),this.scheduleGc()};return m(this,B,Lr({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,g,P,v;if(f===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(O){l(O);return}(g=(p=o(this,ne).config).onSuccess)==null||g.call(p,f,this),(v=(P=o(this,ne).config).onSettled)==null||v.call(P,f,this.state.error,this),this.scheduleGc()},onError:l,onFail:(f,p)=>{R(this,oe,me).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{R(this,oe,me).call(this,{type:"pause"})},onContinue:()=>{R(this,oe,me).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0})),o(this,B).start()}},et=new WeakMap,tt=new WeakMap,ne=new WeakMap,Me=new WeakMap,B=new WeakMap,Pt=new WeakMap,Ne=new WeakMap,oe=new WeakSet,me=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...$r(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return er(s)&&s.revert&&o(this,tt)?{...o(this,tt),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),K.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),o(this,ne).notify({query:this,type:"updated",action:e})})},In);function $r(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Nr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function xs(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Fs=(jn=class extends He{constructor(e={}){super();w(this,ce);this.config=e,m(this,ce,new Map)}build(e,r,n){const s=r.queryKey,a=r.queryHash??Wt(s,r);let u=this.get(a);return u||(u=new Ts({client:e,queryKey:s,queryHash:a,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(u)),u}add(e){o(this,ce).has(e.queryHash)||(o(this,ce).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=o(this,ce).get(e.queryHash);r&&(e.destroy(),r===e&&o(this,ce).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){K.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return o(this,ce).get(e)}getAll(){return[...o(this,ce).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Ir(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>Ir(e,n)):r}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){K.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){K.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ce=new WeakMap,jn),As=(Dn=class extends Qr{constructor(e){super();w(this,fe);w(this,le);w(this,W);w(this,Ue);this.mutationId=e.mutationId,m(this,W,e.mutationCache),m(this,le,[]),this.state=e.state||Kr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){o(this,le).includes(e)||(o(this,le).push(e),this.clearGcTimeout(),o(this,W).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){m(this,le,o(this,le).filter(r=>r!==e)),this.scheduleGc(),o(this,W).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){o(this,le).length||(this.state.status==="pending"?this.scheduleGc():o(this,W).remove(this))}continue(){var e;return((e=o(this,Ue))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var s,a,u,l,c,d,h,f,p,g,P,v,O,_,x,M,V,Y,te,z;m(this,Ue,Lr({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(U,q)=>{R(this,fe,_e).call(this,{type:"failed",failureCount:U,error:q})},onPause:()=>{R(this,fe,_e).call(this,{type:"pause"})},onContinue:()=>{R(this,fe,_e).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>o(this,W).canRun(this)}));const r=this.state.status==="pending",n=!o(this,Ue).canStart();try{if(!r){R(this,fe,_e).call(this,{type:"pending",variables:e,isPaused:n}),await((a=(s=o(this,W).config).onMutate)==null?void 0:a.call(s,e,this));const q=await((l=(u=this.options).onMutate)==null?void 0:l.call(u,e));q!==this.state.context&&R(this,fe,_e).call(this,{type:"pending",context:q,variables:e,isPaused:n})}const U=await o(this,Ue).start();return await((d=(c=o(this,W).config).onSuccess)==null?void 0:d.call(c,U,e,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,U,e,this.state.context)),await((g=(p=o(this,W).config).onSettled)==null?void 0:g.call(p,U,null,this.state.variables,this.state.context,this)),await((v=(P=this.options).onSettled)==null?void 0:v.call(P,U,null,e,this.state.context)),R(this,fe,_e).call(this,{type:"success",data:U}),U}catch(U){try{throw await((_=(O=o(this,W).config).onError)==null?void 0:_.call(O,U,e,this.state.context,this)),await((M=(x=this.options).onError)==null?void 0:M.call(x,U,e,this.state.context)),await((Y=(V=o(this,W).config).onSettled)==null?void 0:Y.call(V,void 0,U,this.state.variables,this.state.context,this)),await((z=(te=this.options).onSettled)==null?void 0:z.call(te,void 0,U,e,this.state.context)),U}finally{R(this,fe,_e).call(this,{type:"error",error:U})}}finally{o(this,W).runNext(this)}}},le=new WeakMap,W=new WeakMap,Ue=new WeakMap,fe=new WeakSet,_e=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,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{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),K.batch(()=>{o(this,le).forEach(n=>{n.onMutationUpdate(e)}),o(this,W).notify({mutation:this,type:"updated",action:e})})},Dn);function Kr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _s=(qn=class extends He{constructor(e={}){super();w(this,de);w(this,ae);w(this,Rt);this.config=e,m(this,de,new Set),m(this,ae,new Map),m(this,Rt,0)}build(e,r,n){const s=new As({mutationCache:this,mutationId:++Kt(this,Rt)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){o(this,de).add(e);const r=It(e);if(typeof r=="string"){const n=o(this,ae).get(r);n?n.push(e):o(this,ae).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(o(this,de).delete(e)){const r=It(e);if(typeof r=="string"){const n=o(this,ae).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&o(this,ae).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=It(e);if(typeof r=="string"){const n=o(this,ae).get(r),s=n==null?void 0:n.find(a=>a.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=It(e);if(typeof r=="string"){const s=(n=o(this,ae).get(r))==null?void 0:n.find(a=>a!==e&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){K.batch(()=>{o(this,de).forEach(e=>{this.notify({type:"removed",mutation:e})}),o(this,de).clear(),o(this,ae).clear()})}getAll(){return Array.from(o(this,de))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>jr(r,n))}findAll(e={}){return this.getAll().filter(r=>jr(e,r))}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return K.batch(()=>Promise.all(e.map(r=>r.continue().catch(re))))}},de=new WeakMap,ae=new WeakMap,Rt=new WeakMap,qn);function It(t){var e;return(e=t.options.scope)==null?void 0:e.id}function Vr(t){return{onFetch:(e,r)=>{var h,f,p,g,P;const n=e.options,s=(p=(f=(h=e.fetchOptions)==null?void 0:h.meta)==null?void 0:f.fetchMore)==null?void 0:p.direction,a=((g=e.state.data)==null?void 0:g.pages)||[],u=((P=e.state.data)==null?void 0:P.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let v=!1;const O=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},_=Mr(e.options,e.fetchOptions),x=async(M,V,Y)=>{if(v)return Promise.reject();if(V==null&&M.pages.length)return Promise.resolve(M);const te={client:e.client,queryKey:e.queryKey,pageParam:V,direction:Y?"backward":"forward",meta:e.options.meta};O(te);const z=await _(te),{maxPages:U}=e.options,q=Y?Os:Es;return{pages:q(M.pages,z,U),pageParams:q(M.pageParams,V,U)}};if(s&&a.length){const M=s==="backward",V=M?ks:zr,Y={pages:a,pageParams:u},te=V(n,Y);l=await x(Y,te,M)}else{const M=t??a.length;do{const V=c===0?u[0]??n.initialPageParam:zr(n,l);if(c>0&&V==null)break;l=await x(l,V),c++}while(c<M)}return l};e.options.persister?e.fetchFn=()=>{var v,O;return(O=(v=e.options).persister)==null?void 0:O.call(v,d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=d}}}function zr(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function ks(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var Is=(Mn=class{constructor(t={}){w(this,L);w(this,Ee);w(this,Oe);w(this,rt);w(this,nt);w(this,Pe);w(this,st);w(this,it);m(this,L,t.queryCache||new Fs),m(this,Ee,t.mutationCache||new _s),m(this,Oe,t.defaultOptions||{}),m(this,rt,new Map),m(this,nt,new Map),m(this,Pe,0)}mount(){Kt(this,Pe)._++,o(this,Pe)===1&&(m(this,st,Jt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onFocus())})),m(this,it,kt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onOnline())})))}unmount(){var t,e;Kt(this,Pe)._--,o(this,Pe)===0&&((t=o(this,st))==null||t.call(this),m(this,st,void 0),(e=o(this,it))==null||e.call(this),m(this,it,void 0))}isFetching(t){return o(this,L).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return o(this,Ee).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=o(this,L).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=o(this,L).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Be(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return o(this,L).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=o(this,L).get(n.queryHash),a=s==null?void 0:s.state.data,u=vs(e,a);if(u!==void 0)return o(this,L).build(this,n).setData(u,{...r,manual:!0})}setQueriesData(t,e,r){return K.batch(()=>o(this,L).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=o(this,L).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=o(this,L);K.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=o(this,L);return K.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=K.batch(()=>o(this,L).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(re).catch(re)}invalidateQueries(t,e={}){return K.batch(()=>(o(this,L).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=K.batch(()=>o(this,L).findAll(t).filter(s=>!s.isDisabled()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(re)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(re)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=o(this,L).build(this,e);return r.isStaleByTime(Be(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(re).catch(re)}fetchInfiniteQuery(t){return t.behavior=Vr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(re).catch(re)}ensureInfiniteQueryData(t){return t.behavior=Vr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return kt.isOnline()?o(this,Ee).resumePausedMutations():Promise.resolve()}getQueryCache(){return o(this,L)}getMutationCache(){return o(this,Ee)}getDefaultOptions(){return o(this,Oe)}setDefaultOptions(t){m(this,Oe,t)}setQueryDefaults(t,e){o(this,rt).set(Ie(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...o(this,rt).values()],r={};return e.forEach(n=>{mt(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){o(this,nt).set(Ie(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...o(this,nt).values()],r={};return e.forEach(n=>{mt(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...o(this,Oe).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Wt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===_t&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...o(this,Oe).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){o(this,L).clear(),o(this,Ee).clear()}},L=new WeakMap,Ee=new WeakMap,Oe=new WeakMap,rt=new WeakMap,nt=new WeakMap,Pe=new WeakMap,st=new WeakMap,it=new WeakMap,Mn),js=(Nn=class extends He{constructor(e,r){super();w(this,I);w(this,J);w(this,T);w(this,St);w(this,G);w(this,Le);w(this,ot);w(this,Re);w(this,he);w(this,Ct);w(this,at);w(this,ut);w(this,Qe);w(this,$e);w(this,Se);w(this,ct,new Set);this.options=r,m(this,J,e),m(this,he,null),m(this,Re,Zt()),this.options.experimental_prefetchInRender||o(this,Re).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(o(this,T).addObserver(this),Hr(o(this,T),this.options)?R(this,I,Ft).call(this):this.updateResult(),R(this,I,Rr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return tr(o(this,T),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return tr(o(this,T),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,R(this,I,Sr).call(this),R(this,I,Cr).call(this),o(this,T).removeObserver(this)}setOptions(e,r){const n=this.options,s=o(this,T);if(this.options=o(this,J).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ie(this.options.enabled,o(this,T))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");R(this,I,Tr).call(this),o(this,T).setOptions(this.options),n._defaulted&&!At(this.options,n)&&o(this,J).getQueryCache().notify({type:"observerOptionsUpdated",query:o(this,T),observer:this});const a=this.hasListeners();a&&Br(o(this,T),s,this.options,n)&&R(this,I,Ft).call(this),this.updateResult(r),a&&(o(this,T)!==s||ie(this.options.enabled,o(this,T))!==ie(n.enabled,o(this,T))||Be(this.options.staleTime,o(this,T))!==Be(n.staleTime,o(this,T)))&&R(this,I,Er).call(this);const u=R(this,I,Or).call(this);a&&(o(this,T)!==s||ie(this.options.enabled,o(this,T))!==ie(n.enabled,o(this,T))||u!==o(this,Se))&&R(this,I,Pr).call(this,u)}getOptimisticResult(e){const r=o(this,J).getQueryCache().build(o(this,J),e),n=this.createResult(r,e);return qs(this,n)&&(m(this,G,n),m(this,ot,this.options),m(this,Le,o(this,T).state)),n}getCurrentResult(){return o(this,G)}trackResult(e,r){const n={};return Object.keys(e).forEach(s=>{Object.defineProperty(n,s,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(s),r==null||r(s),e[s])})}),n}trackProp(e){o(this,ct).add(e)}getCurrentQuery(){return o(this,T)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=o(this,J).defaultQueryOptions(e),n=o(this,J).getQueryCache().build(o(this,J),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return R(this,I,Ft).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),o(this,G)))}createResult(e,r){var U;const n=o(this,T),s=this.options,a=o(this,G),u=o(this,Le),l=o(this,ot),d=e!==n?e.state:o(this,St),{state:h}=e;let f={...h},p=!1,g;if(r._optimisticResults){const q=this.hasListeners(),xe=!q&&Hr(e,r),Fe=q&&Br(e,n,r,s);(xe||Fe)&&(f={...f,...$r(h.data,e.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:P,errorUpdatedAt:v,status:O}=f;if(r.select&&f.data!==void 0)if(a&&f.data===(u==null?void 0:u.data)&&r.select===o(this,Ct))g=o(this,at);else try{m(this,Ct,r.select),g=r.select(f.data),g=Xt(a==null?void 0:a.data,g,r),m(this,at,g),m(this,he,null)}catch(q){m(this,he,q)}else g=f.data;if(r.placeholderData!==void 0&&g===void 0&&O==="pending"){let q;if(a!=null&&a.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData))q=a.data;else if(q=typeof r.placeholderData=="function"?r.placeholderData((U=o(this,ut))==null?void 0:U.state.data,o(this,ut)):r.placeholderData,r.select&&q!==void 0)try{q=r.select(q),m(this,he,null)}catch(xe){m(this,he,xe)}q!==void 0&&(O="success",g=Xt(a==null?void 0:a.data,q,r),p=!0)}o(this,he)&&(P=o(this,he),g=o(this,at),v=Date.now(),O="error");const _=f.fetchStatus==="fetching",x=O==="pending",M=O==="error",V=x&&_,Y=g!==void 0,z={status:O,fetchStatus:f.fetchStatus,isPending:x,isSuccess:O==="success",isError:M,isInitialLoading:V,isLoading:V,data:g,dataUpdatedAt:f.dataUpdatedAt,error:P,errorUpdatedAt:v,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:_,isRefetching:_&&!x,isLoadingError:M&&!Y,isPaused:f.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:M&&Y,isStale:rr(e,r),refetch:this.refetch,promise:o(this,Re)};if(this.options.experimental_prefetchInRender){const q=Ke=>{z.status==="error"?Ke.reject(z.error):z.data!==void 0&&Ke.resolve(z.data)},xe=()=>{const Ke=m(this,Re,z.promise=Zt());q(Ke)},Fe=o(this,Re);switch(Fe.status){case"pending":e.queryHash===n.queryHash&&q(Fe);break;case"fulfilled":(z.status==="error"||z.data!==Fe.value)&&xe();break;case"rejected":(z.status!=="error"||z.error!==Fe.reason)&&xe();break}}return z}updateResult(e){const r=o(this,G),n=this.createResult(o(this,T),this.options);if(m(this,Le,o(this,T).state),m(this,ot,this.options),o(this,Le).data!==void 0&&m(this,ut,o(this,T)),At(n,r))return;m(this,G,n);const s={},a=()=>{if(!r)return!0;const{notifyOnChangeProps:u}=this.options,l=typeof u=="function"?u():u;if(l==="all"||!l&&!o(this,ct).size)return!0;const c=new Set(l??o(this,ct));return this.options.throwOnError&&c.add("error"),Object.keys(o(this,G)).some(d=>{const h=d;return o(this,G)[h]!==r[h]&&c.has(h)})};(e==null?void 0:e.listeners)!==!1&&a()&&(s.listeners=!0),R(this,I,ms).call(this,{...s,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&R(this,I,Rr).call(this)}},J=new WeakMap,T=new WeakMap,St=new WeakMap,G=new WeakMap,Le=new WeakMap,ot=new WeakMap,Re=new WeakMap,he=new WeakMap,Ct=new WeakMap,at=new WeakMap,ut=new WeakMap,Qe=new WeakMap,$e=new WeakMap,Se=new WeakMap,ct=new WeakMap,I=new WeakSet,Ft=function(e){R(this,I,Tr).call(this);let r=o(this,T).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(re)),r},Er=function(){R(this,I,Sr).call(this);const e=Be(this.options.staleTime,o(this,T));if(ke||o(this,G).isStale||!Bt(e))return;const n=kr(o(this,G).dataUpdatedAt,e)+1;m(this,Qe,setTimeout(()=>{o(this,G).isStale||this.updateResult()},n))},Or=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(o(this,T)):this.options.refetchInterval)??!1},Pr=function(e){R(this,I,Cr).call(this),m(this,Se,e),!(ke||ie(this.options.enabled,o(this,T))===!1||!Bt(o(this,Se))||o(this,Se)===0)&&m(this,$e,setInterval(()=>{(this.options.refetchIntervalInBackground||Jt.isFocused())&&R(this,I,Ft).call(this)},o(this,Se)))},Rr=function(){R(this,I,Er).call(this),R(this,I,Pr).call(this,R(this,I,Or).call(this))},Sr=function(){o(this,Qe)&&(clearTimeout(o(this,Qe)),m(this,Qe,void 0))},Cr=function(){o(this,$e)&&(clearInterval(o(this,$e)),m(this,$e,void 0))},Tr=function(){const e=o(this,J).getQueryCache().build(o(this,J),this.options);if(e===o(this,T))return;const r=o(this,T);m(this,T,e),m(this,St,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},ms=function(e){K.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(o(this,G))}),o(this,J).getQueryCache().notify({query:o(this,T),type:"observerResultsUpdated"})})},Nn);function Ds(t,e){return ie(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Hr(t,e){return Ds(t,e)||t.state.data!==void 0&&tr(t,e,e.refetchOnMount)}function tr(t,e,r){if(ie(e.enabled,t)!==!1){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&rr(t,e)}return!1}function Br(t,e,r,n){return(t!==e||ie(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&rr(t,r)}function rr(t,e){return ie(e.enabled,t)!==!1&&t.isStaleByTime(Be(e.staleTime,t))}function qs(t,e){return!At(t.getCurrentResult(),e)}var Ms=(Un=class extends He{constructor(e,r){super();w(this,pe);w(this,Ce);w(this,Te);w(this,Z);w(this,ye);m(this,Ce,e),this.setOptions(r),this.bindMethods(),R(this,pe,Vt).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var n;const r=this.options;this.options=o(this,Ce).defaultMutationOptions(e),At(this.options,r)||o(this,Ce).getMutationCache().notify({type:"observerOptionsUpdated",mutation:o(this,Z),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Ie(r.mutationKey)!==Ie(this.options.mutationKey)?this.reset():((n=o(this,Z))==null?void 0:n.state.status)==="pending"&&o(this,Z).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||(e=o(this,Z))==null||e.removeObserver(this)}onMutationUpdate(e){R(this,pe,Vt).call(this),R(this,pe,xr).call(this,e)}getCurrentResult(){return o(this,Te)}reset(){var e;(e=o(this,Z))==null||e.removeObserver(this),m(this,Z,void 0),R(this,pe,Vt).call(this),R(this,pe,xr).call(this)}mutate(e,r){var n;return m(this,ye,r),(n=o(this,Z))==null||n.removeObserver(this),m(this,Z,o(this,Ce).getMutationCache().build(o(this,Ce),this.options)),o(this,Z).addObserver(this),o(this,Z).execute(e)}},Ce=new WeakMap,Te=new WeakMap,Z=new WeakMap,ye=new WeakMap,pe=new WeakSet,Vt=function(){var r;const e=((r=o(this,Z))==null?void 0:r.state)??Kr();m(this,Te,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},xr=function(e){K.batch(()=>{var r,n,s,a,u,l,c,d;if(o(this,ye)&&this.hasListeners()){const h=o(this,Te).variables,f=o(this,Te).context;(e==null?void 0:e.type)==="success"?((n=(r=o(this,ye)).onSuccess)==null||n.call(r,e.data,h,f),(a=(s=o(this,ye)).onSettled)==null||a.call(s,e.data,null,h,f)):(e==null?void 0:e.type)==="error"&&((l=(u=o(this,ye)).onError)==null||l.call(u,e.error,h,f),(d=(c=o(this,ye)).onSettled)==null||d.call(c,void 0,e.error,h,f))}this.listeners.forEach(h=>{h(o(this,Te))})})},Un),Wr=N.createContext(void 0),jt=t=>{const e=N.useContext(Wr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ns=({client:t,children:e})=>(N.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),pt.jsx(Wr.Provider,{value:t,children:e})),Gr=N.createContext(!1),Us=()=>N.useContext(Gr);Gr.Provider;function Ls(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Qs=N.createContext(Ls()),$s=()=>N.useContext(Qs);function Yr(t,e){return typeof t=="function"?t(...e):!!t}function nr(){}var Ks=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Vs=t=>{N.useEffect(()=>{t.clearReset()},[t])},zs=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Yr(r,[t.error,n])),Hs=t=>{const e=t.staleTime;t.suspense&&(t.staleTime=typeof e=="function"?(...r)=>Math.max(e(...r),1e3):Math.max(e??1e3,1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},Bs=(t,e)=>t.isLoading&&t.isFetching&&!e,Ws=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Xr=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Gs(t,e,r){var f,p,g,P,v;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=jt(),s=Us(),a=$s(),u=n.defaultQueryOptions(t);(p=(f=n.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||p.call(f,u),process.env.NODE_ENV!=="production"&&(u.queryFn||console.error(`[${u.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),u._optimisticResults=s?"isRestoring":"optimistic",Hs(u),Ks(u,a),Vs(a);const l=!n.getQueryCache().get(u.queryHash),[c]=N.useState(()=>new e(n,u)),d=c.getOptimisticResult(u),h=!s&&t.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(O=>{const _=h?c.subscribe(K.batchCalls(O)):nr;return c.updateResult(),_},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(u,{listeners:!1})},[u,c]),Ws(u,d))throw Xr(u,c,a);if(zs({result:d,errorResetBoundary:a,throwOnError:u.throwOnError,query:n.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw d.error;if((P=(g=n.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||P.call(g,u,d),u.experimental_prefetchInRender&&!ke&&Bs(d,s)){const O=l?Xr(u,c,a):(v=n.getQueryCache().get(u.queryHash))==null?void 0:v.promise;O==null||O.catch(nr).finally(()=>{c.updateResult()})}return u.notifyOnChangeProps?d:c.trackResult(d)}function Jr(t,e){return Gs(t,js)}function Zr(t,e){const r=jt(),[n]=N.useState(()=>new Ms(r,t));N.useEffect(()=>{n.setOptions(t)},[n,t]);const s=N.useSyncExternalStore(N.useCallback(u=>n.subscribe(K.batchCalls(u)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=N.useCallback((u,l)=>{n.mutate(u,l).catch(nr)},[n]);if(s.error&&Yr(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}function We(t){const e={subscribe(r){let n=null,s=!1,a=!1,u=!1;function l(){if(n===null){u=!0;return}a||(a=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){var d;s||(d=r.next)==null||d.call(r,c)},error(c){var d;s||(s=!0,(d=r.error)==null||d.call(r,c),l())},complete(){var c;s||(s=!0,(c=r.complete)==null||c.call(r),l())}}),u&&l(),{unsubscribe:l}},pipe(...r){return r.reduce(Ys,e)}};return e}function Ys(t,e){return e(t)}function Xs(t){const e=new AbortController;return new Promise((n,s)=>{let a=!1;function u(){a||(a=!0,l.unsubscribe())}e.signal.addEventListener("abort",()=>{s(e.signal.reason)});const l=t.subscribe({next(c){a=!0,n(c),u()},error(c){s(c)},complete(){e.abort(),u()}})})}function Js(t){return e=>{let r=0,n=null;const s=[];function a(){n||(n=e.subscribe({next(l){var c;for(const d of s)(c=d.next)==null||c.call(d,l)},error(l){var c;for(const d of s)(c=d.error)==null||c.call(d,l)},complete(){var l;for(const c of s)(l=c.complete)==null||l.call(c)}}))}function u(){if(r===0&&n){const l=n;n=null,l.unsubscribe()}}return We(l=>(r++,s.push(l),a(),{unsubscribe(){r--,u();const c=s.findIndex(d=>d===l);c>-1&&s.splice(c,1)}}))}}function Zs(t){return e=>We(r=>e.subscribe({next(n){var s;(s=t.next)==null||s.call(t,n),r.next(n)},error(n){var s;(s=t.error)==null||s.call(t,n),r.error(n)},complete(){var n;(n=t.complete)==null||n.call(t),r.complete()}}))}function ei(t){let e=t;const r=[],n=u=>{e!==void 0&&u.next(e),r.push(u)},s=u=>{r.splice(r.indexOf(u),1)},a=We(u=>(n(u),()=>{s(u)}));return a.next=u=>{if(e!==u){e=u;for(const l of r)l.next(u)}},a.get=()=>e,a}function ti(t){return We(e=>{function r(s=0,a=t.op){const u=t.links[s];if(!u)throw new Error("No more links to execute - did you forget to add an ending link?");return u({op:a,next(c){return r(s+1,c)}})}return r().subscribe(e)})}const en=()=>{},tn=t=>{Object.freeze&&Object.freeze(t)};function rn(t,e,r){var n,s;const a=e.join(".");return(n=r)[s=a]??(n[s]=new Proxy(en,{get(u,l){if(!(typeof l!="string"||l==="then"))return rn(t,[...e,l],r)},apply(u,l,c){const d=e[e.length-1];let h={args:c,path:e};return d==="call"?h={args:c.length>=2?[c[1]]:[],path:e.slice(0,-1)}:d==="apply"&&(h={args:c.length>=2?c[1]:[],path:e.slice(0,-1)}),tn(h.args),tn(h.path),t(h)}})),r[a]}const ri=t=>rn(t,[],Object.create(null)),ni=t=>new Proxy(en,{get(e,r){if(r!=="then")return t(r)}});function gt(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function si(t,e){if("error"in t){const n=e.deserialize(t.error);return{ok:!1,error:{...t,error:n}}}return{ok:!0,result:{...t.result,...(!t.result.type||t.result.type==="data")&&{type:"data",data:e.deserialize(t.result.data)}}}}class sr extends Error{constructor(){super("Unable to transform response from server")}}function ii(t,e){let r;try{r=si(t,e)}catch{throw new sr}if(!r.ok&&(!gt(r.error.error)||typeof r.error.error.code!="number"))throw new sr;if(r.ok&&!gt(r.result))throw new sr;return r}var nn,sn;(nn=Symbol).dispose??(nn.dispose=Symbol()),(sn=Symbol).asyncDispose??(sn.asyncDispose=Symbol()),typeof window>"u"||"Deno"in window||((Qn=(Ln=globalThis.process)==null?void 0:Ln.env)==null?void 0:Qn.NODE_ENV)==="test"||(Kn=($n=globalThis.process)==null?void 0:$n.env)!=null&&Kn.JEST_WORKER_ID||(zn=(Vn=globalThis.process)==null?void 0:Vn.env)!=null&&zn.VITEST_WORKER_ID;function Dt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oi(t){return t instanceof ge||t instanceof Error&&t.name==="TRPCClientError"}function ai(t){return gt(t)&>(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function ui(t,e){return typeof t=="string"?t:gt(t)&&typeof t.message=="string"?t.message:e}class ge extends Error{static from(e,r={}){const n=e;return oi(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):ai(n)?new ge(n.error.message,{...r,result:n}):new ge(ui(n,"Unknown error"),{...r,cause:n})}constructor(e,r){var s,a;const n=r==null?void 0:r.cause;super(e,{cause:n}),Dt(this,"cause",void 0),Dt(this,"shape",void 0),Dt(this,"data",void 0),Dt(this,"meta",void 0),this.meta=r==null?void 0:r.meta,this.cause=n,this.shape=(s=r==null?void 0:r.result)==null?void 0:s.error,this.data=(a=r==null?void 0:r.result)==null?void 0:a.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,ge.prototype)}}function ir(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class ci{$request(e){return ti({links:this.links,op:{...e,context:e.context??{},id:++this.requestId}}).pipe(Js())}async requestAsPromise(e){try{const r=this.$request(e);return(await Xs(r)).result.data}catch(r){throw ge.from(r)}}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n.context,signal:n.signal}).subscribe({next(a){var u,l,c,d;switch(a.result.type){case"state":{(u=n.onConnectionStateChange)==null||u.call(n,a.result);break}case"started":{(l=n.onStarted)==null||l.call(n,{context:a.context});break}case"stopped":{(c=n.onStopped)==null||c.call(n);break}case"data":case void 0:{(d=n.onData)==null||d.call(n,a.result.data);break}}},error(a){var u;(u=n.onError)==null||u.call(n,a)},complete(){var a;(a=n.onComplete)==null||a.call(n)}})}constructor(e){ir(this,"links",void 0),ir(this,"runtime",void 0),ir(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(r=>r(this.runtime))}}const li=Symbol.for("trpc_untypedClient"),fi={query:"query",mutate:"mutation",subscribe:"subscription"},hi=t=>fi[t];function di(t){const e=ri(({path:r,args:n})=>{const s=[...r],a=hi(s.pop()),u=s.join(".");return t[a](u,...n)});return ni(r=>r===li?t:e[r])}function yi(t){const e=new ci(t);return di(e)}const on=t=>typeof t=="function";function pi(t){if(t)return t;if(typeof window<"u"&&on(window.fetch))return window.fetch;if(typeof globalThis<"u"&&on(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}const an=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function un(t){let e=null,r=null;const n=()=>{clearTimeout(r),r=null,e=null};function s(l){var h,f;const c=[[]];let d=0;for(;;){const p=l[d];if(!p)break;const g=c[c.length-1];if(p.aborted){(h=p.reject)==null||h.call(p,new Error("Aborted")),d++;continue}if(t.validate(g.concat(p).map(v=>v.key))){g.push(p),d++;continue}if(g.length===0){(f=p.reject)==null||f.call(p,new Error("Input is too big for a single dispatch")),d++;continue}c.push([])}return c}function a(){const l=s(e);n();for(const c of l){if(!c.length)continue;const d={items:c};for(const f of c)f.batch=d;t.fetch(d.items.map(f=>f.key)).then(async f=>{var p;await Promise.all(f.map(async(g,P)=>{var O,_;const v=d.items[P];try{const x=await Promise.resolve(g);(O=v.resolve)==null||O.call(v,x)}catch(x){(_=v.reject)==null||_.call(v,x)}v.batch=null,v.reject=null,v.resolve=null}));for(const g of d.items)(p=g.reject)==null||p.call(g,new Error("Missing result")),g.batch=null}).catch(f=>{var p;for(const g of d.items)(p=g.reject)==null||p.call(g,f),g.batch=null})}}function u(l){const c={aborted:!1,key:l,batch:null,resolve:an,reject:an},d=new Promise((h,f)=>{c.reject=f,c.resolve=h,e||(e=[]),e.push(c)});return r||(r=setTimeout(a)),d}return{load:u}}function mi(...t){const e=new AbortController,r=t.length;let n=0;const s=()=>{++n===r&&e.abort()};for(const a of t)a!=null&&a.aborted?s():a==null||a.addEventListener("abort",s,{once:!0});return e.signal}function gi(t){const e=t;return e?"input"in e?e:{input:e,output:e}:{input:{serialize:r=>r,deserialize:r=>r},output:{serialize:r=>r,deserialize:r=>r}}}function bi(t){return{url:t.url.toString(),fetch:t.fetch,transformer:gi(t.transformer),methodOverride:t.methodOverride}}function vi(t){const e={};for(let r=0;r<t.length;r++){const n=t[r];e[r]=n}return e}const wi={query:"GET",mutation:"POST",subscription:"PATCH"};function cn(t){return"input"in t?t.transformer.input.serialize(t.input):vi(t.inputs.map(e=>t.transformer.input.serialize(e)))}const ln=t=>{const e=t.url.split("?");let n=e[0].replace(/\/$/,"")+"/"+t.path;const s=[];if(e[1]&&s.push(e[1]),"inputs"in t&&s.push("batch=1"),t.type==="query"||t.type==="subscription"){const a=cn(t);a!==void 0&&t.methodOverride!=="POST"&&s.push(`input=${encodeURIComponent(JSON.stringify(a))}`)}return s.length&&(n+="?"+s.join("&")),n},Ei=t=>{if(t.type==="query"&&t.methodOverride!=="POST")return;const e=cn(t);return e!==void 0?JSON.stringify(e):void 0},Oi=t=>Ci({...t,contentTypeHeader:"application/json",getUrl:ln,getBody:Ei});class Pi extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}}const Ri=t=>{var e;if(t!=null&&t.aborted)throw(e=t.throwIfAborted)==null||e.call(t),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new Pi};async function Si(t){Ri(t.signal);const e=t.getUrl(t),r=t.getBody(t),{type:n}=t,s=await(async()=>{const u=await t.headers();return Symbol.iterator in u?Object.fromEntries(u):u})(),a={...t.contentTypeHeader?{"content-type":t.contentTypeHeader}:{},...t.trpcAcceptHeader?{"trpc-accept":t.trpcAcceptHeader}:void 0,...s};return pi(t.fetch)(e,{method:t.methodOverride??wi[n],signal:t.signal,body:r,headers:a})}async function Ci(t){const e={},r=await Si(t);e.response=r;const n=await r.json();return e.responseJSON=n,{json:n,meta:e}}function Ti(t){const e=bi(t),r=t.maxURLLength??1/0;return()=>{const n=l=>({validate(c){if(r===1/0)return!0;const d=c.map(p=>p.path).join(","),h=c.map(p=>p.input);return ln({...e,type:l,path:d,inputs:h,signal:null}).length<=r},async fetch(c){const d=c.map(v=>v.path).join(","),h=c.map(v=>v.input),f=mi(...c.map(v=>v.signal)),p=await Oi({...e,path:d,inputs:h,type:l,headers(){return t.headers?typeof t.headers=="function"?t.headers({opList:c}):t.headers:{}},signal:f});return(Array.isArray(p.json)?p.json:c.map(()=>p.json)).map(v=>({meta:p.meta,json:v}))}}),s=un(n("query")),a=un(n("mutation")),u={query:s,mutation:a};return({op:l})=>We(c=>{/* istanbul ignore if -- @preserve */if(l.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const h=u[l.type].load(l);let f;return h.then(p=>{f=p;const g=ii(p.json,e.transformer.output);if(!g.ok){c.error(ge.from(g.error,{meta:p.meta}));return}c.next({context:p.meta,result:g.result}),c.complete()}).catch(p=>{c.error(ge.from(p,{meta:f==null?void 0:f.meta}))}),()=>{}})}}function xi(t){return typeof FormData>"u"?!1:t instanceof FormData}const or={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"]}}};function Fi(t){const{direction:e,type:r,withContext:n,path:s,id:a,input:u}=t,l=[],c=[];if(t.colorMode==="none")l.push(e==="up"?">>":"<<",r,`#${a}`,s);else if(t.colorMode==="ansi"){const[d,h]=or.ansi.regular[r],[f,p]=or.ansi.bold[r];l.push(e==="up"?d:h,e==="up"?">>":"<<",r,e==="up"?f:p,`#${a}`,s,"\x1B[0m")}else{const[d,h]=or.css[r],f=`
|
|
30
|
+
<%s key={someKey} {...props} />`,vr,ze,Wo,ze),ds[ze+vr]=!0}}return i===n?Ko($):$o($),$}}function Vo(i,y,b){return ys(i,y,b,!0)}function zo(i,y,b){return ys(i,y,b,!1)}var Ho=zo,Bo=Vo;yt.Fragment=n,yt.jsx=Ho,yt.jsxs=Bo}()),yt}process.env.NODE_ENV==="production"?ht.exports=gs():ht.exports=bs();var pt=ht.exports,_r=(t=>(t.NOT_CHUNKED="NOT_CHUNKED",t.PROCESSING="PROCESSING",t.CHUNKED="CHUNKED",t.ERROR_CHUNKING="ERROR_CHUNKING",t))(_r||{}),zt=(t=>(t.PDF="application/pdf",t.TXT="text/plain",t.CSV="text/csv",t))(zt||{});const Ht=4e3*1024*1024;Object.entries({"application/pdf":{extensions:[".pdf"],maxSize:Ht},"text/plain":{extensions:[".txt",".json",".py",".ts",".tsx"],maxSize:Ht},"text/csv":{extensions:[".csv"],maxSize:Ht}}).reduce((t,[e,r])=>({...t,[e]:r.extensions}),{}),new Set(Object.values(zt));var He=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ke=typeof window>"u"||"Deno"in globalThis;function re(){}function vs(t,e){return typeof t=="function"?t(e):t}function Bt(t){return typeof t=="number"&&t>=0&&t!==1/0}function kr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Be(t,e){return typeof t=="function"?t(e):t}function ie(t,e){return typeof t=="function"?t(e):t}function jr(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:u,stale:l}=t;if(u){if(n){if(e.queryHash!==Wt(u,e.options))return!1}else if(!mt(e.queryKey,u))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||s&&s!==e.state.fetchStatus||a&&!a(e))}function Ir(t,e){const{exact:r,status:n,predicate:s,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(r){if(je(e.options.mutationKey)!==je(a))return!1}else if(!mt(e.options.mutationKey,a))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Wt(t,e){return((e==null?void 0:e.queryKeyHashFn)||je)(t)}function je(t){return JSON.stringify(t,(e,r)=>Yt(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function mt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(r=>!mt(t[r],e[r])):!1}function Gt(t,e){if(t===e)return t;const r=Dr(t)&&Dr(e);if(r||Yt(t)&&Yt(e)){const n=r?t:Object.keys(t),s=n.length,a=r?e:Object.keys(e),u=a.length,l=r?[]:{};let c=0;for(let d=0;d<u;d++){const h=r?d:a[d];(!r&&n.includes(h)||r)&&t[h]===void 0&&e[h]===void 0?(l[h]=void 0,c++):(l[h]=Gt(t[h],e[h]),l[h]===t[h]&&t[h]!==void 0&&c++)}return s===u&&c===s?t:l}return e}function At(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function Dr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Yt(t){if(!qr(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!qr(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function qr(t){return Object.prototype.toString.call(t)==="[object Object]"}function ws(t){return new Promise(e=>{setTimeout(e,t)})}function Xt(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Gt(t,e)}catch(n){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`)}return Gt(t,e)}return e}function Es(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function Os(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var _t=Symbol();function Mr(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===_t&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===_t?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Ps=(An=class extends He{constructor(){super();w(this,De);w(this,ve);w(this,Xe);m(this,Xe,e=>{if(!ke&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){o(this,ve)||this.setEventListener(o(this,Xe))}onUnsubscribe(){var e;this.hasListeners()||((e=o(this,ve))==null||e.call(this),m(this,ve,void 0))}setEventListener(e){var r;m(this,Xe,e),(r=o(this,ve))==null||r.call(this),m(this,ve,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){o(this,De)!==e&&(m(this,De,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof o(this,De)=="boolean"?o(this,De):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},De=new WeakMap,ve=new WeakMap,Xe=new WeakMap,An),Jt=new Ps,Rs=(_n=class extends He{constructor(){super();w(this,Je,!0);w(this,we);w(this,Ze);m(this,Ze,e=>{if(!ke&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){o(this,we)||this.setEventListener(o(this,Ze))}onUnsubscribe(){var e;this.hasListeners()||((e=o(this,we))==null||e.call(this),m(this,we,void 0))}setEventListener(e){var r;m(this,Ze,e),(r=o(this,we))==null||r.call(this),m(this,we,e(this.setOnline.bind(this)))}setOnline(e){o(this,Je)!==e&&(m(this,Je,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return o(this,Je)}},Je=new WeakMap,we=new WeakMap,Ze=new WeakMap,_n),kt=new Rs;function Zt(){let t,e;const r=new Promise((s,a)=>{t=s,e=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function Ss(t){return Math.min(1e3*2**t,3e4)}function Nr(t){return(t??"online")==="online"?kt.isOnline():!0}var Ur=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function er(t){return t instanceof Ur}function Lr(t){let e=!1,r=0,n=!1,s;const a=Zt(),u=v=>{var O;n||(p(new Ur(v)),(O=t.abort)==null||O.call(t))},l=()=>{e=!0},c=()=>{e=!1},d=()=>Jt.isFocused()&&(t.networkMode==="always"||kt.isOnline())&&t.canRun(),h=()=>Nr(t.networkMode)&&t.canRun(),f=v=>{var O;n||(n=!0,(O=t.onSuccess)==null||O.call(t,v),s==null||s(),a.resolve(v))},p=v=>{var O;n||(n=!0,(O=t.onError)==null||O.call(t,v),s==null||s(),a.reject(v))},g=()=>new Promise(v=>{var O;s=_=>{(n||d())&&v(_)},(O=t.onPause)==null||O.call(t)}).then(()=>{var v;s=void 0,n||(v=t.onContinue)==null||v.call(t)}),P=()=>{if(n)return;let v;const O=r===0?t.initialPromise:void 0;try{v=O??t.fn()}catch(_){v=Promise.reject(_)}Promise.resolve(v).then(f).catch(_=>{var te;if(n)return;const x=t.retry??(ke?0:3),M=t.retryDelay??Ss,V=typeof M=="function"?M(r,_):M,Y=x===!0||typeof x=="number"&&r<x||typeof x=="function"&&x(r,_);if(e||!Y){p(_);return}r++,(te=t.onFail)==null||te.call(t,r,_),ws(V).then(()=>d()?void 0:g()).then(()=>{e?p(_):P()})})};return{promise:a,cancel:u,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:h,start:()=>(h()?P():g().then(P),a)}}function Cs(){let t=[],e=0,r=l=>{l()},n=l=>{l()},s=l=>setTimeout(l,0);const a=l=>{e?t.push(l):s(()=>{r(l)})},u=()=>{const l=t;t=[],l.length&&s(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||u()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{s=l}}}var K=Cs(),Qr=(kn=class{constructor(){w(this,qe)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bt(this.gcTime)&&m(this,qe,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(ke?1/0:5*60*1e3))}clearGcTimeout(){o(this,qe)&&(clearTimeout(o(this,qe)),m(this,qe,void 0))}},qe=new WeakMap,kn),Ts=(jn=class extends Qr{constructor(e){super();w(this,oe);w(this,et);w(this,tt);w(this,ne);w(this,Me);w(this,B);w(this,Pt);w(this,Ne);m(this,Ne,!1),m(this,Pt,e.defaultOptions),this.setOptions(e.options),this.observers=[],m(this,Me,e.client),m(this,ne,o(this,Me).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,m(this,et,xs(this.options)),this.state=e.state??o(this,et),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=o(this,B))==null?void 0:e.promise}setOptions(e){this.options={...o(this,Pt),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&o(this,ne).remove(this)}setData(e,r){const n=Xt(this.state.data,e,this.options);return R(this,oe,me).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){R(this,oe,me).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=o(this,B))==null?void 0:n.promise;return(s=o(this,B))==null||s.cancel(e),r?r.then(re).catch(re):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(o(this,et))}isActive(){return this.observers.some(e=>ie(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_t||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!kr(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,B))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,B))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),o(this,ne).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(o(this,B)&&(o(this,Ne)?o(this,B).cancel({revert:!0}):o(this,B).cancelRetry()),this.scheduleGc()),o(this,ne).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||R(this,oe,me).call(this,{type:"invalidate"})}fetch(e,r){var c,d,h;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(o(this,B))return o(this,B).continueRetry(),o(this,B).promise}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,s=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(m(this,Ne,!0),n.signal)})},a=()=>{const f=Mr(this.options,r),p={client:o(this,Me),queryKey:this.queryKey,meta:this.meta};return s(p),m(this,Ne,!1),this.options.persister?this.options.persister(f,p,this):f(p)},u={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:o(this,Me),state:this.state,fetchFn:a};s(u),(c=this.options.behavior)==null||c.onFetch(u,this),m(this,tt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=u.fetchOptions)==null?void 0:d.meta))&&R(this,oe,me).call(this,{type:"fetch",meta:(h=u.fetchOptions)==null?void 0:h.meta});const l=f=>{var p,g,P,v;er(f)&&f.silent||R(this,oe,me).call(this,{type:"error",error:f}),er(f)||((g=(p=o(this,ne).config).onError)==null||g.call(p,f,this),(v=(P=o(this,ne).config).onSettled)==null||v.call(P,this.state.data,f,this)),this.scheduleGc()};return m(this,B,Lr({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,g,P,v;if(f===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(O){l(O);return}(g=(p=o(this,ne).config).onSuccess)==null||g.call(p,f,this),(v=(P=o(this,ne).config).onSettled)==null||v.call(P,f,this.state.error,this),this.scheduleGc()},onError:l,onFail:(f,p)=>{R(this,oe,me).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{R(this,oe,me).call(this,{type:"pause"})},onContinue:()=>{R(this,oe,me).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0})),o(this,B).start()}},et=new WeakMap,tt=new WeakMap,ne=new WeakMap,Me=new WeakMap,B=new WeakMap,Pt=new WeakMap,Ne=new WeakMap,oe=new WeakSet,me=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...$r(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return er(s)&&s.revert&&o(this,tt)?{...o(this,tt),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),K.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),o(this,ne).notify({query:this,type:"updated",action:e})})},jn);function $r(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Nr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function xs(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Fs=(In=class extends He{constructor(e={}){super();w(this,ce);this.config=e,m(this,ce,new Map)}build(e,r,n){const s=r.queryKey,a=r.queryHash??Wt(s,r);let u=this.get(a);return u||(u=new Ts({client:e,queryKey:s,queryHash:a,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(u)),u}add(e){o(this,ce).has(e.queryHash)||(o(this,ce).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=o(this,ce).get(e.queryHash);r&&(e.destroy(),r===e&&o(this,ce).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){K.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return o(this,ce).get(e)}getAll(){return[...o(this,ce).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>jr(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>jr(e,n)):r}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){K.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){K.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ce=new WeakMap,In),As=(Dn=class extends Qr{constructor(e){super();w(this,fe);w(this,le);w(this,W);w(this,Ue);this.mutationId=e.mutationId,m(this,W,e.mutationCache),m(this,le,[]),this.state=e.state||Kr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){o(this,le).includes(e)||(o(this,le).push(e),this.clearGcTimeout(),o(this,W).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){m(this,le,o(this,le).filter(r=>r!==e)),this.scheduleGc(),o(this,W).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){o(this,le).length||(this.state.status==="pending"?this.scheduleGc():o(this,W).remove(this))}continue(){var e;return((e=o(this,Ue))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var s,a,u,l,c,d,h,f,p,g,P,v,O,_,x,M,V,Y,te,z;m(this,Ue,Lr({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(U,q)=>{R(this,fe,_e).call(this,{type:"failed",failureCount:U,error:q})},onPause:()=>{R(this,fe,_e).call(this,{type:"pause"})},onContinue:()=>{R(this,fe,_e).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>o(this,W).canRun(this)}));const r=this.state.status==="pending",n=!o(this,Ue).canStart();try{if(!r){R(this,fe,_e).call(this,{type:"pending",variables:e,isPaused:n}),await((a=(s=o(this,W).config).onMutate)==null?void 0:a.call(s,e,this));const q=await((l=(u=this.options).onMutate)==null?void 0:l.call(u,e));q!==this.state.context&&R(this,fe,_e).call(this,{type:"pending",context:q,variables:e,isPaused:n})}const U=await o(this,Ue).start();return await((d=(c=o(this,W).config).onSuccess)==null?void 0:d.call(c,U,e,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,U,e,this.state.context)),await((g=(p=o(this,W).config).onSettled)==null?void 0:g.call(p,U,null,this.state.variables,this.state.context,this)),await((v=(P=this.options).onSettled)==null?void 0:v.call(P,U,null,e,this.state.context)),R(this,fe,_e).call(this,{type:"success",data:U}),U}catch(U){try{throw await((_=(O=o(this,W).config).onError)==null?void 0:_.call(O,U,e,this.state.context,this)),await((M=(x=this.options).onError)==null?void 0:M.call(x,U,e,this.state.context)),await((Y=(V=o(this,W).config).onSettled)==null?void 0:Y.call(V,void 0,U,this.state.variables,this.state.context,this)),await((z=(te=this.options).onSettled)==null?void 0:z.call(te,void 0,U,e,this.state.context)),U}finally{R(this,fe,_e).call(this,{type:"error",error:U})}}finally{o(this,W).runNext(this)}}},le=new WeakMap,W=new WeakMap,Ue=new WeakMap,fe=new WeakSet,_e=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,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{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),K.batch(()=>{o(this,le).forEach(n=>{n.onMutationUpdate(e)}),o(this,W).notify({mutation:this,type:"updated",action:e})})},Dn);function Kr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _s=(qn=class extends He{constructor(e={}){super();w(this,de);w(this,ae);w(this,Rt);this.config=e,m(this,de,new Set),m(this,ae,new Map),m(this,Rt,0)}build(e,r,n){const s=new As({mutationCache:this,mutationId:++Kt(this,Rt)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){o(this,de).add(e);const r=jt(e);if(typeof r=="string"){const n=o(this,ae).get(r);n?n.push(e):o(this,ae).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(o(this,de).delete(e)){const r=jt(e);if(typeof r=="string"){const n=o(this,ae).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&o(this,ae).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=jt(e);if(typeof r=="string"){const n=o(this,ae).get(r),s=n==null?void 0:n.find(a=>a.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=jt(e);if(typeof r=="string"){const s=(n=o(this,ae).get(r))==null?void 0:n.find(a=>a!==e&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){K.batch(()=>{o(this,de).forEach(e=>{this.notify({type:"removed",mutation:e})}),o(this,de).clear(),o(this,ae).clear()})}getAll(){return Array.from(o(this,de))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Ir(r,n))}findAll(e={}){return this.getAll().filter(r=>Ir(e,r))}notify(e){K.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return K.batch(()=>Promise.all(e.map(r=>r.continue().catch(re))))}},de=new WeakMap,ae=new WeakMap,Rt=new WeakMap,qn);function jt(t){var e;return(e=t.options.scope)==null?void 0:e.id}function Vr(t){return{onFetch:(e,r)=>{var h,f,p,g,P;const n=e.options,s=(p=(f=(h=e.fetchOptions)==null?void 0:h.meta)==null?void 0:f.fetchMore)==null?void 0:p.direction,a=((g=e.state.data)==null?void 0:g.pages)||[],u=((P=e.state.data)==null?void 0:P.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let v=!1;const O=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},_=Mr(e.options,e.fetchOptions),x=async(M,V,Y)=>{if(v)return Promise.reject();if(V==null&&M.pages.length)return Promise.resolve(M);const te={client:e.client,queryKey:e.queryKey,pageParam:V,direction:Y?"backward":"forward",meta:e.options.meta};O(te);const z=await _(te),{maxPages:U}=e.options,q=Y?Os:Es;return{pages:q(M.pages,z,U),pageParams:q(M.pageParams,V,U)}};if(s&&a.length){const M=s==="backward",V=M?ks:zr,Y={pages:a,pageParams:u},te=V(n,Y);l=await x(Y,te,M)}else{const M=t??a.length;do{const V=c===0?u[0]??n.initialPageParam:zr(n,l);if(c>0&&V==null)break;l=await x(l,V),c++}while(c<M)}return l};e.options.persister?e.fetchFn=()=>{var v,O;return(O=(v=e.options).persister)==null?void 0:O.call(v,d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=d}}}function zr(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function ks(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var js=(Mn=class{constructor(t={}){w(this,L);w(this,Ee);w(this,Oe);w(this,rt);w(this,nt);w(this,Pe);w(this,st);w(this,it);m(this,L,t.queryCache||new Fs),m(this,Ee,t.mutationCache||new _s),m(this,Oe,t.defaultOptions||{}),m(this,rt,new Map),m(this,nt,new Map),m(this,Pe,0)}mount(){Kt(this,Pe)._++,o(this,Pe)===1&&(m(this,st,Jt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onFocus())})),m(this,it,kt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onOnline())})))}unmount(){var t,e;Kt(this,Pe)._--,o(this,Pe)===0&&((t=o(this,st))==null||t.call(this),m(this,st,void 0),(e=o(this,it))==null||e.call(this),m(this,it,void 0))}isFetching(t){return o(this,L).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return o(this,Ee).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=o(this,L).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=o(this,L).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Be(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return o(this,L).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=o(this,L).get(n.queryHash),a=s==null?void 0:s.state.data,u=vs(e,a);if(u!==void 0)return o(this,L).build(this,n).setData(u,{...r,manual:!0})}setQueriesData(t,e,r){return K.batch(()=>o(this,L).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=o(this,L).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=o(this,L);K.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=o(this,L);return K.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=K.batch(()=>o(this,L).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(re).catch(re)}invalidateQueries(t,e={}){return K.batch(()=>(o(this,L).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=K.batch(()=>o(this,L).findAll(t).filter(s=>!s.isDisabled()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(re)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(re)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=o(this,L).build(this,e);return r.isStaleByTime(Be(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(re).catch(re)}fetchInfiniteQuery(t){return t.behavior=Vr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(re).catch(re)}ensureInfiniteQueryData(t){return t.behavior=Vr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return kt.isOnline()?o(this,Ee).resumePausedMutations():Promise.resolve()}getQueryCache(){return o(this,L)}getMutationCache(){return o(this,Ee)}getDefaultOptions(){return o(this,Oe)}setDefaultOptions(t){m(this,Oe,t)}setQueryDefaults(t,e){o(this,rt).set(je(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...o(this,rt).values()],r={};return e.forEach(n=>{mt(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){o(this,nt).set(je(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...o(this,nt).values()],r={};return e.forEach(n=>{mt(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...o(this,Oe).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Wt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===_t&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...o(this,Oe).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){o(this,L).clear(),o(this,Ee).clear()}},L=new WeakMap,Ee=new WeakMap,Oe=new WeakMap,rt=new WeakMap,nt=new WeakMap,Pe=new WeakMap,st=new WeakMap,it=new WeakMap,Mn),Is=(Nn=class extends He{constructor(e,r){super();w(this,j);w(this,J);w(this,T);w(this,St);w(this,G);w(this,Le);w(this,ot);w(this,Re);w(this,he);w(this,Ct);w(this,at);w(this,ut);w(this,Qe);w(this,$e);w(this,Se);w(this,ct,new Set);this.options=r,m(this,J,e),m(this,he,null),m(this,Re,Zt()),this.options.experimental_prefetchInRender||o(this,Re).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(o(this,T).addObserver(this),Hr(o(this,T),this.options)?R(this,j,Ft).call(this):this.updateResult(),R(this,j,Rr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return tr(o(this,T),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return tr(o(this,T),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,R(this,j,Sr).call(this),R(this,j,Cr).call(this),o(this,T).removeObserver(this)}setOptions(e,r){const n=this.options,s=o(this,T);if(this.options=o(this,J).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ie(this.options.enabled,o(this,T))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");R(this,j,Tr).call(this),o(this,T).setOptions(this.options),n._defaulted&&!At(this.options,n)&&o(this,J).getQueryCache().notify({type:"observerOptionsUpdated",query:o(this,T),observer:this});const a=this.hasListeners();a&&Br(o(this,T),s,this.options,n)&&R(this,j,Ft).call(this),this.updateResult(r),a&&(o(this,T)!==s||ie(this.options.enabled,o(this,T))!==ie(n.enabled,o(this,T))||Be(this.options.staleTime,o(this,T))!==Be(n.staleTime,o(this,T)))&&R(this,j,Er).call(this);const u=R(this,j,Or).call(this);a&&(o(this,T)!==s||ie(this.options.enabled,o(this,T))!==ie(n.enabled,o(this,T))||u!==o(this,Se))&&R(this,j,Pr).call(this,u)}getOptimisticResult(e){const r=o(this,J).getQueryCache().build(o(this,J),e),n=this.createResult(r,e);return qs(this,n)&&(m(this,G,n),m(this,ot,this.options),m(this,Le,o(this,T).state)),n}getCurrentResult(){return o(this,G)}trackResult(e,r){const n={};return Object.keys(e).forEach(s=>{Object.defineProperty(n,s,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(s),r==null||r(s),e[s])})}),n}trackProp(e){o(this,ct).add(e)}getCurrentQuery(){return o(this,T)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=o(this,J).defaultQueryOptions(e),n=o(this,J).getQueryCache().build(o(this,J),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return R(this,j,Ft).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),o(this,G)))}createResult(e,r){var U;const n=o(this,T),s=this.options,a=o(this,G),u=o(this,Le),l=o(this,ot),d=e!==n?e.state:o(this,St),{state:h}=e;let f={...h},p=!1,g;if(r._optimisticResults){const q=this.hasListeners(),xe=!q&&Hr(e,r),Fe=q&&Br(e,n,r,s);(xe||Fe)&&(f={...f,...$r(h.data,e.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:P,errorUpdatedAt:v,status:O}=f;if(r.select&&f.data!==void 0)if(a&&f.data===(u==null?void 0:u.data)&&r.select===o(this,Ct))g=o(this,at);else try{m(this,Ct,r.select),g=r.select(f.data),g=Xt(a==null?void 0:a.data,g,r),m(this,at,g),m(this,he,null)}catch(q){m(this,he,q)}else g=f.data;if(r.placeholderData!==void 0&&g===void 0&&O==="pending"){let q;if(a!=null&&a.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData))q=a.data;else if(q=typeof r.placeholderData=="function"?r.placeholderData((U=o(this,ut))==null?void 0:U.state.data,o(this,ut)):r.placeholderData,r.select&&q!==void 0)try{q=r.select(q),m(this,he,null)}catch(xe){m(this,he,xe)}q!==void 0&&(O="success",g=Xt(a==null?void 0:a.data,q,r),p=!0)}o(this,he)&&(P=o(this,he),g=o(this,at),v=Date.now(),O="error");const _=f.fetchStatus==="fetching",x=O==="pending",M=O==="error",V=x&&_,Y=g!==void 0,z={status:O,fetchStatus:f.fetchStatus,isPending:x,isSuccess:O==="success",isError:M,isInitialLoading:V,isLoading:V,data:g,dataUpdatedAt:f.dataUpdatedAt,error:P,errorUpdatedAt:v,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:_,isRefetching:_&&!x,isLoadingError:M&&!Y,isPaused:f.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:M&&Y,isStale:rr(e,r),refetch:this.refetch,promise:o(this,Re)};if(this.options.experimental_prefetchInRender){const q=Ke=>{z.status==="error"?Ke.reject(z.error):z.data!==void 0&&Ke.resolve(z.data)},xe=()=>{const Ke=m(this,Re,z.promise=Zt());q(Ke)},Fe=o(this,Re);switch(Fe.status){case"pending":e.queryHash===n.queryHash&&q(Fe);break;case"fulfilled":(z.status==="error"||z.data!==Fe.value)&&xe();break;case"rejected":(z.status!=="error"||z.error!==Fe.reason)&&xe();break}}return z}updateResult(e){const r=o(this,G),n=this.createResult(o(this,T),this.options);if(m(this,Le,o(this,T).state),m(this,ot,this.options),o(this,Le).data!==void 0&&m(this,ut,o(this,T)),At(n,r))return;m(this,G,n);const s={},a=()=>{if(!r)return!0;const{notifyOnChangeProps:u}=this.options,l=typeof u=="function"?u():u;if(l==="all"||!l&&!o(this,ct).size)return!0;const c=new Set(l??o(this,ct));return this.options.throwOnError&&c.add("error"),Object.keys(o(this,G)).some(d=>{const h=d;return o(this,G)[h]!==r[h]&&c.has(h)})};(e==null?void 0:e.listeners)!==!1&&a()&&(s.listeners=!0),R(this,j,ms).call(this,{...s,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&R(this,j,Rr).call(this)}},J=new WeakMap,T=new WeakMap,St=new WeakMap,G=new WeakMap,Le=new WeakMap,ot=new WeakMap,Re=new WeakMap,he=new WeakMap,Ct=new WeakMap,at=new WeakMap,ut=new WeakMap,Qe=new WeakMap,$e=new WeakMap,Se=new WeakMap,ct=new WeakMap,j=new WeakSet,Ft=function(e){R(this,j,Tr).call(this);let r=o(this,T).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(re)),r},Er=function(){R(this,j,Sr).call(this);const e=Be(this.options.staleTime,o(this,T));if(ke||o(this,G).isStale||!Bt(e))return;const n=kr(o(this,G).dataUpdatedAt,e)+1;m(this,Qe,setTimeout(()=>{o(this,G).isStale||this.updateResult()},n))},Or=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(o(this,T)):this.options.refetchInterval)??!1},Pr=function(e){R(this,j,Cr).call(this),m(this,Se,e),!(ke||ie(this.options.enabled,o(this,T))===!1||!Bt(o(this,Se))||o(this,Se)===0)&&m(this,$e,setInterval(()=>{(this.options.refetchIntervalInBackground||Jt.isFocused())&&R(this,j,Ft).call(this)},o(this,Se)))},Rr=function(){R(this,j,Er).call(this),R(this,j,Pr).call(this,R(this,j,Or).call(this))},Sr=function(){o(this,Qe)&&(clearTimeout(o(this,Qe)),m(this,Qe,void 0))},Cr=function(){o(this,$e)&&(clearInterval(o(this,$e)),m(this,$e,void 0))},Tr=function(){const e=o(this,J).getQueryCache().build(o(this,J),this.options);if(e===o(this,T))return;const r=o(this,T);m(this,T,e),m(this,St,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},ms=function(e){K.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(o(this,G))}),o(this,J).getQueryCache().notify({query:o(this,T),type:"observerResultsUpdated"})})},Nn);function Ds(t,e){return ie(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Hr(t,e){return Ds(t,e)||t.state.data!==void 0&&tr(t,e,e.refetchOnMount)}function tr(t,e,r){if(ie(e.enabled,t)!==!1){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&rr(t,e)}return!1}function Br(t,e,r,n){return(t!==e||ie(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&rr(t,r)}function rr(t,e){return ie(e.enabled,t)!==!1&&t.isStaleByTime(Be(e.staleTime,t))}function qs(t,e){return!At(t.getCurrentResult(),e)}var Ms=(Un=class extends He{constructor(e,r){super();w(this,pe);w(this,Ce);w(this,Te);w(this,Z);w(this,ye);m(this,Ce,e),this.setOptions(r),this.bindMethods(),R(this,pe,Vt).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var n;const r=this.options;this.options=o(this,Ce).defaultMutationOptions(e),At(this.options,r)||o(this,Ce).getMutationCache().notify({type:"observerOptionsUpdated",mutation:o(this,Z),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&je(r.mutationKey)!==je(this.options.mutationKey)?this.reset():((n=o(this,Z))==null?void 0:n.state.status)==="pending"&&o(this,Z).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||(e=o(this,Z))==null||e.removeObserver(this)}onMutationUpdate(e){R(this,pe,Vt).call(this),R(this,pe,xr).call(this,e)}getCurrentResult(){return o(this,Te)}reset(){var e;(e=o(this,Z))==null||e.removeObserver(this),m(this,Z,void 0),R(this,pe,Vt).call(this),R(this,pe,xr).call(this)}mutate(e,r){var n;return m(this,ye,r),(n=o(this,Z))==null||n.removeObserver(this),m(this,Z,o(this,Ce).getMutationCache().build(o(this,Ce),this.options)),o(this,Z).addObserver(this),o(this,Z).execute(e)}},Ce=new WeakMap,Te=new WeakMap,Z=new WeakMap,ye=new WeakMap,pe=new WeakSet,Vt=function(){var r;const e=((r=o(this,Z))==null?void 0:r.state)??Kr();m(this,Te,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},xr=function(e){K.batch(()=>{var r,n,s,a,u,l,c,d;if(o(this,ye)&&this.hasListeners()){const h=o(this,Te).variables,f=o(this,Te).context;(e==null?void 0:e.type)==="success"?((n=(r=o(this,ye)).onSuccess)==null||n.call(r,e.data,h,f),(a=(s=o(this,ye)).onSettled)==null||a.call(s,e.data,null,h,f)):(e==null?void 0:e.type)==="error"&&((l=(u=o(this,ye)).onError)==null||l.call(u,e.error,h,f),(d=(c=o(this,ye)).onSettled)==null||d.call(c,void 0,e.error,h,f))}this.listeners.forEach(h=>{h(o(this,Te))})})},Un),Wr=N.createContext(void 0),It=t=>{const e=N.useContext(Wr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ns=({client:t,children:e})=>(N.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),pt.jsx(Wr.Provider,{value:t,children:e})),Gr=N.createContext(!1),Us=()=>N.useContext(Gr);Gr.Provider;function Ls(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Qs=N.createContext(Ls()),$s=()=>N.useContext(Qs);function Yr(t,e){return typeof t=="function"?t(...e):!!t}function nr(){}var Ks=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Vs=t=>{N.useEffect(()=>{t.clearReset()},[t])},zs=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Yr(r,[t.error,n])),Hs=t=>{const e=t.staleTime;t.suspense&&(t.staleTime=typeof e=="function"?(...r)=>Math.max(e(...r),1e3):Math.max(e??1e3,1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},Bs=(t,e)=>t.isLoading&&t.isFetching&&!e,Ws=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Xr=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Gs(t,e,r){var f,p,g,P,v;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=It(),s=Us(),a=$s(),u=n.defaultQueryOptions(t);(p=(f=n.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||p.call(f,u),process.env.NODE_ENV!=="production"&&(u.queryFn||console.error(`[${u.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),u._optimisticResults=s?"isRestoring":"optimistic",Hs(u),Ks(u,a),Vs(a);const l=!n.getQueryCache().get(u.queryHash),[c]=N.useState(()=>new e(n,u)),d=c.getOptimisticResult(u),h=!s&&t.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(O=>{const _=h?c.subscribe(K.batchCalls(O)):nr;return c.updateResult(),_},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(u,{listeners:!1})},[u,c]),Ws(u,d))throw Xr(u,c,a);if(zs({result:d,errorResetBoundary:a,throwOnError:u.throwOnError,query:n.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw d.error;if((P=(g=n.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||P.call(g,u,d),u.experimental_prefetchInRender&&!ke&&Bs(d,s)){const O=l?Xr(u,c,a):(v=n.getQueryCache().get(u.queryHash))==null?void 0:v.promise;O==null||O.catch(nr).finally(()=>{c.updateResult()})}return u.notifyOnChangeProps?d:c.trackResult(d)}function Jr(t,e){return Gs(t,Is)}function Zr(t,e){const r=It(),[n]=N.useState(()=>new Ms(r,t));N.useEffect(()=>{n.setOptions(t)},[n,t]);const s=N.useSyncExternalStore(N.useCallback(u=>n.subscribe(K.batchCalls(u)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=N.useCallback((u,l)=>{n.mutate(u,l).catch(nr)},[n]);if(s.error&&Yr(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}function We(t){const e={subscribe(r){let n=null,s=!1,a=!1,u=!1;function l(){if(n===null){u=!0;return}a||(a=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){var d;s||(d=r.next)==null||d.call(r,c)},error(c){var d;s||(s=!0,(d=r.error)==null||d.call(r,c),l())},complete(){var c;s||(s=!0,(c=r.complete)==null||c.call(r),l())}}),u&&l(),{unsubscribe:l}},pipe(...r){return r.reduce(Ys,e)}};return e}function Ys(t,e){return e(t)}function Xs(t){const e=new AbortController;return new Promise((n,s)=>{let a=!1;function u(){a||(a=!0,l.unsubscribe())}e.signal.addEventListener("abort",()=>{s(e.signal.reason)});const l=t.subscribe({next(c){a=!0,n(c),u()},error(c){s(c)},complete(){e.abort(),u()}})})}function Js(t){return e=>{let r=0,n=null;const s=[];function a(){n||(n=e.subscribe({next(l){var c;for(const d of s)(c=d.next)==null||c.call(d,l)},error(l){var c;for(const d of s)(c=d.error)==null||c.call(d,l)},complete(){var l;for(const c of s)(l=c.complete)==null||l.call(c)}}))}function u(){if(r===0&&n){const l=n;n=null,l.unsubscribe()}}return We(l=>(r++,s.push(l),a(),{unsubscribe(){r--,u();const c=s.findIndex(d=>d===l);c>-1&&s.splice(c,1)}}))}}function Zs(t){return e=>We(r=>e.subscribe({next(n){var s;(s=t.next)==null||s.call(t,n),r.next(n)},error(n){var s;(s=t.error)==null||s.call(t,n),r.error(n)},complete(){var n;(n=t.complete)==null||n.call(t),r.complete()}}))}function ei(t){let e=t;const r=[],n=u=>{e!==void 0&&u.next(e),r.push(u)},s=u=>{r.splice(r.indexOf(u),1)},a=We(u=>(n(u),()=>{s(u)}));return a.next=u=>{if(e!==u){e=u;for(const l of r)l.next(u)}},a.get=()=>e,a}function ti(t){return We(e=>{function r(s=0,a=t.op){const u=t.links[s];if(!u)throw new Error("No more links to execute - did you forget to add an ending link?");return u({op:a,next(c){return r(s+1,c)}})}return r().subscribe(e)})}const en=()=>{},tn=t=>{Object.freeze&&Object.freeze(t)};function rn(t,e,r){var n,s;const a=e.join(".");return(n=r)[s=a]??(n[s]=new Proxy(en,{get(u,l){if(!(typeof l!="string"||l==="then"))return rn(t,[...e,l],r)},apply(u,l,c){const d=e[e.length-1];let h={args:c,path:e};return d==="call"?h={args:c.length>=2?[c[1]]:[],path:e.slice(0,-1)}:d==="apply"&&(h={args:c.length>=2?c[1]:[],path:e.slice(0,-1)}),tn(h.args),tn(h.path),t(h)}})),r[a]}const ri=t=>rn(t,[],Object.create(null)),ni=t=>new Proxy(en,{get(e,r){if(r!=="then")return t(r)}});function gt(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function si(t,e){if("error"in t){const n=e.deserialize(t.error);return{ok:!1,error:{...t,error:n}}}return{ok:!0,result:{...t.result,...(!t.result.type||t.result.type==="data")&&{type:"data",data:e.deserialize(t.result.data)}}}}class sr extends Error{constructor(){super("Unable to transform response from server")}}function ii(t,e){let r;try{r=si(t,e)}catch{throw new sr}if(!r.ok&&(!gt(r.error.error)||typeof r.error.error.code!="number"))throw new sr;if(r.ok&&!gt(r.result))throw new sr;return r}var nn,sn;(nn=Symbol).dispose??(nn.dispose=Symbol()),(sn=Symbol).asyncDispose??(sn.asyncDispose=Symbol()),typeof window>"u"||"Deno"in window||((Qn=(Ln=globalThis.process)==null?void 0:Ln.env)==null?void 0:Qn.NODE_ENV)==="test"||(Kn=($n=globalThis.process)==null?void 0:$n.env)!=null&&Kn.JEST_WORKER_ID||(zn=(Vn=globalThis.process)==null?void 0:Vn.env)!=null&&zn.VITEST_WORKER_ID;function Dt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oi(t){return t instanceof ge||t instanceof Error&&t.name==="TRPCClientError"}function ai(t){return gt(t)&>(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function ui(t,e){return typeof t=="string"?t:gt(t)&&typeof t.message=="string"?t.message:e}class ge extends Error{static from(e,r={}){const n=e;return oi(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):ai(n)?new ge(n.error.message,{...r,result:n}):new ge(ui(n,"Unknown error"),{...r,cause:n})}constructor(e,r){var s,a;const n=r==null?void 0:r.cause;super(e,{cause:n}),Dt(this,"cause",void 0),Dt(this,"shape",void 0),Dt(this,"data",void 0),Dt(this,"meta",void 0),this.meta=r==null?void 0:r.meta,this.cause=n,this.shape=(s=r==null?void 0:r.result)==null?void 0:s.error,this.data=(a=r==null?void 0:r.result)==null?void 0:a.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,ge.prototype)}}function ir(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class ci{$request(e){return ti({links:this.links,op:{...e,context:e.context??{},id:++this.requestId}}).pipe(Js())}async requestAsPromise(e){try{const r=this.$request(e);return(await Xs(r)).result.data}catch(r){throw ge.from(r)}}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n.context,signal:n.signal}).subscribe({next(a){var u,l,c,d;switch(a.result.type){case"state":{(u=n.onConnectionStateChange)==null||u.call(n,a.result);break}case"started":{(l=n.onStarted)==null||l.call(n,{context:a.context});break}case"stopped":{(c=n.onStopped)==null||c.call(n);break}case"data":case void 0:{(d=n.onData)==null||d.call(n,a.result.data);break}}},error(a){var u;(u=n.onError)==null||u.call(n,a)},complete(){var a;(a=n.onComplete)==null||a.call(n)}})}constructor(e){ir(this,"links",void 0),ir(this,"runtime",void 0),ir(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(r=>r(this.runtime))}}const li=Symbol.for("trpc_untypedClient"),fi={query:"query",mutate:"mutation",subscribe:"subscription"},hi=t=>fi[t];function di(t){const e=ri(({path:r,args:n})=>{const s=[...r],a=hi(s.pop()),u=s.join(".");return t[a](u,...n)});return ni(r=>r===li?t:e[r])}function yi(t){const e=new ci(t);return di(e)}const on=t=>typeof t=="function";function pi(t){if(t)return t;if(typeof window<"u"&&on(window.fetch))return window.fetch;if(typeof globalThis<"u"&&on(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}const an=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function un(t){let e=null,r=null;const n=()=>{clearTimeout(r),r=null,e=null};function s(l){var h,f;const c=[[]];let d=0;for(;;){const p=l[d];if(!p)break;const g=c[c.length-1];if(p.aborted){(h=p.reject)==null||h.call(p,new Error("Aborted")),d++;continue}if(t.validate(g.concat(p).map(v=>v.key))){g.push(p),d++;continue}if(g.length===0){(f=p.reject)==null||f.call(p,new Error("Input is too big for a single dispatch")),d++;continue}c.push([])}return c}function a(){const l=s(e);n();for(const c of l){if(!c.length)continue;const d={items:c};for(const f of c)f.batch=d;t.fetch(d.items.map(f=>f.key)).then(async f=>{var p;await Promise.all(f.map(async(g,P)=>{var O,_;const v=d.items[P];try{const x=await Promise.resolve(g);(O=v.resolve)==null||O.call(v,x)}catch(x){(_=v.reject)==null||_.call(v,x)}v.batch=null,v.reject=null,v.resolve=null}));for(const g of d.items)(p=g.reject)==null||p.call(g,new Error("Missing result")),g.batch=null}).catch(f=>{var p;for(const g of d.items)(p=g.reject)==null||p.call(g,f),g.batch=null})}}function u(l){const c={aborted:!1,key:l,batch:null,resolve:an,reject:an},d=new Promise((h,f)=>{c.reject=f,c.resolve=h,e||(e=[]),e.push(c)});return r||(r=setTimeout(a)),d}return{load:u}}function mi(...t){const e=new AbortController,r=t.length;let n=0;const s=()=>{++n===r&&e.abort()};for(const a of t)a!=null&&a.aborted?s():a==null||a.addEventListener("abort",s,{once:!0});return e.signal}function gi(t){const e=t;return e?"input"in e?e:{input:e,output:e}:{input:{serialize:r=>r,deserialize:r=>r},output:{serialize:r=>r,deserialize:r=>r}}}function bi(t){return{url:t.url.toString(),fetch:t.fetch,transformer:gi(t.transformer),methodOverride:t.methodOverride}}function vi(t){const e={};for(let r=0;r<t.length;r++){const n=t[r];e[r]=n}return e}const wi={query:"GET",mutation:"POST",subscription:"PATCH"};function cn(t){return"input"in t?t.transformer.input.serialize(t.input):vi(t.inputs.map(e=>t.transformer.input.serialize(e)))}const ln=t=>{const e=t.url.split("?");let n=e[0].replace(/\/$/,"")+"/"+t.path;const s=[];if(e[1]&&s.push(e[1]),"inputs"in t&&s.push("batch=1"),t.type==="query"||t.type==="subscription"){const a=cn(t);a!==void 0&&t.methodOverride!=="POST"&&s.push(`input=${encodeURIComponent(JSON.stringify(a))}`)}return s.length&&(n+="?"+s.join("&")),n},Ei=t=>{if(t.type==="query"&&t.methodOverride!=="POST")return;const e=cn(t);return e!==void 0?JSON.stringify(e):void 0},Oi=t=>Ci({...t,contentTypeHeader:"application/json",getUrl:ln,getBody:Ei});class Pi extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}}const Ri=t=>{var e;if(t!=null&&t.aborted)throw(e=t.throwIfAborted)==null||e.call(t),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new Pi};async function Si(t){Ri(t.signal);const e=t.getUrl(t),r=t.getBody(t),{type:n}=t,s=await(async()=>{const u=await t.headers();return Symbol.iterator in u?Object.fromEntries(u):u})(),a={...t.contentTypeHeader?{"content-type":t.contentTypeHeader}:{},...t.trpcAcceptHeader?{"trpc-accept":t.trpcAcceptHeader}:void 0,...s};return pi(t.fetch)(e,{method:t.methodOverride??wi[n],signal:t.signal,body:r,headers:a})}async function Ci(t){const e={},r=await Si(t);e.response=r;const n=await r.json();return e.responseJSON=n,{json:n,meta:e}}function Ti(t){const e=bi(t),r=t.maxURLLength??1/0;return()=>{const n=l=>({validate(c){if(r===1/0)return!0;const d=c.map(p=>p.path).join(","),h=c.map(p=>p.input);return ln({...e,type:l,path:d,inputs:h,signal:null}).length<=r},async fetch(c){const d=c.map(v=>v.path).join(","),h=c.map(v=>v.input),f=mi(...c.map(v=>v.signal)),p=await Oi({...e,path:d,inputs:h,type:l,headers(){return t.headers?typeof t.headers=="function"?t.headers({opList:c}):t.headers:{}},signal:f});return(Array.isArray(p.json)?p.json:c.map(()=>p.json)).map(v=>({meta:p.meta,json:v}))}}),s=un(n("query")),a=un(n("mutation")),u={query:s,mutation:a};return({op:l})=>We(c=>{/* istanbul ignore if -- @preserve */if(l.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const h=u[l.type].load(l);let f;return h.then(p=>{f=p;const g=ii(p.json,e.transformer.output);if(!g.ok){c.error(ge.from(g.error,{meta:p.meta}));return}c.next({context:p.meta,result:g.result}),c.complete()}).catch(p=>{c.error(ge.from(p,{meta:f==null?void 0:f.meta}))}),()=>{}})}}function xi(t){return typeof FormData>"u"?!1:t instanceof FormData}const or={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"]}}};function Fi(t){const{direction:e,type:r,withContext:n,path:s,id:a,input:u}=t,l=[],c=[];if(t.colorMode==="none")l.push(e==="up"?">>":"<<",r,`#${a}`,s);else if(t.colorMode==="ansi"){const[d,h]=or.ansi.regular[r],[f,p]=or.ansi.bold[r];l.push(e==="up"?d:h,e==="up"?">>":"<<",r,e==="up"?f:p,`#${a}`,s,"\x1B[0m")}else{const[d,h]=or.css[r],f=`
|
|
31
31
|
background-color: #${e==="up"?d:h};
|
|
32
32
|
color: ${e==="up"?"black":"white"};
|
|
33
33
|
padding: 2px;
|
|
34
|
-
`;l.push("%c",e==="up"?">>":"<<",r,`#${a}`,`%c${s}%c`,"%O"),c.push(f,`${f}; font-weight: bold;`,`${f}; font-weight: normal;`)}return e==="up"?c.push(n?{input:u,context:t.context}:{input:u}):c.push({input:u,result:t.result,elapsedMs:t.elapsedMs,...n&&{context:t.context}}),{parts:l,args:c}}const Ai=({c:t=console,colorMode:e="css",withContext:r})=>n=>{const s=n.input,a=xi(s)?Object.fromEntries(s):s,{parts:u,args:l}=Fi({...n,colorMode:e,input:a,withContext:r}),c=n.direction==="down"&&n.result&&(n.result instanceof Error||"error"in n.result.result&&n.result.result.error)?"error":"log";t[c].apply(null,[u.join(" ")].concat(l))};function _i(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),n=t.withContext??r==="css",{logger:s=Ai({c:t.console,colorMode:r,withContext:n})}=t;return()=>({op:a,next:u})=>We(l=>{e({...a,direction:"up"})&&s({...a,direction:"up"});const c=Date.now();function d(h){const f=Date.now()-c;e({...a,direction:"down",result:h})&&s({...a,direction:"down",elapsedMs:f,result:h})}return u(a).pipe(Zs({next(h){d(h)},error(h){d(h)}})).subscribe(l)})}const ki=(t,...e)=>typeof t=="function"?t(...e):t;function Ii(){let t,e;return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}async function ji(t){const e=await ki(t.url);if(!t.connectionParams)return e;const n=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+n}function je(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Di(t){const{promise:e,resolve:r,reject:n}=Ii();return t.addEventListener("open",()=>{t.removeEventListener("error",n),r()}),t.addEventListener("error",n),e}function qi(t,{intervalMs:e,pongTimeoutMs:r}){let n,s;function a(){n=setTimeout(()=>{t.send("PING"),s=setTimeout(()=>{t.close()},r)},e)}function u(){clearTimeout(n),a()}function l(){clearTimeout(s),u()}t.addEventListener("open",a),t.addEventListener("message",({data:c})=>{clearTimeout(n),a(),c==="PONG"&&l()}),t.addEventListener("close",()=>{clearTimeout(n),clearTimeout(s)})}class qt{get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){if(this.openPromise)return this.openPromise;this.id=++qt.connectCount;const e=ji(this.urlOptions).then(r=>new this.WebSocketPonyfill(r));this.openPromise=e.then(Di),this.ws=await e,this.ws.addEventListener("message",function({data:r}){r==="PING"&&this.send("PONG")}),this.keepAliveOpts.enabled&&qi(this.ws,this.keepAliveOpts),this.ws.addEventListener("close",()=>{this.ws=null});try{await this.openPromise}finally{this.openPromise=null}}async close(){var e;try{await this.openPromise}finally{(e=this.ws)==null||e.close()}}constructor(e){if(je(this,"id",++qt.connectCount),je(this,"WebSocketPonyfill",void 0),je(this,"urlOptions",void 0),je(this,"keepAliveOpts",void 0),je(this,"wsObservable",ei(null)),je(this,"openPromise",null),this.WebSocketPonyfill=e.WebSocketPonyfill??WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=e.urlOptions,this.keepAliveOpts=e.keepAlive}}je(qt,"connectCount",0);class Mi{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,r){this.keyToValue.set(e,r),this.valueToKey.set(r,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class fn{constructor(e){this.generateIdentifier=e,this.kv=new Mi}register(e,r){this.kv.getByValue(e)||(r||(r=this.generateIdentifier(e)),this.kv.set(r,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}}class Ni extends fn{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,r){typeof r=="object"?(r.allowProps&&this.classToAllowedProps.set(e,r.allowProps),super.register(e,r.identifier)):super.register(e,r)}getAllowedProps(e){return this.classToAllowedProps.get(e)}}function Ui(t){if("values"in Object)return Object.values(t);const e=[];for(const r in t)t.hasOwnProperty(r)&&e.push(t[r]);return e}function Li(t,e){const r=Ui(t);if("find"in r)return r.find(e);const n=r;for(let s=0;s<n.length;s++){const a=n[s];if(e(a))return a}}function Ge(t,e){Object.entries(t).forEach(([r,n])=>e(n,r))}function Mt(t,e){return t.indexOf(e)!==-1}function hn(t,e){for(let r=0;r<t.length;r++){const n=t[r];if(e(n))return n}}class Qi{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Li(this.transfomers,r=>r.isApplicable(e))}findByName(e){return this.transfomers[e]}}const $i=t=>Object.prototype.toString.call(t).slice(8,-1),dn=t=>typeof t>"u",Ki=t=>t===null,bt=t=>typeof t!="object"||t===null||t===Object.prototype?!1:Object.getPrototypeOf(t)===null?!0:Object.getPrototypeOf(t)===Object.prototype,ar=t=>bt(t)&&Object.keys(t).length===0,be=t=>Array.isArray(t),Vi=t=>typeof t=="string",zi=t=>typeof t=="number"&&!isNaN(t),Hi=t=>typeof t=="boolean",Bi=t=>t instanceof RegExp,vt=t=>t instanceof Map,wt=t=>t instanceof Set,yn=t=>$i(t)==="Symbol",Wi=t=>t instanceof Date&&!isNaN(t.valueOf()),Gi=t=>t instanceof Error,pn=t=>typeof t=="number"&&isNaN(t),Yi=t=>Hi(t)||Ki(t)||dn(t)||zi(t)||Vi(t)||yn(t),Xi=t=>typeof t=="bigint",Ji=t=>t===1/0||t===-1/0,Zi=t=>ArrayBuffer.isView(t)&&!(t instanceof DataView),eo=t=>t instanceof URL,mn=t=>t.replace(/\./g,"\\."),ur=t=>t.map(String).map(mn).join("."),Et=t=>{const e=[];let r="";for(let s=0;s<t.length;s++){let a=t.charAt(s);if(a==="\\"&&t.charAt(s+1)==="."){r+=".",s++;continue}if(a==="."){e.push(r),r="";continue}r+=a}const n=r;return e.push(n),e};function ue(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const gn=[ue(dn,"undefined",()=>null,()=>{}),ue(Xi,"bigint",t=>t.toString(),t=>typeof BigInt<"u"?BigInt(t):(console.error("Please add a BigInt polyfill."),t)),ue(Wi,"Date",t=>t.toISOString(),t=>new Date(t)),ue(Gi,"Error",(t,e)=>{const r={name:t.name,message:t.message};return e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r},(t,e)=>{const r=new Error(t.message);return r.name=t.name,r.stack=t.stack,e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r}),ue(Bi,"regexp",t=>""+t,t=>{const e=t.slice(1,t.lastIndexOf("/")),r=t.slice(t.lastIndexOf("/")+1);return new RegExp(e,r)}),ue(wt,"set",t=>[...t.values()],t=>new Set(t)),ue(vt,"map",t=>[...t.entries()],t=>new Map(t)),ue(t=>pn(t)||Ji(t),"number",t=>pn(t)?"NaN":t>0?"Infinity":"-Infinity",Number),ue(t=>t===0&&1/t===-1/0,"number",()=>"-0",Number),ue(eo,"URL",t=>t.toString(),t=>new URL(t))];function Nt(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const bn=Nt((t,e)=>yn(t)?!!e.symbolRegistry.getIdentifier(t):!1,(t,e)=>["symbol",e.symbolRegistry.getIdentifier(t)],t=>t.description,(t,e,r)=>{const n=r.symbolRegistry.getValue(e[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),to=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((t,e)=>(t[e.name]=e,t),{}),vn=Nt(Zi,t=>["typed-array",t.constructor.name],t=>[...t],(t,e)=>{const r=to[e[1]];if(!r)throw new Error("Trying to deserialize unknown typed array");return new r(t)});function wn(t,e){return t!=null&&t.constructor?!!e.classRegistry.getIdentifier(t.constructor):!1}const En=Nt(wn,(t,e)=>["class",e.classRegistry.getIdentifier(t.constructor)],(t,e)=>{const r=e.classRegistry.getAllowedProps(t.constructor);if(!r)return{...t};const n={};return r.forEach(s=>{n[s]=t[s]}),n},(t,e,r)=>{const n=r.classRegistry.getValue(e[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${e[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),t)}),On=Nt((t,e)=>!!e.customTransformerRegistry.findApplicable(t),(t,e)=>["custom",e.customTransformerRegistry.findApplicable(t).name],(t,e)=>e.customTransformerRegistry.findApplicable(t).serialize(t),(t,e,r)=>{const n=r.customTransformerRegistry.findByName(e[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(t)}),ro=[En,bn,On,vn],Pn=(t,e)=>{const r=hn(ro,s=>s.isApplicable(t,e));if(r)return{value:r.transform(t,e),type:r.annotation(t,e)};const n=hn(gn,s=>s.isApplicable(t,e));if(n)return{value:n.transform(t,e),type:n.annotation}},Rn={};gn.forEach(t=>{Rn[t.annotation]=t});const no=(t,e,r)=>{if(be(e))switch(e[0]){case"symbol":return bn.untransform(t,e,r);case"class":return En.untransform(t,e,r);case"custom":return On.untransform(t,e,r);case"typed-array":return vn.untransform(t,e,r);default:throw new Error("Unknown transformation: "+e)}else{const n=Rn[e];if(!n)throw new Error("Unknown transformation: "+e);return n.untransform(t,r)}},Ye=(t,e)=>{if(e>t.size)throw new Error("index out of bounds");const r=t.keys();for(;e>0;)r.next(),e--;return r.next().value};function Sn(t){if(Mt(t,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Mt(t,"prototype"))throw new Error("prototype is not allowed as a property");if(Mt(t,"constructor"))throw new Error("constructor is not allowed as a property")}const so=(t,e)=>{Sn(e);for(let r=0;r<e.length;r++){const n=e[r];if(wt(t))t=Ye(t,+n);else if(vt(t)){const s=+n,a=+e[++r]==0?"key":"value",u=Ye(t,s);switch(a){case"key":t=u;break;case"value":t=t.get(u);break}}else t=t[n]}return t},cr=(t,e,r)=>{if(Sn(e),e.length===0)return r(t);let n=t;for(let a=0;a<e.length-1;a++){const u=e[a];if(be(n)){const l=+u;n=n[l]}else if(bt(n))n=n[u];else if(wt(n)){const l=+u;n=Ye(n,l)}else if(vt(n)){if(a===e.length-2)break;const c=+u,d=+e[++a]==0?"key":"value",h=Ye(n,c);switch(d){case"key":n=h;break;case"value":n=n.get(h);break}}}const s=e[e.length-1];if(be(n)?n[+s]=r(n[+s]):bt(n)&&(n[s]=r(n[s])),wt(n)){const a=Ye(n,+s),u=r(a);a!==u&&(n.delete(a),n.add(u))}if(vt(n)){const a=+e[e.length-2],u=Ye(n,a);switch(+s==0?"key":"value"){case"key":{const c=r(u);n.set(c,n.get(u)),c!==u&&n.delete(u);break}case"value":{n.set(u,r(n.get(u)));break}}}return t};function lr(t,e,r=[]){if(!t)return;if(!be(t)){Ge(t,(a,u)=>lr(a,e,[...r,...Et(u)]));return}const[n,s]=t;s&&Ge(s,(a,u)=>{lr(a,e,[...r,...Et(u)])}),e(n,r)}function io(t,e,r){return lr(e,(n,s)=>{t=cr(t,s,a=>no(a,n,r))}),t}function oo(t,e){function r(n,s){const a=so(t,Et(s));n.map(Et).forEach(u=>{t=cr(t,u,()=>a)})}if(be(e)){const[n,s]=e;n.forEach(a=>{t=cr(t,Et(a),()=>t)}),s&&Ge(s,r)}else Ge(e,r);return t}const ao=(t,e)=>bt(t)||be(t)||vt(t)||wt(t)||wn(t,e);function uo(t,e,r){const n=r.get(t);n?n.push(e):r.set(t,[e])}function co(t,e){const r={};let n;return t.forEach(s=>{if(s.length<=1)return;e||(s=s.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...u]=s;a.length===0?n=u.map(ur):r[ur(a)]=u.map(ur)}),n?ar(r)?[n]:[n,r]:ar(r)?void 0:r}const Cn=(t,e,r,n,s=[],a=[],u=new Map)=>{const l=Yi(t);if(!l){uo(t,s,e);const g=u.get(t);if(g)return n?{transformedValue:null}:g}if(!ao(t,r)){const g=Pn(t,r),P=g?{transformedValue:g.value,annotations:[g.type]}:{transformedValue:t};return l||u.set(t,P),P}if(Mt(a,t))return{transformedValue:null};const c=Pn(t,r),d=(c==null?void 0:c.value)??t,h=be(d)?[]:{},f={};Ge(d,(g,P)=>{if(P==="__proto__"||P==="constructor"||P==="prototype")throw new Error(`Detected property ${P}. This is a prototype pollution risk, please remove it from your object.`);const v=Cn(g,e,r,n,[...s,P],[...a,t],u);h[P]=v.transformedValue,be(v.annotations)?f[P]=v.annotations:bt(v.annotations)&&Ge(v.annotations,(O,_)=>{f[mn(P)+"."+_]=O})});const p=ar(f)?{transformedValue:h,annotations:c?[c.type]:void 0}:{transformedValue:h,annotations:c?[c.type,f]:f};return l||u.set(t,p),p};function Tn(t){return Object.prototype.toString.call(t).slice(8,-1)}function xn(t){return Tn(t)==="Array"}function lo(t){if(Tn(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return!!e&&e.constructor===Object&&e===Object.prototype}function fo(t,e,r,n,s){const a={}.propertyIsEnumerable.call(n,e)?"enumerable":"nonenumerable";a==="enumerable"&&(t[e]=r),s&&a==="nonenumerable"&&Object.defineProperty(t,e,{value:r,enumerable:!1,writable:!0,configurable:!0})}function fr(t,e={}){if(xn(t))return t.map(s=>fr(s,e));if(!lo(t))return t;const r=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return[...r,...n].reduce((s,a)=>{if(xn(e.props)&&!e.props.includes(a))return s;const u=t[a],l=fr(u,e);return fo(s,a,l,t,e.nonenumerable),s},{})}class C{constructor({dedupe:e=!1}={}){this.classRegistry=new Ni,this.symbolRegistry=new fn(r=>r.description??""),this.customTransformerRegistry=new Qi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const r=new Map,n=Cn(e,r,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const a=co(r,this.dedupe);return a&&(s.meta={...s.meta,referentialEqualities:a}),s}deserialize(e){const{json:r,meta:n}=e;let s=fr(r);return n!=null&&n.values&&(s=io(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=oo(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,r){this.classRegistry.register(e,r)}registerSymbol(e,r){this.symbolRegistry.register(e,r)}registerCustom(e,r){this.customTransformerRegistry.register({name:r,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}}C.defaultInstance=new C,C.serialize=C.defaultInstance.serialize.bind(C.defaultInstance),C.deserialize=C.defaultInstance.deserialize.bind(C.defaultInstance),C.stringify=C.defaultInstance.stringify.bind(C.defaultInstance),C.parse=C.defaultInstance.parse.bind(C.defaultInstance),C.registerClass=C.defaultInstance.registerClass.bind(C.defaultInstance),C.registerSymbol=C.defaultInstance.registerSymbol.bind(C.defaultInstance),C.registerCustom=C.defaultInstance.registerCustom.bind(C.defaultInstance),C.allowErrorProps=C.defaultInstance.allowErrorProps.bind(C.defaultInstance),C.serialize,C.deserialize,C.stringify,C.parse,C.registerClass,C.registerCustom,C.registerSymbol,C.allowErrorProps;const Fn=k.createContext(null);function ho(t,e){const r=yi({links:[_i({enabled:s=>process.env.NODE_ENV==="development"&&typeof window<"u"||s.direction==="down"&&s.result instanceof Error}),Ti({url:`${t}/trpc`,headers:()=>({Authorization:`Bearer ${e}`}),transformer:C})]}),n=async(s,a)=>{const u=a.filter(h=>h.name.toLowerCase().endsWith(".pdf"));if(u.length===0)return{filesToCreate:[]};const l=await r.fileRouter.getFilesByProject.query({projectId:s}),c=u.filter(h=>!l.some(f=>f.path===h.blobUrl));return c.length===0?{filesToCreate:[]}:{filesToCreate:c.map(h=>({projectId:s,mimeType:zt.PDF,path:h.blobUrl,name:h.name,size:0,metadata:null,isArtifact:!1,summary:null,chunkingStatus:_r.NOT_CHUNKED}))}};return{getProjectsForUser:async()=>(await r.projectRouter.getAllProjects.query()).map(a=>({name:a.name,id:a.id})),addProjectForUser:async s=>{const a=await r.projectRouter.createProject.mutate({name:s});return{name:a.name,id:a.id}},addFilesToProject:async(s,a)=>{const{filesToCreate:u}=await n(s,a);return u.length===0?[]:(await r.fileRouter.createFiles.mutate({files:u})).map(c=>({blobUrl:c.path,name:c.name,id:c.id}))},getFilesForProject:async s=>(await r.fileRouter.getFilesByProject.query({projectId:s})).map(u=>({blobUrl:u.path,name:u.name,id:u.id}))}}function yo({children:t,host:e="http://localhost",port:r=5174,token:n}){const[s,a]=k.useState(null),u=k.useMemo(()=>new Is({defaultOptions:{queries:{staleTime:30*1e3,refetchOnWindowFocus:!1}}}),[]);return k.useEffect(()=>{const l=`${e}:${r}`,c=ho(l,n);a(c)},[e,r,n]),pt.jsx(Ns,{client:u,children:pt.jsx(Fn.Provider,{value:{host:e,port:r,client:s,token:n},children:t})})}function Ot(){const t=k.useContext(Fn);if(!t)throw new Error("useFolioContext must be used within a FolioProvider");return t}const{useEffect:po,useRef:mo,useState:go}=N;function bo({width:t="100%",height:e="100vh",allow:r="camera; microphone; clipboard-read; clipboard-write; fullscreen",style:n,className:s="",iframeProps:a={}}){const{host:u,port:l,token:c}=Ot(),d=mo(null),[h,f]=go();return po(()=>{(()=>{const P=`${`${u}:${l}`}?jwt=${encodeURIComponent(c)}`;f(P)})()},[u,l,c]),h?pt.jsx("div",{className:`folio-embed-container ${s}`,style:{width:t,height:e,overflow:"hidden",...n},children:pt.jsx("iframe",{ref:d,src:h,width:"100%",height:"100%",style:{border:"none",width:"100%",height:"100%",overflow:"auto"},allow:r,allowFullScreen:!0,...a})}):null}function vo(){const{client:t}=Ot(),e=Jr({queryKey:["folioProjects"],queryFn:async()=>{if(!t)throw new Error("Folio client not initialized");return t.getProjectsForUser()},enabled:!!t});return{projects:e.data||[],isLoading:e.isLoading,isError:e.isError,error:e.error,refetch:e.refetch}}function wo(t){const{client:e}=Ot(),r=Jr({queryKey:["folioFiles",t],queryFn:async()=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.getFilesForProject(t)},enabled:!!e&&!!t});return{files:r.data||[],isLoading:r.isLoading,isError:r.isError,error:r.error,refetch:r.refetch}}function Eo(){const{client:t}=Ot(),e=jt(),r=Zr({mutationFn:async n=>{if(!t)throw new Error("Folio client not initialized");return t.addProjectForUser(n)},onSuccess:()=>{e.invalidateQueries({queryKey:["folioProjects"]})}});return{addProject:r.mutate,addProjectAsync:r.mutateAsync,isAdding:r.isPending,isError:r.isError,error:r.error,newProject:r.data}}function Oo(t){const{client:e}=Ot(),r=jt(),n=Zr({mutationFn:async s=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.addFilesToProject(t,s)},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addFiles:n.mutate,addFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,newFiles:n.data}}A.FolioEmbed=bo,A.FolioProvider=yo,A.useAddFolioFiles=Oo,A.useAddFolioProject=Eo,A.useFolioFiles=wo,A.useFolioProjects=vo,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
34
|
+
`;l.push("%c",e==="up"?">>":"<<",r,`#${a}`,`%c${s}%c`,"%O"),c.push(f,`${f}; font-weight: bold;`,`${f}; font-weight: normal;`)}return e==="up"?c.push(n?{input:u,context:t.context}:{input:u}):c.push({input:u,result:t.result,elapsedMs:t.elapsedMs,...n&&{context:t.context}}),{parts:l,args:c}}const Ai=({c:t=console,colorMode:e="css",withContext:r})=>n=>{const s=n.input,a=xi(s)?Object.fromEntries(s):s,{parts:u,args:l}=Fi({...n,colorMode:e,input:a,withContext:r}),c=n.direction==="down"&&n.result&&(n.result instanceof Error||"error"in n.result.result&&n.result.result.error)?"error":"log";t[c].apply(null,[u.join(" ")].concat(l))};function _i(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),n=t.withContext??r==="css",{logger:s=Ai({c:t.console,colorMode:r,withContext:n})}=t;return()=>({op:a,next:u})=>We(l=>{e({...a,direction:"up"})&&s({...a,direction:"up"});const c=Date.now();function d(h){const f=Date.now()-c;e({...a,direction:"down",result:h})&&s({...a,direction:"down",elapsedMs:f,result:h})}return u(a).pipe(Zs({next(h){d(h)},error(h){d(h)}})).subscribe(l)})}const ki=(t,...e)=>typeof t=="function"?t(...e):t;function ji(){let t,e;return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}async function Ii(t){const e=await ki(t.url);if(!t.connectionParams)return e;const n=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+n}function Ie(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Di(t){const{promise:e,resolve:r,reject:n}=ji();return t.addEventListener("open",()=>{t.removeEventListener("error",n),r()}),t.addEventListener("error",n),e}function qi(t,{intervalMs:e,pongTimeoutMs:r}){let n,s;function a(){n=setTimeout(()=>{t.send("PING"),s=setTimeout(()=>{t.close()},r)},e)}function u(){clearTimeout(n),a()}function l(){clearTimeout(s),u()}t.addEventListener("open",a),t.addEventListener("message",({data:c})=>{clearTimeout(n),a(),c==="PONG"&&l()}),t.addEventListener("close",()=>{clearTimeout(n),clearTimeout(s)})}class qt{get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){if(this.openPromise)return this.openPromise;this.id=++qt.connectCount;const e=Ii(this.urlOptions).then(r=>new this.WebSocketPonyfill(r));this.openPromise=e.then(Di),this.ws=await e,this.ws.addEventListener("message",function({data:r}){r==="PING"&&this.send("PONG")}),this.keepAliveOpts.enabled&&qi(this.ws,this.keepAliveOpts),this.ws.addEventListener("close",()=>{this.ws=null});try{await this.openPromise}finally{this.openPromise=null}}async close(){var e;try{await this.openPromise}finally{(e=this.ws)==null||e.close()}}constructor(e){if(Ie(this,"id",++qt.connectCount),Ie(this,"WebSocketPonyfill",void 0),Ie(this,"urlOptions",void 0),Ie(this,"keepAliveOpts",void 0),Ie(this,"wsObservable",ei(null)),Ie(this,"openPromise",null),this.WebSocketPonyfill=e.WebSocketPonyfill??WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=e.urlOptions,this.keepAliveOpts=e.keepAlive}}Ie(qt,"connectCount",0);class Mi{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,r){this.keyToValue.set(e,r),this.valueToKey.set(r,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}}class fn{constructor(e){this.generateIdentifier=e,this.kv=new Mi}register(e,r){this.kv.getByValue(e)||(r||(r=this.generateIdentifier(e)),this.kv.set(r,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}}class Ni extends fn{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,r){typeof r=="object"?(r.allowProps&&this.classToAllowedProps.set(e,r.allowProps),super.register(e,r.identifier)):super.register(e,r)}getAllowedProps(e){return this.classToAllowedProps.get(e)}}function Ui(t){if("values"in Object)return Object.values(t);const e=[];for(const r in t)t.hasOwnProperty(r)&&e.push(t[r]);return e}function Li(t,e){const r=Ui(t);if("find"in r)return r.find(e);const n=r;for(let s=0;s<n.length;s++){const a=n[s];if(e(a))return a}}function Ge(t,e){Object.entries(t).forEach(([r,n])=>e(n,r))}function Mt(t,e){return t.indexOf(e)!==-1}function hn(t,e){for(let r=0;r<t.length;r++){const n=t[r];if(e(n))return n}}class Qi{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Li(this.transfomers,r=>r.isApplicable(e))}findByName(e){return this.transfomers[e]}}const $i=t=>Object.prototype.toString.call(t).slice(8,-1),dn=t=>typeof t>"u",Ki=t=>t===null,bt=t=>typeof t!="object"||t===null||t===Object.prototype?!1:Object.getPrototypeOf(t)===null?!0:Object.getPrototypeOf(t)===Object.prototype,ar=t=>bt(t)&&Object.keys(t).length===0,be=t=>Array.isArray(t),Vi=t=>typeof t=="string",zi=t=>typeof t=="number"&&!isNaN(t),Hi=t=>typeof t=="boolean",Bi=t=>t instanceof RegExp,vt=t=>t instanceof Map,wt=t=>t instanceof Set,yn=t=>$i(t)==="Symbol",Wi=t=>t instanceof Date&&!isNaN(t.valueOf()),Gi=t=>t instanceof Error,pn=t=>typeof t=="number"&&isNaN(t),Yi=t=>Hi(t)||Ki(t)||dn(t)||zi(t)||Vi(t)||yn(t),Xi=t=>typeof t=="bigint",Ji=t=>t===1/0||t===-1/0,Zi=t=>ArrayBuffer.isView(t)&&!(t instanceof DataView),eo=t=>t instanceof URL,mn=t=>t.replace(/\./g,"\\."),ur=t=>t.map(String).map(mn).join("."),Et=t=>{const e=[];let r="";for(let s=0;s<t.length;s++){let a=t.charAt(s);if(a==="\\"&&t.charAt(s+1)==="."){r+=".",s++;continue}if(a==="."){e.push(r),r="";continue}r+=a}const n=r;return e.push(n),e};function ue(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const gn=[ue(dn,"undefined",()=>null,()=>{}),ue(Xi,"bigint",t=>t.toString(),t=>typeof BigInt<"u"?BigInt(t):(console.error("Please add a BigInt polyfill."),t)),ue(Wi,"Date",t=>t.toISOString(),t=>new Date(t)),ue(Gi,"Error",(t,e)=>{const r={name:t.name,message:t.message};return e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r},(t,e)=>{const r=new Error(t.message);return r.name=t.name,r.stack=t.stack,e.allowedErrorProps.forEach(n=>{r[n]=t[n]}),r}),ue(Bi,"regexp",t=>""+t,t=>{const e=t.slice(1,t.lastIndexOf("/")),r=t.slice(t.lastIndexOf("/")+1);return new RegExp(e,r)}),ue(wt,"set",t=>[...t.values()],t=>new Set(t)),ue(vt,"map",t=>[...t.entries()],t=>new Map(t)),ue(t=>pn(t)||Ji(t),"number",t=>pn(t)?"NaN":t>0?"Infinity":"-Infinity",Number),ue(t=>t===0&&1/t===-1/0,"number",()=>"-0",Number),ue(eo,"URL",t=>t.toString(),t=>new URL(t))];function Nt(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const bn=Nt((t,e)=>yn(t)?!!e.symbolRegistry.getIdentifier(t):!1,(t,e)=>["symbol",e.symbolRegistry.getIdentifier(t)],t=>t.description,(t,e,r)=>{const n=r.symbolRegistry.getValue(e[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),to=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((t,e)=>(t[e.name]=e,t),{}),vn=Nt(Zi,t=>["typed-array",t.constructor.name],t=>[...t],(t,e)=>{const r=to[e[1]];if(!r)throw new Error("Trying to deserialize unknown typed array");return new r(t)});function wn(t,e){return t!=null&&t.constructor?!!e.classRegistry.getIdentifier(t.constructor):!1}const En=Nt(wn,(t,e)=>["class",e.classRegistry.getIdentifier(t.constructor)],(t,e)=>{const r=e.classRegistry.getAllowedProps(t.constructor);if(!r)return{...t};const n={};return r.forEach(s=>{n[s]=t[s]}),n},(t,e,r)=>{const n=r.classRegistry.getValue(e[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${e[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),t)}),On=Nt((t,e)=>!!e.customTransformerRegistry.findApplicable(t),(t,e)=>["custom",e.customTransformerRegistry.findApplicable(t).name],(t,e)=>e.customTransformerRegistry.findApplicable(t).serialize(t),(t,e,r)=>{const n=r.customTransformerRegistry.findByName(e[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(t)}),ro=[En,bn,On,vn],Pn=(t,e)=>{const r=hn(ro,s=>s.isApplicable(t,e));if(r)return{value:r.transform(t,e),type:r.annotation(t,e)};const n=hn(gn,s=>s.isApplicable(t,e));if(n)return{value:n.transform(t,e),type:n.annotation}},Rn={};gn.forEach(t=>{Rn[t.annotation]=t});const no=(t,e,r)=>{if(be(e))switch(e[0]){case"symbol":return bn.untransform(t,e,r);case"class":return En.untransform(t,e,r);case"custom":return On.untransform(t,e,r);case"typed-array":return vn.untransform(t,e,r);default:throw new Error("Unknown transformation: "+e)}else{const n=Rn[e];if(!n)throw new Error("Unknown transformation: "+e);return n.untransform(t,r)}},Ye=(t,e)=>{if(e>t.size)throw new Error("index out of bounds");const r=t.keys();for(;e>0;)r.next(),e--;return r.next().value};function Sn(t){if(Mt(t,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Mt(t,"prototype"))throw new Error("prototype is not allowed as a property");if(Mt(t,"constructor"))throw new Error("constructor is not allowed as a property")}const so=(t,e)=>{Sn(e);for(let r=0;r<e.length;r++){const n=e[r];if(wt(t))t=Ye(t,+n);else if(vt(t)){const s=+n,a=+e[++r]==0?"key":"value",u=Ye(t,s);switch(a){case"key":t=u;break;case"value":t=t.get(u);break}}else t=t[n]}return t},cr=(t,e,r)=>{if(Sn(e),e.length===0)return r(t);let n=t;for(let a=0;a<e.length-1;a++){const u=e[a];if(be(n)){const l=+u;n=n[l]}else if(bt(n))n=n[u];else if(wt(n)){const l=+u;n=Ye(n,l)}else if(vt(n)){if(a===e.length-2)break;const c=+u,d=+e[++a]==0?"key":"value",h=Ye(n,c);switch(d){case"key":n=h;break;case"value":n=n.get(h);break}}}const s=e[e.length-1];if(be(n)?n[+s]=r(n[+s]):bt(n)&&(n[s]=r(n[s])),wt(n)){const a=Ye(n,+s),u=r(a);a!==u&&(n.delete(a),n.add(u))}if(vt(n)){const a=+e[e.length-2],u=Ye(n,a);switch(+s==0?"key":"value"){case"key":{const c=r(u);n.set(c,n.get(u)),c!==u&&n.delete(u);break}case"value":{n.set(u,r(n.get(u)));break}}}return t};function lr(t,e,r=[]){if(!t)return;if(!be(t)){Ge(t,(a,u)=>lr(a,e,[...r,...Et(u)]));return}const[n,s]=t;s&&Ge(s,(a,u)=>{lr(a,e,[...r,...Et(u)])}),e(n,r)}function io(t,e,r){return lr(e,(n,s)=>{t=cr(t,s,a=>no(a,n,r))}),t}function oo(t,e){function r(n,s){const a=so(t,Et(s));n.map(Et).forEach(u=>{t=cr(t,u,()=>a)})}if(be(e)){const[n,s]=e;n.forEach(a=>{t=cr(t,Et(a),()=>t)}),s&&Ge(s,r)}else Ge(e,r);return t}const ao=(t,e)=>bt(t)||be(t)||vt(t)||wt(t)||wn(t,e);function uo(t,e,r){const n=r.get(t);n?n.push(e):r.set(t,[e])}function co(t,e){const r={};let n;return t.forEach(s=>{if(s.length<=1)return;e||(s=s.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...u]=s;a.length===0?n=u.map(ur):r[ur(a)]=u.map(ur)}),n?ar(r)?[n]:[n,r]:ar(r)?void 0:r}const Cn=(t,e,r,n,s=[],a=[],u=new Map)=>{const l=Yi(t);if(!l){uo(t,s,e);const g=u.get(t);if(g)return n?{transformedValue:null}:g}if(!ao(t,r)){const g=Pn(t,r),P=g?{transformedValue:g.value,annotations:[g.type]}:{transformedValue:t};return l||u.set(t,P),P}if(Mt(a,t))return{transformedValue:null};const c=Pn(t,r),d=(c==null?void 0:c.value)??t,h=be(d)?[]:{},f={};Ge(d,(g,P)=>{if(P==="__proto__"||P==="constructor"||P==="prototype")throw new Error(`Detected property ${P}. This is a prototype pollution risk, please remove it from your object.`);const v=Cn(g,e,r,n,[...s,P],[...a,t],u);h[P]=v.transformedValue,be(v.annotations)?f[P]=v.annotations:bt(v.annotations)&&Ge(v.annotations,(O,_)=>{f[mn(P)+"."+_]=O})});const p=ar(f)?{transformedValue:h,annotations:c?[c.type]:void 0}:{transformedValue:h,annotations:c?[c.type,f]:f};return l||u.set(t,p),p};function Tn(t){return Object.prototype.toString.call(t).slice(8,-1)}function xn(t){return Tn(t)==="Array"}function lo(t){if(Tn(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return!!e&&e.constructor===Object&&e===Object.prototype}function fo(t,e,r,n,s){const a={}.propertyIsEnumerable.call(n,e)?"enumerable":"nonenumerable";a==="enumerable"&&(t[e]=r),s&&a==="nonenumerable"&&Object.defineProperty(t,e,{value:r,enumerable:!1,writable:!0,configurable:!0})}function fr(t,e={}){if(xn(t))return t.map(s=>fr(s,e));if(!lo(t))return t;const r=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return[...r,...n].reduce((s,a)=>{if(xn(e.props)&&!e.props.includes(a))return s;const u=t[a],l=fr(u,e);return fo(s,a,l,t,e.nonenumerable),s},{})}class C{constructor({dedupe:e=!1}={}){this.classRegistry=new Ni,this.symbolRegistry=new fn(r=>r.description??""),this.customTransformerRegistry=new Qi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const r=new Map,n=Cn(e,r,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const a=co(r,this.dedupe);return a&&(s.meta={...s.meta,referentialEqualities:a}),s}deserialize(e){const{json:r,meta:n}=e;let s=fr(r);return n!=null&&n.values&&(s=io(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=oo(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,r){this.classRegistry.register(e,r)}registerSymbol(e,r){this.symbolRegistry.register(e,r)}registerCustom(e,r){this.customTransformerRegistry.register({name:r,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}}C.defaultInstance=new C,C.serialize=C.defaultInstance.serialize.bind(C.defaultInstance),C.deserialize=C.defaultInstance.deserialize.bind(C.defaultInstance),C.stringify=C.defaultInstance.stringify.bind(C.defaultInstance),C.parse=C.defaultInstance.parse.bind(C.defaultInstance),C.registerClass=C.defaultInstance.registerClass.bind(C.defaultInstance),C.registerSymbol=C.defaultInstance.registerSymbol.bind(C.defaultInstance),C.registerCustom=C.defaultInstance.registerCustom.bind(C.defaultInstance),C.allowErrorProps=C.defaultInstance.allowErrorProps.bind(C.defaultInstance),C.serialize,C.deserialize,C.stringify,C.parse,C.registerClass,C.registerCustom,C.registerSymbol,C.allowErrorProps;const Fn=k.createContext(null);function ho(t,e){const r=yi({links:[_i({enabled:s=>process.env.NODE_ENV==="development"&&typeof window<"u"||s.direction==="down"&&s.result instanceof Error}),Ti({url:`${t}/trpc`,headers:()=>({Authorization:`Bearer ${e}`}),transformer:C})]}),n=async(s,a)=>{const u=a.filter(h=>h.name.toLowerCase().endsWith(".pdf"));if(u.length===0)return{filesToCreate:[]};const l=await r.fileRouter.getFilesByProject.query({projectId:s}),c=u.filter(h=>!l.some(f=>f.path===h.blobUrl));return c.length===0?{filesToCreate:[]}:{filesToCreate:c.map(h=>({projectId:s,mimeType:zt.PDF,path:h.blobUrl,name:h.name,size:0,metadata:null,isArtifact:!1,summary:null,chunkingStatus:_r.NOT_CHUNKED}))}};return{getProjectsForUser:async()=>{const s=await r.projectRouter.getAllProjects.query();if(s.length===0){const a=await r.projectRouter.createProject.mutate({name:"Default Project"});return[{name:a.name,id:a.id}]}return s.map(a=>({name:a.name,id:a.id}))},addProjectForUser:async s=>{const a=await r.projectRouter.createProject.mutate({name:s});return{name:a.name,id:a.id}},addFilesToProject:async(s,a)=>{const{filesToCreate:u}=await n(s,a);return u.length===0?[]:(await r.fileRouter.createFiles.mutate({files:u})).map(c=>({blobUrl:c.path,name:c.name,id:c.id}))},getFilesForProject:async s=>(await r.fileRouter.getFilesByProject.query({projectId:s})).map(u=>({blobUrl:u.path,name:u.name,id:u.id}))}}function yo({children:t,host:e="http://localhost",port:r=5174,token:n}){const[s,a]=k.useState(null),u=k.useMemo(()=>new js({defaultOptions:{queries:{staleTime:30*1e3,refetchOnWindowFocus:!1}}}),[]);return k.useEffect(()=>{const l=`${e}:${r}`,c=ho(l,n);a(c)},[e,r,n]),pt.jsx(Ns,{client:u,children:pt.jsx(Fn.Provider,{value:{host:e,port:r,client:s,token:n},children:t})})}function Ot(){const t=k.useContext(Fn);if(!t)throw new Error("useFolioContext must be used within a FolioProvider");return t}const{useEffect:po,useRef:mo,useState:go}=N;function bo({width:t="100%",height:e="100vh",allow:r="camera; microphone; clipboard-read; clipboard-write; fullscreen",style:n,className:s="",iframeProps:a={}}){const{host:u,port:l,token:c}=Ot(),d=mo(null),[h,f]=go();return po(()=>{(()=>{const P=`${`${u}:${l}`}?jwt=${encodeURIComponent(c)}`;f(P)})()},[u,l,c]),h?pt.jsx("div",{className:`folio-embed-container ${s}`,style:{width:t,height:e,overflow:"hidden",...n},children:pt.jsx("iframe",{ref:d,src:h,width:"100%",height:"100%",style:{border:"none",width:"100%",height:"100%",overflow:"auto"},allow:r,allowFullScreen:!0,...a})}):null}function vo(){const{client:t}=Ot(),e=Jr({queryKey:["folioProjects"],queryFn:async()=>{if(!t)throw new Error("Folio client not initialized");return t.getProjectsForUser()},enabled:!!t});return{projects:e.data||[],isLoading:e.isLoading,isError:e.isError,error:e.error,refetch:e.refetch}}function wo(t){const{client:e}=Ot(),r=Jr({queryKey:["folioFiles",t],queryFn:async()=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.getFilesForProject(t)},enabled:!!e&&!!t});return{files:r.data||[],isLoading:r.isLoading,isError:r.isError,error:r.error,refetch:r.refetch}}function Eo(){const{client:t}=Ot(),e=It(),r=Zr({mutationFn:async n=>{if(!t)throw new Error("Folio client not initialized");return t.addProjectForUser(n)},onSuccess:()=>{e.invalidateQueries({queryKey:["folioProjects"]})}});return{addProject:r.mutate,addProjectAsync:r.mutateAsync,isAdding:r.isPending,isError:r.isError,error:r.error,newProject:r.data}}function Oo(t){const{client:e}=Ot(),r=It(),n=Zr({mutationFn:async s=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.addFilesToProject(t,s)},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addFiles:n.mutate,addFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,newFiles:n.data}}A.FolioEmbed=bo,A.FolioProvider=yo,A.useAddFolioFiles=Oo,A.useAddFolioProject=Eo,A.useFolioFiles=wo,A.useFolioProjects=vo,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|