@arcadeai/design-system 1.5.0 → 1.6.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.
Files changed (45) hide show
  1. package/dist/{arcade-CadnNaba.js → arcade-DzMbb7xi.js} +520 -594
  2. package/dist/components/index.js +302 -300
  3. package/dist/components/ui/atoms/icons/codesandbox.d.ts +3 -0
  4. package/dist/components/ui/atoms/icons/codesandbox.js +26 -0
  5. package/dist/components/ui/atoms/icons/index.d.ts +1 -0
  6. package/dist/components/ui/atoms/icons/index.js +182 -180
  7. package/dist/components/ui/atoms/icons/jira.js +1 -10
  8. package/dist/components/ui/atoms/icons/utils.d.ts +0 -13
  9. package/dist/components/ui/atoms/icons/utils.js +22 -30
  10. package/dist/components/ui/atoms/index.js +285 -283
  11. package/dist/components/ui/index.js +302 -300
  12. package/dist/components/ui/molecules/index.js +1 -1
  13. package/dist/components/ui/molecules/requirement-badges.js +4 -5
  14. package/dist/components/ui/molecules/toolkit-card.js +1 -1
  15. package/dist/components/ui/molecules/toolkit-picker-trigger.js +29 -32
  16. package/dist/components/ui/molecules/toolkit-selection-summary.js +1 -1
  17. package/dist/components/ui/organisms/toolkit-picker/components/search-input.js +3 -4
  18. package/dist/components/ui/organisms/toolkit-picker/components/select-button.js +5 -6
  19. package/dist/components/ui/organisms/toolkit-picker/components/toolkit-card-with-selection.js +1 -1
  20. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.d.ts +11 -3
  21. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.js +141 -99
  22. package/dist/components/ui/organisms/toolkit-picker/index.d.ts +2 -0
  23. package/dist/components/ui/organisms/toolkit-picker/index.js +3 -2
  24. package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.d.ts +2 -0
  25. package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.js +247 -55
  26. package/dist/components/ui/organisms/toolkit-picker/toolkit-picker.js +1 -1
  27. package/dist/lib/arcade/arcade.d.ts +1 -1
  28. package/dist/lib/arcade/arcade.js +3 -2
  29. package/dist/lib/arcade/arcade.test.js +1 -1
  30. package/dist/main.js +351 -343
  31. package/dist/metadata/constants.d.ts +1 -0
  32. package/dist/metadata/constants.js +4 -0
  33. package/dist/metadata/index.d.ts +3 -0
  34. package/dist/metadata/index.js +17 -11
  35. package/dist/metadata/oauth-providers.d.ts +21 -13
  36. package/dist/metadata/oauth-providers.js +98 -72
  37. package/dist/metadata/toolkits.d.ts +1 -21
  38. package/dist/metadata/toolkits.js +443 -273
  39. package/dist/metadata/types.d.ts +40 -0
  40. package/dist/metadata/types.js +1 -0
  41. package/dist/metadata/utils.d.ts +16 -0
  42. package/dist/metadata/utils.js +11 -0
  43. package/dist/{toolkit-card-UG1sZ0Le.js → toolkit-card-CHiL03EY.js} +2 -3
  44. package/dist/web-sgv-FK6q.js +84 -0
  45. package/package.json +1 -1
