@seedprotocol/arweave 0.8.1 → 0.8.2-next.1774.gc97b5ba

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.
@@ -5,25 +5,25 @@ var n = "arweave.net", r = "", i = "", a = "127.0.0.1", o = 1984, s = `https://$
5
5
  "arweave.net",
6
6
  "zigza.xyz",
7
7
  "ar.seedprotocol.io"
8
- ], l = ["permagate.io"], u = [...c, ...l], d = ["ARWEAVE_READ_GATEWAYS", "NEXT_PUBLIC_ARWEAVE_READ_GATEWAYS"], ee = [
8
+ ], l = ["permagate.io"], u = [...c, ...l], d = ["ARWEAVE_READ_GATEWAYS", "NEXT_PUBLIC_ARWEAVE_READ_GATEWAYS"], f = [
9
9
  "NEXT_PUBLIC_ARWEAVE_HOST",
10
10
  "ARWEAVE_HOST",
11
11
  "VITE_ARWEAVE_HOST"
12
12
  ];
13
- function te(e) {
13
+ function ee(e) {
14
14
  let t = e.trim();
15
15
  return t.startsWith("http://") ? t.slice(7).replace(/\/$/, "") : t.startsWith("https://") ? t.slice(8).replace(/\/$/, "") : t.replace(/\/$/, "");
16
16
  }
17
- function ne() {
18
- if (typeof process < "u" && process.env) for (let e of ee) {
17
+ function te() {
18
+ if (typeof process < "u" && process.env) for (let e of f) {
19
19
  let t = process.env[e]?.trim();
20
- if (t) return te(t);
20
+ if (t) return ee(t);
21
21
  }
22
22
  }
23
- function f(e) {
24
- return m(e, p());
23
+ function p(e) {
24
+ return re(e, ne());
25
25
  }
26
- function p() {
26
+ function ne() {
27
27
  if (typeof process > "u" || !process.env) return [...c];
28
28
  for (let e of d) {
29
29
  let t = process.env[e]?.trim();
@@ -31,7 +31,7 @@ function p() {
31
31
  }
32
32
  return [...c];
33
33
  }
34
- function m(e, t) {
34
+ function re(e, t) {
35
35
  let n = /* @__PURE__ */ new Set(), r = [], i = (e) => e.trim().toLowerCase().replace(/\/$/, ""), a = (e) => {
36
36
  let t = e.trim().replace(/\/$/, "");
37
37
  if (!t) return;
@@ -42,7 +42,7 @@ function m(e, t) {
42
42
  for (let e of t) a(e);
43
43
  return r;
44
44
  }
45
- function re(e) {
45
+ function ie(e) {
46
46
  let t = e.trim().toLowerCase();
47
47
  if (!t) return !1;
48
48
  if (t.endsWith("arweave.net") || t.endsWith("ar-io.net")) return !0;
@@ -54,46 +54,52 @@ function re(e) {
54
54
  }
55
55
  //#endregion
56
56
  //#region src/content/arweaveContent.ts
57
- var h;
58
- function ie(e) {
59
- h = e;
57
+ var m;
58
+ function ae(e) {
59
+ m = e;
60
60
  }
61
- function ae() {
62
- return h !== void 0;
61
+ function oe() {
62
+ return m !== void 0;
63
63
  }
64
- async function g(e, t) {
65
- return h ? h(e, t) : e;
64
+ async function h(e, t) {
65
+ return m ? m(e, t) : e;
66
66
  }
67
- function oe(e) {
67
+ var se = "seed-private/v1\n";
68
+ function ce(e) {
69
+ if (e.length < 16) return !1;
70
+ for (let t = 0; t < 16; t++) if (e[t] !== se.charCodeAt(t)) return !1;
71
+ return !0;
72
+ }
73
+ function le(e) {
68
74
  return (e.headers?.get("content-type"))?.split(";")[0]?.trim().toLowerCase() || void 0;
69
75
  }
70
- async function se(e, t) {
71
- return g({
76
+ async function ue(e, t) {
77
+ return h({
72
78
  bytes: new Uint8Array(await e.arrayBuffer()),
73
- contentType: oe(e)
79
+ contentType: le(e)
74
80
  }, t);
75
81
  }
76
82
  //#endregion
77
83
  //#region src/moduleOwner.ts
78
- var _ = Symbol.for("@seedprotocol/arweave:clientOwner"), ce = Object.freeze({ package: "@seedprotocol/arweave" });
79
- function le() {
80
- globalThis[_] = ce;
84
+ var g = Symbol.for("@seedprotocol/arweave:clientOwner"), _ = Object.freeze({ package: "@seedprotocol/arweave" });
85
+ function de() {
86
+ globalThis[g] = _;
81
87
  }
82
- var ue = class extends Error {
88
+ var v = class extends Error {
83
89
  constructor() {
84
90
  super("Two copies of @seedprotocol/arweave are loaded, and the Arweave client was registered on the other copy (e.g. by SeedClient). Reads through this copy would use a different client and gateway. Make sure every @seedprotocol/* package is the same version and installed once (`npm ls @seedprotocol/arweave`). With Vite, keep @seedprotocol/* packages out of optimizeDeps.exclude so they are pre-bundled together, and dedupe them (seedVitePlugin does) when they are linked into the app."), this.name = "DuplicateArweaveModuleError";
85
91
  }
86
92
  };
87
- function de() {
88
- let e = globalThis[_];
89
- if (e !== void 0 && e !== ce) throw new ue();
90
- }
91
93
  function fe() {
92
- delete globalThis[_];
94
+ let e = globalThis[g];
95
+ if (e !== void 0 && e !== _) throw new v();
96
+ }
97
+ function pe() {
98
+ delete globalThis[g];
93
99
  }
94
100
  //#endregion
95
101
  //#region src/ArweaveClient/BaseArweaveClient.ts
96
- function v(e) {
102
+ function y(e) {
97
103
  let t = e.trim();
98
104
  return t.startsWith("http://") ? {
99
105
  protocol: "http",
@@ -106,11 +112,11 @@ function v(e) {
106
112
  host: t.replace(/\/$/, "")
107
113
  };
108
114
  }
109
- var y = n, b = "https", x = !1, S = !1, C = class e {
115
+ var b = n, x = "https", S = !1, C = !1, w = class e {
110
116
  static _impl = null;
111
117
  static configure(t) {
112
118
  if (!t) throw Error("Cannot configure ArweaveClient with undefined or null. Ensure the platform-specific ArweaveClient is properly created.");
113
- e._impl = t, le();
119
+ e._impl = t, de();
114
120
  }
115
121
  static isConfigured() {
116
122
  return e._impl != null;
@@ -120,10 +126,10 @@ var y = n, b = "https", x = !1, S = !1, C = class e {
120
126
  return e._impl;
121
127
  }
122
128
  static resolveGateway() {
123
- let e = ne();
124
- return e && !x && !S ? v(e) : {
125
- protocol: b,
126
- host: y
129
+ let e = te();
130
+ return e && !S && !C ? y(e) : {
131
+ protocol: x,
132
+ host: b
127
133
  };
128
134
  }
129
135
  static getHost() {
@@ -162,22 +168,22 @@ var y = n, b = "https", x = !1, S = !1, C = class e {
162
168
  return `${e}://${t}`;
