starknetkit
Version:
<!-- logo --> <p align="center"> <img width='300' src="https://starknetkit-website-git-blo-1541-argentlabs.vercel.app/starknetKit-logo.svg"> </p>
2,007 lines • 148 kB
JavaScript
import { constants as Re } from "starknet";
import { g as cr, c as Ee } from "./connector-4bc69b15.js";
import { P as qt } from "./lastConnected-c0cae438.js";
const Wa = (t) => t === Re.StarknetChainId.SN_MAIN ? Re.StarknetChainId.SN_MAIN : Re.StarknetChainId.SN_SEPOLIA, an = "https://web.ready.co", Ha = `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="2" y="2" width="28" height="28" rx="5.6" fill="black"/>
<g clip-path="url(#clip0_9_981)">
<path d="M10.5 20.9999H21.5C21.9166 20.9999 22.2736 20.7452 22.424 20.383L18.1419 16.3631L16.3739 18.0018C16.163 18.1973 15.837 18.1973 15.6261 18.0018L13.8581 16.3631L9.57603 20.383C9.72637 20.7452 10.0834 20.9999 10.5 20.9999Z" fill="white"/>
<path d="M18.8771 15.6817L22.5 19.0828V12.3239L18.8771 15.6817Z" fill="white"/>
<path d="M13.1229 15.6817L9.5 12.3239V19.0828L13.1229 15.6817Z" fill="white"/>
<path d="M22 10.9999H10C9.8752 10.9999 9.76108 11.0456 9.67348 11.1212L15.7734 16.7748C15.9012 16.8933 16.0988 16.8933 16.2266 16.7748L22.3265 11.1212C22.2389 11.0456 22.1248 10.9999 22 10.9999Z" fill="white"/>
</g>
<rect x="20" y="20" width="12" height="12" rx="2.4" fill="#FF875B"/>
<path d="M26.9611 22.6222H25.0397C24.9755 22.6222 24.924 22.675 24.9226 22.7406C24.8838 24.5841 23.9398 26.3339 22.3148 27.5732C22.2633 27.6126 22.2515 27.6865 22.2892 27.7397L23.4134 29.3279C23.4517 29.3819 23.5262 29.3941 23.5786 29.3544C24.5947 28.5845 25.4119 27.6558 26.0004 26.6264C26.5889 27.6558 27.4062 28.5845 28.4222 29.3544C28.4746 29.3941 28.5492 29.3819 28.5875 29.3279L29.7117 27.7397C29.7493 27.6865 29.7376 27.6126 29.686 27.5732C28.0611 26.3339 27.117 24.5841 27.0782 22.7406C27.0768 22.675 27.0253 22.6222 26.9611 22.6222Z" fill="white"/>
<defs>
<clipPath id="clip0_9_981">
<rect width="16" height="16" fill="white" transform="translate(8 7.99991)"/>
</clipPath>
</defs>
</svg>`, Ja = "https://static.hydrogen.argent47.net/webwallet/iframe_whitelist_testnet.json", Ya = "https://static.argent.net/webwallet/iframe_whitelist_mainnet.json", J = Re.NetworkName, on = J.SN_SEPOLIA;
function Ga(t) {
try {
const { origin: e } = new URL(t);
if (e.includes("localhost") || e.includes("127.0.0.1"))
return on;
if (e.includes("hydrogen") || e.includes("sepolia-web.staging"))
return J.SN_SEPOLIA;
if (e.includes("staging"))
return J.SN_MAIN;
if (e.includes("dev") || e.includes("sepolia-web.ready.co"))
return J.SN_SEPOLIA;
if (e.includes("ready.co"))
return J.SN_MAIN;
} catch {
console.warn(
"Could not determine network from target URL, defaulting to mainnet-alpha"
);
}
return J.SN_MAIN;
}
function cn(t) {
return t;
}
function un(t) {
return t.length === 0 ? cn : t.length === 1 ? t[0] : function(r) {
return t.reduce((n, s) => s(n), r);
};
}
function dn(t) {
return typeof t == "object" && t !== null && "subscribe" in t;
}
function Ie(t) {
const e = {
subscribe(r) {
let n = null, s = !1, a = !1, i = !1;
function o() {
if (n === null) {
i = !0;
return;
}
a || (a = !0, typeof n == "function" ? n() : n && n.unsubscribe());
}
return n = t({
next(c) {
s || r.next?.(c);
},
error(c) {
s || (s = !0, r.error?.(c), o());
},
complete() {
s || (s = !0, r.complete?.(), o());
}
}), i && o(), {
unsubscribe: o
};
},
pipe(...r) {
return un(r)(e);
}
};
return e;
}
function ur(t) {
return (e) => {
let r = 0, n = null;
const s = [];
function a() {
n || (n = e.subscribe({
next(o) {
for (const c of s)
c.next?.(o);
},
error(o) {
for (const c of s)
c.error?.(o);
},
complete() {
for (const o of s)
o.complete?.();
}
}));
}
function i() {
if (r === 0 && n) {
const o = n;
n = null, o.unsubscribe();
}
}
return {
subscribe(o) {
return r++, s.push(o), a(), {
unsubscribe() {
r--, i();
const c = s.findIndex((u) => u === o);
c > -1 && s.splice(c, 1);
}
};
}
};
};
}
function ln(t) {
return (e) => ({
subscribe(r) {
let n = 0;
return e.subscribe({
next(a) {
r.next?.(t(a, n++));
},
error(a) {
r.error?.(a);
},
complete() {
r.complete?.();
}
});
}
});
}
function dr(t) {
return (e) => ({
subscribe(r) {
return e.subscribe({
next(n) {
t.next?.(n), r.next?.(n);
},
error(n) {
t.error?.(n), r.error?.(n);
},
complete() {
t.complete?.(), r.complete?.();
}
});
}
});
}
let fn = class lr extends Error {
constructor(e) {
super(e), this.name = "ObservableAbortError", Object.setPrototypeOf(this, lr.prototype);
}
};
function fr(t) {
let e;
return {
promise: new Promise((n, s) => {
let a = !1;
function i() {
a || (a = !0, s(new fn("This operation was aborted.")), o.unsubscribe());
}
const o = t.subscribe({
next(c) {
a = !0, n(c), i();
},
error(c) {
a = !0, s(c), i();
},
complete() {
a = !0, i();
}
});
e = i;
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
abort: e
};
}
const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
isObservable: dn,
map: ln,
observable: Ie,
observableToPromise: fr,
share: ur,
tap: dr
}, Symbol.toStringTag, { value: "Module" }));
function pr(t) {
return Ie((e) => {
function r(s = 0, a = t.op) {
const i = t.links[s];
if (!i)
throw new Error("No more links to execute - did you forget to add an ending link?");
return i({
op: a,
next(c) {
return r(s + 1, c);
}
});
}
return r().subscribe(e);
});
}
function zt(t) {
return Array.isArray(t) ? t : [
t
];
}
function hn(t) {
return (e) => {
const r = zt(t.true).map((s) => s(e)), n = zt(t.false).map((s) => s(e));
return (s) => Ie((a) => {
const i = t.condition(s.op) ? r : n;
return pr({
op: s.op,
links: i
}).subscribe(a);
});
};
}
function hr(t) {
const e = /* @__PURE__ */ Object.create(null);
for (const r in t) {
const n = t[r];
e[n] = r;
}
return e;
}
const $e = {
/**
* Invalid JSON was received by the server.
* An error occurred on the server while parsing the JSON text.
*/
PARSE_ERROR: -32700,
/**
* The JSON sent is not a valid Request object.
*/
BAD_REQUEST: -32600,
// Internal JSON-RPC error
INTERNAL_SERVER_ERROR: -32603,
NOT_IMPLEMENTED: -32603,
// Implementation specific errors
UNAUTHORIZED: -32001,
FORBIDDEN: -32003,
NOT_FOUND: -32004,
METHOD_NOT_SUPPORTED: -32005,
TIMEOUT: -32008,
CONFLICT: -32009,
PRECONDITION_FAILED: -32012,
PAYLOAD_TOO_LARGE: -32013,
UNPROCESSABLE_CONTENT: -32022,
TOO_MANY_REQUESTS: -32029,
CLIENT_CLOSED_REQUEST: -32099
};
hr($e);
hr($e);
const mn = {
PARSE_ERROR: 400,
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
NOT_FOUND: 404,
FORBIDDEN: 403,
METHOD_NOT_SUPPORTED: 405,
TIMEOUT: 408,
CONFLICT: 409,
PRECONDITION_FAILED: 412,
PAYLOAD_TOO_LARGE: 413,
UNPROCESSABLE_CONTENT: 422,
TOO_MANY_REQUESTS: 429,
CLIENT_CLOSED_REQUEST: 499,
INTERNAL_SERVER_ERROR: 500,
NOT_IMPLEMENTED: 501
};
function yn(t) {
return mn[t] ?? 500;
}
function mr(t) {
return yn(t.code);
}
const yr = () => {
};
function gr(t, e) {
return new Proxy(yr, {
get(n, s) {
if (!(typeof s != "string" || s === "then"))
return gr(t, [
...e,
s
]);
},
apply(n, s, a) {
const i = e[e.length - 1] === "apply";
return t({
args: i ? a.length >= 2 ? a[1] : [] : a,
path: i ? e.slice(0, -1) : e
});
}
});
}
const Et = (t) => gr(t, []), Rt = (t) => new Proxy(yr, {
get(e, r) {
if (!(typeof r != "string" || r === "then"))
return t(r);
}
});
function gn(t) {
const { path: e, error: r, config: n } = t, { code: s } = t.error, a = {
message: r.message,
code: $e[s],
data: {
code: s,
httpStatus: mr(r)
}
};
return n.isDev && typeof t.error.stack == "string" && (a.data.stack = t.error.stack), typeof e == "string" && (a.data.path = e), n.errorFormatter({
...t,
shape: a
});
}
function Bt(t, e) {
return "error" in e ? {
...e,
error: t.transformer.output.serialize(e.error)
} : "data" in e.result ? {
...e,
result: {
...e.result,
data: t.transformer.output.serialize(e.result.data)
}
} : e;
}
function _n(t, e) {
return Array.isArray(e) ? e.map((r) => Bt(t, r)) : Bt(t, e);
}
function vn(t) {
return !!t && !Array.isArray(t) && typeof t == "object";
}
class bn extends Error {
}
function Ot(t) {
if (t instanceof Error)
return t;
const e = typeof t;
if (!(e === "undefined" || e === "function" || t === null)) {
if (e !== "object")
return new Error(String(t));
if (vn(t)) {
const r = new bn();
for (const n in t)
r[n] = t[n];
return r;
}
}
}
const wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
createFlatProxy: Rt,
createRecursiveProxy: Et,
getCauseFromUnknown: Ot,
getErrorShape: gn,
transformTRPCResponse: _n
}, Symbol.toStringTag, { value: "Module" }));
function Ft(t) {
return !!t && !Array.isArray(t) && typeof t == "object";
}
function xn(t) {
return t instanceof _r || /**
* @deprecated
* Delete in next major
*/
t instanceof Error && t.name === "TRPCClientError";
}
function kn(t) {
return Ft(t) && Ft(t.error) && typeof t.error.code == "number" && typeof t.error.message == "string";
}
let _r = class _e extends Error {
static from(e, r = {}) {
const n = e;
return xn(n) ? (r.meta && (n.meta = {
...n.meta,
...r.meta
}), n) : kn(n) ? new _e(n.error.message, {
...r,
result: n
}) : n instanceof Error ? new _e(n.message, {
...r,
cause: Ot(n)
}) : new _e("Unknown error", {
...r,
cause: n
});
}
constructor(e, r) {
const n = r?.cause;
super(e, {
cause: n
}), this.meta = r?.meta, this.cause = n, this.shape = r?.result?.error, this.data = r?.result?.error.data, this.name = "TRPCClientError", Object.setPrototypeOf(this, _e.prototype);
}
};
function Tn(t) {
return typeof FormData > "u" ? !1 : t instanceof FormData;
}
const Ve = {
css: {
query: [
"72e3ff",
"3fb0d8"
],
mutation: [
"c5a3fc",
"904dfc"
],
subscription: [
"ff49e1",
"d83fbe"
]
},
ansi: {
regular: {
// Cyan background, black and white text respectively
query: [
"\x1B[30;46m",
"\x1B[97;46m"
],
// Magenta background, black and white text respectively
mutation: [
"\x1B[30;45m",
"\x1B[97;45m"
],
// Green background, black and white text respectively
subscription: [
"\x1B[30;42m",
"\x1B[97;42m"
]
},
bold: {
query: [
"\x1B[1;30;46m",
"\x1B[1;97;46m"
],
mutation: [
"\x1B[1;30;45m",
"\x1B[1;97;45m"
],
subscription: [
"\x1B[1;30;42m",
"\x1B[1;97;42m"
]
}
}
};
function Cn(t) {
const { direction: e, type: r, path: n, id: s, input: a } = t, i = [], o = [];
if (t.colorMode === "ansi") {
const [h, y] = Ve.ansi.regular[r], [k, C] = Ve.ansi.bold[r], A = "\x1B[0m";
return i.push(e === "up" ? h : y, e === "up" ? ">>" : "<<", r, e === "up" ? k : C, `#${s}`, n, A), e === "up" ? o.push({
input: t.input
}) : o.push({
input: t.input,
// strip context from result cause it's too noisy in terminal wihtout collapse mode
result: "result" in t.result ? t.result.result : t.result,
elapsedMs: t.elapsedMs
}), {
parts: i,
args: o
};
}
const [c, u] = Ve.css[r], d = `
background-color: #${e === "up" ? c : u};
color: ${e === "up" ? "black" : "white"};
padding: 2px;
`;
return i.push("%c", e === "up" ? ">>" : "<<", r, `#${s}`, `%c${n}%c`, "%O"), o.push(d, `${d}; font-weight: bold;`, `${d}; font-weight: normal;`), e === "up" ? o.push({
input: a,
context: t.context
}) : o.push({
input: a,
result: t.result,
elapsedMs: t.elapsedMs,
context: t.context
}), {
parts: i,
args: o
};
}
const En = ({ c: t = console, colorMode: e = "css" }) => (r) => {
const n = r.input, s = Tn(n) ? Object.fromEntries(n) : n, { parts: a, args: i } = Cn({
...r,
colorMode: e,
input: s
}), o = r.direction === "down" && r.result && (r.result instanceof Error || "error" in r.result.result) ? "error" : "log";
t[o].apply(null, [
a.join(" ")
].concat(i));
};
function Rn(t = {}) {
const { enabled: e = () => !0 } = t, r = t.colorMode ?? (typeof window > "u" ? "ansi" : "css"), { logger: n = En({
c: t.console,
colorMode: r
}) } = t;
return () => ({ op: s, next: a }) => Ie((i) => {
e({
...s,
direction: "up"
}) && n({
...s,
direction: "up"
});
const o = Date.now();
function c(u) {
const d = Date.now() - o;
e({
...s,
direction: "down",
result: u
}) && n({
...s,
direction: "down",
elapsedMs: d,
result: u
});
}
return a(s).pipe(dr({
next(u) {
c(u);
},
error(u) {
c(u);
}
})).subscribe(i);
});
}
let On = class {
$request({ type: e, input: r, path: n, context: s = {} }) {
return pr({
links: this.links,
op: {
id: ++this.requestId,
type: e,
path: n,
input: r,
context: s
}
}).pipe(ur());
}
requestAsPromise(e) {
const r = this.$request(e), { promise: n, abort: s } = fr(r);
return new Promise((i, o) => {
e.signal?.addEventListener("abort", s), n.then((c) => {
i(c.result.data);
}).catch((c) => {
o(_r.from(c));
});
});
}
query(e, r, n) {
return this.requestAsPromise({
type: "query",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
mutation(e, r, n) {
return this.requestAsPromise({
type: "mutation",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
subscription(e, r, n) {
return this.$request({
type: "subscription",
path: e,
input: r,
context: n?.context
}).subscribe({
next(a) {
a.result.type === "started" ? n.onStarted?.() : a.result.type === "stopped" ? n.onStopped?.() : n.onData?.(a.result.data);
},
error(a) {
n.onError?.(a);
},
complete() {
n.onComplete?.();
}
});
}
constructor(e) {
this.requestId = 0;
const r = (() => {
const n = e.transformer;
return n ? "input" in n ? e.transformer : {
input: n,
output: n
} : {
input: {
serialize: (s) => s,
deserialize: (s) => s
},
output: {
serialize: (s) => s,
deserialize: (s) => s
}
};
})();
this.runtime = {
transformer: {
serialize: (n) => r.input.serialize(n),
deserialize: (n) => r.output.deserialize(n)
},
combinedTransformer: r
}, this.links = e.links.map((n) => n(this.runtime));
}
};
const Sn = {
query: "query",
mutate: "mutation",
subscribe: "subscription"
}, Pn = (t) => Sn[t];
function Nn(t) {
return Rt((e) => t.hasOwnProperty(e) ? t[e] : e === "__untypedClient" ? t : Et(({ path: r, args: n }) => {
const s = [
e,
...r
], a = Pn(s.pop()), i = s.join(".");
return t[a](i, ...n);
}));
}
function An(t) {
const e = new On(t);
return Nn(e);
}
function Ln(t) {
if (t instanceof oe || t instanceof Error && t.name === "TRPCError")
return t;
const e = new oe({
code: "INTERNAL_SERVER_ERROR",
cause: t
});
return t instanceof Error && t.stack && (e.stack = t.stack), e;
}
class oe extends Error {
constructor(e) {
const r = Ot(e.cause), n = e.message ?? r?.message ?? e.code;
super(n, {
cause: r
}), this.code = e.code, this.name = "TRPCError", this.cause || (this.cause = r);
}
}
function In(t) {
return "input" in t ? t : {
input: t,
output: t
};
}
const we = {
_default: !0,
input: {
serialize: (t) => t,
deserialize: (t) => t
},
output: {
serialize: (t) => t,
deserialize: (t) => t
}
}, xe = ({ shape: t }) => t;
function $n(t) {
return Object.assign(/* @__PURE__ */ Object.create(null), t);
}
const jn = [
"query",
"mutation",
"subscription"
];
function Mn(t) {
return "router" in t._def;
}
const Dn = {
_ctx: null,
_errorShape: null,
_meta: null,
queries: {},
mutations: {},
subscriptions: {},
errorFormatter: xe,
transformer: we
}, Zn = [
/**
* Then is a reserved word because otherwise we can't return a promise that returns a Proxy
* since JS will think that `.then` is something that exists
*/
"then"
];
function vr(t) {
return function(r) {
const n = new Set(Object.keys(r).filter((c) => Zn.includes(c)));
if (n.size > 0)
throw new Error("Reserved words used in `router({})` call: " + Array.from(n).join(", "));
const s = $n({});
function a(c, u = "") {
for (const [d, h] of Object.entries(c ?? {})) {
const y = `${u}${d}`;
if (Mn(h)) {
a(h._def.procedures, `${y}.`);
continue;
}
if (s[y])
throw new Error(`Duplicate key: ${y}`);
s[y] = h;
}
}
a(r);
const i = {
_config: t,
router: !0,
procedures: s,
...Dn,
record: r,
queries: Object.entries(s).filter((c) => c[1]._def.query).reduce((c, [u, d]) => ({
...c,
[u]: d
}), {}),
mutations: Object.entries(s).filter((c) => c[1]._def.mutation).reduce((c, [u, d]) => ({
...c,
[u]: d
}), {}),
subscriptions: Object.entries(s).filter((c) => c[1]._def.subscription).reduce((c, [u, d]) => ({
...c,
[u]: d
}), {})
}, o = {
...r,
_def: i,
createCaller(c) {
return br()(o)(c);
},
getErrorShape(c) {
const { path: u, error: d } = c, { code: h } = c.error, y = {
message: d.message,
code: $e[h],
data: {
code: h,
httpStatus: mr(d)
}
};
return t.isDev && typeof c.error.stack == "string" && (y.data.stack = c.error.stack), typeof u == "string" && (y.data.path = u), this._def._config.errorFormatter({
...c,
shape: y
});
}
};
return o;
};
}
function Un(t) {
const { type: e, path: r } = t;
if (!(r in t.procedures) || !t.procedures[r]?._def[e])
throw new oe({
code: "NOT_FOUND",
message: `No "${e}"-procedure on path "${r}"`
});
const n = t.procedures[r];
return n(t);
}
function br() {
return function(e) {
const r = e._def;
return function(s) {
return Et(({ path: i, args: o }) => {
if (i.length === 1 && jn.includes(i[0]))
return Un({
procedures: r.procedures,
path: o[0],
rawInput: o[1],
ctx: s,
type: i[0]
});
const c = i.join("."), u = r.procedures[c];
let d = "query";
return u._def.mutation ? d = "mutation" : u._def.subscription && (d = "subscription"), u({
path: c,
rawInput: o[0],
ctx: s,
type: d
});
});
};
};
}
const Vt = typeof window > "u" || "Deno" in window || globalThis.process?.env?.NODE_ENV === "test" || !!globalThis.process?.env?.JEST_WORKER_ID || !!globalThis.process?.env?.VITEST_WORKER_ID;
function Wt(t) {
const e = t;
if (typeof e == "function")
return e;
if (typeof e.parseAsync == "function")
return e.parseAsync.bind(e);
if (typeof e.parse == "function")
return e.parse.bind(e);
if (typeof e.validateSync == "function")
return e.validateSync.bind(e);
if (typeof e.create == "function")
return e.create.bind(e);
if (typeof e.assert == "function")
return (r) => (e.assert(r), r);
throw new Error("Could not find a validator fn");
}
function wr(t, ...e) {
const r = Object.assign(/* @__PURE__ */ Object.create(null), t);
for (const n of e)
for (const s in n) {
if (s in r && r[s] !== n[s])
throw new Error(`Duplicate key ${s}`);
r[s] = n[s];
}
return r;
}
function qn() {
function t(r) {
return {
_middlewares: r,
unstable_pipe(n) {
const s = "_middlewares" in n ? n._middlewares : [
n
];
return t([
...r,
...s
]);
}
};
}
function e(r) {
return t([
r
]);
}
return e;
}
function Ht(t) {
return t && typeof t == "object" && !Array.isArray(t);
}
function zn(t) {
const e = async ({ next: r, rawInput: n, input: s }) => {
let a;
try {
a = await t(n);
} catch (o) {
throw new oe({
code: "BAD_REQUEST",
cause: o
});
}
const i = Ht(s) && Ht(a) ? {
...s,
...a
} : a;
return r({
input: i
});
};
return e._type = "input", e;
}
function Bn(t) {
const e = async ({ next: r }) => {
const n = await r();
if (!n.ok)
return n;
try {
const s = await t(n.data);
return {
...n,
data: s
};
} catch (s) {
throw new oe({
message: "Output validation failed",
code: "INTERNAL_SERVER_ERROR",
cause: s
});
}
};
return e._type = "output", e;
}
const xr = "middlewareMarker";
function ne(t, e) {
const { middlewares: r = [], inputs: n, meta: s, ...a } = e;
return kr({
...wr(t, a),
inputs: [
...t.inputs,
...n ?? []
],
middlewares: [
...t.middlewares,
...r
],
meta: t.meta && s ? {
...t.meta,
...s
} : s ?? t.meta
});
}
function kr(t = {}) {
const e = {
inputs: [],
middlewares: [],
...t
};
return {
_def: e,
input(r) {
const n = Wt(r);
return ne(e, {
inputs: [
r
],
middlewares: [
zn(n)
]
});
},
output(r) {
const n = Wt(r);
return ne(e, {
output: r,
middlewares: [
Bn(n)
]
});
},
meta(r) {
return ne(e, {
meta: r
});
},
/**
* @deprecated
* This functionality is deprecated and will be removed in the next major version.
*/
unstable_concat(r) {
return ne(e, r._def);
},
use(r) {
const n = "_middlewares" in r ? r._middlewares : [
r
];
return ne(e, {
middlewares: n
});
},
query(r) {
return We({
...e,
query: !0
}, r);
},
mutation(r) {
return We({
...e,
mutation: !0
}, r);
},
subscription(r) {
return We({
...e,
subscription: !0
}, r);
}
};
}
function We(t, e) {
const r = ne(t, {
resolver: e,
middlewares: [
async function(s) {
const a = await e(s);
return {
marker: xr,
ok: !0,
data: a,
ctx: s.ctx
};
}
]
});
return Vn(r._def);
}
const Fn = `
This is a client-only function.
If you want to call this function on the server, see https://trpc.io/docs/server/server-side-calls
`.trim();
function Vn(t) {
const e = async function(n) {
if (!n || !("rawInput" in n))
throw new Error(Fn);
const s = async (i = {
index: 0,
ctx: n.ctx
}) => {
try {
const o = t.middlewares[i.index];
return await o({
ctx: i.ctx,
type: n.type,
path: n.path,
rawInput: i.rawInput ?? n.rawInput,
meta: t.meta,
input: i.input,
next(u) {
const d = u;
return s({
index: i.index + 1,
ctx: d && "ctx" in d ? {
...i.ctx,
...d.ctx
} : i.ctx,
input: d && "input" in d ? d.input : i.input,
rawInput: d && "rawInput" in d ? d.rawInput : i.rawInput
});
}
});
} catch (o) {
return {
ok: !1,
error: Ln(o),
marker: xr
};
}
}, a = await s();
if (!a)
throw new oe({
code: "INTERNAL_SERVER_ERROR",
message: "No result from middlewares - did you forget to `return next()`?"
});
if (!a.ok)
throw a.error;
return a.data;
};
return e._def = t, e.meta = t.meta, e;
}
function Wn(...t) {
const e = wr({}, ...t.map((a) => a._def.record)), r = t.reduce((a, i) => {
if (i._def._config.errorFormatter && i._def._config.errorFormatter !== xe) {
if (a !== xe && a !== i._def._config.errorFormatter)
throw new Error("You seem to have several error formatters");
return i._def._config.errorFormatter;
}
return a;
}, xe), n = t.reduce((a, i) => {
if (i._def._config.transformer && i._def._config.transformer !== we) {
if (a !== we && a !== i._def._config.transformer)
throw new Error("You seem to have several transformers");
return i._def._config.transformer;
}
return a;
}, we);
return vr({
errorFormatter: r,
transformer: n,
isDev: t.some((a) => a._def._config.isDev),
allowOutsideOfServer: t.some((a) => a._def._config.allowOutsideOfServer),
isServer: t.some((a) => a._def._config.isServer),
$types: t[0]?._def._config.$types
})(e);
}
class Oe {
context() {
return new Oe();
}
meta() {
return new Oe();
}
create(e) {
return Jn()(e);
}
}
const Hn = new Oe();
function Jn() {
return function(e) {
const r = e?.errorFormatter ?? xe, s = {
transformer: In(e?.transformer ?? we),
isDev: e?.isDev ?? globalThis.process?.env?.NODE_ENV !== "production",
allowOutsideOfServer: e?.allowOutsideOfServer ?? !1,
errorFormatter: r,
isServer: e?.isServer ?? Vt,
/**
* @internal
*/
$types: Rt((a) => {
throw new Error(`Tried to access "$types.${a}" which is not available at runtime`);
})
};
if (!(e?.isServer ?? Vt) && e?.allowOutsideOfServer !== !0)
throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.");
return {
/**
* These are just types, they can't be used
* @internal
*/
_config: s,
/**
* Builder object for creating procedures
* @see https://trpc.io/docs/server/procedures
*/
procedure: kr({
meta: e?.defaultMeta
}),
/**
* Create reusable middlewares
* @see https://trpc.io/docs/server/middlewares
*/
middleware: qn(),
/**
* Create a router
* @see https://trpc.io/docs/server/routers
*/
router: vr(s),
/**
* Merge Routers
* @see https://trpc.io/docs/server/merging-routers
*/
mergeRouters: Wn,
/**
* Create a server-side caller for a router
* @see https://trpc.io/docs/server/server-side-calls
*/
createCallerFactory: br()
};
};
}
var tt = {}, je = {}, he = {}, P = {};
const me = /* @__PURE__ */ cr(pn);
var St = {}, Tr = me;
function Cr(t) {
return Tr.observable((e) => {
function r(s = 0, a = t.op) {
const i = t.links[s];
if (!i)
throw new Error("No more links to execute - did you forget to add an ending link?");
return i({
op: a,
next(c) {
return r(s + 1, c);
}
});
}
return r().subscribe(e);
});
}
function Jt(t) {
return Array.isArray(t) ? t : [
t
];
}
function Yn(t) {
return (e) => {
const r = Jt(t.true).map((s) => s(e)), n = Jt(t.false).map((s) => s(e));
return (s) => Tr.observable((a) => {
const i = t.condition(s.op) ? r : n;
return Cr({
op: s.op,
links: i
}).subscribe(a);
});
};
}
St.createChain = Cr;
St.splitLink = Yn;
var ye = {};
const Er = /* @__PURE__ */ cr(wn);
var ge = {};
function rt(t) {
return !!t && !Array.isArray(t) && typeof t == "object";
}
function Gn(t, e) {
if ("error" in t) {
const n = e.transformer.deserialize(t.error);
return {
ok: !1,
error: {
...t,
error: n
}
};
}
return {
ok: !0,
result: {
...t.result,
...(!t.result.type || t.result.type === "data") && {
type: "data",
data: e.transformer.deserialize(t.result.data)
}
}
};
}
class He extends Error {
constructor() {
super("Unable to transform response from server");
}
}
function Qn(t, e) {
let r;
try {
r = Gn(t, e);
} catch {
throw new He();
}
if (!r.ok && (!rt(r.error.error) || typeof r.error.error.code != "number"))
throw new He();
if (r.ok && !rt(r.result))
throw new He();
return r;
}
ge.isObject = rt;
ge.transformResult = Qn;
var Xn = Er, Yt = ge;
function Kn(t) {
return t instanceof Rr || /**
* @deprecated
* Delete in next major
*/
t instanceof Error && t.name === "TRPCClientError";
}
function es(t) {
return Yt.isObject(t) && Yt.isObject(t.error) && typeof t.error.code == "number" && typeof t.error.message == "string";
}
let Rr = class ve extends Error {
static from(e, r = {}) {
const n = e;
return Kn(n) ? (r.meta && (n.meta = {
...n.meta,
...r.meta
}), n) : es(n) ? new ve(n.error.message, {
...r,
result: n
}) : n instanceof Error ? new ve(n.message, {
...r,
cause: Xn.getCauseFromUnknown(n)
}) : new ve("Unknown error", {
...r,
cause: n
});
}
constructor(e, r) {
const n = r?.cause;
super(e, {
cause: n
}), this.meta = r?.meta, this.cause = n, this.shape = r?.result?.error, this.data = r?.result?.error.data, this.name = "TRPCClientError", Object.setPrototypeOf(this, ve.prototype);
}
};
ye.TRPCClientError = Rr;
var B = {}, ts = ye;
const Gt = (t) => typeof t == "function";
function Or(t) {
if (t)
return t;
if (typeof window < "u" && Gt(window.fetch))
return window.fetch;
if (typeof globalThis < "u" && Gt(globalThis.fetch))
return globalThis.fetch;
throw new Error("No fetch implementation found");
}
function rs(t) {
return t || (typeof window < "u" && window.AbortController ? window.AbortController : typeof globalThis < "u" && globalThis.AbortController ? globalThis.AbortController : null);
}
function ns(t) {
return {
url: t.url.toString().replace(/\/$/, ""),
fetch: t.fetch,
AbortController: rs(t.AbortController)
};
}
function ss(t) {
const e = {};
for (let r = 0; r < t.length; r++) {
const n = t[r];
e[r] = n;
}
return e;
}
const as = {
query: "GET",
mutation: "POST"
};
function Sr(t) {
return "input" in t ? t.runtime.transformer.serialize(t.input) : ss(t.inputs.map((e) => t.runtime.transformer.serialize(e)));
}
const Pr = (t) => {
let e = t.url + "/" + t.path;
const r = [];
if ("inputs" in t && r.push("batch=1"), t.type === "query") {
const n = Sr(t);
n !== void 0 && r.push(`input=${encodeURIComponent(JSON.stringify(n))}`);
}
return r.length && (e += "?" + r.join("&")), e;
}, Nr = (t) => {
if (t.type === "query")
return;
const e = Sr(t);
return e !== void 0 ? JSON.stringify(e) : void 0;
}, is = (t) => Lr({
...t,
contentTypeHeader: "application/json",
getUrl: Pr,
getBody: Nr
});
async function Ar(t, e) {
const r = t.getUrl(t), n = t.getBody(t), { type: s } = t, a = await t.headers();
/* istanbul ignore if -- @preserve */
if (s === "subscription")
throw new Error("Subscriptions should use wsLink");
const i = {
...t.contentTypeHeader ? {
"content-type": t.contentTypeHeader
} : {},
...t.batchModeHeader ? {
"trpc-batch-mode": t.batchModeHeader
} : {},
...a
};
return Or(t.fetch)(r, {
method: as[s],
signal: e?.signal,
body: n,
headers: i
});
}
function Lr(t) {
const e = t.AbortController ? new t.AbortController() : null, r = {};
let n = !1;
return {
promise: new Promise((i, o) => {
Ar(t, e).then((c) => (r.response = c, n = !0, c.json())).then((c) => {
r.responseJSON = c, i({
json: c,
meta: r
});
}).catch((c) => {
n = !0, o(ts.TRPCClientError.from(c, {
meta: r
}));
});
}),
cancel: () => {
n || e?.abort();
}
};
}
B.fetchHTTPResponse = Ar;
B.getBody = Nr;
B.getFetch = Or;
B.getUrl = Pr;
B.httpRequest = Lr;
B.jsonHttpRequester = is;
B.resolveHTTPLinkOptions = ns;
var Pt = {}, os = me, cs = ge, Qt = ye, nt = B;
const Je = () => {
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
};
function Ye(t) {
let e = null, r = null;
const n = () => {
clearTimeout(r), r = null, e = null;
};
function s(o) {
const c = [
[]
];
let u = 0;
for (; ; ) {
const d = o[u];
if (!d)
break;
const h = c[c.length - 1];
if (d.aborted) {
d.reject?.(new Error("Aborted")), u++;
continue;
}
if (t.validate(h.concat(d).map((k) => k.key))) {
h.push(d), u++;
continue;
}
if (h.length === 0) {
d.reject?.(new Error("Input is too big for a single dispatch")), u++;
continue;
}
c.push([]);
}
return c;
}
function a() {
const o = s(e);
n();
for (const c of o) {
if (!c.length)
continue;
const u = {
items: c,
cancel: Je
};
for (const k of c)
k.batch = u;
const d = (k, C) => {
const A = u.items[k];
A.resolve?.(C), A.batch = null, A.reject = null, A.resolve = null;
}, { promise: h, cancel: y } = t.fetch(u.items.map((k) => k.key), d);
u.cancel = y, h.then((k) => {
for (let C = 0; C < k.length; C++) {
const A = k[C];
d(C, A);
}
for (const C of u.items)
C.reject?.(new Error("Missing result")), C.batch = null;
}).catch((k) => {
for (const C of u.items)
C.reject?.(k), C.batch = null;
});
}
}
function i(o) {
const c = {
aborted: !1,
key: o,
batch: null,
resolve: Je,
reject: Je
}, u = new Promise((h, y) => {
c.reject = y, c.resolve = h, e || (e = []), e.push(c);
});
return r || (r = setTimeout(a)), {
promise: u,
cancel: () => {
c.aborted = !0, c.batch?.items.every((h) => h.aborted) && (c.batch.cancel(), c.batch = null);
}
};
}
return {
load: i
};
}
function Ir(t) {
return function(r) {
const n = nt.resolveHTTPLinkOptions(r), s = r.maxURLLength ?? 1 / 0;
return (a) => {
const i = (h) => {
const y = (C) => {
if (s === 1 / 0)
return !0;
const A = C.map((F) => F.path).join(","), te = C.map((F) => F.input);
return nt.getUrl({
...n,
runtime: a,
type: h,
path: A,
inputs: te
}).length <= s;
}, k = t({
...n,
runtime: a,
type: h,
opts: r
});
return {
validate: y,
fetch: k
};
}, o = Ye(i("query")), c = Ye(i("mutation")), u = Ye(i("subscription")), d = {
query: o,
subscription: u,
mutation: c
};
return ({ op: h }) => os.observable((y) => {
const k = d[h.type], { promise: C, cancel: A } = k.load(h);
let te;
return C.then((j) => {
te = j;
const F = cs.transformResult(j.json, a);
if (!F.ok) {
y.error(Qt.TRPCClientError.from(F.error, {
meta: j.meta
}));
return;
}
y.next({
context: j.meta,
result: F.result
}), y.complete();
}).catch((j) => {
y.error(Qt.TRPCClientError.from(j, {
meta: te?.meta
}));
}), () => {
A();
};
});
};
};
}
const us = (t) => (e) => {
const r = e.map((i) => i.path).join(","), n = e.map((i) => i.input), { promise: s, cancel: a } = nt.jsonHttpRequester({
...t,
path: r,
inputs: n,
headers() {
return t.opts.headers ? typeof t.opts.headers == "function" ? t.opts.headers({
opList: e
}) : t.opts.headers : {};
}
});
return {
promise: s.then((i) => (Array.isArray(i.json) ? i.json : e.map(() => i.json)).map((u) => ({
meta: i.meta,
json: u
}))),
cancel: a
};
}, ds = Ir(us);
Pt.createHTTPBatchLink = Ir;
Pt.httpBatchLink = ds;
var Me = {};
Object.defineProperty(Me, "__esModule", { value: !0 });
var ls = me, fs = ge, Xt = ye, $r = B;
function jr(t) {
return (e) => {
const r = $r.resolveHTTPLinkOptions(e);
return (n) => ({ op: s }) => ls.observable((a) => {
const { path: i, input: o, type: c } = s, { promise: u, cancel: d } = t.requester({
...r,
runtime: n,
type: c,
path: i,
input: o,
headers() {
return e.headers ? typeof e.headers == "function" ? e.headers({
op: s
}) : e.headers : {};
}
});
let h;
return u.then((y) => {
h = y.meta;
const k = fs.transformResult(y.json, n);
if (!k.ok) {
a.error(Xt.TRPCClientError.from(k.error, {
meta: h
}));
return;
}
a.next({
context: y.meta,
result: k.result
}), a.complete();
}).catch((y) => {
a.error(Xt.TRPCClientError.from(y, {
meta: h
}));
}), () => {
d();
};
});
};
}
const ps = jr({
requester: $r.jsonHttpRequester
});
Me.httpLink = ps;
Me.httpLinkFactory = jr;
var Nt = {};
Object.defineProperty(Nt, "__esModule", { value: !0 });
var Kt = me;
function hs(t) {
return typeof FormData > "u" ? !1 : t instanceof FormData;
}
const Ge = {
css: {
query: [
"72e3ff",
"3fb0d8"
],
mutation: [
"c5a3fc",
"904dfc"
],
subscription: [
"ff49e1",
"d83fbe"
]
},
ansi: {
regular: {
// Cyan background, black and white text respectively
query: [
"\x1B[30;46m",
"\x1B[97;46m"
],
// Magenta background, black and white text respectively
mutation: [
"\x1B[30;45m",
"\x1B[97;45m"
],
// Green background, black and white text respectively
subscription: [
"\x1B[30;42m",
"\x1B[97;42m"
]
},
bold: {
query: [
"\x1B[1;30;46m",
"\x1B[1;97;46m"
],
mutation: [
"\x1B[1;30;45m",
"\x1B[1;97;45m"
],
subscription: [
"\x1B[1;30;42m",
"\x1B[1;97;42m"
]
}
}
};
function ms(t) {
const { direction: e, type: r, path: n, id: s, input: a } = t, i = [], o = [];
if (t.colorMode === "ansi") {
const [h, y] = Ge.ansi.regular[r], [k, C] = Ge.ansi.bold[r], A = "\x1B[0m";
return i.push(e === "up" ? h : y, e === "up" ? ">>" : "<<", r, e === "up" ? k : C, `#${s}`, n, A), e === "up" ? o.push({
input: t.input
}) : o.push({
input: t.input,
// strip context from result cause it's too noisy in terminal wihtout collapse mode
result: "result" in t.result ? t.result.result : t.result,
elapsedMs: t.elapsedMs
}), {
parts: i,
args: o
};
}
const [c, u] = Ge.css[r], d = `
background-color: #${e === "up" ? c : u};
color: ${e === "up" ? "black" : "white"};
padding: 2px;
`;
return i.push("%c", e === "up" ? ">>" : "<<", r, `#${s}`, `%c${n}%c`, "%O"), o.push(d, `${d}; font-weight: bold;`, `${d}; font-weight: normal;`), e === "up" ? o.push({
input: a,
context: t.context
}) : o.push({
input: a,
result: t.result,
elapsedMs: t.elapsedMs,
context: t.context
}), {
parts: i,
args: o
};
}
const ys = ({ c: t = console, colorMode: e = "css" }) => (r) => {
const n = r.input, s = hs(n) ? Object.fromEntries(n) : n, { parts: a, args: i } = ms({
...r,
colorMode: e,
input: s
}), o = r.direction === "down" && r.result && (r.result instanceof Error || "error" in r.result.result) ? "error" : "log";
t[o].apply(null, [
a.join(" ")
].concat(i));
};
function gs(t = {}) {
const { enabled: e = () => !0 } = t, r = t.colorMode ?? (typeof window > "u" ? "ansi" : "css"), { logger: n = ys({
c: t.console,
colorMode: r
}) } = t;
return () => ({ op: s, next: a }) => Kt.observable((i) => {
e({
...s,
direction: "up"
}) && n({
...s,
direction: "up"
});
const o = Date.now();
function c(u) {
const d = Date.now() - o;
e({
...s,
direction: "down",
result: u
}) && n({
...s,
direction: "down",
elapsedMs: d,
result: u
});
}
return a(s).pipe(Kt.tap({
next(u) {
c(u);
},
error(u) {
c(u);
}
})).subscribe(i);
});
}
Nt.loggerLink = gs;
var De = {};
Object.defineProperty(De, "__esModule", { value: !0 });
var _s = me, vs = ge, Mr = ye;
/* istanbul ignore next -- @preserve */
const bs = (t) => t === 0 ? 0 : Math.min(1e3 * 2 ** t, 3e4);
function ws(t) {
const { url: e, WebSocket: r = WebSocket, retryDelayMs: n = bs, onOpen: s, onClose: a } = t;
/* istanbul ignore next -- @preserve */
if (!r)
throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
let i = [];
const o = /* @__PURE__ */ Object.create(null);
let c = 0, u = null, d = null, h = Zt(), y = "connecting";
function k() {
y !== "open" || u || (u = setTimeout(() => {
u = null, i.length === 1 ? h.send(JSON.stringify(i.pop())) : h.send(JSON.stringify(i)), i = [];
}));
}
function C() {
if (d !== null || y === "closed")
return;
const O = n(c++);
te(O);
}
function A() {
y = "connecting";
const O = h;
h = Zt(), j(O);
}
function te(O) {
d || (y = "connecting", d = setTimeout(A, O));
}
function j(O) {
Object.values(o).some((re) => re.ws === O) || O.close();
}
function F() {
Object.values(o).forEach((O) => {
O.type === "subscription" && O.callbacks.complete();
});
}
function Dt(O) {
i.some((N) => N.id === O.op.id) || Ut(O.op, O.callbacks);
}
function Zt() {
const O = typeof e == "function" ? e() : e, N = new r(O);
clearTimeout(d), d = null, N.addEventListener("open", () => {
/* istanbul ignore next -- @preserve */
N === h && (c = 0, y = "open", s?.(), k());
}), N.addEventListener("error", () => {
N === h && C();
});
const re = ($) => {
if ($.method === "reconnect" && N === h) {
y === "open" && a?.(), A();
for (const E of Object.values(o))
E.type === "subscription" && Dt(E);
}
}, Fe = ($) => {
const E = $.id !== null && o[$.id];
if (E) {
if (E.callbacks.next?.($), E.ws !== h && N === h) {
const V = E.ws;
E.ws = h, j(V);
}
"result" in $ && $.result.type === "stopped" && N === h && E.callbacks.complete();
}
};
return N.addEventListener("message", ({ data: $ }) => {
const E = JSON.parse($);
"method" in E ? re(E) : Fe(E), (N !== h || y === "closed") && j(N);
}), N.addEventListener("close", ({ code: $ }) => {
y === "open" && a?.({
code: $
}), h === N && C();
for (const [E, V] of Object.entries(o))
if (V.ws === N) {
if (y === "closed") {
delete o[E], V.callbacks.complete?.();
continue;
}
V.type === "subscription" ? Dt(V) : (delete o[E], V.callbacks.error?.(Mr.TRPCClientError.from(new At("WebSocket closed prematurely"))));
}
}), N;
}
function Ut(O, N) {
const { type: re, input: Fe, path: $, id: E } = O, V = {
id: E,
method: re,
params: {
input: Fe,
path: $
}
};
return o[E] = {
ws: h,
type: re,
callbacks: N,
op: O
}, i.push(V), k(), () => {
const nn = o[E]?.callbacks;
delete o[E], i = i.filter((sn) => sn.id !== E), nn?.complete?.(), h.readyState === r.OPEN && O.type === "subscription" && (i.push({
id: E,
method: "subscription.stop"
}), k());
};
}
return {
close: () => {
y = "closed", a?.(), F(), j(h), clearTimeout(d), d = null;
},
request: Ut,
getConnection() {
return h;
}
};
}
class At extends Error {
constructor(e) {
super(e), this.name = "TRPCWebSocketClosedError", Object.setPrototypeOf(this, At.prototype);
}
}
function xs(t) {
return (e) => {
const { client: r } = t;
return ({ op: n }) => _s.observable((s) => {
const { type: a, path: i, id: o, context: c } = n, u = e.transformer.serialize(n.input), d = r.request({
type: a,
path: i,
input: u,
id: o,
context: c
}, {
error(h) {
s.error(h), d();
},
complete() {
s.complete();
},
next(h) {
const y = vs.transformResult(h, e);
if (!y.ok) {
s.error(Mr.TRPCClientError.from(y.error));
return;
}
s.next({
result: y.result
}), n.type !== "subscription" && (d(), s.complete());
}
});
return () => {
d();
};
});
};
}
De.createWSClient = ws;
De.wsLink = xs;
Object.defineProperty(P, "__esModule", { value: !0 });
var er = me, Dr = St, Zr = ye, tr = Er, ke = B, Ur = Pt, Lt = Me, ks = Nt, qr = De;
class Ze {
$request({ type: e, input: r, path: n, context: s = {} }) {
return Dr.createChain({
links: this.links,
op: {
id: ++this.requestId,
type: e,
path: n,
input: r,
context: s
}
}).pipe(er.share());
}
requestAsPromise(e) {
const r = this.$request(e), { promise: n, abort: s } = er.observableToPromise(r);
return new Promise((i, o) => {
e.signal?.addEventListener("abort", s), n.then((c) => {
i(c.result.data);
}).catch((c) => {
o(Zr.TRPCClientError.from(c));
});
});
}
query(e, r, n) {
return this.requestAsPromise({
type: "query",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
mutation(e, r, n) {
return this.requestAsPromise({
type: "mutation",
path: e,
input: r,
context: n?.context,
signal: n?.signal
});
}
subscription(e, r, n) {
return this.$request({
type: "subscription",
path: e,
input: r,
context: n?.context
}).subscribe({
next(a) {
a.result.type === "started" ? n.onStarted?.() : a.result.type === "stopped" ? n.onStopped?.() : n.onData?.(a.result.data);
},
error(a) {
n.onError?.(a);
},
complete() {
n.onComplete?.();
}
});
}
constructor(e) {
this.requestId = 0;
const r = (() => {
const n = e.transformer;
return n ? "input" in n ? e.transformer : {
input: n,
output: n
} : {
input: {
serialize: (s) => s,
deserialize: (s) => s
},
output: {
serialize: (s) => s,
deserialize: (s) => s
}
};
})();
this.runtime = {
transformer: {
serialize: (n) => r.input.serialize(n),
deserialize: (n) => r.output.deserialize(n)
},
combinedTransformer: r
}, this.links = e.links.map((n) => n(this.runtime));
}
}
function Ts(t) {
return new Ze(t);
}
function Cs(t) {
return new Ze(t);
}
const Es = {
query: "query",
mutate: "mutation",
subscribe: "subscription"
}, zr = (t) => Es[t];
function Br(t) {
return tr.createFlatProxy((e) => t.hasOwnProperty(e) ? t[e] : e === "__untypedClient" ? t : tr.createRecursiveProxy(({ path: r, args: n }) => {
const s = [
e,
...r
], a = zr(s.pop()), i = s.join(".");
return t[a](i, ...n);
}));
}
function Rs(t) {
const e = new Ze(t);
return Br(e);
}
function Os(t) {
return t.__untypedClient;
}
function Ss(t) {
if (t)
return t;
if (typeof window < "u" && window.TextDecoder)
return new window.TextDecoder();
if (typeof globalThis < "u" && globalThis.TextDecoder)
return new globalThis.TextDecoder();
throw new Error("No TextDecoder implementation found");
}
async function Ps(t) {
const e = t.parse ?? JSON.parse, r = (n) => {
if (t.signal?.aborted || !n || n === "}")
return;
const s = n.indexOf(":"), a = n.substring(2, s - 1), i = n.substring(s + 1);
t.onSingle(Number(a), e(i));
};
await Ns(t.readableStream, r, t.textDecoder);
}
async function Ns(t, e