@hostlink/light 3.3.0 → 3.4.0

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/dist/light.js CHANGED
@@ -1,131 +1,131 @@
1
- import { jsonToGraphQLQuery as q, VariableType as b } from "json-to-graphql-query";
2
- import P from "collect.js";
3
- import H from "axios";
4
- function U(t) {
1
+ import { jsonToGraphQLQuery as I, VariableType as S } from "json-to-graphql-query";
2
+ import Q from "collect.js";
3
+ import gt from "axios";
4
+ function $(t) {
5
5
  if (t === null || typeof t != "object")
6
6
  return !1;
7
7
  const e = Object.getPrototypeOf(t);
8
8
  return e !== null && e !== Object.prototype && Object.getPrototypeOf(e) !== null || Symbol.iterator in t ? !1 : Symbol.toStringTag in t ? Object.prototype.toString.call(t) === "[object Module]" : !0;
9
9
  }
10
- function E(t, e, r = ".", s) {
11
- if (!U(e))
12
- return E(t, {}, r, s);
13
- const o = Object.assign({}, e);
14
- for (const u in t) {
15
- if (u === "__proto__" || u === "constructor")
10
+ function W(t, e, r = ".", s) {
11
+ if (!$(e))
12
+ return W(t, {}, r, s);
13
+ const n = Object.assign({}, e);
14
+ for (const c in t) {
15
+ if (c === "__proto__" || c === "constructor")
16
16
  continue;
17
- const c = t[u];
18
- c != null && (s && s(o, u, c, r) || (Array.isArray(c) && Array.isArray(o[u]) ? o[u] = [...c, ...o[u]] : U(c) && U(o[u]) ? o[u] = E(
19
- c,
20
- o[u],
21
- (r ? `${r}.` : "") + u.toString(),
17
+ const l = t[c];
18
+ l != null && (s && s(n, c, l, r) || (Array.isArray(l) && Array.isArray(n[c]) ? n[c] = [...l, ...n[c]] : $(l) && $(n[c]) ? n[c] = W(
19
+ l,
20
+ n[c],
21
+ (r ? `${r}.` : "") + c.toString(),
22
22
  s
23
- ) : o[u] = c));
23
+ ) : n[c] = l));
24
24
  }
25
- return o;
25
+ return n;
26
26
  }
27
- function X(t) {
27
+ function dt(t) {
28
28
  return (...e) => (
29
29
  // eslint-disable-next-line unicorn/no-array-reduce
30
- e.reduce((r, s) => E(r, s, "", t), {})
30
+ e.reduce((r, s) => W(r, s, "", t), {})
31
31
  );
32
32
  }
33
- const A = X();
34
- let S = null;
35
- const Y = (t) => {
36
- S = t;
37
- }, M = () => {
38
- if (!S)
33
+ const j = dt();
34
+ let q = null;
35
+ const _t = (t) => {
36
+ q = t;
37
+ }, K = () => {
38
+ if (!q)
39
39
  throw new Error("Api client not initialized. Call setApiClient() first.");
40
- return S;
41
- }, xt = () => S;
42
- function D(t) {
40
+ return q;
41
+ }, ce = () => q;
42
+ function N(t) {
43
43
  for (let e = 0; e < t.length; e++)
44
44
  if (t[e] instanceof File)
45
45
  return !0;
46
46
  return !1;
47
47
  }
48
- function N(t) {
48
+ function x(t) {
49
49
  for (let e in t)
50
- if (t[e] instanceof File || t[e] instanceof Array && D(t[e]))
50
+ if (t[e] instanceof File || t[e] instanceof Array && N(t[e]))
51
51
  return !0;
52
52
  return !1;
53
53
  }
54
- function Z(t) {
54
+ function yt(t) {
55
55
  t = "<~" + t + "~>";
56
- var e, r, s, o, u, c = String, p = 255;
57
- for (t.slice(0, 2) === "<~" && t.slice(-2), t = t.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), e = "uuuuu".slice(t.length % 5 || 5), t += e, s = [], o = 0, u = t.length; u > o; o += 5) r = 52200625 * (t.charCodeAt(o) - 33) + 614125 * (t.charCodeAt(o + 1) - 33) + 7225 * (t.charCodeAt(o + 2) - 33) + 85 * (t.charCodeAt(o + 3) - 33) + (t.charCodeAt(o + 4) - 33), s.push(p & r >> 24, p & r >> 16, p & r >> 8, p & r);
58
- return (function(n, i) {
59
- for (var a = i; a > 0; a--) n.pop();
60
- })(s, e.length), c.fromCharCode.apply(c, s);
56
+ var e, r, s, n, c, l = String, f = 255;
57
+ for (t.slice(0, 2) === "<~" && t.slice(-2), t = t.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), e = "uuuuu".slice(t.length % 5 || 5), t += e, s = [], n = 0, c = t.length; c > n; n += 5) r = 52200625 * (t.charCodeAt(n) - 33) + 614125 * (t.charCodeAt(n + 1) - 33) + 7225 * (t.charCodeAt(n + 2) - 33) + 85 * (t.charCodeAt(n + 3) - 33) + (t.charCodeAt(n + 4) - 33), s.push(f & r >> 24, f & r >> 16, f & r >> 8, f & r);
58
+ return (function(p, o) {
59
+ for (var i = o; i > 0; i--) p.pop();
60
+ })(s, e.length), l.fromCharCode.apply(l, s);
61
61
  }
62
- const B = (t = "") => {
62
+ const tt = (t = "") => {
63
63
  const e = t, r = (s = "application/octet-stream") => {
64
- const o = new Uint8Array(e.length);
65
- for (let p = 0; p < e.length; p++)
66
- o[p] = e.charCodeAt(p);
67
- const u = new Blob([o], { type: s });
68
- return URL.createObjectURL(u);
64
+ const n = new Uint8Array(e.length);
65
+ for (let f = 0; f < e.length; f++)
66
+ n[f] = e.charCodeAt(f);
67
+ const c = new Blob([n], { type: s });
68
+ return URL.createObjectURL(c);
69
69
  };
70
70
  return {
71
71
  getContent: () => e,
72
72
  getURL: r,
73
73
  download: (s) => {
74
- const o = document.createElement("a");
75
- o.download = s, o.href = r(), document.body.appendChild(o), o.click(), document.body.removeChild(o);
74
+ const n = document.createElement("a");
75
+ n.download = s, n.href = r(), document.body.appendChild(n), n.click(), document.body.removeChild(n);
76
76
  },
77
77
  open: (s) => {
78
78
  window.open(r(s), "_blank");
79
79
  }
80
80
  };
81
- }, te = (t) => B(atob(t)), ee = (t) => B(Z(t));
82
- function T(t, e, r, s, o) {
81
+ }, ue = (t) => tt(atob(t)), he = (t) => tt(yt(t));
82
+ function et(t, e, r, s, n) {
83
83
  if (!(!t || typeof t != "object"))
84
- for (let u in t) {
85
- const c = t[u];
86
- if (c && typeof c == "object") {
87
- if ("__args" in c) {
88
- const p = c.__args, n = {};
89
- Object.entries(p).forEach(([i, a]) => {
90
- if (a instanceof Array && D(a)) {
91
- n[i] = new b(i);
92
- let l = 0;
93
- a.forEach((h) => {
94
- h instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + i + "." + l), s.append(o.current.toString(), h), o.current++, l++);
95
- }), e[i] = "[Upload!]!";
96
- } else a instanceof File ? (n[i] = new b(i), r[o.current] = ["variables." + i], s.append(o.current.toString(), a), e[i] = "Upload!", o.current++) : a instanceof Object && N(a) ? (n[i] = {}, Object.entries(a).forEach(([l, h]) => {
97
- if (h instanceof Array && D(h)) {
98
- n[i][l] = new b(l);
99
- let d = 0;
100
- h.forEach((_) => {
101
- _ instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + l + "." + d), s.append(o.current.toString(), _), o.current++, d++);
102
- }), e[l] = "[Upload!]!";
103
- } else h instanceof File ? (n[i][l] = new b(l), r[o.current] = ["variables." + l], s.append(o.current.toString(), h), e[l] = "Upload!", o.current++) : n[i][l] = h;
104
- })) : a != null && (n[i] = a);
105
- }), c.__args = n;
84
+ for (let c in t) {
85
+ const l = t[c];
86
+ if (l && typeof l == "object") {
87
+ if ("__args" in l) {
88
+ const f = l.__args, p = {};
89
+ Object.entries(f).forEach(([o, i]) => {
90
+ if (i instanceof Array && N(i)) {
91
+ p[o] = new S(o);
92
+ let a = 0;
93
+ i.forEach((u) => {
94
+ u instanceof File && (r[n.current] || (r[n.current] = []), r[n.current].push("variables." + o + "." + a), s.append(n.current.toString(), u), n.current++, a++);
95
+ }), e[o] = "[Upload!]!";
96
+ } else i instanceof File ? (p[o] = new S(o), r[n.current] = ["variables." + o], s.append(n.current.toString(), i), e[o] = "Upload!", n.current++) : i instanceof Object && x(i) ? (p[o] = {}, Object.entries(i).forEach(([a, u]) => {
97
+ if (u instanceof Array && N(u)) {
98
+ p[o][a] = new S(a);
99
+ let m = 0;
100
+ u.forEach((d) => {
101
+ d instanceof File && (r[n.current] || (r[n.current] = []), r[n.current].push("variables." + a + "." + m), s.append(n.current.toString(), d), n.current++, m++);
102
+ }), e[a] = "[Upload!]!";
103
+ } else u instanceof File ? (p[o][a] = new S(a), r[n.current] = ["variables." + a], s.append(n.current.toString(), u), e[a] = "Upload!", n.current++) : p[o][a] = u;
104
+ })) : i != null && (p[o] = i);
105
+ }), l.__args = p;
106
106
  }
107
- T(c, e, r, s, o);
107
+ et(l, e, r, s, n);
108
108
  }
109
109
  }
110
110
  }
111
- const y = async (t) => {
112
- const { axios: e } = M(), r = t, s = new FormData();
113
- let o = !1;
114
- const u = {}, c = {};
115
- T(r, u, c, s, { current: 0 }), o = Object.keys(u).length > 0, o && (r.__variables = u);
116
- let n = null;
117
- const a = q({ query: r });
118
- if (o ? (s.append("map", JSON.stringify(c)), s.append("operations", JSON.stringify({
119
- query: a
120
- })), n = await e.post("", s)) : n = await e.post("", {
121
- query: a
122
- }), n.data.errors)
123
- throw new Error(n.data.errors[0].message);
124
- return n.data.data;
125
- };
126
- function j(t, e) {
127
- let r, s = [], o, u;
128
- const c = (n) => !n || typeof n != "object" ? !1 : Object.values(n).some((i) => i && typeof i == "object" && Object.keys(i).some((a) => a.startsWith("_"))), p = () => s.length === 0 ? (s.unshift({}), s[0]) : (c(s[0]) && s.unshift({}), s[0]);
111
+ const rt = (t) => async (e) => {
112
+ const r = e, s = new FormData();
113
+ let n = !1;
114
+ const c = {}, l = {};
115
+ et(r, c, l, s, { current: 0 }), n = Object.keys(c).length > 0, n && (r.__variables = c);
116
+ let p = null;
117
+ const i = I({ query: r });
118
+ if (n ? (s.append("map", JSON.stringify(l)), s.append("operations", JSON.stringify({
119
+ query: i
120
+ })), p = await t.post("", s)) : p = await t.post("", {
121
+ query: i
122
+ }), p.data.errors)
123
+ throw new Error(p.data.errors[0].message);
124
+ return p.data.data;
125
+ }, F = async (t) => rt(K().axios)(t);
126
+ function L(t, e, r = F) {
127
+ let s, n = [], c, l;
128
+ const f = (o) => !o || typeof o != "object" ? !1 : Object.values(o).some((i) => i && typeof i == "object" && Object.keys(i).some((a) => a.startsWith("_"))), p = () => n.length === 0 ? (n.unshift({}), n[0]) : (f(n[0]) && n.unshift({}), n[0]);
129
129
  return {
130
130
  first() {
131
131
  return this.fetchFirst();
@@ -138,40 +138,40 @@ function j(t, e) {
138
138
  return Array.isArray(i) && i.length > 0 ? i[0] : null;
139
139
  },
140
140
  async fetchWithMeta() {
141
- let i = await y(this.toQuery(!0));
142
- if (u) {
143
- const a = u.split(".");
144
- for (const l of a)
145
- i = i[l];
141
+ let i = await r(this.toQuery(!0));
142
+ if (l) {
143
+ const a = l.split(".");
144
+ for (const u of a)
145
+ i = i[u];
146
146
  return i;
147
147
  }
148
148
  return i[`list${t}`];
149
149
  },
150
150
  async fetch() {
151
- let i = await y(this.toQuery());
152
- if (u) {
153
- const a = u.split(".");
154
- for (const l of a)
155
- i = i[l];
151
+ let i = await r(this.toQuery());
152
+ if (l) {
153
+ const a = l.split(".");
154
+ for (const u of a)
155
+ i = i[u];
156
156
  return i.data;
157
157
  }
158
158
  return i[`list${t}`].data;
159
159
  },
160
- dataPath(n) {
161
- return n && typeof n == "string" && (u = n), this;
160
+ dataPath(o) {
161
+ return o && typeof o == "string" && (l = o), this;
162
162
  },
163
- sort(n) {
164
- return n && typeof n == "string" && (o = n), this;
163
+ sort(o) {
164
+ return o && typeof o == "string" && (c = o), this;
165
165
  },
166
- filters(n) {
167
- return n && typeof n == "object" && (s = [n]), this;
166
+ filters(o) {
167
+ return o && typeof o == "object" && (n = [o]), this;
168
168
  },
169
169
  // where can be called as:
170
170
  // where('key', value) -> exact match
171
171
  // where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
172
- where(n, i, a) {
173
- const l = (h, d, _) => {
174
- const F = {
172
+ where(o, i, a) {
173
+ const u = (m, d, b) => {
174
+ const C = {
175
175
  ">": "_gt",
176
176
  "<": "_lt",
177
177
  ">=": "_gte",
@@ -180,83 +180,83 @@ function j(t, e) {
180
180
  in: "_in",
181
181
  contains: "_contains"
182
182
  }[d];
183
- F && s.push({ [h]: { [F]: _ } });
183
+ C && n.push({ [m]: { [C]: b } });
184
184
  };
185
185
  if (a !== void 0)
186
- l(n, String(i), a);
186
+ u(o, String(i), a);
187
187
  else {
188
- const h = p(), d = A(h, { [n]: i });
189
- s[0] = d;
188
+ const m = p(), d = j(m, { [o]: i });
189
+ n[0] = d;
190
190
  }
191
191
  return this;
192
192
  },
193
193
  // whereContains adds a _contains filter for a specific field
194
194
  // If the same field is used multiple times, it merges them into an array
195
- whereContains(n, i) {
196
- if (n && typeof n == "string") {
197
- const a = p(), l = { _contains: i };
198
- a[n] ? Array.isArray(a[n]) ? a[n].push(l) : a[n] = [a[n], l] : a[n] = [l], s[0] = a;
195
+ whereContains(o, i) {
196
+ if (o && typeof o == "string") {
197
+ const a = p(), u = { _contains: i };
198
+ a[o] ? Array.isArray(a[o]) ? a[o].push(u) : a[o] = [a[o], u] : a[o] = [u], n[0] = a;
199
199
  }
200
200
  return this;
201
201
  },
202
202
  // ...existing code...
203
203
  // whereIn adds an _in filter for a specific field
204
204
  // If the same field is used multiple times, it merges them into an array
205
- whereIn(n, i) {
206
- if (n && typeof n == "string" && Array.isArray(i)) {
207
- const a = p(), l = { _in: i };
208
- a[n] ? Array.isArray(a[n]) ? a[n].push(l) : a[n] = [a[n], l] : a[n] = [l], s[0] = a;
205
+ whereIn(o, i) {
206
+ if (o && typeof o == "string" && Array.isArray(i)) {
207
+ const a = p(), u = { _in: i };
208
+ a[o] ? Array.isArray(a[o]) ? a[o].push(u) : a[o] = [a[o], u] : a[o] = [u], n[0] = a;
209
209
  }
210
210
  return this;
211
211
  },
212
212
  // whereBetween adds a _between filter for a specific field
213
- whereBetween(n, i, a) {
214
- if (n && typeof n == "string") {
215
- const l = p(), h = { _between: [i, a] };
216
- l[n] ? Array.isArray(l[n]) ? l[n].push(h) : l[n] = [l[n], h] : l[n] = h, s[0] = l;
213
+ whereBetween(o, i, a) {
214
+ if (o && typeof o == "string") {
215
+ const u = p(), m = { _between: [i, a] };
216
+ u[o] ? Array.isArray(u[o]) ? u[o].push(m) : u[o] = [u[o], m] : u[o] = m, n[0] = u;
217
217
  }
218
218
  return this;
219
219
  },
220
220
  // limit sets paging/limit for the data selection
221
- limit(n) {
222
- return typeof n == "number" && Number.isFinite(n) && (r = A(r || {}, { limit: n })), this;
221
+ limit(o) {
222
+ return typeof o == "number" && Number.isFinite(o) && (s = j(s || {}, { limit: o })), this;
223
223
  },
224
224
  // offset sets the starting index for the data selection
225
- offset(n) {
226
- return typeof n == "number" && Number.isFinite(n) && (r = A(r || {}, { offset: n })), this;
225
+ offset(o) {
226
+ return typeof o == "number" && Number.isFinite(o) && (s = j(s || {}, { offset: o })), this;
227
227
  },
228
- toQuery(n = !1) {
228
+ toQuery(o = !1) {
229
229
  let i;
230
- const a = s.length > 0 && Object.keys(s[0] || {}).length > 0, l = a ? 1 : 0, h = s.length > l;
231
- a && h ? i = s : h ? i = s.slice(l) : a && (i = s[0]);
232
- const d = A(
233
- o ? { sort: o } : {},
230
+ const a = n.length > 0 && Object.keys(n[0] || {}).length > 0, u = a ? 1 : 0, m = n.length > u;
231
+ a && m ? i = n : m ? i = n.slice(u) : a && (i = n[0]);
232
+ const d = j(
233
+ c ? { sort: c } : {},
234
234
  i ? { filters: i } : {}
235
- ), _ = {
235
+ ), b = {
236
236
  data: {
237
237
  ...e
238
238
  }
239
239
  };
240
- if (r && (_.data.__args = r), Object.keys(d).length > 0 && (_.__args = d), n && (_.meta = {
240
+ if (s && (b.data.__args = s), Object.keys(d).length > 0 && (b.__args = d), o && (b.meta = {
241
241
  total: !0,
242
242
  key: !0,
243
243
  name: !0
244
- }), u) {
245
- const w = u.split(".");
246
- let F = _;
247
- for (let m = w.length - 1; m >= 0; m--)
248
- F = {
249
- [w[m]]: F
244
+ }), l) {
245
+ const O = l.split(".");
246
+ let C = b;
247
+ for (let P = O.length - 1; P >= 0; P--)
248
+ C = {
249
+ [O[P]]: C
250
250
  };
251
- return F;
251
+ return C;
252
252
  }
253
253
  return {
254
- [`list${t}`]: _
254
+ [`list${t}`]: b
255
255
  };
256
256
  }
257
257
  };
258
258
  }
259
- const V = "list", I = [
259
+ const wt = "list", bt = [
260
260
  "flatMap",
261
261
  "chunk",
262
262
  "shuffle",
@@ -282,7 +282,7 @@ const V = "list", I = [
282
282
  "slice",
283
283
  "tap",
284
284
  "sort"
285
- ], K = [
285
+ ], mt = [
286
286
  "avg",
287
287
  "count",
288
288
  "countBy",
@@ -310,7 +310,7 @@ const V = "list", I = [
310
310
  "implode",
311
311
  "partition"
312
312
  ];
313
- class g {
313
+ class w {
314
314
  _batchData = null;
315
315
  data_path = "";
316
316
  filters;
@@ -327,7 +327,7 @@ class g {
327
327
  this.filters = {}, this.steps = [], this.fields = e;
328
328
  }
329
329
  }
330
- g.prototype.getQueryPayload = function() {
330
+ w.prototype.getQueryPayload = function() {
331
331
  let t = {
332
332
  meta: {
333
333
  total: !0,
@@ -341,26 +341,26 @@ g.prototype.getQueryPayload = function() {
341
341
  steps: this.steps
342
342
  };
343
343
  };
344
- g.prototype.dataPath = function(t) {
344
+ w.prototype.dataPath = function(t) {
345
345
  const e = this.clone();
346
346
  return e.data_path = t, e;
347
347
  };
348
- g.prototype.buildArgs = function() {
348
+ w.prototype.buildArgs = function() {
349
349
  let t = {};
350
350
  return Object.keys(this.filters).length > 0 && (t.filters = this.filters), this._sort && (t.sort = this._sort, this._sortDesc && (t.sort += ":desc")), t;
351
351
  };
352
- g.prototype.clone = function() {
352
+ w.prototype.clone = function() {
353
353
  const t = Object.create(this);
354
354
  return t.steps = JSON.parse(JSON.stringify(this.steps)), t.filters = JSON.parse(JSON.stringify(this.filters)), t.fields = JSON.parse(JSON.stringify(this.fields)), t;
355
355
  };
356
- P().macro("whereContains", function(t, e) {
356
+ Q().macro("whereContains", function(t, e) {
357
357
  return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
358
358
  });
359
- g.prototype.fetchData = async function() {
359
+ w.prototype.fetchData = async function() {
360
360
  try {
361
361
  if (this._batchData) {
362
- const p = this._batchData;
363
- return this.meta = p.meta, P(p.data);
362
+ const f = this._batchData;
363
+ return this.meta = f.meta, Q(f.data);
364
364
  }
365
365
  let t = {
366
366
  meta: {
@@ -371,72 +371,72 @@ g.prototype.fetchData = async function() {
371
371
  };
372
372
  t.__args = this.buildArgs(), t.data = this.fields, this.already_limit && (t.data.__args = t.data.__args || {}, t.data.__args.limit = this.limit), this.already_offset && (t.data.__args = t.data.__args || {}, t.data.__args.offset = this.offset);
373
373
  const e = this.data_path.split(".");
374
- let r = {}, s = r, o = e[e.length - 1];
375
- for (const p of e) {
376
- if (p === o) {
377
- s[p] = t;
374
+ let r = {}, s = r, n = e[e.length - 1];
375
+ for (const f of e) {
376
+ if (f === n) {
377
+ s[f] = t;
378
378
  break;
379
379
  }
380
- s[p] = {}, s = s[p];
380
+ s[f] = {}, s = s[f];
381
381
  }
382
- let c = await y(r);
383
- for (const p of e)
384
- c = c[p];
385
- return this.meta = c.meta, P(c.data);
382
+ let l = await (this._queryFn || F)(r);
383
+ for (const f of e)
384
+ l = l[f];
385
+ return this.meta = l.meta, Q(l.data);
386
386
  } catch (t) {
387
387
  throw console.error("Error fetching collection data:", t), t;
388
388
  }
389
389
  };
390
- g.prototype.processData = async function() {
390
+ w.prototype.processData = async function() {
391
391
  let t = await this.fetchData();
392
392
  for (const e of this.steps)
393
393
  t = t[e.type](...e.args);
394
394
  return t;
395
395
  };
396
- g.prototype.all = async function() {
396
+ w.prototype.all = async function() {
397
397
  return (await this.processData()).all();
398
398
  };
399
- for (const t of I)
400
- g.prototype[t] = function(...e) {
399
+ for (const t of bt)
400
+ w.prototype[t] = function(...e) {
401
401
  const r = this.clone();
402
402
  return r.steps.push({ type: t, args: e }), r;
403
403
  };
404
- for (const t of K)
405
- g.prototype[t] = async function(...e) {
404
+ for (const t of mt)
405
+ w.prototype[t] = async function(...e) {
406
406
  return (await this.clone().processData())[t](...e);
407
407
  };
408
- g.prototype.average = g.prototype.avg;
409
- g.prototype.first = async function() {
408
+ w.prototype.average = w.prototype.avg;
409
+ w.prototype.first = async function() {
410
410
  return this.take(1), (await this.processData()).first();
411
411
  };
412
- g.prototype._handleBatchData = function(t, e) {
412
+ w.prototype._handleBatchData = function(t, e) {
413
413
  return this._batchData ? (this.steps.push({ type: t, args: e }), this) : null;
414
414
  };
415
- g.prototype.where = function(...t) {
415
+ w.prototype.where = function(...t) {
416
416
  const e = this._handleBatchData("where", t);
417
417
  if (e) return e;
418
418
  if (t.length === 2)
419
419
  this.filters[t[0]] = t[1];
420
420
  else if (t.length === 3) {
421
- const r = t[0], s = t[1], o = t[2];
421
+ const r = t[0], s = t[1], n = t[2];
422
422
  switch (s) {
423
423
  case "==":
424
- this.filters[r] = o;
424
+ this.filters[r] = n;
425
425
  break;
426
426
  case "<":
427
- this.filters[r] = { lt: o };
427
+ this.filters[r] = { lt: n };
428
428
  break;
429
429
  case "<=":
430
- this.filters[r] = { lte: o };
430
+ this.filters[r] = { lte: n };
431
431
  break;
432
432
  case ">":
433
- this.filters[r] = { gt: o };
433
+ this.filters[r] = { gt: n };
434
434
  break;
435
435
  case ">=":
436
- this.filters[r] = { gte: o };
436
+ this.filters[r] = { gte: n };
437
437
  break;
438
438
  case "!==":
439
- this.filters[r] = { ne: o };
439
+ this.filters[r] = { ne: n };
440
440
  break;
441
441
  default:
442
442
  throw new Error(`Unsupported operator: ${s}`);
@@ -444,192 +444,227 @@ g.prototype.where = function(...t) {
444
444
  }
445
445
  return this;
446
446
  };
447
- g.prototype.whereContains = function(t, e) {
447
+ w.prototype.whereContains = function(t, e) {
448
448
  const r = this._handleBatchData("whereContains", [t, e]);
449
449
  return r || (this.filters[t] = { contains: e }, this);
450
450
  };
451
- g.prototype.forPage = function(t, e) {
451
+ w.prototype.forPage = function(t, e) {
452
452
  return t = Math.max(1, t), this.already_limit ? (this.steps.push({ type: "forPage", args: [t, e] }), this) : (this.limit = e, this.offset = (t - 1) * e, this.already_limit = !0, this.already_offset = !0, this);
453
453
  };
454
- g.prototype.whereIn = function(t, e) {
454
+ w.prototype.whereIn = function(t, e) {
455
455
  const r = this._handleBatchData("whereIn", [t, e]);
456
456
  return r || (this.filters[t] = { in: e }, this);
457
457
  };
458
- g.prototype.whereNotIn = function(t, e) {
458
+ w.prototype.whereNotIn = function(t, e) {
459
459
  const r = this._handleBatchData("whereNotIn", [t, e]);
460
460
  return r || (this.filters[t] = { nin: e }, this);
461
461
  };
462
- g.prototype.whereNotBetween = function(t, e) {
462
+ w.prototype.whereNotBetween = function(t, e) {
463
463
  const r = this._handleBatchData("whereNotBetween", [t, e]);
464
464
  return r || (this.filters[t] = { notBetween: e }, this);
465
465
  };
466
- g.prototype.whereBetween = function(t, e) {
466
+ w.prototype.whereBetween = function(t, e) {
467
467
  const r = this._handleBatchData("whereBetween", [t, e]);
468
468
  return r || (this.filters[t] = { between: e }, this);
469
469
  };
470
- g.prototype.sortBy = function(t) {
470
+ w.prototype.sortBy = function(t) {
471
471
  return this.steps.push({ type: "sortBy", args: [t] }), typeof t == "string" && (this._sort = t), this;
472
472
  };
473
- g.prototype.sortByDesc = function(t) {
473
+ w.prototype.sortByDesc = function(t) {
474
474
  return this.steps.push({ type: "sortByDesc", args: [t] }), typeof t == "string" && (this._sort = t, this._sortDesc = !0), this;
475
475
  };
476
- g.prototype.skip = function(t) {
476
+ w.prototype.skip = function(t) {
477
477
  if (t < 0)
478
478
  throw new Error("Offset must be non-negative");
479
479
  return this.already_offset && this.steps.push({ type: "skip", args: [t] }), this.offset = t, this.already_offset = !0, this;
480
480
  };
481
- g.prototype.take = function(t) {
481
+ w.prototype.take = function(t) {
482
482
  if (t < 0)
483
483
  throw new Error("Length must be non-negative");
484
484
  return this.already_limit ? (this.steps.push({ type: "take", args: [t] }), this) : (this.limit = t, this.already_limit = !0, this);
485
485
  };
486
- g.prototype.splice = function(t, e) {
486
+ w.prototype.splice = function(t, e) {
487
487
  return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
488
488
  };
489
- const J = (t, e) => {
490
- const r = new g(e);
491
- return r.data_path = V + t, r;
492
- }, x = (t, e = {}) => {
493
- const r = e;
494
- let s = "list" + t;
495
- const o = (u) => r[u] ? r[u] : null;
489
+ const st = (t, e, r = F) => {
490
+ const s = new w(e);
491
+ return s._queryFn = r, s.data_path = wt + t, s;
492
+ }, nt = (t, e = {}, r = {}) => {
493
+ const s = r.mutation || g, n = r.createList || L, c = r.createCollection || st, l = e;
494
+ let f = "list" + t;
495
+ const p = (o) => l[o] ? l[o] : null;
496
496
  return {
497
- field: o,
498
- $fields: r,
499
- setDataPath(u) {
500
- return s = u, s;
497
+ field: p,
498
+ $fields: l,
499
+ setDataPath(o) {
500
+ return f = o, f;
501
501
  },
502
502
  getDataPath() {
503
- return s;
503
+ return f;
504
504
  },
505
- gqlFields(u) {
506
- let c = {};
507
- for (const p of u)
508
- if (typeof p == "string") {
509
- const n = o(p);
510
- n && (c = A(c, n.gqlField ? typeof n.gqlField == "string" ? { [n.gqlField]: !0 } : n.gqlField : { [n.name || p]: !0 }));
511
- } else typeof p == "object" && (c = A(c, p));
512
- return c;
505
+ gqlFields(o) {
506
+ let i = {};
507
+ for (const a of o)
508
+ if (typeof a == "string") {
509
+ const u = p(a);
510
+ u && (i = j(i, u.gqlField ? typeof u.gqlField == "string" ? { [u.gqlField]: !0 } : u.gqlField : { [u.name || a]: !0 }));
511
+ } else typeof a == "object" && (i = j(i, a));
512
+ return i;
513
513
  },
514
- update(u, c) {
515
- return f({
514
+ update(o, i) {
515
+ return s({
516
516
  ["update" + t]: {
517
- __args: { id: u, data: c }
517
+ __args: { id: o, data: i }
518
518
  }
519
- }).then((p) => p["update" + t]);
519
+ }).then((a) => a["update" + t]);
520
520
  },
521
- async delete(u) {
522
- return f({
521
+ async delete(o) {
522
+ return s({
523
523
  ["delete" + t]: {
524
- __args: { id: u }
524
+ __args: { id: o }
525
525
  }
526
- }).then((c) => c["delete" + t]);
526
+ }).then((i) => i["delete" + t]);
527
527
  },
528
- add(u) {
529
- return f({
528
+ add(o) {
529
+ return s({
530
530
  ["add" + t]: {
531
- __args: { data: u }
531
+ __args: { data: o }
532
532
  }
533
- }).then((c) => c["add" + t]);
533
+ }).then((i) => i["add" + t]);
534
534
  },
535
- fields(u) {
536
- let c = [];
537
- for (let p of u) {
538
- const n = o(p);
539
- n && c.push(n);
535
+ fields(o) {
536
+ let i = [];
537
+ for (let a of o) {
538
+ const u = p(a);
539
+ u && i.push(u);
540
540
  }
541
- return c;
541
+ return i;
542
542
  },
543
- async get(u, c) {
544
- const p = J(t, Zt(c));
545
- for (const [n, i] of Object.entries(u))
546
- p.where(n, "==", i);
547
- return await p.first();
543
+ async get(o, i) {
544
+ const a = c(t, ne(i));
545
+ for (const [u, m] of Object.entries(o))
546
+ a.where(u, "==", m);
547
+ return await a.first();
548
548
  },
549
- list(u) {
550
- let c = u;
551
- const p = {};
552
- Object.entries(u).forEach(([a]) => {
553
- r[a] && (p[a] = r[a], r[a].gqlField && (delete c[a], c = A(c, r[a].gqlField)), r[a].gql && (delete c[a], c = A(c, r[a].gql)));
549
+ list(o) {
550
+ let i = o;
551
+ const a = {};
552
+ Object.entries(o).forEach(([d]) => {
553
+ l[d] && (a[d] = l[d], l[d].gqlField && (delete i[d], i = j(i, l[d].gqlField)), l[d].gql && (delete i[d], i = j(i, l[d].gql)));
554
554
  });
555
- const n = j(t, c).dataPath(s), i = n.fetch.bind(n);
555
+ const u = n(t, i).dataPath(f), m = u.fetch.bind(u);
556
556
  return {
557
- ...n,
557
+ ...u,
558
558
  async fetch() {
559
- return (await i()).map((l) => {
560
- const h = { ...l };
561
- return Object.entries(p).forEach(([d, _]) => {
562
- _.field && typeof _.field == "function" && (h[d] = _.field(l[d], l));
563
- }), h;
559
+ return (await m()).map((b) => {
560
+ const O = { ...b };
561
+ return Object.entries(a).forEach(([C, P]) => {
562
+ P.field && typeof P.field == "function" && (O[C] = P.field(b[C], b));
563
+ }), O;
564
564
  });
565
565
  },
566
566
  async fetchFirst() {
567
- const l = await n.fetchFirst.bind(n)();
568
- if (!l) return l;
569
- const h = { ...l };
570
- return Object.entries(p).forEach(([d, _]) => {
571
- _.field && typeof _.field == "function" && (h[d] = _.field(l[d], l));
572
- }), h;
567
+ const b = await u.fetchFirst.bind(u)();
568
+ if (!b) return b;
569
+ const O = { ...b };
570
+ return Object.entries(a).forEach(([C, P]) => {
571
+ P.field && typeof P.field == "function" && (O[C] = P.field(b[C], b));
572
+ }), O;
573
573
  }
574
574
  };
575
575
  }
576
576
  };
577
- }, O = {}, L = (t, e) => {
578
- const r = x(t, e);
579
- return O[t] = r, r;
580
- }, k = (t) => O[t] ? O[t] : L(t, {}), re = (t) => !!O[t], se = () => Object.keys(O), ne = () => {
581
- Object.keys(O).forEach((t) => delete O[t]);
582
- }, ie = (t) => {
577
+ }, E = {}, ot = (t, e) => {
578
+ const r = nt(t, e);
579
+ return E[t] = r, r;
580
+ }, z = (t) => E[t] ? E[t] : ot(t, {}), pe = (t) => !!E[t], fe = () => Object.keys(E), ge = () => {
581
+ Object.keys(E).forEach((t) => delete E[t]);
582
+ }, de = (t) => {
583
583
  Object.entries(t).forEach(([e, r]) => {
584
- L(e, r);
584
+ ot(e, r);
585
585
  });
586
- }, oe = () => y({
586
+ }, _e = () => F({
587
587
  app: {
588
588
  permissions: !0
589
589
  }
590
- }).then((t) => t.app.permissions), R = async () => {
591
- const { app: t } = await y({
592
- app: {
593
- auth: {
594
- webAuthnRequestOptions: !0
590
+ }).then((t) => t.app.permissions), Y = (t, e) => {
591
+ const r = async () => {
592
+ const { app: l } = await t({
593
+ app: {
594
+ auth: {
595
+ webAuthnRequestOptions: !0
596
+ }
595
597
  }
596
- }
597
- }), e = t.auth.webAuthnRequestOptions, r = PublicKeyCredential.parseRequestOptionsFromJSON(e);
598
- return await navigator.credentials.get({ publicKey: r });
599
- }, $ = async () => {
600
- const { app: t } = await y({
601
- app: {
602
- auth: {
603
- webAuthnCreationOptions: !0
598
+ }), f = l.auth.webAuthnRequestOptions, p = PublicKeyCredential.parseRequestOptionsFromJSON(f);
599
+ return await navigator.credentials.get({ publicKey: p });
600
+ }, s = async () => {
601
+ const { app: l } = await t({
602
+ app: {
603
+ auth: {
604
+ webAuthnCreationOptions: !0
605
+ }
604
606
  }
605
- }
606
- }), e = PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);
607
- return await navigator.credentials.create({ publicKey: e });
608
- }, tt = async () => {
609
- const t = await R();
610
- return await f({
611
- webAuthnAssertion: {
612
- __args: {
613
- assertion: t.toJSON()
607
+ }), f = PublicKeyCredential.parseCreationOptionsFromJSON(l.auth.webAuthnCreationOptions);
608
+ return await navigator.credentials.create({ publicKey: f });
609
+ };
610
+ return { assertion: r, attestation: s, login: async () => {
611
+ const l = await r();
612
+ return await e({
613
+ webAuthnAssertion: {
614
+ __args: {
615
+ assertion: l.toJSON()
616
+ }
614
617
  }
615
- }
616
- }).then((e) => e.webAuthnAssertion);
617
- }, et = async () => {
618
- const t = await $();
619
- return await f({
620
- webAuthnRegister: {
621
- __args: {
622
- registration: t.toJSON()
618
+ }).then((f) => f.webAuthnAssertion);
619
+ }, register: async () => {
620
+ const l = await s();
621
+ return await e({
622
+ webAuthnRegister: {
623
+ __args: {
624
+ registration: l.toJSON()
625
+ }
623
626
  }
624
- }
625
- }).then((e) => e.webAuthnRegister);
626
- }, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
627
+ }).then((f) => f.webAuthnRegister);
628
+ } };
629
+ }, G = Y(F, g), Ft = G.assertion, At = G.attestation, kt = G.login, Ct = G.register, Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
627
630
  __proto__: null,
628
- assertion: R,
629
- attestation: $,
630
- login: tt,
631
- register: et
632
- }, Symbol.toStringTag, { value: "Module" })), st = (t = G) => y({ my: t }).then((e) => e.my), nt = (t, e, r = "") => f({ login: { __args: { username: t, password: e, code: r } } }).then((s) => s.login), it = () => f({ logout: !0 }).then((t) => t.logout), ot = (t, e, r) => f({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((s) => s.changeExpiredPassword), at = (t, e) => f({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), lt = (t, e, r) => f({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((s) => s.resetPassword), ct = (t, e) => f({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), ut = (t, e) => f({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), ht = (t) => y({
631
+ assertion: Ft,
632
+ attestation: At,
633
+ createWebAuthn: Y,
634
+ login: kt,
635
+ register: Ct
636
+ }, Symbol.toStringTag, { value: "Module" })), Pt = (t, e) => ({
637
+ getCurrentUser: (r = J) => t({ my: r }).then((s) => s.my),
638
+ login: (r, s, n = "") => e({ login: { __args: { username: r, password: s, code: n } } }).then((c) => c.login),
639
+ logout: () => e({ logout: !0 }).then((r) => r.logout),
640
+ changeExpiredPassword: (r, s, n) => e({ changeExpiredPassword: { __args: { username: r, old_password: s, new_password: n } } }).then((c) => c.changeExpiredPassword),
641
+ updatePassword: (r, s) => e({ changeUserPassword: { __args: { old_password: r, new_password: s } } }).then((n) => n.changeUserPassword),
642
+ resetPassword: (r, s, n) => e({ resetPassword: { __args: { jwt: r, password: s, code: n } } }).then((c) => c.resetPassword),
643
+ forgetPassword: (r, s) => e({ forgetPassword: { __args: { username: r, email: s } } }).then((n) => n.forgetPassword),
644
+ verifyCode: (r, s) => e({ forgetPasswordVerifyCode: { __args: { jwt: r, code: s } } }).then((n) => n.forgetPasswordVerifyCode),
645
+ grantedRights: (r) => t({
646
+ my: { grantedRights: { __args: { rights: r } } }
647
+ }).then((s) => s.my.grantedRights),
648
+ isGranted: (r) => t({
649
+ my: { granted: { __args: { right: r } } }
650
+ }).then((s) => s.my.granted),
651
+ webAuthn: Y(t, e),
652
+ google: {
653
+ unlink: () => e({ lightAuthUnlinkGoogle: !0 }).then((r) => r.lightAuthUnlinkGoogle),
654
+ login: (r) => e({ lightAuthLoginGoogle: { __args: { credential: r } } }).then((s) => s.lightAuthLoginGoogle),
655
+ register: (r) => e({ lightAuthRegisterGoogle: { __args: { credential: r } } }).then((s) => s.lightAuthRegisterGoogle)
656
+ },
657
+ facebook: {
658
+ unlink: () => e({ lightAuthUnlinkFacebook: !0 }).then((r) => r.lightAuthUnlinkFacebook),
659
+ login: (r) => e({ lightAuthLoginFacebook: { __args: { access_token: r } } }).then((s) => s.lightAuthLoginFacebook),
660
+ register: (r) => e({ lightAuthRegisterFacebook: { __args: { access_token: r } } }).then((s) => s.lightAuthRegisterFacebook)
661
+ },
662
+ microsoft: {
663
+ unlink: () => e({ lightAuthUnlinkMicrosoft: !0 }).then((r) => r.lightAuthUnlinkMicrosoft),
664
+ login: (r) => e({ lightAuthLoginMicrosoft: { __args: { access_token: r } } }).then((s) => s.lightAuthLoginMicrosoft),
665
+ register: (r) => e({ lightAuthRegisterMicrosoft: { __args: { account_id: r } } }).then((s) => s.lightAuthRegisterMicrosoft)
666
+ }
667
+ }), Ut = (t = J) => F({ my: t }).then((e) => e.my), Dt = (t, e, r = "") => g({ login: { __args: { username: t, password: e, code: r } } }).then((s) => s.login), St = () => g({ logout: !0 }).then((t) => t.logout), jt = (t, e, r) => g({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((s) => s.changeExpiredPassword), vt = (t, e) => g({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), Et = (t, e, r) => g({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((s) => s.resetPassword), Mt = (t, e) => g({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), Tt = (t, e) => g({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), Nt = (t) => F({
633
668
  my: {
634
669
  granted: {
635
670
  __args: {
@@ -637,7 +672,7 @@ const J = (t, e) => {
637
672
  }
638
673
  }
639
674
  }
640
- }).then((e) => e.my.granted), pt = (t) => y({
675
+ }).then((e) => e.my.granted), Rt = (t) => F({
641
676
  my: {
642
677
  grantedRights: {
643
678
  __args: {
@@ -645,40 +680,40 @@ const J = (t, e) => {
645
680
  }
646
681
  }
647
682
  }
648
- }).then((e) => e.my.grantedRights), ft = {
649
- getCurrentUser: st,
650
- webAuthn: rt,
683
+ }).then((e) => e.my.grantedRights), ye = {
684
+ getCurrentUser: Ut,
685
+ webAuthn: Ot,
651
686
  google: {
652
- unlink: () => f({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
653
- login: (t) => f({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
654
- register: (t) => f({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
687
+ unlink: () => g({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
688
+ login: (t) => g({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
689
+ register: (t) => g({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
655
690
  },
656
691
  facebook: {
657
- unlink: () => f({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
658
- login: (t) => f({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
659
- register: (t) => f({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
692
+ unlink: () => g({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
693
+ login: (t) => g({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
694
+ register: (t) => g({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
660
695
  },
661
696
  microsoft: {
662
- unlink: () => f({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
663
- login: (t) => f({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
664
- register: (t) => f({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
697
+ unlink: () => g({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
698
+ login: (t) => g({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
699
+ register: (t) => g({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
665
700
  },
666
- login: nt,
667
- logout: it,
668
- changeExpiredPassword: ot,
669
- updatePassword: at,
670
- resetPassword: lt,
671
- forgetPassword: ct,
672
- verifyCode: ut,
673
- grantedRights: pt,
674
- isGranted: ht
675
- }, Q = {
701
+ login: Dt,
702
+ logout: St,
703
+ changeExpiredPassword: jt,
704
+ updatePassword: vt,
705
+ resetPassword: Et,
706
+ forgetPassword: Mt,
707
+ verifyCode: Tt,
708
+ grantedRights: Rt,
709
+ isGranted: Nt
710
+ }, it = {
676
711
  name: !0,
677
712
  path: !0,
678
713
  size: !0,
679
714
  mime: !0,
680
715
  url: !0
681
- }, dt = (t, e, r = Q) => y({
716
+ }, we = (t, e, r = it) => F({
682
717
  app: {
683
718
  drive: {
684
719
  __args: { index: t },
@@ -688,7 +723,7 @@ const J = (t, e) => {
688
723
  }
689
724
  }
690
725
  }
691
- }).then((s) => s.app.drive.files), _t = (t, e) => y({
726
+ }).then((s) => s.app.drive.files), be = (t, e) => F({
692
727
  app: {
693
728
  drive: {
694
729
  __args: {
@@ -702,15 +737,15 @@ const J = (t, e) => {
702
737
  }
703
738
  }
704
739
  }
705
- }).then((r) => r.app.drive?.file?.base64Content), gt = (t) => ({
706
- list: (e, r = Q) => dt(t, e, r),
707
- get: (e, r = {
740
+ }).then((r) => r.app.drive?.file?.base64Content), Bt = (t, e = F, r = g) => ({
741
+ list: (s, n = it) => e({ app: { drive: { __args: { index: t }, files: { __args: { path: s }, ...n } } } }).then((c) => c.app.drive.files),
742
+ get: (s, n = {
708
743
  name: !0,
709
744
  path: !0,
710
745
  size: !0,
711
746
  mime: !0,
712
747
  url: !0
713
- }) => y({
748
+ }) => e({
714
749
  app: {
715
750
  drive: {
716
751
  __args: {
@@ -718,18 +753,18 @@ const J = (t, e) => {
718
753
  },
719
754
  file: {
720
755
  __args: {
721
- path: e
756
+ path: s
722
757
  },
723
- ...r
758
+ ...n
724
759
  }
725
760
  }
726
761
  }
727
- }).then((s) => s.app.drive.file),
728
- readFileAsBase64(e) {
729
- return _t(t, e);
762
+ }).then((c) => c.app.drive.file),
763
+ readFileAsBase64(s) {
764
+ return e({ app: { drive: { __args: { index: t }, file: { __args: { path: s }, base64Content: !0 } } } }).then((n) => n.app.drive?.file?.base64Content);
730
765
  },
731
- read: async (e) => {
732
- let r = await y({
766
+ read: async (s) => {
767
+ let n = await e({
733
768
  app: {
734
769
  drive: {
735
770
  __args: {
@@ -737,25 +772,25 @@ const J = (t, e) => {
737
772
  },
738
773
  file: {
739
774
  __args: {
740
- path: e
775
+ path: s
741
776
  },
742
777
  base64Content: !0
743
778
  }
744
779
  }
745
780
  }
746
781
  });
747
- if (!r.app.drive.file || !r.app.drive.file.base64Content)
748
- throw new Error(`File not found or cannot read content: ${e}`);
749
- return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
782
+ if (!n.app.drive.file || !n.app.drive.file.base64Content)
783
+ throw new Error(`File not found or cannot read content: ${s}`);
784
+ return typeof window < "u" && window.atob ? window.atob(n.app.drive.file.base64Content) : n.app.drive.file.base64Content;
750
785
  },
751
- write: (e, r) => f({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((s) => s.lightDriveWriteFile),
752
- delete: (e) => f({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
753
- rename: (e, r) => f({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((s) => s.lightDriveRenameFile),
754
- move: (e, r) => f({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((s) => s.lightDriveMoveFile)
755
- }), z = {
786
+ write: (s, n) => r({ lightDriveWriteFile: { __args: { index: t, path: s, content: n } } }).then((c) => c.lightDriveWriteFile),
787
+ delete: (s) => r({ lightDriveDeleteFile: { __args: { index: t, path: s } } }).then((n) => n.lightDriveDeleteFile),
788
+ rename: (s, n) => r({ lightDriveRenameFile: { __args: { index: t, path: s, name: n } } }).then((c) => c.lightDriveRenameFile),
789
+ move: (s, n) => r({ lightDriveMoveFile: { __args: { index: t, source: s, destination: n } } }).then((c) => c.lightDriveMoveFile)
790
+ }), at = {
756
791
  name: !0,
757
792
  path: !0
758
- }, yt = (t, e, r = z) => y({
793
+ }, me = (t, e, r = at) => F({
759
794
  app: {
760
795
  drive: {
761
796
  __args: { index: t },
@@ -765,73 +800,79 @@ const J = (t, e) => {
765
800
  }
766
801
  }
767
802
  }
768
- }).then((s) => s.app.drive.folders), mt = (t) => ({
769
- list: (e, r = z) => yt(t, e, r),
770
- create: (e) => f({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
771
- delete: (e) => f({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
772
- rename: (e, r) => f({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((s) => s.lightDriveRenameFolder)
773
- }), ae = () => y({
803
+ }).then((s) => s.app.drive.folders), qt = (t, e = F, r = g) => ({
804
+ list: (s, n = at) => e({ app: { drive: { __args: { index: t }, folders: { __args: { path: s }, ...n } } } }).then((c) => c.app.drive.folders),
805
+ create: (s) => r({ lightDriveCreateFolder: { __args: { index: t, path: s } } }).then((n) => n.lightDriveCreateFolder),
806
+ delete: (s) => r({ lightDriveDeleteFolder: { __args: { index: t, path: s } } }).then((n) => n.lightDriveDeleteFolder),
807
+ rename: (s, n) => r({ lightDriveRenameFolder: { __args: { index: t, path: s, name: n } } }).then((c) => c.lightDriveRenameFolder)
808
+ }), Fe = () => F({
774
809
  app: {
775
810
  drives: {
776
811
  index: !0,
777
812
  name: !0
778
813
  }
779
814
  }
780
- }).then((t) => t.app.drives), Ft = (t) => {
781
- const e = gt(t), r = mt(t);
815
+ }).then((t) => t.app.drives), Ae = (t) => lt(F, g)(t), lt = (t, e) => (r) => {
816
+ const s = Bt(r, t, e), n = qt(r, t, e);
782
817
  return {
783
- folders: r,
784
- files: e,
785
- listFiles: e.list,
786
- getFile: e.get,
787
- readFile: e.read,
788
- writeFile: e.write,
789
- deleteFile: e.delete,
790
- renameFile: e.rename,
791
- moveFile: e.move,
792
- listFolders: r.list,
793
- createFolder: r.create,
794
- deleteFolder: r.delete,
795
- renameFolder: r.rename,
796
- uploadTempFile: (s) => f({
818
+ folders: n,
819
+ files: s,
820
+ listFiles: s.list,
821
+ getFile: s.get,
822
+ readFile: s.read,
823
+ writeFile: s.write,
824
+ deleteFile: s.delete,
825
+ renameFile: s.rename,
826
+ moveFile: s.move,
827
+ listFolders: n.list,
828
+ createFolder: n.create,
829
+ deleteFolder: n.delete,
830
+ renameFolder: n.rename,
831
+ uploadTempFile: (c) => e({
797
832
  lightDriveUploadTempFile: {
798
- __args: { index: t, file: s },
833
+ __args: { index: r, file: c },
799
834
  name: !0,
800
835
  path: !0,
801
836
  size: !0,
802
837
  mime: !0
803
838
  }
804
- }).then((o) => o.lightDriveUploadTempFile)
839
+ }).then((l) => l.lightDriveUploadTempFile)
805
840
  };
806
- }, G = {
841
+ }, J = {
807
842
  user_id: !0,
808
843
  username: !0,
809
844
  first_name: !0,
810
845
  last_name: !0,
811
846
  status: !0
812
- }, wt = (t) => f({
847
+ }, ke = (t) => g({
813
848
  addUser: {
814
849
  __args: t
815
850
  }
816
- }).then((e) => e.addUser), bt = (t) => f({
851
+ }).then((e) => e.addUser), Ce = (t) => g({
817
852
  deleteUser: {
818
853
  __args: { id: t }
819
854
  }
820
- }).then((e) => e.deleteUser), At = (t = G) => j("Users", t).dataPath("app.listUser").fetch(), Ot = (t, e) => f({
855
+ }).then((e) => e.deleteUser), Oe = (t = J) => L("Users", t).dataPath("app.listUser").fetch(), Pe = (t, e) => g({
821
856
  updateUser: {
822
857
  __args: { id: t, data: e }
823
858
  }
824
- }).then((r) => r.updateUser), Dt = {
825
- list: At,
826
- create: wt,
827
- delete: bt,
828
- update: Ot
829
- }, Ct = (t) => y({
859
+ }).then((r) => r.updateUser), Lt = (t, e) => ({
860
+ list: (r = J) => e("Users", r).dataPath("app.listUser").fetch(),
861
+ create: (r) => t({
862
+ addUser: { __args: r }
863
+ }).then((s) => s.addUser),
864
+ delete: (r) => t({
865
+ deleteUser: { __args: { id: r } }
866
+ }).then((s) => s.deleteUser),
867
+ update: (r, s) => t({
868
+ updateUser: { __args: { id: r, data: s } }
869
+ }).then((n) => n.updateUser)
870
+ }), ct = (t) => (e) => t({
830
871
  app: {
831
872
  listConfig: {
832
873
  __args: {
833
874
  filters: {
834
- name: t
875
+ name: e
835
876
  }
836
877
  },
837
878
  data: {
@@ -840,13 +881,13 @@ const J = (t, e) => {
840
881
  }
841
882
  }
842
883
  }
843
- }).then((e) => e.app.listConfig.data[0]?.value), St = {
884
+ }).then((r) => r.app.listConfig.data[0]?.value), Ue = ct(F), ut = {
844
885
  name: !0
845
- }, jt = (t = St) => y({
886
+ }, De = (t = ut) => F({
846
887
  app: {
847
888
  roles: t
848
889
  }
849
- }).then((e) => e.app.roles), Ut = (t, e) => f({
890
+ }).then((e) => e.app.roles), Se = (t, e) => g({
850
891
  addRole: {
851
892
  __args: {
852
893
  data: {
@@ -855,93 +896,111 @@ const J = (t, e) => {
855
896
  }
856
897
  }
857
898
  }
858
- }).then((r) => r.addRole), kt = (t) => f({
899
+ }).then((r) => r.addRole), je = (t) => g({
859
900
  deleteRole: {
860
901
  __args: { name: t }
861
902
  }
862
- }).then((e) => e.deleteRole), Pt = () => ({
863
- list: jt,
864
- create: Ut,
865
- delete: kt
903
+ }).then((e) => e.deleteRole), Gt = (t, e) => ({
904
+ list: (r = ut) => t({
905
+ app: { roles: r }
906
+ }).then((s) => s.app.roles),
907
+ create: (r, s) => e({
908
+ addRole: { __args: { data: { name: r, childs: s } } }
909
+ }).then((n) => n.addRole),
910
+ delete: (r) => e({
911
+ deleteRole: { __args: { name: r } }
912
+ }).then((s) => s.deleteRole)
866
913
  });
867
- function W(t, e, r, s, o) {
914
+ function H(t) {
915
+ if (Array.isArray(t))
916
+ return t.map((e) => H(e)).filter((e) => e !== void 0);
917
+ if (t !== null && typeof t == "object") {
918
+ const e = Object.getPrototypeOf(t);
919
+ if (e === Object.prototype || e === null)
920
+ return Object.fromEntries(
921
+ Object.entries(t).filter(([, r]) => r !== void 0).map(([r, s]) => [r, H(s)])
922
+ );
923
+ }
924
+ return t;
925
+ }
926
+ function ht(t, e, r, s, n) {
868
927
  if (!(!t || typeof t != "object"))
869
- for (let u in t) {
870
- const c = t[u];
871
- if (c && typeof c == "object") {
872
- if ("__args" in c) {
873
- const p = c.__args, n = {};
874
- Object.entries(p).forEach(([i, a]) => {
875
- if (a instanceof Array && D(a)) {
876
- n[i] = new b(i);
877
- let l = 0;
878
- a.forEach((h) => {
879
- h instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + i + "." + l), s.append(o.current.toString(), h), o.current++, l++);
880
- }), e[i] = "[Upload!]!";
881
- } else a instanceof File ? (n[i] = new b(i), r[o.current] = ["variables." + i], s.append(o.current.toString(), a), e[i] = "Upload!", o.current++) : a instanceof Object && N(a) ? (n[i] = {}, Object.entries(a).forEach(([l, h]) => {
882
- if (h instanceof Array && D(h)) {
883
- n[i][l] = new b(l);
884
- let d = 0;
885
- h.forEach((_) => {
886
- _ instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + l + "." + d), s.append(o.current.toString(), _), o.current++, d++);
887
- }), e[l] = "[Upload!]!";
888
- } else h instanceof File ? (n[i][l] = new b(l), r[o.current] = ["variables." + l], s.append(o.current.toString(), h), e[l] = "Upload!", o.current++) : n[i][l] = h;
889
- })) : a != null && (n[i] = a);
890
- }), c.__args = n;
928
+ for (let c in t) {
929
+ const l = t[c];
930
+ if (l && typeof l == "object") {
931
+ if ("__args" in l) {
932
+ const f = H(l.__args), p = {};
933
+ Object.entries(f).forEach(([o, i]) => {
934
+ if (i instanceof Array && N(i)) {
935
+ p[o] = new S(o);
936
+ let a = 0;
937
+ i.forEach((u) => {
938
+ u instanceof File && (r[n.current] || (r[n.current] = []), r[n.current].push("variables." + o + "." + a), s.append(n.current.toString(), u), n.current++, a++);
939
+ }), e[o] = "[Upload!]!";
940
+ } else i instanceof File ? (p[o] = new S(o), r[n.current] = ["variables." + o], s.append(n.current.toString(), i), e[o] = "Upload!", n.current++) : i instanceof Object && x(i) ? (p[o] = {}, Object.entries(i).forEach(([a, u]) => {
941
+ if (u instanceof Array && N(u)) {
942
+ p[o][a] = new S(a);
943
+ let m = 0;
944
+ u.forEach((d) => {
945
+ d instanceof File && (r[n.current] || (r[n.current] = []), r[n.current].push("variables." + a + "." + m), s.append(n.current.toString(), d), n.current++, m++);
946
+ }), e[a] = "[Upload!]!";
947
+ } else u instanceof File ? (p[o][a] = new S(a), r[n.current] = ["variables." + a], s.append(n.current.toString(), u), e[a] = "Upload!", n.current++) : p[o][a] = u;
948
+ })) : i != null && (p[o] = i);
949
+ }), l.__args = p;
891
950
  }
892
- W(c, e, r, s, o);
951
+ ht(l, e, r, s, n);
893
952
  }
894
953
  }
895
954
  }
896
- const f = async (t) => {
897
- const { axios: e } = M(), r = t, s = new FormData();
898
- let o = !1;
899
- const u = {}, c = {};
900
- W(r, u, c, s, { current: 0 }), o = Object.keys(u).length > 0, o && (r.__variables = u);
901
- let n = null;
902
- const a = q({ mutation: r });
903
- if (o ? (s.append("map", JSON.stringify(c)), s.append("operations", JSON.stringify({
904
- query: a
905
- })), n = await e.post("", s)) : n = await e.post("", {
906
- query: a
907
- }), n.data.errors)
908
- throw new Error(n.data.errors[0].message);
909
- return n.data.data;
910
- }, Et = (t, e, r) => f({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((s) => s.sendMail), vt = {
911
- send: Et
912
- }, qt = (t) => f({
955
+ const pt = (t) => async (e) => {
956
+ const r = e, s = new FormData();
957
+ let n = !1;
958
+ const c = {}, l = {};
959
+ ht(r, c, l, s, { current: 0 }), n = Object.keys(c).length > 0, n && (r.__variables = c);
960
+ let p = null;
961
+ const i = I({ mutation: r });
962
+ if (n ? (s.append("map", JSON.stringify(l)), s.append("operations", JSON.stringify({
963
+ query: i
964
+ })), p = await t.post("", s)) : p = await t.post("", {
965
+ query: i
966
+ }), p.data.errors)
967
+ throw new Error(p.data.errors[0].message);
968
+ return p.data.data;
969
+ }, g = async (t) => pt(K().axios)(t), ve = (t, e, r) => g({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((s) => s.sendMail), Jt = (t) => ({
970
+ send: (e, r, s) => t({ sendMail: { __args: { email: e, subject: r, message: s } } }).then((n) => n.sendMail)
971
+ }), $t = (t) => g({
913
972
  lightFSCreateFolder: {
914
973
  __args: { location: t }
915
974
  }
916
- }).then((e) => e.lightFSCreateFolder), Mt = (t) => f({
975
+ }).then((e) => e.lightFSCreateFolder), zt = (t) => g({
917
976
  lightFSDeleteFolder: {
918
977
  __args: { location: t }
919
978
  }
920
- }).then((e) => e.lightFSDeleteFolder), Nt = (t, e) => f({
979
+ }).then((e) => e.lightFSDeleteFolder), Qt = (t, e) => g({
921
980
  lightFSRenameFolder: {
922
981
  __args: { location: t, newName: e }
923
982
  }
924
- }).then((r) => r.lightFSRenameFolder), Bt = (t, e) => f({
983
+ }).then((r) => r.lightFSRenameFolder), Wt = (t, e) => g({
925
984
  lightFSRenameFile: {
926
985
  __args: { location: t, newName: e }
927
986
  }
928
- }).then((r) => r.lightFSRenameFile), Tt = (t, e) => f({
987
+ }).then((r) => r.lightFSRenameFile), Ht = (t, e) => g({
929
988
  lightFSWriteFile: {
930
989
  __args: { location: t, content: e }
931
990
  }
932
- }).then((r) => r.lightFSWriteFile), Jt = (t, e) => f({
991
+ }).then((r) => r.lightFSWriteFile), Xt = (t, e, r = !1) => g({
933
992
  lightFSUploadFile: {
934
- __args: { location: t, file: e }
993
+ __args: { location: t, file: e, rename: r }
935
994
  }
936
- }).then((r) => r.lightFSUploadFile), Lt = (t) => f({
995
+ }).then((s) => s.lightFSUploadFile), Yt = (t) => g({
937
996
  lightFSDeleteFile: {
938
997
  __args: { location: t }
939
998
  }
940
- }).then((e) => e.lightFSDeleteFile), Rt = (t, e) => f({
999
+ }).then((e) => e.lightFSDeleteFile), Zt = (t, e) => g({
941
1000
  lightFSMove: {
942
1001
  __args: { from: t, to: e }
943
1002
  }
944
- }).then((r) => r.lightFSMove), $t = (t) => y({
1003
+ }).then((r) => r.lightFSMove), Vt = (t) => F({
945
1004
  app: {
946
1005
  fs: {
947
1006
  exists: {
@@ -949,9 +1008,9 @@ const f = async (t) => {
949
1008
  }
950
1009
  }
951
1010
  }
952
- }).then((e) => e.app.fs.exists), Qt = (t, e) => {
1011
+ }).then((e) => e.app.fs.exists), It = (t, e) => {
953
1012
  const r = {};
954
- return t && (r.search = t), e && (r.label = e), y({
1013
+ return t && (r.search = t), e && (r.label = e), F({
955
1014
  app: {
956
1015
  fs: {
957
1016
  find: {
@@ -973,7 +1032,7 @@ const f = async (t) => {
973
1032
  }
974
1033
  }
975
1034
  }).then((s) => s.app.fs.find);
976
- }, zt = (t) => y({
1035
+ }, Kt = (t) => F({
977
1036
  app: {
978
1037
  fs: {
979
1038
  node: {
@@ -1003,7 +1062,7 @@ const f = async (t) => {
1003
1062
  }
1004
1063
  }
1005
1064
  }
1006
- }).then((r) => r.app.fs.node), Gt = (t, e = "text") => y({
1065
+ }).then((r) => r.app.fs.node), xt = (t, e = "text") => F({
1007
1066
  app: {
1008
1067
  fs: {
1009
1068
  node: {
@@ -1020,7 +1079,7 @@ const f = async (t) => {
1020
1079
  }).then((r) => {
1021
1080
  const s = r.app.fs.node;
1022
1081
  return s?.__typename === "File" ? e === "text" ? s.content : s.base64Content : null;
1023
- }), Wt = (t, e) => f({
1082
+ }), te = (t, e) => g({
1024
1083
  lightFSUploadBase64: {
1025
1084
  __args: { location: t, base64: e },
1026
1085
  __typename: !0,
@@ -1034,11 +1093,11 @@ const f = async (t) => {
1034
1093
  lastModified: !0
1035
1094
  }]
1036
1095
  }
1037
- }).then((r) => r.lightFSUploadBase64), Ht = (t) => f({
1096
+ }).then((r) => r.lightFSUploadBase64), ee = (t) => g({
1038
1097
  lightFSDuplicateFile: {
1039
1098
  __args: { location: t }
1040
1099
  }
1041
- }).then((e) => e.lightFSDuplicateFile), Xt = (t, e) => f({
1100
+ }).then((e) => e.lightFSDuplicateFile), re = (t, e) => g({
1042
1101
  lightFSUploadTempFile: {
1043
1102
  __args: { location: t, file: e },
1044
1103
  name: !0,
@@ -1047,9 +1106,9 @@ const f = async (t) => {
1047
1106
  size: !0,
1048
1107
  mimeType: !0
1049
1108
  }
1050
- }).then((r) => r.lightFSUploadTempFile), Yt = (t, e, r) => {
1109
+ }).then((r) => r.lightFSUploadTempFile), se = (t, e, r) => {
1051
1110
  const s = { location: t };
1052
- return e && (s.type = e), r && (s.search = r), y({
1111
+ return e && (s.type = e), r && (s.search = r), F({
1053
1112
  app: {
1054
1113
  fs: {
1055
1114
  listFiles: {
@@ -1064,30 +1123,30 @@ const f = async (t) => {
1064
1123
  }
1065
1124
  }
1066
1125
  }
1067
- }).then((o) => o.app.fs.listFiles);
1068
- }, le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1126
+ }).then((n) => n.app.fs.listFiles);
1127
+ }, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1069
1128
  __proto__: null,
1070
- createFolder: qt,
1071
- deleteFile: Lt,
1072
- deleteFolder: Mt,
1073
- duplicateFile: Ht,
1074
- exists: $t,
1075
- find: Qt,
1076
- list: zt,
1077
- listFiles: Yt,
1078
- move: Rt,
1079
- readFile: Gt,
1080
- renameFile: Bt,
1081
- renameFolder: Nt,
1082
- uploadBase64: Wt,
1083
- uploadFile: Jt,
1084
- uploadTempFile: Xt,
1085
- writeFile: Tt
1086
- }, Symbol.toStringTag, { value: "Module" })), v = (t) => {
1129
+ createFolder: $t,
1130
+ deleteFile: Yt,
1131
+ deleteFolder: zt,
1132
+ duplicateFile: ee,
1133
+ exists: Vt,
1134
+ find: It,
1135
+ list: Kt,
1136
+ listFiles: se,
1137
+ move: Zt,
1138
+ readFile: xt,
1139
+ renameFile: Wt,
1140
+ renameFolder: Qt,
1141
+ uploadBase64: te,
1142
+ uploadFile: Xt,
1143
+ uploadTempFile: re,
1144
+ writeFile: Ht
1145
+ }, Symbol.toStringTag, { value: "Module" })), X = (t) => {
1087
1146
  let e = {};
1088
1147
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
1089
- Object.entries(v(r)).forEach(([s, o]) => {
1090
- e[s] = o;
1148
+ Object.entries(X(r)).forEach(([s, n]) => {
1149
+ e[s] = n;
1091
1150
  });
1092
1151
  }), e) : (Object.entries(t).forEach(([r, s]) => {
1093
1152
  if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
@@ -1098,152 +1157,227 @@ const f = async (t) => {
1098
1157
  e[r] = s;
1099
1158
  return;
1100
1159
  }
1101
- e[r] = v(s);
1160
+ e[r] = X(s);
1102
1161
  }), e);
1103
- }, Zt = (t) => v(t), ce = (t) => {
1162
+ }, ne = (t) => X(t), Me = (t) => {
1104
1163
  const e = typeof window > "u";
1105
- let r = [];
1106
- const s = H.create({
1164
+ let r = [], s = null, n = null, c = null, l = null;
1165
+ const f = /* @__PURE__ */ new Set(), p = gt.create({
1107
1166
  baseURL: t,
1108
1167
  withCredentials: !0
1168
+ }), o = async () => s && !oe(s) || !n ? s : (c ??= n().then((h) => (s = h, h)).finally(() => {
1169
+ c = null;
1170
+ }), c);
1171
+ p.interceptors.request.use(async (h) => {
1172
+ const _ = await o();
1173
+ return _ && (h.headers.Authorization = `Bearer ${_}`), h;
1109
1174
  });
1110
- let o = !1, u = [];
1111
- const c = (i, a = null) => {
1112
- u.forEach((l) => {
1113
- i ? l.reject(i) : l.resolve(a);
1114
- }), u = [];
1175
+ let i = !1, a = [];
1176
+ const u = (h, _ = null) => {
1177
+ a.forEach((y) => {
1178
+ h ? y.reject(h) : y.resolve(_);
1179
+ }), a = [];
1115
1180
  };
1116
- s.interceptors.response.use(
1117
- (i) => {
1118
- const a = i.data.errors;
1119
- if (a && a.some((l) => l.extensions?.code === "TOKEN_EXPIRED")) {
1120
- const l = i.config;
1121
- return o ? new Promise((h, d) => {
1122
- u.push({ resolve: h, reject: d });
1123
- }).then(() => s(l)).catch((h) => Promise.reject(h)) : (o = !0, p().then(() => (o = !1, c(null), s(l))).catch((h) => (o = !1, c(h), Promise.reject(h))));
1181
+ p.interceptors.response.use(
1182
+ (h) => {
1183
+ const _ = h.data.errors;
1184
+ if (_ && _.some((y) => y.extensions?.code === "TOKEN_EXPIRED")) {
1185
+ const y = h.config;
1186
+ return y._lightTokenRetried ? h : (y._lightTokenRetried = !0, n && (s = null), i ? new Promise((A, k) => {
1187
+ a.push({ resolve: A, reject: k });
1188
+ }).then(() => p(y)).catch((A) => Promise.reject(A)) : (i = !0, m().then(() => (i = !1, u(null), p(y))).catch((A) => (i = !1, u(A), Promise.reject(A)))));
1124
1189
  }
1125
- return i;
1190
+ return h;
1126
1191
  },
1127
- (i) => Promise.reject(i)
1192
+ (h) => Promise.reject(h)
1128
1193
  );
1129
- function p() {
1130
- return s.post("/refresh_token");
1194
+ function m() {
1195
+ return n ? o().then(() => {
1196
+ }) : p.post("/refresh_token");
1131
1197
  }
1132
- e && (s.interceptors.request.use((i) => (i.withCredentials = !0, r.length > 0 && (i.headers.Cookie = r.join("; ")), i)), s.interceptors.response.use((i) => {
1133
- if (i.headers["set-cookie"]) {
1134
- const a = i.headers["set-cookie"].map((h) => h.split(";")[0]), l = /* @__PURE__ */ new Map();
1135
- r.forEach((h) => {
1136
- const d = h.split("=")[0];
1137
- l.set(d, h);
1138
- }), a.forEach((h) => {
1139
- const d = h.split("=")[0];
1140
- l.set(d, h);
1141
- }), r = Array.from(l.values());
1198
+ e && (p.interceptors.request.use((h) => (h.withCredentials = !0, r.length > 0 && (h.headers.Cookie = r.join("; ")), h)), p.interceptors.response.use((h) => {
1199
+ if (h.headers["set-cookie"]) {
1200
+ const _ = h.headers["set-cookie"].map((A) => A.split(";")[0]), y = /* @__PURE__ */ new Map();
1201
+ r.forEach((A) => {
1202
+ const k = A.split("=")[0];
1203
+ y.set(k, A);
1204
+ }), _.forEach((A) => {
1205
+ const k = A.split("=")[0];
1206
+ y.set(k, A);
1207
+ }), r = Array.from(y.values());
1142
1208
  }
1143
- return i;
1209
+ return h;
1144
1210
  }));
1145
- const n = {
1146
- post: s.post,
1211
+ const d = rt(p), b = pt(p), O = (h, _) => L(h, _, d), C = (h, _) => st(h, _, d), P = (h) => {
1212
+ const _ = z(h), y = nt(h, _.$fields, {
1213
+ mutation: b,
1214
+ createList: O,
1215
+ createCollection: C
1216
+ });
1217
+ return y.setDataPath(_.getDataPath()), y;
1218
+ }, U = Pt(d, b), Z = () => f.forEach((h) => h()), T = (h) => (async (..._) => {
1219
+ const y = await h(..._);
1220
+ return Z(), y;
1221
+ }), ft = {
1222
+ ...U,
1223
+ login: T(U.login),
1224
+ logout: (async () => {
1225
+ try {
1226
+ return await U.logout();
1227
+ } finally {
1228
+ Z();
1229
+ }
1230
+ }),
1231
+ google: { ...U.google, login: T(U.google.login) },
1232
+ facebook: { ...U.facebook, login: T(U.facebook.login) },
1233
+ microsoft: { ...U.microsoft, login: T(U.microsoft.login) },
1234
+ webAuthn: { ...U.webAuthn, login: T(U.webAuthn.login) }
1235
+ }, V = {
1236
+ post: p.post.bind(p),
1147
1237
  baseURL: t,
1148
- axios: s,
1238
+ axios: p,
1239
+ setAccessToken(h) {
1240
+ s = h;
1241
+ },
1242
+ getAccessToken() {
1243
+ return s;
1244
+ },
1245
+ clearAccessToken() {
1246
+ s = null;
1247
+ },
1248
+ setAccessTokenProvider(h) {
1249
+ l?.(), l = null, n = h, s = null, c = null;
1250
+ },
1251
+ onAuthChange(h) {
1252
+ return f.add(h), () => f.delete(h);
1253
+ },
1254
+ useAudience(h, _) {
1255
+ l?.(), n = async () => (await h.mutation({
1256
+ createAudienceAccessToken: {
1257
+ __args: { audience: _ }
1258
+ }
1259
+ })).createAudienceAccessToken, s = null, c = null, l = h.onAuthChange(() => {
1260
+ s = null, c = null;
1261
+ });
1262
+ },
1149
1263
  auth: ft,
1150
- mutation: f,
1151
- query: y,
1152
- config: Ct,
1153
- mail: vt,
1154
- users: Dt,
1155
- model(i) {
1156
- return k(i);
1264
+ mutation: b,
1265
+ query: d,
1266
+ config: ct(d),
1267
+ mail: Jt(b),
1268
+ users: Lt(b, O),
1269
+ model(h) {
1270
+ return P(h);
1157
1271
  },
1158
- roles: Pt(),
1159
- collect: (i, a) => {
1160
- const l = J(i, a);
1161
- return l.data_path = k(i).getDataPath(), l;
1272
+ roles: Gt(d, b),
1273
+ collect: (h, _) => {
1274
+ const y = C(h, _);
1275
+ return y.data_path = z(h).getDataPath(), y;
1162
1276
  },
1163
- list: (i, a) => j(i, a).dataPath(k(i).getDataPath()),
1164
- drive: Ft,
1165
- async collects(i) {
1166
- const a = {}, l = {};
1167
- for (const d in i) {
1168
- const _ = i[d].getQueryPayload();
1169
- l[d] = _.data_path, a[d] = {};
1170
- const w = _.data_path.split(".");
1171
- let F = w[w.length - 1], m = a[d];
1172
- for (const C of w) {
1173
- if (C === F) {
1174
- m[C] = _.query;
1277
+ list: (h, _) => O(h, _).dataPath(z(h).getDataPath()),
1278
+ /**
1279
+ * @deprecated Use `fs.*` from `filesystem` instead.
1280
+ */
1281
+ drive: lt(d, b),
1282
+ async collects(h) {
1283
+ const _ = {}, y = {};
1284
+ for (const k in h) {
1285
+ const v = h[k].getQueryPayload();
1286
+ y[k] = v.data_path, _[k] = {};
1287
+ const M = v.data_path.split(".");
1288
+ let R = M[M.length - 1], D = _[k];
1289
+ for (const B of M) {
1290
+ if (B === R) {
1291
+ D[B] = v.query;
1175
1292
  break;
1176
1293
  }
1177
- m[C] = m[C] || {};
1294
+ D[B] = D[B] || {};
1178
1295
  }
1179
- a[d].__aliasFor = w[0];
1296
+ _[k].__aliasFor = M[0];
1180
1297
  }
1181
- const h = await y(a);
1182
- for (const d in i) {
1183
- const _ = l[d].split(".");
1184
- let w = _[_.length - 1], F = h[d];
1185
- for (const m of _) {
1186
- if (m === w) {
1187
- i[d]._batchData = h[d][m];
1298
+ const A = await d(_);
1299
+ for (const k in h) {
1300
+ const v = y[k].split(".");
1301
+ let M = v[v.length - 1], R = A[k];
1302
+ for (const D of v) {
1303
+ if (D === M) {
1304
+ h[k]._batchData = A[k][D];
1188
1305
  break;
1189
1306
  }
1190
- F[m] = F[m] || {};
1307
+ R[D] = R[D] || {};
1191
1308
  }
1192
1309
  }
1193
- return i;
1310
+ return h;
1194
1311
  }
1195
1312
  };
1196
- return Y(n), n;
1197
- }, ue = j;
1313
+ return _t(V), V;
1314
+ };
1315
+ function oe(t, e = 30) {
1316
+ try {
1317
+ const r = t.split(".")[1];
1318
+ if (!r) return !0;
1319
+ const s = r.replace(/-/g, "+").replace(/_/g, "/"), n = s.padEnd(Math.ceil(s.length / 4) * 4, "="), c = JSON.parse(globalThis.atob(n));
1320
+ return typeof c.exp == "number" ? c.exp <= Math.floor(Date.now() / 1e3) + e : !1;
1321
+ } catch {
1322
+ return !0;
1323
+ }
1324
+ }
1325
+ const Te = L;
1198
1326
  export {
1199
- D as arrayHasFile,
1200
- ft as auth,
1201
- ot as changeExpiredPassword,
1202
- ne as clearModels,
1203
- ce as createClient,
1204
- J as createCollection,
1205
- te as createFileFromBase64,
1206
- ee as createFileFromBase85,
1207
- B as createFileFromString,
1208
- j as createList,
1209
- Ut as createRole,
1210
- wt as createUser,
1211
- G as defaultUserFields,
1212
- L as defineModel,
1213
- ie as defineModels,
1214
- kt as deleteRole,
1215
- bt as deleteUser,
1216
- ct as forgetPassword,
1217
- le as fs,
1218
- M as getApiClient,
1219
- xt as getApiClientOptional,
1220
- Ct as getConfig,
1221
- st as getCurrentUser,
1222
- Ft as getDrive,
1223
- pt as getGrantedRights,
1224
- k as getModel,
1225
- re as hasModel,
1226
- ht as isGranted,
1227
- ue as list,
1228
- ae as listDrives,
1229
- dt as listFiles,
1230
- yt as listFolders,
1231
- se as listModels,
1232
- oe as listPermissions,
1233
- jt as listRoles,
1234
- At as listUsers,
1235
- nt as login,
1236
- it as logout,
1237
- f as mutation,
1238
- N as objectHasFile,
1239
- y as query,
1240
- _t as readFileAsBase64,
1241
- lt as resetPassword,
1242
- Et as sendMail,
1243
- Y as setApiClient,
1244
- Zt as toQuery,
1245
- at as updatePassword,
1246
- Ot as updateUser,
1247
- ut as verifyCode,
1248
- rt as webAuthn
1327
+ N as arrayHasFile,
1328
+ ye as auth,
1329
+ jt as changeExpiredPassword,
1330
+ ge as clearModels,
1331
+ Pt as createAuth,
1332
+ Me as createClient,
1333
+ st as createCollection,
1334
+ ct as createConfig,
1335
+ lt as createDrive,
1336
+ ue as createFileFromBase64,
1337
+ he as createFileFromBase85,
1338
+ tt as createFileFromString,
1339
+ L as createList,
1340
+ Jt as createMail,
1341
+ Se as createRole,
1342
+ Gt as createRoles,
1343
+ ke as createUser,
1344
+ Lt as createUsers,
1345
+ J as defaultUserFields,
1346
+ ot as defineModel,
1347
+ de as defineModels,
1348
+ je as deleteRole,
1349
+ Ce as deleteUser,
1350
+ Mt as forgetPassword,
1351
+ Ee as fs,
1352
+ K as getApiClient,
1353
+ ce as getApiClientOptional,
1354
+ Ue as getConfig,
1355
+ Ut as getCurrentUser,
1356
+ Ae as getDrive,
1357
+ Rt as getGrantedRights,
1358
+ z as getModel,
1359
+ pe as hasModel,
1360
+ Nt as isGranted,
1361
+ Te as list,
1362
+ Fe as listDrives,
1363
+ we as listFiles,
1364
+ me as listFolders,
1365
+ fe as listModels,
1366
+ _e as listPermissions,
1367
+ De as listRoles,
1368
+ Oe as listUsers,
1369
+ Dt as login,
1370
+ St as logout,
1371
+ g as mutation,
1372
+ x as objectHasFile,
1373
+ F as query,
1374
+ be as readFileAsBase64,
1375
+ Et as resetPassword,
1376
+ ve as sendMail,
1377
+ _t as setApiClient,
1378
+ ne as toQuery,
1379
+ vt as updatePassword,
1380
+ Pe as updateUser,
1381
+ Tt as verifyCode,
1382
+ Ot as webAuthn
1249
1383
  };