@gradio/client 2.1.0 → 2.2.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/browser.js CHANGED
@@ -1,5 +1,5 @@
1
- const We = "host", Te = "queue/data", Ze = "queue/join", ye = "upload", Ke = "login", V = "config", Ve = "info", Ye = "runtime", Qe = "sleeptime", Xe = "heartbeat", et = "component_server", tt = "reset", st = "cancel", nt = "app_id", Ae = "This application is currently busy. Please try again. ", L = "Connection errored out. ", N = "Could not resolve app config. ", ot = "Could not get space status. ", it = "Could not get API info. ", le = "Space metadata could not be loaded. ", rt = "Invalid URL. A full URL path is required.", at = "Not authorized to access this space. ", xe = "Invalid credentials. Could not login. ", ct = "Login credentials are required to access this space.", ut = "File system access is only available in Node.js environments", Ce = "Root URL not found in client config", lt = "Error uploading file";
2
- async function be(e, s, t) {
1
+ const Ke = "host", Ae = "queue/data", Ve = "queue/join", we = "upload", Ye = "login", K = "config", Qe = "info", Xe = "runtime", et = "sleeptime", tt = "heartbeat", st = "component_server", nt = "reset", ot = "cancel", it = "app_id", xe = "This application is currently busy. Please try again. ", L = "Connection errored out. ", C = "Could not resolve app config. ", rt = "Could not get space status. ", at = "Could not get API info. ", ue = "Space metadata could not be loaded. ", ct = "Invalid URL. A full URL path is required.", ut = "Not authorized to access this space. ", De = "Invalid credentials. Could not login. ", lt = "Login credentials are required to access this space.", pt = "File system access is only available in Node.js environments", Ce = "Root URL not found in client config", dt = "Error uploading file";
2
+ async function ye(e, s, t) {
3
3
  try {
4
4
  return (await (await fetch(`https://huggingface.co/api/spaces/${e}/jwt`, {
5
5
  headers: {
@@ -11,24 +11,24 @@ async function be(e, s, t) {
11
11
  return !1;
12
12
  }
13
13
  }
14
- function pt(e) {
14
+ function ht(e) {
15
15
  let s = {};
16
16
  return e.forEach(({ api_name: t, id: n }) => {
17
17
  t && (s[t] = n);
18
18
  }), s;
19
19
  }
20
- async function dt(e) {
20
+ async function ft(e) {
21
21
  const s = this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {};
22
22
  if (s["Content-Type"] = "application/json", typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876") {
23
23
  if (window.gradio_config.current_page && (e = e.substring(0, e.lastIndexOf("/"))), window.gradio_config.dev_mode || typeof window < "u" && window?.BUILD_MODE === "dev") {
24
- let t = ce(
24
+ let t = ae(
25
25
  e,
26
- this.deep_link ? V + "?deep_link=" + this.deep_link : V
26
+ this.deep_link ? K + "?deep_link=" + this.deep_link : K
27
27
  );
28
28
  const n = await this.fetch(t, {
29
29
  headers: s,
30
30
  credentials: "include"
31
- }), o = await ve(n, !!this.options.auth);
31
+ }), o = await be(n, !!this.options.auth);
32
32
  o.root = e || o.root, window.gradio_config = {
33
33
  ...o,
34
34
  current_page: window.gradio_config.current_page
@@ -36,41 +36,41 @@ async function dt(e) {
36
36
  }
37
37
  return { ...window.gradio_config };
38
38
  } else if (e) {
39
- let t = ce(
39
+ let t = ae(
40
40
  e,
41
- this.deep_link ? V + "?deep_link=" + this.deep_link : V
41
+ this.deep_link ? K + "?deep_link=" + this.deep_link : K
42
42
  );
43
43
  const n = await this.fetch(t, {
44
44
  headers: s,
45
45
  credentials: "include"
46
- }), o = await ve(n, !!this.options.auth);
46
+ }), o = await be(n, !!this.options.auth);
47
47
  return o.root || (o.root = e), o;
48
48
  }
49
- throw new Error(N);
49
+ throw new Error(C);
50
50
  }
51
- async function ve(e, s) {
51
+ async function be(e, s) {
52
52
  if (e?.status === 401 && !s) {
53
53
  const n = (await e.json())?.detail?.auth_message;
54
- throw new Error(n || ct);
54
+ throw new Error(n || lt);
55
55
  } else if (e?.status === 401 && s)
56
- throw new Error(xe);
56
+ throw new Error(De);
57
57
  if (e?.status === 200) {
58
58
  let t = await e.json();
59
59
  return t.dependencies?.forEach((n, o) => {
60
60
  n.id === void 0 && (n.id = o);
61
61
  }), t;
62
62
  } else if (e?.status === 401)
63
- throw new Error(at);
64
- throw new Error(N);
63
+ throw new Error(ut);
64
+ throw new Error(C);
65
65
  }
66
- async function ht() {
67
- const { http_protocol: e, host: s } = await de(
66
+ async function _t() {
67
+ const { http_protocol: e, host: s } = await pe(
68
68
  this.app_reference,
69
69
  this.options.token
70
70
  );
71
71
  try {
72
72
  if (this.options.auth) {
73
- const t = await De(
73
+ const t = await Le(
74
74
  e,
75
75
  s,
76
76
  this.options.auth,
@@ -83,12 +83,12 @@ async function ht() {
83
83
  throw Error(t.message);
84
84
  }
85
85
  }
86
- async function De(e, s, t, n, o) {
86
+ async function Le(e, s, t, n, o) {
87
87
  const r = new FormData();
88
88
  r.append("username", t?.[0]), r.append("password", t?.[1]);
89
89
  let i = {};
90
90
  o && (i.Authorization = `Bearer ${o}`);
91
- const a = await n(`${e}//${s}/${Ke}`, {
91
+ const a = await n(`${e}//${s}/${Ye}`, {
92
92
  headers: i,
93
93
  method: "POST",
94
94
  body: r,
@@ -96,9 +96,9 @@ async function De(e, s, t, n, o) {
96
96
  });
97
97
  if (a.status === 200)
98
98
  return a.headers.get("set-cookie");
99
- throw a.status === 401 ? new Error(xe) : new Error(le);
99
+ throw a.status === 401 ? new Error(De) : new Error(ue);
100
100
  }
101
- function ae(e) {
101
+ function re(e) {
102
102
  if (e.startsWith("http")) {
103
103
  const { protocol: s, host: t, pathname: n } = new URL(e);
104
104
  return {
@@ -119,26 +119,26 @@ const Ne = (e) => {
119
119
  const [o, r] = n.split(";")[0].split("=");
120
120
  o && r && s.push(`${o.trim()}=${r.trim()}`);
121
121
  }), s;
122
- }, pe = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, ft = /.*hf\.space\/{0,1}.*$/;
123
- async function de(e, s) {
122
+ }, le = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, gt = /.*hf\.space\/{0,1}.*$/;
123
+ async function pe(e, s) {
124
124
  const t = {};
125
125
  s && (t.Authorization = `Bearer ${s}`);
126
126
  const n = e.trim().replace(/\/$/, "");
127
- if (pe.test(n))
127
+ if (le.test(n))
128
128
  try {
129
129
  const r = (await (await fetch(
130
- `https://huggingface.co/api/spaces/${n}/${We}`,
130
+ `https://huggingface.co/api/spaces/${n}/${Ke}`,
131
131
  { headers: t }
132
132
  )).json()).host;
133
133
  return {
134
134
  space_id: e,
135
- ...ae(r)
135
+ ...re(r)
136
136
  };
137
137
  } catch {
138
- throw new Error(le);
138
+ throw new Error(ue);
139
139
  }
140
- if (ft.test(n)) {
141
- const { ws_protocol: o, http_protocol: r, host: i } = ae(n);
140
+ if (gt.test(n)) {
141
+ const { ws_protocol: o, http_protocol: r, host: i } = re(n);
142
142
  return {
143
143
  space_id: i.split("/")[0].replace(".hf.space", ""),
144
144
  ws_protocol: o,
@@ -148,17 +148,17 @@ async function de(e, s) {
148
148
  }
149
149
  return {
150
150
  space_id: !1,
151
- ...ae(n)
151
+ ...re(n)
152
152
  };
153
153
  }
154
- const ce = (...e) => {
154
+ const ae = (...e) => {
155
155
  try {
156
156
  return e.reduce((s, t) => (s = s.replace(/\/+$/, ""), t = t.replace(/^\/+/, ""), new URL(t, s + "/").toString()));
157
157
  } catch {
158
- throw new Error(rt);
158
+ throw new Error(ct);
159
159
  }
160
160
  };
161
- function _t(e, s, t) {
161
+ function mt(e, s, t) {
162
162
  const n = {
163
163
  named_endpoints: {},
164
164
  unnamed_endpoints: {}
@@ -170,13 +170,13 @@ function _t(e, s, t) {
170
170
  (c) => c.api_name === r || c.api_name === r.replace("/", "")
171
171
  )?.id || t[r.replace("/", "")] || -1, l = u !== -1 ? s.dependencies.find((c) => c.id == u)?.types : { generator: !1, cancel: !1 };
172
172
  if (u !== -1 && s.dependencies.find((c) => c.id == u)?.inputs?.length !== i.length) {
173
- const c = s.dependencies.find((m) => m.id == u).inputs.map(
174
- (m) => s.components.find((w) => w.id === m)?.type
173
+ const c = s.dependencies.find((g) => g.id == u).inputs.map(
174
+ (g) => s.components.find((w) => w.id === g)?.type
175
175
  );
176
176
  try {
177
- c.forEach((m, w) => {
178
- if (m === "state") {
179
- const P = {
177
+ c.forEach((g, w) => {
178
+ if (g === "state") {
179
+ const N = {
180
180
  component: "state",
181
181
  example: null,
182
182
  parameter_default: null,
@@ -184,17 +184,17 @@ function _t(e, s, t) {
184
184
  parameter_name: null,
185
185
  hidden: !0
186
186
  };
187
- i.splice(w, 0, P);
187
+ i.splice(w, 0, N);
188
188
  }
189
189
  });
190
- } catch (m) {
191
- console.error(m);
190
+ } catch (g) {
191
+ console.error(g);
192
192
  }
193
193
  }
194
- const p = (c, m, w, P) => ({
194
+ const p = (c, g, w, N) => ({
195
195
  ...c,
196
- description: gt(c?.type, w),
197
- type: mt(c?.type, m, w, P) || ""
196
+ description: yt(c?.type, w),
197
+ type: wt(c?.type, g, w, N) || ""
198
198
  });
199
199
  n[o][r] = {
200
200
  parameters: i.map(
@@ -209,7 +209,7 @@ function _t(e, s, t) {
209
209
  ));
210
210
  }), n;
211
211
  }
212
- function mt(e, s, t, n) {
212
+ function wt(e, s, t, n) {
213
213
  if (s === "Api") return e.type;
214
214
  switch (e?.type) {
215
215
  case "string":
@@ -230,10 +230,10 @@ function mt(e, s, t, n) {
230
230
  if (t === "GallerySerializable")
231
231
  return n === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : "[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]";
232
232
  }
233
- function gt(e, s) {
233
+ function yt(e, s) {
234
234
  return s === "GallerySerializable" ? "array of [file, label] tuples" : s === "ListStringSerializable" ? "array of strings" : s === "FileSerializable" ? "array of files or single file" : e?.description;
235
235
  }
236
- function Ee(e, s) {
236
+ function ve(e, s) {
237
237
  switch (e.msg) {
238
238
  case "send_data":
239
239
  return { type: "data" };
@@ -244,7 +244,7 @@ function Ee(e, s) {
244
244
  type: "update",
245
245
  status: {
246
246
  queue: !0,
247
- message: Ae,
247
+ message: xe,
248
248
  stage: "error",
249
249
  code: e.code,
250
250
  success: e.success
@@ -350,7 +350,10 @@ function Ee(e, s) {
350
350
  stage: e.success ? "complete" : "error",
351
351
  code: e.code,
352
352
  progress_data: e.progress_data,
353
- changed_state_ids: e.success ? e.output.changed_state_ids : void 0
353
+ changed_state_ids: e.success ? e.output.changed_state_ids : void 0,
354
+ used_cache: e.used_cache,
355
+ cache_duration: e.cache_duration,
356
+ avg_time: e.avg_time
354
357
  },
355
358
  data: e.success ? e.output : null
356
359
  };
@@ -371,7 +374,7 @@ function Ee(e, s) {
371
374
  }
372
375
  return { type: "none", status: { stage: "error", queue: !0 } };
373
376
  }
374
- const wt = (e = [], s) => {
377
+ const bt = (e = [], s) => {
375
378
  const t = s ? s.parameters : [];
376
379
  if (Array.isArray(e))
377
380
  return s && t.length > 0 && e.length > t.length && console.warn("Too many arguments provided for the endpoint."), e;
@@ -397,7 +400,7 @@ const wt = (e = [], s) => {
397
400
  );
398
401
  }), n;
399
402
  };
400
- async function yt() {
403
+ async function vt() {
401
404
  if (this.api_info) return this.api_info;
402
405
  const { token: e } = this.options, { config: s } = this, t = { "Content-Type": "application/json" };
403
406
  if (e && (t.Authorization = `Bearer ${e}`), !!s)
@@ -406,7 +409,7 @@ async function yt() {
406
409
  if (typeof window < "u" && window.gradio_api_info)
407
410
  o = window.gradio_api_info;
408
411
  else {
409
- const r = ce(s.root, this.api_prefix, Ve);
412
+ const r = ae(s.root, this.api_prefix, Qe);
410
413
  if (n = await this.fetch(r, {
411
414
  headers: t,
412
415
  credentials: "include"
@@ -414,12 +417,12 @@ async function yt() {
414
417
  throw new Error(L);
415
418
  o = await n.json();
416
419
  }
417
- return "api" in o && (o = o.api), o.named_endpoints["/predict"] && !o.unnamed_endpoints[0] && (o.unnamed_endpoints[0] = o.named_endpoints["/predict"]), _t(o, s, this.api_map);
420
+ return "api" in o && (o = o.api), o.named_endpoints["/predict"] && !o.unnamed_endpoints[0] && (o.unnamed_endpoints[0] = o.named_endpoints["/predict"]), mt(o, s, this.api_map);
418
421
  } catch (n) {
419
422
  throw new Error("Could not get API info. " + n.message);
420
423
  }
421
424
  }
422
- async function bt(e, s, t) {
425
+ async function Et(e, s, t) {
423
426
  const n = {};
424
427
  this?.options?.token && (n.Authorization = `Bearer ${this.options.token}`);
425
428
  const o = 1e3, r = [];
@@ -430,7 +433,7 @@ async function bt(e, s, t) {
430
433
  l.append("files", c);
431
434
  });
432
435
  try {
433
- const c = t ? `${e}${this.api_prefix}/${ye}?upload_id=${t}` : `${e}${this.api_prefix}/${ye}`;
436
+ const c = t ? `${e}${this.api_prefix}/${we}?upload_id=${t}` : `${e}${this.api_prefix}/${we}`;
434
437
  i = await this.fetch(c, {
435
438
  method: "POST",
436
439
  body: l,
@@ -449,29 +452,29 @@ async function bt(e, s, t) {
449
452
  }
450
453
  return { files: r };
451
454
  }
452
- const vt = {
455
+ const St = {
453
456
  radix: 1e3,
454
457
  unit: ["b", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"]
455
- }, Et = {
458
+ }, $t = {
456
459
  radix: 1024,
457
460
  unit: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"]
458
- }, St = {
461
+ }, kt = {
459
462
  radix: 1024,
460
463
  unit: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"]
461
- }, Se = {
462
- si: vt,
463
- iec: Et,
464
- jedec: St
464
+ }, Ee = {
465
+ si: St,
466
+ iec: $t,
467
+ jedec: kt
465
468
  };
466
- function $t(e, s = 1, t = "jedec") {
469
+ function Rt(e, s = 1, t = "jedec") {
467
470
  e = Math.abs(e);
468
- const { radix: n, unit: o } = Se[t] || Se.jedec;
471
+ const { radix: n, unit: o } = Ee[t] || Ee.jedec;
469
472
  let r = 0;
470
473
  for (; e >= n; )
471
474
  e /= n, ++r;
472
475
  return `${e.toFixed(s)} ${o[r]}`;
473
476
  }
474
- async function kt(e, s, t, n) {
477
+ async function Ot(e, s, t, n) {
475
478
  let o = (Array.isArray(e) ? e : [e]).map(
476
479
  (i) => i.blob
477
480
  );
@@ -480,14 +483,14 @@ async function kt(e, s, t, n) {
480
483
  );
481
484
  if (r.length)
482
485
  throw new Error(
483
- `File(s) exceed the maximum allowed size of ${$t(n || 1 / 0)}: ${r.map((i) => `"${i.name}"`).join(", ")}`
486
+ `File(s) exceed the maximum allowed size of ${Rt(n || 1 / 0)}: ${r.map((i) => `"${i.name}"`).join(", ")}`
484
487
  );
485
488
  return await Promise.all(
486
489
  await this.upload_files(s, o, t).then(
487
490
  async (i) => {
488
491
  if (i.error)
489
492
  throw new Error(i.error);
490
- return i.files ? i.files.map((a, u) => new X({
493
+ return i.files ? i.files.map((a, u) => new Q({
491
494
  ...e[u],
492
495
  path: a,
493
496
  url: `${s}${this.api_prefix}/file=${a}`
@@ -496,9 +499,9 @@ async function kt(e, s, t, n) {
496
499
  )
497
500
  );
498
501
  }
499
- async function Xt(e, s) {
502
+ async function ns(e, s) {
500
503
  return e.map(
501
- (t) => new X({
504
+ (t) => new Q({
502
505
  path: t.name,
503
506
  orig_name: t.name,
504
507
  blob: t,
@@ -508,7 +511,7 @@ async function Xt(e, s) {
508
511
  })
509
512
  );
510
513
  }
511
- class X {
514
+ class Q {
512
515
  path;
513
516
  url;
514
517
  orig_name;
@@ -533,7 +536,7 @@ class X {
533
536
  this.path = s, this.url = t, this.orig_name = n, this.size = o, this.blob = t ? void 0 : r, this.is_stream = i, this.mime_type = a, this.alt_text = u, this.b64 = l;
534
537
  }
535
538
  }
536
- class Le {
539
+ class Pe {
537
540
  type;
538
541
  command;
539
542
  meta;
@@ -542,8 +545,8 @@ class Le {
542
545
  this.type = "command", this.command = s, this.meta = t;
543
546
  }
544
547
  }
545
- const Rt = typeof process < "u" && process.versions && process.versions.node;
546
- function $e(e, s, t) {
548
+ const Tt = typeof process < "u" && process.versions && process.versions.node;
549
+ function Se(e, s, t) {
547
550
  for (; t.length > 1; ) {
548
551
  const o = t.shift();
549
552
  if (typeof o == "string" || typeof o == "number")
@@ -557,14 +560,14 @@ function $e(e, s, t) {
557
560
  else
558
561
  throw new Error("Invalid key type");
559
562
  }
560
- async function ue(e, s = void 0, t = [], n = !1, o = void 0) {
563
+ async function ce(e, s = void 0, t = [], n = !1, o = void 0) {
561
564
  if (Array.isArray(e)) {
562
565
  let r = [];
563
566
  return await Promise.all(
564
567
  e.map(async (i, a) => {
565
568
  let u = t.slice();
566
569
  u.push(String(a));
567
- const l = await ue(
570
+ const l = await ce(
568
571
  e[a],
569
572
  n ? o?.parameters[a]?.component || void 0 : s,
570
573
  u,
@@ -588,7 +591,7 @@ async function ue(e, s = void 0, t = [], n = !1, o = void 0) {
588
591
  for (const i of Object.keys(e)) {
589
592
  const a = [...t, i], u = e[i];
590
593
  r = r.concat(
591
- await ue(
594
+ await ce(
592
595
  u,
593
596
  void 0,
594
597
  a,
@@ -602,11 +605,11 @@ async function ue(e, s = void 0, t = [], n = !1, o = void 0) {
602
605
  }
603
606
  return [];
604
607
  }
605
- function Ot(e, s) {
608
+ function At(e, s) {
606
609
  let t = s?.dependencies?.find((n) => n.id == e)?.queue;
607
610
  return t != null ? !t : !s.enable_queue;
608
611
  }
609
- function Tt(e, s) {
612
+ function xt(e, s) {
610
613
  return new Promise((t, n) => {
611
614
  const o = new MessageChannel();
612
615
  o.port1.onmessage = (({ data: r }) => {
@@ -614,7 +617,7 @@ function Tt(e, s) {
614
617
  }), window.parent.postMessage(e, s, [o.port2]);
615
618
  });
616
619
  }
617
- function es(e) {
620
+ function os(e) {
618
621
  if (typeof e == "string") {
619
622
  if (e.startsWith("http://") || e.startsWith("https://"))
620
623
  return {
@@ -623,8 +626,8 @@ function es(e) {
623
626
  orig_name: e.split("/").pop() ?? "unknown",
624
627
  meta: { _type: "gradio.FileData" }
625
628
  };
626
- if (Rt)
627
- return new Le("upload_file", {
629
+ if (Tt)
630
+ return new Pe("upload_file", {
628
631
  path: e,
629
632
  name: e,
630
633
  orig_path: e
@@ -641,7 +644,7 @@ function es(e) {
641
644
  "Invalid input: must be a URL, File, Blob, or Buffer object."
642
645
  );
643
646
  }
644
- function Y(e, s, t, n, o = !1) {
647
+ function V(e, s, t, n, o = !1) {
645
648
  if (n === "input" && !o)
646
649
  throw new Error("Invalid code path. Cannot skip state inputs for input.");
647
650
  if (n === "output" && o)
@@ -669,10 +672,10 @@ function Y(e, s, t, n, o = !1) {
669
672
  }
670
673
  return r;
671
674
  }
672
- async function At(e, s, t) {
675
+ async function Dt(e, s, t) {
673
676
  const n = this;
674
- await xt(n, s);
675
- const o = await ue(
677
+ await Ct(n, s);
678
+ const o = await ce(
676
679
  s,
677
680
  void 0,
678
681
  [],
@@ -692,23 +695,23 @@ async function At(e, s, t) {
692
695
  })
693
696
  )).forEach(({ path: i, file_url: a, type: u, name: l }) => {
694
697
  if (u === "Gallery")
695
- $e(s, a, i);
698
+ Se(s, a, i);
696
699
  else if (a) {
697
- const p = new X({ path: a, orig_name: l });
698
- $e(s, p, i);
700
+ const p = new Q({ path: a, orig_name: l });
701
+ Se(s, p, i);
699
702
  }
700
703
  }), s;
701
704
  }
702
- async function xt(e, s) {
705
+ async function Ct(e, s) {
703
706
  if (!(e.config?.root || e.config?.root_url))
704
707
  throw new Error(Ce);
705
- await Pe(e, s);
708
+ await je(e, s);
706
709
  }
707
- async function Pe(e, s, t = []) {
710
+ async function je(e, s, t = []) {
708
711
  for (const n in s)
709
- s[n] instanceof Le ? await Ct(e, s, n) : typeof s[n] == "object" && s[n] !== null && await Pe(e, s[n], [...t, n]);
712
+ s[n] instanceof Pe ? await Lt(e, s, n) : typeof s[n] == "object" && s[n] !== null && await je(e, s[n], [...t, n]);
710
713
  }
711
- async function Ct(e, s, t) {
714
+ async function Lt(e, s, t) {
712
715
  let n = s[t];
713
716
  const o = e.config?.root || e.config?.root_url;
714
717
  if (!o)
@@ -719,22 +722,22 @@ async function Ct(e, s, t) {
719
722
  const p = await import("./__vite-browser-external-DYxpcVy9.js");
720
723
  i = (await import("./__vite-browser-external-DYxpcVy9.js")).resolve(process.cwd(), n.meta.path), r = await p.readFile(i);
721
724
  } else
722
- throw new Error(ut);
725
+ throw new Error(pt);
723
726
  const a = new Blob([r], {
724
727
  type: "application/octet-stream"
725
728
  }), u = await e.upload_files(o, [a]), l = u.files && u.files[0];
726
729
  if (l) {
727
- const p = new X({
730
+ const p = new Q({
728
731
  path: l,
729
732
  orig_name: n.meta.name || ""
730
733
  });
731
734
  s[t] = p;
732
735
  }
733
736
  } catch (r) {
734
- console.error(lt, r);
737
+ console.error(dt, r);
735
738
  }
736
739
  }
737
- async function Dt(e, s, t) {
740
+ async function Nt(e, s, t) {
738
741
  const n = { "Content-Type": "application/json" };
739
742
  this.options.token && (n.Authorization = `Bearer ${this.options.token}`);
740
743
  try {
@@ -755,7 +758,7 @@ async function Dt(e, s, t) {
755
758
  }
756
759
  return [r, i];
757
760
  }
758
- async function Nt(e, s = {}) {
761
+ async function Pt(e, s = {}) {
759
762
  let t = !1, n = !1;
760
763
  if (!this.config)
761
764
  throw new Error("Could not resolve app config");
@@ -774,7 +777,7 @@ async function Nt(e, s = {}) {
774
777
  u.type === "data" && (n && o(a), t = !0, a = u), u.type === "status" && (u.stage === "error" && r(u), u.stage === "complete" && (n = !0, t && o(a)));
775
778
  });
776
779
  }
777
- async function H(e, s, t) {
780
+ async function F(e, s, t) {
778
781
  let n = s === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${e}` : `https://huggingface.co/api/spaces/${e}`, o, r;
779
782
  try {
780
783
  if (o = await fetch(n), r = o.status, r !== 200)
@@ -784,7 +787,7 @@ async function H(e, s, t) {
784
787
  t({
785
788
  status: "error",
786
789
  load_status: "error",
787
- message: ot,
790
+ message: rt,
788
791
  detail: "NOT_FOUND"
789
792
  });
790
793
  return;
@@ -803,7 +806,7 @@ async function H(e, s, t) {
803
806
  message: "Space is asleep. Waking it up...",
804
807
  detail: i
805
808
  }), setTimeout(() => {
806
- H(e, s, t);
809
+ F(e, s, t);
807
810
  }, 1e3);
808
811
  break;
809
812
  case "PAUSED":
@@ -812,7 +815,7 @@ async function H(e, s, t) {
812
815
  load_status: "error",
813
816
  message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
814
817
  detail: i,
815
- discussions_enabled: await ke(a)
818
+ discussions_enabled: await $e(a)
816
819
  });
817
820
  break;
818
821
  case "RUNNING":
@@ -831,7 +834,7 @@ async function H(e, s, t) {
831
834
  message: "Space is building...",
832
835
  detail: i
833
836
  }), setTimeout(() => {
834
- H(e, s, t);
837
+ F(e, s, t);
835
838
  }, 1e3);
836
839
  break;
837
840
  case "APP_STARTING":
@@ -841,7 +844,7 @@ async function H(e, s, t) {
841
844
  message: "Space is starting...",
842
845
  detail: i
843
846
  }), setTimeout(() => {
844
- H(e, s, t);
847
+ F(e, s, t);
845
848
  }, 1e3);
846
849
  break;
847
850
  default:
@@ -850,27 +853,27 @@ async function H(e, s, t) {
850
853
  load_status: "error",
851
854
  message: "This space is experiencing an issue.",
852
855
  detail: i,
853
- discussions_enabled: await ke(a)
856
+ discussions_enabled: await $e(a)
854
857
  });
855
858
  break;
856
859
  }
857
860
  }
858
- const je = async (e, s) => {
861
+ const Ie = async (e, s) => {
859
862
  let t = 0;
860
863
  const n = 12, o = 5e3;
861
864
  return new Promise((r) => {
862
- H(
865
+ F(
863
866
  e,
864
- pe.test(e) ? "space_name" : "subdomain",
867
+ le.test(e) ? "space_name" : "subdomain",
865
868
  (i) => {
866
869
  s(i), i.status === "running" || i.status === "error" || i.status === "paused" || i.status === "space_error" ? r() : (i.status === "sleeping" || i.status === "building") && (t < n ? (t++, setTimeout(() => {
867
- je(e, s).then(r);
870
+ Ie(e, s).then(r);
868
871
  }, o)) : r());
869
872
  }
870
873
  );
871
874
  });
872
- }, Lt = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
873
- async function ke(e) {
875
+ }, jt = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
876
+ async function $e(e) {
874
877
  try {
875
878
  const s = await fetch(
876
879
  `https://huggingface.co/api/spaces/${e}/discussions`,
@@ -878,17 +881,17 @@ async function ke(e) {
878
881
  method: "HEAD"
879
882
  }
880
883
  ), t = s.headers.get("x-error-message");
881
- return !(!s.ok || t && Lt.test(t));
884
+ return !(!s.ok || t && jt.test(t));
882
885
  } catch {
883
886
  return !1;
884
887
  }
885
888
  }
886
- async function Pt(e, s) {
889
+ async function It(e, s) {
887
890
  const t = {};
888
891
  s && (t.Authorization = `Bearer ${s}`);
889
892
  try {
890
893
  const n = await fetch(
891
- `https://huggingface.co/api/spaces/${e}/${Ye}`,
894
+ `https://huggingface.co/api/spaces/${e}/${Xe}`,
892
895
  { headers: t }
893
896
  );
894
897
  if (n.status !== 200)
@@ -899,7 +902,7 @@ async function Pt(e, s) {
899
902
  throw new Error(n.message);
900
903
  }
901
904
  }
902
- async function jt(e, s, t) {
905
+ async function Ut(e, s, t) {
903
906
  const n = {};
904
907
  t && (n.Authorization = `Bearer ${t}`);
905
908
  const o = {
@@ -907,7 +910,7 @@ async function jt(e, s, t) {
907
910
  };
908
911
  try {
909
912
  const r = await fetch(
910
- `https://huggingface.co/api/spaces/${e}/${Qe}`,
913
+ `https://huggingface.co/api/spaces/${e}/${et}`,
911
914
  {
912
915
  method: "POST",
913
916
  headers: { "Content-Type": "application/json", ...n },
@@ -923,7 +926,7 @@ async function jt(e, s, t) {
923
926
  throw new Error(r.message);
924
927
  }
925
928
  }
926
- const Re = [
929
+ const ke = [
927
930
  "cpu-basic",
928
931
  "cpu-upgrade",
929
932
  "cpu-xl",
@@ -938,22 +941,22 @@ const Re = [
938
941
  "h100",
939
942
  "h100x8"
940
943
  ];
941
- async function It(e, s) {
944
+ async function qt(e, s) {
942
945
  const { token: t, private: n, hardware: o, timeout: r, auth: i } = s;
943
- if (o && !Re.includes(o))
946
+ if (o && !ke.includes(o))
944
947
  throw new Error(
945
- `Invalid hardware type provided. Valid types are: ${Re.map((g) => `"${g}"`).join(",")}.`
948
+ `Invalid hardware type provided. Valid types are: ${ke.map((m) => `"${m}"`).join(",")}.`
946
949
  );
947
- const { http_protocol: a, host: u } = await de(e, t);
950
+ const { http_protocol: a, host: u } = await pe(e, t);
948
951
  let l = null;
949
952
  if (i) {
950
- const g = await De(
953
+ const m = await Le(
951
954
  a,
952
955
  u,
953
956
  i,
954
957
  fetch
955
958
  );
956
- g && (l = Ne(g));
959
+ m && (l = Ne(m));
957
960
  }
958
961
  const p = {
959
962
  Authorization: `Bearer ${t}`,
@@ -961,20 +964,20 @@ async function It(e, s) {
961
964
  ...l ? { Cookie: l.join("; ") } : {}
962
965
  }, c = (await (await fetch("https://huggingface.co/api/whoami-v2", {
963
966
  headers: p
964
- })).json()).name, m = e.split("/")[1], w = {
965
- repository: `${c}/${m}`
967
+ })).json()).name, g = e.split("/")[1], w = {
968
+ repository: `${c}/${g}`
966
969
  };
967
970
  n && (w.private = !0);
968
- let P;
971
+ let N;
969
972
  try {
970
- o || (P = await Pt(e, t));
971
- } catch (g) {
972
- throw Error(le + g.message);
973
+ o || (N = await It(e, t));
974
+ } catch (m) {
975
+ throw Error(ue + m.message);
973
976
  }
974
- const f = o || P || "cpu-basic";
977
+ const f = o || N || "cpu-basic";
975
978
  w.hardware = f;
976
979
  try {
977
- const g = await fetch(
980
+ const m = await fetch(
978
981
  `https://huggingface.co/api/spaces/${e}/duplicate`,
979
982
  {
980
983
  method: "POST",
@@ -982,29 +985,46 @@ async function It(e, s) {
982
985
  body: JSON.stringify(w)
983
986
  }
984
987
  );
985
- if (g.status === 409)
988
+ if (m.status === 409)
986
989
  try {
987
- return await Q.connect(`${c}/${m}`, s);
990
+ return await Y.connect(`${c}/${g}`, s);
988
991
  } catch (z) {
989
992
  throw console.error("Failed to connect Client instance:", z), z;
990
993
  }
991
- else if (g.status !== 200)
992
- throw new Error(g.statusText);
993
- const J = await g.json();
994
- return await jt(`${c}/${m}`, r || 300, t), await Q.connect(
995
- Ut(J.url),
994
+ else if (m.status !== 200)
995
+ throw new Error(m.statusText);
996
+ const H = await m.json();
997
+ return await Ut(`${c}/${g}`, r || 300, t), await Y.connect(
998
+ zt(H.url),
996
999
  s
997
1000
  );
998
- } catch (g) {
999
- throw new Error(g);
1001
+ } catch (m) {
1002
+ throw new Error(m);
1000
1003
  }
1001
1004
  }
1002
- function Ut(e) {
1005
+ function zt(e) {
1003
1006
  const s = /https:\/\/huggingface.co\/spaces\/([^/]+\/[^/]+)/, t = e.match(s);
1004
1007
  if (t)
1005
1008
  return t[1];
1006
1009
  }
1007
- class qt extends TransformStream {
1010
+ const Re = "supports-zerogpu-headers";
1011
+ let Oe = !1;
1012
+ function Bt() {
1013
+ return typeof window < "u" && typeof document < "u" && typeof window.addEventListener == "function";
1014
+ }
1015
+ function Ue(e) {
1016
+ return e.includes(".dev.") ? `https://moon-${e.split(".")[1]}.dev.spaces.huggingface.tech` : e.endsWith(".hf.space") ? "https://huggingface.co" : null;
1017
+ }
1018
+ function Gt() {
1019
+ if (!Bt() || Oe)
1020
+ return;
1021
+ window.addEventListener("message", (s) => {
1022
+ s.data === Re && (window.supports_zerogpu_headers = !0);
1023
+ }), Oe = !0;
1024
+ const e = Ue(window.location.hostname);
1025
+ e && window.parent !== window && window.parent.postMessage(Re, e);
1026
+ }
1027
+ class Mt extends TransformStream {
1008
1028
  #e = "";
1009
1029
  /** Constructs a new instance. */
1010
1030
  constructor(s = { allowCR: !1 }) {
@@ -1033,11 +1053,11 @@ class qt extends TransformStream {
1033
1053
  });
1034
1054
  }
1035
1055
  }
1036
- function zt(e) {
1037
- let s = new TextDecoderStream(), t = new qt({ allowCR: !0 });
1056
+ function Ft(e) {
1057
+ let s = new TextDecoderStream(), t = new Mt({ allowCR: !0 });
1038
1058
  return e.pipeThrough(s).pipeThrough(t);
1039
1059
  }
1040
- function Bt(e) {
1060
+ function Ht(e) {
1041
1061
  let t = /[:]\s*/.exec(e), n = t && t.index;
1042
1062
  if (n)
1043
1063
  return [
@@ -1045,13 +1065,13 @@ function Bt(e) {
1045
1065
  e.substring(n + t[0].length)
1046
1066
  ];
1047
1067
  }
1048
- function Oe(e, s, t) {
1068
+ function Te(e, s, t) {
1049
1069
  e.get(s) || e.set(s, t);
1050
1070
  }
1051
- async function* Ft(e, s) {
1071
+ async function* Jt(e, s) {
1052
1072
  if (!e.body)
1053
1073
  return;
1054
- let t = zt(e.body), n, o = t.getReader(), r;
1074
+ let t = Ft(e.body), n, o = t.getReader(), r;
1055
1075
  for (; ; ) {
1056
1076
  if (s && s.aborted)
1057
1077
  return o.cancel();
@@ -1061,20 +1081,20 @@ async function* Ft(e, s) {
1061
1081
  r && (yield r), r = void 0;
1062
1082
  continue;
1063
1083
  }
1064
- let [i, a] = Bt(n.value) || [];
1084
+ let [i, a] = Ht(n.value) || [];
1065
1085
  i === "data" ? (r ||= {}, r[i] = r[i] ? r[i] + `
1066
1086
  ` + a : a) : i === "event" ? (r ||= {}, r[i] = a) : i === "id" ? (r ||= {}, r[i] = String(+a) === a ? +a : a) : i === "retry" && (r ||= {}, r[i] = +a || void 0);
1067
1087
  }
1068
1088
  }
1069
- async function Gt(e, s) {
1089
+ async function Wt(e, s) {
1070
1090
  let t = new Request(e, s);
1071
- Oe(t.headers, "Accept", "text/event-stream"), Oe(t.headers, "Content-Type", "application/json");
1091
+ Te(t.headers, "Accept", "text/event-stream"), Te(t.headers, "Content-Type", "application/json");
1072
1092
  let n = await fetch(t);
1073
1093
  if (!n.ok)
1074
1094
  throw n;
1075
- return Ft(n, t.signal);
1095
+ return Jt(n, t.signal);
1076
1096
  }
1077
- async function Mt() {
1097
+ async function Zt() {
1078
1098
  let {
1079
1099
  event_callbacks: e,
1080
1100
  unclosed_events: s,
@@ -1089,7 +1109,7 @@ async function Mt() {
1089
1109
  n.open = !0;
1090
1110
  let a = null, u = new URLSearchParams({
1091
1111
  session_hash: this.session_hash
1092
- }).toString(), l = new URL(`${o.root}${this.api_prefix}/${Te}?${u}`);
1112
+ }).toString(), l = new URL(`${o.root}${this.api_prefix}/${Ae}?${u}`);
1093
1113
  if (r && l.searchParams.set("__sign", r), a = this.stream(l), !a) {
1094
1114
  console.warn("Cannot connect to SSE endpoint: " + l.toString());
1095
1115
  return;
@@ -1097,24 +1117,24 @@ async function Mt() {
1097
1117
  a.onmessage = async function(p) {
1098
1118
  let c = JSON.parse(p.data);
1099
1119
  if (c.msg === "close_stream") {
1100
- he(n, i.abort_controller);
1120
+ de(n, i.abort_controller);
1101
1121
  return;
1102
1122
  }
1103
- const m = c.event_id;
1104
- if (!m)
1123
+ const g = c.event_id;
1124
+ if (!g)
1105
1125
  await Promise.all(
1106
1126
  Object.keys(e).map(
1107
1127
  (w) => e[w](c)
1108
1128
  )
1109
1129
  );
1110
- else if (e[m] && o) {
1130
+ else if (e[g] && o) {
1111
1131
  c.msg === "process_completed" && ["sse", "sse_v1", "sse_v2", "sse_v2.1", "sse_v3"].includes(
1112
1132
  o.protocol
1113
- ) && s.delete(m);
1114
- let w = e[m];
1133
+ ) && s.delete(g);
1134
+ let w = e[g];
1115
1135
  typeof window < "u" && typeof document < "u" ? setTimeout(w, 0, c) : w(c);
1116
1136
  } else
1117
- t[m] || (t[m] = []), t[m].push(c);
1137
+ t[g] || (t[g] = []), t[g].push(c);
1118
1138
  }, a.onerror = async function(p) {
1119
1139
  console.error(p), await Promise.all(
1120
1140
  Object.keys(e).map(
@@ -1126,23 +1146,23 @@ async function Mt() {
1126
1146
  );
1127
1147
  };
1128
1148
  }
1129
- function he(e, s) {
1149
+ function de(e, s) {
1130
1150
  e && (e.open = !1, s?.abort());
1131
1151
  }
1132
- function Ht(e, s, t) {
1152
+ function Kt(e, s, t) {
1133
1153
  !e[s] ? (e[s] = [], t.data.forEach((o, r) => {
1134
1154
  e[s][r] = o;
1135
1155
  })) : t.data.forEach((o, r) => {
1136
- let i = Jt(e[s][r], o);
1156
+ let i = Vt(e[s][r], o);
1137
1157
  e[s][r] = i, t.data[r] = i;
1138
1158
  });
1139
1159
  }
1140
- function Jt(e, s) {
1160
+ function Vt(e, s) {
1141
1161
  return s.forEach(([t, n, o]) => {
1142
- e = Wt(e, n, t, o);
1162
+ e = Yt(e, n, t, o);
1143
1163
  }), e;
1144
1164
  }
1145
- function Wt(e, s, t, n) {
1165
+ function Yt(e, s, t, n) {
1146
1166
  if (s.length === 0) {
1147
1167
  if (t === "replace")
1148
1168
  return n;
@@ -1172,7 +1192,7 @@ function Wt(e, s, t, n) {
1172
1192
  }
1173
1193
  return e;
1174
1194
  }
1175
- function Zt(e, s = {}) {
1195
+ function Qt(e, s = {}) {
1176
1196
  const t = {
1177
1197
  close: () => {
1178
1198
  console.warn("Method not implemented.");
@@ -1196,7 +1216,7 @@ function Zt(e, s = {}) {
1196
1216
  throw new Error("Method not implemented.");
1197
1217
  }
1198
1218
  };
1199
- return Gt(e, s).then(async (n) => {
1219
+ return Wt(e, s).then(async (n) => {
1200
1220
  t.readyState = t.OPEN;
1201
1221
  try {
1202
1222
  for await (const o of n)
@@ -1209,69 +1229,69 @@ function Zt(e, s = {}) {
1209
1229
  console.error(n), t.onerror && t.onerror(n), t.readyState = t.CLOSED;
1210
1230
  }), t;
1211
1231
  }
1212
- function Kt(e, s = {}, t, n, o, r) {
1232
+ function Xt(e, s = {}, t, n, o, r) {
1213
1233
  try {
1214
1234
  let i = function(h) {
1215
- (o || ze[h.type]) && p(h);
1235
+ (o || Ge[h.type]) && p(h);
1216
1236
  }, a = function() {
1217
- for (Me = !0; G.length > 0; )
1218
- G.shift()({
1237
+ for (Je = !0; M.length > 0; )
1238
+ M.shift()({
1219
1239
  value: void 0,
1220
1240
  done: !0
1221
1241
  });
1222
1242
  }, u = function(h) {
1223
- G.length > 0 ? G.shift()(h) : ie.push(h);
1243
+ M.length > 0 ? M.shift()(h) : oe.push(h);
1224
1244
  }, l = function(h) {
1225
- u(Vt(h)), a();
1245
+ u(es(h)), a();
1226
1246
  }, p = function(h) {
1227
1247
  u({ value: h, done: !1 });
1228
1248
  }, c = function() {
1229
- return ie.length > 0 ? Promise.resolve(ie.shift()) : new Promise((h) => G.push(h));
1249
+ return oe.length > 0 ? Promise.resolve(oe.shift()) : new Promise((h) => M.push(h));
1230
1250
  };
1231
- const { token: m } = this.options, {
1251
+ const { token: g } = this.options, {
1232
1252
  fetch: w,
1233
- app_reference: P,
1253
+ app_reference: N,
1234
1254
  config: f,
1235
- session_hash: g,
1236
- api_info: J,
1255
+ session_hash: m,
1256
+ api_info: H,
1237
1257
  api_map: z,
1238
- stream_status: ee,
1239
- pending_stream_messages: te,
1240
- pending_diff_streams: se,
1241
- event_callbacks: ne,
1242
- unclosed_events: Ie,
1243
- post_data: oe,
1244
- options: W,
1258
+ stream_status: X,
1259
+ pending_stream_messages: ee,
1260
+ pending_diff_streams: te,
1261
+ event_callbacks: se,
1262
+ unclosed_events: qe,
1263
+ post_data: ne,
1264
+ options: J,
1245
1265
  api_prefix: T
1246
- } = this, fe = r || { "x-gradio-user": "api" }, Ue = this;
1247
- if (!J) throw new Error("No API found");
1266
+ } = this, he = r || { "x-gradio-user": "api" }, ze = this;
1267
+ if (!H) throw new Error("No API found");
1248
1268
  if (!f) throw new Error("Could not resolve app config");
1249
- let { fn_index: d, endpoint_info: _e, dependency: B } = Yt(
1250
- J,
1269
+ let { fn_index: d, endpoint_info: fe, dependency: B } = ts(
1270
+ H,
1251
1271
  e,
1252
1272
  z,
1253
1273
  f
1254
- ), qe = wt(s, _e), U, A = f.protocol ?? "ws";
1274
+ ), Be = bt(s, fe), j, A = f.protocol ?? "ws";
1255
1275
  if (A === "ws")
1256
1276
  throw new Error("WebSocket protocol is not supported in this version");
1257
- let q = "", Qt = () => q;
1277
+ let I = "", ss = () => I;
1258
1278
  const _ = typeof e == "number" ? "/predict" : e;
1259
- let Z, b = null, x = !1, me = {}, F = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
1260
- const ze = W?.events?.reduce(
1279
+ let W, v = null, x = !1, _e = {}, G = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
1280
+ const Ge = J?.events?.reduce(
1261
1281
  (h, R) => (h[R] = !0, h),
1262
1282
  {}
1263
1283
  ) || {};
1264
- async function Be() {
1284
+ async function Me() {
1265
1285
  let h = {}, R = {};
1266
- h = { event_id: b }, R = { event_id: b, session_hash: g, fn_index: d };
1286
+ h = { event_id: v }, R = { event_id: v, session_hash: m, fn_index: d };
1267
1287
  try {
1268
1288
  if (!f)
1269
1289
  throw new Error("Could not resolve app config");
1270
- "event_id" in R && await w(`${f.root}${T}/${st}`, {
1290
+ "event_id" in R && await w(`${f.root}${T}/${ot}`, {
1271
1291
  headers: { "Content-Type": "application/json" },
1272
1292
  method: "POST",
1273
1293
  body: JSON.stringify(R)
1274
- }), await w(`${f.root}${T}/${tt}`, {
1294
+ }), await w(`${f.root}${T}/${nt}`, {
1275
1295
  headers: { "Content-Type": "application/json" },
1276
1296
  method: "POST",
1277
1297
  body: JSON.stringify(h)
@@ -1289,29 +1309,29 @@ function Kt(e, s = {}, t, n, o, r) {
1289
1309
  if (!f) return;
1290
1310
  let R = h.render_id;
1291
1311
  f.components = [
1292
- ...f.components.filter((v) => v.props.rendered_in !== R),
1312
+ ...f.components.filter((E) => E.props.rendered_in !== R),
1293
1313
  ...h.components
1294
1314
  ], f.dependencies = [
1295
- ...f.dependencies.filter((v) => v.rendered_in !== R),
1315
+ ...f.dependencies.filter((E) => E.rendered_in !== R),
1296
1316
  ...h.dependencies
1297
1317
  ];
1298
- const K = f.components.some((v) => v.type === "state"), y = f.dependencies.some(
1299
- (v) => v.targets.some((j) => j[1] === "unload")
1318
+ const Z = f.components.some((E) => E.type === "state"), y = f.dependencies.some(
1319
+ (E) => E.targets.some((U) => U[1] === "unload")
1300
1320
  );
1301
- f.connect_heartbeat = K || y, await Fe(f), i({
1321
+ f.connect_heartbeat = Z || y, await Fe(f), i({
1302
1322
  type: "render",
1303
1323
  data: h,
1304
1324
  endpoint: _,
1305
1325
  fn_index: d
1306
1326
  });
1307
1327
  }
1308
- const Ge = this.handle_blob(
1328
+ const He = this.handle_blob(
1309
1329
  f.root,
1310
- qe,
1311
- _e
1330
+ Be,
1331
+ fe
1312
1332
  ).then(async (h) => {
1313
- if (Z = {
1314
- data: Y(
1333
+ if (W = {
1334
+ data: V(
1315
1335
  h,
1316
1336
  B,
1317
1337
  f.components,
@@ -1321,7 +1341,7 @@ function Kt(e, s = {}, t, n, o, r) {
1321
1341
  event_data: t,
1322
1342
  fn_index: d,
1323
1343
  trigger_id: n
1324
- }, Ot(d, f))
1344
+ }, At(d, f))
1325
1345
  i({
1326
1346
  type: "status",
1327
1347
  endpoint: _,
@@ -1329,26 +1349,26 @@ function Kt(e, s = {}, t, n, o, r) {
1329
1349
  queue: !1,
1330
1350
  fn_index: d,
1331
1351
  time: /* @__PURE__ */ new Date()
1332
- }), oe(
1333
- `${f.root}${T}/run${_.startsWith("/") ? _ : `/${_}`}${F ? "?" + F : ""}`,
1352
+ }), ne(
1353
+ `${f.root}${T}/run${_.startsWith("/") ? _ : `/${_}`}${G ? "?" + G : ""}`,
1334
1354
  {
1335
- ...Z,
1336
- session_hash: g
1355
+ ...W,
1356
+ session_hash: m
1337
1357
  },
1338
- fe
1339
- ).then(async ([y, v]) => {
1340
- const j = y.data;
1341
- if (v == 200)
1358
+ he
1359
+ ).then(async ([y, E]) => {
1360
+ const U = y.data;
1361
+ if (E == 200)
1342
1362
  i({
1343
1363
  type: "data",
1344
1364
  endpoint: _,
1345
1365
  fn_index: d,
1346
- data: Y(
1347
- j,
1366
+ data: V(
1367
+ U,
1348
1368
  B,
1349
1369
  f.components,
1350
1370
  "output",
1351
- W.with_null_state
1371
+ J.with_null_state
1352
1372
  ),
1353
1373
  time: /* @__PURE__ */ new Date(),
1354
1374
  event_data: t,
@@ -1395,40 +1415,40 @@ function Kt(e, s = {}, t, n, o, r) {
1395
1415
  fn_index: d,
1396
1416
  time: /* @__PURE__ */ new Date()
1397
1417
  });
1398
- var K = new URLSearchParams({
1418
+ var Z = new URLSearchParams({
1399
1419
  fn_index: d.toString(),
1400
- session_hash: g
1420
+ session_hash: m
1401
1421
  }).toString();
1402
1422
  let y = new URL(
1403
- `${f.root}${T}/${Te}?${F ? F + "&" : ""}${K}`
1423
+ `${f.root}${T}/${Ae}?${G ? G + "&" : ""}${Z}`
1404
1424
  );
1405
- if (this.jwt && y.searchParams.set("__sign", this.jwt), U = this.stream(y), !U)
1425
+ if (this.jwt && y.searchParams.set("__sign", this.jwt), j = this.stream(y), !j)
1406
1426
  return Promise.reject(
1407
1427
  new Error("Cannot connect to SSE endpoint: " + y.toString())
1408
1428
  );
1409
- U.onmessage = async function(v) {
1410
- const j = JSON.parse(v.data), { type: O, status: C, data: D } = Ee(
1411
- j,
1412
- me[d]
1429
+ j.onmessage = async function(E) {
1430
+ const U = JSON.parse(E.data), { type: O, status: D, data: b } = ve(
1431
+ U,
1432
+ _e[d]
1413
1433
  );
1414
- if (O === "update" && C && !x)
1434
+ if (O === "update" && D && !x)
1415
1435
  i({
1416
1436
  type: "status",
1417
1437
  endpoint: _,
1418
1438
  fn_index: d,
1419
1439
  time: /* @__PURE__ */ new Date(),
1420
- ...C
1421
- }), C.stage === "error" && (U?.close(), a());
1440
+ ...D
1441
+ }), D.stage === "error" && (j?.close(), a());
1422
1442
  else if (O === "data") {
1423
- let [k, I] = await oe(
1443
+ let [q, P] = await ne(
1424
1444
  `${f.root}${T}/queue/data`,
1425
1445
  {
1426
- ...Z,
1427
- session_hash: g,
1428
- event_id: b
1446
+ ...W,
1447
+ session_hash: m,
1448
+ event_id: v
1429
1449
  }
1430
1450
  );
1431
- I !== 200 && (i({
1451
+ P !== 200 && (i({
1432
1452
  type: "status",
1433
1453
  stage: "error",
1434
1454
  message: L,
@@ -1436,34 +1456,34 @@ function Kt(e, s = {}, t, n, o, r) {
1436
1456
  endpoint: _,
1437
1457
  fn_index: d,
1438
1458
  time: /* @__PURE__ */ new Date()
1439
- }), U?.close(), a());
1440
- } else O === "complete" ? x = C : O === "log" ? i({
1459
+ }), j?.close(), a());
1460
+ } else O === "complete" ? x = D : O === "log" ? i({
1441
1461
  type: "log",
1442
- title: D.title,
1443
- log: D.log,
1444
- level: D.level,
1462
+ title: b.title,
1463
+ log: b.log,
1464
+ level: b.level,
1445
1465
  endpoint: _,
1446
- duration: D.duration,
1447
- visible: D.visible,
1466
+ duration: b.duration,
1467
+ visible: b.visible,
1448
1468
  fn_index: d
1449
1469
  }) : (O === "generating" || O === "streaming") && i({
1450
1470
  type: "status",
1451
1471
  time: /* @__PURE__ */ new Date(),
1452
- ...C,
1453
- stage: C?.stage,
1472
+ ...D,
1473
+ stage: D?.stage,
1454
1474
  queue: !0,
1455
1475
  endpoint: _,
1456
1476
  fn_index: d
1457
1477
  });
1458
- D && (i({
1478
+ b && (i({
1459
1479
  type: "data",
1460
1480
  time: /* @__PURE__ */ new Date(),
1461
- data: Y(
1462
- D.data,
1481
+ data: V(
1482
+ b.data,
1463
1483
  B,
1464
1484
  f.components,
1465
1485
  "output",
1466
- W.with_null_state
1486
+ J.with_null_state
1467
1487
  ),
1468
1488
  endpoint: _,
1469
1489
  fn_index: d,
@@ -1473,11 +1493,11 @@ function Kt(e, s = {}, t, n, o, r) {
1473
1493
  type: "status",
1474
1494
  time: /* @__PURE__ */ new Date(),
1475
1495
  ...x,
1476
- stage: C?.stage,
1496
+ stage: D?.stage,
1477
1497
  queue: !0,
1478
1498
  endpoint: _,
1479
1499
  fn_index: d
1480
- }), U?.close(), a()));
1500
+ }), j?.close(), a()));
1481
1501
  };
1482
1502
  } else if (A == "sse_v1" || A == "sse_v2" || A == "sse_v2.1" || A == "sse_v3") {
1483
1503
  i({
@@ -1490,34 +1510,34 @@ function Kt(e, s = {}, t, n, o, r) {
1490
1510
  });
1491
1511
  let y = "";
1492
1512
  typeof window < "u" && typeof document < "u" && (y = window?.location?.hostname);
1493
- const j = y.includes(".dev.") ? `https://moon-${y.split(".")[1]}.dev.spaces.huggingface.tech` : "https://huggingface.co";
1494
- return (typeof window < "u" && typeof document < "u" && window.parent != window && window.supports_zerogpu_headers ? Tt("zerogpu-headers", j) : Promise.resolve(null)).then((k) => {
1495
- const I = { ...fe, ...k || {} };
1496
- return oe(
1497
- `${f.root}${T}/${Ze}?${F}`,
1513
+ const E = Ue(y);
1514
+ return (typeof window < "u" && typeof document < "u" && window.parent != window && !!E && window.supports_zerogpu_headers ? xt("zerogpu-headers", E) : Promise.resolve(null)).then((b) => {
1515
+ const q = { ...he, ...b || {} };
1516
+ return ne(
1517
+ `${f.root}${T}/${Ve}?${G}`,
1498
1518
  {
1499
- ...Z,
1500
- session_hash: g
1519
+ ...W,
1520
+ session_hash: m
1501
1521
  },
1502
- I
1522
+ q
1503
1523
  );
1504
- }).then(async ([k, I]) => {
1505
- if (k.event_id && (q = k.event_id), I === 503)
1524
+ }).then(async ([b, q]) => {
1525
+ if (b.event_id && (I = b.event_id), q === 503)
1506
1526
  i({
1507
1527
  type: "status",
1508
1528
  stage: "error",
1509
- message: Ae,
1529
+ message: xe,
1510
1530
  queue: !0,
1511
1531
  endpoint: _,
1512
1532
  fn_index: d,
1513
1533
  time: /* @__PURE__ */ new Date(),
1514
1534
  visible: !0
1515
1535
  });
1516
- else if (I === 422)
1536
+ else if (q === 422)
1517
1537
  i({
1518
1538
  type: "status",
1519
1539
  stage: "error",
1520
- message: k.detail,
1540
+ message: b.detail,
1521
1541
  queue: !0,
1522
1542
  endpoint: _,
1523
1543
  fn_index: d,
@@ -1525,13 +1545,13 @@ function Kt(e, s = {}, t, n, o, r) {
1525
1545
  time: /* @__PURE__ */ new Date(),
1526
1546
  visible: !0
1527
1547
  }), a();
1528
- else if (I !== 200) {
1529
- const M = k?.error === L;
1548
+ else if (q !== 200) {
1549
+ const P = b?.error === L;
1530
1550
  i({
1531
1551
  type: "status",
1532
1552
  stage: "error",
1533
- broken: M,
1534
- message: M ? L : k.detail || k.error,
1553
+ broken: P,
1554
+ message: P ? L : b.detail || b.error,
1535
1555
  queue: !0,
1536
1556
  endpoint: _,
1537
1557
  fn_index: d,
@@ -1539,84 +1559,84 @@ function Kt(e, s = {}, t, n, o, r) {
1539
1559
  visible: !0
1540
1560
  });
1541
1561
  } else {
1542
- b = k.event_id, q = b;
1543
- let M = async function(re) {
1562
+ v = b.event_id, I = v;
1563
+ let P = async function(ie) {
1544
1564
  try {
1545
- const { type: E, status: S, data: $, original_msg: He } = Ee(
1546
- re,
1547
- me[d]
1565
+ const { type: S, status: $, data: k, original_msg: We } = ve(
1566
+ ie,
1567
+ _e[d]
1548
1568
  );
1549
- if (E == "heartbeat")
1569
+ if (S == "heartbeat")
1550
1570
  return;
1551
- if (E === "update" && S && !x)
1571
+ if (S === "update" && $ && !x)
1552
1572
  i({
1553
1573
  type: "status",
1554
1574
  endpoint: _,
1555
1575
  fn_index: d,
1556
1576
  time: /* @__PURE__ */ new Date(),
1557
- original_msg: He,
1558
- ...S
1577
+ original_msg: We,
1578
+ ...$
1559
1579
  });
1560
- else if (E === "complete")
1561
- x = S;
1562
- else if (E == "unexpected_error" || E == "broken_connection") {
1563
- console.error("Unexpected error", S?.message);
1564
- const Je = E === "broken_connection";
1580
+ else if (S === "complete")
1581
+ x = $;
1582
+ else if (S == "unexpected_error" || S == "broken_connection") {
1583
+ console.error("Unexpected error", $?.message);
1584
+ const Ze = S === "broken_connection";
1565
1585
  i({
1566
1586
  type: "status",
1567
1587
  stage: "error",
1568
- message: S?.message || "An Unexpected Error Occurred!",
1588
+ message: $?.message || "An Unexpected Error Occurred!",
1569
1589
  queue: !0,
1570
1590
  endpoint: _,
1571
- broken: Je,
1572
- session_not_found: S?.session_not_found,
1591
+ broken: Ze,
1592
+ session_not_found: $?.session_not_found,
1573
1593
  fn_index: d,
1574
1594
  time: /* @__PURE__ */ new Date()
1575
1595
  });
1576
- } else if (E === "log") {
1596
+ } else if (S === "log") {
1577
1597
  i({
1578
1598
  type: "log",
1579
- title: $.title,
1580
- log: $.log,
1581
- level: $.level,
1599
+ title: k.title,
1600
+ log: k.log,
1601
+ level: k.level,
1582
1602
  endpoint: _,
1583
- duration: $.duration,
1584
- visible: $.visible,
1603
+ duration: k.duration,
1604
+ visible: k.visible,
1585
1605
  fn_index: d
1586
1606
  });
1587
1607
  return;
1588
- } else (E === "generating" || E === "streaming") && (i({
1608
+ } else (S === "generating" || S === "streaming") && (i({
1589
1609
  type: "status",
1590
1610
  time: /* @__PURE__ */ new Date(),
1591
- ...S,
1592
- stage: S?.stage,
1611
+ ...$,
1612
+ stage: $?.stage,
1593
1613
  queue: !0,
1594
1614
  endpoint: _,
1595
1615
  fn_index: d
1596
- }), $ && B.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(A) && Ht(se, b, $));
1597
- $ && (i({
1616
+ }), k && B.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(A) && Kt(te, v, k));
1617
+ k && (i({
1598
1618
  type: "data",
1599
1619
  time: /* @__PURE__ */ new Date(),
1600
- data: Y(
1601
- $.data,
1620
+ data: V(
1621
+ k.data,
1602
1622
  B,
1603
1623
  f.components,
1604
1624
  "output",
1605
- W.with_null_state
1625
+ J.with_null_state
1606
1626
  ),
1607
1627
  endpoint: _,
1608
1628
  fn_index: d
1609
- }), $.render_config && await ge($.render_config), x && (i({
1629
+ }), k.render_config && await ge(k.render_config), x && (i({
1610
1630
  type: "status",
1611
1631
  time: /* @__PURE__ */ new Date(),
1612
1632
  ...x,
1613
- stage: S?.stage,
1633
+ stage: $?.stage,
1614
1634
  queue: !0,
1615
1635
  endpoint: _,
1616
1636
  fn_index: d
1617
- }), a())), (S?.stage === "complete" || S?.stage === "error") && (ne[b] && delete ne[b], b in se && delete se[b]);
1618
- } catch (E) {
1619
- console.error("Unexpected client exception", E), i({
1637
+ }), a())), ($?.stage === "complete" || $?.stage === "error") && (se[v] && delete se[v], v in te && delete te[v]);
1638
+ } catch (S) {
1639
+ console.error("Unexpected client exception", S), i({
1620
1640
  type: "status",
1621
1641
  stage: "error",
1622
1642
  message: "An Unexpected Error Occurred!",
@@ -1624,47 +1644,47 @@ function Kt(e, s = {}, t, n, o, r) {
1624
1644
  endpoint: _,
1625
1645
  fn_index: d,
1626
1646
  time: /* @__PURE__ */ new Date()
1627
- }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(A) && (he(ee, Ue.abort_controller), ee.open = !1, a());
1647
+ }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(A) && (de(X, ze.abort_controller), X.open = !1, a());
1628
1648
  }
1629
1649
  };
1630
- b in te && (te[b].forEach((re) => M(re)), delete te[b]), ne[b] = M, Ie.add(b), ee.open || await this.open_stream();
1650
+ v in ee && (ee[v].forEach((ie) => P(ie)), delete ee[v]), se[v] = P, qe.add(v), X.open || await this.open_stream();
1631
1651
  }
1632
1652
  });
1633
1653
  }
1634
1654
  });
1635
- let Me = !1;
1636
- const ie = [], G = [], we = {
1637
- [Symbol.asyncIterator]: () => we,
1655
+ let Je = !1;
1656
+ const oe = [], M = [], me = {
1657
+ [Symbol.asyncIterator]: () => me,
1638
1658
  next: c,
1639
1659
  throw: async (h) => (l(h), c()),
1640
1660
  return: async () => (a(), { value: void 0, done: !0 }),
1641
- cancel: Be,
1661
+ cancel: Me,
1642
1662
  send_chunk: (h) => {
1643
- this.post_data(`${f.root}${T}/stream/${q}`, {
1663
+ this.post_data(`${f.root}${T}/stream/${I}`, {
1644
1664
  ...h,
1645
1665
  session_hash: this.session_hash
1646
1666
  });
1647
1667
  },
1648
1668
  close_stream: () => {
1649
1669
  this.post_data(
1650
- `${f.root}${T}/stream/${q}/close`,
1670
+ `${f.root}${T}/stream/${I}/close`,
1651
1671
  {}
1652
1672
  ), a();
1653
1673
  },
1654
- event_id: () => q,
1655
- wait_for_id: async () => (await Ge, b)
1674
+ event_id: () => I,
1675
+ wait_for_id: async () => (await He, v)
1656
1676
  };
1657
- return we;
1677
+ return me;
1658
1678
  } catch (i) {
1659
1679
  throw console.error("Submit function encountered an error:", i), i;
1660
1680
  }
1661
1681
  }
1662
- function Vt(e) {
1682
+ function es(e) {
1663
1683
  return {
1664
1684
  then: (s, t) => t(e)
1665
1685
  };
1666
1686
  }
1667
- function Yt(e, s, t, n) {
1687
+ function ts(e, s, t, n) {
1668
1688
  let o, r, i;
1669
1689
  if (typeof s == "number")
1670
1690
  o = s, r = e.unnamed_endpoints[o], i = n.dependencies.find((a) => a.id == s);
@@ -1680,7 +1700,7 @@ function Yt(e, s, t, n) {
1680
1700
  );
1681
1701
  return { fn_index: o, endpoint_info: r, dependency: i };
1682
1702
  }
1683
- class Q {
1703
+ class Y {
1684
1704
  app_reference;
1685
1705
  options;
1686
1706
  deep_link = null;
@@ -1705,7 +1725,7 @@ class Q {
1705
1725
  current_payload;
1706
1726
  get_url_config(s = null) {
1707
1727
  if (!this.config)
1708
- throw new Error(N);
1728
+ throw new Error(C);
1709
1729
  s === null && (s = window.location.href);
1710
1730
  const t = (i) => i.replace(/^\/+|\/+$/g, "");
1711
1731
  let n = t(new URL(this.config.root).pathname), o = t(new URL(s).pathname), r;
@@ -1713,7 +1733,7 @@ class Q {
1713
1733
  }
1714
1734
  get_page_config(s) {
1715
1735
  if (!this.config)
1716
- throw new Error(N);
1736
+ throw new Error(C);
1717
1737
  let t = this.config;
1718
1738
  return s in t.page || (s = ""), {
1719
1739
  ...t,
@@ -1737,7 +1757,7 @@ class Q {
1737
1757
  const t = new Headers();
1738
1758
  return this && this.cookies && t.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((o, r) => {
1739
1759
  t.append(r, o);
1740
- }), this && this.options.token && t.append("Authorization", `Bearer ${this.options.token}`), this.abort_controller = new AbortController(), this.stream_instance = Zt(s.toString(), {
1760
+ }), this && this.options.token && t.append("Authorization", `Bearer ${this.options.token}`), this.abort_controller = new AbortController(), this.stream_instance = Qt(s.toString(), {
1741
1761
  credentials: "include",
1742
1762
  headers: t,
1743
1763
  signal: this.abort_controller.signal
@@ -1754,21 +1774,21 @@ class Q {
1754
1774
  resolve_config;
1755
1775
  resolve_cookies;
1756
1776
  constructor(s, t = { events: ["data"] }) {
1757
- this.app_reference = s, this.deep_link = t.query_params?.deep_link || null, t.events || (t.events = ["data"]), this.options = t, this.current_payload = {}, t.cookies && (this.cookies = t.cookies), this.view_api = yt.bind(this), this.upload_files = bt.bind(this), this.handle_blob = At.bind(this), this.post_data = Dt.bind(this), this.submit = Kt.bind(this), this.predict = Nt.bind(this), this.open_stream = Mt.bind(this), this.resolve_config = dt.bind(this), this.resolve_cookies = ht.bind(this), this.upload = kt.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1777
+ this.app_reference = s, this.deep_link = t.query_params?.deep_link || null, t.events || (t.events = ["data"]), this.options = t, this.current_payload = {}, t.cookies && (this.cookies = t.cookies), this.view_api = vt.bind(this), this.upload_files = Et.bind(this), this.handle_blob = Dt.bind(this), this.post_data = Nt.bind(this), this.submit = Xt.bind(this), this.predict = Pt.bind(this), this.open_stream = Zt.bind(this), this.resolve_config = ft.bind(this), this.resolve_cookies = _t.bind(this), this.upload = Ot.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1758
1778
  }
1759
1779
  async init() {
1760
- this.options.auth && await this.resolve_cookies(), await this._resolve_config().then(
1780
+ Gt(), this.options.auth && await this.resolve_cookies(), await this._resolve_config().then(
1761
1781
  ({ config: s }) => this._resolve_heartbeat(s)
1762
- ), this.api_info = await this.view_api(), this.api_map = pt(this.config?.dependencies || []);
1782
+ ), this.api_info = await this.view_api(), this.api_map = ht(this.config?.dependencies || []);
1763
1783
  }
1764
1784
  async _resolve_heartbeat(s) {
1765
- if (s && (this.config = s, this.api_prefix = s.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.token && (this.jwt = await be(
1785
+ if (s && (this.config = s, this.api_prefix = s.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.token && (this.jwt = await ye(
1766
1786
  this.config.space_id,
1767
1787
  this.options.token,
1768
1788
  this.cookies
1769
- ))), s.space_id && this.options.token && (this.jwt = await be(s.space_id, this.options.token)), this.config && this.config.connect_heartbeat) {
1789
+ ))), s.space_id && this.options.token && (this.jwt = await ye(s.space_id, this.options.token)), this.config && this.config.connect_heartbeat) {
1770
1790
  const t = new URL(
1771
- `${this.config.root}${this.api_prefix}/${Xe}/${this.session_hash}`
1791
+ `${this.config.root}${this.api_prefix}/${tt}/${this.session_hash}`
1772
1792
  );
1773
1793
  this.jwt && t.searchParams.set("__sign", this.jwt), this.heartbeat_event || (this.heartbeat_event = this.stream(t));
1774
1794
  }
@@ -1781,7 +1801,7 @@ class Q {
1781
1801
  }
1782
1802
  async reconnect() {
1783
1803
  const s = new URL(
1784
- `${this.config.root}${this.api_prefix}/${nt}`
1804
+ `${this.config.root}${this.api_prefix}/${it}`
1785
1805
  );
1786
1806
  let t;
1787
1807
  try {
@@ -1795,7 +1815,7 @@ class Q {
1795
1815
  return t !== this.config.app_id ? "changed" : "connected";
1796
1816
  }
1797
1817
  close() {
1798
- this.closed = !0, he(this.stream_status, this.abort_controller);
1818
+ this.closed = !0, de(this.stream_status, this.abort_controller);
1799
1819
  }
1800
1820
  set_current_payload(s) {
1801
1821
  this.current_payload = s;
@@ -1803,25 +1823,25 @@ class Q {
1803
1823
  static async duplicate(s, t = {
1804
1824
  events: ["data"]
1805
1825
  }) {
1806
- return It(s, t);
1826
+ return qt(s, t);
1807
1827
  }
1808
1828
  async _resolve_config() {
1809
- const { http_protocol: s, host: t, space_id: n } = await de(
1829
+ const { http_protocol: s, host: t, space_id: n } = await pe(
1810
1830
  this.app_reference,
1811
1831
  this.options.token
1812
1832
  ), { status_callback: o } = this.options;
1813
- n && o && await je(n, o);
1833
+ n && o && await Ie(n, o);
1814
1834
  let r;
1815
1835
  try {
1816
1836
  let i = `${s}//${t}`;
1817
1837
  if (r = await this.resolve_config(i), !r)
1818
- throw new Error(N);
1838
+ throw new Error(C);
1819
1839
  return this.config_success(r);
1820
1840
  } catch (i) {
1821
1841
  if (n && o)
1822
- H(
1842
+ F(
1823
1843
  n,
1824
- pe.test(n) ? "space_name" : "subdomain",
1844
+ le.test(n) ? "space_name" : "subdomain",
1825
1845
  this.handle_space_success
1826
1846
  );
1827
1847
  else
@@ -1839,18 +1859,18 @@ class Q {
1839
1859
  try {
1840
1860
  this.api_info = await this.view_api();
1841
1861
  } catch (t) {
1842
- console.error(it + t.message);
1862
+ console.error(at + t.message);
1843
1863
  }
1844
1864
  return this.prepare_return_obj();
1845
1865
  }
1846
1866
  async handle_space_success(s) {
1847
1867
  if (!this)
1848
- throw new Error(N);
1868
+ throw new Error(C);
1849
1869
  const { status_callback: t } = this.options;
1850
1870
  if (t && t(s), s.status === "running")
1851
1871
  try {
1852
1872
  if (this.config = await this._resolve_config(), this.api_prefix = this?.config?.api_prefix || "", !this.config)
1853
- throw new Error(N);
1873
+ throw new Error(C);
1854
1874
  return await this.config_success(this.config);
1855
1875
  } catch (n) {
1856
1876
  throw t && t({
@@ -1863,7 +1883,7 @@ class Q {
1863
1883
  }
1864
1884
  async component_server(s, t, n) {
1865
1885
  if (!this.config)
1866
- throw new Error(N);
1886
+ throw new Error(C);
1867
1887
  const o = {}, { token: r } = this.options, { session_hash: i } = this;
1868
1888
  r && (o.Authorization = `Bearer ${this.options.token}`);
1869
1889
  let a, u = this.config.components.find(
@@ -1887,7 +1907,7 @@ class Q {
1887
1907
  r && (o.Authorization = `Bearer ${r}`);
1888
1908
  try {
1889
1909
  const p = await this.fetch(
1890
- `${a}${this.api_prefix}/${et}/`,
1910
+ `${a}${this.api_prefix}/${st}/`,
1891
1911
  {
1892
1912
  method: "POST",
1893
1913
  body: l,
@@ -1917,24 +1937,24 @@ class Q {
1917
1937
  };
1918
1938
  }
1919
1939
  }
1920
- async function ts(e, s = {
1940
+ async function is(e, s = {
1921
1941
  events: ["data"]
1922
1942
  }) {
1923
- return await Q.connect(e, s);
1943
+ return await Y.connect(e, s);
1924
1944
  }
1925
- async function ss(e, s) {
1926
- return await Q.duplicate(e, s);
1945
+ async function rs(e, s) {
1946
+ return await Y.duplicate(e, s);
1927
1947
  }
1928
1948
  export {
1929
- Q as Client,
1930
- X as FileData,
1931
- ct as MISSING_CREDENTIALS_MSG,
1932
- ts as client,
1933
- ss as duplicate,
1934
- es as handle_file,
1935
- Nt as predict,
1936
- Xt as prepare_files,
1937
- Kt as submit,
1938
- kt as upload,
1939
- bt as upload_files
1949
+ Y as Client,
1950
+ Q as FileData,
1951
+ lt as MISSING_CREDENTIALS_MSG,
1952
+ is as client,
1953
+ rs as duplicate,
1954
+ os as handle_file,
1955
+ Pt as predict,
1956
+ ns as prepare_files,
1957
+ Xt as submit,
1958
+ Ot as upload,
1959
+ Et as upload_files
1940
1960
  };