163
169
  }
164
170
  static setHost(e) {
165
- let t = v(e);
166
- y = t.host, b = t.protocol, x = !0, S = !1;
171
+ let t = y(e);
172
+ b = t.host, x = t.protocol, S = !0, C = !1;
167
173
  }
168
174
  static isReadGatewayLocked() {
169
- return x;
175
+ return S;
170
176
  }
171
177
  static resetReadGatewaySelectionStateForTests() {
172
- S = !1;
178
+ C = !1;
173
179
  }
174
180
  static setPreferredReadGateway(e) {
175
- let t = v(e);
176
- y = t.host, b = t.protocol, x = !1;
181
+ let t = y(e);
182
+ b = t.host, x = t.protocol, S = !1;
177
183
  }
178
184
  static applyProbedReadGateway(e) {
179
- let t = v(e);
180
- y = t.host, b = t.protocol, x = !1, S = !0;
185
+ let t = y(e);
186
+ b = t.host, x = t.protocol, S = !1, C = !0;
181
187
  }
182
188
  static getEndpoint() {
183
189
  return `${this.getBaseUrl()}/graphql`;
@@ -196,8 +202,8 @@ var y = n, b = "https", x = !1, S = !1, C = class e {
196
202
  }
197
203
  static async getTransactionData(t, n) {
198
204
  let r = await e.requireImpl().getTransactionData(t, n);
199
- if (n?.decode === !1 || !ae()) return r;
200
- let i = typeof r == "string", { bytes: a } = await g({ bytes: i ? new TextEncoder().encode(r) : r }, { transactionId: t });
205
+ if (n?.decode === !1 || !oe()) return r;
206
+ let i = typeof r == "string", { bytes: a } = await h({ bytes: i ? new TextEncoder().encode(r) : r }, { transactionId: t });
201
207
  return i ? new TextDecoder().decode(a) : a;
202
208
  }
203
209
  static getTransactionTags(t) {
@@ -209,99 +215,99 @@ var y = n, b = "https", x = !1, S = !1, C = class e {
209
215
  static downloadFiles(t) {
210
216
  return e.requireImpl().downloadFiles(t);
211
217
  }
212
- }, pe = 1, me = 6e4, w = pe, T = me, E = /* @__PURE__ */ new Map();
213
- function D(e) {
218
+ }, me = 1, he = 6e4, T = me, E = he, D = /* @__PURE__ */ new Map();
219
+ function O(e) {
214
220
  let t = e.trim();
215
221
  return t ? (t.startsWith("http://") ? t = t.slice(7) : t.startsWith("https://") && (t = t.slice(8)), t.replace(/\/$/, "").toLowerCase()) : "";
216
222
  }
217
- function he(e) {
218
- let t = E.get(e);
223
+ function ge(e) {
224
+ let t = D.get(e);
219
225
  return t || (t = {
220
226
  failures: 0,
221
227
  openedAt: null,
222
228
  halfOpenProbeInFlight: !1
223
- }, E.set(e, t)), t;
229
+ }, D.set(e, t)), t;
224
230
  }
225
- function O(e, t) {
226
- return e.openedAt == null ? "closed" : t - e.openedAt >= T ? "half-open" : "open";
231
+ function k(e, t) {
232
+ return e.openedAt == null ? "closed" : t - e.openedAt >= E ? "half-open" : "open";
227
233
  }
228
- function ge(e) {
229
- e.failureThreshold != null && e.failureThreshold >= 1 && (w = e.failureThreshold), e.openDurationMs != null && e.openDurationMs >= 0 && (T = e.openDurationMs);
234
+ function _e(e) {
235
+ e.failureThreshold != null && e.failureThreshold >= 1 && (T = e.failureThreshold), e.openDurationMs != null && e.openDurationMs >= 0 && (E = e.openDurationMs);
230
236
  }
231
- function _e() {
232
- E.clear(), w = pe, T = me;
237
+ function ve() {
238
+ D.clear(), T = me, E = he;
233
239
  }
234
- function k(e, t = Date.now()) {
235
- let n = D(e);
240
+ function A(e, t = Date.now()) {
241
+ let n = O(e);
236
242
  if (!n) return !1;
237
- let r = E.get(n);
243
+ let r = D.get(n);
238
244
  if (!r) return !1;
239
- let i = O(r, t);
245
+ let i = k(r, t);
240
246
  return !!(i === "open" || i === "half-open" && r.halfOpenProbeInFlight);
241
247
  }
242
- function ve(e, t = Date.now()) {
243
- let n = D(e);
248
+ function ye(e, t = Date.now()) {
249
+ let n = O(e);
244
250
  if (!n) return "closed";
245
- let r = E.get(n);
246
- return r ? O(r, t) : "closed";
251
+ let r = D.get(n);
252
+ return r ? k(r, t) : "closed";
247
253
  }
248
- function A(e, t = Date.now()) {
249
- let n = D(e);
254
+ function j(e, t = Date.now()) {
255
+ let n = O(e);
250
256
  if (!n) return;
251
- let r = he(n);
252
- O(r, t) === "half-open" && (r.halfOpenProbeInFlight = !0);
257
+ let r = ge(n);
258
+ k(r, t) === "half-open" && (r.halfOpenProbeInFlight = !0);
253
259
  }
254
- function j(e) {
255
- let t = D(e), n = t ? E.get(t) : void 0;
260
+ function M(e) {
261
+ let t = O(e), n = t ? D.get(t) : void 0;
256
262
  n && (n.halfOpenProbeInFlight = !1);
257
263
  }
258
- function M(e) {
259
- let t = D(e);
260
- t && E.set(t, {
264
+ function N(e) {
265
+ let t = O(e);
266
+ t && D.set(t, {
261
267
  failures: 0,
262
268
  openedAt: null,
263
269
  halfOpenProbeInFlight: !1
264
270
  });
265
271
  }
266
- function N(e, t = Date.now()) {
267
- let n = D(e);
272
+ function P(e, t = Date.now()) {
273
+ let n = O(e);
268
274
  if (!n) return;
269
- let r = he(n);
270
- r.failures += 1, r.halfOpenProbeInFlight = !1, r.failures >= w && (r.openedAt = t);
275
+ let r = ge(n);
276
+ r.failures += 1, r.halfOpenProbeInFlight = !1, r.failures >= T && (r.openedAt = t);
271
277
  }
272
- function ye(e = Date.now()) {
278
+ function be(e = Date.now()) {
273
279
  let t = [];
274
- for (let n of E.keys()) k(n, e) && t.push(n);
280
+ for (let n of D.keys()) A(n, e) && t.push(n);
275
281
  return t;
276
282
  }
277
283
  //#endregion
278
284
  //#region src/ArweaveClient/selectReadGateway.ts
279
- var P = 18e4, be = 6e4, xe = 5e3, F = null, I = null, L = null;
280
- function R() {
281
- F = null, I = null;
282
- }
283
- function Se() {
284
- R(), L = null, _e(), C.resetReadGatewaySelectionStateForTests(), C.isReadGatewayLocked() || C.setPreferredReadGateway(n);
285
+ var F = 18e4, xe = 6e4, Se = 5e3, I = null, L = null, R = null;
286
+ function z() {
287
+ I = null, L = null;
285
288
  }
286
289
  function Ce() {
287
- return C.isReadGatewayLocked() ? !0 : F && Date.now() < F.expiresAt ? F.healthy : L != null;
290
+ z(), R = null, ve(), w.resetReadGatewaySelectionStateForTests(), w.isReadGatewayLocked() || w.setPreferredReadGateway(n);
288
291
  }
289
292
  function we() {
290
- return L;
293
+ return w.isReadGatewayLocked() ? !0 : I && Date.now() < I.expiresAt ? I.healthy : R != null;
294
+ }
295
+ function Te() {
296
+ return R;
291
297
  }
292
- async function z(e, t = {}) {
298
+ async function B(e, t = {}) {
293
299
  if (t instanceof AbortSignal) throw TypeError("probeGateway takes options: pass { signal }, not an AbortSignal");
294
- let { signal: n, timeoutMs: r = xe, recordCircuit: i = !0 } = t, a = `${e.replace(/\/$/, "")}/info`, o = e;
300
+ let { signal: n, timeoutMs: r = Se, recordCircuit: i = !0 } = t, a = `${e.replace(/\/$/, "")}/info`, o = e;
295
301
  try {
296
302
  o = new URL(e.includes("://") ? e : `https://${e}`).host;
297
303
  } catch {
298
304
  o = e.replace(/^https?:\/\//, "").replace(/\/$/, "");
299
305
  }
300
306
  if (i) {
301
- if (k(o)) return !1;
302
- A(o);
307
+ if (A(o)) return !1;
308
+ j(o);
303
309
  }
304
- let s = (e) => (i && (e ? M(o) : N(o)), e), c = () => (i && j(o), !1);
310
+ let s = (e) => (i && (e ? N(o) : P(o)), e), c = () => (i && M(o), !1);
305
311
  if (n?.aborted) return c();
306
312
  let l = new AbortController(), u = setTimeout(() => l.abort(), r), d = () => l.abort(n?.reason);
307
313
  n?.addEventListener("abort", d, { once: !0 });
@@ -326,56 +332,56 @@ async function z(e, t = {}) {
326
332
  clearTimeout(u), n?.removeEventListener("abort", d);
327
333
  }
328
334
  }
329
- async function Te(e, t = "https", n) {
335
+ async function V(e, t = "https", n) {
330
336
  for (let r of e) {
331
337
  let e = r.trim().replace(/\/$/, "");
332
- if (e && !k(e) && await z(`${t}://${e}`, { signal: n })) return e;
338
+ if (e && !A(e) && await B(`${t}://${e}`, { signal: n })) return e;
333
339
  }
334
340
  return null;
335
341
  }
336
342
  function Ee() {
337
- return f(C.getHost());
338
- }
339
- async function B(e) {
340
- if (C.isReadGatewayLocked()) return C.getHost();
341
- if (F && Date.now() < F.expiresAt) return F.host;
342
- if (I) return I;
343
- I = (async () => {
344
- let t = await Te(Ee(), C.getProtocol(), e);
345
- if (!t && e?.aborted) return L ?? C.getHost();
346
- if (C.isReadGatewayLocked()) F = {
347
- host: C.getHost(),
343
+ return p(w.getHost());
344
+ }
345
+ async function De(e) {
346
+ if (w.isReadGatewayLocked()) return w.getHost();
347
+ if (I && Date.now() < I.expiresAt) return I.host;
348
+ if (L) return L;
349
+ L = (async () => {
350
+ let t = await V(Ee(), w.getProtocol(), e);
351
+ if (!t && e?.aborted) return R ?? w.getHost();
352
+ if (w.isReadGatewayLocked()) I = {
353
+ host: w.getHost(),
348
354
  healthy: !0,
349
- expiresAt: Date.now() + P
355
+ expiresAt: Date.now() + F
350
356
  };
351
- else if (t) C.applyProbedReadGateway(t), L = t, F = {
357
+ else if (t) w.applyProbedReadGateway(t), R = t, I = {
352
358
  host: t,
353
359
  healthy: !0,
354
- expiresAt: Date.now() + P
360
+ expiresAt: Date.now() + F
355
361
  };
356
362
  else {
357
- let e = L ?? C.getHost();
358
- L && C.getHost() !== L && C.applyProbedReadGateway(L), F = {
363
+ let e = R ?? w.getHost();
364
+ R && w.getHost() !== R && w.applyProbedReadGateway(R), I = {
359
365
  host: e,
360
366
  healthy: !1,
361
- expiresAt: Date.now() + be
367
+ expiresAt: Date.now() + xe
362
368
  };
363
369
  }
364
- return F.host;
370
+ return I.host;
365
371
  })();
366
372
  try {
367
- return await I;
373
+ return await L;
368
374
  } finally {
369
- I = null;
375
+ L = null;
370
376
  }
371
377
  }
372
378
  //#endregion
373
379
  //#region src/gateway/resolveSeedGatewayEndpoints.ts
374
- var De = 18e4, Oe = 6e4, V = null, H = /* @__PURE__ */ new Map();
375
- function ke() {
376
- V = null, H.clear();
380
+ var Oe = 18e4, ke = 6e4, H = null, U = /* @__PURE__ */ new Map();
381
+ function Ae() {
382
+ H = null, U.clear();
377
383
  }
378
- function Ae(e) {
384
+ function je(e) {
379
385
  let t = e?.trim() || "arweave.net";
380
386
  return t.startsWith("http://") ? {
381
387
  protocol: "http",
@@ -388,11 +394,11 @@ function Ae(e) {
388
394
  host: t.replace(/\/$/, "")
389
395
  };
390
396
  }
391
- function je(e) {
392
- let { host: t, protocol: n } = Ae(e.arweaveDomain);
397
+ function Me(e) {
398
+ let { host: t, protocol: n } = je(e.arweaveDomain);
393
399
  return `${n}://${t}`;
394
400
  }
395
- function U(e) {
401
+ function W(e) {
396
402
  let t = e.hyper?.localSidecarHost?.trim() || "127.0.0.1", n = e.hyper?.localSidecarPort ?? 1984;
397
403
  return {
398
404
  host: n === 80 || n === 443 ? t : `${t}:${n}`,
@@ -400,7 +406,7 @@ function U(e) {
400
406
  baseUrl: `http://${t}:${n}`
401
407
  };
402
408
  }
403
- function Me() {
409
+ function Ne() {
404
410
  try {
405
411
  let e = globalThis.window?.location?.origin;
406
412
  return typeof e == "string" && e.length > 0 ? e.replace(/\/$/, "") : void 0;
@@ -408,30 +414,30 @@ function Me() {
408
414
  return;
409
415
  }
410
416
  }
411
- function W(e, t) {
417
+ function G(e, t) {
412
418
  let n = e.trim();
413
419
  if (!n) throw Error("proxyBaseUrl is empty");
414
420
  if (n.startsWith("http://") || n.startsWith("https://")) return n.replace(/\/$/, "");
415
421
  if (n.startsWith("/")) {
416
- let r = (t?.origin?.trim() || Me() || "").replace(/\/$/, "");
422
+ let r = (t?.origin?.trim() || Ne() || "").replace(/\/$/, "");
417
423
  if (!r) throw Error(`Relative proxyBaseUrl "${e}" requires a browser origin or resolve options.origin`);
418
424
  return `${r}${n.replace(/\/$/, "")}`;
419
425
  }
420
426
  return `https://${n.replace(/\/$/, "")}`;
421
427
  }
422
- async function G(e, t, n) {
423
- let r = Date.now(), i = t === "sidecar" ? V : H.get(t);
428
+ async function K(e, t, n) {
429
+ let r = Date.now(), i = t === "sidecar" ? H : U.get(t);
424
430
  if (i && r < i.expiresAt) return i.healthy;
425
- let a = await z(e, { signal: n });
431
+ let a = await B(e, { signal: n });
426
432
  if (!a && n?.aborted) return !1;
427
433
  let o = {
428
434
  healthy: a,
429
- expiresAt: r + (a ? De : Oe)
435
+ expiresAt: r + (a ? Oe : ke)
430
436
  };
431
- return t === "sidecar" ? V = o : H.set(t, o), a;
437
+ return t === "sidecar" ? H = o : U.set(t, o), a;
432
438
  }
433
- function Ne(e) {
434
- let { host: t, protocol: n } = Ae(e.arweaveDomain), r = `${n}://${t}`, i = e.uploadApiBaseUrl?.trim() ?? "";
439
+ function Pe(e) {
440
+ let { host: t, protocol: n } = je(e.arweaveDomain), r = `${n}://${t}`, i = e.uploadApiBaseUrl?.trim() ?? "";
435
441
  return {
436
442
  mode: e.transport ?? "http-gateway",
437
443
  arweaveHost: t,
@@ -444,8 +450,8 @@ function Ne(e) {
444
450
  publicArweaveBaseUrl: r
445
451
  };
446
452
  }
447
- function Pe(e) {
448
- let t = U(e), n = e.hyper?.gatewayHyperKey?.trim();
453
+ function Fe(e) {
454
+ let t = W(e), n = e.hyper?.gatewayHyperKey?.trim();
449
455
  return {
450
456
  mode: "hyper",
451
457
  arweaveHost: t.host,
@@ -455,10 +461,10 @@ function Pe(e) {
455
461
  uploadApiBaseUrl: t.baseUrl,
456
462
  activePath: "hyper-sidecar",
457
463
  gatewayHyperKey: n || void 0,
458
- publicArweaveBaseUrl: je(e)
464
+ publicArweaveBaseUrl: Me(e)
459
465
  };
460
466
  }
461
- function Fe(e, t) {
467
+ function Ie(e, t) {
462
468
  let n = new URL(t), r = n.protocol === "http:" ? "http" : "https", i = n.pathname.replace(/\/$/, ""), a = i ? `${n.host}${i}` : n.host, o = `${r}://${a}`;
463
469
  return {
464
470
  mode: e.transport ?? "http-gateway",
@@ -470,37 +476,37 @@ function Fe(e, t) {
470
476
  activePath: "http-proxy",
471
477
  gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0,
472
478
  proxyBaseUrl: t,
473
- publicArweaveBaseUrl: je(e)
479
+ publicArweaveBaseUrl: Me(e)
474
480
  };
475
481
  }
476
- function Ie(e) {
482
+ function Le(e) {
477
483
  return (e.hyper?.probeProxy ?? e.hyper?.probeSidecar) !== !1;
478
484
  }
479
- var Le = /^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|::1)$|\.localhost$/i;
480
- function Re(e, t) {
485
+ var Re = /^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|::1)$|\.localhost$/i;
486
+ function ze(e, t) {
481
487
  if (e.hyper?.probeSidecarFromBrowser) return !0;
482
488
  let n = globalThis.window;
483
489
  if (!n) return !0;
484
490
  let r = t ?? n.location?.origin;
485
491
  if (!r) return !0;
486
492
  try {
487
- return Le.test(new URL(r).hostname);
493
+ return Re.test(new URL(r).hostname);
488
494
  } catch {
489
495
  return !1;
490
496
  }
491
497
  }
492
- async function ze(e, t) {
498
+ async function Be(e, t) {
493
499
  let n = e.proxyBaseUrl?.trim();
494
500
  if (!n) return null;
495
- let r = W(n, { origin: t?.origin });
496
- return Ie(e) && !await G(r, `proxy:${r}`, t?.signal) ? null : Fe(e, r);
501
+ let r = G(n, { origin: t?.origin });
502
+ return Le(e) && !await K(r, `proxy:${r}`, t?.signal) ? null : Ie(e, r);
497
503
  }
498
- async function Be(e, t) {
499
- if (t?.forceSidecarProbe && ke(), t?.timeoutMs === void 0) return Ve(e, t);
504
+ async function Ve(e, t) {
505
+ if (t?.forceSidecarProbe && Ae(), t?.timeoutMs === void 0) return He(e, t);
500
506
  let n = new AbortController(), r = setTimeout(() => n.abort(), t.timeoutMs), i = t.signal, a = () => n.abort(i?.reason);
501
507
  i?.aborted ? a() : i?.addEventListener("abort", a, { once: !0 });
502
508
  try {
503
- return await Ve(e, {
509
+ return await He(e, {
504
510
  ...t,
505
511
  signal: n.signal
506
512
  });
@@ -508,46 +514,46 @@ async function Be(e, t) {
508
514
  clearTimeout(r), i?.removeEventListener("abort", a);
509
515
  }
510
516
  }
511
- async function Ve(e, t) {
517
+ async function He(e, t) {
512
518
  let n = e.transport ?? "http-gateway", r = e.hyper?.probeSidecar !== !1;
513
519
  if (n === "http-gateway") {
514
520
  if (e.proxyBaseUrl?.trim()) {
515
- let r = W(e.proxyBaseUrl, { origin: t?.origin });
516
- if (Ie(e) && !await G(r, `proxy:${r}`, t?.signal)) throw Error(`Gateway HTTP proxy not reachable at ${r}. Ensure your Node route runs createGatewayProxy (or equivalent) and mounts at proxyBaseUrl.`);
517
- return Fe({
521
+ let r = G(e.proxyBaseUrl, { origin: t?.origin });
522
+ if (Le(e) && !await K(r, `proxy:${r}`, t?.signal)) throw Error(`Gateway HTTP proxy not reachable at ${r}. Ensure your Node route runs createGatewayProxy (or equivalent) and mounts at proxyBaseUrl.`);
523
+ return Ie({
518
524
  ...e,
519
525
  transport: n
520
526
  }, r);
521
527
  }
522
- return Ne({
528
+ return Pe({
523
529
  ...e,
524
530
  transport: n
525
531
  });
526
532
  }
527
533
  if (n === "hyper") {
528
- let i = await ze({
534
+ let i = await Be({
529
535
  ...e,
530
536
  transport: n
531
537
  }, t);
532
538
  if (i) return i;
533
- let a = Pe({
539
+ let a = Fe({
534
540
  ...e,
535
541
  transport: n
536
542
  });
537
- if (r && !await G(a.arweaveBaseUrl, "sidecar", t?.signal)) throw Error(`Gateway Hyper sidecar not reachable at ${a.arweaveBaseUrl}. Run: seed-gateway connect <operator-z32-key> — or configure gateway.proxyBaseUrl for an app-server proxy.`);
543
+ if (r && !await K(a.arweaveBaseUrl, "sidecar", t?.signal)) throw Error(`Gateway Hyper sidecar not reachable at ${a.arweaveBaseUrl}. Run: seed-gateway connect <operator-z32-key> — or configure gateway.proxyBaseUrl for an app-server proxy.`);
538
544
  return a;
539
545
  }
540
- let i = await ze({
546
+ let i = await Be({
541
547
  ...e,
542
548
  transport: n
543
549
  }, t);
544
550
  if (i) return i;
545
- let a = U(e);
546
- return r && Re(e, t?.origin) && await G(a.baseUrl, "sidecar", t?.signal) ? Pe({
551
+ let a = W(e);
552
+ return r && ze(e, t?.origin) && await K(a.baseUrl, "sidecar", t?.signal) ? Fe({
547
553
  ...e,
548
554
  transport: "hyper"
549
555
  }) : {
550
- ...Ne({
556
+ ...Pe({
551
557
  ...e,
552
558
  transport: "http-gateway"
553
559
  }),
@@ -555,71 +561,71 @@ async function Ve(e, t) {
555
561
  activePath: "hybrid-fallback-http"
556
562
  };
557
563
  }
558
- function He(e, t) {
564
+ function Ue(e, t) {
559
565
  if (e.activePath === "hyper-sidecar" || e.activePath === "http-proxy") {
560
- let t = new URL(e.publicArweaveBaseUrl), n = f(t.host).map((e, n) => n === 0 ? `${t.protocol}//${e}` : `https://${e}`);
566
+ let t = new URL(e.publicArweaveBaseUrl), n = p(t.host).map((e, n) => n === 0 ? `${t.protocol}//${e}` : `https://${e}`);
561
567
  return [e.arweaveBaseUrl, ...n];
562
568
  }
563
- return f(e.arweaveHost);
569
+ return p(e.arweaveHost);
564
570
  }
565
571
  //#endregion
566
572
  //#region src/gateway/gatewayState.ts
567
- var Ue = null;
568
- function K() {
569
- return Ue;
573
+ var We = null;
574
+ function q() {
575
+ return We;
570
576
  }
571
- function We(e) {
572
- Ue = e;
577
+ function Ge(e) {
578
+ We = e;
573
579
  }
574
- var Ge = [];
575
- function q() {
576
- return Ge;
580
+ var Ke = [];
581
+ function J() {
582
+ return Ke;
577
583
  }
578
- function Ke(e) {
584
+ function qe(e) {
579
585
  let t = [], n = /* @__PURE__ */ new Set();
580
586
  for (let r of e) {
581
587
  let e = r?.trim();
582
588
  if (!e) continue;
583
589
  let i;
584
590
  try {
585
- let t = new URL(/^https?:\/\//i.test(e) ? e : W(e));
591
+ let t = new URL(/^https?:\/\//i.test(e) ? e : G(e));
586
592
  i = `${t.origin}${t.pathname.replace(/\/+$/, "")}`;
587
593
  } catch {
588
594
  continue;
589
595
  }
590
596
  n.has(i) || (n.add(i), t.push(i));
591
597
  }
592
- Ge = t;
598
+ Ke = t;
593
599
  }
594
600
  //#endregion
595
601
  //#region src/gateway/readBaseUrls.ts
596
- var qe = 1e4;
597
- function J(e, t, n) {
602
+ var Je = 1e4;
603
+ function Y(e, t, n) {
598
604
  let r = n.trim().replace(/\/$/, "");
599
605
  r && !t.has(r) && (t.add(r), e.push(r));
600
606
  }
601
- function Y(e) {
602
- let t = K(), n = C.getProtocol(), r = t ? He(t) : e?.fallbackHosts?.length ? [...e.fallbackHosts] : f(C.getHost()), i = [], a = /* @__PURE__ */ new Set();
607
+ function X(e) {
608
+ let t = q(), n = w.getProtocol(), r = t ? Ue(t) : e?.fallbackHosts?.length ? [...e.fallbackHosts] : p(w.getHost()), i = [], a = /* @__PURE__ */ new Set();
603
609
  for (let e of r) {
604
610
  let t = e.trim();
605
- t && J(i, a, /^https?:\/\//i.test(t) ? t : `${n}://${t}`);
611
+ t && Y(i, a, /^https?:\/\//i.test(t) ? t : `${n}://${t}`);
606
612
  }
607
613
  return i;
608
614
  }
609
- function Je(e) {
615
+ function Ye(e) {
610
616
  let t = [], n = /* @__PURE__ */ new Set();
611
- for (let e of q()) J(t, n, e);
612
- for (let r of Y(e)) J(t, n, r);
617
+ for (let e of J()) Y(t, n, e);
618
+ for (let r of X(e)) Y(t, n, r);
613
619
  return t;
614
620
  }
615
- async function Ye() {
621
+ async function Xe() {
616
622
  try {
617
- let e = K();
623
+ let e = q();
618
624
  if (e && (e.activePath === "hyper-sidecar" || e.activePath === "http-proxy")) return;
619
- await B();
625
+ await De();
620
626
  } catch {}
621
627
  }
622
- async function X(e, t, n) {
628
+ async function Z(e, t, n) {
623
629
  let r = new AbortController(), i = setTimeout(() => r.abort(), n?.timeoutMs ?? 1e4);
624
630
  try {
625
631
  let n = await fetch(`${e.replace(/\/$/, "")}/raw/${encodeURIComponent(t)}`, {
@@ -634,27 +640,27 @@ async function X(e, t, n) {
634
640
  clearTimeout(i);
635
641
  }
636
642
  }
637
- async function Xe(e, t) {
643
+ async function Ze(e, t) {
638
644
  let n = /* @__PURE__ */ new Set(), r = async (r) => {
639
645
  for (let i of r) {
640
646
  if (n.has(i)) continue;
641
647
  n.add(i);
642
- let r = await X(i, e, t);
648
+ let r = await Z(i, e, t);
643
649
  if (r) try {
644
- let { bytes: t } = await se(r, { transactionId: e });
645
- if (t.byteLength > 0) return t;
650
+ let n = t?.decode === !1 ? new Uint8Array(await r.arrayBuffer()) : (await ue(r, { transactionId: e })).bytes;
651
+ if (n.byteLength > 0) return n;
646
652
  } catch {}
647
653
  }
648
654
  };
649
- return await r(q()) || (await Ye(), r(Y(t)));
655
+ return await r(J()) || (await Xe(), r(X(t)));
650
656
  }
651
- async function Ze(e, t) {
652
- let n = await Xe(e, t);
653
- return n && new TextDecoder().decode(n) || void 0;
657
+ async function Qe(e, t) {
658
+ let n = await Ze(e, t);
659
+ if (n && !ce(n)) return new TextDecoder().decode(n) || void 0;
654
660
  }
655
661
  //#endregion
656
662
  //#region src/graphql/gql/gql.ts
657
- var Qe = {
663
+ var $e = {
658
664
  "\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n": {
659
665
  kind: "Document",
660
666
  definitions: [{
@@ -1008,13 +1014,13 @@ var Qe = {
1008
1014
  }]
1009
1015
  }
1010
1016
  };
1011
- function $e(e) {
1012
- return Qe[e] ?? {};
1017
+ function et(e) {
1018
+ return $e[e] ?? {};
1013
1019
  }
1014
1020
  //#endregion
1015
1021
  //#region src/ArweaveClient/queries.ts
1016
- var et = $e("\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"), tt = $e("\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"), nt = 1e4, rt = 2e4, it = 1e3, at = (e) => e >= 500 || e === 429;
1017
- async function ot(e, t, n) {
1022
+ var tt = et("\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"), nt = et("\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"), rt = 1e4, it = 2e4, at = 1e3, ot = (e) => e >= 500 || e === 429;
1023
+ async function st(e, t, n) {
1018
1024
  let r = new AbortController(), i = setTimeout(() => r.abort(), n);
1019
1025
  try {
1020
1026
  let n = await fetch(`${e.replace(/\/$/, "")}/${encodeURIComponent(t)}`, {
@@ -1022,7 +1028,7 @@ async function ot(e, t, n) {
1022
1028
  credentials: "omit",
1023
1029
  signal: r.signal
1024
1030
  });
1025
- return await n.body?.cancel().catch(() => {}), at(n.status) ? {
1031
+ return await n.body?.cancel().catch(() => {}), ot(n.status) ? {
1026
1032
  kind: "retry",
1027
1033
  status: n.status
1028
1034
  } : {
@@ -1038,23 +1044,23 @@ async function ot(e, t, n) {
1038
1044
  clearTimeout(i);
1039
1045
  }
1040
1046
  }
1041
- function st() {
1042
- let e = Je(), t = K();
1047
+ function ct() {
1048
+ let e = Ye(), t = q();
1043
1049
  if (t?.activePath !== "hyper-sidecar" && t?.activePath !== "http-proxy") return e;
1044
- let n = /* @__PURE__ */ new Set([...q(), t.arweaveBaseUrl.replace(/\/$/, "")]);
1050
+ let n = /* @__PURE__ */ new Set([...J(), t.arweaveBaseUrl.replace(/\/$/, "")]);
1045
1051
  return e.filter((e) => n.has(e));
1046
1052
  }
1047
- async function ct(e, t = {}) {
1048
- let n = t.timeoutMs ?? 1e4, r = performance.now() + (t.totalTimeoutMs ?? 2e4), i = t.baseUrls ?? st(), a = i.filter((e) => !k(e)), o = a.length > 0 ? a : i, s = 500;
1053
+ async function lt(e, t = {}) {
1054
+ let n = t.timeoutMs ?? 1e4, r = performance.now() + (t.totalTimeoutMs ?? 2e4), i = t.baseUrls ?? ct(), a = i.filter((e) => !A(e)), o = a.length > 0 ? a : i, s = 500;
1049
1055
  for (let [t, i] of o.entries()) {
1050
1056
  let a = r - performance.now();
1051
1057
  if (a <= 0 || t > 0 && a < Math.min(n, 1e3)) break;
1052
- let o = await ot(i, e, Math.min(n, a));
1053
- if (o.kind === "answer") return M(i), {
1058
+ let o = await st(i, e, Math.min(n, a));
1059
+ if (o.kind === "answer") return N(i), {
1054
1060
  status: o.status >= 200 && o.status < 300 ? 200 : o.status,
1055
1061
  confirmed: null
1056
1062
  };
1057
- N(i), s = o.status;
1063
+ P(i), s = o.status;
1058
1064
  }
1059
1065
  return {
1060
1066
  status: s,
@@ -1063,8 +1069,8 @@ async function ct(e, t = {}) {
1063
1069
  }
1064
1070
  //#endregion
1065
1071
  //#region src/default/ArweaveClient.ts
1066
- var Z = t("seedArweave:ArweaveClient"), lt = 3e4;
1067
- function ut(e) {
1072
+ var Q = t("seedArweave:ArweaveClient"), ut = 3e4;
1073
+ function dt(e) {
1068
1074
  return (t, n) => {
1069
1075
  if (typeof AbortController > "u") return fetch(t, n);
1070
1076
  let r = new AbortController(), i = n?.signal ?? void 0, a = setTimeout(() => r.abort(/* @__PURE__ */ Error(`Arweave GraphQL request timed out after ${e} ms`)), e), o = () => r.abort(i?.reason);
@@ -1076,34 +1082,34 @@ function ut(e) {
1076
1082
  });
1077
1083
  };
1078
1084
  }
1079
- var Q = null, dt = null, $ = async () => {
1080
- let e = `${C.getProtocol()}://${C.getHost()}`;
1081
- if (Q && dt === e) return Q;
1085
+ var $ = null, ft = null, pt = async () => {
1086
+ let e = `${w.getProtocol()}://${w.getHost()}`;
1087
+ if ($ && ft === e) return $;
1082
1088
  let t = await import("arweave"), n = t.default ?? t;
1083
- return typeof n.init != "function" && typeof n.default?.init == "function" && (n = n.default), dt = e, Q = n.init(C.getArweaveJsApiConfig()), Q;
1084
- }, ft = class {
1089
+ return typeof n.init != "function" && typeof n.default?.init == "function" && (n = n.default), ft = e, $ = n.init(w.getArweaveJsApiConfig()), $;
1090
+ }, mt = class {
1085
1091
  getArweaveClient() {
1086
- return new e(C.getEndpoint(), { fetch: ut(lt) });
1092
+ return new e(w.getEndpoint(), { fetch: dt(ut) });
1087
1093
  }
1088
1094
  async getTransactionStatus(e) {
1089
- return ct(e);
1095
+ return lt(e);
1090
1096
  }
1091
1097
  async getTransactionData(e, t) {
1092
- let n = t?.decode === !1 ? [] : q();
1098
+ let n = t?.decode === !1 ? [] : J();
1093
1099
  for (let r of n) {
1094
- let n = await X(r, e);
1100
+ let n = await Z(r, e);
1095
1101
  if (n) try {
1096
1102
  return t?.string ? await n.text() : new Uint8Array(await n.arrayBuffer());
1097
1103
  } catch (e) {
1098
- Z("Error reading preferred gateway response:", e);
1104
+ Q("Error reading preferred gateway response:", e);
1099
1105
  }
1100
1106
  }
1101
- if (C.getGatewayPath()) {
1102
- let n = await fetch(C.getRawUrl(e));
1107
+ if (w.getGatewayPath()) {
1108
+ let n = await fetch(w.getRawUrl(e));
1103
1109
  if (!n.ok) throw Error(`Failed to fetch transaction data: HTTP ${n.status}`);
1104
1110
  return t?.string ? n.text() : new Uint8Array(await n.arrayBuffer());
1105
1111
  }
1106
- let r = await $();
1112
+ let r = await pt();
1107
1113
  try {
1108
1114
  let n = await r.transactions.getData(e, {
1109
1115
  decode: t?.decode ?? !0,
@@ -1111,28 +1117,28 @@ var Q = null, dt = null, $ = async () => {
1111
1117
  });
1112
1118
  return t?.string && typeof n == "string" || n instanceof Uint8Array ? n : typeof n == "string" ? new TextEncoder().encode(n) : n;
1113
1119
  } catch (e) {
1114
- throw Z("Error fetching transaction data:", e), e;
1120
+ throw Q("Error fetching transaction data:", e), e;
1115
1121
  }
1116
1122
  }
1117
1123
  async getTransactionTags(e) {
1118
1124
  let t = this.getArweaveClient();
1119
1125
  try {
1120
- let n = await t.request(et, { transactionId: e });
1126
+ let n = await t.request(tt, { transactionId: e });
1121
1127
  return n.tags?.tags ? n.tags.tags.map((e) => ({
1122
1128
  name: e.name,
1123
1129
  value: e.value
1124
1130
  })) : [];
1125
1131
  } catch (e) {
1126
- return Z("Error fetching transaction tags:", e), [];
1132
+ return Q("Error fetching transaction tags:", e), [];
1127
1133
  }
1128
1134
  }
1129
1135
  async createTransaction(e, t) {
1130
- let n = await (await $()).createTransaction({ data: e });
1136
+ let n = await (await pt()).createTransaction({ data: e });
1131
1137
  if (t?.tags) for (let e of t.tags) n.addTag(e.name, e.value);
1132
1138
  return n;
1133
1139
  }
1134
1140
  async downloadFiles(e) {
1135
- let { transactionIds: t, excludedTransactions: n } = e, r = [], i = C.getBaseUrl();
1141
+ let { transactionIds: t, excludedTransactions: n } = e, r = [], i = w.getBaseUrl();
1136
1142
  for (let e of t) if (!n?.has(e)) try {
1137
1143
  let t = `${i}/raw/${e}`, n = await fetch(t);
1138
1144
  if (!n.ok) {
@@ -1151,7 +1157,7 @@ var Q = null, dt = null, $ = async () => {
1151
1157
  data: a
1152
1158
  });
1153
1159
  } catch (t) {
1154
- Z(`Error downloading transaction ${e}:`, t), r.push({
1160
+ Q(`Error downloading transaction ${e}:`, t), r.push({
1155
1161
  transactionId: e,
1156
1162
  success: !1,
1157
1163
  error: t instanceof Error ? t.message : String(t)
@@ -1161,6 +1167,6 @@ var Q = null, dt = null, $ = async () => {
1161
1167
  }
1162
1168
  };
1163
1169
  //#endregion
1164
- export { s as $, Se as A, M as B, Be as C, R as D, we as E, ve as F, fe as G, C as H, k as I, se as J, oe as K, ye as L, A as M, j as N, Ce as O, ge as P, c as Q, D as R, W as S, B as T, ue as U, _e as V, de as W, g as X, ie as Y, ee as Z, K as _, it as a, u as at, He as b, et as c, re as ct, Xe as d, n as et, X as f, q as g, Y as h, rt as i, i as it, Te as j, z as k, qe as l, m as lt, Je as m, ft as n, o as nt, ct as o, f as ot, Ze as p, ae as q, nt as r, r as rt, tt as s, p as st, lt as t, a as tt, Ye as u, ne as ut, Ke as v, U as w, ke as x, We as y, N as z };
1170
+ export { c as $, Ce as A, N as B, Ve as C, z as D, Te as E, ye as F, pe as G, w as H, A as I, ce as J, le as K, be as L, j as M, M as N, we as O, _e as P, f as Q, O as R, G as S, De as T, v as U, ve as V, fe as W, ae as X, ue as Y, h as Z, q as _, at as a, i as at, Ue as b, tt as c, ne as ct, Ze as d, te as dt, s as et, Z as f, J as g, X as h, it as i, r as it, V as j, B as k, Je as l, ie as lt, Ye as m, mt as n, a as nt, lt as o, u as ot, Qe as p, oe as q, rt as r, o as rt, nt as s, p as st, ut as t, n as tt, Xe as u, re as ut, qe as v, W as w, Ae as x, Ge as y, P as z };
1165
1171
 
1166
- //# sourceMappingURL=ArweaveClient-BhqiFB9a.js.map
1172
+ //# sourceMappingURL=ArweaveClient-BsqZ1E90.js.map