@shiftengineering/folio 0.1.3 → 0.1.4
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.
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ This package exports three main features:
|
|
|
26
26
|
- `useFolioFiles` - Get files for a project
|
|
27
27
|
- `useAddFolioProject` - Create new projects
|
|
28
28
|
- `useAddFolioFiles` - Add files to a project
|
|
29
|
-
- `useAddFolioDirectoryWithFiles` - Add
|
|
29
|
+
- `useAddFolioDirectoryWithFiles` - Add directories with files to a project
|
|
30
30
|
|
|
31
31
|
### Basic Setup
|
|
32
32
|
|
|
@@ -80,6 +80,7 @@ import {
|
|
|
80
80
|
useAddFolioProject,
|
|
81
81
|
useAddFolioFiles,
|
|
82
82
|
useAddFolioDirectoryWithFiles,
|
|
83
|
+
type DirectoryEntry,
|
|
83
84
|
} from "@shiftengineering/folio";
|
|
84
85
|
import { useState } from "react";
|
|
85
86
|
|
|
@@ -103,7 +104,7 @@ function FolioProjectManager() {
|
|
|
103
104
|
const { addFiles, isAdding: isAddingFiles } =
|
|
104
105
|
useAddFolioFiles(selectedProjectId);
|
|
105
106
|
|
|
106
|
-
// Add
|
|
107
|
+
// Add directories with files to a project
|
|
107
108
|
const { addDirectoryWithFiles, isAdding: isAddingDirectory } =
|
|
108
109
|
useAddFolioDirectoryWithFiles(selectedProjectId);
|
|
109
110
|
|
|
@@ -115,15 +116,52 @@ function FolioProjectManager() {
|
|
|
115
116
|
addFiles([{ blobUrl: "/path/to/file.pdf", name: "My Document.pdf" }]);
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
const
|
|
119
|
-
|
|
119
|
+
const handleAddSingleDirectory = () => {
|
|
120
|
+
// Create a metadata map
|
|
121
|
+
const metadata = new Map<string, string>();
|
|
122
|
+
metadata.set("category", "reports");
|
|
123
|
+
metadata.set("owner", "John Doe");
|
|
124
|
+
|
|
125
|
+
const directoryEntry: DirectoryEntry = {
|
|
120
126
|
directoryName: "My Documents",
|
|
121
|
-
directoryMetadata:
|
|
127
|
+
directoryMetadata: metadata,
|
|
122
128
|
files: [
|
|
123
129
|
{ blobUrl: "/path/to/file1.pdf", name: "Document 1.pdf" },
|
|
124
130
|
{ blobUrl: "/path/to/file2.pdf", name: "Document 2.pdf" },
|
|
125
131
|
],
|
|
126
|
-
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
addDirectoryWithFiles(directoryEntry);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const handleAddMultipleDirectories = () => {
|
|
138
|
+
// Create metadata maps for each directory
|
|
139
|
+
const metadata1 = new Map<string, string>();
|
|
140
|
+
metadata1.set("category", "reports");
|
|
141
|
+
|
|
142
|
+
const metadata2 = new Map<string, string>();
|
|
143
|
+
metadata2.set("category", "contracts");
|
|
144
|
+
|
|
145
|
+
const directories: DirectoryEntry[] = [
|
|
146
|
+
{
|
|
147
|
+
directoryName: "Reports",
|
|
148
|
+
directoryMetadata: metadata1,
|
|
149
|
+
files: [
|
|
150
|
+
{ blobUrl: "/path/to/report1.pdf", name: "Report 1.pdf" },
|
|
151
|
+
{ blobUrl: "/path/to/report2.pdf", name: "Report 2.pdf" },
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
directoryName: "Contracts",
|
|
156
|
+
directoryMetadata: metadata2,
|
|
157
|
+
files: [
|
|
158
|
+
{ blobUrl: "/path/to/contract1.pdf", name: "Contract 1.pdf" },
|
|
159
|
+
{ blobUrl: "/path/to/contract2.pdf", name: "Contract 2.pdf" },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
addDirectoryWithFiles(directories);
|
|
127
165
|
};
|
|
128
166
|
|
|
129
167
|
if (isProjectsLoading) return <div>Loading projects...</div>;
|
|
@@ -156,9 +194,12 @@ function FolioProjectManager() {
|
|
|
156
194
|
<button onClick={handleAddFile} disabled={isAddingFiles}>
|
|
157
195
|
{isAddingFiles ? "Adding..." : "Add File"}
|
|
158
196
|
</button>
|
|
159
|
-
<button onClick={
|
|
197
|
+
<button onClick={handleAddSingleDirectory} disabled={isAddingDirectory}>
|
|
160
198
|
{isAddingDirectory ? "Adding..." : "Add Directory with Files"}
|
|
161
199
|
</button>
|
|
200
|
+
<button onClick={handleAddMultipleDirectories} disabled={isAddingDirectory}>
|
|
201
|
+
{isAddingDirectory ? "Adding..." : "Add Multiple Directories"}
|
|
202
|
+
</button>
|
|
162
203
|
|
|
163
204
|
{isFilesLoading ? (
|
|
164
205
|
<div>Loading files...</div>
|
|
@@ -255,27 +296,28 @@ Hook for adding files to a project. Files are always created at the root level (
|
|
|
255
296
|
|
|
256
297
|
#### `useAddFolioDirectoryWithFiles(projectId?: number)`
|
|
257
298
|
|
|
258
|
-
Hook for adding
|
|
299
|
+
Hook for adding one or more directories with files to a project. Directory names must be unique at the root level (duplicates will be silently skipped with a console warning).
|
|
259
300
|
|
|
260
|
-
| Return Property | Type
|
|
261
|
-
| ---------------------------- |
|
|
262
|
-
| `addDirectoryWithFiles` | `(params:
|
|
263
|
-
| `addDirectoryWithFilesAsync` | `(params:
|
|
264
|
-
| `isAdding` | `boolean`
|
|
265
|
-
| `isError` | `boolean`
|
|
266
|
-
| `error` | `Error \| null`
|
|
267
|
-
| `result` | `{ directory: FolioFile \| null; files: FolioFile[] } \| undefined`
|
|
301
|
+
| Return Property | Type | Description |
|
|
302
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
303
|
+
| `addDirectoryWithFiles` | `(params: DirectoryEntry \| DirectoryEntry[]) => void` | Function to add one or more directories with files |
|
|
304
|
+
| `addDirectoryWithFilesAsync` | `(params: DirectoryEntry \| DirectoryEntry[]) => Promise<{ directory: FolioFile \| null; files: FolioFile[] } \| Array<{ directory: FolioFile \| null; files: FolioFile[] }>>` | Async version returning a promise. Returns a single result when given a single directory, or an array of results when given multiple directories |
|
|
305
|
+
| `isAdding` | `boolean` | Whether the directories and files are being added |
|
|
306
|
+
| `isError` | `boolean` | Whether an error occurred |
|
|
307
|
+
| `error` | `Error \| null` | Error object if an error occurred |
|
|
308
|
+
| `result` | `{ directory: FolioFile \| null; files: FolioFile[] } \| Array<{ directory: FolioFile \| null; files: FolioFile[] }> \| undefined` | The newly added directories and files. If a directory is null in a result, it means a directory with that name already existed |
|
|
268
309
|
|
|
269
310
|
## Types
|
|
270
311
|
|
|
271
312
|
The library exports these TypeScript types:
|
|
272
313
|
|
|
273
|
-
| Type | Description
|
|
274
|
-
| -------------------- |
|
|
275
|
-
| `FolioFile` | Represents a file in Folio. Contains properties: `id`, `name`, `blobUrl`, `parentId` (null for root items), and `isDirectory` (boolean)
|
|
276
|
-
| `FolioProject` | Represents a project in Folio
|
|
277
|
-
| `
|
|
278
|
-
| `
|
|
314
|
+
| Type | Description |
|
|
315
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
316
|
+
| `FolioFile` | Represents a file in Folio. Contains properties: `id`, `name`, `blobUrl`, `parentId` (null for root items), and `isDirectory` (boolean) |
|
|
317
|
+
| `FolioProject` | Represents a project in Folio |
|
|
318
|
+
| `DirectoryEntry` | Represents a directory with metadata and files to be added to Folio. Contains properties: `directoryName`, `directoryMetadata` (Map<string, string>), and `files` |
|
|
319
|
+
| `FolioEmbedProps` | Props for the FolioEmbed component |
|
|
320
|
+
| `FolioProviderProps` | Props for the FolioProvider component |
|
|
279
321
|
|
|
280
322
|
## License
|
|
281
323
|
|
|
@@ -4253,19 +4253,22 @@ function ra(t) {
|
|
|
4253
4253
|
}
|
|
4254
4254
|
function na(t) {
|
|
4255
4255
|
const { client: e } = ct(), r = Ct(), n = Tr({
|
|
4256
|
-
mutationFn: async ({
|
|
4257
|
-
directoryName: s,
|
|
4258
|
-
directoryMetadata: a,
|
|
4259
|
-
files: u
|
|
4260
|
-
}) => {
|
|
4256
|
+
mutationFn: async (s) => {
|
|
4261
4257
|
if (!e) throw new Error("Folio client not initialized");
|
|
4262
4258
|
if (!t) throw new Error("Project ID is required");
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4259
|
+
const a = Array.isArray(s) ? s : [s], u = [];
|
|
4260
|
+
for (const l of a) {
|
|
4261
|
+
const c = JSON.stringify(
|
|
4262
|
+
Object.fromEntries(l.directoryMetadata)
|
|
4263
|
+
), d = await e.addDirectoryWithFilesToProject(
|
|
4264
|
+
t,
|
|
4265
|
+
l.directoryName,
|
|
4266
|
+
c,
|
|
4267
|
+
l.files
|
|
4268
|
+
);
|
|
4269
|
+
u.push(d);
|
|
4270
|
+
}
|
|
4271
|
+
return Array.isArray(s) ? u : u[0];
|
|
4269
4272
|
},
|
|
4270
4273
|
onSuccess: () => {
|
|
4271
4274
|
r.invalidateQueries({ queryKey: ["folioFiles", t] });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(x,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(x=typeof globalThis<"u"?globalThis:x||self,_(x.FolioEmbedComponent={},x.React))})(this,function(x,_){"use strict";var ps=x=>{throw TypeError(x)};var Or=(x,_,H)=>_.has(x)||ps("Cannot "+H);var o=(x,_,H)=>(Or(x,_,"read from private field"),H?H.call(x):_.get(x)),w=(x,_,H)=>_.has(x)?ps("Cannot add the same private member more than once"):_ instanceof WeakSet?_.add(x):_.set(x,H),g=(x,_,H,M)=>(Or(x,_,"write to private field"),M?M.call(x,H):_.set(x,H),H),R=(x,_,H)=>(Or(x,_,"access private method"),H);var zt=(x,_,H,M)=>({set _(dt){g(x,_,dt,H)},get _(){return o(x,_,M)}});var je,ve,
|
|
1
|
+
(function(x,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(x=typeof globalThis<"u"?globalThis:x||self,_(x.FolioEmbedComponent={},x.React))})(this,function(x,_){"use strict";var ps=x=>{throw TypeError(x)};var Or=(x,_,H)=>_.has(x)||ps("Cannot "+H);var o=(x,_,H)=>(Or(x,_,"read from private field"),H?H.call(x):_.get(x)),w=(x,_,H)=>_.has(x)?ps("Cannot add the same private member more than once"):_ instanceof WeakSet?_.add(x):_.set(x,H),g=(x,_,H,M)=>(Or(x,_,"write to private field"),M?M.call(x,H):_.set(x,H),H),R=(x,_,H)=>(Or(x,_,"access private method"),H);var zt=(x,_,H,M)=>({set _(dt){g(x,_,dt,H)},get _(){return o(x,_,M)}});var je,ve,Xe,An,Ze,we,et,Dn,qe,_n,tt,rt,ne,Ue,W,Rt,Me,oe,me,In,ce,kn,le,B,Ne,fe,De,jn,de,ae,St,qn,L,Ee,Oe,nt,st,Pe,it,ot,Un,X,T,Ct,G,Le,at,Re,he,Tt,ut,ct,Qe,$e,Se,lt,I,At,Pr,Rr,Sr,Cr,Tr,Fr,xr,ms,Mn,Ce,Te,Z,ye,pe,Ht,Ar,Nn,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 M=H(_);var dt={exports:{}},yt={};/**
|
|
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 _r;function bs(){return _r||(_r=1,process.env.NODE_ENV!=="production"&&function(){var t=_,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"),m=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 D=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function F(i){{for(var y=arguments.length,b=new Array(y>1?y-1:0),E=1;E<y;E++)b[E-1]=arguments[E];U("error",i,b)}}function U(i,y,b){{var E=D.ReactDebugCurrentFrame,k=E.getStackAddendum();k!==""&&(y+="%s",b=b.concat([k]));var j=b.map(function(A){return String(A)});j.unshift("Warning: "+y),Function.prototype.apply.call(console[i],console,j)}}var V=!1,Y=!1,te=!1,z=!1,N=!1,q;q=Symbol.for("react.module.reference");function Fe(i){return!!(typeof i=="string"||typeof i=="function"||i===n||i===a||N||i===s||i===d||i===h||z||i===m||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 xe(i,y,b){var E=i.displayName;if(E)return E;var k=y.displayName||y.name||"";return k!==""?b+"("+k+")":b}function Ke(i){return i.displayName||"Context"}function Ae(i){if(i==null)return null;if(typeof i.tag=="number"&&F("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 xe(i,i.render,"ForwardRef");case f:var E=i.displayName||null;return E!==null?E:Ae(i.type)||"Memo";case p:{var k=i,j=k._payload,A=k._init;try{return Ae(A(j))}catch{return null}}}return null}var Ve=Object.assign,Ft=0,Hn,Wn,Bn,Gn,Yn,Xn
|
|
17
|
+
*/var _r;function bs(){return _r||(_r=1,process.env.NODE_ENV!=="production"&&function(){var t=_,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"),m=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 D=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function F(i){{for(var y=arguments.length,b=new Array(y>1?y-1:0),E=1;E<y;E++)b[E-1]=arguments[E];U("error",i,b)}}function U(i,y,b){{var E=D.ReactDebugCurrentFrame,k=E.getStackAddendum();k!==""&&(y+="%s",b=b.concat([k]));var j=b.map(function(A){return String(A)});j.unshift("Warning: "+y),Function.prototype.apply.call(console[i],console,j)}}var V=!1,Y=!1,te=!1,z=!1,N=!1,q;q=Symbol.for("react.module.reference");function Fe(i){return!!(typeof i=="string"||typeof i=="function"||i===n||i===a||N||i===s||i===d||i===h||z||i===m||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 xe(i,y,b){var E=i.displayName;if(E)return E;var k=y.displayName||y.name||"";return k!==""?b+"("+k+")":b}function Ke(i){return i.displayName||"Context"}function Ae(i){if(i==null)return null;if(typeof i.tag=="number"&&F("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 xe(i,i.render,"ForwardRef");case f:var E=i.displayName||null;return E!==null?E:Ae(i.type)||"Memo";case p:{var k=i,j=k._payload,A=k._init;try{return Ae(A(j))}catch{return null}}}return null}var Ve=Object.assign,Ft=0,Hn,Wn,Bn,Gn,Yn,Jn,Xn;function Zn(){}Zn.__reactDisabledLog=!0;function Ro(){{if(Ft===0){Hn=console.log,Wn=console.info,Bn=console.warn,Gn=console.error,Yn=console.group,Jn=console.groupCollapsed,Xn=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})}Ft++}}function So(){{if(Ft--,Ft===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ve({},i,{value:Hn}),info:Ve({},i,{value:Wn}),warn:Ve({},i,{value:Bn}),error:Ve({},i,{value:Gn}),group:Ve({},i,{value:Yn}),groupCollapsed:Ve({},i,{value:Jn}),groupEnd:Ve({},i,{value:Xn})})}Ft<0&&F("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var yr=D.ReactCurrentDispatcher,pr;function Qt(i,y,b){{if(pr===void 0)try{throw Error()}catch(k){var E=k.stack.trim().match(/\n( *(at )?)/);pr=E&&E[1]||""}return`
|
|
18
18
|
`+pr+i}}var mr=!1,$t;{var Co=typeof WeakMap=="function"?WeakMap:Map;$t=new Co}function es(i,y){if(!i||mr)return"";{var b=$t.get(i);if(b!==void 0)return b}var E;mr=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var j;j=yr.current,yr.current=null,Ro();try{if(y){var A=function(){throw Error()};if(Object.defineProperty(A.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(A,[])}catch(ee){E=ee}Reflect.construct(i,[],A)}else{try{A.call()}catch(ee){E=ee}i.call(A.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
|
-
`),
|
|
20
|
-
`),Q=S.length-1,$=
|
|
21
|
-
`+S[Q].replace(" at new "," at ");return i.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",i.displayName)),typeof i=="function"&&$t.set(i,se),se}while(Q>=1&&$>=0);break}}}finally{mr=!1,yr.current=j,So(),Error.prepareStackTrace=k}var ht=i?i.displayName||i.name:"",ze=ht?Qt(ht):"";return typeof i=="function"&&$t.set(i,ze),ze}function To(i,y,b){return es(i,!1)}function Fo(i){var y=i.prototype;return!!(y&&y.isReactComponent)}function Kt(i,y,b){if(i==null)return"";if(typeof i=="function")return es(i,Fo(i));if(typeof i=="string")return Qt(i);switch(i){case d:return Qt("Suspense");case h:return Qt("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case c:return To(i.render);case f:return Kt(i.type,y,b);case p:{var E=i,k=E._payload,j=E._init;try{return Kt(j(k),y,b)}catch{}}}return""}var xt=Object.prototype.hasOwnProperty,ts={},rs=D.ReactDebugCurrentFrame;function Vt(i){if(i){var y=i._owner,b=Kt(i.type,i._source,y?y.type:null);rs.setExtraStackFrame(b)}else rs.setExtraStackFrame(null)}function xo(i,y,b,E,k){{var j=Function.call.bind(xt);for(var A in i)if(j(i,A)){var S=void 0;try{if(typeof i[A]!="function"){var
|
|
19
|
+
`),J=E.stack.split(`
|
|
20
|
+
`),Q=S.length-1,$=J.length-1;Q>=1&&$>=0&&S[Q]!==J[$];)$--;for(;Q>=1&&$>=0;Q--,$--)if(S[Q]!==J[$]){if(Q!==1||$!==1)do if(Q--,$--,$<0||S[Q]!==J[$]){var se=`
|
|
21
|
+
`+S[Q].replace(" at new "," at ");return i.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",i.displayName)),typeof i=="function"&&$t.set(i,se),se}while(Q>=1&&$>=0);break}}}finally{mr=!1,yr.current=j,So(),Error.prepareStackTrace=k}var ht=i?i.displayName||i.name:"",ze=ht?Qt(ht):"";return typeof i=="function"&&$t.set(i,ze),ze}function To(i,y,b){return es(i,!1)}function Fo(i){var y=i.prototype;return!!(y&&y.isReactComponent)}function Kt(i,y,b){if(i==null)return"";if(typeof i=="function")return es(i,Fo(i));if(typeof i=="string")return Qt(i);switch(i){case d:return Qt("Suspense");case h:return Qt("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case c:return To(i.render);case f:return Kt(i.type,y,b);case p:{var E=i,k=E._payload,j=E._init;try{return Kt(j(k),y,b)}catch{}}}return""}var xt=Object.prototype.hasOwnProperty,ts={},rs=D.ReactDebugCurrentFrame;function Vt(i){if(i){var y=i._owner,b=Kt(i.type,i._source,y?y.type:null);rs.setExtraStackFrame(b)}else rs.setExtraStackFrame(null)}function xo(i,y,b,E,k){{var j=Function.call.bind(xt);for(var A in i)if(j(i,A)){var S=void 0;try{if(typeof i[A]!="function"){var J=Error((E||"React class")+": "+b+" type `"+A+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[A]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw J.name="Invariant Violation",J}S=i[A](y,A,E,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Q){S=Q}S&&!(S instanceof Error)&&(Vt(k),F("%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,A,typeof S),Vt(null)),S instanceof Error&&!(S.message in ts)&&(ts[S.message]=!0,Vt(k),F("Failed %s type: %s",b,S.message),Vt(null))}}}var Ao=Array.isArray;function gr(i){return Ao(i)}function Do(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 F("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Do(i)),ns(i)}var is=D.ReactCurrentOwner,Io={key:!0,ref:!0,__self:!0,__source:!0},os,as;function ko(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 jo(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 qo(i,y){typeof i.ref=="string"&&is.current}function Uo(i,y){{var b=function(){os||(os=!0,F("%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,F("%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,k,j,A){var S={$$typeof:e,type:i,key:y,ref:b,props:A,_owner:j};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:k}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function Lo(i,y,b,E,k){{var j,A={},S=null,J=null;b!==void 0&&(ss(b),S=""+b),jo(y)&&(ss(y.key),S=""+y.key),ko(y)&&(J=y.ref,qo(y,k));for(j in y)xt.call(y,j)&&!Io.hasOwnProperty(j)&&(A[j]=y[j]);if(i&&i.defaultProps){var Q=i.defaultProps;for(j in Q)A[j]===void 0&&(A[j]=Q[j])}if(S||J){var $=typeof i=="function"?i.displayName||i.name||"Unknown":i;S&&Uo(A,$),J&&Mo(A,$)}return No(i,S,J,k,E,is.current,A)}}var br=D.ReactCurrentOwner,us=D.ReactDebugCurrentFrame;function ft(i){if(i){var y=i._owner,b=Kt(i.type,i._source,y?y.type:null);us.setExtraStackFrame(b)}else us.setExtraStackFrame(null)}var vr;vr=!1;function wr(i){return typeof i=="object"&&i!==null&&i.$$typeof===e}function cs(){{if(br.current){var i=Ae(br.current.type);if(i)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+i+"`."}return""}}function Qo(i){return""}var ls={};function $o(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=$o(y);if(ls[b])return;ls[b]=!0;var E="";i&&i._owner&&i._owner!==br.current&&(E=" It was passed a child from "+Ae(i._owner.type)+"."),ft(i),F('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),ft(null)}}function hs(i,y){{if(typeof i!="object")return;if(gr(i))for(var b=0;b<i.length;b++){var E=i[b];wr(E)&&fs(E,y)}else if(wr(i))i._store&&(i._store.validated=!0);else if(i){var k=O(i);if(typeof k=="function"&&k!==i.entries)for(var j=k.call(i),A;!(A=j.next()).done;)wr(A.value)&&fs(A.value,y)}}}function Ko(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&&!vr){vr=!0;var k=Ae(y);F("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof y.getDefaultProps=="function"&&!y.getDefaultProps.isReactClassApproved&&F("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vo(i){{for(var y=Object.keys(i.props),b=0;b<y.length;b++){var E=y[b];if(E!=="children"&&E!=="key"){ft(i),F("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),ft(null);break}}i.ref!==null&&(ft(i),F("Invalid attribute `ref` supplied to `React.Fragment`."),ft(null))}}var ds={};function ys(i,y,b,E,k,j){{var A=Fe(i);if(!A){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
|
|
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=$o(y);if(ls[b])return;ls[b]=!0;var E="";i&&i._owner&&i._owner!==br.current&&(E=" It was passed a child from "+Ae(i._owner.type)+"."),ft(i),F('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),ft(null)}}function hs(i,y){{if(typeof i!="object")return;if(gr(i))for(var b=0;b<i.length;b++){var E=i[b];wr(E)&&fs(E,y)}else if(wr(i))i._store&&(i._store.validated=!0);else if(i){var k=O(i);if(typeof k=="function"&&k!==i.entries)for(var j=k.call(i),A;!(A=j.next()).done;)wr(A.value)&&fs(A.value,y)}}}function Ko(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&&!vr){vr=!0;var k=Ae(y);F("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof y.getDefaultProps=="function"&&!y.getDefaultProps.isReactClassApproved&&F("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vo(i){{for(var y=Object.keys(i.props),b=0;b<y.length;b++){var E=y[b];if(E!=="children"&&E!=="key"){ft(i),F("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),ft(null);break}}i.ref!==null&&(ft(i),F("Invalid attribute `ref` supplied to `React.Fragment`."),ft(null))}}var ds={};function ys(i,y,b,E,k,j){{var A=Fe(i);if(!A){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 J=Qo();J?S+=J:S+=cs();var Q;i===null?Q="null":gr(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,F("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 $=Lo(i,y,b,k,j);if($==null)return $;if(A){var se=y.children;if(se!==void 0)if(E)if(gr(se)){for(var ht=0;ht<se.length;ht++)hs(se[ht],i);Object.freeze&&Object.freeze(se)}else F("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(Yo){return Yo!=="key"}),Er=ee.length>0?"{key: someKey, "+ee.join(": ..., ")+": ...}":"{key: someKey}";if(!ds[ze+Er]){var Go=ee.length>0?"{"+ee.join(": ..., ")+": ...}":"{}";F(`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} />`,Er,ze,Go,ze),ds[ze+Er]=!0}}return i===n?Vo($):Ko($),$}}function zo(i,y,b){return ys(i,y,b,!0)}function Ho(i,y,b){return ys(i,y,b,!1)}var Wo=Ho,Bo=zo;pt.Fragment=n,pt.jsx=Wo,pt.jsxs=Bo}()),pt}process.env.NODE_ENV==="production"?dt.exports=gs():dt.exports=bs();var mt=dt.exports,Wt=(t=>(t.NOT_CHUNKED="NOT_CHUNKED",t.PROCESSING="PROCESSING",t.CHUNKED="CHUNKED",t.ERROR_CHUNKING="ERROR_CHUNKING",t))(Wt||{}),Dt=(t=>(t.PDF="application/pdf",t.TXT="text/plain",t.CSV="text/csv",t.DIRECTORY="inode/directory",t))(Dt||{});const _t=4e3*1024*1024;Object.entries({"application/pdf":{extensions:[".pdf"],maxSize:_t},"text/plain":{extensions:[".txt",".json",".py",".ts",".tsx"],maxSize:_t},"text/csv":{extensions:[".csv"],maxSize:_t},"inode/directory":{extensions:[],maxSize:_t}}).reduce((t,[e,r])=>({...t,[e]:r.extensions}),{}),new Set(Object.values(Dt));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(){}},_e=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 Ir(t,e){return Math.max(t+(e||0)-Date.now(),0)}function We(t,e){return typeof t=="function"?t(e):t}function ie(t,e){return typeof t=="function"?t(e):t}function kr(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:u,stale:l}=t;if(u){if(n){if(e.queryHash!==Gt(u,e.options))return!1}else if(!gt(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(!gt(e.options.mutationKey,a))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Gt(t,e){return((e==null?void 0:e.queryKeyHashFn)||Ie)(t)}function Ie(t){return JSON.stringify(t,(e,r)=>Xt(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function gt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(r=>!gt(t[r],e[r])):!1}function Yt(t,e){if(t===e)return t;const r=qr(t)&&qr(e);if(r||Xt(t)&&Xt(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]=Yt(t[h],e[h]),l[h]===t[h]&&t[h]!==void 0&&c++)}return s===u&&c===s?t:l}return e}function It(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 qr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Xt(t){if(!Ur(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!Ur(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Ur(t){return Object.prototype.toString.call(t)==="[object Object]"}function ws(t){return new Promise(e=>{setTimeout(e,t)})}function Jt(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 Yt(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 Yt(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 kt=Symbol();function Mr(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===kt&&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===kt?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Ps=(An=class extends He{constructor(){super();w(this,je);w(this,ve);w(this,Je);g(this,Je,e=>{if(!_e&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){o(this,ve)||this.setEventListener(o(this,Je))}onUnsubscribe(){var e;this.hasListeners()||((e=o(this,ve))==null||e.call(this),g(this,ve,void 0))}setEventListener(e){var r;g(this,Je,e),(r=o(this,ve))==null||r.call(this),g(this,ve,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){o(this,je)!==e&&(g(this,je,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof o(this,je)=="boolean"?o(this,je):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},je=new WeakMap,ve=new WeakMap,Je=new WeakMap,An),Zt=new Ps,Rs=(Dn=class extends He{constructor(){super();w(this,Ze,!0);w(this,we);w(this,et);g(this,et,e=>{if(!_e&&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,et))}onUnsubscribe(){var e;this.hasListeners()||((e=o(this,we))==null||e.call(this),g(this,we,void 0))}setEventListener(e){var r;g(this,et,e),(r=o(this,we))==null||r.call(this),g(this,we,e(this.setOnline.bind(this)))}setOnline(e){o(this,Ze)!==e&&(g(this,Ze,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return o(this,Ze)}},Ze=new WeakMap,we=new WeakMap,et=new WeakMap,Dn),jt=new Rs;function er(){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"?jt.isOnline():!0}var Lr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function tr(t){return t instanceof Lr}function Qr(t){let e=!1,r=0,n=!1,s;const a=er(),u=v=>{var O;n||(p(new Lr(v)),(O=t.abort)==null||O.call(t))},l=()=>{e=!0},c=()=>{e=!1},d=()=>Zt.isFocused()&&(t.networkMode==="always"||jt.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))},m=()=>new Promise(v=>{var O;s=D=>{(n||d())&&v(D)},(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(D){v=Promise.reject(D)}Promise.resolve(v).then(f).catch(D=>{var te;if(n)return;const F=t.retry??(_e?0:3),U=t.retryDelay??Ss,V=typeof U=="function"?U(r,D):U,Y=F===!0||typeof F=="number"&&r<F||typeof F=="function"&&F(r,D);if(e||!Y){p(D);return}r++,(te=t.onFail)==null||te.call(t,r,D),ws(V).then(()=>d()?void 0:m()).then(()=>{e?p(D):P()})})};return{promise:a,cancel:u,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:h,start:()=>(h()?P():m().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(),$r=(_n=class{constructor(){w(this,qe)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bt(this.gcTime)&&g(this,qe,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(_e?1/0:5*60*1e3))}clearGcTimeout(){o(this,qe)&&(clearTimeout(o(this,qe)),g(this,qe,void 0))}},qe=new WeakMap,_n),Ts=(In=class extends $r{constructor(e){super();w(this,oe);w(this,tt);w(this,rt);w(this,ne);w(this,Ue);w(this,W);w(this,Rt);w(this,Me);g(this,Me,!1),g(this,Rt,e.defaultOptions),this.setOptions(e.options),this.observers=[],g(this,Ue,e.client),g(this,ne,o(this,Ue).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,g(this,tt,Fs(this.options)),this.state=e.state??o(this,tt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=o(this,W))==null?void 0:e.promise}setOptions(e){this.options={...o(this,Rt),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&o(this,ne).remove(this)}setData(e,r){const n=Jt(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,W))==null?void 0:n.promise;return(s=o(this,W))==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,tt))}isActive(){return this.observers.some(e=>ie(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===kt||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||!Ir(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,W))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,W))==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,W)&&(o(this,Me)?o(this,W).cancel({revert:!0}):o(this,W).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,W))return o(this,W).continueRetry(),o(this,W).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:()=>(g(this,Me,!0),n.signal)})},a=()=>{const f=Mr(this.options,r),p={client:o(this,Ue),queryKey:this.queryKey,meta:this.meta};return s(p),g(this,Me,!1),this.options.persister?this.options.persister(f,p,this):f(p)},u={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:o(this,Ue),state:this.state,fetchFn:a};s(u),(c=this.options.behavior)==null||c.onFetch(u,this),g(this,rt,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,m,P,v;tr(f)&&f.silent||R(this,oe,me).call(this,{type:"error",error:f}),tr(f)||((m=(p=o(this,ne).config).onError)==null||m.call(p,f,this),(v=(P=o(this,ne).config).onSettled)==null||v.call(P,this.state.data,f,this)),this.scheduleGc()};return g(this,W,Qr({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,m,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}(m=(p=o(this,ne).config).onSuccess)==null||m.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,W).start()}},tt=new WeakMap,rt=new WeakMap,ne=new WeakMap,Ue=new WeakMap,W=new WeakMap,Rt=new WeakMap,Me=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,...Kr(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 tr(s)&&s.revert&&o(this,rt)?{...o(this,rt),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 Kr(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Nr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Fs(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 xs=(kn=class extends He{constructor(e={}){super();w(this,ce);this.config=e,g(this,ce,new Map)}build(e,r,n){const s=r.queryKey,a=r.queryHash??Gt(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=>kr(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>kr(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,kn),As=(jn=class extends $r{constructor(e){super();w(this,fe);w(this,le);w(this,B);w(this,Ne);this.mutationId=e.mutationId,g(this,B,e.mutationCache),g(this,le,[]),this.state=e.state||Vr(),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,B).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){g(this,le,o(this,le).filter(r=>r!==e)),this.scheduleGc(),o(this,B).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){o(this,le).length||(this.state.status==="pending"?this.scheduleGc():o(this,B).remove(this))}continue(){var e;return((e=o(this,Ne))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var s,a,u,l,c,d,h,f,p,m,P,v,O,D,F,U,V,Y,te,z;g(this,Ne,Qr({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(N,q)=>{R(this,fe,De).call(this,{type:"failed",failureCount:N,error:q})},onPause:()=>{R(this,fe,De).call(this,{type:"pause"})},onContinue:()=>{R(this,fe,De).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>o(this,B).canRun(this)}));const r=this.state.status==="pending",n=!o(this,Ne).canStart();try{if(!r){R(this,fe,De).call(this,{type:"pending",variables:e,isPaused:n}),await((a=(s=o(this,B).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,De).call(this,{type:"pending",context:q,variables:e,isPaused:n})}const N=await o(this,Ne).start();return await((d=(c=o(this,B).config).onSuccess)==null?void 0:d.call(c,N,e,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,N,e,this.state.context)),await((m=(p=o(this,B).config).onSettled)==null?void 0:m.call(p,N,null,this.state.variables,this.state.context,this)),await((v=(P=this.options).onSettled)==null?void 0:v.call(P,N,null,e,this.state.context)),R(this,fe,De).call(this,{type:"success",data:N}),N}catch(N){try{throw await((D=(O=o(this,B).config).onError)==null?void 0:D.call(O,N,e,this.state.context,this)),await((U=(F=this.options).onError)==null?void 0:U.call(F,N,e,this.state.context)),await((Y=(V=o(this,B).config).onSettled)==null?void 0:Y.call(V,void 0,N,this.state.variables,this.state.context,this)),await((z=(te=this.options).onSettled)==null?void 0:z.call(te,void 0,N,e,this.state.context)),N}finally{R(this,fe,De).call(this,{type:"error",error:N})}}finally{o(this,B).runNext(this)}}},le=new WeakMap,B=new WeakMap,Ne=new WeakMap,fe=new WeakSet,De=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,B).notify({mutation:this,type:"updated",action:e})})},jn);function Vr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ds=(qn=class extends He{constructor(e={}){super();w(this,de);w(this,ae);w(this,St);this.config=e,g(this,de,new Set),g(this,ae,new Map),g(this,St,0)}build(e,r,n){const s=new As({mutationCache:this,mutationId:++zt(this,St)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){o(this,de).add(e);const r=qt(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=qt(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=qt(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=qt(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,St=new WeakMap,qn);function qt(t){var e;return(e=t.options.scope)==null?void 0:e.id}function zr(t){return{onFetch:(e,r)=>{var h,f,p,m,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=((m=e.state.data)==null?void 0:m.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=U=>{Object.defineProperty(U,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},D=Mr(e.options,e.fetchOptions),F=async(U,V,Y)=>{if(v)return Promise.reject();if(V==null&&U.pages.length)return Promise.resolve(U);const te={client:e.client,queryKey:e.queryKey,pageParam:V,direction:Y?"backward":"forward",meta:e.options.meta};O(te);const z=await D(te),{maxPages:N}=e.options,q=Y?Os:Es;return{pages:q(U.pages,z,N),pageParams:q(U.pageParams,V,N)}};if(s&&a.length){const U=s==="backward",V=U?_s:Hr,Y={pages:a,pageParams:u},te=V(n,Y);l=await F(Y,te,U)}else{const U=t??a.length;do{const V=c===0?u[0]??n.initialPageParam:Hr(n,l);if(c>0&&V==null)break;l=await F(l,V),c++}while(c<U)}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 Hr(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 _s(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=(Un=class{constructor(t={}){w(this,L);w(this,Ee);w(this,Oe);w(this,nt);w(this,st);w(this,Pe);w(this,it);w(this,ot);g(this,L,t.queryCache||new xs),g(this,Ee,t.mutationCache||new Ds),g(this,Oe,t.defaultOptions||{}),g(this,nt,new Map),g(this,st,new Map),g(this,Pe,0)}mount(){zt(this,Pe)._++,o(this,Pe)===1&&(g(this,it,Zt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onFocus())})),g(this,ot,jt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onOnline())})))}unmount(){var t,e;zt(this,Pe)._--,o(this,Pe)===0&&((t=o(this,it))==null||t.call(this),g(this,it,void 0),(e=o(this,ot))==null||e.call(this),g(this,ot,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(We(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(We(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=zr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(re).catch(re)}ensureInfiniteQueryData(t){return t.behavior=zr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return jt.isOnline()?o(this,Ee).resumePausedMutations():Promise.resolve()}getQueryCache(){return o(this,L)}getMutationCache(){return o(this,Ee)}getDefaultOptions(){return o(this,Oe)}setDefaultOptions(t){g(this,Oe,t)}setQueryDefaults(t,e){o(this,nt).set(Ie(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...o(this,nt).values()],r={};return e.forEach(n=>{gt(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){o(this,st).set(Ie(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...o(this,st).values()],r={};return e.forEach(n=>{gt(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=Gt(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===kt&&(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,nt=new WeakMap,st=new WeakMap,Pe=new WeakMap,it=new WeakMap,ot=new WeakMap,Un),ks=(Mn=class extends He{constructor(e,r){super();w(this,I);w(this,J);w(this,T);w(this,Ct);w(this,G);w(this,Le);w(this,at);w(this,Re);w(this,he);w(this,Tt);w(this,ut);w(this,ct);w(this,Qe);w(this,$e);w(this,Se);w(this,lt,new Set);this.options=r,g(this,J,e),g(this,he,null),g(this,Re,er()),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),Wr(o(this,T),this.options)?R(this,I,At).call(this):this.updateResult(),R(this,I,Cr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rr(o(this,T),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rr(o(this,T),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,R(this,I,Tr).call(this),R(this,I,Fr).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,xr).call(this),o(this,T).setOptions(this.options),n._defaulted&&!It(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,At).call(this),this.updateResult(r),a&&(o(this,T)!==s||ie(this.options.enabled,o(this,T))!==ie(n.enabled,o(this,T))||We(this.options.staleTime,o(this,T))!==We(n.staleTime,o(this,T)))&&R(this,I,Pr).call(this);const u=R(this,I,Rr).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,Sr).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)&&(g(this,G,n),g(this,at,this.options),g(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,lt).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,At).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),o(this,G)))}createResult(e,r){var N;const n=o(this,T),s=this.options,a=o(this,G),u=o(this,Le),l=o(this,at),d=e!==n?e.state:o(this,Ct),{state:h}=e;let f={...h},p=!1,m;if(r._optimisticResults){const q=this.hasListeners(),Fe=!q&&Wr(e,r),xe=q&&Br(e,n,r,s);(Fe||xe)&&(f={...f,...Kr(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,Tt))m=o(this,ut);else try{g(this,Tt,r.select),m=r.select(f.data),m=Jt(a==null?void 0:a.data,m,r),g(this,ut,m),g(this,he,null)}catch(q){g(this,he,q)}else m=f.data;if(r.placeholderData!==void 0&&m===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((N=o(this,ct))==null?void 0:N.state.data,o(this,ct)):r.placeholderData,r.select&&q!==void 0)try{q=r.select(q),g(this,he,null)}catch(Fe){g(this,he,Fe)}q!==void 0&&(O="success",m=Jt(a==null?void 0:a.data,q,r),p=!0)}o(this,he)&&(P=o(this,he),m=o(this,ut),v=Date.now(),O="error");const D=f.fetchStatus==="fetching",F=O==="pending",U=O==="error",V=F&&D,Y=m!==void 0,z={status:O,fetchStatus:f.fetchStatus,isPending:F,isSuccess:O==="success",isError:U,isInitialLoading:V,isLoading:V,data:m,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:D,isRefetching:D&&!F,isLoadingError:U&&!Y,isPaused:f.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:U&&Y,isStale:nr(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)},Fe=()=>{const Ke=g(this,Re,z.promise=er());q(Ke)},xe=o(this,Re);switch(xe.status){case"pending":e.queryHash===n.queryHash&&q(xe);break;case"fulfilled":(z.status==="error"||z.data!==xe.value)&&Fe();break;case"rejected":(z.status!=="error"||z.error!==xe.reason)&&Fe();break}}return z}updateResult(e){const r=o(this,G),n=this.createResult(o(this,T),this.options);if(g(this,Le,o(this,T).state),g(this,at,this.options),o(this,Le).data!==void 0&&g(this,ct,o(this,T)),It(n,r))return;g(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,lt).size)return!0;const c=new Set(l??o(this,lt));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,Cr).call(this)}},J=new WeakMap,T=new WeakMap,Ct=new WeakMap,G=new WeakMap,Le=new WeakMap,at=new WeakMap,Re=new WeakMap,he=new WeakMap,Tt=new WeakMap,ut=new WeakMap,ct=new WeakMap,Qe=new WeakMap,$e=new WeakMap,Se=new WeakMap,lt=new WeakMap,I=new WeakSet,At=function(e){R(this,I,xr).call(this);let r=o(this,T).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(re)),r},Pr=function(){R(this,I,Tr).call(this);const e=We(this.options.staleTime,o(this,T));if(_e||o(this,G).isStale||!Bt(e))return;const n=Ir(o(this,G).dataUpdatedAt,e)+1;g(this,Qe,setTimeout(()=>{o(this,G).isStale||this.updateResult()},n))},Rr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(o(this,T)):this.options.refetchInterval)??!1},Sr=function(e){R(this,I,Fr).call(this),g(this,Se,e),!(_e||ie(this.options.enabled,o(this,T))===!1||!Bt(o(this,Se))||o(this,Se)===0)&&g(this,$e,setInterval(()=>{(this.options.refetchIntervalInBackground||Zt.isFocused())&&R(this,I,At).call(this)},o(this,Se)))},Cr=function(){R(this,I,Pr).call(this),R(this,I,Sr).call(this,R(this,I,Rr).call(this))},Tr=function(){o(this,Qe)&&(clearTimeout(o(this,Qe)),g(this,Qe,void 0))},Fr=function(){o(this,$e)&&(clearInterval(o(this,$e)),g(this,$e,void 0))},xr=function(){const e=o(this,J).getQueryCache().build(o(this,J),this.options);if(e===o(this,T))return;const r=o(this,T);g(this,T,e),g(this,Ct,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"})})},Mn);function js(t,e){return ie(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Wr(t,e){return js(t,e)||t.state.data!==void 0&&rr(t,e,e.refetchOnMount)}function rr(t,e,r){if(ie(e.enabled,t)!==!1){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&nr(t,e)}return!1}function Br(t,e,r,n){return(t!==e||ie(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&nr(t,r)}function nr(t,e){return ie(e.enabled,t)!==!1&&t.isStaleByTime(We(e.staleTime,t))}function qs(t,e){return!It(t.getCurrentResult(),e)}var Us=(Nn=class extends He{constructor(e,r){super();w(this,pe);w(this,Ce);w(this,Te);w(this,Z);w(this,ye);g(this,Ce,e),this.setOptions(r),this.bindMethods(),R(this,pe,Ht).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),It(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,Ht).call(this),R(this,pe,Ar).call(this,e)}getCurrentResult(){return o(this,Te)}reset(){var e;(e=o(this,Z))==null||e.removeObserver(this),g(this,Z,void 0),R(this,pe,Ht).call(this),R(this,pe,Ar).call(this)}mutate(e,r){var n;return g(this,ye,r),(n=o(this,Z))==null||n.removeObserver(this),g(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,Ht=function(){var r;const e=((r=o(this,Z))==null?void 0:r.state)??Vr();g(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})},Ar=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))})})},Nn),Gr=M.createContext(void 0),bt=t=>{const e=M.useContext(Gr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ms=({client:t,children:e})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),mt.jsx(Gr.Provider,{value:t,children:e})),Yr=M.createContext(!1),Ns=()=>M.useContext(Yr);Yr.Provider;function Ls(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Qs=M.createContext(Ls()),$s=()=>M.useContext(Qs);function Xr(t,e){return typeof t=="function"?t(...e):!!t}function sr(){}var Ks=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Vs=t=>{M.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||Xr(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)))},Ws=(t,e)=>t.isLoading&&t.isFetching&&!e,Bs=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Jr=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Gs(t,e,r){var f,p,m,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=bt(),s=Ns(),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]=M.useState(()=>new e(n,u)),d=c.getOptimisticResult(u),h=!s&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(O=>{const D=h?c.subscribe(K.batchCalls(O)):sr;return c.updateResult(),D},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setOptions(u,{listeners:!1})},[u,c]),Bs(u,d))throw Jr(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=(m=n.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||P.call(m,u,d),u.experimental_prefetchInRender&&!_e&&Ws(d,s)){const O=l?Jr(u,c,a):(v=n.getQueryCache().get(u.queryHash))==null?void 0:v.promise;O==null||O.catch(sr).finally(()=>{c.updateResult()})}return u.notifyOnChangeProps?d:c.trackResult(d)}function Zr(t,e){return Gs(t,ks)}function ir(t,e){const r=bt(),[n]=M.useState(()=>new Us(r,t));M.useEffect(()=>{n.setOptions(t)},[n,t]);const s=M.useSyncExternalStore(M.useCallback(u=>n.subscribe(K.batchCalls(u)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=M.useCallback((u,l)=>{n.mutate(u,l).catch(sr)},[n]);if(s.error&&Xr(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}function Be(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 Be(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=>Be(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=Be(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 Be(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 vt(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 or extends Error{constructor(){super("Unable to transform response from server")}}function ii(t,e){let r;try{r=si(t,e)}catch{throw new or}if(!r.ok&&(!vt(r.error.error)||typeof r.error.error.code!="number"))throw new or;if(r.ok&&!vt(r.result))throw new or;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 Ut(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 vt(t)&&vt(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function ui(t,e){return typeof t=="string"?t:vt(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}),Ut(this,"cause",void 0),Ut(this,"shape",void 0),Ut(this,"data",void 0),Ut(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 ar(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){ar(this,"links",void 0),ar(this,"runtime",void 0),ar(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 m=c[c.length-1];if(p.aborted){(h=p.reject)==null||h.call(p,new Error("Aborted")),d++;continue}if(t.validate(m.concat(p).map(v=>v.key))){m.push(p),d++;continue}if(m.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(m,P)=>{var O,D;const v=d.items[P];try{const F=await Promise.resolve(m);(O=v.resolve)==null||O.call(v,F)}catch(F){(D=v.reject)==null||D.call(v,F)}v.batch=null,v.reject=null,v.resolve=null}));for(const m of d.items)(p=m.reject)==null||p.call(m,new Error("Missing result")),m.batch=null}).catch(f=>{var p;for(const m of d.items)(p=m.reject)==null||p.call(m,f),m.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})=>Be(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 m=ii(p.json,e.transformer.output);if(!m.ok){c.error(ge.from(m.error,{meta:p.meta}));return}c.next({context:p.meta,result:m.result}),c.complete()}).catch(p=>{c.error(ge.from(p,{meta:f==null?void 0:f.meta}))}),()=>{}})}}function Fi(t){return typeof FormData>"u"?!1:t instanceof FormData}const ur={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 xi(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]=ur.ansi.regular[r],[f,p]=ur.ansi.bold[r];l.push(e==="up"?d:h,e==="up"?">>":"<<",r,e==="up"?f:p,`#${a}`,s,"\x1B[0m")}else{const[d,h]=ur.css[r],f=`
|
|
30
|
+
<%s key={someKey} {...props} />`,Er,ze,Go,ze),ds[ze+Er]=!0}}return i===n?Vo($):Ko($),$}}function zo(i,y,b){return ys(i,y,b,!0)}function Ho(i,y,b){return ys(i,y,b,!1)}var Wo=Ho,Bo=zo;pt.Fragment=n,pt.jsx=Wo,pt.jsxs=Bo}()),pt}process.env.NODE_ENV==="production"?dt.exports=gs():dt.exports=bs();var mt=dt.exports,Wt=(t=>(t.NOT_CHUNKED="NOT_CHUNKED",t.PROCESSING="PROCESSING",t.CHUNKED="CHUNKED",t.ERROR_CHUNKING="ERROR_CHUNKING",t))(Wt||{}),Dt=(t=>(t.PDF="application/pdf",t.TXT="text/plain",t.CSV="text/csv",t.DIRECTORY="inode/directory",t))(Dt||{});const _t=4e3*1024*1024;Object.entries({"application/pdf":{extensions:[".pdf"],maxSize:_t},"text/plain":{extensions:[".txt",".json",".py",".ts",".tsx"],maxSize:_t},"text/csv":{extensions:[".csv"],maxSize:_t},"inode/directory":{extensions:[],maxSize:_t}}).reduce((t,[e,r])=>({...t,[e]:r.extensions}),{}),new Set(Object.values(Dt));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(){}},_e=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 Ir(t,e){return Math.max(t+(e||0)-Date.now(),0)}function We(t,e){return typeof t=="function"?t(e):t}function ie(t,e){return typeof t=="function"?t(e):t}function kr(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:u,stale:l}=t;if(u){if(n){if(e.queryHash!==Gt(u,e.options))return!1}else if(!gt(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(!gt(e.options.mutationKey,a))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Gt(t,e){return((e==null?void 0:e.queryKeyHashFn)||Ie)(t)}function Ie(t){return JSON.stringify(t,(e,r)=>Jt(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function gt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(r=>!gt(t[r],e[r])):!1}function Yt(t,e){if(t===e)return t;const r=qr(t)&&qr(e);if(r||Jt(t)&&Jt(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]=Yt(t[h],e[h]),l[h]===t[h]&&t[h]!==void 0&&c++)}return s===u&&c===s?t:l}return e}function It(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 qr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Jt(t){if(!Ur(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!Ur(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Ur(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 Yt(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 Yt(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 kt=Symbol();function Mr(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===kt&&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===kt?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Ps=(An=class extends He{constructor(){super();w(this,je);w(this,ve);w(this,Xe);g(this,Xe,e=>{if(!_e&&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),g(this,ve,void 0))}setEventListener(e){var r;g(this,Xe,e),(r=o(this,ve))==null||r.call(this),g(this,ve,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){o(this,je)!==e&&(g(this,je,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof o(this,je)=="boolean"?o(this,je):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},je=new WeakMap,ve=new WeakMap,Xe=new WeakMap,An),Zt=new Ps,Rs=(Dn=class extends He{constructor(){super();w(this,Ze,!0);w(this,we);w(this,et);g(this,et,e=>{if(!_e&&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,et))}onUnsubscribe(){var e;this.hasListeners()||((e=o(this,we))==null||e.call(this),g(this,we,void 0))}setEventListener(e){var r;g(this,et,e),(r=o(this,we))==null||r.call(this),g(this,we,e(this.setOnline.bind(this)))}setOnline(e){o(this,Ze)!==e&&(g(this,Ze,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return o(this,Ze)}},Ze=new WeakMap,we=new WeakMap,et=new WeakMap,Dn),jt=new Rs;function er(){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"?jt.isOnline():!0}var Lr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function tr(t){return t instanceof Lr}function Qr(t){let e=!1,r=0,n=!1,s;const a=er(),u=v=>{var O;n||(p(new Lr(v)),(O=t.abort)==null||O.call(t))},l=()=>{e=!0},c=()=>{e=!1},d=()=>Zt.isFocused()&&(t.networkMode==="always"||jt.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))},m=()=>new Promise(v=>{var O;s=D=>{(n||d())&&v(D)},(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(D){v=Promise.reject(D)}Promise.resolve(v).then(f).catch(D=>{var te;if(n)return;const F=t.retry??(_e?0:3),U=t.retryDelay??Ss,V=typeof U=="function"?U(r,D):U,Y=F===!0||typeof F=="number"&&r<F||typeof F=="function"&&F(r,D);if(e||!Y){p(D);return}r++,(te=t.onFail)==null||te.call(t,r,D),ws(V).then(()=>d()?void 0:m()).then(()=>{e?p(D):P()})})};return{promise:a,cancel:u,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:h,start:()=>(h()?P():m().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(),$r=(_n=class{constructor(){w(this,qe)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bt(this.gcTime)&&g(this,qe,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(_e?1/0:5*60*1e3))}clearGcTimeout(){o(this,qe)&&(clearTimeout(o(this,qe)),g(this,qe,void 0))}},qe=new WeakMap,_n),Ts=(In=class extends $r{constructor(e){super();w(this,oe);w(this,tt);w(this,rt);w(this,ne);w(this,Ue);w(this,W);w(this,Rt);w(this,Me);g(this,Me,!1),g(this,Rt,e.defaultOptions),this.setOptions(e.options),this.observers=[],g(this,Ue,e.client),g(this,ne,o(this,Ue).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,g(this,tt,Fs(this.options)),this.state=e.state??o(this,tt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=o(this,W))==null?void 0:e.promise}setOptions(e){this.options={...o(this,Rt),...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,W))==null?void 0:n.promise;return(s=o(this,W))==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,tt))}isActive(){return this.observers.some(e=>ie(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===kt||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||!Ir(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,W))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=o(this,W))==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,W)&&(o(this,Me)?o(this,W).cancel({revert:!0}):o(this,W).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,W))return o(this,W).continueRetry(),o(this,W).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:()=>(g(this,Me,!0),n.signal)})},a=()=>{const f=Mr(this.options,r),p={client:o(this,Ue),queryKey:this.queryKey,meta:this.meta};return s(p),g(this,Me,!1),this.options.persister?this.options.persister(f,p,this):f(p)},u={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:o(this,Ue),state:this.state,fetchFn:a};s(u),(c=this.options.behavior)==null||c.onFetch(u,this),g(this,rt,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,m,P,v;tr(f)&&f.silent||R(this,oe,me).call(this,{type:"error",error:f}),tr(f)||((m=(p=o(this,ne).config).onError)==null||m.call(p,f,this),(v=(P=o(this,ne).config).onSettled)==null||v.call(P,this.state.data,f,this)),this.scheduleGc()};return g(this,W,Qr({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,m,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}(m=(p=o(this,ne).config).onSuccess)==null||m.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,W).start()}},tt=new WeakMap,rt=new WeakMap,ne=new WeakMap,Ue=new WeakMap,W=new WeakMap,Rt=new WeakMap,Me=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,...Kr(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 tr(s)&&s.revert&&o(this,rt)?{...o(this,rt),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 Kr(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Nr(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Fs(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 xs=(kn=class extends He{constructor(e={}){super();w(this,ce);this.config=e,g(this,ce,new Map)}build(e,r,n){const s=r.queryKey,a=r.queryHash??Gt(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=>kr(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>kr(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,kn),As=(jn=class extends $r{constructor(e){super();w(this,fe);w(this,le);w(this,B);w(this,Ne);this.mutationId=e.mutationId,g(this,B,e.mutationCache),g(this,le,[]),this.state=e.state||Vr(),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,B).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){g(this,le,o(this,le).filter(r=>r!==e)),this.scheduleGc(),o(this,B).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){o(this,le).length||(this.state.status==="pending"?this.scheduleGc():o(this,B).remove(this))}continue(){var e;return((e=o(this,Ne))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var s,a,u,l,c,d,h,f,p,m,P,v,O,D,F,U,V,Y,te,z;g(this,Ne,Qr({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(N,q)=>{R(this,fe,De).call(this,{type:"failed",failureCount:N,error:q})},onPause:()=>{R(this,fe,De).call(this,{type:"pause"})},onContinue:()=>{R(this,fe,De).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>o(this,B).canRun(this)}));const r=this.state.status==="pending",n=!o(this,Ne).canStart();try{if(!r){R(this,fe,De).call(this,{type:"pending",variables:e,isPaused:n}),await((a=(s=o(this,B).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,De).call(this,{type:"pending",context:q,variables:e,isPaused:n})}const N=await o(this,Ne).start();return await((d=(c=o(this,B).config).onSuccess)==null?void 0:d.call(c,N,e,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,N,e,this.state.context)),await((m=(p=o(this,B).config).onSettled)==null?void 0:m.call(p,N,null,this.state.variables,this.state.context,this)),await((v=(P=this.options).onSettled)==null?void 0:v.call(P,N,null,e,this.state.context)),R(this,fe,De).call(this,{type:"success",data:N}),N}catch(N){try{throw await((D=(O=o(this,B).config).onError)==null?void 0:D.call(O,N,e,this.state.context,this)),await((U=(F=this.options).onError)==null?void 0:U.call(F,N,e,this.state.context)),await((Y=(V=o(this,B).config).onSettled)==null?void 0:Y.call(V,void 0,N,this.state.variables,this.state.context,this)),await((z=(te=this.options).onSettled)==null?void 0:z.call(te,void 0,N,e,this.state.context)),N}finally{R(this,fe,De).call(this,{type:"error",error:N})}}finally{o(this,B).runNext(this)}}},le=new WeakMap,B=new WeakMap,Ne=new WeakMap,fe=new WeakSet,De=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,B).notify({mutation:this,type:"updated",action:e})})},jn);function Vr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ds=(qn=class extends He{constructor(e={}){super();w(this,de);w(this,ae);w(this,St);this.config=e,g(this,de,new Set),g(this,ae,new Map),g(this,St,0)}build(e,r,n){const s=new As({mutationCache:this,mutationId:++zt(this,St)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){o(this,de).add(e);const r=qt(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=qt(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=qt(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=qt(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,St=new WeakMap,qn);function qt(t){var e;return(e=t.options.scope)==null?void 0:e.id}function zr(t){return{onFetch:(e,r)=>{var h,f,p,m,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=((m=e.state.data)==null?void 0:m.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=U=>{Object.defineProperty(U,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},D=Mr(e.options,e.fetchOptions),F=async(U,V,Y)=>{if(v)return Promise.reject();if(V==null&&U.pages.length)return Promise.resolve(U);const te={client:e.client,queryKey:e.queryKey,pageParam:V,direction:Y?"backward":"forward",meta:e.options.meta};O(te);const z=await D(te),{maxPages:N}=e.options,q=Y?Os:Es;return{pages:q(U.pages,z,N),pageParams:q(U.pageParams,V,N)}};if(s&&a.length){const U=s==="backward",V=U?_s:Hr,Y={pages:a,pageParams:u},te=V(n,Y);l=await F(Y,te,U)}else{const U=t??a.length;do{const V=c===0?u[0]??n.initialPageParam:Hr(n,l);if(c>0&&V==null)break;l=await F(l,V),c++}while(c<U)}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 Hr(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 _s(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=(Un=class{constructor(t={}){w(this,L);w(this,Ee);w(this,Oe);w(this,nt);w(this,st);w(this,Pe);w(this,it);w(this,ot);g(this,L,t.queryCache||new xs),g(this,Ee,t.mutationCache||new Ds),g(this,Oe,t.defaultOptions||{}),g(this,nt,new Map),g(this,st,new Map),g(this,Pe,0)}mount(){zt(this,Pe)._++,o(this,Pe)===1&&(g(this,it,Zt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onFocus())})),g(this,ot,jt.subscribe(async t=>{t&&(await this.resumePausedMutations(),o(this,L).onOnline())})))}unmount(){var t,e;zt(this,Pe)._--,o(this,Pe)===0&&((t=o(this,it))==null||t.call(this),g(this,it,void 0),(e=o(this,ot))==null||e.call(this),g(this,ot,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(We(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(We(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=zr(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(re).catch(re)}ensureInfiniteQueryData(t){return t.behavior=zr(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return jt.isOnline()?o(this,Ee).resumePausedMutations():Promise.resolve()}getQueryCache(){return o(this,L)}getMutationCache(){return o(this,Ee)}getDefaultOptions(){return o(this,Oe)}setDefaultOptions(t){g(this,Oe,t)}setQueryDefaults(t,e){o(this,nt).set(Ie(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...o(this,nt).values()],r={};return e.forEach(n=>{gt(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){o(this,st).set(Ie(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...o(this,st).values()],r={};return e.forEach(n=>{gt(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=Gt(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===kt&&(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,nt=new WeakMap,st=new WeakMap,Pe=new WeakMap,it=new WeakMap,ot=new WeakMap,Un),ks=(Mn=class extends He{constructor(e,r){super();w(this,I);w(this,X);w(this,T);w(this,Ct);w(this,G);w(this,Le);w(this,at);w(this,Re);w(this,he);w(this,Tt);w(this,ut);w(this,ct);w(this,Qe);w(this,$e);w(this,Se);w(this,lt,new Set);this.options=r,g(this,X,e),g(this,he,null),g(this,Re,er()),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),Wr(o(this,T),this.options)?R(this,I,At).call(this):this.updateResult(),R(this,I,Cr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rr(o(this,T),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rr(o(this,T),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,R(this,I,Tr).call(this),R(this,I,Fr).call(this),o(this,T).removeObserver(this)}setOptions(e,r){const n=this.options,s=o(this,T);if(this.options=o(this,X).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,xr).call(this),o(this,T).setOptions(this.options),n._defaulted&&!It(this.options,n)&&o(this,X).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,At).call(this),this.updateResult(r),a&&(o(this,T)!==s||ie(this.options.enabled,o(this,T))!==ie(n.enabled,o(this,T))||We(this.options.staleTime,o(this,T))!==We(n.staleTime,o(this,T)))&&R(this,I,Pr).call(this);const u=R(this,I,Rr).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,Sr).call(this,u)}getOptimisticResult(e){const r=o(this,X).getQueryCache().build(o(this,X),e),n=this.createResult(r,e);return qs(this,n)&&(g(this,G,n),g(this,at,this.options),g(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,lt).add(e)}getCurrentQuery(){return o(this,T)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=o(this,X).defaultQueryOptions(e),n=o(this,X).getQueryCache().build(o(this,X),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return R(this,I,At).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),o(this,G)))}createResult(e,r){var N;const n=o(this,T),s=this.options,a=o(this,G),u=o(this,Le),l=o(this,at),d=e!==n?e.state:o(this,Ct),{state:h}=e;let f={...h},p=!1,m;if(r._optimisticResults){const q=this.hasListeners(),Fe=!q&&Wr(e,r),xe=q&&Br(e,n,r,s);(Fe||xe)&&(f={...f,...Kr(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,Tt))m=o(this,ut);else try{g(this,Tt,r.select),m=r.select(f.data),m=Xt(a==null?void 0:a.data,m,r),g(this,ut,m),g(this,he,null)}catch(q){g(this,he,q)}else m=f.data;if(r.placeholderData!==void 0&&m===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((N=o(this,ct))==null?void 0:N.state.data,o(this,ct)):r.placeholderData,r.select&&q!==void 0)try{q=r.select(q),g(this,he,null)}catch(Fe){g(this,he,Fe)}q!==void 0&&(O="success",m=Xt(a==null?void 0:a.data,q,r),p=!0)}o(this,he)&&(P=o(this,he),m=o(this,ut),v=Date.now(),O="error");const D=f.fetchStatus==="fetching",F=O==="pending",U=O==="error",V=F&&D,Y=m!==void 0,z={status:O,fetchStatus:f.fetchStatus,isPending:F,isSuccess:O==="success",isError:U,isInitialLoading:V,isLoading:V,data:m,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:D,isRefetching:D&&!F,isLoadingError:U&&!Y,isPaused:f.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:U&&Y,isStale:nr(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)},Fe=()=>{const Ke=g(this,Re,z.promise=er());q(Ke)},xe=o(this,Re);switch(xe.status){case"pending":e.queryHash===n.queryHash&&q(xe);break;case"fulfilled":(z.status==="error"||z.data!==xe.value)&&Fe();break;case"rejected":(z.status!=="error"||z.error!==xe.reason)&&Fe();break}}return z}updateResult(e){const r=o(this,G),n=this.createResult(o(this,T),this.options);if(g(this,Le,o(this,T).state),g(this,at,this.options),o(this,Le).data!==void 0&&g(this,ct,o(this,T)),It(n,r))return;g(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,lt).size)return!0;const c=new Set(l??o(this,lt));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,Cr).call(this)}},X=new WeakMap,T=new WeakMap,Ct=new WeakMap,G=new WeakMap,Le=new WeakMap,at=new WeakMap,Re=new WeakMap,he=new WeakMap,Tt=new WeakMap,ut=new WeakMap,ct=new WeakMap,Qe=new WeakMap,$e=new WeakMap,Se=new WeakMap,lt=new WeakMap,I=new WeakSet,At=function(e){R(this,I,xr).call(this);let r=o(this,T).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(re)),r},Pr=function(){R(this,I,Tr).call(this);const e=We(this.options.staleTime,o(this,T));if(_e||o(this,G).isStale||!Bt(e))return;const n=Ir(o(this,G).dataUpdatedAt,e)+1;g(this,Qe,setTimeout(()=>{o(this,G).isStale||this.updateResult()},n))},Rr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(o(this,T)):this.options.refetchInterval)??!1},Sr=function(e){R(this,I,Fr).call(this),g(this,Se,e),!(_e||ie(this.options.enabled,o(this,T))===!1||!Bt(o(this,Se))||o(this,Se)===0)&&g(this,$e,setInterval(()=>{(this.options.refetchIntervalInBackground||Zt.isFocused())&&R(this,I,At).call(this)},o(this,Se)))},Cr=function(){R(this,I,Pr).call(this),R(this,I,Sr).call(this,R(this,I,Rr).call(this))},Tr=function(){o(this,Qe)&&(clearTimeout(o(this,Qe)),g(this,Qe,void 0))},Fr=function(){o(this,$e)&&(clearInterval(o(this,$e)),g(this,$e,void 0))},xr=function(){const e=o(this,X).getQueryCache().build(o(this,X),this.options);if(e===o(this,T))return;const r=o(this,T);g(this,T,e),g(this,Ct,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,X).getQueryCache().notify({query:o(this,T),type:"observerResultsUpdated"})})},Mn);function js(t,e){return ie(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Wr(t,e){return js(t,e)||t.state.data!==void 0&&rr(t,e,e.refetchOnMount)}function rr(t,e,r){if(ie(e.enabled,t)!==!1){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&nr(t,e)}return!1}function Br(t,e,r,n){return(t!==e||ie(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&nr(t,r)}function nr(t,e){return ie(e.enabled,t)!==!1&&t.isStaleByTime(We(e.staleTime,t))}function qs(t,e){return!It(t.getCurrentResult(),e)}var Us=(Nn=class extends He{constructor(e,r){super();w(this,pe);w(this,Ce);w(this,Te);w(this,Z);w(this,ye);g(this,Ce,e),this.setOptions(r),this.bindMethods(),R(this,pe,Ht).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),It(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,Ht).call(this),R(this,pe,Ar).call(this,e)}getCurrentResult(){return o(this,Te)}reset(){var e;(e=o(this,Z))==null||e.removeObserver(this),g(this,Z,void 0),R(this,pe,Ht).call(this),R(this,pe,Ar).call(this)}mutate(e,r){var n;return g(this,ye,r),(n=o(this,Z))==null||n.removeObserver(this),g(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,Ht=function(){var r;const e=((r=o(this,Z))==null?void 0:r.state)??Vr();g(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})},Ar=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))})})},Nn),Gr=M.createContext(void 0),bt=t=>{const e=M.useContext(Gr);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ms=({client:t,children:e})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),mt.jsx(Gr.Provider,{value:t,children:e})),Yr=M.createContext(!1),Ns=()=>M.useContext(Yr);Yr.Provider;function Ls(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Qs=M.createContext(Ls()),$s=()=>M.useContext(Qs);function Jr(t,e){return typeof t=="function"?t(...e):!!t}function sr(){}var Ks=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Vs=t=>{M.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||Jr(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)))},Ws=(t,e)=>t.isLoading&&t.isFetching&&!e,Bs=(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,m,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=bt(),s=Ns(),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]=M.useState(()=>new e(n,u)),d=c.getOptimisticResult(u),h=!s&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(O=>{const D=h?c.subscribe(K.batchCalls(O)):sr;return c.updateResult(),D},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setOptions(u,{listeners:!1})},[u,c]),Bs(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=(m=n.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||P.call(m,u,d),u.experimental_prefetchInRender&&!_e&&Ws(d,s)){const O=l?Xr(u,c,a):(v=n.getQueryCache().get(u.queryHash))==null?void 0:v.promise;O==null||O.catch(sr).finally(()=>{c.updateResult()})}return u.notifyOnChangeProps?d:c.trackResult(d)}function Zr(t,e){return Gs(t,ks)}function ir(t,e){const r=bt(),[n]=M.useState(()=>new Us(r,t));M.useEffect(()=>{n.setOptions(t)},[n,t]);const s=M.useSyncExternalStore(M.useCallback(u=>n.subscribe(K.batchCalls(u)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=M.useCallback((u,l)=>{n.mutate(u,l).catch(sr)},[n]);if(s.error&&Jr(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}function Be(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 Js(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 Xs(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 Be(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=>Be(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=Be(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 Be(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 vt(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 or extends Error{constructor(){super("Unable to transform response from server")}}function ii(t,e){let r;try{r=si(t,e)}catch{throw new or}if(!r.ok&&(!vt(r.error.error)||typeof r.error.error.code!="number"))throw new or;if(r.ok&&!vt(r.result))throw new or;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 Ut(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 vt(t)&&vt(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function ui(t,e){return typeof t=="string"?t:vt(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}),Ut(this,"cause",void 0),Ut(this,"shape",void 0),Ut(this,"data",void 0),Ut(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 ar(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(Xs())}async requestAsPromise(e){try{const r=this.$request(e);return(await Js(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){ar(this,"links",void 0),ar(this,"runtime",void 0),ar(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 m=c[c.length-1];if(p.aborted){(h=p.reject)==null||h.call(p,new Error("Aborted")),d++;continue}if(t.validate(m.concat(p).map(v=>v.key))){m.push(p),d++;continue}if(m.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(m,P)=>{var O,D;const v=d.items[P];try{const F=await Promise.resolve(m);(O=v.resolve)==null||O.call(v,F)}catch(F){(D=v.reject)==null||D.call(v,F)}v.batch=null,v.reject=null,v.resolve=null}));for(const m of d.items)(p=m.reject)==null||p.call(m,new Error("Missing result")),m.batch=null}).catch(f=>{var p;for(const m of d.items)(p=m.reject)==null||p.call(m,f),m.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})=>Be(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 m=ii(p.json,e.transformer.output);if(!m.ok){c.error(ge.from(m.error,{meta:p.meta}));return}c.next({context:p.meta,result:m.result}),c.complete()}).catch(p=>{c.error(ge.from(p,{meta:f==null?void 0:f.meta}))}),()=>{}})}}function Fi(t){return typeof FormData>"u"?!1:t instanceof FormData}const ur={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 xi(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]=ur.ansi.regular[r],[f,p]=ur.ansi.bold[r];l.push(e==="up"?d:h,e==="up"?">>":"<<",r,e==="up"?f:p,`#${a}`,s,"\x1B[0m")}else{const[d,h]=ur.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=Fi(s)?Object.fromEntries(s):s,{parts:u,args:l}=xi({...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 Di(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})=>Be(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 _i=(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 ki(t){const e=await _i(t.url);if(!t.connectionParams)return e;const n=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+n}function ke(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ji(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 Mt{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=++Mt.connectCount;const e=ki(this.urlOptions).then(r=>new this.WebSocketPonyfill(r));this.openPromise=e.then(ji),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(ke(this,"id",++Mt.connectCount),ke(this,"WebSocketPonyfill",void 0),ke(this,"urlOptions",void 0),ke(this,"keepAliveOpts",void 0),ke(this,"wsObservable",ei(null)),ke(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}}ke(Mt,"connectCount",0);class Ui{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 Ui}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 Mi 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 Ni(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=Ni(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 Nt(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,wt=t=>typeof t!="object"||t===null||t===Object.prototype?!1:Object.getPrototypeOf(t)===null?!0:Object.getPrototypeOf(t)===Object.prototype,cr=t=>wt(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",Wi=t=>t instanceof RegExp,Et=t=>t instanceof Map,Ot=t=>t instanceof Set,yn=t=>$i(t)==="Symbol",Bi=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,"\\."),lr=t=>t.map(String).map(mn).join("."),Pt=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(Bi,"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(Wi,"regexp",t=>""+t,t=>{const e=t.slice(1,t.lastIndexOf("/")),r=t.slice(t.lastIndexOf("/")+1);return new RegExp(e,r)}),ue(Ot,"set",t=>[...t.values()],t=>new Set(t)),ue(Et,"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 Lt(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const bn=Lt((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=Lt(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=Lt(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=Lt((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(Nt(t,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Nt(t,"prototype"))throw new Error("prototype is not allowed as a property");if(Nt(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(Ot(t))t=Ye(t,+n);else if(Et(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},fr=(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(wt(n))n=n[u];else if(Ot(n)){const l=+u;n=Ye(n,l)}else if(Et(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]):wt(n)&&(n[s]=r(n[s])),Ot(n)){const a=Ye(n,+s),u=r(a);a!==u&&(n.delete(a),n.add(u))}if(Et(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 hr(t,e,r=[]){if(!t)return;if(!be(t)){Ge(t,(a,u)=>hr(a,e,[...r,...Pt(u)]));return}const[n,s]=t;s&&Ge(s,(a,u)=>{hr(a,e,[...r,...Pt(u)])}),e(n,r)}function io(t,e,r){return hr(e,(n,s)=>{t=fr(t,s,a=>no(a,n,r))}),t}function oo(t,e){function r(n,s){const a=so(t,Pt(s));n.map(Pt).forEach(u=>{t=fr(t,u,()=>a)})}if(be(e)){const[n,s]=e;n.forEach(a=>{t=fr(t,Pt(a),()=>t)}),s&&Ge(s,r)}else Ge(e,r);return t}const ao=(t,e)=>wt(t)||be(t)||Et(t)||Ot(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(lr):r[lr(a)]=u.map(lr)}),n?cr(r)?[n]:[n,r]:cr(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 m=u.get(t);if(m)return n?{transformedValue:null}:m}if(!ao(t,r)){const m=Pn(t,r),P=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:t};return l||u.set(t,P),P}if(Nt(a,t))return{transformedValue:null};const c=Pn(t,r),d=(c==null?void 0:c.value)??t,h=be(d)?[]:{},f={};Ge(d,(m,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(m,e,r,n,[...s,P],[...a,t],u);h[P]=v.transformedValue,be(v.annotations)?f[P]=v.annotations:wt(v.annotations)&&Ge(v.annotations,(O,D)=>{f[mn(P)+"."+D]=O})});const p=cr(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 Fn(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 dr(t,e={}){if(Fn(t))return t.map(s=>dr(s,e));if(!lo(t))return t;const r=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return[...r,...n].reduce((s,a)=>{if(Fn(e.props)&&!e.props.includes(a))return s;const u=t[a],l=dr(u,e);return fo(s,a,l,t,e.nonenumerable),s},{})}class C{constructor({dedupe:e=!1}={}){this.classRegistry=new Mi,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=dr(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 xn=_.createContext(null);function ho(t,e){const r=yi({links:[Di({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,u=null)=>{const l=a.filter(f=>f.name.toLowerCase().endsWith(".pdf"));if(l.length===0)return{filesToCreate:[]};const c=await r.fileRouter.getFilesByProject.query({projectId:s}),d=l.filter(f=>u===null?!c.some(p=>p.path===f.blobUrl):!c.some(p=>p.path===f.blobUrl&&p.parentId===u));return d.length===0?{filesToCreate:[]}:{filesToCreate:d.map(f=>({projectId:s,mimeType:Dt.PDF,path:f.blobUrl,name:f.name,size:0,metadata:null,isArtifact:!1,summary:null,chunkingStatus:Wt.NOT_CHUNKED,isDirectory:!1,parentId:u}))}};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,parentId:c.parentId,isDirectory:c.isDirectory}))},getFilesForProject:async s=>(await r.fileRouter.getFilesByProject.query({projectId:s})).map(u=>({blobUrl:u.path,name:u.name,id:u.id,parentId:u.parentId,isDirectory:u.isDirectory})),addDirectoryWithFilesToProject:async(s,a,u,l)=>{if((await r.fileRouter.getFilesByProject.query({projectId:s})).some(m=>m.name===a&&m.isDirectory===!0&&m.parentId===null))return console.warn(`A directory named "${a}" already exists at the root level. Skipping creation.`),{directory:null,files:[]};const h=await r.fileRouter.createFile.mutate({file:{projectId:s,mimeType:Dt.DIRECTORY,path:"",name:a,size:0,metadata:u,isArtifact:!1,isDirectory:!0,parentId:null,summary:null,chunkingStatus:Wt.NOT_CHUNKED}});if(l.length===0)return{directory:{blobUrl:h.path,name:h.name,id:h.id,parentId:h.parentId,isDirectory:h.isDirectory},files:[]};const{filesToCreate:f}=await n(s,l,h.id);if(f.length===0)return{directory:{blobUrl:h.path,name:h.name,id:h.id,parentId:h.parentId,isDirectory:h.isDirectory},files:[]};const p=await r.fileRouter.createFiles.mutate({files:f});return{directory:h?{blobUrl:h.path,name:h.name,id:h.id,parentId:h.parentId,isDirectory:h.isDirectory}:null,files:p.map(m=>({blobUrl:m.path,name:m.name,id:m.id,parentId:m.parentId,isDirectory:m.isDirectory}))}}}}function yo({children:t,host:e="http://localhost",port:r=5174,token:n}){const[s,a]=_.useState(null),u=_.useMemo(()=>new Is({defaultOptions:{queries:{staleTime:30*1e3,refetchOnWindowFocus:!1}}}),[]);return _.useEffect(()=>{const l=`${e}:${r}`,c=ho(l,n);a(c)},[e,r,n]),mt.jsx(Ms,{client:u,children:mt.jsx(xn.Provider,{value:{host:e,port:r,client:s,token:n},children:t})})}function Xe(){const t=_.useContext(xn);if(!t)throw new Error("useFolioContext must be used within a FolioProvider");return t}const{useEffect:po,useRef:mo,useState:go}=M;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}=Xe(),d=mo(null),[h,f]=go();return po(()=>{(()=>{const P=`${`${u}:${l}`}?jwt=${encodeURIComponent(c)}`;f(P)})()},[u,l,c]),h?mt.jsx("div",{className:`folio-embed-container ${s}`,style:{width:t,height:e,overflow:"hidden",...n},children:mt.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}=Xe(),e=Zr({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}=Xe(),r=Zr({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}=Xe(),e=bt(),r=ir({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}=Xe(),r=bt(),n=ir({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}}function Po(t){const{client:e}=Xe(),r=bt(),n=ir({mutationFn:async({directoryName:s,directoryMetadata:a,files:u})=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");return e.addDirectoryWithFilesToProject(t,s,a,u)},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addDirectoryWithFiles:n.mutate,addDirectoryWithFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,result:n.data}}x.FolioEmbed=bo,x.FolioProvider=yo,x.useAddFolioDirectoryWithFiles=Po,x.useAddFolioFiles=Oo,x.useAddFolioProject=Eo,x.useFolioFiles=wo,x.useFolioProjects=vo,Object.defineProperty(x,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=Fi(s)?Object.fromEntries(s):s,{parts:u,args:l}=xi({...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 Di(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})=>Be(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 _i=(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 ki(t){const e=await _i(t.url);if(!t.connectionParams)return e;const n=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+n}function ke(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ji(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 Mt{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=++Mt.connectCount;const e=ki(this.urlOptions).then(r=>new this.WebSocketPonyfill(r));this.openPromise=e.then(ji),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(ke(this,"id",++Mt.connectCount),ke(this,"WebSocketPonyfill",void 0),ke(this,"urlOptions",void 0),ke(this,"keepAliveOpts",void 0),ke(this,"wsObservable",ei(null)),ke(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}}ke(Mt,"connectCount",0);class Ui{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 Ui}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 Mi 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 Ni(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=Ni(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 Nt(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,wt=t=>typeof t!="object"||t===null||t===Object.prototype?!1:Object.getPrototypeOf(t)===null?!0:Object.getPrototypeOf(t)===Object.prototype,cr=t=>wt(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",Wi=t=>t instanceof RegExp,Et=t=>t instanceof Map,Ot=t=>t instanceof Set,yn=t=>$i(t)==="Symbol",Bi=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),Ji=t=>typeof t=="bigint",Xi=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,"\\."),lr=t=>t.map(String).map(mn).join("."),Pt=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(Ji,"bigint",t=>t.toString(),t=>typeof BigInt<"u"?BigInt(t):(console.error("Please add a BigInt polyfill."),t)),ue(Bi,"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(Wi,"regexp",t=>""+t,t=>{const e=t.slice(1,t.lastIndexOf("/")),r=t.slice(t.lastIndexOf("/")+1);return new RegExp(e,r)}),ue(Ot,"set",t=>[...t.values()],t=>new Set(t)),ue(Et,"map",t=>[...t.entries()],t=>new Map(t)),ue(t=>pn(t)||Xi(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 Lt(t,e,r,n){return{isApplicable:t,annotation:e,transform:r,untransform:n}}const bn=Lt((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=Lt(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=Lt(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=Lt((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(Nt(t,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Nt(t,"prototype"))throw new Error("prototype is not allowed as a property");if(Nt(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(Ot(t))t=Ye(t,+n);else if(Et(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},fr=(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(wt(n))n=n[u];else if(Ot(n)){const l=+u;n=Ye(n,l)}else if(Et(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]):wt(n)&&(n[s]=r(n[s])),Ot(n)){const a=Ye(n,+s),u=r(a);a!==u&&(n.delete(a),n.add(u))}if(Et(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 hr(t,e,r=[]){if(!t)return;if(!be(t)){Ge(t,(a,u)=>hr(a,e,[...r,...Pt(u)]));return}const[n,s]=t;s&&Ge(s,(a,u)=>{hr(a,e,[...r,...Pt(u)])}),e(n,r)}function io(t,e,r){return hr(e,(n,s)=>{t=fr(t,s,a=>no(a,n,r))}),t}function oo(t,e){function r(n,s){const a=so(t,Pt(s));n.map(Pt).forEach(u=>{t=fr(t,u,()=>a)})}if(be(e)){const[n,s]=e;n.forEach(a=>{t=fr(t,Pt(a),()=>t)}),s&&Ge(s,r)}else Ge(e,r);return t}const ao=(t,e)=>wt(t)||be(t)||Et(t)||Ot(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(lr):r[lr(a)]=u.map(lr)}),n?cr(r)?[n]:[n,r]:cr(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 m=u.get(t);if(m)return n?{transformedValue:null}:m}if(!ao(t,r)){const m=Pn(t,r),P=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:t};return l||u.set(t,P),P}if(Nt(a,t))return{transformedValue:null};const c=Pn(t,r),d=(c==null?void 0:c.value)??t,h=be(d)?[]:{},f={};Ge(d,(m,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(m,e,r,n,[...s,P],[...a,t],u);h[P]=v.transformedValue,be(v.annotations)?f[P]=v.annotations:wt(v.annotations)&&Ge(v.annotations,(O,D)=>{f[mn(P)+"."+D]=O})});const p=cr(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 Fn(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 dr(t,e={}){if(Fn(t))return t.map(s=>dr(s,e));if(!lo(t))return t;const r=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return[...r,...n].reduce((s,a)=>{if(Fn(e.props)&&!e.props.includes(a))return s;const u=t[a],l=dr(u,e);return fo(s,a,l,t,e.nonenumerable),s},{})}class C{constructor({dedupe:e=!1}={}){this.classRegistry=new Mi,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=dr(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 xn=_.createContext(null);function ho(t,e){const r=yi({links:[Di({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,u=null)=>{const l=a.filter(f=>f.name.toLowerCase().endsWith(".pdf"));if(l.length===0)return{filesToCreate:[]};const c=await r.fileRouter.getFilesByProject.query({projectId:s}),d=l.filter(f=>u===null?!c.some(p=>p.path===f.blobUrl):!c.some(p=>p.path===f.blobUrl&&p.parentId===u));return d.length===0?{filesToCreate:[]}:{filesToCreate:d.map(f=>({projectId:s,mimeType:Dt.PDF,path:f.blobUrl,name:f.name,size:0,metadata:null,isArtifact:!1,summary:null,chunkingStatus:Wt.NOT_CHUNKED,isDirectory:!1,parentId:u}))}};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,parentId:c.parentId,isDirectory:c.isDirectory}))},getFilesForProject:async s=>(await r.fileRouter.getFilesByProject.query({projectId:s})).map(u=>({blobUrl:u.path,name:u.name,id:u.id,parentId:u.parentId,isDirectory:u.isDirectory})),addDirectoryWithFilesToProject:async(s,a,u,l)=>{if((await r.fileRouter.getFilesByProject.query({projectId:s})).some(m=>m.name===a&&m.isDirectory===!0&&m.parentId===null))return console.warn(`A directory named "${a}" already exists at the root level. Skipping creation.`),{directory:null,files:[]};const h=await r.fileRouter.createFile.mutate({file:{projectId:s,mimeType:Dt.DIRECTORY,path:"",name:a,size:0,metadata:u,isArtifact:!1,isDirectory:!0,parentId:null,summary:null,chunkingStatus:Wt.NOT_CHUNKED}});if(l.length===0)return{directory:{blobUrl:h.path,name:h.name,id:h.id,parentId:h.parentId,isDirectory:h.isDirectory},files:[]};const{filesToCreate:f}=await n(s,l,h.id);if(f.length===0)return{directory:{blobUrl:h.path,name:h.name,id:h.id,parentId:h.parentId,isDirectory:h.isDirectory},files:[]};const p=await r.fileRouter.createFiles.mutate({files:f});return{directory:h?{blobUrl:h.path,name:h.name,id:h.id,parentId:h.parentId,isDirectory:h.isDirectory}:null,files:p.map(m=>({blobUrl:m.path,name:m.name,id:m.id,parentId:m.parentId,isDirectory:m.isDirectory}))}}}}function yo({children:t,host:e="http://localhost",port:r=5174,token:n}){const[s,a]=_.useState(null),u=_.useMemo(()=>new Is({defaultOptions:{queries:{staleTime:30*1e3,refetchOnWindowFocus:!1}}}),[]);return _.useEffect(()=>{const l=`${e}:${r}`,c=ho(l,n);a(c)},[e,r,n]),mt.jsx(Ms,{client:u,children:mt.jsx(xn.Provider,{value:{host:e,port:r,client:s,token:n},children:t})})}function Je(){const t=_.useContext(xn);if(!t)throw new Error("useFolioContext must be used within a FolioProvider");return t}const{useEffect:po,useRef:mo,useState:go}=M;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}=Je(),d=mo(null),[h,f]=go();return po(()=>{(()=>{const P=`${`${u}:${l}`}?jwt=${encodeURIComponent(c)}`;f(P)})()},[u,l,c]),h?mt.jsx("div",{className:`folio-embed-container ${s}`,style:{width:t,height:e,overflow:"hidden",...n},children:mt.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}=Je(),e=Zr({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}=Je(),r=Zr({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}=Je(),e=bt(),r=ir({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}=Je(),r=bt(),n=ir({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}}function Po(t){const{client:e}=Je(),r=bt(),n=ir({mutationFn:async s=>{if(!e)throw new Error("Folio client not initialized");if(!t)throw new Error("Project ID is required");const a=Array.isArray(s)?s:[s],u=[];for(const l of a){const c=JSON.stringify(Object.fromEntries(l.directoryMetadata)),d=await e.addDirectoryWithFilesToProject(t,l.directoryName,c,l.files);u.push(d)}return Array.isArray(s)?u:u[0]},onSuccess:()=>{r.invalidateQueries({queryKey:["folioFiles",t]})}});return{addDirectoryWithFiles:n.mutate,addDirectoryWithFilesAsync:n.mutateAsync,isAdding:n.isPending,isError:n.isError,error:n.error,result:n.data}}x.FolioEmbed=bo,x.FolioProvider=yo,x.useAddFolioDirectoryWithFiles=Po,x.useAddFolioFiles=Oo,x.useAddFolioProject=Eo,x.useFolioFiles=wo,x.useFolioProjects=vo,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -6,6 +6,15 @@ import { RefetchOptions } from '@tanstack/react-query';
|
|
|
6
6
|
import { UseMutateAsyncFunction } from '@tanstack/react-query';
|
|
7
7
|
import { UseMutateFunction } from '@tanstack/react-query';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Type for directory entries with metadata and files
|
|
11
|
+
*/
|
|
12
|
+
export declare type DirectoryEntry = {
|
|
13
|
+
directoryName: string;
|
|
14
|
+
directoryMetadata: Map<string, string>;
|
|
15
|
+
files: Omit<FolioFile, "id" | "parentId" | "isDirectory">[];
|
|
16
|
+
};
|
|
17
|
+
|
|
9
18
|
export declare function FolioEmbed({ width, height, allow, style, className, iframeProps, }: FolioEmbedProps): JSX_2.Element | null;
|
|
10
19
|
|
|
11
20
|
export declare interface FolioEmbedProps {
|
|
@@ -83,9 +92,9 @@ export declare interface FolioProviderProps {
|
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
/**
|
|
86
|
-
* Hook for adding
|
|
87
|
-
* @param projectId The ID of the project to add the
|
|
88
|
-
* @returns Functions and state for adding
|
|
95
|
+
* Hook for adding one or more directories with files to a project
|
|
96
|
+
* @param projectId The ID of the project to add the directories and files to
|
|
97
|
+
* @returns Functions and state for adding directories with files
|
|
89
98
|
*
|
|
90
99
|
* @remarks
|
|
91
100
|
* - Directory names must be unique at the root level. If a directory with the same name
|
|
@@ -93,31 +102,35 @@ export declare interface FolioProviderProps {
|
|
|
93
102
|
* - Files are checked for duplicates based on their path and parent directory.
|
|
94
103
|
* Files with the same path but in different directories are considered unique.
|
|
95
104
|
* - Only PDF files are accepted and will be filtered automatically.
|
|
105
|
+
* - Metadata is provided as a Map<string, string> and will be automatically
|
|
106
|
+
* converted to a JSON string before sending to the API.
|
|
107
|
+
* - Can add a single directory or multiple directories in one call.
|
|
96
108
|
*/
|
|
97
109
|
export declare function useAddFolioDirectoryWithFiles(projectId?: number): {
|
|
98
110
|
addDirectoryWithFiles: UseMutateFunction< {
|
|
99
111
|
directory: FolioFile | null;
|
|
100
112
|
files: FolioFile[];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}, unknown>;
|
|
113
|
+
} | {
|
|
114
|
+
directory: FolioFile | null;
|
|
115
|
+
files: FolioFile[];
|
|
116
|
+
}[], Error, DirectoryEntry | DirectoryEntry[], unknown>;
|
|
106
117
|
addDirectoryWithFilesAsync: UseMutateAsyncFunction< {
|
|
107
118
|
directory: FolioFile | null;
|
|
108
119
|
files: FolioFile[];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}, unknown>;
|
|
120
|
+
} | {
|
|
121
|
+
directory: FolioFile | null;
|
|
122
|
+
files: FolioFile[];
|
|
123
|
+
}[], Error, DirectoryEntry | DirectoryEntry[], unknown>;
|
|
114
124
|
isAdding: boolean;
|
|
115
125
|
isError: boolean;
|
|
116
126
|
error: Error | null;
|
|
117
127
|
result: {
|
|
118
128
|
directory: FolioFile | null;
|
|
119
129
|
files: FolioFile[];
|
|
120
|
-
} |
|
|
130
|
+
} | {
|
|
131
|
+
directory: FolioFile | null;
|
|
132
|
+
files: FolioFile[];
|
|
133
|
+
}[] | undefined;
|
|
121
134
|
};
|
|
122
135
|
|
|
123
136
|
/**
|