@@ -1,99 +1,25 @@
1
- import { TOOLKIT_CATALOGUE as tt } from "./metadata/toolkits.js";
2
- import { r as pe } from "./utils-Db4QWi-E.js";
3
- let ye = !1, D, Re, Y, Se, Ee;
4
- function Pe(t, e = { auto: !1 }) {
5
- if (ye)
6
- throw new Error(`you must \`import '@arcadeai/arcadejs/shims/${t.kind}'\` before importing anything else from @arcadeai/arcadejs`);
7
- if (D)
8
- throw new Error(`can't \`import '@arcadeai/arcadejs/shims/${t.kind}'\` after \`import '@arcadeai/arcadejs/shims/${D}'\``);
9
- ye = e.auto, D = t.kind, Re = t.fetch, t.Request, t.Response, t.Headers, t.FormData, t.Blob, Y = t.File, t.ReadableStream, t.getMultipartRequestOptions, Se = t.getDefaultAgent, Ee = t.fileFromPath, t.isFsReadStream;
10
- }
11
- class rt {
12
- constructor(e) {
13
- this.body = e;
14
- }
15
- get [Symbol.toStringTag]() {
16
- return "MultipartBody";
17
- }
18
- }
19
- function ke({ manuallyImported: t } = {}) {
20
- const e = t ? "You may need to use polyfills" : "Add one of these imports before your first `import … from '@arcadeai/arcadejs'`:\n- `import '@arcadeai/arcadejs/shims/node'` (if you're running on Node)\n- `import '@arcadeai/arcadejs/shims/web'` (otherwise)\n";
21
- let r, n, s, o;
22
- try {
23
- r = fetch, n = Request, s = Response, o = Headers;
24
- } catch (i) {
25
- throw new Error(`this environment is missing the following Web Fetch API type: ${i.message}. ${e}`);
26
- }
27
- return {
28
- kind: "web",
29
- fetch: r,
30
- Request: n,
31
- Response: s,
32
- Headers: o,
33
- FormData: (
34
- // @ts-ignore
35
- typeof FormData < "u" ? FormData : class {
36
- // @ts-ignore
37
- constructor() {
38
- throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${e}`);
39
- }
40
- }
41
- ),
42
- Blob: typeof Blob < "u" ? Blob : class {
43
- constructor() {
44
- throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${e}`);
45
- }
46
- },
47
- File: (
48
- // @ts-ignore
49
- typeof File < "u" ? File : class {
50
- // @ts-ignore
51
- constructor() {
52
- throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${e}`);
53
- }
54
- }
55
- ),
56
- ReadableStream: (
57
- // @ts-ignore
58
- typeof ReadableStream < "u" ? ReadableStream : class {
59
- // @ts-ignore
60
- constructor() {
61
- throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${e}`);
62
- }
63
- }
64
- ),
65
- getMultipartRequestOptions: async (i, l) => ({
66
- ...l,
67
- body: new rt(i)
68
- }),
69
- getDefaultAgent: (i) => {
70
- },
71
- fileFromPath: () => {
72
- throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/ArcadeAI/arcade-js#file-uploads");
73
- },
74
- isFsReadStream: (i) => !1
75
- };
76
- }
77
- Pe(ke({ manuallyImported: !0 }));
78
- const Z = "RFC3986", ee = {
1
+ import { k as _e, s as Qe, g as Ge, F as de, f as Je, a as Ye, b as Ze } from "./web-sgv-FK6q.js";
2
+ import { TOOLKIT_CATALOGUE as et } from "./metadata/toolkits.js";
3
+ import { r as he } from "./utils-Db4QWi-E.js";
4
+ const J = "RFC3986", Y = {
79
5
  RFC1738: (t) => String(t).replace(/%20/g, "+"),
80
6
  RFC3986: (t) => String(t)
81
- }, nt = "RFC1738", st = Array.isArray, _ = (() => {
7
+ }, tt = "RFC1738", nt = Array.isArray, _ = (() => {
82
8
  const t = [];
83
9
  for (let e = 0; e < 256; ++e)
84
10
  t.push("%" + ((e < 16 ? "0" : "") + e.toString(16)).toUpperCase());
85
11
  return t;
86
- })(), V = 1024, ot = (t, e, r, n, s) => {
12
+ })(), W = 1024, rt = (t, e, n, r, s) => {
87
13
  if (t.length === 0)
88
14
  return t;
89
15
  let o = t;
90
- if (typeof t == "symbol" ? o = Symbol.prototype.toString.call(t) : typeof t != "string" && (o = String(t)), r === "iso-8859-1")
16
+ if (typeof t == "symbol" ? o = Symbol.prototype.toString.call(t) : typeof t != "string" && (o = String(t)), n === "iso-8859-1")
91
17
  return escape(o).replace(/%u[0-9a-f]{4}/gi, function(l) {
92
18
  return "%26%23" + parseInt(l.slice(2), 16) + "%3B";
93
19
  });
94
20
  let i = "";
95
- for (let l = 0; l < o.length; l += V) {
96
- const c = o.length >= V ? o.slice(l, l + V) : o, u = [];
21
+ for (let l = 0; l < o.length; l += W) {
22
+ const c = o.length >= W ? o.slice(l, l + W) : o, u = [];
97
23
  for (let p = 0; p < c.length; ++p) {
98
24
  let a = c.charCodeAt(p);
99
25
  if (a === 45 || // -
@@ -103,7 +29,7 @@ const Z = "RFC3986", ee = {
103
29
  a >= 48 && a <= 57 || // 0-9
104
30
  a >= 65 && a <= 90 || // a-z
105
31
  a >= 97 && a <= 122 || // A-Z
106
- s === nt && (a === 40 || a === 41)) {
32
+ s === tt && (a === 40 || a === 41)) {
107
33
  u[u.length] = c.charAt(p);
108
34
  continue;
109
35
  }
@@ -125,19 +51,19 @@ const Z = "RFC3986", ee = {
125
51
  }
126
52
  return i;
127
53
  };
128
- function it(t) {
54
+ function st(t) {
129
55
  return !t || typeof t != "object" ? !1 : !!(t.constructor && t.constructor.isBuffer && t.constructor.isBuffer(t));
130
56
  }
131
- function me(t, e) {
132
- if (st(t)) {
133
- const r = [];
134
- for (let n = 0; n < t.length; n += 1)
135
- r.push(e(t[n]));
136
- return r;
57
+ function pe(t, e) {
58
+ if (nt(t)) {
59
+ const n = [];
60
+ for (let r = 0; r < t.length; r += 1)
61
+ n.push(e(t[r]));
62
+ return n;
137
63
  }
138
64
  return e(t);
139
65
  }
140
- const at = Object.prototype.hasOwnProperty, Te = {
66
+ const ot = Object.prototype.hasOwnProperty, Ae = {
141
67
  brackets(t) {
142
68
  return String(t) + "[]";
143
69
  },
@@ -148,9 +74,9 @@ const at = Object.prototype.hasOwnProperty, Te = {
148
74
  repeat(t) {
149
75
  return String(t);
150
76
  }
151
- }, A = Array.isArray, ct = Array.prototype.push, ve = function(t, e) {
152
- ct.apply(t, A(e) ? e : [e]);
153
- }, ut = Date.prototype.toISOString, y = {
77
+ }, A = Array.isArray, it = Array.prototype.push, Se = function(t, e) {
78
+ it.apply(t, A(e) ? e : [e]);
79
+ }, at = Date.prototype.toISOString, y = {
154
80
  addQueryPrefix: !1,
155
81
  allowDots: !1,
156
82
  allowEmptyArrays: !1,
@@ -160,103 +86,103 @@ const at = Object.prototype.hasOwnProperty, Te = {
160
86
  delimiter: "&",
161
87
  encode: !0,
162
88
  encodeDotInKeys: !1,
163
- encoder: ot,
89
+ encoder: rt,
164
90
  encodeValuesOnly: !1,
165
- format: Z,
166
- formatter: ee[Z],
91
+ format: J,
92
+ formatter: Y[J],
167
93
  /** @deprecated */
168
94
  indices: !1,
169
95
  serializeDate(t) {
170
- return ut.call(t);
96
+ return at.call(t);
171
97
  },
172
98
  skipNulls: !1,
173
99
  strictNullHandling: !1
174
100
  };
175
- function lt(t) {
101
+ function ct(t) {
176
102
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || typeof t == "symbol" || typeof t == "bigint";
177
103
  }
178
- const Q = {};
179
- function Ce(t, e, r, n, s, o, i, l, c, u, p, a, h, m, x, E, R, X) {
180
- let f = t, F = X, $ = 0, le = !1;
181
- for (; (F = F.get(Q)) !== void 0 && !le; ) {
182
- const g = F.get(t);
183
- if ($ += 1, typeof g < "u") {
184
- if (g === $)
104
+ const V = {};
105
+ function Re(t, e, n, r, s, o, i, l, c, u, p, a, h, m, b, E, S, z) {
106
+ let f = t, D = z, U = 0, ce = !1;
107
+ for (; (D = D.get(V)) !== void 0 && !ce; ) {
108
+ const g = D.get(t);
109
+ if (U += 1, typeof g < "u") {
110
+ if (g === U)
185
111
  throw new RangeError("Cyclic object value");
186
- le = !0;
112
+ ce = !0;
187
113
  }
188
- typeof F.get(Q) > "u" && ($ = 0);
114
+ typeof D.get(V) > "u" && (U = 0);
189
115
  }
190
- if (typeof u == "function" ? f = u(e, f) : f instanceof Date ? f = h?.(f) : r === "comma" && A(f) && (f = me(f, function(g) {
116
+ if (typeof u == "function" ? f = u(e, f) : f instanceof Date ? f = h?.(f) : n === "comma" && A(f) && (f = pe(f, function(g) {
191
117
  return g instanceof Date ? h?.(g) : g;
192
118
  })), f === null) {
193
119
  if (o)
194
120
  return c && !E ? (
195
121
  // @ts-expect-error
196
- c(e, y.encoder, R, "key", m)
122
+ c(e, y.encoder, S, "key", m)
197
123
  ) : e;
198
124
  f = "";
199
125
  }
200
- if (lt(f) || it(f)) {
126
+ if (ct(f) || st(f)) {
201
127
  if (c) {
202
- const g = E ? e : c(e, y.encoder, R, "key", m);
128
+ const g = E ? e : c(e, y.encoder, S, "key", m);
203
129
  return [
204
- x?.(g) + "=" + // @ts-expect-error
205
- x?.(c(f, y.encoder, R, "value", m))
130
+ b?.(g) + "=" + // @ts-expect-error
131
+ b?.(c(f, y.encoder, S, "value", m))
206
132
  ];
207
133
  }
208
- return [x?.(e) + "=" + x?.(String(f))];
134
+ return [b?.(e) + "=" + b?.(String(f))];
209
135
  }
210
- const K = [];
136
+ const X = [];
211
137
  if (typeof f > "u")
212
- return K;
138
+ return X;
213
139
  let I;
214
- if (r === "comma" && A(f))
215
- E && c && (f = me(f, c)), I = [{ value: f.length > 0 ? f.join(",") || null : void 0 }];
140
+ if (n === "comma" && A(f))
141
+ E && c && (f = pe(f, c)), I = [{ value: f.length > 0 ? f.join(",") || null : void 0 }];
216
142
  else if (A(u))
217
143
  I = u;
218
144
  else {
219
145
  const g = Object.keys(f);
220
146
  I = p ? g.sort(p) : g;
221
147
  }
222
- const fe = l ? String(e).replace(/\./g, "%2E") : String(e), j = n && A(f) && f.length === 1 ? fe + "[]" : fe;
148
+ const ue = l ? String(e).replace(/\./g, "%2E") : String(e), $ = r && A(f) && f.length === 1 ? ue + "[]" : ue;
223
149
  if (s && A(f) && f.length === 0)
224
- return j + "[]";
150
+ return $ + "[]";
225
151
  for (let g = 0; g < I.length; ++g) {
226
- const k = I[g], de = (
152
+ const k = I[g], le = (
227
153
  // @ts-ignore
228
154
  typeof k == "object" && typeof k.value < "u" ? k.value : f[k]
229
155
  );
230
- if (i && de === null)
156
+ if (i && le === null)
231
157
  continue;
232
- const W = a && l ? k.replace(/\./g, "%2E") : k, et = A(f) ? typeof r == "function" ? r(j, W) : j : j + (a ? "." + W : "[" + W + "]");
233
- X.set(t, $);
234
- const he = /* @__PURE__ */ new WeakMap();
235
- he.set(Q, X), ve(K, Ce(
236
- de,
237
- et,
238
- r,
158
+ const K = a && l ? k.replace(/\./g, "%2E") : k, Ve = A(f) ? typeof n == "function" ? n($, K) : $ : $ + (a ? "." + K : "[" + K + "]");
159
+ z.set(t, U);
160
+ const fe = /* @__PURE__ */ new WeakMap();
161
+ fe.set(V, z), Se(X, Re(
162
+ le,
163
+ Ve,
239
164
  n,
165
+ r,
240
166
  s,
241
167
  o,
242
168
  i,
243
169
  l,
244
170
  // @ts-ignore
245
- r === "comma" && E && A(f) ? null : c,
171
+ n === "comma" && E && A(f) ? null : c,
246
172
  u,
247
173
  p,
248
174
  a,
249
175
  h,
250
176
  m,
251
- x,
177
+ b,
252
178
  E,
253
- R,
254
- he
179
+ S,
180
+ fe
255
181
  ));
256
182
  }
257
- return K;
183
+ return X;
258
184
  }
259
- function ft(t = y) {
185
+ function ut(t = y) {
260
186
  if (typeof t.allowEmptyArrays < "u" && typeof t.allowEmptyArrays != "boolean")
261
187
  throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
262
188
  if (typeof t.encodeDotInKeys < "u" && typeof t.encodeDotInKeys != "boolean")
@@ -266,17 +192,17 @@ function ft(t = y) {
266
192
  const e = t.charset || y.charset;
267
193
  if (typeof t.charset < "u" && t.charset !== "utf-8" && t.charset !== "iso-8859-1")
268
194
  throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
269
- let r = Z;
195
+ let n = J;
270
196
  if (typeof t.format < "u") {
271
- if (!at.call(ee, t.format))
197
+ if (!ot.call(Y, t.format))
272
198
  throw new TypeError("Unknown format option provided.");
273
- r = t.format;
199
+ n = t.format;
274
200
  }
275
- const n = ee[r];
201
+ const r = Y[n];
276
202
  let s = y.filter;
277
203
  (typeof t.filter == "function" || A(t.filter)) && (s = t.filter);
278
204
  let o;
279
- if (t.arrayFormat && t.arrayFormat in Te ? o = t.arrayFormat : "indices" in t ? o = t.indices ? "indices" : "repeat" : o = y.arrayFormat, "commaRoundTrip" in t && typeof t.commaRoundTrip != "boolean")
205
+ if (t.arrayFormat && t.arrayFormat in Ae ? o = t.arrayFormat : "indices" in t ? o = t.indices ? "indices" : "repeat" : o = y.arrayFormat, "commaRoundTrip" in t && typeof t.commaRoundTrip != "boolean")
280
206
  throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
281
207
  const i = typeof t.allowDots > "u" ? t.encodeDotInKeys ? !0 : y.allowDots : !!t.allowDots;
282
208
  return {
@@ -294,8 +220,8 @@ function ft(t = y) {
294
220
  encoder: typeof t.encoder == "function" ? t.encoder : y.encoder,
295
221
  encodeValuesOnly: typeof t.encodeValuesOnly == "boolean" ? t.encodeValuesOnly : y.encodeValuesOnly,
296
222
  filter: s,
297
- format: r,
298
- formatter: n,
223
+ format: n,
224
+ formatter: r,
299
225
  serializeDate: typeof t.serializeDate == "function" ? t.serializeDate : y.serializeDate,
300
226
  skipNulls: typeof t.skipNulls == "boolean" ? t.skipNulls : y.skipNulls,
301
227
  // @ts-ignore
@@ -303,175 +229,175 @@ function ft(t = y) {
303
229
  strictNullHandling: typeof t.strictNullHandling == "boolean" ? t.strictNullHandling : y.strictNullHandling
304
230
  };
305
231
  }
306
- function dt(t, e = {}) {
307
- let r = t;
308
- const n = ft(e);
232
+ function lt(t, e = {}) {
233
+ let n = t;
234
+ const r = ut(e);
309
235
  let s, o;
310
- typeof n.filter == "function" ? (o = n.filter, r = o("", r)) : A(n.filter) && (o = n.filter, s = o);
236
+ typeof r.filter == "function" ? (o = r.filter, n = o("", n)) : A(r.filter) && (o = r.filter, s = o);
311
237
  const i = [];
312
- if (typeof r != "object" || r === null)
238
+ if (typeof n != "object" || n === null)
313
239
  return "";
314
- const l = Te[n.arrayFormat], c = l === "comma" && n.commaRoundTrip;
315
- s || (s = Object.keys(r)), n.sort && s.sort(n.sort);
240
+ const l = Ae[r.arrayFormat], c = l === "comma" && r.commaRoundTrip;
241
+ s || (s = Object.keys(n)), r.sort && s.sort(r.sort);
316
242
  const u = /* @__PURE__ */ new WeakMap();
317
243
  for (let h = 0; h < s.length; ++h) {
318
244
  const m = s[h];
319
- n.skipNulls && r[m] === null || ve(i, Ce(
320
- r[m],
245
+ r.skipNulls && n[m] === null || Se(i, Re(
246
+ n[m],
321
247
  m,
322
248
  // @ts-expect-error
323
249
  l,
324
250
  c,
325
- n.allowEmptyArrays,
326
- n.strictNullHandling,
327
- n.skipNulls,
328
- n.encodeDotInKeys,
329
- n.encode ? n.encoder : null,
330
- n.filter,
331
- n.sort,
332
- n.allowDots,
333
- n.serializeDate,
334
- n.format,
335
- n.formatter,
336
- n.encodeValuesOnly,
337
- n.charset,
251
+ r.allowEmptyArrays,
252
+ r.strictNullHandling,
253
+ r.skipNulls,
254
+ r.encodeDotInKeys,
255
+ r.encode ? r.encoder : null,
256
+ r.filter,
257
+ r.sort,
258
+ r.allowDots,
259
+ r.serializeDate,
260
+ r.format,
261
+ r.formatter,
262
+ r.encodeValuesOnly,
263
+ r.charset,
338
264
  u
339
265
  ));
340
266
  }
341
- const p = i.join(n.delimiter);
342
- let a = n.addQueryPrefix === !0 ? "?" : "";
343
- return n.charsetSentinel && (n.charset === "iso-8859-1" ? a += "utf8=%26%2310003%3B&" : a += "utf8=%E2%9C%93&"), p.length > 0 ? a + p : "";
267
+ const p = i.join(r.delimiter);
268
+ let a = r.addQueryPrefix === !0 ? "?" : "";
269
+ return r.charsetSentinel && (r.charset === "iso-8859-1" ? a += "utf8=%26%2310003%3B&" : a += "utf8=%E2%9C%93&"), p.length > 0 ? a + p : "";
344
270
  }
345
271
  const T = "1.9.1";
346
272
  class P extends Error {
347
273
  }
348
274
  class w extends P {
349
- constructor(e, r, n, s) {
350
- super(`${w.makeMessage(e, r, n)}`), this.status = e, this.headers = s, this.error = r;
275
+ constructor(e, n, r, s) {
276
+ super(`${w.makeMessage(e, n, r)}`), this.status = e, this.headers = s, this.error = n;
351
277
  }
352
- static makeMessage(e, r, n) {
353
- const s = r?.message ? typeof r.message == "string" ? r.message : JSON.stringify(r.message) : r ? JSON.stringify(r) : n;
278
+ static makeMessage(e, n, r) {
279
+ const s = n?.message ? typeof n.message == "string" ? n.message : JSON.stringify(n.message) : n ? JSON.stringify(n) : r;
354
280
  return e && s ? `${e} ${s}` : e ? `${e} status code (no body)` : s || "(no status code or body)";
355
281
  }
356
- static generate(e, r, n, s) {
282
+ static generate(e, n, r, s) {
357
283
  if (!e || !s)
358
- return new q({ message: n, cause: re(r) });
359
- const o = r;
360
- return e === 400 ? new De(e, o, n, s) : e === 401 ? new Le(e, o, n, s) : e === 403 ? new Oe(e, o, n, s) : e === 404 ? new Fe(e, o, n, s) : e === 409 ? new $e(e, o, n, s) : e === 422 ? new je(e, o, n, s) : e === 429 ? new Ue(e, o, n, s) : e >= 500 ? new Be(e, o, n, s) : new w(e, o, n, s);
284
+ return new F({ message: r, cause: ee(n) });
285
+ const o = n;
286
+ return e === 400 ? new Pe(e, o, r, s) : e === 401 ? new ke(e, o, r, s) : e === 403 ? new Te(e, o, r, s) : e === 404 ? new Ce(e, o, r, s) : e === 409 ? new ve(e, o, r, s) : e === 422 ? new Ie(e, o, r, s) : e === 429 ? new Le(e, o, r, s) : e >= 500 ? new Oe(e, o, r, s) : new w(e, o, r, s);
361
287
  }
362
288
  }
363
- class te extends w {
289
+ class Z extends w {
364
290
  constructor({ message: e } = {}) {
365
291
  super(void 0, void 0, e || "Request was aborted.", void 0);
366
292
  }
367
293
  }
368
- class q extends w {
369
- constructor({ message: e, cause: r }) {
370
- super(void 0, void 0, e || "Connection error.", void 0), r && (this.cause = r);
294
+ class F extends w {
295
+ constructor({ message: e, cause: n }) {
296
+ super(void 0, void 0, e || "Connection error.", void 0), n && (this.cause = n);
371
297
  }
372
298
  }
373
- class Ie extends q {
299
+ class Ee extends F {
374
300
  constructor({ message: e } = {}) {
375
301
  super({ message: e ?? "Request timed out." });
376
302
  }
377
303
  }
378
- class De extends w {
304
+ class Pe extends w {
379
305
  }
380
- class Le extends w {
306
+ class ke extends w {
381
307
  }
382
- class Oe extends w {
308
+ class Te extends w {
383
309
  }
384
- class Fe extends w {
310
+ class Ce extends w {
385
311
  }
386
- class $e extends w {
312
+ class ve extends w {
387
313
  }
388
- class je extends w {
314
+ class Ie extends w {
389
315
  }
390
- class Ue extends w {
316
+ class Le extends w {
391
317
  }
392
- class Be extends w {
318
+ class Oe extends w {
393
319
  }
394
- const Me = () => {
395
- D || Pe(ke(), { auto: !0 });
320
+ const De = () => {
321
+ _e || Qe(Ge(), { auto: !0 });
396
322
  };
397
- Me();
398
- const ht = (t) => t != null && typeof t == "object" && typeof t.url == "string" && typeof t.blob == "function", pt = (t) => t != null && typeof t == "object" && typeof t.name == "string" && typeof t.lastModified == "number" && N(t), N = (t) => t != null && typeof t == "object" && typeof t.size == "number" && typeof t.type == "string" && typeof t.text == "function" && typeof t.slice == "function" && typeof t.arrayBuffer == "function";
399
- async function yt(t, e, r) {
400
- if (t = await t, pt(t))
323
+ De();
324
+ const ft = (t) => t != null && typeof t == "object" && typeof t.url == "string" && typeof t.blob == "function", dt = (t) => t != null && typeof t == "object" && typeof t.name == "string" && typeof t.lastModified == "number" && q(t), q = (t) => t != null && typeof t == "object" && typeof t.size == "number" && typeof t.type == "string" && typeof t.text == "function" && typeof t.slice == "function" && typeof t.arrayBuffer == "function";
325
+ async function ht(t, e, n) {
326
+ if (t = await t, dt(t))
401
327
  return t;
402
- if (ht(t)) {
328
+ if (ft(t)) {
403
329
  const s = await t.blob();
404
330
  e || (e = new URL(t.url).pathname.split(/[\\/]/).pop() ?? "unknown_file");
405
- const o = N(s) ? [await s.arrayBuffer()] : [s];
406
- return new Y(o, e, r);
331
+ const o = q(s) ? [await s.arrayBuffer()] : [s];
332
+ return new de(o, e, n);
407
333
  }
408
- const n = await mt(t);
409
- if (e || (e = wt(t) ?? "unknown_file"), !r?.type) {
410
- const s = n[0]?.type;
411
- typeof s == "string" && (r = { ...r, type: s });
334
+ const r = await pt(t);
335
+ if (e || (e = mt(t) ?? "unknown_file"), !n?.type) {
336
+ const s = r[0]?.type;
337
+ typeof s == "string" && (n = { ...n, type: s });
412
338
  }
413
- return new Y(n, e, r);
339
+ return new de(r, e, n);
414
340
  }
415
- async function mt(t) {
341
+ async function pt(t) {
416
342
  let e = [];
417
343
  if (typeof t == "string" || ArrayBuffer.isView(t) || // includes Uint8Array, Buffer, etc.
418
344
  t instanceof ArrayBuffer)
419
345
  e.push(t);
420
- else if (N(t))
346
+ else if (q(t))
421
347
  e.push(await t.arrayBuffer());
422
- else if (bt(t))
423
- for await (const r of t)
424
- e.push(r);
348
+ else if (gt(t))
349
+ for await (const n of t)
350
+ e.push(n);
425
351
  else
426
- throw new Error(`Unexpected data type: ${typeof t}; constructor: ${t?.constructor?.name}; props: ${gt(t)}`);
352
+ throw new Error(`Unexpected data type: ${typeof t}; constructor: ${t?.constructor?.name}; props: ${yt(t)}`);
427
353
  return e;
428
354
  }
429
- function gt(t) {
430
- return `[${Object.getOwnPropertyNames(t).map((r) => `"${r}"`).join(", ")}]`;
355
+ function yt(t) {
356
+ return `[${Object.getOwnPropertyNames(t).map((n) => `"${n}"`).join(", ")}]`;
431
357
  }
432
- function wt(t) {
433
- return G(t.name) || G(t.filename) || // For fs.ReadStream
434
- G(t.path)?.split(/[\\/]/).pop();
358
+ function mt(t) {
359
+ return Q(t.name) || Q(t.filename) || // For fs.ReadStream
360
+ Q(t.path)?.split(/[\\/]/).pop();
435
361
  }
436
- const G = (t) => {
362
+ const Q = (t) => {
437
363
  if (typeof t == "string")
438
364
  return t;
439
365
  if (typeof Buffer < "u" && t instanceof Buffer)
440
366
  return String(t);
441
- }, bt = (t) => t != null && typeof t == "object" && typeof t[Symbol.asyncIterator] == "function", ge = (t) => t && typeof t == "object" && t.body && t[Symbol.toStringTag] === "MultipartBody";
442
- var qe = function(t, e, r, n, s) {
443
- if (n === "m") throw new TypeError("Private method is not writable");
444
- if (n === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
367
+ }, gt = (t) => t != null && typeof t == "object" && typeof t[Symbol.asyncIterator] == "function", ye = (t) => t && typeof t == "object" && t.body && t[Symbol.toStringTag] === "MultipartBody";
368
+ var Ue = function(t, e, n, r, s) {
369
+ if (r === "m") throw new TypeError("Private method is not writable");
370
+ if (r === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
445
371
  if (typeof e == "function" ? t !== e || !s : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
446
- return n === "a" ? s.call(t, r) : s ? s.value = r : e.set(t, r), r;
447
- }, Ne = function(t, e, r, n) {
448
- if (r === "a" && !n) throw new TypeError("Private accessor was defined without a getter");
449
- if (typeof e == "function" ? t !== e || !n : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
450
- return r === "m" ? n : r === "a" ? n.call(t) : n ? n.value : e.get(t);
451
- }, M, U;
452
- Me();
453
- async function He(t) {
372
+ return r === "a" ? s.call(t, n) : s ? s.value = n : e.set(t, n), n;
373
+ }, $e = function(t, e, n, r) {
374
+ if (n === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
375
+ if (typeof e == "function" ? t !== e || !r : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
376
+ return n === "m" ? r : n === "a" ? r.call(t) : r ? r.value : e.get(t);
377
+ }, M, j;
378
+ De();
379
+ async function je(t) {
454
380
  const { response: e } = t;
455
381
  if (e.status === 204)
456
382
  return null;
457
383
  if (t.options.__binaryResponse)
458
384
  return e;
459
- const n = e.headers.get("content-type")?.split(";")[0]?.trim();
460
- if (n?.includes("application/json") || n?.endsWith("+json")) {
385
+ const r = e.headers.get("content-type")?.split(";")[0]?.trim();
386
+ if (r?.includes("application/json") || r?.endsWith("+json")) {
461
387
  const i = await e.json();
462
388
  return L("response", e.status, e.url, e.headers, i), i;
463
389
  }
464
390
  const o = await e.text();
465
391
  return L("response", e.status, e.url, e.headers, o), o;
466
392
  }
467
- class H extends Promise {
468
- constructor(e, r = He) {
469
- super((n) => {
470
- n(null);
471
- }), this.responsePromise = e, this.parseResponse = r;
393
+ class B extends Promise {
394
+ constructor(e, n = je) {
395
+ super((r) => {
396
+ r(null);
397
+ }), this.responsePromise = e, this.parseResponse = n;
472
398
  }
473
399
  _thenUnwrap(e) {
474
- return new H(this.responsePromise, async (r) => e(await this.parseResponse(r), r));
400
+ return new B(this.responsePromise, async (n) => e(await this.parseResponse(n), n));
475
401
  }
476
402
  /**
477
403
  * Gets the raw `Response` instance instead of parsing the response
@@ -503,14 +429,14 @@ class H extends Promise {
503
429
  * - `import '@arcadeai/arcadejs/shims/web'` (otherwise)
504
430
  */
505
431
  async withResponse() {
506
- const [e, r] = await Promise.all([this.parse(), this.asResponse()]);
507
- return { data: e, response: r };
432
+ const [e, n] = await Promise.all([this.parse(), this.asResponse()]);
433
+ return { data: e, response: n };
508
434
  }
509
435
  parse() {
510
436
  return this.parsedPromise || (this.parsedPromise = this.responsePromise.then(this.parseResponse)), this.parsedPromise;
511
437
  }
512
- then(e, r) {
513
- return this.parse().then(e, r);
438
+ then(e, n) {
439
+ return this.parse().then(e, n);
514
440
  }
515
441
  catch(e) {
516
442
  return this.parse().catch(e);
@@ -519,17 +445,17 @@ class H extends Promise {
519
445
  return this.parse().finally(e);
520
446
  }
521
447
  }
522
- class xt {
448
+ class wt {
523
449
  constructor({
524
450
  baseURL: e,
525
- baseURLOverridden: r,
526
- maxRetries: n = 2,
451
+ baseURLOverridden: n,
452
+ maxRetries: r = 2,
527
453
  timeout: s = 6e4,
528
454
  // 1 minute
529
455
  httpAgent: o,
530
456
  fetch: i
531
457
  }) {
532
- M.set(this, void 0), this.baseURL = e, qe(this, M, r, "f"), this.maxRetries = J("maxRetries", n), this.timeout = J("timeout", s), this.httpAgent = o, this.fetch = i ?? Re;
458
+ M.set(this, void 0), this.baseURL = e, Ue(this, M, n, "f"), this.maxRetries = G("maxRetries", r), this.timeout = G("timeout", s), this.httpAgent = o, this.fetch = i ?? Je;
533
459
  }
534
460
  authHeaders(e) {
535
461
  return {};
@@ -547,41 +473,41 @@ class xt {
547
473
  Accept: "application/json",
548
474
  ...["head", "get"].includes(e.method) ? {} : { "Content-Type": "application/json" },
549
475
  "User-Agent": this.getUserAgent(),
550
- ...kt(),
476
+ ...Et(),
551
477
  ...this.authHeaders(e)
552
478
  };
553
479
  }
554
480
  /**
555
481
  * Override this to add your own headers validation:
556
482
  */
557
- validateHeaders(e, r) {
483
+ validateHeaders(e, n) {
558
484
  }
559
485
  defaultIdempotencyKey() {
560
- return `stainless-node-retry-${Dt()}`;
486
+ return `stainless-node-retry-${vt()}`;
561
487
  }
562
- get(e, r) {
563
- return this.methodRequest("get", e, r);
488
+ get(e, n) {
489
+ return this.methodRequest("get", e, n);
564
490
  }
565
- post(e, r) {
566
- return this.methodRequest("post", e, r);
491
+ post(e, n) {
492
+ return this.methodRequest("post", e, n);
567
493
  }
568
- patch(e, r) {
569
- return this.methodRequest("patch", e, r);
494
+ patch(e, n) {
495
+ return this.methodRequest("patch", e, n);
570
496
  }
571
- put(e, r) {
572
- return this.methodRequest("put", e, r);
497
+ put(e, n) {
498
+ return this.methodRequest("put", e, n);
573
499
  }
574
- delete(e, r) {
575
- return this.methodRequest("delete", e, r);
500
+ delete(e, n) {
501
+ return this.methodRequest("delete", e, n);
576
502
  }
577
- methodRequest(e, r, n) {
578
- return this.request(Promise.resolve(n).then(async (s) => {
579
- const o = s && N(s?.body) ? new DataView(await s.body.arrayBuffer()) : s?.body instanceof DataView ? s.body : s?.body instanceof ArrayBuffer ? new DataView(s.body) : s && ArrayBuffer.isView(s?.body) ? new DataView(s.body.buffer) : s?.body;
580
- return { method: e, path: r, ...s, body: o };
503
+ methodRequest(e, n, r) {
504
+ return this.request(Promise.resolve(r).then(async (s) => {
505
+ const o = s && q(s?.body) ? new DataView(await s.body.arrayBuffer()) : s?.body instanceof DataView ? s.body : s?.body instanceof ArrayBuffer ? new DataView(s.body) : s && ArrayBuffer.isView(s?.body) ? new DataView(s.body.buffer) : s?.body;
506
+ return { method: e, path: n, ...s, body: o };
581
507
  }));
582
508
  }
583
- getAPIList(e, r, n) {
584
- return this.requestAPIList(r, { method: "get", path: e, ...n });
509
+ getAPIList(e, n, r) {
510
+ return this.requestAPIList(n, { method: "get", path: e, ...r });
585
511
  }
586
512
  calculateContentLength(e) {
587
513
  if (typeof e == "string") {
@@ -593,27 +519,27 @@ class xt {
593
519
  return e.byteLength.toString();
594
520
  return null;
595
521
  }
596
- async buildRequest(e, { retryCount: r = 0 } = {}) {
597
- const n = { ...e }, { method: s, path: o, query: i, defaultBaseURL: l, headers: c = {} } = n, u = ArrayBuffer.isView(n.body) || n.__binaryRequest && typeof n.body == "string" ? n.body : ge(n.body) ? n.body.body : n.body ? JSON.stringify(n.body, null, 2) : null, p = this.calculateContentLength(u), a = this.buildURL(o, i, l);
598
- "timeout" in n && J("timeout", n.timeout), n.timeout = n.timeout ?? this.timeout;
599
- const h = n.httpAgent ?? this.httpAgent ?? Se(a), m = n.timeout + 1e3;
522
+ async buildRequest(e, { retryCount: n = 0 } = {}) {
523
+ const r = { ...e }, { method: s, path: o, query: i, defaultBaseURL: l, headers: c = {} } = r, u = ArrayBuffer.isView(r.body) || r.__binaryRequest && typeof r.body == "string" ? r.body : ye(r.body) ? r.body.body : r.body ? JSON.stringify(r.body, null, 2) : null, p = this.calculateContentLength(u), a = this.buildURL(o, i, l);
524
+ "timeout" in r && G("timeout", r.timeout), r.timeout = r.timeout ?? this.timeout;
525
+ const h = r.httpAgent ?? this.httpAgent ?? Ye(a), m = r.timeout + 1e3;
600
526
  typeof h?.options?.timeout == "number" && m > (h.options.timeout ?? 0) && (h.options.timeout = m), this.idempotencyHeader && s !== "get" && (e.idempotencyKey || (e.idempotencyKey = this.defaultIdempotencyKey()), c[this.idempotencyHeader] = e.idempotencyKey);
601
- const x = this.buildHeaders({ options: n, headers: c, contentLength: p, retryCount: r });
527
+ const b = this.buildHeaders({ options: r, headers: c, contentLength: p, retryCount: n });
602
528
  return { req: {
603
529
  method: s,
604
530
  ...u && { body: u },
605
- headers: x,
531
+ headers: b,
606
532
  ...h && { agent: h },
607
533
  // @ts-ignore node-fetch uses a custom AbortSignal type that is
608
534
  // not compatible with standard web types
609
- signal: n.signal ?? null
610
- }, url: a, timeout: n.timeout };
535
+ signal: r.signal ?? null
536
+ }, url: a, timeout: r.timeout };
611
537
  }
612
- buildHeaders({ options: e, headers: r, contentLength: n, retryCount: s }) {
538
+ buildHeaders({ options: e, headers: n, contentLength: r, retryCount: s }) {
613
539
  const o = {};
614
- n && (o["content-length"] = n);
540
+ r && (o["content-length"] = r);
615
541
  const i = this.defaultHeaders(e);
616
- return Ae(o, i), Ae(o, r), ge(e.body) && D !== "node" && delete o["content-type"], B(i, "x-stainless-retry-count") === void 0 && B(r, "x-stainless-retry-count") === void 0 && (o["x-stainless-retry-count"] = String(s)), B(i, "x-stainless-timeout") === void 0 && B(r, "x-stainless-timeout") === void 0 && e.timeout && (o["x-stainless-timeout"] = String(Math.trunc(e.timeout / 1e3))), this.validateHeaders(o, r), o;
542
+ return be(o, i), be(o, n), ye(e.body) && _e !== "node" && delete o["content-type"], N(i, "x-stainless-retry-count") === void 0 && N(n, "x-stainless-retry-count") === void 0 && (o["x-stainless-retry-count"] = String(s)), N(i, "x-stainless-timeout") === void 0 && N(n, "x-stainless-timeout") === void 0 && e.timeout && (o["x-stainless-timeout"] = String(Math.trunc(e.timeout / 1e3))), this.validateHeaders(o, n), o;
617
543
  }
618
544
  /**
619
545
  * Used as a callback for mutating the given `FinalRequestOptions` object.
@@ -626,65 +552,65 @@ class xt {
626
552
  * This is useful for cases where you want to add certain headers based off of
627
553
  * the request properties, e.g. `method` or `url`.
628
554
  */
629
- async prepareRequest(e, { url: r, options: n }) {
555
+ async prepareRequest(e, { url: n, options: r }) {
630
556
  }
631
557
  parseHeaders(e) {
632
- return e ? Symbol.iterator in e ? Object.fromEntries(Array.from(e).map((r) => [...r])) : { ...e } : {};
558
+ return e ? Symbol.iterator in e ? Object.fromEntries(Array.from(e).map((n) => [...n])) : { ...e } : {};
633
559
  }
634
- makeStatusError(e, r, n, s) {
635
- return w.generate(e, r, n, s);
560
+ makeStatusError(e, n, r, s) {
561
+ return w.generate(e, n, r, s);
636
562
  }
637
- request(e, r = null) {
638
- return new H(this.makeRequest(e, r));
563
+ request(e, n = null) {
564
+ return new B(this.makeRequest(e, n));
639
565
  }
640
- async makeRequest(e, r) {
641
- const n = await e, s = n.maxRetries ?? this.maxRetries;
642
- r == null && (r = s), await this.prepareOptions(n);
643
- const { req: o, url: i, timeout: l } = await this.buildRequest(n, {
644
- retryCount: s - r
566
+ async makeRequest(e, n) {
567
+ const r = await e, s = r.maxRetries ?? this.maxRetries;
568
+ n == null && (n = s), await this.prepareOptions(r);
569
+ const { req: o, url: i, timeout: l } = await this.buildRequest(r, {
570
+ retryCount: s - n
645
571
  });
646
- if (await this.prepareRequest(o, { url: i, options: n }), L("request", i, n, o.headers), n.signal?.aborted)
647
- throw new te();
648
- const c = new AbortController(), u = await this.fetchWithTimeout(i, o, l, c).catch(re);
572
+ if (await this.prepareRequest(o, { url: i, options: r }), L("request", i, r, o.headers), r.signal?.aborted)
573
+ throw new Z();
574
+ const c = new AbortController(), u = await this.fetchWithTimeout(i, o, l, c).catch(ee);
649
575
  if (u instanceof Error) {
650
- if (n.signal?.aborted)
651
- throw new te();
652
- if (r)
653
- return this.retryRequest(n, r);
654
- throw u.name === "AbortError" ? new Ie() : new q({ cause: u });
576
+ if (r.signal?.aborted)
577
+ throw new Z();
578
+ if (n)
579
+ return this.retryRequest(r, n);
580
+ throw u.name === "AbortError" ? new Ee() : new F({ cause: u });
655
581
  }
656
- const p = Rt(u.headers);
582
+ const p = _t(u.headers);
657
583
  if (!u.ok) {
658
- if (r && this.shouldRetry(u)) {
659
- const R = `retrying, ${r} attempts remaining`;
660
- return L(`response (error; ${R})`, u.status, i, p), this.retryRequest(n, r, p);
584
+ if (n && this.shouldRetry(u)) {
585
+ const S = `retrying, ${n} attempts remaining`;
586
+ return L(`response (error; ${S})`, u.status, i, p), this.retryRequest(r, n, p);
661
587
  }
662
- const a = await u.text().catch((R) => re(R).message), h = Tt(a), m = h ? void 0 : a;
663
- throw L(`response (error; ${r ? "(error; no more retries left)" : "(error; not retryable)"})`, u.status, i, p, m), this.makeStatusError(u.status, h, m, p);
588
+ const a = await u.text().catch((S) => ee(S).message), h = Pt(a), m = h ? void 0 : a;
589
+ throw L(`response (error; ${n ? "(error; no more retries left)" : "(error; not retryable)"})`, u.status, i, p, m), this.makeStatusError(u.status, h, m, p);
664
590
  }
665
- return { response: u, options: n, controller: c };
591
+ return { response: u, options: r, controller: c };
666
592
  }
667
- requestAPIList(e, r) {
668
- const n = this.makeRequest(r, null);
669
- return new At(this, n, e);
593
+ requestAPIList(e, n) {
594
+ const r = this.makeRequest(n, null);
595
+ return new bt(this, r, e);
670
596
  }
671
- buildURL(e, r, n) {
672
- const s = !Ne(this, M, "f") && n || this.baseURL, o = Ct(e) ? new URL(e) : new URL(s + (s.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), i = this.defaultQuery();
673
- return ze(i) || (r = { ...i, ...r }), typeof r == "object" && r && !Array.isArray(r) && (o.search = this.stringifyQuery(r)), o.toString();
597
+ buildURL(e, n, r) {
598
+ const s = !$e(this, M, "f") && r || this.baseURL, o = Tt(e) ? new URL(e) : new URL(s + (s.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), i = this.defaultQuery();
599
+ return Ne(i) || (n = { ...i, ...n }), typeof n == "object" && n && !Array.isArray(n) && (o.search = this.stringifyQuery(n)), o.toString();
674
600
  }
675
601
  stringifyQuery(e) {
676
- return Object.entries(e).filter(([r, n]) => typeof n < "u").map(([r, n]) => {
677
- if (typeof n == "string" || typeof n == "number" || typeof n == "boolean")
678
- return `${encodeURIComponent(r)}=${encodeURIComponent(n)}`;
679
- if (n === null)
680
- return `${encodeURIComponent(r)}=`;
681
- throw new P(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
602
+ return Object.entries(e).filter(([n, r]) => typeof r < "u").map(([n, r]) => {
603
+ if (typeof r == "string" || typeof r == "number" || typeof r == "boolean")
604
+ return `${encodeURIComponent(n)}=${encodeURIComponent(r)}`;
605
+ if (r === null)
606
+ return `${encodeURIComponent(n)}=`;
607
+ throw new P(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
682
608
  }).join("&");
683
609
  }
684
- async fetchWithTimeout(e, r, n, s) {
685
- const { signal: o, ...i } = r || {};
610
+ async fetchWithTimeout(e, n, r, s) {
611
+ const { signal: o, ...i } = n || {};
686
612
  o && o.addEventListener("abort", () => s.abort());
687
- const l = setTimeout(() => s.abort(), n), c = {
613
+ const l = setTimeout(() => s.abort(), r), c = {
688
614
  signal: s.signal,
689
615
  ...i
690
616
  };
@@ -694,29 +620,29 @@ class xt {
694
620
  });
695
621
  }
696
622
  shouldRetry(e) {
697
- const r = e.headers.get("x-should-retry");
698
- return r === "true" ? !0 : r === "false" ? !1 : e.status === 408 || e.status === 409 || e.status === 429 || e.status >= 500;
623
+ const n = e.headers.get("x-should-retry");
624
+ return n === "true" ? !0 : n === "false" ? !1 : e.status === 408 || e.status === 409 || e.status === 429 || e.status >= 500;
699
625
  }
700
- async retryRequest(e, r, n) {
626
+ async retryRequest(e, n, r) {
701
627
  let s;
702
- const o = n?.["retry-after-ms"];
628
+ const o = r?.["retry-after-ms"];
703
629
  if (o) {
704
630
  const l = parseFloat(o);
705
631
  Number.isNaN(l) || (s = l);
706
632
  }
707
- const i = n?.["retry-after"];
633
+ const i = r?.["retry-after"];
708
634
  if (i && !s) {
709
635
  const l = parseFloat(i);
710
636
  Number.isNaN(l) ? s = Date.parse(i) - Date.now() : s = l * 1e3;
711
637
  }
712
638
  if (!(s && 0 <= s && s < 60 * 1e3)) {
713
639
  const l = e.maxRetries ?? this.maxRetries;
714
- s = this.calculateDefaultRetryTimeoutMillis(r, l);
640
+ s = this.calculateDefaultRetryTimeoutMillis(n, l);
715
641
  }
716
- return await It(s), this.makeRequest(e, r - 1);
642
+ return await Ct(s), this.makeRequest(e, n - 1);
717
643
  }
718
- calculateDefaultRetryTimeoutMillis(e, r) {
719
- const o = r - e, i = Math.min(0.5 * Math.pow(2, o), 8), l = 1 - Math.random() * 0.25;
644
+ calculateDefaultRetryTimeoutMillis(e, n) {
645
+ const o = n - e, i = Math.min(0.5 * Math.pow(2, o), 8), l = 1 - Math.random() * 0.25;
720
646
  return i * l * 1e3;
721
647
  }
722
648
  getUserAgent() {
@@ -724,9 +650,9 @@ class xt {
724
650
  }
725
651
  }
726
652
  M = /* @__PURE__ */ new WeakMap();
727
- class _t {
728
- constructor(e, r, n, s) {
729
- U.set(this, void 0), qe(this, U, e, "f"), this.options = s, this.response = r, this.body = n;
653
+ class xt {
654
+ constructor(e, n, r, s) {
655
+ j.set(this, void 0), Ue(this, j, e, "f"), this.options = s, this.response = n, this.body = r;
730
656
  }
731
657
  hasNextPage() {
732
658
  return this.getPaginatedItems().length ? this.nextPageInfo() != null : !1;
@@ -735,31 +661,31 @@ class _t {
735
661
  const e = this.nextPageInfo();
736
662
  if (!e)
737
663
  throw new P("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
738
- const r = { ...this.options };
739
- if ("params" in e && typeof r.query == "object")
740
- r.query = { ...r.query, ...e.params };
664
+ const n = { ...this.options };
665
+ if ("params" in e && typeof n.query == "object")
666
+ n.query = { ...n.query, ...e.params };
741
667
  else if ("url" in e) {
742
- const n = [...Object.entries(r.query || {}), ...e.url.searchParams.entries()];
743
- for (const [s, o] of n)
668
+ const r = [...Object.entries(n.query || {}), ...e.url.searchParams.entries()];
669
+ for (const [s, o] of r)
744
670
  e.url.searchParams.set(s, o);
745
- r.query = void 0, r.path = e.url.toString();
671
+ n.query = void 0, n.path = e.url.toString();
746
672
  }
747
- return await Ne(this, U, "f").requestAPIList(this.constructor, r);
673
+ return await $e(this, j, "f").requestAPIList(this.constructor, n);
748
674
  }
749
675
  async *iterPages() {
750
676
  let e = this;
751
677
  for (yield e; e.hasNextPage(); )
752
678
  e = await e.getNextPage(), yield e;
753
679
  }
754
- async *[(U = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
680
+ async *[(j = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
755
681
  for await (const e of this.iterPages())
756
- for (const r of e.getPaginatedItems())
757
- yield r;
682
+ for (const n of e.getPaginatedItems())
683
+ yield n;
758
684
  }
759
685
  }
760
- class At extends H {
761
- constructor(e, r, n) {
762
- super(r, async (s) => new n(e, s.response, await He(s), s.options));
686
+ class bt extends B {
687
+ constructor(e, n, r) {
688
+ super(n, async (s) => new r(e, s.response, await je(s), s.options));
763
689
  }
764
690
  /**
765
691
  * Allow auto-paginating iteration on an unawaited list call, eg:
@@ -770,19 +696,19 @@ class At extends H {
770
696
  */
771
697
  async *[Symbol.asyncIterator]() {
772
698
  const e = await this;
773
- for await (const r of e)
774
- yield r;
699
+ for await (const n of e)
700
+ yield n;
775
701
  }
776
702
  }
777
- const Rt = (t) => new Proxy(Object.fromEntries(
703
+ const _t = (t) => new Proxy(Object.fromEntries(
778
704
  // @ts-ignore
779
705
  t.entries()
780
706
  ), {
781
- get(e, r) {
782
- const n = r.toString();
783
- return e[n.toLowerCase()] || e[n];
707
+ get(e, n) {
708
+ const r = n.toString();
709
+ return e[r.toLowerCase()] || e[r];
784
710
  }
785
- }), St = {
711
+ }), At = {
786
712
  method: !0,
787
713
  path: !0,
788
714
  query: !0,
@@ -797,13 +723,13 @@ const Rt = (t) => new Proxy(Object.fromEntries(
797
723
  idempotencyKey: !0,
798
724
  __binaryRequest: !0,
799
725
  __binaryResponse: !0
800
- }, S = (t) => typeof t == "object" && t !== null && !ze(t) && Object.keys(t).every((e) => Xe(St, e)), Et = () => {
726
+ }, R = (t) => typeof t == "object" && t !== null && !Ne(t) && Object.keys(t).every((e) => Me(At, e)), St = () => {
801
727
  if (typeof Deno < "u" && Deno.build != null)
802
728
  return {
803
729
  "X-Stainless-Lang": "js",
804
730
  "X-Stainless-Package-Version": T,
805
- "X-Stainless-OS": be(Deno.build.os),
806
- "X-Stainless-Arch": we(Deno.build.arch),
731
+ "X-Stainless-OS": ge(Deno.build.os),
732
+ "X-Stainless-Arch": me(Deno.build.arch),
807
733
  "X-Stainless-Runtime": "deno",
808
734
  "X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : Deno.version?.deno ?? "unknown"
809
735
  };
@@ -820,12 +746,12 @@ const Rt = (t) => new Proxy(Object.fromEntries(
820
746
  return {
821
747
  "X-Stainless-Lang": "js",
822
748
  "X-Stainless-Package-Version": T,
823
- "X-Stainless-OS": be(process.platform),
824
- "X-Stainless-Arch": we(process.arch),
749
+ "X-Stainless-OS": ge(process.platform),
750
+ "X-Stainless-Arch": me(process.arch),
825
751
  "X-Stainless-Runtime": "node",
826
752
  "X-Stainless-Runtime-Version": process.version
827
753
  };
828
- const t = Pt();
754
+ const t = Rt();
829
755
  return t ? {
830
756
  "X-Stainless-Lang": "js",
831
757
  "X-Stainless-Package-Version": T,
@@ -842,7 +768,7 @@ const Rt = (t) => new Proxy(Object.fromEntries(
842
768
  "X-Stainless-Runtime-Version": "unknown"
843
769
  };
844
770
  };
845
- function Pt() {
771
+ function Rt() {
846
772
  if (typeof navigator > "u" || !navigator)
847
773
  return null;
848
774
  const t = [
@@ -853,30 +779,30 @@ function Pt() {
853
779
  { key: "firefox", pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
854
780
  { key: "safari", pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }
855
781
  ];
856
- for (const { key: e, pattern: r } of t) {
857
- const n = r.exec(navigator.userAgent);
858
- if (n) {
859
- const s = n[1] || 0, o = n[2] || 0, i = n[3] || 0;
782
+ for (const { key: e, pattern: n } of t) {
783
+ const r = n.exec(navigator.userAgent);
784
+ if (r) {
785
+ const s = r[1] || 0, o = r[2] || 0, i = r[3] || 0;
860
786
  return { browser: e, version: `${s}.${o}.${i}` };
861
787
  }
862
788
  }
863
789
  return null;
864
790
  }
865
- const we = (t) => t === "x32" ? "x32" : t === "x86_64" || t === "x64" ? "x64" : t === "arm" ? "arm" : t === "aarch64" || t === "arm64" ? "arm64" : t ? `other:${t}` : "unknown", be = (t) => (t = t.toLowerCase(), t.includes("ios") ? "iOS" : t === "android" ? "Android" : t === "darwin" ? "MacOS" : t === "win32" ? "Windows" : t === "freebsd" ? "FreeBSD" : t === "openbsd" ? "OpenBSD" : t === "linux" ? "Linux" : t ? `Other:${t}` : "Unknown");
866
- let xe;
867
- const kt = () => xe ?? (xe = Et()), Tt = (t) => {
791
+ const me = (t) => t === "x32" ? "x32" : t === "x86_64" || t === "x64" ? "x64" : t === "arm" ? "arm" : t === "aarch64" || t === "arm64" ? "arm64" : t ? `other:${t}` : "unknown", ge = (t) => (t = t.toLowerCase(), t.includes("ios") ? "iOS" : t === "android" ? "Android" : t === "darwin" ? "MacOS" : t === "win32" ? "Windows" : t === "freebsd" ? "FreeBSD" : t === "openbsd" ? "OpenBSD" : t === "linux" ? "Linux" : t ? `Other:${t}` : "Unknown");
792
+ let we;
793
+ const Et = () => we ?? (we = St()), Pt = (t) => {
868
794
  try {
869
795
  return JSON.parse(t);
870
796
  } catch {
871
797
  return;
872
798
  }
873
- }, vt = /^[a-z][a-z0-9+.-]*:/i, Ct = (t) => vt.test(t), It = (t) => new Promise((e) => setTimeout(e, t)), J = (t, e) => {
799
+ }, kt = /^[a-z][a-z0-9+.-]*:/i, Tt = (t) => kt.test(t), Ct = (t) => new Promise((e) => setTimeout(e, t)), G = (t, e) => {
874
800
  if (typeof e != "number" || !Number.isInteger(e))
875
801
  throw new P(`${t} must be an integer`);
876
802
  if (e < 0)
877
803
  throw new P(`${t} must be a positive integer`);
878
804
  return e;
879
- }, re = (t) => {
805
+ }, ee = (t) => {
880
806
  if (t instanceof Error)
881
807
  return t;
882
808
  if (typeof t == "object" && t !== null)
@@ -885,56 +811,56 @@ const kt = () => xe ?? (xe = Et()), Tt = (t) => {
885
811
  } catch {
886
812
  }
887
813
  return new Error(t);
888
- }, _e = (t) => {
814
+ }, xe = (t) => {
889
815
  if (typeof process < "u")
890
816
  return process.env?.[t]?.trim() ?? void 0;
891
817
  if (typeof Deno < "u")
892
818
  return Deno.env?.get?.(t)?.trim();
893
819
  };
894
- function ze(t) {
820
+ function Ne(t) {
895
821
  if (!t)
896
822
  return !0;
897
823
  for (const e in t)
898
824
  return !1;
899
825
  return !0;
900
826
  }
901
- function Xe(t, e) {
827
+ function Me(t, e) {
902
828
  return Object.prototype.hasOwnProperty.call(t, e);
903
829
  }
904
- function Ae(t, e) {
905
- for (const r in e) {
906
- if (!Xe(e, r))
830
+ function be(t, e) {
831
+ for (const n in e) {
832
+ if (!Me(e, n))
907
833
  continue;
908
- const n = r.toLowerCase();
909
- if (!n)
834
+ const r = n.toLowerCase();
835
+ if (!r)
910
836
  continue;
911
- const s = e[r];
912
- s === null ? delete t[n] : s !== void 0 && (t[n] = s);
837
+ const s = e[n];
838
+ s === null ? delete t[r] : s !== void 0 && (t[r] = s);
913
839
  }
914
840
  }
915
841
  function L(t, ...e) {
916
842
  typeof process < "u" && process?.env?.DEBUG === "true" && console.log(`Arcade:DEBUG:${t}`, ...e);
917
843
  }
918
- const Dt = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
844
+ const vt = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
919
845
  const e = Math.random() * 16 | 0;
920
846
  return (t === "x" ? e : e & 3 | 8).toString(16);
921
- }), Lt = (t) => typeof t?.get == "function", B = (t, e) => {
922
- const r = e.toLowerCase();
923
- if (Lt(t)) {
924
- const n = e[0]?.toUpperCase() + e.substring(1).replace(/([^\w])(\w)/g, (s, o, i) => o + i.toUpperCase());
925
- for (const s of [e, r, e.toUpperCase(), n]) {
847
+ }), It = (t) => typeof t?.get == "function", N = (t, e) => {
848
+ const n = e.toLowerCase();
849
+ if (It(t)) {
850
+ const r = e[0]?.toUpperCase() + e.substring(1).replace(/([^\w])(\w)/g, (s, o, i) => o + i.toUpperCase());
851
+ for (const s of [e, n, e.toUpperCase(), r]) {
926
852
  const o = t.get(s);
927
853
  if (o)
928
854
  return o;
929
855
  }
930
856
  }
931
- for (const [n, s] of Object.entries(t))
932
- if (n.toLowerCase() === r)
857
+ for (const [r, s] of Object.entries(t))
858
+ if (r.toLowerCase() === n)
933
859
  return Array.isArray(s) ? (s.length <= 1 || console.warn(`Received ${s.length} entries for the ${e} header, using the first entry.`), s[0]) : s;
934
860
  };
935
- class O extends _t {
936
- constructor(e, r, n, s) {
937
- super(e, r, n, s), this.items = n.items || [], this.total_count = n.total_count || 0, this.offset = n.offset || 0;
861
+ class O extends xt {
862
+ constructor(e, n, r, s) {
863
+ super(e, n, r, s), this.items = r.items || [], this.total_count = r.total_count || 0, this.offset = r.offset || 0;
938
864
  }
939
865
  getPaginatedItems() {
940
866
  return this.items ?? [];
@@ -946,28 +872,28 @@ class O extends _t {
946
872
  return null;
947
873
  if ("params" in e)
948
874
  return e.params;
949
- const r = Object.fromEntries(e.url.searchParams);
950
- return Object.keys(r).length ? r : null;
875
+ const n = Object.fromEntries(e.url.searchParams);
876
+ return Object.keys(n).length ? n : null;
951
877
  }
952
878
  nextPageInfo() {
953
879
  const e = this.offset;
954
880
  if (!e)
955
881
  return null;
956
- const r = this.getPaginatedItems().length, n = e + r, s = this.total_count;
957
- return s && n < s ? { params: { offset: n } } : null;
882
+ const n = this.getPaginatedItems().length, r = e + n, s = this.total_count;
883
+ return s && r < s ? { params: { offset: r } } : null;
958
884
  }
959
885
  }
960
- class b {
886
+ class x {
961
887
  constructor(e) {
962
888
  this._client = e;
963
889
  }
964
890
  }
965
- class Ke extends b {
891
+ class Fe extends x {
966
892
  /**
967
893
  * Create a new auth provider
968
894
  */
969
- create(e, r) {
970
- return this._client.post("/v1/admin/auth_providers", { body: e, ...r });
895
+ create(e, n) {
896
+ return this._client.post("/v1/admin/auth_providers", { body: e, ...n });
971
897
  }
972
898
  /**
973
899
  * List a page of auth providers that are available to the caller
@@ -978,23 +904,23 @@ class Ke extends b {
978
904
  /**
979
905
  * Delete a specific auth provider
980
906
  */
981
- delete(e, r) {
982
- return this._client.delete(`/v1/admin/auth_providers/${e}`, r);
907
+ delete(e, n) {
908
+ return this._client.delete(`/v1/admin/auth_providers/${e}`, n);
983
909
  }
984
910
  /**
985
911
  * Get the details of a specific auth provider
986
912
  */
987
- get(e, r) {
988
- return this._client.get(`/v1/admin/auth_providers/${e}`, r);
913
+ get(e, n) {
914
+ return this._client.get(`/v1/admin/auth_providers/${e}`, n);
989
915
  }
990
916
  /**
991
917
  * Patch an existing auth provider
992
918
  */
993
- patch(e, r, n) {
994
- return this._client.patch(`/v1/admin/auth_providers/${e}`, { body: r, ...n });
919
+ patch(e, n, r) {
920
+ return this._client.patch(`/v1/admin/auth_providers/${e}`, { body: n, ...r });
995
921
  }
996
922
  }
997
- class We extends b {
923
+ class qe extends x {
998
924
  /**
999
925
  * List all secrets that are visible to the caller
1000
926
  */
@@ -1004,49 +930,49 @@ class We extends b {
1004
930
  /**
1005
931
  * Delete a secret by its ID
1006
932
  */
1007
- delete(e, r) {
933
+ delete(e, n) {
1008
934
  return this._client.delete(`/v1/admin/secrets/${e}`, {
1009
- ...r,
1010
- headers: { Accept: "*/*", ...r?.headers }
935
+ ...n,
936
+ headers: { Accept: "*/*", ...n?.headers }
1011
937
  });
1012
938
  }
1013
939
  }
1014
- class ne extends b {
1015
- list(e = {}, r) {
1016
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/admin/user_connections", se, {
940
+ class te extends x {
941
+ list(e = {}, n) {
942
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/admin/user_connections", ne, {
1017
943
  query: e,
1018
- ...r
944
+ ...n
1019
945
  });
1020
946
  }
1021
947
  /**
1022
948
  * Delete a user/auth provider connection
1023
949
  */
1024
- delete(e, r) {
950
+ delete(e, n) {
1025
951
  return this._client.delete(`/v1/admin/user_connections/${e}`, {
1026
- ...r,
1027
- headers: { Accept: "*/*", ...r?.headers }
952
+ ...n,
953
+ headers: { Accept: "*/*", ...n?.headers }
1028
954
  });
1029
955
  }
1030
956
  }
1031
- class se extends O {
957
+ class ne extends O {
1032
958
  }
1033
- ne.UserConnectionResponsesOffsetPage = se;
1034
- class v extends b {
959
+ te.UserConnectionResponsesOffsetPage = ne;
960
+ class C extends x {
1035
961
  constructor() {
1036
- super(...arguments), this.userConnections = new ne(this._client), this.authProviders = new Ke(this._client), this.secrets = new We(this._client);
962
+ super(...arguments), this.userConnections = new te(this._client), this.authProviders = new Fe(this._client), this.secrets = new qe(this._client);
1037
963
  }
1038
964
  }
1039
- v.UserConnections = ne;
1040
- v.UserConnectionResponsesOffsetPage = se;
1041
- v.AuthProviders = Ke;
1042
- v.Secrets = We;
1043
- const Ot = 45;
1044
- class Ft extends Error {
965
+ C.UserConnections = te;
966
+ C.UserConnectionResponsesOffsetPage = ne;
967
+ C.AuthProviders = Fe;
968
+ C.Secrets = qe;
969
+ const Lt = 45;
970
+ class Ot extends Error {
1045
971
  constructor(e) {
1046
972
  super(e), this.name = "AuthorizationError";
1047
973
  }
1048
974
  }
1049
- class Ve extends b {
975
+ class Be extends x {
1050
976
  /**
1051
977
  * Starts the authorization process for a given provider and scopes.
1052
978
  * @param userId - The user ID for which authorization is being requested
@@ -1061,9 +987,9 @@ class Ve extends b {
1061
987
  * const authResponse = await client.auth.start("user@example.com", "github");
1062
988
  * ```
1063
989
  */
1064
- start(e, r, n = {}) {
1065
- const { providerType: s = "oauth2", scopes: o = [] } = n, i = {
1066
- provider_id: r,
990
+ start(e, n, r = {}) {
991
+ const { providerType: s = "oauth2", scopes: o = [] } = r, i = {
992
+ provider_id: n,
1067
993
  provider_type: s,
1068
994
  oauth2: {
1069
995
  scopes: o
@@ -1077,22 +1003,22 @@ class Ve extends b {
1077
1003
  /**
1078
1004
  * Starts the authorization process for given authorization requirements
1079
1005
  */
1080
- authorize(e, r) {
1081
- return this._client.post("/v1/auth/authorize", { body: e, ...r });
1006
+ authorize(e, n) {
1007
+ return this._client.post("/v1/auth/authorize", { body: e, ...n });
1082
1008
  }
1083
1009
  /**
1084
1010
  * Confirms a user's details during an authorization flow
1085
1011
  */
1086
- confirmUser(e, r) {
1087
- return this._client.post("/v1/auth/confirm_user", { body: e, ...r });
1012
+ confirmUser(e, n) {
1013
+ return this._client.post("/v1/auth/confirm_user", { body: e, ...n });
1088
1014
  }
1089
1015
  /**
1090
1016
  * Checks the status of an ongoing authorization process for a specific tool. If
1091
1017
  * 'wait' param is present, does not respond until either the auth status becomes
1092
1018
  * completed or the timeout is reached.
1093
1019
  */
1094
- status(e, r) {
1095
- return this._client.get("/v1/auth/status", { query: e, ...r });
1020
+ status(e, n) {
1021
+ return this._client.get("/v1/auth/status", { query: e, ...n });
1096
1022
  }
1097
1023
  /**
1098
1024
  * Waits for the authorization process to complete.
@@ -1114,37 +1040,37 @@ class Ve extends b {
1114
1040
  * ```
1115
1041
  */
1116
1042
  async waitForCompletion(e) {
1117
- let r, n;
1043
+ let n, r;
1118
1044
  if (typeof e == "string")
1119
- r = e, n = { status: "pending" };
1045
+ n = e, r = { status: "pending" };
1120
1046
  else {
1121
1047
  if (!e.id)
1122
- throw new Ft("Authorization ID is required");
1123
- r = e.id, n = e;
1048
+ throw new Ot("Authorization ID is required");
1049
+ n = e.id, r = e;
1124
1050
  }
1125
- for (; n.status !== "completed"; )
1126
- n = await this.status({
1127
- id: r,
1128
- wait: Ot
1051
+ for (; r.status !== "completed"; )
1052
+ r = await this.status({
1053
+ id: n,
1054
+ wait: Lt
1129
1055
  });
1130
- return n;
1056
+ return r;
1131
1057
  }
1132
1058
  }
1133
- class Qe extends b {
1059
+ class He extends x {
1134
1060
  /**
1135
1061
  * Talk to different LLM Chat APIs via OpenAI's API
1136
1062
  */
1137
- create(e, r) {
1138
- return this._client.post("/v1/chat/completions", { body: e, ...r });
1063
+ create(e, n) {
1064
+ return this._client.post("/v1/chat/completions", { body: e, ...n });
1139
1065
  }
1140
1066
  }
1141
- class oe extends b {
1067
+ class re extends x {
1142
1068
  constructor() {
1143
- super(...arguments), this.completions = new Qe(this._client);
1069
+ super(...arguments), this.completions = new He(this._client);
1144
1070
  }
1145
1071
  }
1146
- oe.Completions = Qe;
1147
- class Ge extends b {
1072
+ re.Completions = He;
1073
+ class ze extends x {
1148
1074
  /**
1149
1075
  * Engine Health
1150
1076
  */
@@ -1152,111 +1078,111 @@ class Ge extends b {
1152
1078
  return this._client.get("/v1/health", e);
1153
1079
  }
1154
1080
  }
1155
- class ie extends b {
1156
- list(e = {}, r) {
1157
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/formatted_tools", ae, {
1081
+ class se extends x {
1082
+ list(e = {}, n) {
1083
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/formatted_tools", oe, {
1158
1084
  query: e,
1159
- ...r
1085
+ ...n
1160
1086
  });
1161
1087
  }
1162
- get(e, r = {}, n) {
1163
- return S(r) ? this.get(e, {}, r) : this._client.get(`/v1/formatted_tools/${e}`, { query: r, ...n });
1088
+ get(e, n = {}, r) {
1089
+ return R(n) ? this.get(e, {}, n) : this._client.get(`/v1/formatted_tools/${e}`, { query: n, ...r });
1164
1090
  }
1165
1091
  }
1166
- class ae extends O {
1092
+ class oe extends O {
1167
1093
  }
1168
- ie.FormattedListResponsesOffsetPage = ae;
1169
- class Je extends b {
1170
- list(e = {}, r) {
1171
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/scheduled_tools", $t, { query: e, ...r });
1094
+ se.FormattedListResponsesOffsetPage = oe;
1095
+ class Xe extends x {
1096
+ list(e = {}, n) {
1097
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/scheduled_tools", Dt, { query: e, ...n });
1172
1098
  }
1173
1099
  /**
1174
1100
  * Returns the details for a specific scheduled tool execution
1175
1101
  */
1176
- get(e, r) {
1177
- return this._client.get(`/v1/scheduled_tools/${e}`, r);
1102
+ get(e, n) {
1103
+ return this._client.get(`/v1/scheduled_tools/${e}`, n);
1178
1104
  }
1179
1105
  }
1180
- class C extends b {
1106
+ class v extends x {
1181
1107
  constructor() {
1182
- super(...arguments), this.scheduled = new Je(this._client), this.formatted = new ie(this._client);
1108
+ super(...arguments), this.scheduled = new Xe(this._client), this.formatted = new se(this._client);
1183
1109
  }
1184
- list(e = {}, r) {
1185
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/tools", z, { query: e, ...r });
1110
+ list(e = {}, n) {
1111
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/tools", H, { query: e, ...n });
1186
1112
  }
1187
1113
  /**
1188
1114
  * Authorizes a user for a specific tool by name
1189
1115
  */
1190
- authorize(e, r) {
1191
- return this._client.post("/v1/tools/authorize", { body: e, ...r });
1116
+ authorize(e, n) {
1117
+ return this._client.post("/v1/tools/authorize", { body: e, ...n });
1192
1118
  }
1193
1119
  /**
1194
1120
  * Executes a tool by name and arguments
1195
1121
  */
1196
- execute(e, r) {
1197
- return this._client.post("/v1/tools/execute", { body: e, ...r });
1122
+ execute(e, n) {
1123
+ return this._client.post("/v1/tools/execute", { body: e, ...n });
1198
1124
  }
1199
- get(e, r = {}, n) {
1200
- return S(r) ? this.get(e, {}, r) : this._client.get(`/v1/tools/${e}`, { query: r, ...n });
1125
+ get(e, n = {}, r) {
1126
+ return R(n) ? this.get(e, {}, n) : this._client.get(`/v1/tools/${e}`, { query: n, ...r });
1201
1127
  }
1202
1128
  }
1203
- class z extends O {
1129
+ class H extends O {
1204
1130
  }
1205
- class $t extends O {
1131
+ class Dt extends O {
1206
1132
  }
1207
- C.ToolDefinitionsOffsetPage = z;
1208
- C.Scheduled = Je;
1209
- C.Formatted = ie;
1210
- C.FormattedListResponsesOffsetPage = ae;
1211
- class ce extends b {
1133
+ v.ToolDefinitionsOffsetPage = H;
1134
+ v.Scheduled = Xe;
1135
+ v.Formatted = se;
1136
+ v.FormattedListResponsesOffsetPage = oe;
1137
+ class ie extends x {
1212
1138
  /**
1213
1139
  * Create a worker
1214
1140
  */
1215
- create(e, r) {
1216
- return this._client.post("/v1/workers", { body: e, ...r });
1141
+ create(e, n) {
1142
+ return this._client.post("/v1/workers", { body: e, ...n });
1217
1143
  }
1218
1144
  /**
1219
1145
  * Update a worker
1220
1146
  */
1221
- update(e, r, n) {
1222
- return this._client.patch(`/v1/workers/${e}`, { body: r, ...n });
1147
+ update(e, n, r) {
1148
+ return this._client.patch(`/v1/workers/${e}`, { body: n, ...r });
1223
1149
  }
1224
- list(e = {}, r) {
1225
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/workers", ue, { query: e, ...r });
1150
+ list(e = {}, n) {
1151
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/workers", ae, { query: e, ...n });
1226
1152
  }
1227
1153
  /**
1228
1154
  * Delete a worker
1229
1155
  */
1230
- delete(e, r) {
1156
+ delete(e, n) {
1231
1157
  return this._client.delete(`/v1/workers/${e}`, {
1232
- ...r,
1233
- headers: { Accept: "*/*", ...r?.headers }
1158
+ ...n,
1159
+ headers: { Accept: "*/*", ...n?.headers }
1234
1160
  });
1235
1161
  }
1236
1162
  /**
1237
1163
  * Get a worker by ID
1238
1164
  */
1239
- get(e, r) {
1240
- return this._client.get(`/v1/workers/${e}`, r);
1165
+ get(e, n) {
1166
+ return this._client.get(`/v1/workers/${e}`, n);
1241
1167
  }
1242
1168
  /**
1243
1169
  * Get the health of a worker
1244
1170
  */
1245
- health(e, r) {
1246
- return this._client.get(`/v1/workers/${e}/health`, r);
1171
+ health(e, n) {
1172
+ return this._client.get(`/v1/workers/${e}/health`, n);
1247
1173
  }
1248
- tools(e, r = {}, n) {
1249
- return S(r) ? this.tools(e, {}, r) : this._client.getAPIList(`/v1/workers/${e}/tools`, z, {
1250
- query: r,
1251
- ...n
1174
+ tools(e, n = {}, r) {
1175
+ return R(n) ? this.tools(e, {}, n) : this._client.getAPIList(`/v1/workers/${e}/tools`, H, {
1176
+ query: n,
1177
+ ...r
1252
1178
  });
1253
1179
  }
1254
1180
  }
1255
- class ue extends O {
1181
+ class ae extends O {
1256
1182
  }
1257
- ce.WorkerResponsesOffsetPage = ue;
1258
- var Ye, Ze;
1259
- class d extends xt {
1183
+ ie.WorkerResponsesOffsetPage = ae;
1184
+ var Ke, We;
1185
+ class d extends wt {
1260
1186
  /**
1261
1187
  * API Client for interfacing with the Arcade API.
1262
1188
  *
@@ -1269,12 +1195,12 @@ class d extends xt {
1269
1195
  * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
1270
1196
  * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
1271
1197
  */
1272
- constructor({ baseURL: e = _e("ARCADE_BASE_URL"), apiKey: r = _e("ARCADE_API_KEY"), ...n } = {}) {
1273
- if (r === void 0)
1198
+ constructor({ baseURL: e = xe("ARCADE_BASE_URL"), apiKey: n = xe("ARCADE_API_KEY"), ...r } = {}) {
1199
+ if (n === void 0)
1274
1200
  throw new P("The ARCADE_API_KEY environment variable is missing or empty; either provide it, or instantiate the Arcade client with an apiKey option, like new Arcade({ apiKey: 'My API Key' }).");
1275
1201
  const s = {
1276
- apiKey: r,
1277
- ...n,
1202
+ apiKey: n,
1203
+ ...r,
1278
1204
  baseURL: e || "https://api.arcade.dev"
1279
1205
  };
1280
1206
  super({
@@ -1284,7 +1210,7 @@ class d extends xt {
1284
1210
  httpAgent: s.httpAgent,
1285
1211
  maxRetries: s.maxRetries,
1286
1212
  fetch: s.fetch
1287
- }), Ye.add(this), this.admin = new v(this), this.auth = new Ve(this), this.health = new Ge(this), this.chat = new oe(this), this.tools = new C(this), this.workers = new ce(this), this._options = s, this.idempotencyHeader = "Idempotency-Key", this.apiKey = r;
1213
+ }), Ke.add(this), this.admin = new C(this), this.auth = new Be(this), this.health = new ze(this), this.chat = new re(this), this.tools = new v(this), this.workers = new ie(this), this._options = s, this.idempotencyHeader = "Idempotency-Key", this.apiKey = n;
1288
1214
  }
1289
1215
  defaultQuery() {
1290
1216
  return this._options.defaultQuery;
@@ -1299,43 +1225,43 @@ class d extends xt {
1299
1225
  return { Authorization: this.apiKey };
1300
1226
  }
1301
1227
  stringifyQuery(e) {
1302
- return dt(e, { arrayFormat: "comma" });
1228
+ return lt(e, { arrayFormat: "comma" });
1303
1229
  }
1304
1230
  }
1305
- Ze = d, Ye = /* @__PURE__ */ new WeakSet();
1306
- d.Arcade = Ze;
1231
+ We = d, Ke = /* @__PURE__ */ new WeakSet();
1232
+ d.Arcade = We;
1307
1233
  d.DEFAULT_TIMEOUT = 6e4;
1308
1234
  d.ArcadeError = P;
1309
1235
  d.APIError = w;
1310
- d.APIConnectionError = q;
1311
- d.APIConnectionTimeoutError = Ie;
1312
- d.APIUserAbortError = te;
1313
- d.NotFoundError = Fe;
1314
- d.ConflictError = $e;
1315
- d.RateLimitError = Ue;
1316
- d.BadRequestError = De;
1317
- d.AuthenticationError = Le;
1318
- d.InternalServerError = Be;
1319
- d.PermissionDeniedError = Oe;
1320
- d.UnprocessableEntityError = je;
1321
- d.toFile = yt;
1322
- d.fileFromPath = Ee;
1323
- d.Admin = v;
1324
- d.Auth = Ve;
1325
- d.Health = Ge;
1326
- d.Chat = oe;
1327
- d.Tools = C;
1328
- d.ToolDefinitionsOffsetPage = z;
1329
- d.Workers = ce;
1330
- d.WorkerResponsesOffsetPage = ue;
1331
- const jt = /[._\-\s]+/, Ut = /([a-z])([A-Z])/g, Bt = /\s+/;
1332
- class Kt {
1236
+ d.APIConnectionError = F;
1237
+ d.APIConnectionTimeoutError = Ee;
1238
+ d.APIUserAbortError = Z;
1239
+ d.NotFoundError = Ce;
1240
+ d.ConflictError = ve;
1241
+ d.RateLimitError = Le;
1242
+ d.BadRequestError = Pe;
1243
+ d.AuthenticationError = ke;
1244
+ d.InternalServerError = Oe;
1245
+ d.PermissionDeniedError = Te;
1246
+ d.UnprocessableEntityError = Ie;
1247
+ d.toFile = ht;
1248
+ d.fileFromPath = Ze;
1249
+ d.Admin = C;
1250
+ d.Auth = Be;
1251
+ d.Health = ze;
1252
+ d.Chat = re;
1253
+ d.Tools = v;
1254
+ d.ToolDefinitionsOffsetPage = H;
1255
+ d.Workers = ie;
1256
+ d.WorkerResponsesOffsetPage = ae;
1257
+ const Ut = /[._\-\s]+/, $t = /([a-z])([A-Z])/g, jt = /\s+/;
1258
+ class qt {
1333
1259
  #e;
1334
1260
  constructor(e) {
1335
- const { accessToken: r, apiKey: n, arcadeClientId: s, baseURL: o } = e, i = n ?? pe("ARCADE_API_KEY"), l = !!i, c = {};
1336
- s && (c["Arcade-Client-Id"] = s), !l && r && (c.Authorization = `Bearer ${r}`);
1261
+ const { accessToken: n, apiKey: r, arcadeClientId: s, baseURL: o } = e, i = r ?? he("ARCADE_API_KEY"), l = !!i, c = {};
1262
+ s && (c["Arcade-Client-Id"] = s), !l && n && (c.Authorization = `Bearer ${n}`);
1337
1263
  const u = {
1338
- baseURL: o ?? pe("ARCADE_BASE_URL"),
1264
+ baseURL: o ?? he("ARCADE_BASE_URL"),
1339
1265
  defaultHeaders: c,
1340
1266
  apiKey: i ?? ""
1341
1267
  };
@@ -1345,28 +1271,28 @@ class Kt {
1345
1271
  return new d(e);
1346
1272
  }
1347
1273
  async getAllTools(e = {}) {
1348
- const { limit: r = 1e3, offset: n = 0, toolkit: s } = e;
1274
+ const { limit: n = 1e3, offset: r = 0, toolkit: s } = e;
1349
1275
  return (await this.#e.tools.list({
1350
- limit: r,
1351
- offset: n,
1276
+ limit: n,
1277
+ offset: r,
1352
1278
  toolkit: s
1353
1279
  })).items;
1354
1280
  }
1355
1281
  async groupToolsBy(e) {
1356
- const r = await this.getAllTools(), n = /* @__PURE__ */ new Map();
1357
- for (const s of r) {
1282
+ const n = await this.getAllTools(), r = /* @__PURE__ */ new Map();
1283
+ for (const s of n) {
1358
1284
  const o = s[e];
1359
- typeof o == "string" && n.set(o, s);
1285
+ typeof o == "string" && r.set(o, s);
1360
1286
  }
1361
- return n;
1287
+ return r;
1362
1288
  }
1363
1289
  async getToolkits() {
1364
- const e = await this.getAllTools(), r = /* @__PURE__ */ new Map();
1365
- for (const n of e) {
1366
- const s = n.toolkit.name;
1367
- let o = r.get(s);
1290
+ const e = await this.getAllTools(), n = /* @__PURE__ */ new Map();
1291
+ for (const r of e) {
1292
+ const s = r.toolkit.name;
1293
+ let o = n.get(s);
1368
1294
  o || (o = {
1369
- ...n.toolkit,
1295
+ ...r.toolkit,
1370
1296
  tools: [],
1371
1297
  requirements: {
1372
1298
  met: !0,
@@ -1374,9 +1300,9 @@ class Kt {
1374
1300
  authorization: [],
1375
1301
  scopes: {}
1376
1302
  }
1377
- }, r.set(s, o)), o.tools.push(n), n.requirements && this.applyToolRequirements(o, n.requirements);
1303
+ }, n.set(s, o)), o.tools.push(r), r.requirements && this.applyToolRequirements(o, r.requirements);
1378
1304
  }
1379
- return r;
1305
+ return n;
1380
1306
  }
1381
1307
  async getToolsForToolkit(e) {
1382
1308
  return (await this.#e.tools.list({
@@ -1384,81 +1310,81 @@ class Kt {
1384
1310
  limit: 1e3
1385
1311
  })).items;
1386
1312
  }
1387
- applyToolRequirements(e, r) {
1388
- if (!r)
1313
+ applyToolRequirements(e, n) {
1314
+ if (!n)
1389
1315
  return;
1390
1316
  e.requirements.secrets = this.mergeSecrets(
1391
- r.secrets ?? [],
1317
+ n.secrets ?? [],
1392
1318
  e.requirements.secrets ?? []
1393
1319
  ), e.requirements.authorization = this.mergeAuthorizations(
1394
- r.authorization,
1320
+ n.authorization,
1395
1321
  e.requirements.authorization ?? []
1396
1322
  );
1397
- const n = r.authorization?.provider_id, s = r.authorization?.oauth2?.scopes ?? [];
1398
- n && s.length && (e.requirements.scopes = this.mergeScopes(
1399
- n,
1323
+ const r = n.authorization?.provider_id, s = n.authorization?.oauth2?.scopes ?? [];
1324
+ r && s.length && (e.requirements.scopes = this.mergeScopes(
1325
+ r,
1400
1326
  s,
1401
1327
  e.requirements.scopes ?? {}
1402
- )), e.requirements.met = !!(e.requirements.met && (r.met ?? !0));
1328
+ )), e.requirements.met = !!(e.requirements.met && (n.met ?? !0));
1403
1329
  }
1404
- mergeSecrets(e = [], r = []) {
1330
+ mergeSecrets(e = [], n = []) {
1405
1331
  if (e.length === 0)
1406
- return r;
1407
- const n = /* @__PURE__ */ new Map();
1408
- for (const s of r)
1409
- n.set(s.key, { ...s });
1332
+ return n;
1333
+ const r = /* @__PURE__ */ new Map();
1334
+ for (const s of n)
1335
+ r.set(s.key, { ...s });
1410
1336
  for (const s of e) {
1411
- const o = n.get(s.key);
1337
+ const o = r.get(s.key);
1412
1338
  if (!o) {
1413
- n.set(s.key, { ...s });
1339
+ r.set(s.key, { ...s });
1414
1340
  continue;
1415
1341
  }
1416
1342
  const i = !!(o.met || s.met), l = s.status_reason ?? o.status_reason;
1417
- n.set(s.key, { key: s.key, met: i, status_reason: l });
1343
+ r.set(s.key, { key: s.key, met: i, status_reason: l });
1418
1344
  }
1419
- return Array.from(n.values());
1345
+ return Array.from(r.values());
1420
1346
  }
1421
- mergeAuthorizations(e, r = []) {
1347
+ mergeAuthorizations(e, n = []) {
1422
1348
  if (!e?.provider_id)
1423
- return r;
1424
- const n = new Map(r.map((i) => [i.provider_id, { ...i }])), s = n.get(e.provider_id);
1349
+ return n;
1350
+ const r = new Map(n.map((i) => [i.provider_id, { ...i }])), s = r.get(e.provider_id);
1425
1351
  if (!s)
1426
- return n.set(e.provider_id, { ...e }), Array.from(n.values());
1352
+ return r.set(e.provider_id, { ...e }), Array.from(r.values());
1427
1353
  const o = new Set(s.oauth2?.scopes ?? []);
1428
1354
  for (const i of e.oauth2?.scopes ?? [])
1429
1355
  o.add(i);
1430
- return n.set(e.provider_id, {
1356
+ return r.set(e.provider_id, {
1431
1357
  ...s,
1432
1358
  oauth2: {
1433
1359
  ...s.oauth2 ?? {},
1434
1360
  scopes: Array.from(o)
1435
1361
  }
1436
- }), Array.from(n.values());
1362
+ }), Array.from(r.values());
1437
1363
  }
1438
- mergeScopes(e, r = [], n = {}) {
1439
- if (!e || r.length === 0)
1440
- return n;
1441
- const s = new Set(n[e] ?? []);
1442
- for (const o of r)
1364
+ mergeScopes(e, n = [], r = {}) {
1365
+ if (!e || n.length === 0)
1366
+ return r;
1367
+ const s = new Set(r[e] ?? []);
1368
+ for (const o of n)
1443
1369
  s.add(o);
1444
- return { ...n, [e]: Array.from(s) };
1370
+ return { ...r, [e]: Array.from(s) };
1445
1371
  }
1446
1372
  /**
1447
1373
  * Pre-compute requirements summary for optimal UI performance.
1448
1374
  * This eliminates the need for runtime transformation in UI components.
1449
1375
  */
1450
1376
  computeRequirementsSummary(e) {
1451
- const r = e?.secrets?.length ? {
1377
+ const n = e?.secrets?.length ? {
1452
1378
  configured: e.secrets.filter((s) => s.met === !0).map((s) => s.key),
1453
1379
  pending: e.secrets.filter((s) => s.met === !1).map((s) => s.key)
1454
- } : void 0, n = e?.authorization?.length ? {
1380
+ } : void 0, r = e?.authorization?.length ? {
1455
1381
  providers: e.authorization.filter((s) => s.provider_id || s.id).map((s) => ({
1456
1382
  id: s.provider_id || s.id || "",
1457
1383
  status: s.status,
1458
1384
  scopes: s.oauth2?.scopes || []
1459
1385
  }))
1460
1386
  } : void 0;
1461
- return { secrets: r, oauth: n };
1387
+ return { secrets: n, oauth: r };
1462
1388
  }
1463
1389
  /**
1464
1390
  * Process raw toolkit data into an optimized collection with pre-computed search indices.
@@ -1470,7 +1396,7 @@ class Kt {
1470
1396
  * - Toolkit/tool mapping for quick relationships
1471
1397
  */
1472
1398
  async getProcessedToolkitCollection() {
1473
- const e = await this.getToolkits(), r = [], n = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = {
1399
+ const e = await this.getToolkits(), n = [], r = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = {
1474
1400
  toolkitsByName: /* @__PURE__ */ new Map(),
1475
1401
  toolsByName: /* @__PURE__ */ new Map()
1476
1402
  };
@@ -1485,9 +1411,9 @@ class Kt {
1485
1411
  ...c,
1486
1412
  searchableText: u,
1487
1413
  requirementsSummary: p,
1488
- metadata: tt[c.name]
1414
+ metadata: et[c.name]
1489
1415
  };
1490
- r.push(a), s.set(l, a), i.toolkitsByName.set(l.toLowerCase(), a);
1416
+ n.push(a), s.set(l, a), i.toolkitsByName.set(l.toLowerCase(), a);
1491
1417
  for (const h of c.tools) {
1492
1418
  const m = this.normalizeText([
1493
1419
  h.name,
@@ -1495,19 +1421,19 @@ class Kt {
1495
1421
  h.description ?? "",
1496
1422
  c.name,
1497
1423
  c.description ?? ""
1498
- ]), x = {
1424
+ ]), b = {
1499
1425
  ...h,
1500
1426
  searchableText: m
1501
1427
  };
1502
- n.push(x), o.set(h.fully_qualified_name, l), i.toolsByName.set(
1428
+ r.push(b), o.set(h.fully_qualified_name, l), i.toolsByName.set(
1503
1429
  h.fully_qualified_name.toLowerCase(),
1504
- x
1430
+ b
1505
1431
  );
1506
1432
  }
1507
1433
  }
1508
1434
  return {
1509
- toolkits: r,
1510
- tools: n,
1435
+ toolkits: n,
1436
+ tools: r,
1511
1437
  toolkitMap: s,
1512
1438
  toolToToolkitMap: o,
1513
1439
  searchIndex: i
@@ -1519,25 +1445,25 @@ class Kt {
1519
1445
  * Handles camelCase, snake_case, kebab-case, and dot.notation.
1520
1446
  */
1521
1447
  normalizeText(e) {
1522
- const r = /* @__PURE__ */ new Set();
1523
- for (const n of e) {
1524
- if (!n)
1448
+ const n = /* @__PURE__ */ new Set();
1449
+ for (const r of e) {
1450
+ if (!r)
1525
1451
  continue;
1526
- const s = n.toLowerCase();
1527
- r.add(s);
1528
- const o = n.split(jt);
1452
+ const s = r.toLowerCase();
1453
+ n.add(s);
1454
+ const o = r.split(Ut);
1529
1455
  for (const i of o) {
1530
1456
  if (i.length <= 1)
1531
1457
  continue;
1532
- const c = i.replace(Ut, "$1 $2").split(Bt);
1458
+ const c = i.replace($t, "$1 $2").split(jt);
1533
1459
  for (const u of c)
1534
- u.length > 1 && r.add(u.toLowerCase());
1460
+ u.length > 1 && n.add(u.toLowerCase());
1535
1461
  }
1536
1462
  }
1537
- return Array.from(r).join(" ");
1463
+ return Array.from(n).join(" ");
1538
1464
  }
1539
1465
  }
1540
1466
  export {
1541
- Kt as A,
1467
+ qt as A,
1542
1468
  d as a
1543
1469
  };