Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: add tasks for OG image unfurling, agent ID resolution, and embed referrer allowlist

nirholas023a6115c87f
diff --git a/api/agent-oembed.js b/api/agent-oembed.js
new file mode 100644
index 000000000..fe52b9ff0
--- /dev/null
+++ b/api/agent-oembed.js
@@ -0,0 +1,113 @@
+/**
+ * oEmbed endpoint for agent URLs
+ * ------------------------------
+ * GET /api/oembed?url=<agent-url>[&format=json|xml]
+ *
+ * Implements https://oembed.com with type=rich. The html payload is a
+ * sandboxed iframe pointing at /agent/:id/embed so consumers (Notion,
+ * Discord, etc.) can render the agent inline.
+ */
+
+import { sql } from './_lib/db.js';
+import { env } from './_lib/env.js';
+import { cors, wrap, error } from './_lib/http.js';
+
+const WIDTH = 420;
+const HEIGHT = 520;
+const THUMB_WIDTH = 1200;
+const THUMB_HEIGHT = 630;
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+
+ const url = new URL(req.url, 'http://x');
+ const target = url.searchParams.get('url');
+ const format = (url.searchParams.get('format') || 'json').toLowerCase();
+
+ if (!target) return error(res, 400, 'invalid_request', 'url parameter required');
+
+ const agentId = extractAgentId(target);
+ if (!agentId) return error(res, 404, 'not_found', 'url is not a recognised agent url');
+
+ const [agent] = await sql`
+ SELECT id, name, description, avatar_id
+ FROM agent_identities
+ WHERE id = ${agentId} AND deleted_at IS NULL
+ LIMIT 1
+ `;
+ if (!agent) return error(res, 404, 'not_found', 'agent not found');
+
+ const origin = env.APP_ORIGIN;
+ const embedUrl = `${origin}/agent/${agent.id}/embed`;
+ const agentUrl = `${origin}/agent/${agent.id}`;
+ const thumbUrl = `${origin}/api/agent/${agent.id}/og`;
+ const title = agent.name || 'Agent';
+
+ const iframe = `<iframe src="${escapeAttr(embedUrl)}" width="${WIDTH}" height="${HEIGHT}" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" sandbox="allow-scripts allow-same-origin allow-popups"></iframe>`;
+
+ const payload = {
+ type: 'rich',
+ version: '1.0',
+ provider_name: '3D Agent',
+ provider_url: origin,
+ title,
+ author_name: title,
+ author_url: agentUrl,
+ html: iframe,
+ width: WIDTH,
+ height: HEIGHT,
+ thumbnail_url: thumbUrl,
+ thumbnail_width: THUMB_WIDTH,
+ thumbnail_height: THUMB_HEIGHT,
+ };
+
+ res.setHeader('cache-control', 'public, max-age=900');
+
+ if (format === 'xml') {
+ res.statusCode = 200;
+ res.setHeader('content-type', 'text/xml; charset=utf-8');
+ res.end(toXml(payload));
+ return;
+ }
+
+ res.statusCode = 200;
+ res.setHeader('content-type', 'application/json+oembed; charset=utf-8');
+ res.end(JSON.stringify(payload));
+});
+
+function extractAgentId(target) {
+ let parsed;
+ try { parsed = new URL(target); } catch { return null; }
+
+ const originStr = `${parsed.protocol}//${parsed.host}`;
+ const okOrigin = originStr === env.APP_ORIGIN
+ || /^https?:\/\/localhost(:\d+)?$/.test(originStr);
+ if (!okOrigin) return null;
+
+ const match = parsed.pathname.match(/^\/agent\/([A-Za-z0-9_-]+)\/?$/);
+ return match ? match[1] : null;
+}
+
+function toXml(payload) {
+ const lines = Object.entries(payload).map(([k, v]) =>
+ ` <${k}>${escapeXml(String(v))}</${k}>`
+ );
+ return `<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n<oembed>\n${lines.join('\n')}\n</oembed>`;
+}
+
+function escapeXml(s) {
+ return String(s)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&apos;');
+}
+
+function escapeAttr(s) {
+ return String(s)
+ .replace(/&/g, '&amp;')
+ .replace(/"/g, '&quot;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;');
+}
diff --git a/api/agent-og.js b/api/agent-og.js
new file mode 100644
index 000000000..b16be746e
--- /dev/null
+++ b/api/agent-og.js
@@ -0,0 +1,91 @@
+/**
+ * Agent OG image endpoint
+ * -----------------------
+ * GET /api/agent/:id/og
+ *
+ * Happy path: 302 to the avatar's thumbnail_url so Slack/X/Discord cache
+ * a real PNG of the avatar. Fallback: a server-rendered SVG card — Slack,
+ * X, and Discord all accept image/svg+xml for OG images, so we avoid
+ * pulling in canvas/imagemagick on the serverless side.
+ */
+
+import { sql } from './_lib/db.js';
+import { getAvatar } from './_lib/avatars.js';
+import { cors, wrap } from './_lib/http.js';
+
+const CACHE_CARD = 'public, max-age=3600, s-maxage=86400';
+const CACHE_REDIR = 'public, max-age=3600';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+
+ const url = new URL(req.url, 'http://x');
+ const agentId = url.searchParams.get('id');
+
+ if (!agentId) return sendNotFound(res);
+
+ const [agent] = await sql`
+ SELECT id, name, description, avatar_id
+ FROM agent_identities
+ WHERE id = ${agentId} AND deleted_at IS NULL
+ LIMIT 1
+ `;
+ if (!agent) return sendNotFound(res);
+
+ if (agent.avatar_id) {
+ const avatar = await getAvatar({ id: agent.avatar_id });
+ if (avatar?.thumbnail_url) {
+ res.statusCode = 302;
+ res.setHeader('location', avatar.thumbnail_url);
+ res.setHeader('cache-control', CACHE_REDIR);
+ res.end();
+ return;
+ }
+ }
+
+ sendCardSvg(res, 200, CACHE_CARD, {
+ name: agent.name || 'Agent',
+ description: agent.description || 'An embodied 3D agent.',
+ });
+});
+
+function sendNotFound(res) {
+ sendCardSvg(res, 404, 'public, max-age=60', {
+ name: 'Agent not found',
+ description: '',
+ });
+}
+
+function sendCardSvg(res, status, cacheControl, { name, description }) {
+ res.statusCode = status;
+ res.setHeader('content-type', 'image/svg+xml; charset=utf-8');
+ res.setHeader('cache-control', cacheControl);
+ res.end(renderCardSvg({ name, description }));
+}
+
+function renderCardSvg({ name, description }) {
+ const safeName = escapeXml(truncate(name, 60));
+ const safeDesc = escapeXml(truncate(description, 140));
+ return `<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630" role="img" aria-label="${safeName}">
+ <rect width="1200" height="630" fill="#0b0d10"/>
+ <text x="80" y="140" fill="#e5e5e5" font-family="Inter, -apple-system, system-ui, sans-serif" font-size="56" font-weight="300">◎</text>
+ <text x="80" y="320" fill="#e5e5e5" font-family="Inter, -apple-system, system-ui, sans-serif" font-size="76" font-weight="300" letter-spacing="-2">${safeName}</text>
+ <text x="80" y="390" fill="rgba(229,229,229,0.55)" font-family="Inter, -apple-system, system-ui, sans-serif" font-size="28" font-weight="400">${safeDesc}</text>
+ <text x="80" y="570" fill="rgba(229,229,229,0.3)" font-family="Inter, -apple-system, system-ui, sans-serif" font-size="20" font-weight="400" letter-spacing="4">3D AGENT</text>
+</svg>`;
+}
+
+function truncate(s, n) {
+ s = String(s || '');
+ return s.length <= n ? s : s.slice(0, n - 1) + '…';
+}
+
+function escapeXml(s) {
+ return String(s)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&apos;');
+}
diff --git a/api/agents/[id]/embed-policy.js b/api/agents/[id]/embed-policy.js
new file mode 100644
index 000000000..7f2b95e3c
--- /dev/null
+++ b/api/agents/[id]/embed-policy.js
@@ -0,0 +1,74 @@
+// GET /api/agents/:id/embed-policy — public; returns { policy } (or { policy: null })
+// PUT /api/agents/:id/embed-policy — owner-only; sets the policy
+// DELETE /api/agents/:id/embed-policy — owner-only; clears the policy
+//
+// Policy shape when non-null:
+// { mode: "allowlist" | "denylist", hosts: ["example.com", "*.substack.com"] }
+// `hosts` supports exact match and a single leading-wildcard segment ("*.foo.com").
+
+import { z } from 'zod';
+import { getSessionUser } from '../../_lib/auth.js';
+import { sql } from '../../_lib/db.js';
+import { cors, json, method, readJson, wrap, error } from '../../_lib/http.js';
+import { parse } from '../../_lib/validate.js';
+
+// Hostnames are ASCII only here — policy authors enter punycoded forms.
+// Allow a single leading "*." wildcard segment; otherwise require conventional
+// dot-separated labels. Cap at 253 chars (DNS max).
+const hostPattern = /^(\*\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
+
+const policySchema = z.object({
+ mode: z.enum(['allowlist', 'denylist']),
+ hosts: z
+ .array(
+ z
+ .string()
+ .trim()
+ .toLowerCase()
+ .min(1)
+ .max(253)
+ .regex(hostPattern, 'invalid host; use example.com or *.example.com'),
+ )
+ .max(100),
+});
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,PUT,DELETE,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET', 'PUT', 'DELETE'])) return;
+
+ const id = req.query?.id || new URL(req.url, 'http://x').pathname.split('/').filter(Boolean)[2];
+ if (!id) return error(res, 400, 'invalid_request', 'agent id required');
+
+ if (req.method === 'GET') {
+ const [row] = await sql`
+ SELECT embed_policy FROM agent_identities
+ WHERE id = ${id} AND deleted_at IS NULL
+ `;
+ if (!row) return error(res, 404, 'not_found', 'agent not found');
+ return json(res, 200, { policy: row.embed_policy ?? null });
+ }
+
+ const session = await getSessionUser(req);
+ if (!session) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const [existing] = await sql`
+ SELECT id, user_id FROM agent_identities
+ WHERE id = ${id} AND deleted_at IS NULL
+ `;
+ if (!existing) return error(res, 404, 'not_found', 'agent not found');
+ if (existing.user_id !== session.id) return error(res, 403, 'forbidden', 'not your agent');
+
+ if (req.method === 'DELETE') {
+ await sql`UPDATE agent_identities SET embed_policy = NULL WHERE id = ${id}`;
+ return json(res, 200, { policy: null });
+ }
+
+ const policy = parse(policySchema, await readJson(req));
+ const [updated] = await sql`
+ UPDATE agent_identities
+ SET embed_policy = ${sql.json(policy)}
+ WHERE id = ${id}
+ RETURNING embed_policy
+ `;
+ return json(res, 200, { policy: updated.embed_policy });
+});
diff --git a/dist-lib/.well-known/agent-card.json b/dist-lib/.well-known/agent-card.json
index 41dd0b2d3..4e947a10b 100644
--- a/dist-lib/.well-known/agent-card.json
+++ b/dist-lib/.well-known/agent-card.json
@@ -1,10 +1,10 @@
{
"name": "3D Agent",
"description": "AI-powered 3D model viewer and validation agent. Load glTF/GLB models, run validation, inspect materials, and manage avatar assets.",
- "url": "https://3d.irish",
+ "url": "https://3dagent.vercel.app",
"provider": {
"organization": "3D Agent",
- "url": "https://3d.irish"
+ "url": "https://3dagent.vercel.app"
},
"version": "1.5.1",
"capabilities": {
@@ -53,6 +53,39 @@
"description": "Delete an avatar owned by the authenticated user",
"tags": ["avatar", "delete"],
"examples": ["Delete my old avatar", "Remove avatar abc123"]
+ },
+ {
+ "id": "validate-model",
+ "name": "Validate glTF/GLB Model",
+ "description": "Run the Khronos glTF-Validator against a remote model URL and return a structured error/warning/info/hint report",
+ "tags": ["model", "validation", "gltf", "glb"],
+ "examples": [
+ "Validate https://example.com/model.glb",
+ "Is this GLB spec-compliant?",
+ "Check my model for errors"
+ ]
+ },
+ {
+ "id": "inspect-model",
+ "name": "Inspect glTF/GLB Model",
+ "description": "Parse a remote model and return structural stats: scene/node/mesh counts, vertex and triangle totals, material and texture summaries, extensions used",
+ "tags": ["model", "inspect", "stats", "gltf", "glb"],
+ "examples": [
+ "How many triangles are in this model?",
+ "Inspect https://example.com/scene.glb",
+ "Show texture stats for this GLB"
+ ]
+ },
+ {
+ "id": "optimize-model",
+ "name": "Suggest Optimizations",
+ "description": "Inspect a remote model and return actionable suggestions for reducing size and draw-call overhead (Draco/Meshopt, KTX2, texture resize, reindexing, material merging)",
+ "tags": ["model", "optimize", "suggestions", "performance"],
+ "examples": [
+ "How can I make this model smaller?",
+ "Optimize this GLB for web delivery",
+ "Suggest compression for https://example.com/avatar.glb"
+ ]
}
]
}
diff --git a/dist-lib/.well-known/agent-registration.json b/dist-lib/.well-known/agent-registration.json
index 4d1eae972..4bee98074 100644
--- a/dist-lib/.well-known/agent-registration.json
+++ b/dist-lib/.well-known/agent-registration.json
@@ -2,21 +2,21 @@
"type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
"name": "3D Agent",
"description": "AI-powered 3D model viewer and validation agent. Drag and drop glTF, GLB, and 3D files to preview instantly in your browser. Supports real-time rendering, model validation, environment maps, and animation playback via Three.js and WebGL.",
- "image": "https://3d.irish/og-image.png",
+ "image": "https://3dagent.vercel.app/og-image.png",
"active": true,
"services": [
{
"name": "web",
- "endpoint": "https://3d.irish/"
+ "endpoint": "https://3dagent.vercel.app/"
},
{
"name": "A2A",
- "endpoint": "https://3d.irish/.well-known/agent-card.json",
+ "endpoint": "https://3dagent.vercel.app/.well-known/agent-card.json",
"version": "0.3.0"
},
{
"name": "MCP",
- "endpoint": "https://3d.irish/.well-known/openapi.yaml",
+ "endpoint": "https://3dagent.vercel.app/.well-known/openapi.yaml",
"version": "2025-06-18"
}
],
diff --git a/dist-lib/.well-known/ai-plugin.json b/dist-lib/.well-known/ai-plugin.json
index 91aa1b05e..ee9a9b47b 100644
--- a/dist-lib/.well-known/ai-plugin.json
+++ b/dist-lib/.well-known/ai-plugin.json
@@ -9,9 +9,9 @@
},
"api": {
"type": "openapi",
- "url": "https://3d.irish/.well-known/openapi.yaml"
+ "url": "https://3dagent.vercel.app/.well-known/openapi.yaml"
},
- "logo_url": "https://3d.irish/favicon.ico",
+ "logo_url": "https://3dagent.vercel.app/favicon.ico",
"contact_email": "[email protected]",
- "legal_info_url": "https://3d.irish/"
+ "legal_info_url": "https://3dagent.vercel.app/"
}
diff --git a/dist-lib/.well-known/openapi.yaml b/dist-lib/.well-known/openapi.yaml
index 89cdfadb0..a0c0f684d 100644
--- a/dist-lib/.well-known/openapi.yaml
+++ b/dist-lib/.well-known/openapi.yaml
@@ -14,7 +14,7 @@ info:
url: https://opensource.org/licenses/MIT
servers:
- - url: https://3d.irish
+ - url: https://3dagent.vercel.app
tags:
- name: Auth
diff --git a/dist-lib/.well-known/security.txt b/dist-lib/.well-known/security.txt
index 1701ce5a9..294b4e7f3 100644
--- a/dist-lib/.well-known/security.txt
+++ b/dist-lib/.well-known/security.txt
@@ -1,7 +1,7 @@
-# Security policy for 3d.irish
+# Security policy for 3dagent.vercel.app
# https://securitytxt.org/
Contact: mailto:[email protected]
Preferred-Languages: en
-Canonical: https://3d.irish/.well-known/security.txt
+Canonical: https://3dagent.vercel.app/.well-known/security.txt
Expires: 2027-04-14T00:00:00.000Z
diff --git a/dist-lib/agent-3d.js b/dist-lib/agent-3d.js
index a827f87bf..7a6eff27b 100644
--- a/dist-lib/agent-3d.js
+++ b/dist-lib/agent-3d.js
@@ -22648,7 +22648,7 @@ function W_(e) {
//#region src/animation-manager.js
var G_ = .35, K_ = class {
constructor() {
- this.model = null, this.mixer = null, this.clips = /* @__PURE__ */ new Map(), this.actions = /* @__PURE__ */ new Map(), this.currentName = null, this.currentAction = null, this.loader = new fu(), this.onChange = null, this._animationDefs = [];
+ this.model = null, this.mixer = null, this.clips = /* @__PURE__ */ new Map(), this.actions = /* @__PURE__ */ new Map(), this.currentName = null, this.currentAction = null, this.loader = new fu(), this.onChange = null, this._gltfCache = /* @__PURE__ */ new Map(), this._animationDefs = [];
}
attach(e) {
this.detach(), this.model = e, this.mixer = new Xo(e), this.actions.clear(), this.currentAction = null, this.currentName = null;
@@ -22668,20 +22668,25 @@ var G_ = .35, K_ = class {
}
async loadAnimation(e, t, n = {}) {
if (this.clips.has(e)) return this.clips.get(e);
- let r = (await new Promise((e, n) => {
+ let r;
+ this._gltfCache.has(t) ? r = this._gltfCache.get(t) : (r = await new Promise((e, n) => {
this.loader.load(t, e, void 0, n);
- })).animations[0];
- if (!r) throw Error(`No animation found in ${t}`);
- if (r.name = e, this.clips.set(e, r), this.model && this.mixer) {
- let t = this._retargetClip(r, e), i = this.mixer.clipAction(t);
- i.enabled = !0, i.setLoop(n.loop === !1 ? Me : Ne), n.loop === !1 && (i.clampWhenFinished = !0), this.actions.set(e, i);
+ }), this._gltfCache.set(t, r));
+ let i;
+ if (n.clipName ? (i = r.animations.find((e) => e.name === n.clipName), i ||= (console.warn(`[AnimationManager] Clip "${n.clipName}" not found in ${t}, using first clip`), r.animations[0])) : i = r.animations[0], !i) throw Error(`No animation found in ${t}`);
+ if (i = i.clone(), i.name = e, this.clips.set(e, i), this.model && this.mixer) {
+ let t = this._retargetClip(i, e), r = this.mixer.clipAction(t);
+ r.enabled = !0, r.setLoop(n.loop === !1 ? Me : Ne), n.loop === !1 && (r.clampWhenFinished = !0), this.actions.set(e, r);
}
- return r;
+ return i;
}
async loadAll() {
let e = this._animationDefs.map(async (e) => {
try {
- await this.loadAnimation(e.name, e.url, { loop: e.loop !== !1 });
+ await this.loadAnimation(e.name, e.url, {
+ loop: e.loop !== !1,
+ clipName: e.clipName
+ });
} catch (t) {
console.warn(`[AnimationManager] Failed to load "${e.name}" from ${e.url}:`, t);
}
@@ -22752,7 +22757,7 @@ var G_ = .35, K_ = class {
return this.clips.has(e);
}
dispose() {
- this.detach(), this.clips.clear(), this._animationDefs = [];
+ this.detach(), this.clips.clear(), this._gltfCache.clear(), this._animationDefs = [];
}
};
//#endregion
@@ -22950,7 +22955,12 @@ var q_ = class {
let i = t.addFolder("Performance"), a = document.createElement("li");
this.stats.dom.style.position = "static", a.appendChild(this.stats.dom), a.classList.add("gui-stats"), i.__ul.appendChild(a);
let o = document.createElement("div");
- this.el.appendChild(o), o.classList.add("gui-wrap"), o.appendChild(t.domElement), this._guiWrap = o, e ? t.close() : t.open();
+ this.el.appendChild(o), o.classList.add("gui-wrap"), o.classList.add("gui-wrap--hidden"), o.appendChild(t.domElement), this._guiWrap = o;
+ let s = document.createElement("button");
+ s.className = "gui-toggle", s.setAttribute("title", "Toggle advanced controls"), s.setAttribute("aria-label", "Toggle advanced controls"), s.innerHTML = "<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"3\"></circle><path d=\"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z\"></path></svg><span class=\"gui-toggle__label\">Controls</span>", s.addEventListener("click", () => {
+ let e = o.classList.toggle("gui-wrap--hidden");
+ s.classList.toggle("gui-toggle--active", !e);
+ }), this.el.appendChild(s), this._guiToggle = s, e ? t.close() : t.open();
}
updateGUI() {
this.cameraFolder.domElement.style.display = "none", this.morphCtrls.forEach((e) => e.remove()), this.morphCtrls.length = 0, this.morphFolder.domElement.style.display = "none", this.animCtrls.forEach((e) => e.remove()), this.animCtrls.length = 0, this.animFolder.domElement.style.display = "none";
@@ -23037,15 +23047,21 @@ var q_ = class {
kicking: "🦵",
kick: "🦵"
};
- e.innerHTML = t.map((e) => {
- let t = this.animationManager.isLoaded(e.name), i = n === e.name, a = e.icon || r[e.name.toLowerCase()] || "▶", o = e.label || e.name.charAt(0).toUpperCase() + e.name.slice(1);
- return "<button class=\"anim-btn" + (i ? " anim-btn--active" : "") + (t ? "" : " anim-btn--loading") + "\" data-anim=\"" + e.name + "\" title=\"" + o + "\"" + (t ? "" : " disabled") + "><span class=\"anim-btn__icon\">" + a + "</span><span class=\"anim-btn__label\">" + o + "</span></button>";
+ e.innerHTML = t.map((e, t) => {
+ let i = this.animationManager.isLoaded(e.name), a = n === e.name, o = e.icon || r[e.name.toLowerCase()] || "▶", s = e.label || e.name.charAt(0).toUpperCase() + e.name.slice(1), c = t < 9 ? t + 1 : "";
+ return "<button class=\"anim-btn" + (a ? " anim-btn--active" : "") + (i ? "" : " anim-btn--loading") + "\" data-anim=\"" + e.name + "\" title=\"" + s + (c ? " — press " + c : "") + "\"" + (i ? "" : " disabled") + ">" + (c ? "<span class=\"anim-btn__key\">" + c + "</span>" : "") + "<span class=\"anim-btn__icon\">" + o + "</span><span class=\"anim-btn__label\">" + s + "</span></button>";
}).join(""), e.querySelectorAll(".anim-btn:not([disabled])").forEach((e) => {
e.addEventListener("click", () => {
let t = e.dataset.anim;
this.animationManager.crossfadeTo(t), this.invalidate(), this._recomputeAnimating(), this._updateRenderLoop();
});
- });
+ }), this._animKeyBound || (this._animKeyBound = !0, document.addEventListener("keydown", (e) => {
+ if (e.target && /INPUT|TEXTAREA|SELECT/.test(e.target.tagName) || e.metaKey || e.ctrlKey || e.altKey) return;
+ let t = parseInt(e.key, 10);
+ if (!t || t < 1 || t > 9) return;
+ let n = this.animationManager.getAnimationDefs()[t - 1];
+ !n || !this.animationManager.isLoaded(n.name) || (this.animationManager.crossfadeTo(n.name), this.invalidate(), this._recomputeAnimating(), this._updateRenderLoop());
+ }));
}
clear() {
this.content && (this.animationManager.detach(), this._animPanelEl &&= (this._animPanelEl.remove(), null), this.modelInfo &&= (this.modelInfo.remove(), null), this.annotationEls.forEach((e) => e.el.remove()), this.annotationEls = [], this.scene.remove(this.content), this.content.traverse((e) => {
@@ -34133,18 +34149,87 @@ async function wA(e, t) {
}
}
//#endregion
+//#region src/agent-resolver.js
+var TA = class extends Error {
+ constructor(e, t, { status: n } = {}) {
+ super(t), this.name = "AgentResolveError", this.code = e, n !== void 0 && (this.status = n);
+ }
+};
+async function EA(e, { fetchFn: t }) {
+ let n;
+ try {
+ n = await t(e, { credentials: "include" });
+ } catch (t) {
+ throw new TA("network", `network error fetching ${e}: ${t.message || t}`);
+ }
+ if (n.status === 401 || n.status === 403) throw new TA("unauthorized", `unauthorized fetching ${e} (${n.status})`, { status: n.status });
+ if (n.status === 404) throw new TA("not_found", `resource not found: ${e}`, { status: 404 });
+ if (!n.ok) throw new TA("network", `request failed: ${e} (${n.status})`, { status: n.status });
+ try {
+ return await n.json();
+ } catch (t) {
+ throw new TA("network", `invalid JSON from ${e}: ${t.message || t}`);
+ }
+}
+async function DA(e, { origin: t = typeof location < "u" ? location.origin : "", fetchFn: n = fetch } = {}) {
+ if (!e) throw new TA("not_found", "agentId required");
+ let r = n.bind(typeof globalThis < "u" ? globalThis : void 0), i = (await EA(`${t}/api/agents/${encodeURIComponent(e)}`, { fetchFn: r }))?.agent;
+ if (!i) throw new TA("not_found", `agent ${e} not found`);
+ if (!i.avatar_id) throw new TA("no_avatar", `agent ${e} has no avatar bound`);
+ let a = (await EA(`${t}/api/avatars/${encodeURIComponent(i.avatar_id)}`, { fetchFn: r }))?.avatar;
+ if (!a || !a.url) throw new TA("no_avatar", `avatar ${i.avatar_id} has no url`);
+ let o = Array.isArray(i.skills) ? i.skills.map((e) => typeof e == "string" ? { name: e } : e).filter(Boolean) : [];
+ return {
+ spec: "agent-manifest/0.1",
+ name: i.name || "Agent",
+ description: i.description || "",
+ id: {
+ agentId: i.id,
+ owner: i.wallet_address,
+ chainId: i.chain_id,
+ walletAddress: i.wallet_address
+ },
+ body: {
+ uri: a.url,
+ format: "gltf-binary"
+ },
+ brain: {},
+ voice: {
+ tts: { provider: "browser" },
+ stt: { provider: "browser" }
+ },
+ skills: o,
+ memory: {
+ mode: "remote",
+ namespace: i.id
+ },
+ tools: [
+ "wave",
+ "lookAt",
+ "play_clip",
+ "setExpression",
+ "speak",
+ "remember"
+ ],
+ version: "0.1.0",
+ _baseURI: `${t}/agent/${i.id}/`,
+ _source: "agent-id"
+ };
+}
+//#endregion
//#region src/element.js
-var TA = [
+var OA = [
"inline",
"floating",
"section",
"fullscreen"
-], EA = "\n :host {\n display: block;\n position: relative;\n width: 100%;\n height: 480px;\n --agent-bubble-radius: 16px;\n --agent-accent: #3b82f6;\n --agent-surface: rgba(17, 24, 39, 0.92);\n --agent-on-surface: #f9fafb;\n --agent-chat-font: system-ui, -apple-system, sans-serif;\n --agent-mic-glow: #22c55e;\n --agent-shadow: 0 20px 60px rgba(0,0,0,0.3);\n contain: layout style;\n }\n :host([mode=\"floating\"]) {\n position: fixed;\n z-index: 2147483000;\n width: var(--agent-width, 320px);\n height: var(--agent-height, 420px);\n border-radius: var(--agent-bubble-radius);\n overflow: hidden;\n box-shadow: var(--agent-shadow);\n }\n :host([mode=\"fullscreen\"]) {\n position: fixed;\n inset: 0;\n width: 100vw;\n height: 100vh;\n z-index: 2147483000;\n }\n :host([hidden]) { display: none; }\n .stage {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n }\n .stage canvas { display: block; }\n .chrome {\n position: absolute;\n left: 12px;\n right: 12px;\n bottom: 12px;\n display: flex;\n gap: 8px;\n align-items: flex-end;\n pointer-events: none;\n }\n .chrome > * { pointer-events: auto; }\n .chat {\n flex: 1;\n max-height: 40%;\n overflow-y: auto;\n background: var(--agent-surface);\n color: var(--agent-on-surface);\n font: 14px/1.4 var(--agent-chat-font);\n border-radius: 12px;\n padding: 10px 12px;\n backdrop-filter: blur(12px);\n }\n .chat:empty { display: none; }\n .msg { margin: 4px 0; }\n .msg .role { opacity: 0.55; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }\n .input-row {\n display: flex;\n gap: 6px;\n background: var(--agent-surface);\n border-radius: 999px;\n padding: 4px 4px 4px 14px;\n backdrop-filter: blur(12px);\n flex: 1;\n }\n .input-row input {\n flex: 1;\n background: transparent;\n border: 0;\n color: var(--agent-on-surface);\n font: 14px var(--agent-chat-font);\n outline: none;\n }\n button.icon {\n width: 36px;\n height: 36px;\n border-radius: 50%;\n border: 0;\n background: var(--agent-accent);\n color: white;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n button.icon.mic[data-listening=\"true\"] { box-shadow: 0 0 0 4px var(--agent-mic-glow); }\n .poster {\n position: absolute;\n inset: 0;\n background-size: contain;\n background-position: center;\n background-repeat: no-repeat;\n transition: opacity 0.4s;\n pointer-events: none;\n }\n .loading {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n color: var(--agent-on-surface);\n font: 14px var(--agent-chat-font);\n background: var(--agent-surface);\n padding: 8px 14px;\n border-radius: 999px;\n }\n .error {\n position: absolute;\n inset: 16px;\n display: grid;\n place-items: center;\n color: var(--agent-on-surface);\n background: var(--agent-surface);\n border-radius: 12px;\n padding: 16px;\n font: 14px var(--agent-chat-font);\n }\n", DA = class extends HTMLElement {
+], kA = "\n :host {\n display: block;\n position: relative;\n width: 100%;\n height: 480px;\n --agent-bubble-radius: 16px;\n --agent-accent: #3b82f6;\n --agent-surface: rgba(17, 24, 39, 0.92);\n --agent-on-surface: #f9fafb;\n --agent-chat-font: system-ui, -apple-system, sans-serif;\n --agent-mic-glow: #22c55e;\n --agent-shadow: 0 20px 60px rgba(0,0,0,0.3);\n contain: layout style;\n }\n :host([mode=\"floating\"]) {\n position: fixed;\n z-index: 2147483000;\n width: var(--agent-width, 320px);\n height: var(--agent-height, 420px);\n border-radius: var(--agent-bubble-radius);\n overflow: hidden;\n box-shadow: var(--agent-shadow);\n }\n :host([mode=\"fullscreen\"]) {\n position: fixed;\n inset: 0;\n width: 100vw;\n height: 100vh;\n z-index: 2147483000;\n }\n :host([hidden]) { display: none; }\n .stage {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n }\n .stage canvas { display: block; }\n .chrome {\n position: absolute;\n left: 12px;\n right: 12px;\n bottom: 12px;\n display: flex;\n gap: 8px;\n align-items: flex-end;\n pointer-events: none;\n }\n .chrome > * { pointer-events: auto; }\n .chat {\n flex: 1;\n max-height: 40%;\n overflow-y: auto;\n background: var(--agent-surface);\n color: var(--agent-on-surface);\n font: 14px/1.4 var(--agent-chat-font);\n border-radius: 12px;\n padding: 10px 12px;\n backdrop-filter: blur(12px);\n }\n .chat:empty { display: none; }\n .msg { margin: 4px 0; }\n .msg .role { opacity: 0.55; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }\n .input-row {\n display: flex;\n gap: 6px;\n background: var(--agent-surface);\n border-radius: 999px;\n padding: 4px 4px 4px 14px;\n backdrop-filter: blur(12px);\n flex: 1;\n }\n .input-row input {\n flex: 1;\n background: transparent;\n border: 0;\n color: var(--agent-on-surface);\n font: 14px var(--agent-chat-font);\n outline: none;\n }\n button.icon {\n width: 36px;\n height: 36px;\n border-radius: 50%;\n border: 0;\n background: var(--agent-accent);\n color: white;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n button.icon.mic[data-listening=\"true\"] { box-shadow: 0 0 0 4px var(--agent-mic-glow); }\n .poster {\n position: absolute;\n inset: 0;\n background-size: contain;\n background-position: center;\n background-repeat: no-repeat;\n transition: opacity 0.4s;\n pointer-events: none;\n }\n .loading {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n color: var(--agent-on-surface);\n font: 14px var(--agent-chat-font);\n background: var(--agent-surface);\n padding: 8px 14px;\n border-radius: 999px;\n }\n .error {\n position: absolute;\n inset: 16px;\n display: grid;\n place-items: center;\n color: var(--agent-on-surface);\n background: var(--agent-surface);\n border-radius: 12px;\n padding: 16px;\n font: 14px var(--agent-chat-font);\n }\n", AA = class extends HTMLElement {
static get observedAttributes() {
return [
"src",
"manifest",
"body",
+ "agent-id",
"mode",
"position",
"width",
@@ -34172,12 +34257,13 @@ var TA = [
].includes(e) && this._applyLayout(), [
"src",
"manifest",
- "body"
+ "body",
+ "agent-id"
].includes(e) && (this._teardown(), this._boot()));
}
_renderShell() {
let e = document.createElement("style");
- e.textContent = EA, this.shadowRoot.appendChild(e);
+ e.textContent = kA, this.shadowRoot.appendChild(e);
let t = document.createElement("div");
t.className = "stage", t.part = "stage", this.shadowRoot.appendChild(t), this._stageEl = t;
let n = document.createElement("div");
@@ -34203,7 +34289,7 @@ var TA = [
}
_applyLayout() {
let e = this.getAttribute("mode") || "inline";
- if (!TA.includes(e)) return;
+ if (!OA.includes(e)) return;
if (e === "floating") {
let e = this.getAttribute("position") || "bottom-right", t = (this.getAttribute("offset") || "24px 24px").split(/\s+/), [n, r] = [t[0], t[1] || t[0]];
this.style.top = this.style.bottom = this.style.left = this.style.right = "", e.includes("top") ? this.style.top = n : this.style.bottom = n, e.includes("left") ? this.style.left = r : e.includes("right") ? this.style.right = r : e.includes("center") && (this.style.left = "50%", this.style.transform = "translateX(-50%)");
@@ -34236,7 +34322,7 @@ var TA = [
pct: .3
} })), typeof e.brain?.instructions == "string" && e.brain.instructions.endsWith(".md")) {
let t = await wA(e, e.brain.instructions);
- t && (e.instructions = OA(t));
+ t && (e.instructions = jA(t));
} else e.brain?.instructions && (e.instructions = e.brain.instructions);
this.dispatchEvent(new CustomEvent("agent:load-progress", { detail: {
phase: "body",
@@ -34326,11 +34412,12 @@ var TA = [
}
}
async _resolveManifest() {
- let e = this.getAttribute("src"), t = this.getAttribute("manifest"), n = this.getAttribute("body");
- if (e) return yA(e, {
+ let e = this.getAttribute("src"), t = this.getAttribute("manifest"), n = this.getAttribute("body"), r = this.getAttribute("agent-id");
+ if (e) return r && console.warn("[agent-3d] both src and agent-id provided; using src"), yA(e, {
rpcURL: this.getAttribute("rpc-url"),
registry: this.getAttribute("registry")
});
+ if (r) return DA(r);
if (t) return yA(t);
if (n) {
let e = this.getAttribute("instructions");
@@ -34467,15 +34554,15 @@ var TA = [
});
}
};
-function OA(e) {
+function jA(e) {
let t = e.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/);
return t ? t[1] : e;
}
-customElements.get("agent-3d") || customElements.define("agent-3d", DA);
+customElements.get("agent-3d") || customElements.define("agent-3d", AA);
//#endregion
//#region src/lib.js
-var kA = (e = "agent-3d") => {
- customElements.get(e) || customElements.define(e, DA);
+var MA = (e = "agent-3d") => {
+ customElements.get(e) || customElements.define(e, AA);
};
//#endregion
-export { DA as Agent3DElement, _v as Memory, iv as Runtime, uv as SceneController, fv as Skill, pv as SkillRegistry, q_ as Viewer, kA as defineElement, wA as fetchRelative, cv as fetchWithFallback, yA as loadManifest, SA as normalize, sv as resolveURI };
+export { AA as Agent3DElement, _v as Memory, iv as Runtime, uv as SceneController, fv as Skill, pv as SkillRegistry, q_ as Viewer, MA as defineElement, wA as fetchRelative, cv as fetchWithFallback, yA as loadManifest, SA as normalize, sv as resolveURI };
diff --git a/dist-lib/agent-3d.umd.cjs b/dist-lib/agent-3d.umd.cjs
index c07d58960..b2ceda95e 100644
--- a/dist-lib/agent-3d.umd.cjs
+++ b/dist-lib/agent-3d.umd.cjs
@@ -3843,7 +3843,7 @@ void main() {
`)}var mp=null,hp;function gp(){return mp===null&&(mp=new Intl.Segmenter(hp,{granularity:`word`})),mp}var _p=/\p{Script=Arabic}/u,vp=/\p{M}/u,yp=/\p{Nd}/u;function bp(e){return _p.test(e)}function xp(e){return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=191472&&e<=192093||e>=194560&&e<=195103||e>=196608&&e<=201551||e>=201552&&e<=205743||e>=205744&&e<=210041||e>=63744&&e<=64255||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=44032&&e<=55215||e>=65280&&e<=65519}function Sp(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(!(n<12288)){if(n>=55296&&n<=56319&&t+1<e.length){let r=e.charCodeAt(t+1);if(r>=56320&&r<=57343){if(xp((n-55296<<10)+(r-56320)+65536))return!0;t++;continue}}if(xp(n))return!0}}return!1}function Cp(e){let t=Bp(e);return t!==null&&(Op.has(t)||jp.has(t))}var wp=new Set([`\xA0`,` `,`⁠`,``]);function Tp(e){return Sp(e)}function Ep(e){let t=Bp(e);return t!==null&&wp.has(t)}function Dp(e){return!Cp(e)&&!Ep(e)}var Op=new Set(`,...!.:.;.?.、.。.・.).〕.〉.》.」.』.】.〗.〙.〛.ー.々.〻.ゝ.ゞ.ヽ.ヾ`.split(`.`)),kp=new Set([`"`,`(`,`[`,`{`,`“`,`‘`,`«`,`‹`,`(`,`〔`,`〈`,`《`,`「`,`『`,`【`,`〖`,`〘`,`〚`]),Ap=new Set([`'`,`’`]),jp=new Set(`.(,(!(?(:(;(،(؛(؟(।(॥(၊(။(၌(၍(၏()(](}(%("(”(’(»(›(…`.split(`(`)),Mp=new Set([`:`,`.`,`،`,`؛`]),Np=new Set([`၏`]),Pp=new Set([`”`,`’`,`»`,`›`,`」`,`』`,`】`,`》`,`〉`,`〕`,`)`]);function Fp(e){if(Rp(e))return!0;let t=!1;for(let n of e){if(jp.has(n)){t=!0;continue}if(!(t&&vp.test(n)))return!1}return t}function Ip(e){for(let t of e)if(!Op.has(t)&&!jp.has(t))return!1;return e.length>0}function Lp(e){if(Rp(e))return!0;for(let t of e)if(!kp.has(t)&&!Ap.has(t)&&!vp.test(t))return!1;return e.length>0}function Rp(e){let t=!1;for(let n of e)if(!(n===`\\`||vp.test(n))){if(kp.has(n)||jp.has(n)||Ap.has(n)){t=!0;continue}return!1}return t}function zp(e,t){let n=t-1;if(n<=0)return Math.max(n,0);let r=e.charCodeAt(n);if(r<56320||r>57343)return n;let i=n-1;if(i<0)return n;let a=e.charCodeAt(i);return a>=55296&&a<=56319?i:n}function Bp(e){if(e.length===0)return null;let t=zp(e,e.length);return e.slice(t)}function Vp(e){let t=Array.from(e),n=t.length;for(;n>0;){let e=t[n-1];if(vp.test(e)){n--;continue}if(kp.has(e)||Ap.has(e)){n--;continue}break}return n<=0||n===t.length?null:{head:t.slice(0,n).join(``),tail:t.slice(n).join(``)}}function Hp(e,t,n){return n===`text`&&!t&&e.length===1&&e!==`-`&&e!==`—`?e:null}function Up(e,t,n,r){let i=t[r],a=e[r];if(i==null)return a;let o=n[r];if(a.length===o)return a;let s=i.repeat(o);return e[r]=s,s}function Wp(e,t){return e&&t!==null&&Mp.has(t)}function Gp(e){let t=Bp(e);return t!==null&&Np.has(t)}function Kp(e){if(e.length<2||e[0]!==` `)return null;let t=e.slice(1);return/^\p{M}+$/u.test(t)?{space:` `,marks:t}:null}function qp(e){let t=e.length;for(;t>0;){let n=zp(e,t),r=e.slice(n,t);if(Pp.has(r))return!0;if(!jp.has(r))return!1;t=n}return!1}function Jp(e,t){if(t.preserveOrdinarySpaces||t.preserveHardBreaks){if(e===` `)return`preserved-space`;if(e===` `)return`tab`;if(t.preserveHardBreaks&&e===`
`)return`hard-break`}return e===` `?`space`:e===`\xA0`||e===` `||e===`⁠`||e===``?`glue`:e===`​`?`zero-width-break`:e===`­`?`soft-hyphen`:`text`}var Yp=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function Xp(e){return e.length===1?e[0]:e.join(``)}function Zp(e,t){let n=[];for(let t=e.length-1;t>=0;t--)n.push(e[t]);return n.push(t),Xp(n)}function Qp(e,t,n,r){if(!Yp.test(e))return[{text:e,isWordLike:t,kind:`text`,start:n}];let i=[],a=null,o=[],s=n,c=!1,l=0;for(let u of e){let e=Jp(u,r),d=e===`text`&&t;if(a!==null&&e===a&&d===c){o.push(u),l+=u.length;continue}a!==null&&i.push({text:Xp(o),isWordLike:c,kind:a,start:s}),a=e,o=[u],s=n+l,c=d,l+=u.length}return a!==null&&i.push({text:Xp(o),isWordLike:c,kind:a,start:s}),i}function $p(e){return e===`space`||e===`preserved-space`||e===`zero-width-break`||e===`hard-break`}var em=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function tm(e,t){let n=e.texts[t];return n.startsWith(`www.`)?!0:em.test(n)&&t+1<e.len&&e.kinds[t+1]===`text`&&e.texts[t+1]===`//`}function nm(e){return e.includes(`?`)&&(e.includes(`://`)||e.startsWith(`www.`))}function rm(e){let t=e.texts.slice(),n=e.isWordLike.slice(),r=e.kinds.slice(),i=e.starts.slice();for(let i=0;i<e.len;i++){if(r[i]!==`text`||!tm(e,i))continue;let a=[t[i]],o=i+1;for(;o<e.len&&!$p(r[o]);){a.push(t[o]),n[i]=!0;let e=t[o].includes(`?`);if(r[o]=`text`,t[o]=``,o++,e)break}t[i]=Xp(a)}let a=0;for(let e=0;e<t.length;e++){let o=t[e];o.length!==0&&(a!==e&&(t[a]=o,n[a]=n[e],r[a]=r[e],i[a]=i[e]),a++)}return t.length=a,n.length=a,r.length=a,i.length=a,{len:a,texts:t,isWordLike:n,kinds:r,starts:i}}function im(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a];if(t.push(o),n.push(e.isWordLike[a]),r.push(e.kinds[a]),i.push(e.starts[a]),!nm(o))continue;let s=a+1;if(s>=e.len||$p(e.kinds[s]))continue;let c=[],l=e.starts[s],u=s;for(;u<e.len&&!$p(e.kinds[u]);)c.push(e.texts[u]),u++;c.length>0&&(t.push(Xp(c)),n.push(!0),r.push(`text`),i.push(l),a=u-1)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}var am=new Set([`:`,`-`,`/`,`×`,`,`,`.`,`+`,`–`,`—`]),om=/^[A-Za-z0-9_]+[,:;]*$/,sm=/[,:;]+$/;function cm(e){for(let t of e)if(yp.test(t))return!0;return!1}function lm(e){if(e.length===0)return!1;for(let t of e)if(!(yp.test(t)||am.has(t)))return!1;return!0}function um(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a],s=e.kinds[a];if(s===`text`&&lm(o)&&cm(o)){let s=[o],c=a+1;for(;c<e.len&&e.kinds[c]===`text`&&lm(e.texts[c]);)s.push(e.texts[c]),c++;t.push(Xp(s)),n.push(!0),r.push(`text`),i.push(e.starts[a]),a=c-1;continue}t.push(o),n.push(e.isWordLike[a]),r.push(s),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function dm(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a],s=e.kinds[a],c=e.isWordLike[a];if(s===`text`&&c&&om.test(o)){let s=[o],c=sm.test(o),l=a+1;for(;c&&l<e.len&&e.kinds[l]===`text`&&e.isWordLike[l]&&om.test(e.texts[l]);){let t=e.texts[l];s.push(t),c=sm.test(t),l++}t.push(Xp(s)),n.push(!0),r.push(`text`),i.push(e.starts[a]),a=l-1;continue}t.push(o),n.push(c),r.push(s),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function fm(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a];if(e.kinds[a]===`text`&&o.includes(`-`)){let s=o.split(`-`),c=s.length>1;for(let e=0;e<s.length;e++){let t=s[e];if(!c)break;(t.length===0||!cm(t)||!lm(t))&&(c=!1)}if(c){let o=0;for(let c=0;c<s.length;c++){let l=s[c],u=c<s.length-1?`${l}-`:l;t.push(u),n.push(!0),r.push(`text`),i.push(e.starts[a]+o),o+=u.length}continue}}t.push(o),n.push(e.isWordLike[a]),r.push(e.kinds[a]),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function pm(e){let t=[],n=[],r=[],i=[],a=0;for(;a<e.len;){let o=[e.texts[a]],s=e.isWordLike[a],c=e.kinds[a],l=e.starts[a];if(c===`glue`){let u=[o[0]],d=l;for(a++;a<e.len&&e.kinds[a]===`glue`;)u.push(e.texts[a]),a++;let f=Xp(u);if(a<e.len&&e.kinds[a]===`text`)o[0]=f,o.push(e.texts[a]),s=e.isWordLike[a],c=`text`,l=d,a++;else{t.push(f),n.push(!1),r.push(`glue`),i.push(d);continue}}else a++;if(c===`text`)for(;a<e.len&&e.kinds[a]===`glue`;){let t=[];for(;a<e.len&&e.kinds[a]===`glue`;)t.push(e.texts[a]),a++;let n=Xp(t);if(a<e.len&&e.kinds[a]===`text`){o.push(n,e.texts[a]),s||=e.isWordLike[a],a++;continue}o.push(n)}t.push(Xp(o)),n.push(s),r.push(c),i.push(l)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function mm(e){let t=e.texts.slice(),n=e.isWordLike.slice(),r=e.kinds.slice(),i=e.starts.slice();for(let e=0;e<t.length-1;e++){if(r[e]!==`text`||r[e+1]!==`text`||!Sp(t[e])||!Sp(t[e+1]))continue;let n=Vp(t[e]);n!==null&&(t[e]=n.head,t[e+1]=n.tail+t[e+1],i[e+1]=i[e]+n.head.length)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function hm(e,t,n){let r=gp(),i=0,a=[],o=[],s=[],c=[],l=[],u=[],d=[],f=[],p=[],m=[],h=[],g=[];for(let v of r.segment(e))for(let e of Qp(v.segment,v.isWordLike??!1,v.index,n)){let n=e.kind===`text`,r=Hp(e.text,e.isWordLike,e.kind),v=Sp(e.text),y=bp(e.text),b=Bp(e.text),x=qp(e.text),S=Gp(e.text),C=i-1;function _(){u[C]!==null&&(o[C]=[Up(a,u,d,C)],u[C]=null),o[C].push(e.text),s[C]=s[C]||e.isWordLike,f[C]=f[C]||v,p[C]=p[C]||y,m[C]=x,h[C]=S,g[C]=Wp(p[C],b)}t.carryCJKAfterClosingQuote&&n&&i>0&&c[C]===`text`&&v&&f[C]&&m[C]||n&&i>0&&c[C]===`text`&&Ip(e.text)&&f[C]||n&&i>0&&c[C]===`text`&&h[C]?_():n&&i>0&&c[C]===`text`&&e.isWordLike&&y&&g[C]?(_(),s[C]=!0):r!==null&&i>0&&c[C]===`text`&&u[C]===r?d[C]=(d[C]??1)+1:n&&!e.isWordLike&&i>0&&c[C]===`text`&&(Fp(e.text)||e.text===`-`&&s[C])?_():(a[i]=e.text,o[i]=[e.text],s[i]=e.isWordLike,c[i]=e.kind,l[i]=e.start,u[i]=r,d[i]=r===null?0:1,f[i]=v,p[i]=y,m[i]=x,h[i]=S,g[i]=Wp(y,b),i++)}for(let e=0;e<i;e++){if(u[e]!==null){a[e]=Up(a,u,d,e);continue}a[e]=Xp(o[e])}for(let e=1;e<i;e++)c[e]===`text`&&!s[e]&&Rp(a[e])&&c[e-1]===`text`&&(a[e-1]+=a[e],s[e-1]=s[e-1]||s[e],a[e]=``);let v=Array.from({length:i},()=>null),y=-1;for(let e=i-1;e>=0;e--){let t=a[e];if(t.length!==0){if(c[e]===`text`&&!s[e]&&Lp(t)&&y>=0&&c[y]===`text`){let n=v[y]??[];n.push(t),v[y]=n,l[y]=l[e],a[e]=``;continue}y=e}}for(let e=0;e<i;e++){let t=v[e];t!=null&&(a[e]=Zp(t,a[e]))}let b=0;for(let e=0;e<i;e++){let t=a[e];t.length!==0&&(b!==e&&(a[b]=t,s[b]=s[e],c[b]=c[e],l[b]=l[e]),b++)}a.length=b,s.length=b,c.length=b,l.length=b;let x=mm(dm(fm(um(im(rm(pm({len:b,texts:a,isWordLike:s,kinds:c,starts:l})))))));for(let e=0;e<x.len-1;e++){let t=Kp(x.texts[e]);t!==null&&(x.kinds[e]!==`space`&&x.kinds[e]!==`preserved-space`||x.kinds[e+1]!==`text`||!bp(x.texts[e+1])||(x.texts[e]=t.space,x.isWordLike[e]=!1,x.kinds[e]=x.kinds[e]===`preserved-space`?`preserved-space`:`space`,x.texts[e+1]=t.marks+x.texts[e+1],x.starts[e+1]=x.starts[e]+t.space.length))}return x}function gm(e,t){if(e.len===0)return[];if(!t.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}];let n=[],r=0;for(let t=0;t<e.len;t++)e.kinds[t]===`hard-break`&&(n.push({startSegmentIndex:r,endSegmentIndex:t,consumedEndSegmentIndex:t+1}),r=t+1);return r<e.len&&n.push({startSegmentIndex:r,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}),n}function _m(e){if(e.len<=1)return e;let t=[],n=[],r=[],i=[],a=null,o=!1,s=0,c=!1,l=!1;function u(){a!==null&&(t.push(Xp(a)),n.push(o),r.push(`text`),i.push(s),a=null)}for(let d=0;d<e.len;d++){let f=e.texts[d],p=e.kinds[d],m=e.isWordLike[d],h=e.starts[d];if(p===`text`){let e=Tp(f),t=Dp(f);if(a!==null&&c&&l){a.push(f),o||=m,c||=e,l=t;continue}u(),a=[f],o=m,s=h,c=e,l=t;continue}u(),t.push(f),n.push(m),r.push(p),i.push(h)}return u(),{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function vm(e,t,n=`normal`,r=`normal`){let i=dp(n),a=i.mode===`pre-wrap`?pp(e):fp(e);if(a.length===0)return{normalized:a,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let o=r===`keep-all`?_m(hm(a,t,i)):hm(a,t,i);return{normalized:a,chunks:gm(o,i),...o}}var ym=null,bm=new Map,xm=null,Sm=96,Cm=/\p{Emoji_Presentation}/u,wm=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,Tm=null,Em=new Map;function Dm(){if(ym!==null)return ym;if(typeof OffscreenCanvas<`u`)return ym=new OffscreenCanvas(1,1).getContext(`2d`),ym;if(typeof document<`u`)return ym=document.createElement(`canvas`).getContext(`2d`),ym;throw Error(`Text measurement requires OffscreenCanvas or a DOM canvas context.`)}function Om(e){let t=bm.get(e);return t||(t=new Map,bm.set(e,t)),t}function km(e,t){let n=t.get(e);return n===void 0&&(n={width:Dm().measureText(e).width,containsCJK:Sp(e)},t.set(e,n)),n}function Am(){if(xm!==null)return xm;if(typeof navigator>`u`)return xm={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},xm;let e=navigator.userAgent,t=navigator.vendor===`Apple Computer, Inc.`&&e.includes(`Safari/`)&&!e.includes(`Chrome/`)&&!e.includes(`Chromium/`)&&!e.includes(`CriOS/`)&&!e.includes(`FxiOS/`)&&!e.includes(`EdgiOS/`),n=e.includes(`Chrome/`)||e.includes(`Chromium/`)||e.includes(`CriOS/`)||e.includes(`Edg/`);return xm={lineFitEpsilon:t?1/64:.005,carryCJKAfterClosingQuote:n,preferPrefixWidthsForBreakableRuns:t,preferEarlySoftHyphenBreak:t},xm}function jm(e){let t=e.match(/(\d+(?:\.\d+)?)\s*px/);return t?parseFloat(t[1]):16}function Mm(){return Tm===null&&(Tm=new Intl.Segmenter(void 0,{granularity:`grapheme`})),Tm}function Nm(e){return Cm.test(e)||e.includes(`️`)}function Pm(e){return wm.test(e)}function Fm(e,t){let n=Em.get(e);if(n!==void 0)return n;let r=Dm();r.font=e;let i=r.measureText(`😀`).width;if(n=0,i>t+.5&&typeof document<`u`&&document.body!==null){let t=document.createElement(`span`);t.style.font=e,t.style.display=`inline-block`,t.style.visibility=`hidden`,t.style.position=`absolute`,t.textContent=`😀`,document.body.appendChild(t);let r=t.getBoundingClientRect().width;document.body.removeChild(t),i-r>.5&&(n=i-r)}return Em.set(e,n),n}function Im(e){let t=0,n=Mm();for(let r of n.segment(e))Nm(r.segment)&&t++;return t}function Lm(e,t){return t.emojiCount===void 0&&(t.emojiCount=Im(e)),t.emojiCount}function Rm(e,t,n){return n===0?t.width:t.width-Lm(e,t)*n}function zm(e,t,n,r,i){if(t.breakableFitAdvances!==void 0)return t.breakableFitAdvances;let a=Mm(),o=[];for(let t of a.segment(e))o.push(t.segment);if(o.length<=1)return t.breakableFitAdvances=null,t.breakableFitAdvances;if(i===`sum-graphemes`){let e=[];for(let t of o){let i=km(t,n);e.push(Rm(t,i,r))}return t.breakableFitAdvances=e,t.breakableFitAdvances}if(i===`pair-context`||o.length>Sm){let e=[],i=null,a=0;for(let t of o){let o=Rm(t,km(t,n),r);if(i===null)e.push(o);else{let o=i+t,s=km(o,n);e.push(Rm(o,s,r)-a)}i=t,a=o}return t.breakableFitAdvances=e,t.breakableFitAdvances}let s=[],c=``,l=0;for(let e of o){c+=e;let t=km(c,n),i=Rm(c,t,r);s.push(i-l),l=i}return t.breakableFitAdvances=s,t.breakableFitAdvances}function Bm(e,t){let n=Dm();n.font=e;let r=Om(e),i=jm(e);return{cache:r,fontSize:i,emojiCorrection:t?Fm(e,i):0}}function Vm(e,t){for(;t<e.widths.length;){let n=e.kinds[t];if(n!==`space`&&n!==`zero-width-break`&&n!==`soft-hyphen`)break;t++}return t}function Hm(e,t){if(t<=0)return 0;let n=e%t;return Math.abs(n)<=1e-6?t:t-n}function Um(e,t,n,r,i){let a=0,o=t;for(;a<e.length;){let t=o+e[a];if((a+1<e.length?t+i:t)>n+r)break;o=t,a++}return{fitCount:a,fittedWidth:o}}function Wm(e,t){let n=0,r=e.chunks.length;for(;n<r;){let i=Math.floor((n+r)/2);t<e.chunks[i].consumedEndSegmentIndex?r=i:n=i+1}return n<e.chunks.length?n:-1}function Gm(e,t,n){let r=n.segmentIndex;if(n.graphemeIndex>0)return t;let i=e.chunks[t];if(i.startSegmentIndex===i.endSegmentIndex&&r===i.startSegmentIndex)return n.segmentIndex=r,n.graphemeIndex=0,t;for(r<i.startSegmentIndex&&(r=i.startSegmentIndex);r<i.endSegmentIndex;){let i=e.kinds[r];if(i!==`space`&&i!==`zero-width-break`&&i!==`soft-hyphen`)return n.segmentIndex=r,n.graphemeIndex=0,t;r++}return i.consumedEndSegmentIndex>=e.widths.length?-1:(n.segmentIndex=i.consumedEndSegmentIndex,n.graphemeIndex=0,t+1)}function Km(e,t){if(t.segmentIndex>=e.widths.length)return-1;let n=Wm(e,t.segmentIndex);return n<0?-1:Gm(e,n,t)}function qm(e,t,n){if(n.segmentIndex>=e.widths.length)return-1;let r=t;for(;r<e.chunks.length&&n.segmentIndex>=e.chunks[r].consumedEndSegmentIndex;)r++;return r>=e.chunks.length?-1:Gm(e,r,n)}function Jm(e,t){return e.simpleLineWalkFastPath?Ym(e,t):Xm(e,t)}function Ym(e,t,n){let{widths:r,kinds:i,breakableFitAdvances:a}=e;if(r.length===0)return 0;let o=t+Am().lineFitEpsilon,s=0,c=0,l=!1,u=0,d=0,f=0,p=0,m=-1,h=0;function g(){m=-1,h=0}function _(e=f,t=p,r=c){s++,n?.({startSegmentIndex:u,startGraphemeIndex:d,endSegmentIndex:e,endGraphemeIndex:t,width:r}),c=0,l=!1,g()}function v(e,t){l=!0,u=e,d=0,f=e+1,p=0,c=t}function y(e,t,n){l=!0,u=e,d=t,f=e,p=t+1,c=n}function b(e,t){if(!l){v(e,t);return}c+=t,f=e+1,p=0}function x(e,t){let n=a[e];for(let r=t;r<n.length;r++){let t=n[r];l?c+t>o?(_(),y(e,r,t)):(c+=t,f=e,p=r+1):y(e,r,t)}l&&f===e&&p===n.length&&(f=e+1,p=0)}let S=0;for(;S<r.length&&!(!l&&(S=Vm(e,S),S>=r.length));){let e=r[S],n=i[S],s=n===`space`||n===`preserved-space`||n===`tab`||n===`zero-width-break`||n===`soft-hyphen`;if(!l){e>t&&a[S]!==null?x(S,0):v(S,e),s&&(m=S+1,h=c-e),S++;continue}if(c+e>o){if(s){b(S,e),_(S+1,0,c-e),S++;continue}if(m>=0){if(f>m||f===m&&p>0){_();continue}_(m,0,h);continue}if(e>t&&a[S]!==null){_(),x(S,0),S++;continue}_();continue}b(S,e),s&&(m=S+1,h=c-e),S++}return l&&_(),s}function Xm(e,t,n){if(e.simpleLineWalkFastPath)return Ym(e,t,n);let{widths:r,lineEndFitAdvances:i,lineEndPaintAdvances:a,kinds:o,breakableFitAdvances:s,discretionaryHyphenWidth:c,tabStopAdvance:l,chunks:u}=e;if(r.length===0||u.length===0)return 0;let d=Am(),f=d.lineFitEpsilon,p=t+f,m=0,h=0,g=!1,_=0,v=0,y=0,b=0,x=-1,S=0,C=0,w=null;function T(){x=-1,S=0,C=0,w=null}function E(e=y,t=b,r=h){m++,n?.({startSegmentIndex:_,startGraphemeIndex:v,endSegmentIndex:e,endGraphemeIndex:t,width:r}),h=0,g=!1,T()}function D(e,t){g=!0,_=e,v=0,y=e+1,b=0,h=t}function O(e,t,n){g=!0,_=e,v=t,y=e,b=t+1,h=n}function k(e,t){if(!g){D(e,t);return}h+=t,y=e+1,b=0}function ee(e,t,n,r){if(!t)return;let o=e===`tab`?0:i[n],s=e===`tab`?r:a[n];x=n+1,S=h-r+o,C=h-r+s,w=e}function te(e,t){let n=s[e];for(let r=t;r<n.length;r++){let t=n[r];g?h+t>p?(E(),O(e,r,t)):(h+=t,y=e,b=r+1):O(e,r,t)}g&&y===e&&b===n.length&&(y=e+1,b=0)}function ne(e){if(w!==`soft-hyphen`)return!1;let n=s[e];if(n==null)return!1;let{fitCount:r,fittedWidth:i}=Um(n,h,t,f,c);return r===0?!1:(h=i,y=e,b=r,T(),r===n.length?(y=e+1,b=0,!0):(E(e,r,i+c),te(e,r),!0))}function re(e){m++,n?.({startSegmentIndex:e.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:e.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),T()}for(let e=0;e<u.length;e++){let n=u[e];if(n.startSegmentIndex===n.endSegmentIndex){re(n);continue}g=!1,h=0,_=n.startSegmentIndex,v=0,y=n.startSegmentIndex,b=0,T();let f=n.startSegmentIndex;for(;f<n.endSegmentIndex;){let e=o[f],n=e===`space`||e===`preserved-space`||e===`tab`||e===`zero-width-break`||e===`soft-hyphen`,u=e===`tab`?Hm(h,l):r[f];if(e===`soft-hyphen`){g&&(y=f+1,b=0,x=f+1,S=h+c,C=h+c,w=e),f++;continue}if(!g){u>t&&s[f]!==null?te(f,0):D(f,u),ee(e,n,f,u),f++;continue}if(h+u>p){let r=h+(e===`tab`?0:i[f]),o=h+(e===`tab`?u:a[f]);if(w===`soft-hyphen`&&d.preferEarlySoftHyphenBreak&&S<=p){E(x,0,C);continue}if(w===`soft-hyphen`&&ne(f)){f++;continue}if(n&&r<=p){k(f,u),E(f+1,0,o),f++;continue}if(x>=0&&S<=p){if(y>x||y===x&&b>0){E();continue}let e=x;E(e,0,C),f=e;continue}if(u>t&&s[f]!==null){E(),te(f,0),f++;continue}E();continue}k(f,u),ee(e,n,f,u),f++}if(g){let e=x===n.consumedEndSegmentIndex?C:h;E(n.consumedEndSegmentIndex,0,e)}}return m}function Zm(e,t,n,r){let i=e.chunks[n];if(i.startSegmentIndex===i.endSegmentIndex)return t.segmentIndex=i.consumedEndSegmentIndex,t.graphemeIndex=0,0;let{widths:a,lineEndFitAdvances:o,lineEndPaintAdvances:s,kinds:c,breakableFitAdvances:l,discretionaryHyphenWidth:u,tabStopAdvance:d}=e,f=Am(),p=f.lineFitEpsilon,m=r+p,h=0,g=!1,_=t.segmentIndex,v=t.graphemeIndex,y=-1,b=0,x=0,S=null;function C(){y=-1,b=0,x=0,S=null}function w(e=_,n=v,r=h){return g?(t.segmentIndex=e,t.graphemeIndex=n,r):null}function T(e,t){g=!0,_=e+1,v=0,h=t}function E(e,t,n){g=!0,_=e,v=t+1,h=n}function D(e,t){if(!g){T(e,t);return}h+=t,_=e+1,v=0}function O(e,t,n,r){if(!t)return;let i=e===`tab`?0:o[n],a=e===`tab`?r:s[n];y=n+1,b=h-r+i,x=h-r+a,S=e}function k(e,t){let n=l[e];for(let r=t;r<n.length;r++){let t=n[r];if(!g)E(e,r,t);else{if(h+t>m)return w();h+=t,_=e,v=r+1}}return g&&_===e&&v===n.length&&(_=e+1,v=0),null}function ee(e){if(S!==`soft-hyphen`||y<0)return null;let t=l[e]??null;if(t!==null){let{fitCount:n,fittedWidth:i}=Um(t,h,r,p,u);if(n===t.length)return h=i,_=e+1,v=0,C(),null;if(n>0)return w(e,n,i+u)}return b<=m?w(y,0,x):null}for(let e=t.segmentIndex;e<i.endSegmentIndex;e++){let n=c[e],i=n===`space`||n===`preserved-space`||n===`tab`||n===`zero-width-break`||n===`soft-hyphen`,p=e===t.segmentIndex?t.graphemeIndex:0,C=n===`tab`?Hm(h,d):a[e];if(n===`soft-hyphen`&&p===0){g&&(_=e+1,v=0,y=e+1,b=h+u,x=h+u,S=n);continue}if(!g){if(p>0){let t=k(e,p);if(t!==null)return t}else if(C>r&&l[e]!==null){let t=k(e,0);if(t!==null)return t}else T(e,C);O(n,i,e,C);continue}if(h+C>m){let t=h+(n===`tab`?0:o[e]),a=h+(n===`tab`?C:s[e]);if(S===`soft-hyphen`&&f.preferEarlySoftHyphenBreak&&b<=m)return w(y,0,x);let c=ee(e);if(c!==null)return c;if(i&&t<=m)return D(e,C),w(e+1,0,a);if(y>=0&&b<=m)return _>y||_===y&&v>0?w():w(y,0,x);if(C>r&&l[e]!==null){let t=w();if(t!==null)return t;let n=k(e,0);if(n!==null)return n}return w()}D(e,C),O(n,i,e,C)}return y===i.consumedEndSegmentIndex&&v===0?w(i.consumedEndSegmentIndex,0,x):w(i.consumedEndSegmentIndex,0,h)}function Qm(e,t,n){let{widths:r,kinds:i,breakableFitAdvances:a}=e,o=n+Am().lineFitEpsilon,s=0,c=!1,l=t.segmentIndex,u=t.graphemeIndex,d=-1,f=0;for(let e=t.segmentIndex;e<r.length;e++){let p=r[e],m=i[e],h=m===`space`||m===`preserved-space`||m===`tab`||m===`zero-width-break`||m===`soft-hyphen`,g=e===t.segmentIndex?t.graphemeIndex:0,_=a[e];if(!c){if(g>0||p>n&&_!==null){let n=_,r=n[g];c=!0,s=r,l=e,u=g+1;for(let r=g+1;r<n.length;r++){let i=n[r];if(s+i>o)return t.segmentIndex=l,t.graphemeIndex=u,s;s+=i,l=e,u=r+1}l===e&&u===n.length&&(l=e+1,u=0)}else c=!0,s=p,l=e+1,u=0;h&&(d=e+1,f=s-p);continue}if(s+p>o)return h?(t.segmentIndex=e+1,t.graphemeIndex=0,s):d>=0?l>d||l===d&&u>0?(t.segmentIndex=l,t.graphemeIndex=u,s):(t.segmentIndex=d,t.graphemeIndex=0,f):(t.segmentIndex=l,t.graphemeIndex=u,s);s+=p,l=e+1,u=0,h&&(d=e+1,f=s-p)}return c?(t.segmentIndex=l,t.graphemeIndex=u,s):null}function $m(e,t,n){let r={segmentIndex:t.segmentIndex,graphemeIndex:t.graphemeIndex},i=Km(e,r);if(i<0)return null;let a=r.segmentIndex,o=r.graphemeIndex,s=e.simpleLineWalkFastPath?Qm(e,r,n):Zm(e,r,i,n);return s===null?null:{startSegmentIndex:a,startGraphemeIndex:o,endSegmentIndex:r.segmentIndex,endGraphemeIndex:r.graphemeIndex,width:s}}function eh(e,t,n){let r=Km(e,t);return r<0?null:e.simpleLineWalkFastPath?Qm(e,t,n):Zm(e,t,r,n)}function th(e,t){if(e.widths.length===0)return{lineCount:0,maxLineWidth:0};let n={segmentIndex:0,graphemeIndex:0},r=0,i=0;if(!e.simpleLineWalkFastPath){let a=Km(e,n);for(;a>=0;){let o=Zm(e,n,a,t);if(o===null)return{lineCount:r,maxLineWidth:i};r++,o>i&&(i=o),a=qm(e,a,n)}return{lineCount:r,maxLineWidth:i}}for(;;){let a=eh(e,n,t);if(a===null)return{lineCount:r,maxLineWidth:i};r++,a>i&&(i=a)}}var nh=null,rh=new WeakMap;function ih(){return nh===null&&(nh=new Intl.Segmenter(void 0,{granularity:`grapheme`})),nh}function ah(e){return e?{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}:{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function oh(e,t){let n=[],r=[],i=0,a=!1,o=!1,s=!1;function c(){r.length!==0&&(n.push({text:r.length===1?r[0]:r.join(``),start:i}),r=[],a=!1,o=!1,s=!1)}function l(e,t,n){r=[e],i=t,a=n,o=qp(e),s=kp.has(e)}function u(e,t){r.push(e),a||=t;let n=qp(e);e.length===1&&jp.has(e)?o||=n:o=n,s=!1}for(let n of ih().segment(e)){let e=n.segment,i=Sp(e);if(r.length===0){l(e,n.index,i);continue}if(s||Op.has(e)||jp.has(e)||t.carryCJKAfterClosingQuote&&i&&o){u(e,i);continue}if(!a&&!i){u(e,i);continue}c(),l(e,n.index,i)}return c(),n}function sh(e){if(e.length<=1)return e;let t=[],n=[e[0].text],r=e[0].start,i=Sp(e[0].text),a=Dp(e[0].text);function o(){t.push({text:n.length===1?n[0]:n.join(``),start:r})}for(let t=1;t<e.length;t++){let s=e[t],c=Sp(s.text),l=Dp(s.text);if(i&&a){n.push(s.text),i||=c,a=l;continue}o(),n=[s.text],r=s.start,i=c,a=l}return o(),t}function ch(e,t,n,r){let i=Am(),{cache:a,emojiCorrection:o}=Bm(t,Pm(e.normalized)),s=Rm(`-`,km(`-`,a),o),c=Rm(` `,km(` `,a),o)*8;if(e.len===0)return ah(n);let l=[],u=[],d=[],f=[],p=e.chunks.length<=1,m=n?[]:null,h=[],g=n?[]:null,_=Array.from({length:e.len});function v(e,t,n,r,i,a,o){i!==`text`&&i!==`space`&&i!==`zero-width-break`&&(p=!1),l.push(t),u.push(n),d.push(r),f.push(i),m?.push(a),h.push(o),g!==null&&g.push(e)}function y(e,t,n,r,s){let c=km(e,a),l=Rm(e,c,o),u=t===`space`||t===`preserved-space`||t===`zero-width-break`?0:l,d=t===`space`||t===`zero-width-break`?0:l;if(s&&r&&e.length>1){let r=`sum-graphemes`;lm(e)?r=`pair-context`:i.preferPrefixWidthsForBreakableRuns&&(r=`segment-prefixes`),v(e,l,u,d,t,n,zm(e,c,a,o,r));return}v(e,l,u,d,t,n,null)}for(let t=0;t<e.len;t++){_[t]=l.length;let n=e.texts[t],o=e.isWordLike[t],c=e.kinds[t],u=e.starts[t];if(c===`soft-hyphen`){v(n,0,s,s,c,u,null);continue}if(c===`hard-break`){v(n,0,0,0,c,u,null);continue}if(c===`tab`){v(n,0,0,0,c,u,null);continue}let d=km(n,a);if(c===`text`&&d.containsCJK){let e=oh(n,i),t=r===`keep-all`?sh(e):e;for(let e=0;e<t.length;e++){let n=t[e];y(n.text,`text`,u+n.start,o,r===`keep-all`||!Sp(n.text))}continue}y(n,c,u,o,!0)}let b=lh(e.chunks,_,l.length),x=m===null?null:cp(e.normalized,m);return g===null?{widths:l,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:p,segLevels:x,breakableFitAdvances:h,discretionaryHyphenWidth:s,tabStopAdvance:c,chunks:b}:{widths:l,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:p,segLevels:x,breakableFitAdvances:h,discretionaryHyphenWidth:s,tabStopAdvance:c,chunks:b,segments:g}}function lh(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a.startSegmentIndex<t.length?t[a.startSegmentIndex]:n,s=a.endSegmentIndex<t.length?t[a.endSegmentIndex]:n,c=a.consumedEndSegmentIndex<t.length?t[a.consumedEndSegmentIndex]:n;r.push({startSegmentIndex:o,endSegmentIndex:s,consumedEndSegmentIndex:c})}return r}function uh(e,t,n,r){let i=r?.wordBreak??`normal`;return ch(vm(e,Am(),r?.whiteSpace,i),t,n,i)}function dh(e,t,n){return uh(e,t,!1,n)}function fh(e,t,n){return uh(e,t,!0,n)}function ph(e){return e}function mh(e,t,n){let r=Jm(ph(e),t);return{lineCount:r,height:r*n}}function hh(e,t,n){let r=n.get(e);if(r!==void 0)return r;r=[];let i=ih();for(let n of i.segment(t[e]))r.push(n.segment);return n.set(e,r),r}function gh(e){let t=rh.get(e);return t===void 0?(t=new Map,rh.set(e,t),t):t}function _h(e,t,n,r){return r>0&&e[r-1]===`soft-hyphen`&&!(t===r&&n>0)}function vh(e,t,n,r,i,a,o){let s=``,c=_h(t,r,i,a);for(let o=r;o<a;o++)t[o]===`soft-hyphen`||t[o]===`hard-break`||(o===r&&i>0?s+=hh(o,e,n).slice(i).join(``):s+=e[o]);return o>0?(c&&(s+=`-`),s+=hh(a,e,n).slice(r===a?i:0,o).join(``)):c&&(s+=`-`),s}function yh(e,t,n,r,i,a,o){return{text:vh(e.segments,e.kinds,t,r,i,a,o),width:n,start:{segmentIndex:r,graphemeIndex:i},end:{segmentIndex:a,graphemeIndex:o}}}function bh(e,t,n){return yh(e,t,n.width,n.startSegmentIndex,n.startGraphemeIndex,n.endSegmentIndex,n.endGraphemeIndex)}function xh(e){return{width:e.width,start:{segmentIndex:e.startSegmentIndex,graphemeIndex:e.startGraphemeIndex},end:{segmentIndex:e.endSegmentIndex,graphemeIndex:e.endGraphemeIndex}}}function Sh(e,t){return yh(e,gh(e),t.width,t.start.segmentIndex,t.start.graphemeIndex,t.end.segmentIndex,t.end.graphemeIndex)}function Ch(e,t,n){return e.widths.length===0?0:Xm(ph(e),t,e=>{n(xh(e))})}function wh(e,t){return th(ph(e),t)}function Th(e){let t=0;return Ch(e,1/0,e=>{e.width>t&&(t=e.width)}),t}function Eh(e,t,n){let r=[];if(e.widths.length===0)return{lineCount:0,height:0,lines:r};let i=gh(e),a=Xm(ph(e),t,t=>{r.push(bh(e,i,t))});return{lineCount:a,height:a*n,lines:r}}var Dh=/[ \t\n\f\r]+/,Oh=/^[ \t\n\f\r]+/,kh=/[ \t\n\f\r]+$/,Ah={segmentIndex:0,graphemeIndex:0},jh={itemIndex:0,segmentIndex:0,graphemeIndex:0};function Mh(e){return e}function Nh(e){return{segmentIndex:e.segmentIndex,graphemeIndex:e.graphemeIndex}}function Ph(e){return e.segmentIndex===0&&e.graphemeIndex===0}function Fh(e,t){let n=t.get(e);if(n!==void 0)return n;let r=Th(fh(`A A`,e)),i=Th(fh(`AA`,e)),a=Math.max(0,r-i);return t.set(e,a),a}function Ih(e){let t=$m(e,Ah,1/0);return t===null?null:{endGraphemeIndex:t.endGraphemeIndex,endSegmentIndex:t.endSegmentIndex,width:t.width}}function Lh(e,t){return e===0&&t>0}function Rh(e){let t=[],n=Array.from({length:e.length}),r=new Map,i=0;for(let a=0;a<e.length;a++){let o=e[a],s=Oh.test(o.text),c=kh.test(o.text),l=o.text.replace(Oh,``).replace(kh,``);if(l.length===0){Dh.test(o.text)&&i===0&&(i=Fh(o.font,r));continue}let u=i>0?i:s?Fh(o.font,r):0,d=fh(l,o.font),f=Ih(d);if(f===null){i=c?Fh(o.font,r):0;continue}let p={break:o.break??`normal`,endGraphemeIndex:f.endGraphemeIndex,endSegmentIndex:f.endSegmentIndex,extraWidth:o.extraWidth??0,gapBefore:u,naturalWidth:f.width,prepared:d,sourceItemIndex:a};t.push(p),n[a]=p,i=c?Fh(o.font,r):0}return{items:t,itemsBySourceItemIndex:n}}function zh(e,t,n,r){if(e.items.length===0||n.itemIndex>=e.items.length)return null;let i=Math.max(1,t),a=0,o=i,s=n.itemIndex,c={segmentIndex:n.segmentIndex,graphemeIndex:n.graphemeIndex};lineLoop:for(;s<e.items.length;){let t=e.items[s];if(!Ph(c)&&c.segmentIndex===t.endSegmentIndex&&c.graphemeIndex===t.endGraphemeIndex){s++,c.segmentIndex=0,c.graphemeIndex=0;continue}let n=a===0?0:t.gapBefore,l=Ph(c);if(t.break===`never`){if(!l){s++,c.segmentIndex=0,c.graphemeIndex=0;continue}let e=t.naturalWidth+t.extraWidth,u=n+e;if(a>0&&u>o)break lineLoop;r?.(t,n,e,Nh(Ah),{segmentIndex:t.endSegmentIndex,graphemeIndex:t.endGraphemeIndex}),a+=u,o=Math.max(0,i-a),s++,c.segmentIndex=0,c.graphemeIndex=0;continue}let u=n+t.extraWidth;if(a>0&&u>=o)break lineLoop;if(l){let e=u+t.naturalWidth;if(e<=o){r?.(t,n,t.naturalWidth+t.extraWidth,Nh(Ah),{segmentIndex:t.endSegmentIndex,graphemeIndex:t.endGraphemeIndex}),a+=e,o=Math.max(0,i-a),s++,c.segmentIndex=0,c.graphemeIndex=0;continue}}let d=Math.max(1,o-u),f=$m(t.prepared,c,d);if(f===null){s++,c.segmentIndex=0,c.graphemeIndex=0;continue}if(c.segmentIndex===f.endSegmentIndex&&c.graphemeIndex===f.endGraphemeIndex){s++,c.segmentIndex=0,c.graphemeIndex=0;continue}if(a>0&&l&&n>0&&Lh(f.endSegmentIndex,f.endGraphemeIndex)){let e=$m(t.prepared,Ah,Math.max(1,i-t.extraWidth));if(e!==null&&(e.endSegmentIndex>f.endSegmentIndex||e.endSegmentIndex===f.endSegmentIndex&&e.endGraphemeIndex>f.endGraphemeIndex))break lineLoop}if(r?.(t,n,f.width+t.extraWidth,Nh(c),{segmentIndex:f.endSegmentIndex,graphemeIndex:f.endGraphemeIndex}),a+=n+f.width+t.extraWidth,o=Math.max(0,i-a),f.endSegmentIndex===t.endSegmentIndex&&f.endGraphemeIndex===t.endGraphemeIndex){s++,c.segmentIndex=0,c.graphemeIndex=0;continue}c.segmentIndex=f.endSegmentIndex,c.graphemeIndex=f.endGraphemeIndex;break}return a===0?null:(n.itemIndex=s,n.segmentIndex=c.segmentIndex,n.graphemeIndex=c.graphemeIndex,a)}function Bh(e,t,n=jh){let r=Mh(e),i={itemIndex:n.itemIndex,segmentIndex:n.segmentIndex,graphemeIndex:n.graphemeIndex},a=[],o=zh(r,t,i,(e,t,n,r,i)=>{a.push({itemIndex:e.sourceItemIndex,gapBefore:t,occupiedWidth:n,start:r,end:i})});return o===null?null:{fragments:a,width:o,end:i}}function Vh(e,t){return Sh(e.prepared,{width:t.occupiedWidth-e.extraWidth,start:t.start,end:t.end}).text}function Hh(e,t){let n=Mh(e);return{fragments:t.fragments.map(e=>{let t=n.itemsBySourceItemIndex[e.itemIndex];if(t===void 0)throw Error(`Missing rich-text inline item for fragment`);return{...e,text:Vh(t,e)}}),width:t.width,end:t.end}}function Uh(e,t,n){let r=0,i=jh;for(;;){let a=Bh(e,t,i);if(a===null)return r;n(a),r++,i=a.end}}var Wh=`500 14px Inter, sans-serif`,Gh=`600 10px Inter, sans-serif`,Kh=`300 13px Inter, sans-serif`,qh=`600 10px Inter, sans-serif`,Jh=`300 12px Inter, sans-serif`,Yh=18,Xh=16,Zh=16,Qh=6,$h=12,eg=Math.min(window.devicePixelRatio||1,2),tg=`rgba(0, 0, 0, 0.75)`,ng=`rgba(255, 255, 255, 0.08)`,rg=`rgba(255, 255, 255, 0.9)`,ig=`rgba(255, 255, 255, 0.30)`,ag=`rgba(255, 255, 255, 0.85)`,og=`rgba(255, 255, 255, 0.08)`,sg=`rgba(255, 255, 255, 0.45)`,cg=`rgba(255, 255, 255, 0.08)`,lg=`rgba(255, 255, 255, 0.7)`;function ug(e){let t=0,n=0,r=0,i=new Set,a=new Set,o=new Set,s=!1,c=!1;return e.traverse(e=>{if(e.isMesh||e.isPoints||e.isLine){r++;let l=e.geometry;l&&(l.index?n+=l.index.count/3:l.attributes.position&&(n+=l.attributes.position.count/3),l.attributes.position&&(t+=l.attributes.position.count)),e.skeleton&&(s=!0),e.morphTargetInfluences&&e.morphTargetInfluences.length>0&&(c=!0),(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>{if(e){i.add(e.uuid),o.add(e.type.replace(`Material`,``));for(let t in e)e[t]&&e[t].isTexture&&a.add(e[t].uuid)}})}}),{vertices:t,triangles:Math.floor(n),meshes:r,materials:i.size,textures:a.size,materialTypes:Array.from(o),hasSkinning:s,hasMorphs:c}}function dg(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:e.toString()}function fg(e,t){let n=[];return e.hasSkinning&&n.push(`skinned`),e.hasMorphs&&n.push(`morph targets`),t&&t.length>0&&n.push(`${t.length} animation${t.length>1?`s`:``}`),e.materialTypes.length>0&&n.push(e.materialTypes.join(`, `)),n.length>0?n.join(` · `):``}function pg(e,t,n){let r=ug(t),i=fg(r,n),a=[{label:`MESHES`,value:dg(r.meshes)},{label:`VERTICES`,value:dg(r.vertices)},{label:`TRIANGLES`,value:dg(r.triangles)},{label:`MATERIALS`,value:dg(r.materials)},{label:`TEXTURES`,value:dg(r.textures)}];n&&n.length>0&&a.push({label:`ANIMATIONS`,value:n.length.toString()});let o=[];r.materialTypes.forEach(e=>o.push(e)),r.hasSkinning&&o.push(`Skinned`),r.hasMorphs&&o.push(`Morph`),n&&n.length>0&&o.push(`Animated`);let s=mh(dh(`Model Info`,Wh),200,Yh+2),c=a.map(e=>{let t=Rh([{text:e.label+` `,font:Gh},{text:e.value,font:Kh}]),n=wh(dh(e.label,Gh),200),r=wh(dh(e.value,Kh),200);return{...e,labelWidth:n.maxLineWidth,valueWidth:r.maxLineWidth,richPrepared:t}}),l=o.map(e=>({text:e,width:wh(dh(e,qh),300).maxLineWidth+$h})),u=[],d=0;if(i){let e=Eh(fh(i,Jh),200-Zh,Yh);u=e.lines,d=e.height}let f=Math.max(s.width+Zh*2,...c.map(e=>e.labelWidth+e.valueWidth+Zh*3)),p=Math.max(f,180),m=0;if(l.length>0){let e=0,t=1;l.forEach(n=>{e>0&&e+n.width>p-Zh*2&&(t++,e=0),e+=n.width+6}),m=t*(Xh+6)+Qh}let h=Zh+s.height+Qh+Qh+c.length*(Yh+Qh)+m+(d>0?Qh+d:0)+Zh,g=document.createElement(`canvas`);g.width=p*eg,g.height=h*eg,g.style.width=p+`px`,g.style.height=h+`px`;let _=g.getContext(`2d`);_.scale(eg,eg),_.fillStyle=tg,mg(_,0,0,p,h,10),_.fill(),_.strokeStyle=ng,_.lineWidth=1,mg(_,.5,.5,p-1,h-1,10),_.stroke();let v=Zh;if(_.font=Wh,_.fillStyle=rg,_.textBaseline=`top`,_.fillText(`Model Info`,Zh,v),v+=s.height+Qh,_.strokeStyle=og,_.beginPath(),_.moveTo(Zh,v),_.lineTo(p-Zh,v),_.stroke(),v+=Qh,c.forEach(e=>{_.font=Gh,_.fillStyle=ig,_.textAlign=`left`,_.fillText(e.label,Zh,v),_.font=Kh,_.fillStyle=ag,_.textAlign=`right`,_.fillText(e.value,p-Zh,v),_.textAlign=`left`,v+=Yh+Qh}),l.length>0){let e=Zh;l.forEach(t=>{e>Zh&&e+t.width>p-Zh&&(e=Zh,v+=Xh+6),_.fillStyle=cg,mg(_,e,v,t.width,Xh,4),_.fill(),_.font=qh,_.fillStyle=lg,_.textBaseline=`top`,_.fillText(t.text,e+$h/2,v+3),e+=t.width+6}),v+=Xh+Qh+4}u.length>0&&(_.strokeStyle=og,_.beginPath(),_.moveTo(Zh,v),_.lineTo(p-Zh,v),_.stroke(),v+=Qh,_.font=Jh,_.fillStyle=sg,_.textBaseline=`top`,u.forEach(e=>{_.fillText(e.text,Zh,v),v+=Yh}));let y=document.createElement(`div`);return y.classList.add(`model-info`),y.appendChild(g),e.appendChild(y),{el:y,canvas:g,remove(){y.remove()}}}function mg(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath()}var hg=`500 11px Inter, sans-serif`,gg=`300 10px Inter, sans-serif`,_g=10,vg=6,yg=14,bg=Math.min(window.devicePixelRatio||1,2),xg=8;function Sg(e){let t=[];return e.traverse(e=>{if(t.length>=xg||!e.isMesh||!e.name||e.name.startsWith(`_`))return;let n=e.geometry,r=Array.isArray(e.material)?e.material[0]:e.material,i=n&&n.attributes.position?n.attributes.position.count:0,a=r?r.type.replace(`Material`,``):``,o=[{text:e.name,font:hg}];i>0&&o.push({text:` `+wg(i)+` verts`,font:gg}),a&&o.push({text:` `+a,font:gg});let s=Rh(o),c=0,l=0;Uh(s,300,e=>{let t=Hh(s,e);c=Math.max(c,t.width),l++});let u=c+_g*2,d=l*yg+vg*2;n&&n.computeBoundingBox();let f=n?n.boundingBox:null,p=new R;f?(f.getCenter(p),p.applyMatrix4(e.matrixWorld)):e.getWorldPosition(p),t.push({name:e.name,items:o,prepared:s,labelWidth:u,labelHeight:d,position:p,vertCount:i,matType:a})}),t}function Cg(e){let{labelWidth:t,labelHeight:n,items:r,prepared:i}=e,a=document.createElement(`canvas`);a.width=t*bg,a.height=n*bg,a.style.width=t+`px`,a.style.height=n+`px`;let o=a.getContext(`2d`);o.scale(bg,bg),o.fillStyle=`rgba(0, 0, 0, 0.8)`,Tg(o,0,0,t,n,6),o.fill(),o.strokeStyle=`rgba(255, 255, 255, 0.1)`,o.lineWidth=1,Tg(o,.5,.5,t-1,n-1,6),o.stroke(),o.textBaseline=`top`;let s=vg;return Uh(i,t-_g*2,e=>{let t=Hh(i,e),n=_g;t.fragments.forEach(e=>{n+=e.gapBefore,o.font=r[e.itemIndex].font,o.fillStyle=e.itemIndex===0?`rgba(255, 255, 255, 0.9)`:`rgba(255, 255, 255, 0.45)`,o.fillText(e.text,n,s),n+=e.occupiedWidth}),s+=yg}),a}function wg(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:e.toString()}function Tg(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath()}var Eg=new WeakMap,Dg=class extends co{constructor(e){super(e),this.decoderPath=``,this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL=``,this.defaultAttributeIDs={position:`POSITION`,normal:`NORMAL`,color:`COLOR`,uv:`TEX_COORD`},this.defaultAttributeTypes={position:`Float32Array`,normal:`Float32Array`,color:`Float32Array`,uv:`Float32Array`}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){let i=new fo(this.manager);i.setPath(this.path),i.setResponseType(`arraybuffer`),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,e=>{this.parse(e,t,r)},n,r)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Ke,n).catch(n)}decodeDracoFile(e,t,n,r,i=qe,a=()=>{}){let o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:i};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){let n=JSON.stringify(t);if(Eg.has(e)){let t=Eg.get(e);if(t.key===n)return t.promise;if(e.byteLength===0)throw Error(`THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.`)}let r,i=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(i,a).then(n=>(r=n,new Promise((n,a)=>{r._callbacks[i]={resolve:n,reject:a},r.postMessage({type:`decode`,id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return o.catch(()=>!0).then(()=>{r&&i&&this._releaseTask(r,i)}),Eg.set(e,{key:n,promise:o}),o}_createGeometry(e){let t=new Gr;e.index&&t.setIndex(new Pr(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n],i=r.name,a=r.array,o=r.itemSize,s=new Pr(a,o);i===`color`&&(this._assignVertexColorSpace(s,r.vertexColorSpace),s.normalized=!(a instanceof Float32Array)),t.setAttribute(i,s)}return t}_assignVertexColorSpace(e,t){if(t!==`srgb`)return;let n=new B;for(let t=0,r=e.count;t<r;t++)n.fromBufferAttribute(e,t),zt.toWorkingColorSpace(n,Ke),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){let n=new fo(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((t,r)=>{n.load(e,t,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!=`object`||this.decoderConfig.type===`js`,t=[];return e?t.push(this._loadLibrary(`draco_decoder.js`,`text`)):(t.push(this._loadLibrary(`draco_wasm_wrapper.js`,`text`)),t.push(this._loadLibrary(`draco_decoder.wasm`,`arraybuffer`))),this.decoderPending=Promise.all(t).then(t=>{let n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let r=Og.toString(),i=[`/* draco decoder */`,n,``,`/* worker */`,r.substring(r.indexOf(`{`)+1,r.lastIndexOf(`}`))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:`init`,decoderConfig:this.decoderConfig}),e.onmessage=function(t){let n=t.data;switch(n.type){case`decode`:e._callbacks[n.id].resolve(n);break;case`error`:e._callbacks[n.id].reject(n);break;default:console.error(`THREE.DRACOLoader: Unexpected message, "`+n.type+`"`)}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e._taskLoad>t._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log(`Task load: `,this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==``&&URL.revokeObjectURL(this.workerSourceURL),this}};function Og(){let e,t;onmessage=function(r){let i=r.data;switch(i.type){case`init`:e=i.decoderConfig,t=new Promise(function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)});break;case`decode`:let r=i.buffer,a=i.taskConfig;t.then(e=>{let t=e.draco,o=new t.Decoder;try{let e=n(t,o,new Int8Array(r),a),s=e.attributes.map(e=>e.array.buffer);e.index&&s.push(e.index.array.buffer),self.postMessage({type:`decode`,id:i.id,geometry:e},s)}catch(e){console.error(e),self.postMessage({type:`error`,id:i.id,error:e.message})}finally{t.destroy(o)}});break}};function n(e,t,n,a){let o=a.attributeIDs,s=a.attributeTypes,c,l,u=t.GetEncodedGeometryType(n);if(u===e.TRIANGULAR_MESH)c=new e.Mesh,l=t.DecodeArrayToMesh(n,n.byteLength,c);else if(u===e.POINT_CLOUD)c=new e.PointCloud,l=t.DecodeArrayToPointCloud(n,n.byteLength,c);else throw Error(`THREE.DRACOLoader: Unexpected geometry type.`);if(!l.ok()||c.ptr===0)throw Error(`THREE.DRACOLoader: Decoding failed: `+l.error_msg());let d={index:null,attributes:[]};for(let n in o){let r=self[s[n]],l,u;if(a.useUniqueIDs)u=o[n],l=t.GetAttributeByUniqueId(c,u);else{if(u=t.GetAttributeId(c,e[o[n]]),u===-1)continue;l=t.GetAttribute(c,u)}let f=i(e,t,c,n,r,l);n===`color`&&(f.vertexColorSpace=a.vertexColorSpace),d.attributes.push(f)}return u===e.TRIANGULAR_MESH&&(d.index=r(e,t,c)),e.destroy(c),d}function r(e,t,n){let r=n.num_faces()*3,i=r*4,a=e._malloc(i);t.GetTrianglesUInt32Array(n,i,a);let o=new Uint32Array(e.HEAPF32.buffer,a,r).slice();return e._free(a),{array:o,itemSize:1}}function i(e,t,n,r,i,o){let s=o.num_components(),c=n.num_points()*s,l=c*i.BYTES_PER_ELEMENT,u=a(e,i),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,o,u,l,d);let f=new i(e.HEAPF32.buffer,d,c).slice();return e._free(d),{name:r,array:f,itemSize:s}}function a(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}}var kg=class{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){let t=this.workerCreator();t.addEventListener(`message`,this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){let n=this.workersResolve[e];if(n&&n(t),this.queue.length){let{resolve:t,msg:n,transfer:r}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,r)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(n=>{let r=this._getIdleWorker();r===-1?this.queue.push({resolve:n,msg:e,transfer:t}):(this._initWorker(r),this.workerStatus|=1<<r,this.workersResolve[r]=n,this.workers[r].postMessage(e,t))})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}},Ag=1000066e3,jg=class{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}},Mg=class{constructor(e,t,n,r){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=r,this._offset=0}_nextUint8(){let e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){let e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){let e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){let e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){let e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t){t===void 0&&(t=0);let n=this._offset,r=0;for(;this._dataView.getUint8(this._offset)!==t&&r<e;)r++,this._offset++;return r<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,r)}};new Uint8Array([0]);var Ng=[171,75,84,88,32,50,48,187,13,10,26,10];function Pg(e){return new TextDecoder().decode(e)}function Fg(e){let t=new Uint8Array(e.buffer,e.byteOffset,Ng.length);if(t[0]!==Ng[0]||t[1]!==Ng[1]||t[2]!==Ng[2]||t[3]!==Ng[3]||t[4]!==Ng[4]||t[5]!==Ng[5]||t[6]!==Ng[6]||t[7]!==Ng[7]||t[8]!==Ng[8]||t[9]!==Ng[9]||t[10]!==Ng[10]||t[11]!==Ng[11])throw Error(`Missing KTX 2.0 identifier.`);let n=new jg,r=17*Uint32Array.BYTES_PER_ELEMENT,i=new Mg(e,Ng.length,r,!0);n.vkFormat=i._nextUint32(),n.typeSize=i._nextUint32(),n.pixelWidth=i._nextUint32(),n.pixelHeight=i._nextUint32(),n.pixelDepth=i._nextUint32(),n.layerCount=i._nextUint32(),n.faceCount=i._nextUint32();let a=i._nextUint32();n.supercompressionScheme=i._nextUint32();let o=i._nextUint32(),s=i._nextUint32(),c=i._nextUint32(),l=i._nextUint32(),u=i._nextUint64(),d=i._nextUint64(),f=new Mg(e,Ng.length+r,3*a*8,!0);for(let t=0;t<a;t++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});let p=new Mg(e,o,s,!0),m={vendorId:p._skip(4)._nextUint16(),descriptorType:p._nextUint16(),versionNumber:p._nextUint16(),descriptorBlockSize:p._nextUint16(),colorModel:p._nextUint8(),colorPrimaries:p._nextUint8(),transferFunction:p._nextUint8(),flags:p._nextUint8(),texelBlockDimension:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],bytesPlane:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],samples:[]},h=(m.descriptorBlockSize/4-6)/4;for(let e=0;e<h;e++){let t={bitOffset:p._nextUint16(),bitLength:p._nextUint8(),channelType:p._nextUint8(),samplePosition:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&t.channelType?(t.sampleLower=p._nextInt32(),t.sampleUpper=p._nextInt32()):(t.sampleLower=p._nextUint32(),t.sampleUpper=p._nextUint32()),m.samples[e]=t}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(m);let g=new Mg(e,c,l,!0);for(;g._offset<l;){let e=g._nextUint32(),t=g._scan(e),r=Pg(t);if(n.keyValue[r]=g._nextUint8Array(e-t.byteLength-1),r.match(/^ktx/i)){let e=Pg(n.keyValue[r]);n.keyValue[r]=e.substring(0,e.lastIndexOf(`\0`))}g._skip(e%4?4-e%4:0)}if(d<=0)return n;let _=new Mg(e,u,d,!0),v=_._nextUint16(),y=_._nextUint16(),b=_._nextUint32(),x=_._nextUint32(),S=_._nextUint32(),C=_._nextUint32(),w=[];for(let e=0;e<a;e++)w.push({imageFlags:_._nextUint32(),rgbSliceByteOffset:_._nextUint32(),rgbSliceByteLength:_._nextUint32(),alphaSliceByteOffset:_._nextUint32(),alphaSliceByteLength:_._nextUint32()});let T=u+_._offset,E=T+b,D=E+x,O=D+S;return n.globalData={endpointCount:v,selectorCount:y,imageDescs:w,endpointsData:new Uint8Array(e.buffer,e.byteOffset+T,b),selectorsData:new Uint8Array(e.buffer,e.byteOffset+E,x),tablesData:new Uint8Array(e.buffer,e.byteOffset+D,S),extendedData:new Uint8Array(e.buffer,e.byteOffset+O,C)},n}var Ig,Lg,Rg,zg={env:{emscripten_notify_memory_growth:function(e){Rg=new Uint8Array(Lg.exports.memory.buffer)}}},Bg=class{init(){return Ig||(Ig=typeof fetch<`u`?fetch(`data:application/wasm;base64,`+Vg).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,zg)).then(this._init):WebAssembly.instantiate(Buffer.from(Vg,`base64`),zg).then(this._init),Ig)}_init(e){Lg=e.instance,zg.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!Lg)throw Error(`ZSTDDecoder: Await .init() before decoding.`);let n=e.byteLength,r=Lg.exports.malloc(n);Rg.set(e,r),t||=Number(Lg.exports.ZSTD_findDecompressedSize(r,n));let i=Lg.exports.malloc(t),a=Lg.exports.ZSTD_decompress(i,t,r,n),o=Rg.slice(i,i+a);return Lg.exports.free(r),Lg.exports.free(i),o}},Vg=`AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIA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kEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2A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jYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOE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YaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVI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EEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2Ag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AAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ`,Hg=`display-p3`,Ug=`display-p3-linear`,Wg=new WeakMap,Gg=0,Kg,qg=class e extends co{constructor(e){super(e),this.transcoderPath=``,this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new kg,this.workerSourceURL=``,this.workerConfig=null,typeof MSC_TRANSCODER<`u`&&console.warn(`THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.`)}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return this.workerConfig={astcSupported:await e.hasFeatureAsync(`texture-compression-astc`),astcHDRSupported:!1,etc1Supported:await e.hasFeatureAsync(`texture-compression-etc1`),etc2Supported:await e.hasFeatureAsync(`texture-compression-etc2`),dxtSupported:await e.hasFeatureAsync(`texture-compression-bc`),bptcSupported:await e.hasFeatureAsync(`texture-compression-bptc`),pvrtcSupported:await e.hasFeatureAsync(`texture-compression-pvrtc`)},this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature(`texture-compression-astc`),astcHDRSupported:!1,etc1Supported:e.hasFeature(`texture-compression-etc1`),etc2Supported:e.hasFeature(`texture-compression-etc2`),dxtSupported:e.hasFeature(`texture-compression-bc`),bptcSupported:e.hasFeature(`texture-compression-bptc`),pvrtcSupported:e.hasFeature(`texture-compression-pvrtc`)}:this.workerConfig={astcSupported:e.extensions.has(`WEBGL_compressed_texture_astc`),astcHDRSupported:e.extensions.has(`WEBGL_compressed_texture_astc`)&&e.extensions.get(`WEBGL_compressed_texture_astc`).getSupportedProfiles().includes(`hdr`),etc1Supported:e.extensions.has(`WEBGL_compressed_texture_etc1`),etc2Supported:e.extensions.has(`WEBGL_compressed_texture_etc`),dxtSupported:e.extensions.has(`WEBGL_compressed_texture_s3tc`),bptcSupported:e.extensions.has(`EXT_texture_compression_bptc`),pvrtcSupported:e.extensions.has(`WEBGL_compressed_texture_pvrtc`)||e.extensions.has(`WEBKIT_WEBGL_compressed_texture_pvrtc`)},this}init(){if(!this.transcoderPending){let t=new fo(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);let n=t.loadAsync(`basis_transcoder.js`),r=new fo(this.manager);r.setPath(this.transcoderPath),r.setResponseType(`arraybuffer`),r.setWithCredentials(this.withCredentials);let i=r.loadAsync(`basis_transcoder.wasm`);this.transcoderPending=Promise.all([n,i]).then(([t,n])=>{let r=e.BasisWorker.toString(),i=[`/* constants */`,`let _EngineFormat = `+JSON.stringify(e.EngineFormat),`let _EngineType = `+JSON.stringify(e.EngineType),`let _TranscoderFormat = `+JSON.stringify(e.TranscoderFormat),`let _BasisFormat = `+JSON.stringify(e.BasisFormat),`/* basis_transcoder.js */`,t,`/* worker */`,r.substring(r.indexOf(`{`)+1,r.lastIndexOf(`}`))].join(`
-`);this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=n,this.workerPool.setWorkerCreator(()=>{let e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:`init`,config:this.workerConfig,transcoderBinary:t},[t]),e})}),Gg>0&&console.warn(`THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances.`),Gg++}return this.transcoderPending}load(e,t,n,r){if(this.workerConfig===null)throw Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");let i=new fo(this.manager);i.setResponseType(`arraybuffer`),i.setWithCredentials(this.withCredentials),i.load(e,e=>{this.parse(e,t,r)},n,r)}parse(e,t,n){if(this.workerConfig===null)throw Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Wg.has(e))return Wg.get(e).promise.then(t).catch(n);this._createTexture(e).then(e=>t?t(e):null).catch(n)}_createTextureFrom(e,t){let{type:n,error:r,data:{faces:i,width:a,height:o,format:s,type:c,dfdFlags:l}}=e;if(n===`error`)return Promise.reject(r);let u;if(t.faceCount===6)u=new Ma(i,s,c);else{let e=i[0].mipmaps;u=t.layerCount>1?new ja(e,a,o,t.layerCount,s,c):new Aa(e,a,o,s,c)}return u.minFilter=i[0].mipmaps.length===1?f:m,u.magFilter=f,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=Qg(t),u.premultiplyAlpha=!!(l&1),u}async _createTexture(e,t={}){let n=Fg(new Uint8Array(e)),r=n.vkFormat===1000066e3&&n.dataFormatDescriptor[0].colorModel===167;if(!(n.vkFormat===0||r&&!this.workerConfig.astcHDRSupported))return Zg(n);let i=t,a=this.init().then(()=>this.workerPool.postMessage({type:`transcode`,buffer:e,taskConfig:i},[e])).then(e=>this._createTextureFrom(e.data,n));return Wg.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Gg--}};qg.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},qg.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},qg.EngineFormat={RGBAFormat:k,RGBA_ASTC_4x4_Format:_e,RGB_BPTC_UNSIGNED_Format:Oe,RGBA_BPTC_Format:F,RGBA_ETC2_EAC_Format:ge,RGBA_PVRTC_4BPPV1_Format:fe,RGBA_S3TC_DXT5_Format:le,RGB_ETC1_Format:me,RGB_ETC2_Format:he,RGB_PVRTC_4BPPV1_Format:ue,RGBA_S3TC_DXT1_Format:se},qg.EngineType={UnsignedByteType:h,HalfFloatType:S,FloatType:x},qg.BasisWorker=function(){let e,t,n,r=_EngineFormat,i=_EngineType,a=_TranscoderFormat,o=_BasisFormat;self.addEventListener(`message`,function(n){let r=n.data;switch(r.type){case`init`:e=r.config,s(r.transcoderBinary);break;case`transcode`:t.then(()=>{try{let{faces:e,buffers:t,width:n,height:i,hasAlpha:a,format:o,type:s,dfdFlags:l}=c(r.buffer);self.postMessage({type:`transcode`,id:r.id,data:{faces:e,width:n,height:i,hasAlpha:a,format:o,type:s,dfdFlags:l}},t)}catch(e){console.error(e),self.postMessage({type:`error`,id:r.id,error:e.message})}});break}});function s(e){t=new Promise(t=>{n={wasmBinary:e,onRuntimeInitialized:t},BASIS(n)}).then(()=>{n.initializeBasis(),n.KTX2File===void 0&&console.warn(`THREE.KTX2Loader: Please update Basis Universal transcoder.`)})}function c(e){let t=new n.KTX2File(new Uint8Array(e));function r(){t.close(),t.delete()}if(!t.isValid())throw r(),Error(`THREE.KTX2Loader: Invalid or unsupported .ktx2 file`);let a;if(t.isUASTC())a=o.UASTC;else if(t.isETC1S())a=o.ETC1S;else if(t.isHDR())a=o.UASTC_HDR;else throw Error(`THREE.KTX2Loader: Unknown Basis encoding`);let s=t.getWidth(),c=t.getHeight(),l=t.getLayers()||1,u=t.getLevels(),f=t.getFaces(),m=t.getHasAlpha(),h=t.getDFDFlags(),{transcoderFormat:g,engineFormat:_,engineType:v}=d(a,s,c,m);if(!s||!c||!u)throw r(),Error(`THREE.KTX2Loader: Invalid texture`);if(!t.startTranscoding())throw r(),Error(`THREE.KTX2Loader: .startTranscoding failed`);let y=[],b=[];for(let e=0;e<f;e++){let n=[];for(let a=0;a<u;a++){let o=[],s,c;for(let n=0;n<l;n++){let l=t.getImageLevelInfo(a,n,e);e===0&&a===0&&n===0&&(l.origWidth%4!=0||l.origHeight%4!=0)&&console.warn(`THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions.`),u>1?(s=l.origWidth,c=l.origHeight):(s=l.width,c=l.height);let d=new Uint8Array(t.getImageTranscodedSizeInBytes(a,n,0,g)),f=t.transcodeImage(d,a,n,e,g,0,-1,-1);if(v===i.HalfFloatType&&(d=new Uint16Array(d.buffer,d.byteOffset,d.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!f)throw r(),Error(`THREE.KTX2Loader: .transcodeImage failed.`);o.push(d)}let d=p(o);n.push({data:d,width:s,height:c}),b.push(d.buffer)}y.push({mipmaps:n,width:s,height:c,format:_,type:v})}return r(),{faces:y,buffers:b,width:s,height:c,hasAlpha:m,dfdFlags:h,format:_,type:v}}let l=[{if:`astcSupported`,basisFormat:[o.UASTC],transcoderFormat:[a.ASTC_4x4,a.ASTC_4x4],engineFormat:[r.RGBA_ASTC_4x4_Format,r.RGBA_ASTC_4x4_Format],engineType:[i.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:`bptcSupported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.BC7_M5,a.BC7_M5],engineFormat:[r.RGBA_BPTC_Format,r.RGBA_BPTC_Format],engineType:[i.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:`dxtSupported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.BC1,a.BC3],engineFormat:[r.RGBA_S3TC_DXT1_Format,r.RGBA_S3TC_DXT5_Format],engineType:[i.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:`etc2Supported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.ETC1,a.ETC2],engineFormat:[r.RGB_ETC2_Format,r.RGBA_ETC2_EAC_Format],engineType:[i.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:`etc1Supported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.ETC1],engineFormat:[r.RGB_ETC1_Format],engineType:[i.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:`pvrtcSupported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.PVRTC1_4_RGB,a.PVRTC1_4_RGBA],engineFormat:[r.RGB_PVRTC_4BPPV1_Format,r.RGBA_PVRTC_4BPPV1_Format],engineType:[i.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:`bptcSupported`,basisFormat:[o.UASTC_HDR],transcoderFormat:[a.BC6H],engineFormat:[r.RGB_BPTC_UNSIGNED_Format],engineType:[i.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.RGBA32,a.RGBA32],engineFormat:[r.RGBAFormat,r.RGBAFormat],engineType:[i.UnsignedByteType,i.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[a.RGBA_HALF],engineFormat:[r.RGBAFormat],engineType:[i.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],u={[o.ETC1S]:l.filter(e=>e.basisFormat.includes(o.ETC1S)).sort((e,t)=>e.priorityUASTC-t.priorityUASTC),[o.UASTC]:l.filter(e=>e.basisFormat.includes(o.UASTC)).sort((e,t)=>e.priorityUASTC-t.priorityUASTC),[o.UASTC_HDR]:l.filter(e=>e.basisFormat.includes(o.UASTC_HDR)).sort((e,t)=>e.priorityHDR-t.priorityHDR)};function d(t,n,r,i){let a=u[t];for(let o=0;o<a.length;o++){let s=a[o];if(!(s.if&&!e[s.if])&&s.basisFormat.includes(t)&&!(i&&s.transcoderFormat.length<2)&&!(s.needsPowerOfTwo&&!(f(n)&&f(r))))return{transcoderFormat:s.transcoderFormat[+!!i],engineFormat:s.engineFormat[+!!i],engineType:s.engineType[0]}}throw Error(`THREE.KTX2Loader: Failed to identify transcoding target.`)}function f(e){return e<=2?!0:(e&e-1)==0&&e!==0}function p(e){if(e.length===1)return e[0];let t=0;for(let n=0;n<e.length;n++){let r=e[n];t+=r.byteLength}let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.byteLength}return n}};var Jg=new Set([k,A,ne]),Yg={109:k,97:k,37:k,43:k,103:A,83:A,16:A,22:A,100:ne,76:ne,15:ne,9:ne,[Ag]:_e,166:j,165:j},Xg={109:x,97:S,37:h,43:h,103:x,83:S,16:h,22:h,100:x,76:S,15:h,9:h,[Ag]:S,166:h,165:h};async function Zg(e){let{vkFormat:t}=e;if(Yg[t]===void 0)throw Error(`THREE.KTX2Loader: Unsupported vkFormat.`);let n;e.supercompressionScheme===2&&(Kg||=new Promise(async e=>{let t=new Bg;await t.init(),e(t)}),n=await Kg);let r=[];for(let i=0;i<e.levels.length;i++){let a=Math.max(1,e.pixelWidth>>i),o=Math.max(1,e.pixelHeight>>i),s=e.pixelDepth?Math.max(1,e.pixelDepth>>i):0,c=e.levels[i],l;if(e.supercompressionScheme===0)l=c.levelData;else if(e.supercompressionScheme===2)l=n.decode(c.levelData,c.uncompressedByteLength);else throw Error(`THREE.KTX2Loader: Unsupported supercompressionScheme.`);let u;u=Xg[t]===1015?new Float32Array(l.buffer,l.byteOffset,l.byteLength/Float32Array.BYTES_PER_ELEMENT):Xg[t]===1016?new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT):l,r.push({data:u,width:a,height:o,depth:s})}let i;if(Jg.has(Yg[t]))i=e.pixelDepth===0?new Ui(r[0].data,e.pixelWidth,e.pixelHeight):new $t(r[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth);else{if(e.pixelDepth>0)throw Error(`THREE.KTX2Loader: Unsupported pixelDepth.`);i=new Aa(r,e.pixelWidth,e.pixelHeight),i.minFilter=r.length===1?f:m,i.magFilter=f}return i.mipmaps=r,i.type=Xg[t],i.format=Yg[t],i.colorSpace=Qg(e),i.needsUpdate=!0,Promise.resolve(i)}function Qg(e){let t=e.dataFormatDescriptor[0];return t.colorPrimaries===1?t.transferFunction===2?Ke:qe:t.colorPrimaries===10?t.transferFunction===2?Hg:Ug:(t.colorPrimaries===0||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),``)}var $g=`[default]`,e_={ASSET_GENERATOR:`assetgenerator`},t_=new oo,n_=`https://unpkg.com/[email protected]`,r_=new Dg(t_).setDecoderPath(`${n_}/examples/jsm/libs/draco/gltf/`),i_=new qg(t_).setTranscoderPath(`${n_}/examples/jsm/libs/basis/`);function a_(e,t){let n=new Set;e.traverse(e=>{e.geometry&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>{e&&!n.has(e.uuid)&&(n.add(e.uuid),t(e))})})}function o_(e){let{state:t,options:n}=e;if(n.preset===e_.ASSET_GENERATOR){let t=new _o;t.name=`hemi_light`,e.scene.add(t),e.lights.push(t);return}let r=new Mo(t.ambientColor,t.ambientIntensity);r.name=`ambient_light`,e.defaultCamera.add(r);let i=new jo(t.directColor,t.directIntensity);i.position.set(.5,0,.866),i.name=`main_light`,e.defaultCamera.add(i),e.lights.push(r,i)}function s_(e){e.lights.forEach(e=>e.parent.remove(e)),e.lights.length=0}var c_=Uint8Array,l_=Uint16Array,u_=Int32Array,d_=new c_([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),f_=new c_([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),p_=new c_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),m_=function(e,t){for(var n=new l_(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new u_(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},h_=m_(d_,2),g_=h_.b,__=h_.r;g_[28]=258,__[258]=28;var v_=m_(f_,0),y_=v_.b;v_.r;for(var b_=new l_(32768),x_=0;x_<32768;++x_){var S_=(x_&43690)>>1|(x_&21845)<<1;S_=(S_&52428)>>2|(S_&13107)<<2,S_=(S_&61680)>>4|(S_&3855)<<4,b_[x_]=((S_&65280)>>8|(S_&255)<<8)>>1}for(var C_=(function(e,t,n){for(var r=e.length,i=0,a=new l_(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new l_(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new l_(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[b_[d]>>c]=l}else for(s=new l_(r),i=0;i<r;++i)e[i]&&(s[i]=b_[o[e[i]-1]++]>>15-e[i]);return s}),w_=new c_(288),x_=0;x_<144;++x_)w_[x_]=8;for(var x_=144;x_<256;++x_)w_[x_]=9;for(var x_=256;x_<280;++x_)w_[x_]=7;for(var x_=280;x_<288;++x_)w_[x_]=8;for(var T_=new c_(32),x_=0;x_<32;++x_)T_[x_]=5;var E_=C_(w_,9,1),D_=C_(T_,5,1),O_=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},k_=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},A_=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},j_=function(e){return(e+7)/8|0},M_=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new c_(e.subarray(t,n))},N_=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],P_=function(e,t,n){var r=Error(t||N_[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,P_),!n)throw r;return r},F_=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new c_(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new c_(i*3));var l=function(e){var t=n.length;if(e>t){var r=new c_(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=k_(e,d,1);var v=k_(e,d+1,3);if(d+=3,!v){var y=j_(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&P_(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=E_,m=D_,h=9,g=5;else if(v==2){var S=k_(e,d,31)+257,C=k_(e,d+10,15)+4,w=S+k_(e,d+5,31)+1;d+=14;for(var T=new c_(w),E=new c_(19),D=0;D<C;++D)E[p_[D]]=k_(e,d+D*3,7);d+=C*3;for(var O=O_(E),k=(1<<O)-1,ee=C_(E,O,1),D=0;D<w;){var te=ee[k_(e,d,k)];d+=te&15;var y=te>>4;if(y<16)T[D++]=y;else{var ne=0,re=0;for(y==16?(re=3+k_(e,d,3),d+=2,ne=T[D-1]):y==17?(re=3+k_(e,d,7),d+=3):y==18&&(re=11+k_(e,d,127),d+=7);re--;)T[D++]=ne}}var A=T.subarray(0,S),ie=T.subarray(S);h=O_(A),g=O_(ie),p=C_(A,h,1),m=C_(ie,g,1)}else P_(1);if(d>_){c&&P_(0);break}}s&&l(f+131072);for(var ae=(1<<h)-1,oe=(1<<g)-1,se=d;;se=d){var ne=p[A_(e,d)&ae],ce=ne>>4;if(d+=ne&15,d>_){c&&P_(0);break}if(ne||P_(2),ce<256)n[f++]=ce;else if(ce==256){se=d,p=null;break}else{var le=ce-254;if(ce>264){var D=ce-257,ue=d_[D];le=k_(e,d,(1<<ue)-1)+g_[D],d+=ue}var de=m[A_(e,d)&oe],fe=de>>4;de||P_(3),d+=de&15;var ie=y_[fe];if(fe>3){var ue=f_[fe];ie+=A_(e,d)&(1<<ue)-1,d+=ue}if(d>_){c&&P_(0);break}s&&l(f+131072);var pe=f+le;if(f<ie){var me=a-ie,he=Math.min(ie,pe);for(me+f<0&&P_(3);f<he;++f)n[f]=r[me+f]}for(;f<pe;++f)n[f]=n[f-ie]}}t.l=p,t.p=se,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?M_(n,0,f):n.subarray(0,f)},I_=new c_(0),L_=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&P_(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&P_(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function R_(e,t){return F_(e.subarray(L_(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var z_=typeof TextDecoder<`u`&&new TextDecoder;try{z_.decode(I_,{stream:!0})}catch{}var B_=class extends mo{constructor(e){super(e),this.type=S}parse(e){let t=65536,n=t>>3,r=65537,i=16384,a=i-1,o=65535,s=2.7182818**2.2;function c(e,n){let r=0;for(let i=0;i<t;++i)(i==0||e[i>>3]&1<<(i&7))&&(n[r++]=i);let i=r-1;for(;r<t;)n[r++]=0;return i}function l(e){for(let t=0;t<i;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}let u={l:0,c:0,lc:0};function d(e,t,n,r,i){for(;n<e;)t=t<<8|we(r,i),n+=8;n-=e,u.l=t>>n&(1<<e)-1,u.c=t,u.lc=n}let f=Array(59);function p(e){for(let e=0;e<=58;++e)f[e]=0;for(let t=0;t<r;++t)f[e[t]]+=1;let t=0;for(let e=58;e>0;--e){let n=t+f[e]>>1;f[e]=t,t=n}for(let t=0;t<r;++t){let n=e[t];n>0&&(e[t]=n|f[n]++<<6)}}function m(e,t,n,r,i,a){let o=t,s=0,c=0;for(;r<=i;r++){if(o.value-t.value>n)return!1;d(6,s,c,e,o);let l=u.l;if(s=u.c,c=u.lc,a[r]=l,l==63){if(o.value-t.value>n)throw Error(`Something wrong with hufUnpackEncTable`);d(8,s,c,e,o);let l=u.l+6;if(s=u.c,c=u.lc,r+l>i+1)throw Error(`Something wrong with hufUnpackEncTable`);for(;l--;)a[r++]=0;r--}else if(l>=59){let e=l-59+2;if(r+e>i+1)throw Error(`Something wrong with hufUnpackEncTable`);for(;e--;)a[r++]=0;r--}}p(a)}function h(e){return e&63}function g(e){return e>>6}function _(e,t,n,r){for(;t<=n;t++){let n=g(e[t]),i=h(e[t]);if(n>>i)throw Error(`Invalid table entry`);if(i>14){let e=r[n>>i-14];if(e.len)throw Error(`Invalid table entry`);if(e.lit++,e.p){let t=e.p;e.p=Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=[,];e.p[e.lit-1]=t}else if(i){let e=0;for(let a=1<<14-i;a>0;a--){let a=r[(n<<14-i)+e];if(a.len||a.p)throw Error(`Invalid table entry`);a.len=i,a.lit=t,e++}}}return!0}let v={c:0,lc:0};function y(e,t,n,r){e=e<<8|we(n,r),t+=8,v.c=e,v.lc=t}let b={c:0,lc:0};function C(e,t,n,r,i,a,o,s,c){if(e==t){r<8&&(y(n,r,i,a),n=v.c,r=v.lc),r-=8;let e=n>>r;if(e=new Uint8Array([e])[0],s.value+e>c)return!1;let t=o[s.value-1];for(;e-- >0;)o[s.value++]=t}else if(s.value<c)o[s.value++]=e;else return!1;b.c=n,b.lc=r}function w(e){return e&65535}function T(e){let t=w(e);return t>32767?t-65536:t}let E={a:0,b:0};function D(e,t){let n=T(e),r=T(t),i=n+(r&1)+(r>>1),a=i,o=i-r;E.a=a,E.b=o}function O(e,t){let n=w(e),r=w(t),i=n-(r>>1)&o;E.a=r+i-32768&o,E.b=i}function ee(e,t,n,r,i,a,o){let s=o<16384,c=n>i?i:n,l=1,u,d;for(;l<=c;)l<<=1;for(l>>=1,u=l,l>>=1;l>=1;){d=0;let o=d+a*(i-u),c=a*l,f=a*u,p=r*l,m=r*u,h,g,_,v;for(;d<=o;d+=f){let i=d,a=d+r*(n-u);for(;i<=a;i+=m){let n=i+p,r=i+c,a=r+p;s?(D(e[i+t],e[r+t]),h=E.a,_=E.b,D(e[n+t],e[a+t]),g=E.a,v=E.b,D(h,g),e[i+t]=E.a,e[n+t]=E.b,D(_,v),e[r+t]=E.a,e[a+t]=E.b):(O(e[i+t],e[r+t]),h=E.a,_=E.b,O(e[n+t],e[a+t]),g=E.a,v=E.b,O(h,g),e[i+t]=E.a,e[n+t]=E.b,O(_,v),e[r+t]=E.a,e[a+t]=E.b)}if(n&l){let n=i+c;s?D(e[i+t],e[n+t]):O(e[i+t],e[n+t]),h=E.a,e[n+t]=E.b,e[i+t]=h}}if(i&l){let i=d,a=d+r*(n-u);for(;i<=a;i+=m){let n=i+p;s?D(e[i+t],e[n+t]):O(e[i+t],e[n+t]),h=E.a,e[n+t]=E.b,e[i+t]=h}}u=l,l>>=1}return d}function te(e,t,n,r,i,o,s,c,l){let u=0,d=0,f=s,p=Math.trunc(r.value+(i+7)/8);for(;r.value<p;)for(y(u,d,n,r),u=v.c,d=v.lc;d>=14;){let i=t[u>>d-14&a];if(i.len)d-=i.len,C(i.lit,o,u,d,n,r,c,l,f),u=b.c,d=b.lc;else{if(!i.p)throw Error(`hufDecode issues`);let t;for(t=0;t<i.lit;t++){let a=h(e[i.p[t]]);for(;d<a&&r.value<p;)y(u,d,n,r),u=v.c,d=v.lc;if(d>=a&&g(e[i.p[t]])==(u>>d-a&(1<<a)-1)){d-=a,C(i.p[t],o,u,d,n,r,c,l,f),u=b.c,d=b.lc;break}}if(t==i.lit)throw Error(`hufDecode issues`)}}let m=8-i&7;for(u>>=m,d-=m;d>0;){let e=t[u<<14-d&a];if(e.len)d-=e.len,C(e.lit,o,u,d,n,r,c,l,f),u=b.c,d=b.lc;else throw Error(`hufDecode issues`)}return!0}function re(e,t,n,a,o,s){let c={value:0},u=n.value,d=M(t,n),f=M(t,n);n.value+=4;let p=M(t,n);if(n.value+=4,d<0||d>=r||f<0||f>=r)throw Error(`Something wrong with HUF_ENCSIZE`);let h=Array(r),g=Array(i);if(l(g),m(e,n,a-(n.value-u),d,f,h),p>8*(a-(n.value-u)))throw Error(`Something wrong with hufUncompress`);_(h,d,f,g),te(h,g,e,n,p,f,s,o,c)}function A(e,t,n){for(let r=0;r<n;++r)t[r]=e[t[r]]}function ie(e){for(let t=1;t<e.length;t++)e[t]=e[t-1]+e[t]-128}function ae(e,t){let n=0,r=Math.floor((e.length+1)/2),i=0,a=e.length-1;for(;!(i>a||(t[i++]=e[n++],i>a));)t[i++]=e[r++]}function oe(e){let t=e.byteLength,n=[],r=0,i=new DataView(e);for(;t>0;){let e=i.getInt8(r++);if(e<0){let a=-e;t-=a+1;for(let e=0;e<a;e++)n.push(i.getUint8(r++))}else{let a=e;t-=2;let o=i.getUint8(r++);for(let e=0;e<a+1;e++)n.push(o)}}return n}function se(e,t,n,r,i,a){let o=new DataView(a.buffer),s=n[e.idx[0]].width,c=n[e.idx[0]].height,l=Math.floor(s/8),u=Math.ceil(s/8),d=Math.ceil(c/8),f=s-(u-1)*8,p=c-(d-1)*8,m={value:0},h=[,,,],g=[,,,],_=[,,,],v=[,,,],y=[,,,];for(let n=0;n<3;++n)y[n]=t[e.idx[n]],h[n]=n<1?0:h[n-1]+u*d,g[n]=new Float32Array(64),_[n]=new Uint16Array(64),v[n]=new Uint16Array(u*64);for(let t=0;t<d;++t){let a=8;t==d-1&&(a=p);let s=8;for(let e=0;e<u;++e){e==u-1&&(s=f);for(let e=0;e<3;++e)_[e].fill(0),_[e][0]=i[h[e]++],ce(m,r,_[e]),le(_[e],g[e]),ue(g[e]);de(g);for(let t=0;t<3;++t)fe(g[t],v[t],e*64)}let c=0;for(let r=0;r<3;++r){let i=n[e.idx[r]].type;for(let e=8*t;e<8*t+a;++e){c=y[r][e];for(let t=0;t<l;++t){let n=t*64+(e&7)*8;o.setUint16(c+0*i,v[r][n+0],!0),o.setUint16(c+2*i,v[r][n+1],!0),o.setUint16(c+4*i,v[r][n+2],!0),o.setUint16(c+6*i,v[r][n+3],!0),o.setUint16(c+8*i,v[r][n+4],!0),o.setUint16(c+10*i,v[r][n+5],!0),o.setUint16(c+12*i,v[r][n+6],!0),o.setUint16(c+14*i,v[r][n+7],!0),c+=16*i}}if(l!=u)for(let e=8*t;e<8*t+a;++e){let t=y[r][e]+8*l*2*i,n=l*64+(e&7)*8;for(let e=0;e<s;++e)o.setUint16(t+e*2*i,v[r][n+e],!0)}}}let b=new Uint16Array(s);o=new DataView(a.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;let r=n[e.idx[t]].type;if(n[t].type==2)for(let e=0;e<c;++e){let n=y[t][e];for(let e=0;e<s;++e)b[e]=o.getUint16(n+e*2*r,!0);for(let e=0;e<s;++e)o.setFloat32(n+e*2*r,F(b[e]),!0)}}}function ce(e,t,n){let r,i=1;for(;i<64;)r=t[e.value],r==65280?i=64:r>>8==255?i+=r&255:(n[i]=r,i++),e.value++}function le(e,t){t[0]=F(e[0]),t[1]=F(e[1]),t[2]=F(e[5]),t[3]=F(e[6]),t[4]=F(e[14]),t[5]=F(e[15]),t[6]=F(e[27]),t[7]=F(e[28]),t[8]=F(e[2]),t[9]=F(e[4]),t[10]=F(e[7]),t[11]=F(e[13]),t[12]=F(e[16]),t[13]=F(e[26]),t[14]=F(e[29]),t[15]=F(e[42]),t[16]=F(e[3]),t[17]=F(e[8]),t[18]=F(e[12]),t[19]=F(e[17]),t[20]=F(e[25]),t[21]=F(e[30]),t[22]=F(e[41]),t[23]=F(e[43]),t[24]=F(e[9]),t[25]=F(e[11]),t[26]=F(e[18]),t[27]=F(e[24]),t[28]=F(e[31]),t[29]=F(e[40]),t[30]=F(e[44]),t[31]=F(e[53]),t[32]=F(e[10]),t[33]=F(e[19]),t[34]=F(e[23]),t[35]=F(e[32]),t[36]=F(e[39]),t[37]=F(e[45]),t[38]=F(e[52]),t[39]=F(e[54]),t[40]=F(e[20]),t[41]=F(e[22]),t[42]=F(e[33]),t[43]=F(e[38]),t[44]=F(e[46]),t[45]=F(e[51]),t[46]=F(e[55]),t[47]=F(e[60]),t[48]=F(e[21]),t[49]=F(e[34]),t[50]=F(e[37]),t[51]=F(e[47]),t[52]=F(e[50]),t[53]=F(e[56]),t[54]=F(e[59]),t[55]=F(e[61]),t[56]=F(e[35]),t[57]=F(e[36]),t[58]=F(e[48]),t[59]=F(e[49]),t[60]=F(e[57]),t[61]=F(e[58]),t[62]=F(e[62]),t[63]=F(e[63])}function ue(e){let t=.5*Math.cos(3.14159/4),n=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(5*3.14159/16),o=.5*Math.cos(3*3.14159/8),s=.5*Math.cos(7*3.14159/16),c=[,,,,],l=[,,,,],u=[,,,,],d=[,,,,];for(let f=0;f<8;++f){let p=f*8;c[0]=r*e[p+2],c[1]=o*e[p+2],c[2]=r*e[p+6],c[3]=o*e[p+6],l[0]=n*e[p+1]+i*e[p+3]+a*e[p+5]+s*e[p+7],l[1]=i*e[p+1]-s*e[p+3]-n*e[p+5]-a*e[p+7],l[2]=a*e[p+1]-n*e[p+3]+s*e[p+5]+i*e[p+7],l[3]=s*e[p+1]-a*e[p+3]+i*e[p+5]-n*e[p+7],u[0]=t*(e[p+0]+e[p+4]),u[3]=t*(e[p+0]-e[p+4]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[p+0]=d[0]+l[0],e[p+1]=d[1]+l[1],e[p+2]=d[2]+l[2],e[p+3]=d[3]+l[3],e[p+4]=d[3]-l[3],e[p+5]=d[2]-l[2],e[p+6]=d[1]-l[1],e[p+7]=d[0]-l[0]}for(let f=0;f<8;++f)c[0]=r*e[16+f],c[1]=o*e[16+f],c[2]=r*e[48+f],c[3]=o*e[48+f],l[0]=n*e[8+f]+i*e[24+f]+a*e[40+f]+s*e[56+f],l[1]=i*e[8+f]-s*e[24+f]-n*e[40+f]-a*e[56+f],l[2]=a*e[8+f]-n*e[24+f]+s*e[40+f]+i*e[56+f],l[3]=s*e[8+f]-a*e[24+f]+i*e[40+f]-n*e[56+f],u[0]=t*(e[f]+e[32+f]),u[3]=t*(e[f]-e[32+f]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[0+f]=d[0]+l[0],e[8+f]=d[1]+l[1],e[16+f]=d[2]+l[2],e[24+f]=d[3]+l[3],e[32+f]=d[3]-l[3],e[40+f]=d[2]-l[2],e[48+f]=d[1]-l[1],e[56+f]=d[0]-l[0]}function de(e){for(let t=0;t<64;++t){let n=e[0][t],r=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*r-.4682*i,e[2][t]=n+1.8556*r}}function fe(e,t,n){for(let r=0;r<64;++r)t[n+r]=Ar.toHalfFloat(pe(e[r]))}function pe(e){return e<=1?Math.sign(e)*Math.abs(e)**2.2:Math.sign(e)*s**(Math.abs(e)-1)}function me(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function he(e){let t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(oe(t)),r=new Uint8Array(n.length);return ie(n),ae(n,r),new DataView(r.buffer)}function ge(e){let t=R_(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return ie(t),ae(t,n),new DataView(n.buffer)}function _e(e){let r=e.viewer,i={value:e.offset.value},a=new Uint16Array(e.columns*e.lines*(e.inputChannels.length*e.type)),o=new Uint8Array(n),s=0,l=Array(e.inputChannels.length);for(let t=0,n=e.inputChannels.length;t<n;t++)l[t]={},l[t].start=s,l[t].end=l[t].start,l[t].nx=e.columns,l[t].ny=e.lines,l[t].size=e.type,s+=l[t].nx*l[t].ny*l[t].size;let u=De(r,i),d=De(r,i);if(d>=n)throw Error(`Something is wrong with PIZ_COMPRESSION BITMAP_SIZE`);if(u<=d)for(let e=0;e<d-u+1;e++)o[e+u]=N(r,i);let f=new Uint16Array(t),p=c(o,f),m=M(r,i);re(e.array,r,i,m,a,s);for(let t=0;t<e.inputChannels.length;++t){let e=l[t];for(let n=0;n<l[t].size;++n)ee(a,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,p)}A(f,a,s);let h=0,g=new Uint8Array(a.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.inputChannels.length;t++){let e=l[t],n=e.nx*e.size,r=new Uint8Array(a.buffer,e.end*2,n*2);g.set(r,h),h+=n*2,e.end+=n}return new DataView(g.buffer)}function ve(e){let t=R_(e.array.slice(e.offset.value,e.offset.value+e.size)),n=e.inputChannels.length*e.lines*e.columns*e.totalBytes,r=new ArrayBuffer(n),i=new DataView(r),a=0,o=0,s=[,,,,];for(let n=0;n<e.lines;n++)for(let n=0;n<e.inputChannels.length;n++){let r=0;switch(e.inputChannels[n].pixelType){case 1:s[0]=a,s[1]=s[0]+e.columns,a=s[1]+e.columns;for(let n=0;n<e.columns;++n){let e=t[s[0]++]<<8|t[s[1]++];r+=e,i.setUint16(o,r,!0),o+=2}break;case 2:s[0]=a,s[1]=s[0]+e.columns,s[2]=s[1]+e.columns,a=s[2]+e.columns;for(let n=0;n<e.columns;++n){let e=t[s[0]++]<<24|t[s[1]++]<<16|t[s[2]++]<<8;r+=e,i.setUint32(o,r,!0),o+=4}break}}return i}function ye(e){let t=e.viewer,n={value:e.offset.value},r=new Uint8Array(e.columns*e.lines*(e.inputChannels.length*e.type*2)),i={version:P(t,n),unknownUncompressedSize:P(t,n),unknownCompressedSize:P(t,n),acCompressedSize:P(t,n),dcCompressedSize:P(t,n),rleCompressedSize:P(t,n),rleUncompressedSize:P(t,n),rleRawSize:P(t,n),totalAcUncompressedCount:P(t,n),totalDcUncompressedCount:P(t,n),acCompression:P(t,n)};if(i.version<2)throw Error(`EXRLoader.parse: `+Xe.compression+` version `+i.version+` is unsupported`);let a=[],o=De(t,n)-2;for(;o>0;){let e=be(t.buffer,n),r=N(t,n),i=r>>2&3,s=(r>>4)-1,c=new Int8Array([s])[0],l=N(t,n);a.push({name:e,index:c,type:l,compression:i}),o-=e.length+3}let s=Xe.channels,c=Array(e.inputChannels.length);for(let t=0;t<e.inputChannels.length;++t){let n=c[t]={},r=s[t];n.name=r.name,n.compression=0,n.decoded=!1,n.type=r.pixelType,n.pLinear=r.pLinear,n.width=e.columns,n.height=e.lines}let l={idx:[,,,]};for(let t=0;t<e.inputChannels.length;++t){let e=c[t];for(let n=0;n<a.length;++n){let r=a[n];e.name==r.name&&(e.compression=r.compression,r.index>=0&&(l.idx[r.index]=t),e.offset=t)}}let u,d,f;if(i.acCompressedSize>0)switch(i.acCompression){case 0:u=new Uint16Array(i.totalAcUncompressedCount),re(e.array,t,n,i.acCompressedSize,u,i.totalAcUncompressedCount);break;case 1:let r=R_(e.array.slice(n.value,n.value+i.totalAcUncompressedCount));u=new Uint16Array(r.buffer),n.value+=i.totalAcUncompressedCount;break}if(i.dcCompressedSize>0){let t={array:e.array,offset:n,size:i.dcCompressedSize};d=new Uint16Array(ge(t).buffer),n.value+=i.dcCompressedSize}i.rleRawSize>0&&(f=oe(R_(e.array.slice(n.value,n.value+i.rleCompressedSize)).buffer),n.value+=i.rleCompressedSize);let p=0,m=Array(c.length);for(let e=0;e<m.length;++e)m[e]=[];for(let t=0;t<e.lines;++t)for(let t=0;t<c.length;++t)m[t].push(p),p+=c[t].width*e.type*2;se(l,m,c,u,d,r);for(let t=0;t<c.length;++t){let n=c[t];if(!n.decoded)switch(n.compression){case 2:let i=0,a=0;for(let o=0;o<e.lines;++o){let e=m[t][i];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)r[e++]=f[a+t*n.width*n.height];a++}i++}break;default:throw Error(`EXRLoader.parse: unsupported channel compression`)}}return new DataView(r.buffer)}function be(e,t){let n=new Uint8Array(e),r=0;for(;n[t.value+r]!=0;)r+=1;let i=new TextDecoder().decode(n.slice(t.value,t.value+r));return t.value=t.value+r+1,i}function j(e,t,n){let r=new TextDecoder().decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value+=n,r}function xe(e,t){return[Ce(e,t),M(e,t)]}function Se(e,t){return[M(e,t),M(e,t)]}function Ce(e,t){let n=e.getInt32(t.value,!0);return t.value+=4,n}function M(e,t){let n=e.getUint32(t.value,!0);return t.value+=4,n}function we(e,t){let n=e[t.value];return t.value+=1,n}function N(e,t){let n=e.getUint8(t.value);return t.value+=1,n}let P=function(e,t){let n;return n=`getBigInt64`in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,n};function Te(e,t){let n=e.getFloat32(t.value,!0);return t.value+=4,n}function Ee(e,t){return Ar.toHalfFloat(Te(e,t))}function F(e){let t=(e&31744)>>10,n=e&1023;return(e>>15?-1:1)*(t?t===31?n?NaN:1/0:2**(t-15)*(1+n/1024):n/1024*6103515625e-14)}function De(e,t){let n=e.getUint16(t.value,!0);return t.value+=2,n}function Oe(e,t){return F(De(e,t))}function ke(e,t,n,r){let i=n.value,a=[];for(;n.value<i+r-1;){let r=be(t,n),i=Ce(e,n),o=N(e,n);n.value+=3;let s=Ce(e,n),c=Ce(e,n);a.push({name:r,pixelType:i,pLinear:o,xSampling:s,ySampling:c})}return n.value+=1,a}function Ae(e,t){return{redX:Te(e,t),redY:Te(e,t),greenX:Te(e,t),greenY:Te(e,t),blueX:Te(e,t),blueY:Te(e,t),whiteX:Te(e,t),whiteY:Te(e,t)}}function je(e,t){return[`NO_COMPRESSION`,`RLE_COMPRESSION`,`ZIPS_COMPRESSION`,`ZIP_COMPRESSION`,`PIZ_COMPRESSION`,`PXR24_COMPRESSION`,`B44_COMPRESSION`,`B44A_COMPRESSION`,`DWAA_COMPRESSION`,`DWAB_COMPRESSION`][N(e,t)]}function Me(e,t){return{xMin:Ce(e,t),yMin:Ce(e,t),xMax:Ce(e,t),yMax:Ce(e,t)}}function Ne(e,t){return[`INCREASING_Y`,`DECREASING_Y`,`RANDOM_Y`][N(e,t)]}function Pe(e,t){return[`ENVMAP_LATLONG`,`ENVMAP_CUBE`][N(e,t)]}function Fe(e,t){let n=[`ONE_LEVEL`,`MIPMAP_LEVELS`,`RIPMAP_LEVELS`],r=[`ROUND_DOWN`,`ROUND_UP`],i=M(e,t),a=M(e,t),o=N(e,t);return{xSize:i,ySize:a,levelMode:n[o&15],roundingMode:r[o>>4]}}function Ie(e,t){return[Te(e,t),Te(e,t)]}function Le(e,t){return[Te(e,t),Te(e,t),Te(e,t)]}function Re(e,t,n,r,i){if(r===`string`||r===`stringvector`||r===`iccProfile`)return j(t,n,i);if(r===`chlist`)return ke(e,t,n,i);if(r===`chromaticities`)return Ae(e,n);if(r===`compression`)return je(e,n);if(r===`box2i`)return Me(e,n);if(r===`envmap`)return Pe(e,n);if(r===`tiledesc`)return Fe(e,n);if(r===`lineOrder`)return Ne(e,n);if(r===`float`)return Te(e,n);if(r===`v2f`)return Ie(e,n);if(r===`v3f`)return Le(e,n);if(r===`int`)return Ce(e,n);if(r===`rational`)return xe(e,n);if(r===`timecode`)return Se(e,n);if(r===`preview`)return n.value+=i,`skipped`;n.value+=i}function ze(e,t){let n=Math.log2(e);return t==`ROUND_DOWN`?Math.floor(n):Math.ceil(n)}function Be(e,t,n){let r=0;switch(e.levelMode){case`ONE_LEVEL`:r=1;break;case`MIPMAP_LEVELS`:r=ze(Math.max(t,n),e.roundingMode)+1;break;case`RIPMAP_LEVELS`:throw Error(`THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.`)}return r}function Ve(e,t,n,r){let i=Array(e);for(let a=0;a<e;a++){let e=1<<a,o=t/e|0;r==`ROUND_UP`&&o*e<t&&(o+=1),i[a]=(Math.max(o,1)+n-1)/n|0}return i}function He(){let e=this,t=e.offset,n={value:0};for(let r=0;r<e.tileCount;r++){let r=Ce(e.viewer,t),i=Ce(e.viewer,t);t.value+=8,e.size=M(e.viewer,t);let a=r*e.blockWidth,o=i*e.blockHeight;e.columns=a+e.blockWidth>e.width?e.width-a:e.blockWidth,e.lines=o+e.blockHeight>e.height?e.height-o:e.blockHeight;let s=e.columns*e.totalBytes,c=e.size<e.lines*s?e.uncompress(e):me(e);t.value+=e.size;for(let t=0;t<e.lines;t++){let r=t*e.columns*e.totalBytes;for(let i=0;i<e.inputChannels.length;i++){let s=Xe.channels[i].name,l=e.channelByteOffsets[s]*e.columns,u=e.decodeChannels[s];if(u===void 0)continue;n.value=r+l;let d=(e.height-(1+o+t))*e.outLineWidth;for(let t=0;t<e.columns;t++){let r=d+(t+a)*e.outputChannels+u;e.byteArray[r]=e.getter(c,n)}}}}}function Ue(){let e=this,t=e.offset,n={value:0};for(let r=0;r<e.height/e.blockHeight;r++){let i=Ce(e.viewer,t)-Xe.dataWindow.yMin;e.size=M(e.viewer,t),e.lines=i+e.blockHeight>e.height?e.height-i:e.blockHeight;let a=e.columns*e.totalBytes,o=e.size<e.lines*a?e.uncompress(e):me(e);t.value+=e.size;for(let t=0;t<e.blockHeight;t++){let i=r*e.blockHeight,s=t+e.scanOrder(i);if(s>=e.height)continue;let c=t*a,l=(e.height-1-s)*e.outLineWidth;for(let t=0;t<e.inputChannels.length;t++){let r=Xe.channels[t].name,i=e.channelByteOffsets[r]*e.columns,a=e.decodeChannels[r];if(a!==void 0){n.value=c+i;for(let t=0;t<e.columns;t++){let r=l+t*e.outputChannels+a;e.byteArray[r]=e.getter(o,n)}}}}}}function We(e,t,n){let r={};if(e.getUint32(0,!0)!=20000630)throw Error(`THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.`);r.version=e.getUint8(4);let i=e.getUint8(5);r.spec={singleTile:!!(i&2),longName:!!(i&4),deepFormat:!!(i&8),multiPart:!!(i&16)},n.value=8;let a=!0;for(;a;){let i=be(t,n);if(i===``)a=!1;else{let a=be(t,n),o=Re(e,t,n,a,M(e,n));o===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type \'${a}\'.`):r[i]=o}}if(i&-7)throw console.error(`THREE.EXRHeader:`,r),Error(`THREE.EXRLoader: Provided file is currently unsupported.`);return r}function Ge(e,t,n,r,i){let a={size:0,viewer:t,array:n,offset:r,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,inputChannels:e.channels,channelByteOffsets:{},scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:qe};switch(e.compression){case`NO_COMPRESSION`:a.blockHeight=1,a.uncompress=me;break;case`RLE_COMPRESSION`:a.blockHeight=1,a.uncompress=he;break;case`ZIPS_COMPRESSION`:a.blockHeight=1,a.uncompress=ge;break;case`ZIP_COMPRESSION`:a.blockHeight=16,a.uncompress=ge;break;case`PIZ_COMPRESSION`:a.blockHeight=32,a.uncompress=_e;break;case`PXR24_COMPRESSION`:a.blockHeight=16,a.uncompress=ve;break;case`DWAA_COMPRESSION`:a.blockHeight=32,a.uncompress=ye;break;case`DWAB_COMPRESSION`:a.blockHeight=256,a.uncompress=ye;break;default:throw Error(`EXRLoader.parse: `+e.compression+` is unsupported`)}let o={};for(let t of e.channels)switch(t.name){case`Y`:case`R`:case`G`:case`B`:case`A`:o[t.name]=!0,a.type=t.pixelType}let s=!1;if(o.R&&o.G&&o.B)s=!o.A,a.outputChannels=4,a.decodeChannels={R:0,G:1,B:2,A:3};else if(o.Y)a.outputChannels=1,a.decodeChannels={Y:0};else throw Error(`EXRLoader.parse: file contains unsupported data channels.`);if(a.type==1)switch(i){case x:a.getter=Oe;break;case S:a.getter=De;break}else if(a.type==2)switch(i){case x:a.getter=Te;break;case S:a.getter=Ee}else throw Error(`EXRLoader.parse: unsupported pixelType `+a.type+` for `+e.compression+`.`);a.columns=a.width;let c=a.width*a.height*a.outputChannels;switch(i){case x:a.byteArray=new Float32Array(c),s&&a.byteArray.fill(1,0,c);break;case S:a.byteArray=new Uint16Array(c),s&&a.byteArray.fill(15360,0,c);break;default:console.error(`THREE.EXRLoader: unsupported type: `,i);break}let l=0;for(let t of e.channels)a.decodeChannels[t.name]!==void 0&&(a.channelByteOffsets[t.name]=l),l+=t.pixelType*2;if(a.totalBytes=l,a.outLineWidth=a.width*a.outputChannels,e.lineOrder===`INCREASING_Y`?a.scanOrder=e=>e:a.scanOrder=e=>a.height-1-e,a.outputChannels==4?(a.format=k,a.colorSpace=qe):(a.format=ne,a.colorSpace=``),e.spec.singleTile){a.blockHeight=e.tiles.ySize,a.blockWidth=e.tiles.xSize;let n=Be(e.tiles,a.width,a.height),i=Ve(n,a.width,e.tiles.xSize,e.tiles.roundingMode),o=Ve(n,a.height,e.tiles.ySize,e.tiles.roundingMode);a.tileCount=i[0]*o[0];for(let e=0;e<n;e++)for(let n=0;n<o[e];n++)for(let n=0;n<i[e];n++)P(t,r);a.decode=He.bind(a)}else{a.blockWidth=a.width;let e=Math.ceil(a.height/a.blockHeight);for(let n=0;n<e;n++)P(t,r);a.decode=Ue.bind(a)}return a}let Ke={value:0},Je=new DataView(e),Ye=new Uint8Array(e),Xe=We(Je,e,Ke),Ze=Ge(Xe,Je,Ye,Ke,this.type);return Ze.decode(),{header:Xe,width:Ze.width,height:Ze.height,data:Ze.byteArray,format:Ze.format,colorSpace:Ze.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,r){function i(e,n){e.colorSpace=n.colorSpace,e.minFilter=f,e.magFilter=f,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,n)}return super.load(e,i,n,r)}};function V_(e,t){let{id:n,path:r}=t;return n===`neutral`?Promise.resolve({envMap:e.neutralEnvironment}):n===``?Promise.resolve({envMap:null}):new Promise((t,n)=>{new B_().load(r,n=>{let r=e.pmremGenerator.fromEquirectangular(n).texture;n.dispose(),e._loadedEnvironment&&e._loadedEnvironment!==r&&e._loadedEnvironment.dispose(),e._loadedEnvironment=r,t({envMap:r})},void 0,n)})}function H_(e){e.renderer.render(e.scene,e.activeCamera),e.renderer.domElement.toBlob(e=>{if(!e)return;let t=new Date().toISOString().replace(/[:.]/g,`-`).slice(0,19),n=URL.createObjectURL(e),r=document.createElement(`a`);r.download=`3d-screenshot-${t}.png`,r.href=n,r.click(),URL.revokeObjectURL(n)},`image/png`),U_(e)}function U_(e){let t=document.createElement(`div`);t.className=`screenshot-flash`,e.el.appendChild(t),t.addEventListener(`animationend`,()=>t.remove())}function W_(e,t){e.mixer&&=(e.mixer.stopAllAction(),e.mixer.uncacheRoot(e.mixer.getRoot()),null),e.clips=t,t.length&&(e.mixer=new Zo(e.content))}function G_(e){e.clips.forEach(t=>{e.mixer.clipAction(t).reset().play(),e.state.actionStates[t.name]=!0}),e.invalidate()}var K_=.35,q_=class{constructor(){this.model=null,this.mixer=null,this.clips=new Map,this.actions=new Map,this.currentName=null,this.currentAction=null,this.loader=new pu,this.onChange=null,this._animationDefs=[]}attach(e){this.detach(),this.model=e,this.mixer=new Zo(e),this.actions.clear(),this.currentAction=null,this.currentName=null;for(let[e,t]of this.clips){let n=this._retargetClip(t,e),r=this.mixer.clipAction(n);r.enabled=!0,this.actions.set(e,r)}}detach(){this.mixer&&=(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),null),this.model=null,this.actions.clear(),this.currentAction=null,this.currentName=null}setAnimationDefs(e){this._animationDefs=e}getAnimationDefs(){return this._animationDefs}async loadAnimation(e,t,n={}){if(this.clips.has(e))return this.clips.get(e);let r=(await new Promise((e,n)=>{this.loader.load(t,e,void 0,n)})).animations[0];if(!r)throw Error(`No animation found in ${t}`);if(r.name=e,this.clips.set(e,r),this.model&&this.mixer){let t=this._retargetClip(r,e),i=this.mixer.clipAction(t);i.enabled=!0,i.setLoop(n.loop===!1?Ne:Pe),n.loop===!1&&(i.clampWhenFinished=!0),this.actions.set(e,i)}return r}async loadAll(){let e=this._animationDefs.map(async e=>{try{await this.loadAnimation(e.name,e.url,{loop:e.loop!==!1})}catch(t){console.warn(`[AnimationManager] Failed to load "${e.name}" from ${e.url}:`,t)}});await Promise.all(e)}play(e){let t=this.actions.get(e);if(!t){console.warn(`[AnimationManager] Animation "${e}" not loaded`);return}this.currentAction&&this.currentAction!==t&&this.currentAction.fadeOut(.01),t.reset().fadeIn(.01).play(),this.currentAction=t,this.currentName=e,this.onChange&&this.onChange(e)}crossfadeTo(e,t=K_){if(e===this.currentName)return;let n=this.actions.get(e);if(!n){console.warn(`[AnimationManager] Animation "${e}" not loaded`);return}n.reset(),n.play(),this.currentAction?this.currentAction.crossFadeTo(n,t,!0):n.fadeIn(t),this.currentAction=n,this.currentName=e,this.onChange&&this.onChange(e)}stopAll(){this.mixer&&this.mixer.stopAllAction(),this.currentAction=null,this.currentName=null,this.onChange&&this.onChange(null)}update(e){this.mixer&&this.mixer.update(e)}_retargetClip(e,t){if(!this.model)return e;let n=new Set;if(this.model.traverse(e=>{e.isBone&&n.add(e.name)}),n.size===0)return e;let r=new Set;for(let t of e.tracks){let e=t.name.split(`.`)[0];r.add(e)}let i=0;for(let e of r)n.has(e)&&i++;if(i/r.size>.5)return e;let a=this._buildBoneNameMap(n,r);return a?(e.tracks.map(e=>{let t=e.name.split(`.`),n=t[0],r=t.slice(1).join(`.`),i=a.get(n);if(!i)return null;let o=e.clone();return o.name=`${i}.${r}`,o}).filter(Boolean),e.clone().resetDuration()):e}_buildBoneNameMap(e,t){let n=new Map,r=[...e],i=[...t],a=e=>e.replace(/^mixamorig\d*[_:]?/i,``).replace(/^Armature[_/]?/i,``),o=new Map(r.map(e=>[a(e),e])),s=0;for(let e of i){let t=a(e);o.has(t)&&(n.set(e,o.get(t)),s++)}if(s/i.length>.5)return n;let c=new Map(r.map(e=>[e.toLowerCase(),e]));n.clear(),s=0;for(let e of i)c.has(e.toLowerCase())&&(n.set(e,c.get(e.toLowerCase())),s++);return s/i.length>.5?n:null}getLoadedNames(){return[...this.clips.keys()]}isLoaded(e){return this.clips.has(e)}dispose(){this.detach(),this.clips.clear(),this._animationDefs=[]}};ao.enabled=!0;var J_=class{constructor(e,t){this.el=e,this.options=t,this.lights=[],this.content=null,this.mixer=null,this.clips=[],this.gui=null,this.animationManager=new q_,this._animPanelEl=null,this.state={environment:t.preset===e_.ASSET_GENERATOR?rp.find(e=>e.id===`footprint-court`).name:rp[1].name,background:!1,playbackSpeed:1,actionStates:{},camera:$g,wireframe:!1,skeleton:!1,grid:!1,autoRotate:!1,punctualLights:!0,exposure:0,toneMapping:1,ambientIntensity:.3,ambientColor:`#FFFFFF`,directIntensity:.8*Math.PI,directColor:`#FFFFFF`,bgColor:`#000000`,transparentBg:!1,pointSize:1,showInfo:!0,showLabels:!1},this.prevTime=0,this.stats=new du,this.stats.dom.height=`48px`,[].forEach.call(this.stats.dom.children,e=>e.style.display=``),this.backgroundColor=new B(this.state.bgColor),this.scene=new Oi,this.scene.background=this.backgroundColor,this.defaultCamera=new yi(t.preset===e_.ASSET_GENERATOR?.8*180/Math.PI:60,e.clientWidth/e.clientHeight,.01,1e3),this.activeCamera=this.defaultCamera,this.scene.add(this.defaultCamera),this.renderer=window.renderer=new uu({antialias:!0,alpha:!0}),this.renderer.setClearColor(0,1),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(e.clientWidth,e.clientHeight),this.pmremGenerator=new Ps(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.neutralEnvironment=this.pmremGenerator.fromScene(new Id).texture,this.controls=new Cd(this.defaultCamera,this.renderer.domElement),this.controls.screenSpacePanning=!0,this._onControlsChange=()=>this.invalidate(),this.controls.addEventListener(`change`,this._onControlsChange),this.el.appendChild(this.renderer.domElement),this.cameraCtrl=null,this.cameraFolder=null,this.animFolder=null,this.animCtrls=[],this.morphFolder=null,this.morphCtrls=[],this.skeletonHelpers=[],this.gridHelper=null,this.axesHelper=null,this.modelInfo=null,this.annotationEls=[],this._tempVec=new R,this.addAxesHelper(),this.addGUI(),t.kiosk&&this.gui.close(),this.animate=this.animate.bind(this),this._rafId=null,this._visible=!0,this._tabVisible=!document.hidden,this._disposed=!1,this._loadedEnvironment=null,this._guiWrap=null,this._needsRender=!0,this._animating=!1,this._onVisibilityChange=()=>{let e=!this._tabVisible;this._tabVisible=!document.hidden,e&&this._tabVisible&&(this._needsRender=!0),this._updateRenderLoop()},document.addEventListener(`visibilitychange`,this._onVisibilityChange),typeof IntersectionObserver<`u`&&(this._intersectionObserver=new IntersectionObserver(e=>{let t=!this._visible;this._visible=e[e.length-1].isIntersecting,t&&this._visible&&(this._needsRender=!0),this._updateRenderLoop()},{threshold:0}),this._intersectionObserver.observe(this.el)),this._onResize=this.resize.bind(this),this._onKeyDown=e=>{(e.key===`p`||e.key===`P`)&&!this.isInputFocused()&&this.takeScreenshot()},this._updateRenderLoop(),window.addEventListener(`resize`,this._onResize,!1),window.addEventListener(`keydown`,this._onKeyDown)}invalidate(){this._disposed||(this._needsRender=!0,this._updateRenderLoop())}_recomputeAnimating(){let e=!1;if(this.state&&this.state.autoRotate&&(e=!0),!e&&this.mixer&&this.state){for(let t in this.state.actionStates)if(this.state.actionStates[t]){e=!0;break}}!e&&this.animationManager.currentAction&&(e=!0),this._animating=e}_updateRenderLoop(){if(this._disposed)return;let e=this._visible&&this._tabVisible;e&&(this._needsRender||this._animating)&&this._rafId===null?(this.prevTime=performance.now(),this._rafId=requestAnimationFrame(this.animate)):!e&&this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}animate(e){let t=(e-this.prevTime)/1e3;if(this.prevTime=e,this._recomputeAnimating(),this.controls.update(),this.stats.update(),this.mixer&&this.mixer.update(t),this.animationManager.update(t),this._afterAnimateHooks)for(let e=0;e<this._afterAnimateHooks.length;e++)this._afterAnimateHooks[e](t);this.render(),this._needsRender=!1,this._animating&&this._visible&&this._tabVisible&&!this._disposed?this._rafId=requestAnimationFrame(this.animate):this._rafId=null}isInputFocused(){let e=document.activeElement;return e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable)}render(){this.renderer.render(this.scene,this.activeCamera),this.state.grid&&(this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesRenderer.render(this.axesScene,this.axesCamera)),this.projectAnnotations()}takeScreenshot(){H_(this)}resize(){let{clientHeight:e,clientWidth:t}=this.el;this.defaultCamera.aspect=t/e,this.defaultCamera.updateProjectionMatrix(),this.renderer.setSize(t,e),this.axesCamera.aspect=this.axesDiv.clientWidth/this.axesDiv.clientHeight,this.axesCamera.updateProjectionMatrix(),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.invalidate()}load(e,t,n){let r=No.extractUrlBase(e);return new Promise((i,a)=>{t_.setURLModifier((e,i)=>{let a=t+decodeURI(e).replace(r,``).replace(/^(\.?\/)/,``);if(n.has(a)){let e=n.get(a),t=URL.createObjectURL(e);return s.push(t),t}return(i||``)+e});let o=new pu(t_).setCrossOrigin(`anonymous`).setDRACOLoader(r_).setKTX2Loader(i_.detectSupport(this.renderer)).setMeshoptDecoder(fd),s=[];o.load(e,e=>{window.VIEWER.json=e;let t=e.scene||e.scenes[0],n=e.animations||[];if(!t)throw Error(`This model contains no scene, and cannot be viewed here. However, it may contain individual 3D resources.`);this.setContent(t,n),s.forEach(URL.revokeObjectURL),i(e)},void 0,a)})}setContent(e,t){this.clear(),e.updateMatrixWorld();let n=new rn().setFromObject(e),r=n.getSize(new R).length(),i=n.getCenter(new R);this.controls.reset(),e.position.x-=i.x,e.position.y-=i.y,e.position.z-=i.z,this.controls.maxDistance=r*10,this.defaultCamera.near=r/100,this.defaultCamera.far=r*100,this.defaultCamera.updateProjectionMatrix(),this.options.cameraPosition?(this.defaultCamera.position.fromArray(this.options.cameraPosition),this.defaultCamera.lookAt(new R)):(this.defaultCamera.position.copy(i),this.defaultCamera.position.x+=r/2,this.defaultCamera.position.y+=r/5,this.defaultCamera.position.z+=r/2,this.defaultCamera.lookAt(i)),this.setCamera($g),this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesCamera.near=r/100,this.axesCamera.far=r*100,this.axesCamera.updateProjectionMatrix(),this.axesCorner.scale.set(r,r,r),this.controls.saveState(),this.scene.add(e),this.content=e,this.state.punctualLights=!0,this.content.traverse(e=>{e.isLight&&(this.state.punctualLights=!1)}),this.setClips(t),this.animationManager.attach(this.content),this._setupAnimationPanel(),this.updateLights(),this.updateGUI(),this.updateEnvironment(),this.updateDisplay(),this.updateModelInfo(e,t),this.updateAnnotations(),window.VIEWER.scene=this.content,this.printGraph(this.content),this.invalidate()}printGraph(e){console.group(` <`+e.type+`> `+e.name),e.children.forEach(e=>this.printGraph(e)),console.groupEnd()}setClips(e){W_(this,e)}playAllClips(){G_(this)}setCamera(e){e===`[default]`?(this.controls.enabled=!0,this.activeCamera=this.defaultCamera):(this.controls.enabled=!1,this.content.traverse(t=>{t.isCamera&&t.name===e&&(this.activeCamera=t)})),this.invalidate()}updateLights(){let e=this.state,t=this.lights;e.punctualLights&&!t.length?o_(this):!e.punctualLights&&t.length&&s_(this),this.renderer.toneMapping=Number(e.toneMapping),this.renderer.toneMappingExposure=2**e.exposure,t.length===2&&(t[0].intensity=e.ambientIntensity,t[0].color.set(e.ambientColor),t[1].intensity=e.directIntensity,t[1].color.set(e.directColor)),this.invalidate()}updateEnvironment(){let e=rp.filter(e=>e.name===this.state.environment)[0];V_(this,e).then(({envMap:e})=>{this._disposed||!this.scene||(this.scene.environment=e,this.scene.background=this.state.transparentBg?null:this.state.background?e:this.backgroundColor,this.invalidate())})}updateDisplay(){this.skeletonHelpers.length&&this.skeletonHelpers.forEach(e=>this.scene.remove(e)),a_(this.content,e=>{e.wireframe=this.state.wireframe,e instanceof Ca&&(e.size=this.state.pointSize)}),this.content.traverse(e=>{if(e.geometry&&e.skeleton&&this.state.skeleton){let t=new ns(e.skeleton.bones[0].parent);t.material.linewidth=3,this.scene.add(t),this.skeletonHelpers.push(t)}}),this.state.grid!==!!this.gridHelper&&(this.state.grid?(this.gridHelper=new is,this.axesHelper=new as,this.axesHelper.renderOrder=999,this.axesHelper.onBeforeRender=e=>e.clearDepth(),this.scene.add(this.gridHelper),this.scene.add(this.axesHelper)):(this.scene.remove(this.gridHelper),this.scene.remove(this.axesHelper),this.gridHelper=null,this.axesHelper=null,this.axesRenderer.clear())),this.controls.autoRotate=this.state.autoRotate,this.invalidate()}updateBackground(){this.backgroundColor.set(this.state.bgColor),this.state.transparentBg?(this.scene.background=null,this.renderer.setClearColor(0,0)):(this.scene.background=this.backgroundColor,this.renderer.setClearColor(0,1),this.updateEnvironment()),this.invalidate()}updateModelInfo(e,t){this.modelInfo&&=(this.modelInfo.remove(),null),this.state.showInfo&&e&&(this.modelInfo=pg(this.el,e,t))}updateAnnotations(){this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[],!(!this.state.showLabels||!this.content)&&(Sg(this.content).forEach(e=>{let t=Cg(e),n=document.createElement(`div`);n.classList.add(`annotation-label`),n.appendChild(t),this.el.appendChild(n),this.annotationEls.push({el:n,position:e.position})}),this.invalidate())}projectAnnotations(){if(this.annotationEls.length===0)return;let e=this.el.clientWidth,t=this.el.clientHeight,n=e/2,r=t/2,i=this._tempVec;this.annotationEls.forEach(({el:e,position:t})=>{if(i.copy(t),i.project(this.activeCamera),i.z>1){e.style.display=`none`;return}let a=i.x*n+n,o=-(i.y*r)+r;e.style.display=``,e.style.left=a+`px`,e.style.top=o+`px`})}addAxesHelper(){this.axesDiv=document.createElement(`div`),this.el.appendChild(this.axesDiv),this.axesDiv.classList.add(`axes`);let{clientWidth:e,clientHeight:t}=this.axesDiv;this.axesScene=new Oi,this.axesCamera=new yi(50,e/t,.1,10),this.axesScene.add(this.axesCamera),this.axesRenderer=new uu({alpha:!0}),this.axesRenderer.setPixelRatio(window.devicePixelRatio),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.axesCamera.up=this.defaultCamera.up,this.axesCorner=new as(5),this.axesScene.add(this.axesCorner),this.axesDiv.appendChild(this.axesRenderer.domElement)}addGUI(){let e=window.innerWidth<=700,t=this.gui=new np({autoPlace:!1,width:e?220:260,hideable:!0}),n=t.addFolder(`Display`);n.add(this.state,`background`).onChange(()=>this.updateEnvironment()),n.add(this.state,`autoRotate`).onChange(()=>this.updateDisplay()),n.add(this.state,`wireframe`).onChange(()=>this.updateDisplay()),n.add(this.state,`skeleton`).onChange(()=>this.updateDisplay()),n.add(this.state,`grid`).onChange(()=>this.updateDisplay()),n.add(this.controls,`screenSpacePanning`),n.add(this.state,`pointSize`,1,16).onChange(()=>this.updateDisplay()),n.add(this.state,`transparentBg`).name(`transparent bg`).onChange(()=>this.updateBackground()),n.addColor(this.state,`bgColor`).onChange(()=>this.updateBackground()),n.add({screenshot:()=>this.takeScreenshot()},`screenshot`).name(`Screenshot [P]`),n.add(this.state,`showInfo`).name(`model info`).onChange(()=>this.updateModelInfo(this.content,this.clips)),n.add(this.state,`showLabels`).name(`mesh labels`).onChange(()=>this.updateAnnotations());let r=t.addFolder(`Lighting`);r.add(this.state,`environment`,rp.map(e=>e.name)).onChange(()=>this.updateEnvironment()),[r.add(this.state,`toneMapping`,{Linear:1,"ACES Filmic":4}),r.add(this.state,`exposure`,-10,10,.01),r.add(this.state,`punctualLights`).listen(),r.add(this.state,`ambientIntensity`,0,2),r.addColor(this.state,`ambientColor`),r.add(this.state,`directIntensity`,0,4),r.addColor(this.state,`directColor`)].forEach(e=>e.onChange(()=>this.updateLights())),this.animFolder=t.addFolder(`Animation`),this.animFolder.domElement.style.display=`none`,this.animFolder.add(this.state,`playbackSpeed`,0,1).onChange(e=>{this.mixer&&(this.mixer.timeScale=e)}),this.animFolder.add({playAll:()=>this.playAllClips()},`playAll`),this.morphFolder=t.addFolder(`Morph Targets`),this.morphFolder.domElement.style.display=`none`,this.cameraFolder=t.addFolder(`Cameras`),this.cameraFolder.domElement.style.display=`none`;let i=t.addFolder(`Performance`),a=document.createElement(`li`);this.stats.dom.style.position=`static`,a.appendChild(this.stats.dom),a.classList.add(`gui-stats`),i.__ul.appendChild(a);let o=document.createElement(`div`);this.el.appendChild(o),o.classList.add(`gui-wrap`),o.appendChild(t.domElement),this._guiWrap=o,e?t.close():t.open()}updateGUI(){this.cameraFolder.domElement.style.display=`none`,this.morphCtrls.forEach(e=>e.remove()),this.morphCtrls.length=0,this.morphFolder.domElement.style.display=`none`,this.animCtrls.forEach(e=>e.remove()),this.animCtrls.length=0,this.animFolder.domElement.style.display=`none`;let e=[],t=[];if(this.content.traverse(n=>{n.geometry&&n.morphTargetInfluences&&t.push(n),n.isCamera&&(n.name=n.name||`VIEWER__camera_${e.length+1}`,e.push(n.name))}),e.length){this.cameraFolder.domElement.style.display=``,this.cameraCtrl&&this.cameraCtrl.remove();let t=[$g].concat(e);this.cameraCtrl=this.cameraFolder.add(this.state,`camera`,t),this.cameraCtrl.onChange(e=>this.setCamera(e))}if(t.length&&(this.morphFolder.domElement.style.display=``,t.forEach(e=>{if(e.morphTargetInfluences.length){let t=this.morphFolder.add({name:e.name||`Untitled`},`name`);this.morphCtrls.push(t)}for(let t=0;t<e.morphTargetInfluences.length;t++){let n=this.morphFolder.add(e.morphTargetInfluences,t,0,1,.01).listen();Object.keys(e.morphTargetDictionary).forEach(r=>{r&&e.morphTargetDictionary[r]===t&&n.name(r)}),this.morphCtrls.push(n)}})),this.clips.length){this.animFolder.domElement.style.display=``;let e=this.state.actionStates={};this.clips.forEach((t,n)=>{t.name=`${n+1}. ${t.name}`;let r;n===0?(e[t.name]=!0,r=this.mixer.clipAction(t),r.play()):e[t.name]=!1;let i=this.animFolder.add(e,t.name).listen();i.onChange(e=>{r||=this.mixer.clipAction(t),r.setEffectiveTimeScale(1),e?r.play():r.stop(),this.invalidate()}),this.animCtrls.push(i)})}}setAnimationDefs(e){this.animationManager.setAnimationDefs(e),this.content&&this._setupAnimationPanel()}_setupAnimationPanel(){this._animPanelEl&&=(this._animPanelEl.remove(),null);let e=this.animationManager.getAnimationDefs();if(e.length===0)return;let t=!1;if(this.content.traverse(e=>{e.isSkinnedMesh&&(t=!0)}),!t)return;let n=document.createElement(`div`);n.className=`anim-panel`,n.innerHTML=`<div class="anim-panel__header"><span class="anim-panel__title">Animations</span><button class="anim-panel__stop" title="Stop all">⏹</button></div><div class="anim-panel__grid"></div>`,this.el.appendChild(n),this._animPanelEl=n,this._renderAnimButtons(),this.animationManager.loadAll().then(()=>{if(this._renderAnimButtons(),!this.animationManager.currentName&&e.length>0){let t=e[0].name;this.animationManager.isLoaded(t)&&(this.animationManager.play(t),this._renderAnimButtons(),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop())}}),n.querySelector(`.anim-panel__stop`).addEventListener(`click`,()=>{this.animationManager.stopAll(),this._renderAnimButtons(),this.invalidate()}),this.animationManager.onChange=()=>{this._renderAnimButtons()}}_renderAnimButtons(){if(!this._animPanelEl)return;let e=this._animPanelEl.querySelector(`.anim-panel__grid`),t=this.animationManager.getAnimationDefs(),n=this.animationManager.currentName,r={idle:`🧍`,breathing:`🧍`,standing:`🧍`,walking:`🚶`,walk:`🚶`,running:`🏃`,run:`🏃`,waving:`👋`,wave:`👋`,dancing:`💃`,dance:`💃`,sitting:`🪑`,sit:`🪑`,jumping:`🦘`,jump:`🦘`,talking:`🗣️`,talk:`🗣️`,clapping:`👏`,clap:`👏`,punching:`👊`,punch:`👊`,kicking:`🦵`,kick:`🦵`};e.innerHTML=t.map(e=>{let t=this.animationManager.isLoaded(e.name),i=n===e.name,a=e.icon||r[e.name.toLowerCase()]||`▶`,o=e.label||e.name.charAt(0).toUpperCase()+e.name.slice(1);return`<button class="anim-btn`+(i?` anim-btn--active`:``)+(t?``:` anim-btn--loading`)+`" data-anim="`+e.name+`" title="`+o+`"`+(t?``:` disabled`)+`><span class="anim-btn__icon">`+a+`</span><span class="anim-btn__label">`+o+`</span></button>`}).join(``),e.querySelectorAll(`.anim-btn:not([disabled])`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.anim;this.animationManager.crossfadeTo(t),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop()})})}clear(){this.content&&(this.animationManager.detach(),this._animPanelEl&&=(this._animPanelEl.remove(),null),this.modelInfo&&=(this.modelInfo.remove(),null),this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[],this.scene.remove(this.content),this.content.traverse(e=>{e.geometry&&e.geometry.dispose()}),a_(this.content,e=>{for(let t in e)t!==`envMap`&&e[t]&&e[t].isTexture&&e[t].dispose()}),this.content=null,this._disposed||this.invalidate())}dispose(){if(!this._disposed){if(this._disposed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),document.removeEventListener(`visibilitychange`,this._onVisibilityChange),window.removeEventListener(`resize`,this._onResize,!1),window.removeEventListener(`keydown`,this._onKeyDown),this._intersectionObserver&&=(this._intersectionObserver.disconnect(),null),this.clear(),this.mixer){this.mixer.stopAllAction();let e=this.mixer.getRoot();e&&this.mixer.uncacheRoot(e),this.mixer=null}this.clips=[],this.animationManager.dispose(),this._animPanelEl&&=(this._animPanelEl.remove(),null),this.skeletonHelpers.length&&(this.skeletonHelpers.forEach(e=>{this.scene.remove(e),e.dispose?.()}),this.skeletonHelpers.length=0),this.gridHelper&&=(this.scene.remove(this.gridHelper),this.gridHelper.geometry?.dispose(),this.gridHelper.material?.dispose(),null),this.axesHelper&&=(this.scene.remove(this.axesHelper),this.axesHelper.geometry?.dispose(),this.axesHelper.material?.dispose(),null),this.axesCorner&&=(this.axesScene?.remove(this.axesCorner),this.axesCorner.geometry?.dispose(),this.axesCorner.material?.dispose(),null),this.lights.forEach(e=>e.parent?.remove(e)),this.lights=[],this.annotationEls.length&&(this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[]),this.modelInfo&&=(this.modelInfo.remove(),null),this.gui&&=(this.gui.destroy(),null),this._guiWrap&&=(this._guiWrap.remove(),null),this.stats?.dom&&this.stats.dom.remove(),this.controls?.dispose(),this.controls=null,this._loadedEnvironment&&=(this._loadedEnvironment.dispose(),null),this.neutralEnvironment&&=(this.neutralEnvironment.dispose(),null),this.scene&&(this.scene.environment=null,this.scene.background=null),this.pmremGenerator&&=(this.pmremGenerator.dispose(),null),this.axesRenderer&&=(this.axesRenderer.dispose(),this.axesRenderer.forceContextLoss?.(),this.axesRenderer.domElement?.remove(),null),this.axesDiv&&=(this.axesDiv.remove(),null),this.axesScene=null,this.axesCamera=null,this.renderer&&=(this.renderer.dispose(),this.renderer.forceContextLoss?.(),this.renderer.domElement?.remove(),window.renderer===this.renderer&&(window.renderer=null),null),this.scene=null,this.content=null,this.activeCamera=null,this.defaultCamera=null,this._afterAnimateHooks=null}}},Y_=class{constructor({model:e=`claude-opus-4-6`,proxyURL:t,apiKey:n,temperature:r=.7,maxTokens:i=4096,thinking:a=`auto`}={}){this.model=e,this.proxyURL=t,this.apiKey=n,this.temperature=r,this.maxTokens=i,this.thinking=a}async complete({system:e,messages:t,tools:n}){let r={model:this.model,max_tokens:this.maxTokens,temperature:this.temperature,system:e,messages:t};n&&n.length&&(r.tools=n),this.thinking===`always`&&(r.thinking={type:`enabled`,budget_tokens:2048});let i=this.proxyURL||`https://api.anthropic.com/v1/messages`,a={"content-type":`application/json`};this.apiKey&&(a[`x-api-key`]=this.apiKey,a[`anthropic-version`]=`2023-06-01`,a[`anthropic-dangerous-direct-browser-access`]=`true`);let o=await fetch(i,{method:`POST`,headers:a,body:JSON.stringify(r)});if(!o.ok){let e=await o.text();throw Error(`Anthropic ${o.status}: ${e}`)}let s=await o.json();return this._normalize(s)}_normalize(e){let t={text:``,toolCalls:[],thinking:``,stopReason:e.stop_reason};for(let n of e.content||[])n.type===`text`?t.text+=n.text:n.type===`thinking`?t.thinking+=n.thinking||``:n.type===`tool_use`&&t.toolCalls.push({id:n.id,name:n.name,input:n.input});return t}formatToolResults(e){return{role:`user`,content:e.map(e=>({type:`tool_result`,tool_use_id:e.id,content:typeof e.output==`string`?e.output:JSON.stringify(e.output),is_error:!!e.isError}))}}formatAssistantWithToolCalls(e,t){let n=[];e&&n.push({type:`text`,text:e});for(let e of t)n.push({type:`tool_use`,id:e.id,name:e.name,input:e.input});return{role:`assistant`,content:n}}},X_=class{async complete(){return{text:``,toolCalls:[],stopReason:`end_turn`}}formatToolResults(){return{role:`user`,content:[]}}formatAssistantWithToolCalls(e){return{role:`assistant`,content:e||``}}};function Z_(e={}){let t=e.provider||`anthropic`;if(t===`anthropic`)return new Y_(e);if(t===`none`)return new X_;throw Error(`Unsupported provider: ${t}. Supported: anthropic, none`)}var Q_=class{constructor({voiceId:e=`default`,rate:t=1,pitch:n=1,lang:r=`en-US`}={}){this.voiceId=e,this.rate=t,this.pitch=n,this.lang=r,this._queue=[],this._speaking=!1}async speak(e,{onStart:t,onEnd:n}={}){if(`speechSynthesis`in window)return new Promise(r=>{let i=new SpeechSynthesisUtterance(e);i.rate=this.rate,i.pitch=this.pitch,i.lang=this.lang;let a=this._pickVoice();a&&(i.voice=a),i.onstart=()=>{this._speaking=!0,t?.()},i.onend=()=>{this._speaking=!1,n?.(),r()},i.onerror=()=>{this._speaking=!1,r()},window.speechSynthesis.speak(i)})}cancel(){`speechSynthesis`in window&&window.speechSynthesis.cancel(),this._speaking=!1}get speaking(){return this._speaking}_pickVoice(){if(!(`speechSynthesis`in window))return null;let e=window.speechSynthesis.getVoices();if(this.voiceId&&this.voiceId!==`default`){let t=e.find(e=>e.name===this.voiceId||e.voiceURI===this.voiceId);if(t)return t}return e.find(e=>e.lang?.startsWith(this.lang.slice(0,2)))||null}},$_=class{constructor({language:e=`en-US`,continuous:t=!1,interimResults:n=!0}={}){this.language=e,this.continuous=t,this.interimResults=n,this._recognition=null,this._listening=!1}_ensure(){if(this._recognition)return this._recognition;let e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return null;let t=new e;return t.lang=this.language,t.continuous=this.continuous,t.interimResults=this.interimResults,this._recognition=t,t}async listen({onInterim:e,onFinal:t}={}){let n=this._ensure();if(!n)throw Error(`SpeechRecognition unavailable in this browser`);return new Promise((r,i)=>{let a=``;n.onresult=n=>{for(let r=n.resultIndex;r<n.results.length;r++){let i=n.results[r],o=i[0].transcript;i.isFinal?(a+=o,t?.(o)):e?.(o)}},n.onerror=e=>{this._listening=!1,i(e.error)},n.onend=()=>{this._listening=!1,r(a.trim())},this._listening=!0;try{n.start()}catch(e){this._listening=!1,i(e)}})}stop(){this._recognition&&this._listening&&this._recognition.stop()}get listening(){return this._listening}};function ev(e={}){let t=e.provider||`browser`;if(t===`none`)return null;if(t===`browser`)return new Q_(e);throw Error(`TTS provider "${t}" not implemented yet`)}function tv(e={}){let t=e.provider||`browser`;if(t===`none`)return null;if(t===`browser`)return new $_(e);throw Error(`STT provider "${t}" not implemented yet`)}var nv=[{name:`wave`,description:`Wave at the user. Use for greetings, farewells, or acknowledgments.`,input_schema:{type:`object`,properties:{duration_ms:{type:`integer`,minimum:500,maximum:5e3,default:1500}}}},{name:`lookAt`,description:`Direct the agent's gaze toward a target.`,input_schema:{type:`object`,properties:{target:{type:`string`,enum:[`user`,`camera`,`center`],description:`Where to look`}},required:[`target`]}},{name:`play_clip`,description:`Play a named animation clip from the loaded body.`,input_schema:{type:`object`,properties:{name:{type:`string`},loop:{type:`boolean`,default:!1},fade_ms:{type:`integer`,default:200}},required:[`name`]}},{name:`setExpression`,description:`Set facial expression via morph target preset.`,input_schema:{type:`object`,properties:{preset:{type:`string`,enum:[`neutral`,`happy`,`sad`,`surprised`,`confused`,`focused`]},intensity:{type:`number`,minimum:0,maximum:1,default:1}},required:[`preset`]}},{name:`speak`,description:`Say something out loud via TTS. Use this instead of plain text when voice is on.`,input_schema:{type:`object`,properties:{text:{type:`string`}},required:[`text`]}},{name:`remember`,description:`Save a durable memory about the user, a feedback rule, a project fact, or a reference.`,input_schema:{type:`object`,properties:{key:{type:`string`,description:`short snake_case filename, e.g. "user_role"`},name:{type:`string`},description:{type:`string`},type:{type:`string`,enum:[`user`,`feedback`,`project`,`reference`]},body:{type:`string`}},required:[`key`,`name`,`description`,`type`,`body`]}}],rv={async wave(e,t){let n=e.duration_ms||1500;return await t.viewer.playAnimationByHint?.(`wave`,{duration:n}),t.memory.note(`waved`,{duration_ms:n}),{ok:!0}},async lookAt(e,t){let n=e.target||`user`;return t.viewer.lookAt?.(n),{ok:!0,target:n}},async play_clip(e,t){let{name:n,loop:r=!1,fade_ms:i=200}=e;return t.viewer.playClipByName?.(n,{loop:r,fade_ms:i})?{ok:!0,name:n}:{ok:!1,error:`No clip named "${n}"`}},async setExpression(e,t){let{preset:n,intensity:r=1}=e;return t.viewer.setExpression?.(n,r),{ok:!0,preset:n}},async speak(e,t){return await t.speak(e.text),{ok:!0}},async remember(e,t){let{key:n,name:r,description:i,type:a,body:o}=e;return t.memory.write(n,{name:r,description:i,type:a,body:o}),{ok:!0,saved:n}}},iv=8,av=class extends EventTarget{constructor({manifest:e,viewer:t,memory:n,skills:r,providerConfig:i={},voiceConfig:a={}}={}){super(),this.manifest=e||{},this.viewer=t,this.memory=n,this.skills=r,this.provider=Z_({...this.manifest.brain,...i}),this.tts=ev({...this.manifest.voice?.tts,...a.tts}),this.stt=tv({...this.manifest.voice?.stt,...a.stt}),this.messages=[],this._busy=!1}get systemPrompt(){let e=[];return this.manifest.instructions&&e.push(this.manifest.instructions),this.memory&&e.push(`
+`);this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=n,this.workerPool.setWorkerCreator(()=>{let e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:`init`,config:this.workerConfig,transcoderBinary:t},[t]),e})}),Gg>0&&console.warn(`THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances.`),Gg++}return this.transcoderPending}load(e,t,n,r){if(this.workerConfig===null)throw Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");let i=new fo(this.manager);i.setResponseType(`arraybuffer`),i.setWithCredentials(this.withCredentials),i.load(e,e=>{this.parse(e,t,r)},n,r)}parse(e,t,n){if(this.workerConfig===null)throw Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Wg.has(e))return Wg.get(e).promise.then(t).catch(n);this._createTexture(e).then(e=>t?t(e):null).catch(n)}_createTextureFrom(e,t){let{type:n,error:r,data:{faces:i,width:a,height:o,format:s,type:c,dfdFlags:l}}=e;if(n===`error`)return Promise.reject(r);let u;if(t.faceCount===6)u=new Ma(i,s,c);else{let e=i[0].mipmaps;u=t.layerCount>1?new ja(e,a,o,t.layerCount,s,c):new Aa(e,a,o,s,c)}return u.minFilter=i[0].mipmaps.length===1?f:m,u.magFilter=f,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=Qg(t),u.premultiplyAlpha=!!(l&1),u}async _createTexture(e,t={}){let n=Fg(new Uint8Array(e)),r=n.vkFormat===1000066e3&&n.dataFormatDescriptor[0].colorModel===167;if(!(n.vkFormat===0||r&&!this.workerConfig.astcHDRSupported))return Zg(n);let i=t,a=this.init().then(()=>this.workerPool.postMessage({type:`transcode`,buffer:e,taskConfig:i},[e])).then(e=>this._createTextureFrom(e.data,n));return Wg.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Gg--}};qg.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},qg.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},qg.EngineFormat={RGBAFormat:k,RGBA_ASTC_4x4_Format:_e,RGB_BPTC_UNSIGNED_Format:Oe,RGBA_BPTC_Format:F,RGBA_ETC2_EAC_Format:ge,RGBA_PVRTC_4BPPV1_Format:fe,RGBA_S3TC_DXT5_Format:le,RGB_ETC1_Format:me,RGB_ETC2_Format:he,RGB_PVRTC_4BPPV1_Format:ue,RGBA_S3TC_DXT1_Format:se},qg.EngineType={UnsignedByteType:h,HalfFloatType:S,FloatType:x},qg.BasisWorker=function(){let e,t,n,r=_EngineFormat,i=_EngineType,a=_TranscoderFormat,o=_BasisFormat;self.addEventListener(`message`,function(n){let r=n.data;switch(r.type){case`init`:e=r.config,s(r.transcoderBinary);break;case`transcode`:t.then(()=>{try{let{faces:e,buffers:t,width:n,height:i,hasAlpha:a,format:o,type:s,dfdFlags:l}=c(r.buffer);self.postMessage({type:`transcode`,id:r.id,data:{faces:e,width:n,height:i,hasAlpha:a,format:o,type:s,dfdFlags:l}},t)}catch(e){console.error(e),self.postMessage({type:`error`,id:r.id,error:e.message})}});break}});function s(e){t=new Promise(t=>{n={wasmBinary:e,onRuntimeInitialized:t},BASIS(n)}).then(()=>{n.initializeBasis(),n.KTX2File===void 0&&console.warn(`THREE.KTX2Loader: Please update Basis Universal transcoder.`)})}function c(e){let t=new n.KTX2File(new Uint8Array(e));function r(){t.close(),t.delete()}if(!t.isValid())throw r(),Error(`THREE.KTX2Loader: Invalid or unsupported .ktx2 file`);let a;if(t.isUASTC())a=o.UASTC;else if(t.isETC1S())a=o.ETC1S;else if(t.isHDR())a=o.UASTC_HDR;else throw Error(`THREE.KTX2Loader: Unknown Basis encoding`);let s=t.getWidth(),c=t.getHeight(),l=t.getLayers()||1,u=t.getLevels(),f=t.getFaces(),m=t.getHasAlpha(),h=t.getDFDFlags(),{transcoderFormat:g,engineFormat:_,engineType:v}=d(a,s,c,m);if(!s||!c||!u)throw r(),Error(`THREE.KTX2Loader: Invalid texture`);if(!t.startTranscoding())throw r(),Error(`THREE.KTX2Loader: .startTranscoding failed`);let y=[],b=[];for(let e=0;e<f;e++){let n=[];for(let a=0;a<u;a++){let o=[],s,c;for(let n=0;n<l;n++){let l=t.getImageLevelInfo(a,n,e);e===0&&a===0&&n===0&&(l.origWidth%4!=0||l.origHeight%4!=0)&&console.warn(`THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions.`),u>1?(s=l.origWidth,c=l.origHeight):(s=l.width,c=l.height);let d=new Uint8Array(t.getImageTranscodedSizeInBytes(a,n,0,g)),f=t.transcodeImage(d,a,n,e,g,0,-1,-1);if(v===i.HalfFloatType&&(d=new Uint16Array(d.buffer,d.byteOffset,d.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!f)throw r(),Error(`THREE.KTX2Loader: .transcodeImage failed.`);o.push(d)}let d=p(o);n.push({data:d,width:s,height:c}),b.push(d.buffer)}y.push({mipmaps:n,width:s,height:c,format:_,type:v})}return r(),{faces:y,buffers:b,width:s,height:c,hasAlpha:m,dfdFlags:h,format:_,type:v}}let l=[{if:`astcSupported`,basisFormat:[o.UASTC],transcoderFormat:[a.ASTC_4x4,a.ASTC_4x4],engineFormat:[r.RGBA_ASTC_4x4_Format,r.RGBA_ASTC_4x4_Format],engineType:[i.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:`bptcSupported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.BC7_M5,a.BC7_M5],engineFormat:[r.RGBA_BPTC_Format,r.RGBA_BPTC_Format],engineType:[i.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:`dxtSupported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.BC1,a.BC3],engineFormat:[r.RGBA_S3TC_DXT1_Format,r.RGBA_S3TC_DXT5_Format],engineType:[i.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:`etc2Supported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.ETC1,a.ETC2],engineFormat:[r.RGB_ETC2_Format,r.RGBA_ETC2_EAC_Format],engineType:[i.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:`etc1Supported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.ETC1],engineFormat:[r.RGB_ETC1_Format],engineType:[i.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:`pvrtcSupported`,basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.PVRTC1_4_RGB,a.PVRTC1_4_RGBA],engineFormat:[r.RGB_PVRTC_4BPPV1_Format,r.RGBA_PVRTC_4BPPV1_Format],engineType:[i.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:`bptcSupported`,basisFormat:[o.UASTC_HDR],transcoderFormat:[a.BC6H],engineFormat:[r.RGB_BPTC_UNSIGNED_Format],engineType:[i.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[a.RGBA32,a.RGBA32],engineFormat:[r.RGBAFormat,r.RGBAFormat],engineType:[i.UnsignedByteType,i.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[a.RGBA_HALF],engineFormat:[r.RGBAFormat],engineType:[i.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],u={[o.ETC1S]:l.filter(e=>e.basisFormat.includes(o.ETC1S)).sort((e,t)=>e.priorityUASTC-t.priorityUASTC),[o.UASTC]:l.filter(e=>e.basisFormat.includes(o.UASTC)).sort((e,t)=>e.priorityUASTC-t.priorityUASTC),[o.UASTC_HDR]:l.filter(e=>e.basisFormat.includes(o.UASTC_HDR)).sort((e,t)=>e.priorityHDR-t.priorityHDR)};function d(t,n,r,i){let a=u[t];for(let o=0;o<a.length;o++){let s=a[o];if(!(s.if&&!e[s.if])&&s.basisFormat.includes(t)&&!(i&&s.transcoderFormat.length<2)&&!(s.needsPowerOfTwo&&!(f(n)&&f(r))))return{transcoderFormat:s.transcoderFormat[+!!i],engineFormat:s.engineFormat[+!!i],engineType:s.engineType[0]}}throw Error(`THREE.KTX2Loader: Failed to identify transcoding target.`)}function f(e){return e<=2?!0:(e&e-1)==0&&e!==0}function p(e){if(e.length===1)return e[0];let t=0;for(let n=0;n<e.length;n++){let r=e[n];t+=r.byteLength}let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.byteLength}return n}};var Jg=new Set([k,A,ne]),Yg={109:k,97:k,37:k,43:k,103:A,83:A,16:A,22:A,100:ne,76:ne,15:ne,9:ne,[Ag]:_e,166:j,165:j},Xg={109:x,97:S,37:h,43:h,103:x,83:S,16:h,22:h,100:x,76:S,15:h,9:h,[Ag]:S,166:h,165:h};async function Zg(e){let{vkFormat:t}=e;if(Yg[t]===void 0)throw Error(`THREE.KTX2Loader: Unsupported vkFormat.`);let n;e.supercompressionScheme===2&&(Kg||=new Promise(async e=>{let t=new Bg;await t.init(),e(t)}),n=await Kg);let r=[];for(let i=0;i<e.levels.length;i++){let a=Math.max(1,e.pixelWidth>>i),o=Math.max(1,e.pixelHeight>>i),s=e.pixelDepth?Math.max(1,e.pixelDepth>>i):0,c=e.levels[i],l;if(e.supercompressionScheme===0)l=c.levelData;else if(e.supercompressionScheme===2)l=n.decode(c.levelData,c.uncompressedByteLength);else throw Error(`THREE.KTX2Loader: Unsupported supercompressionScheme.`);let u;u=Xg[t]===1015?new Float32Array(l.buffer,l.byteOffset,l.byteLength/Float32Array.BYTES_PER_ELEMENT):Xg[t]===1016?new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT):l,r.push({data:u,width:a,height:o,depth:s})}let i;if(Jg.has(Yg[t]))i=e.pixelDepth===0?new Ui(r[0].data,e.pixelWidth,e.pixelHeight):new $t(r[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth);else{if(e.pixelDepth>0)throw Error(`THREE.KTX2Loader: Unsupported pixelDepth.`);i=new Aa(r,e.pixelWidth,e.pixelHeight),i.minFilter=r.length===1?f:m,i.magFilter=f}return i.mipmaps=r,i.type=Xg[t],i.format=Yg[t],i.colorSpace=Qg(e),i.needsUpdate=!0,Promise.resolve(i)}function Qg(e){let t=e.dataFormatDescriptor[0];return t.colorPrimaries===1?t.transferFunction===2?Ke:qe:t.colorPrimaries===10?t.transferFunction===2?Hg:Ug:(t.colorPrimaries===0||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),``)}var $g=`[default]`,e_={ASSET_GENERATOR:`assetgenerator`},t_=new oo,n_=`https://unpkg.com/[email protected]`,r_=new Dg(t_).setDecoderPath(`${n_}/examples/jsm/libs/draco/gltf/`),i_=new qg(t_).setTranscoderPath(`${n_}/examples/jsm/libs/basis/`);function a_(e,t){let n=new Set;e.traverse(e=>{e.geometry&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>{e&&!n.has(e.uuid)&&(n.add(e.uuid),t(e))})})}function o_(e){let{state:t,options:n}=e;if(n.preset===e_.ASSET_GENERATOR){let t=new _o;t.name=`hemi_light`,e.scene.add(t),e.lights.push(t);return}let r=new Mo(t.ambientColor,t.ambientIntensity);r.name=`ambient_light`,e.defaultCamera.add(r);let i=new jo(t.directColor,t.directIntensity);i.position.set(.5,0,.866),i.name=`main_light`,e.defaultCamera.add(i),e.lights.push(r,i)}function s_(e){e.lights.forEach(e=>e.parent.remove(e)),e.lights.length=0}var c_=Uint8Array,l_=Uint16Array,u_=Int32Array,d_=new c_([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),f_=new c_([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),p_=new c_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),m_=function(e,t){for(var n=new l_(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new u_(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},h_=m_(d_,2),g_=h_.b,__=h_.r;g_[28]=258,__[258]=28;var v_=m_(f_,0),y_=v_.b;v_.r;for(var b_=new l_(32768),x_=0;x_<32768;++x_){var S_=(x_&43690)>>1|(x_&21845)<<1;S_=(S_&52428)>>2|(S_&13107)<<2,S_=(S_&61680)>>4|(S_&3855)<<4,b_[x_]=((S_&65280)>>8|(S_&255)<<8)>>1}for(var C_=(function(e,t,n){for(var r=e.length,i=0,a=new l_(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new l_(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new l_(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[b_[d]>>c]=l}else for(s=new l_(r),i=0;i<r;++i)e[i]&&(s[i]=b_[o[e[i]-1]++]>>15-e[i]);return s}),w_=new c_(288),x_=0;x_<144;++x_)w_[x_]=8;for(var x_=144;x_<256;++x_)w_[x_]=9;for(var x_=256;x_<280;++x_)w_[x_]=7;for(var x_=280;x_<288;++x_)w_[x_]=8;for(var T_=new c_(32),x_=0;x_<32;++x_)T_[x_]=5;var E_=C_(w_,9,1),D_=C_(T_,5,1),O_=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},k_=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},A_=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},j_=function(e){return(e+7)/8|0},M_=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new c_(e.subarray(t,n))},N_=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],P_=function(e,t,n){var r=Error(t||N_[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,P_),!n)throw r;return r},F_=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new c_(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new c_(i*3));var l=function(e){var t=n.length;if(e>t){var r=new c_(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=k_(e,d,1);var v=k_(e,d+1,3);if(d+=3,!v){var y=j_(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&P_(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=E_,m=D_,h=9,g=5;else if(v==2){var S=k_(e,d,31)+257,C=k_(e,d+10,15)+4,w=S+k_(e,d+5,31)+1;d+=14;for(var T=new c_(w),E=new c_(19),D=0;D<C;++D)E[p_[D]]=k_(e,d+D*3,7);d+=C*3;for(var O=O_(E),k=(1<<O)-1,ee=C_(E,O,1),D=0;D<w;){var te=ee[k_(e,d,k)];d+=te&15;var y=te>>4;if(y<16)T[D++]=y;else{var ne=0,re=0;for(y==16?(re=3+k_(e,d,3),d+=2,ne=T[D-1]):y==17?(re=3+k_(e,d,7),d+=3):y==18&&(re=11+k_(e,d,127),d+=7);re--;)T[D++]=ne}}var A=T.subarray(0,S),ie=T.subarray(S);h=O_(A),g=O_(ie),p=C_(A,h,1),m=C_(ie,g,1)}else P_(1);if(d>_){c&&P_(0);break}}s&&l(f+131072);for(var ae=(1<<h)-1,oe=(1<<g)-1,se=d;;se=d){var ne=p[A_(e,d)&ae],ce=ne>>4;if(d+=ne&15,d>_){c&&P_(0);break}if(ne||P_(2),ce<256)n[f++]=ce;else if(ce==256){se=d,p=null;break}else{var le=ce-254;if(ce>264){var D=ce-257,ue=d_[D];le=k_(e,d,(1<<ue)-1)+g_[D],d+=ue}var de=m[A_(e,d)&oe],fe=de>>4;de||P_(3),d+=de&15;var ie=y_[fe];if(fe>3){var ue=f_[fe];ie+=A_(e,d)&(1<<ue)-1,d+=ue}if(d>_){c&&P_(0);break}s&&l(f+131072);var pe=f+le;if(f<ie){var me=a-ie,he=Math.min(ie,pe);for(me+f<0&&P_(3);f<he;++f)n[f]=r[me+f]}for(;f<pe;++f)n[f]=n[f-ie]}}t.l=p,t.p=se,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?M_(n,0,f):n.subarray(0,f)},I_=new c_(0),L_=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&P_(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&P_(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function R_(e,t){return F_(e.subarray(L_(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var z_=typeof TextDecoder<`u`&&new TextDecoder;try{z_.decode(I_,{stream:!0})}catch{}var B_=class extends mo{constructor(e){super(e),this.type=S}parse(e){let t=65536,n=t>>3,r=65537,i=16384,a=i-1,o=65535,s=2.7182818**2.2;function c(e,n){let r=0;for(let i=0;i<t;++i)(i==0||e[i>>3]&1<<(i&7))&&(n[r++]=i);let i=r-1;for(;r<t;)n[r++]=0;return i}function l(e){for(let t=0;t<i;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}let u={l:0,c:0,lc:0};function d(e,t,n,r,i){for(;n<e;)t=t<<8|we(r,i),n+=8;n-=e,u.l=t>>n&(1<<e)-1,u.c=t,u.lc=n}let f=Array(59);function p(e){for(let e=0;e<=58;++e)f[e]=0;for(let t=0;t<r;++t)f[e[t]]+=1;let t=0;for(let e=58;e>0;--e){let n=t+f[e]>>1;f[e]=t,t=n}for(let t=0;t<r;++t){let n=e[t];n>0&&(e[t]=n|f[n]++<<6)}}function m(e,t,n,r,i,a){let o=t,s=0,c=0;for(;r<=i;r++){if(o.value-t.value>n)return!1;d(6,s,c,e,o);let l=u.l;if(s=u.c,c=u.lc,a[r]=l,l==63){if(o.value-t.value>n)throw Error(`Something wrong with hufUnpackEncTable`);d(8,s,c,e,o);let l=u.l+6;if(s=u.c,c=u.lc,r+l>i+1)throw Error(`Something wrong with hufUnpackEncTable`);for(;l--;)a[r++]=0;r--}else if(l>=59){let e=l-59+2;if(r+e>i+1)throw Error(`Something wrong with hufUnpackEncTable`);for(;e--;)a[r++]=0;r--}}p(a)}function h(e){return e&63}function g(e){return e>>6}function _(e,t,n,r){for(;t<=n;t++){let n=g(e[t]),i=h(e[t]);if(n>>i)throw Error(`Invalid table entry`);if(i>14){let e=r[n>>i-14];if(e.len)throw Error(`Invalid table entry`);if(e.lit++,e.p){let t=e.p;e.p=Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=[,];e.p[e.lit-1]=t}else if(i){let e=0;for(let a=1<<14-i;a>0;a--){let a=r[(n<<14-i)+e];if(a.len||a.p)throw Error(`Invalid table entry`);a.len=i,a.lit=t,e++}}}return!0}let v={c:0,lc:0};function y(e,t,n,r){e=e<<8|we(n,r),t+=8,v.c=e,v.lc=t}let b={c:0,lc:0};function C(e,t,n,r,i,a,o,s,c){if(e==t){r<8&&(y(n,r,i,a),n=v.c,r=v.lc),r-=8;let e=n>>r;if(e=new Uint8Array([e])[0],s.value+e>c)return!1;let t=o[s.value-1];for(;e-- >0;)o[s.value++]=t}else if(s.value<c)o[s.value++]=e;else return!1;b.c=n,b.lc=r}function w(e){return e&65535}function T(e){let t=w(e);return t>32767?t-65536:t}let E={a:0,b:0};function D(e,t){let n=T(e),r=T(t),i=n+(r&1)+(r>>1),a=i,o=i-r;E.a=a,E.b=o}function O(e,t){let n=w(e),r=w(t),i=n-(r>>1)&o;E.a=r+i-32768&o,E.b=i}function ee(e,t,n,r,i,a,o){let s=o<16384,c=n>i?i:n,l=1,u,d;for(;l<=c;)l<<=1;for(l>>=1,u=l,l>>=1;l>=1;){d=0;let o=d+a*(i-u),c=a*l,f=a*u,p=r*l,m=r*u,h,g,_,v;for(;d<=o;d+=f){let i=d,a=d+r*(n-u);for(;i<=a;i+=m){let n=i+p,r=i+c,a=r+p;s?(D(e[i+t],e[r+t]),h=E.a,_=E.b,D(e[n+t],e[a+t]),g=E.a,v=E.b,D(h,g),e[i+t]=E.a,e[n+t]=E.b,D(_,v),e[r+t]=E.a,e[a+t]=E.b):(O(e[i+t],e[r+t]),h=E.a,_=E.b,O(e[n+t],e[a+t]),g=E.a,v=E.b,O(h,g),e[i+t]=E.a,e[n+t]=E.b,O(_,v),e[r+t]=E.a,e[a+t]=E.b)}if(n&l){let n=i+c;s?D(e[i+t],e[n+t]):O(e[i+t],e[n+t]),h=E.a,e[n+t]=E.b,e[i+t]=h}}if(i&l){let i=d,a=d+r*(n-u);for(;i<=a;i+=m){let n=i+p;s?D(e[i+t],e[n+t]):O(e[i+t],e[n+t]),h=E.a,e[n+t]=E.b,e[i+t]=h}}u=l,l>>=1}return d}function te(e,t,n,r,i,o,s,c,l){let u=0,d=0,f=s,p=Math.trunc(r.value+(i+7)/8);for(;r.value<p;)for(y(u,d,n,r),u=v.c,d=v.lc;d>=14;){let i=t[u>>d-14&a];if(i.len)d-=i.len,C(i.lit,o,u,d,n,r,c,l,f),u=b.c,d=b.lc;else{if(!i.p)throw Error(`hufDecode issues`);let t;for(t=0;t<i.lit;t++){let a=h(e[i.p[t]]);for(;d<a&&r.value<p;)y(u,d,n,r),u=v.c,d=v.lc;if(d>=a&&g(e[i.p[t]])==(u>>d-a&(1<<a)-1)){d-=a,C(i.p[t],o,u,d,n,r,c,l,f),u=b.c,d=b.lc;break}}if(t==i.lit)throw Error(`hufDecode issues`)}}let m=8-i&7;for(u>>=m,d-=m;d>0;){let e=t[u<<14-d&a];if(e.len)d-=e.len,C(e.lit,o,u,d,n,r,c,l,f),u=b.c,d=b.lc;else throw Error(`hufDecode issues`)}return!0}function re(e,t,n,a,o,s){let c={value:0},u=n.value,d=M(t,n),f=M(t,n);n.value+=4;let p=M(t,n);if(n.value+=4,d<0||d>=r||f<0||f>=r)throw Error(`Something wrong with HUF_ENCSIZE`);let h=Array(r),g=Array(i);if(l(g),m(e,n,a-(n.value-u),d,f,h),p>8*(a-(n.value-u)))throw Error(`Something wrong with hufUncompress`);_(h,d,f,g),te(h,g,e,n,p,f,s,o,c)}function A(e,t,n){for(let r=0;r<n;++r)t[r]=e[t[r]]}function ie(e){for(let t=1;t<e.length;t++)e[t]=e[t-1]+e[t]-128}function ae(e,t){let n=0,r=Math.floor((e.length+1)/2),i=0,a=e.length-1;for(;!(i>a||(t[i++]=e[n++],i>a));)t[i++]=e[r++]}function oe(e){let t=e.byteLength,n=[],r=0,i=new DataView(e);for(;t>0;){let e=i.getInt8(r++);if(e<0){let a=-e;t-=a+1;for(let e=0;e<a;e++)n.push(i.getUint8(r++))}else{let a=e;t-=2;let o=i.getUint8(r++);for(let e=0;e<a+1;e++)n.push(o)}}return n}function se(e,t,n,r,i,a){let o=new DataView(a.buffer),s=n[e.idx[0]].width,c=n[e.idx[0]].height,l=Math.floor(s/8),u=Math.ceil(s/8),d=Math.ceil(c/8),f=s-(u-1)*8,p=c-(d-1)*8,m={value:0},h=[,,,],g=[,,,],_=[,,,],v=[,,,],y=[,,,];for(let n=0;n<3;++n)y[n]=t[e.idx[n]],h[n]=n<1?0:h[n-1]+u*d,g[n]=new Float32Array(64),_[n]=new Uint16Array(64),v[n]=new Uint16Array(u*64);for(let t=0;t<d;++t){let a=8;t==d-1&&(a=p);let s=8;for(let e=0;e<u;++e){e==u-1&&(s=f);for(let e=0;e<3;++e)_[e].fill(0),_[e][0]=i[h[e]++],ce(m,r,_[e]),le(_[e],g[e]),ue(g[e]);de(g);for(let t=0;t<3;++t)fe(g[t],v[t],e*64)}let c=0;for(let r=0;r<3;++r){let i=n[e.idx[r]].type;for(let e=8*t;e<8*t+a;++e){c=y[r][e];for(let t=0;t<l;++t){let n=t*64+(e&7)*8;o.setUint16(c+0*i,v[r][n+0],!0),o.setUint16(c+2*i,v[r][n+1],!0),o.setUint16(c+4*i,v[r][n+2],!0),o.setUint16(c+6*i,v[r][n+3],!0),o.setUint16(c+8*i,v[r][n+4],!0),o.setUint16(c+10*i,v[r][n+5],!0),o.setUint16(c+12*i,v[r][n+6],!0),o.setUint16(c+14*i,v[r][n+7],!0),c+=16*i}}if(l!=u)for(let e=8*t;e<8*t+a;++e){let t=y[r][e]+8*l*2*i,n=l*64+(e&7)*8;for(let e=0;e<s;++e)o.setUint16(t+e*2*i,v[r][n+e],!0)}}}let b=new Uint16Array(s);o=new DataView(a.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;let r=n[e.idx[t]].type;if(n[t].type==2)for(let e=0;e<c;++e){let n=y[t][e];for(let e=0;e<s;++e)b[e]=o.getUint16(n+e*2*r,!0);for(let e=0;e<s;++e)o.setFloat32(n+e*2*r,F(b[e]),!0)}}}function ce(e,t,n){let r,i=1;for(;i<64;)r=t[e.value],r==65280?i=64:r>>8==255?i+=r&255:(n[i]=r,i++),e.value++}function le(e,t){t[0]=F(e[0]),t[1]=F(e[1]),t[2]=F(e[5]),t[3]=F(e[6]),t[4]=F(e[14]),t[5]=F(e[15]),t[6]=F(e[27]),t[7]=F(e[28]),t[8]=F(e[2]),t[9]=F(e[4]),t[10]=F(e[7]),t[11]=F(e[13]),t[12]=F(e[16]),t[13]=F(e[26]),t[14]=F(e[29]),t[15]=F(e[42]),t[16]=F(e[3]),t[17]=F(e[8]),t[18]=F(e[12]),t[19]=F(e[17]),t[20]=F(e[25]),t[21]=F(e[30]),t[22]=F(e[41]),t[23]=F(e[43]),t[24]=F(e[9]),t[25]=F(e[11]),t[26]=F(e[18]),t[27]=F(e[24]),t[28]=F(e[31]),t[29]=F(e[40]),t[30]=F(e[44]),t[31]=F(e[53]),t[32]=F(e[10]),t[33]=F(e[19]),t[34]=F(e[23]),t[35]=F(e[32]),t[36]=F(e[39]),t[37]=F(e[45]),t[38]=F(e[52]),t[39]=F(e[54]),t[40]=F(e[20]),t[41]=F(e[22]),t[42]=F(e[33]),t[43]=F(e[38]),t[44]=F(e[46]),t[45]=F(e[51]),t[46]=F(e[55]),t[47]=F(e[60]),t[48]=F(e[21]),t[49]=F(e[34]),t[50]=F(e[37]),t[51]=F(e[47]),t[52]=F(e[50]),t[53]=F(e[56]),t[54]=F(e[59]),t[55]=F(e[61]),t[56]=F(e[35]),t[57]=F(e[36]),t[58]=F(e[48]),t[59]=F(e[49]),t[60]=F(e[57]),t[61]=F(e[58]),t[62]=F(e[62]),t[63]=F(e[63])}function ue(e){let t=.5*Math.cos(3.14159/4),n=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(5*3.14159/16),o=.5*Math.cos(3*3.14159/8),s=.5*Math.cos(7*3.14159/16),c=[,,,,],l=[,,,,],u=[,,,,],d=[,,,,];for(let f=0;f<8;++f){let p=f*8;c[0]=r*e[p+2],c[1]=o*e[p+2],c[2]=r*e[p+6],c[3]=o*e[p+6],l[0]=n*e[p+1]+i*e[p+3]+a*e[p+5]+s*e[p+7],l[1]=i*e[p+1]-s*e[p+3]-n*e[p+5]-a*e[p+7],l[2]=a*e[p+1]-n*e[p+3]+s*e[p+5]+i*e[p+7],l[3]=s*e[p+1]-a*e[p+3]+i*e[p+5]-n*e[p+7],u[0]=t*(e[p+0]+e[p+4]),u[3]=t*(e[p+0]-e[p+4]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[p+0]=d[0]+l[0],e[p+1]=d[1]+l[1],e[p+2]=d[2]+l[2],e[p+3]=d[3]+l[3],e[p+4]=d[3]-l[3],e[p+5]=d[2]-l[2],e[p+6]=d[1]-l[1],e[p+7]=d[0]-l[0]}for(let f=0;f<8;++f)c[0]=r*e[16+f],c[1]=o*e[16+f],c[2]=r*e[48+f],c[3]=o*e[48+f],l[0]=n*e[8+f]+i*e[24+f]+a*e[40+f]+s*e[56+f],l[1]=i*e[8+f]-s*e[24+f]-n*e[40+f]-a*e[56+f],l[2]=a*e[8+f]-n*e[24+f]+s*e[40+f]+i*e[56+f],l[3]=s*e[8+f]-a*e[24+f]+i*e[40+f]-n*e[56+f],u[0]=t*(e[f]+e[32+f]),u[3]=t*(e[f]-e[32+f]),u[1]=c[0]+c[3],u[2]=c[1]-c[2],d[0]=u[0]+u[1],d[1]=u[3]+u[2],d[2]=u[3]-u[2],d[3]=u[0]-u[1],e[0+f]=d[0]+l[0],e[8+f]=d[1]+l[1],e[16+f]=d[2]+l[2],e[24+f]=d[3]+l[3],e[32+f]=d[3]-l[3],e[40+f]=d[2]-l[2],e[48+f]=d[1]-l[1],e[56+f]=d[0]-l[0]}function de(e){for(let t=0;t<64;++t){let n=e[0][t],r=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*r-.4682*i,e[2][t]=n+1.8556*r}}function fe(e,t,n){for(let r=0;r<64;++r)t[n+r]=Ar.toHalfFloat(pe(e[r]))}function pe(e){return e<=1?Math.sign(e)*Math.abs(e)**2.2:Math.sign(e)*s**(Math.abs(e)-1)}function me(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function he(e){let t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(oe(t)),r=new Uint8Array(n.length);return ie(n),ae(n,r),new DataView(r.buffer)}function ge(e){let t=R_(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return ie(t),ae(t,n),new DataView(n.buffer)}function _e(e){let r=e.viewer,i={value:e.offset.value},a=new Uint16Array(e.columns*e.lines*(e.inputChannels.length*e.type)),o=new Uint8Array(n),s=0,l=Array(e.inputChannels.length);for(let t=0,n=e.inputChannels.length;t<n;t++)l[t]={},l[t].start=s,l[t].end=l[t].start,l[t].nx=e.columns,l[t].ny=e.lines,l[t].size=e.type,s+=l[t].nx*l[t].ny*l[t].size;let u=De(r,i),d=De(r,i);if(d>=n)throw Error(`Something is wrong with PIZ_COMPRESSION BITMAP_SIZE`);if(u<=d)for(let e=0;e<d-u+1;e++)o[e+u]=N(r,i);let f=new Uint16Array(t),p=c(o,f),m=M(r,i);re(e.array,r,i,m,a,s);for(let t=0;t<e.inputChannels.length;++t){let e=l[t];for(let n=0;n<l[t].size;++n)ee(a,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,p)}A(f,a,s);let h=0,g=new Uint8Array(a.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.inputChannels.length;t++){let e=l[t],n=e.nx*e.size,r=new Uint8Array(a.buffer,e.end*2,n*2);g.set(r,h),h+=n*2,e.end+=n}return new DataView(g.buffer)}function ve(e){let t=R_(e.array.slice(e.offset.value,e.offset.value+e.size)),n=e.inputChannels.length*e.lines*e.columns*e.totalBytes,r=new ArrayBuffer(n),i=new DataView(r),a=0,o=0,s=[,,,,];for(let n=0;n<e.lines;n++)for(let n=0;n<e.inputChannels.length;n++){let r=0;switch(e.inputChannels[n].pixelType){case 1:s[0]=a,s[1]=s[0]+e.columns,a=s[1]+e.columns;for(let n=0;n<e.columns;++n){let e=t[s[0]++]<<8|t[s[1]++];r+=e,i.setUint16(o,r,!0),o+=2}break;case 2:s[0]=a,s[1]=s[0]+e.columns,s[2]=s[1]+e.columns,a=s[2]+e.columns;for(let n=0;n<e.columns;++n){let e=t[s[0]++]<<24|t[s[1]++]<<16|t[s[2]++]<<8;r+=e,i.setUint32(o,r,!0),o+=4}break}}return i}function ye(e){let t=e.viewer,n={value:e.offset.value},r=new Uint8Array(e.columns*e.lines*(e.inputChannels.length*e.type*2)),i={version:P(t,n),unknownUncompressedSize:P(t,n),unknownCompressedSize:P(t,n),acCompressedSize:P(t,n),dcCompressedSize:P(t,n),rleCompressedSize:P(t,n),rleUncompressedSize:P(t,n),rleRawSize:P(t,n),totalAcUncompressedCount:P(t,n),totalDcUncompressedCount:P(t,n),acCompression:P(t,n)};if(i.version<2)throw Error(`EXRLoader.parse: `+Xe.compression+` version `+i.version+` is unsupported`);let a=[],o=De(t,n)-2;for(;o>0;){let e=be(t.buffer,n),r=N(t,n),i=r>>2&3,s=(r>>4)-1,c=new Int8Array([s])[0],l=N(t,n);a.push({name:e,index:c,type:l,compression:i}),o-=e.length+3}let s=Xe.channels,c=Array(e.inputChannels.length);for(let t=0;t<e.inputChannels.length;++t){let n=c[t]={},r=s[t];n.name=r.name,n.compression=0,n.decoded=!1,n.type=r.pixelType,n.pLinear=r.pLinear,n.width=e.columns,n.height=e.lines}let l={idx:[,,,]};for(let t=0;t<e.inputChannels.length;++t){let e=c[t];for(let n=0;n<a.length;++n){let r=a[n];e.name==r.name&&(e.compression=r.compression,r.index>=0&&(l.idx[r.index]=t),e.offset=t)}}let u,d,f;if(i.acCompressedSize>0)switch(i.acCompression){case 0:u=new Uint16Array(i.totalAcUncompressedCount),re(e.array,t,n,i.acCompressedSize,u,i.totalAcUncompressedCount);break;case 1:let r=R_(e.array.slice(n.value,n.value+i.totalAcUncompressedCount));u=new Uint16Array(r.buffer),n.value+=i.totalAcUncompressedCount;break}if(i.dcCompressedSize>0){let t={array:e.array,offset:n,size:i.dcCompressedSize};d=new Uint16Array(ge(t).buffer),n.value+=i.dcCompressedSize}i.rleRawSize>0&&(f=oe(R_(e.array.slice(n.value,n.value+i.rleCompressedSize)).buffer),n.value+=i.rleCompressedSize);let p=0,m=Array(c.length);for(let e=0;e<m.length;++e)m[e]=[];for(let t=0;t<e.lines;++t)for(let t=0;t<c.length;++t)m[t].push(p),p+=c[t].width*e.type*2;se(l,m,c,u,d,r);for(let t=0;t<c.length;++t){let n=c[t];if(!n.decoded)switch(n.compression){case 2:let i=0,a=0;for(let o=0;o<e.lines;++o){let e=m[t][i];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)r[e++]=f[a+t*n.width*n.height];a++}i++}break;default:throw Error(`EXRLoader.parse: unsupported channel compression`)}}return new DataView(r.buffer)}function be(e,t){let n=new Uint8Array(e),r=0;for(;n[t.value+r]!=0;)r+=1;let i=new TextDecoder().decode(n.slice(t.value,t.value+r));return t.value=t.value+r+1,i}function j(e,t,n){let r=new TextDecoder().decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value+=n,r}function xe(e,t){return[Ce(e,t),M(e,t)]}function Se(e,t){return[M(e,t),M(e,t)]}function Ce(e,t){let n=e.getInt32(t.value,!0);return t.value+=4,n}function M(e,t){let n=e.getUint32(t.value,!0);return t.value+=4,n}function we(e,t){let n=e[t.value];return t.value+=1,n}function N(e,t){let n=e.getUint8(t.value);return t.value+=1,n}let P=function(e,t){let n;return n=`getBigInt64`in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,n};function Te(e,t){let n=e.getFloat32(t.value,!0);return t.value+=4,n}function Ee(e,t){return Ar.toHalfFloat(Te(e,t))}function F(e){let t=(e&31744)>>10,n=e&1023;return(e>>15?-1:1)*(t?t===31?n?NaN:1/0:2**(t-15)*(1+n/1024):n/1024*6103515625e-14)}function De(e,t){let n=e.getUint16(t.value,!0);return t.value+=2,n}function Oe(e,t){return F(De(e,t))}function ke(e,t,n,r){let i=n.value,a=[];for(;n.value<i+r-1;){let r=be(t,n),i=Ce(e,n),o=N(e,n);n.value+=3;let s=Ce(e,n),c=Ce(e,n);a.push({name:r,pixelType:i,pLinear:o,xSampling:s,ySampling:c})}return n.value+=1,a}function Ae(e,t){return{redX:Te(e,t),redY:Te(e,t),greenX:Te(e,t),greenY:Te(e,t),blueX:Te(e,t),blueY:Te(e,t),whiteX:Te(e,t),whiteY:Te(e,t)}}function je(e,t){return[`NO_COMPRESSION`,`RLE_COMPRESSION`,`ZIPS_COMPRESSION`,`ZIP_COMPRESSION`,`PIZ_COMPRESSION`,`PXR24_COMPRESSION`,`B44_COMPRESSION`,`B44A_COMPRESSION`,`DWAA_COMPRESSION`,`DWAB_COMPRESSION`][N(e,t)]}function Me(e,t){return{xMin:Ce(e,t),yMin:Ce(e,t),xMax:Ce(e,t),yMax:Ce(e,t)}}function Ne(e,t){return[`INCREASING_Y`,`DECREASING_Y`,`RANDOM_Y`][N(e,t)]}function Pe(e,t){return[`ENVMAP_LATLONG`,`ENVMAP_CUBE`][N(e,t)]}function Fe(e,t){let n=[`ONE_LEVEL`,`MIPMAP_LEVELS`,`RIPMAP_LEVELS`],r=[`ROUND_DOWN`,`ROUND_UP`],i=M(e,t),a=M(e,t),o=N(e,t);return{xSize:i,ySize:a,levelMode:n[o&15],roundingMode:r[o>>4]}}function Ie(e,t){return[Te(e,t),Te(e,t)]}function Le(e,t){return[Te(e,t),Te(e,t),Te(e,t)]}function Re(e,t,n,r,i){if(r===`string`||r===`stringvector`||r===`iccProfile`)return j(t,n,i);if(r===`chlist`)return ke(e,t,n,i);if(r===`chromaticities`)return Ae(e,n);if(r===`compression`)return je(e,n);if(r===`box2i`)return Me(e,n);if(r===`envmap`)return Pe(e,n);if(r===`tiledesc`)return Fe(e,n);if(r===`lineOrder`)return Ne(e,n);if(r===`float`)return Te(e,n);if(r===`v2f`)return Ie(e,n);if(r===`v3f`)return Le(e,n);if(r===`int`)return Ce(e,n);if(r===`rational`)return xe(e,n);if(r===`timecode`)return Se(e,n);if(r===`preview`)return n.value+=i,`skipped`;n.value+=i}function ze(e,t){let n=Math.log2(e);return t==`ROUND_DOWN`?Math.floor(n):Math.ceil(n)}function Be(e,t,n){let r=0;switch(e.levelMode){case`ONE_LEVEL`:r=1;break;case`MIPMAP_LEVELS`:r=ze(Math.max(t,n),e.roundingMode)+1;break;case`RIPMAP_LEVELS`:throw Error(`THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.`)}return r}function Ve(e,t,n,r){let i=Array(e);for(let a=0;a<e;a++){let e=1<<a,o=t/e|0;r==`ROUND_UP`&&o*e<t&&(o+=1),i[a]=(Math.max(o,1)+n-1)/n|0}return i}function He(){let e=this,t=e.offset,n={value:0};for(let r=0;r<e.tileCount;r++){let r=Ce(e.viewer,t),i=Ce(e.viewer,t);t.value+=8,e.size=M(e.viewer,t);let a=r*e.blockWidth,o=i*e.blockHeight;e.columns=a+e.blockWidth>e.width?e.width-a:e.blockWidth,e.lines=o+e.blockHeight>e.height?e.height-o:e.blockHeight;let s=e.columns*e.totalBytes,c=e.size<e.lines*s?e.uncompress(e):me(e);t.value+=e.size;for(let t=0;t<e.lines;t++){let r=t*e.columns*e.totalBytes;for(let i=0;i<e.inputChannels.length;i++){let s=Xe.channels[i].name,l=e.channelByteOffsets[s]*e.columns,u=e.decodeChannels[s];if(u===void 0)continue;n.value=r+l;let d=(e.height-(1+o+t))*e.outLineWidth;for(let t=0;t<e.columns;t++){let r=d+(t+a)*e.outputChannels+u;e.byteArray[r]=e.getter(c,n)}}}}}function Ue(){let e=this,t=e.offset,n={value:0};for(let r=0;r<e.height/e.blockHeight;r++){let i=Ce(e.viewer,t)-Xe.dataWindow.yMin;e.size=M(e.viewer,t),e.lines=i+e.blockHeight>e.height?e.height-i:e.blockHeight;let a=e.columns*e.totalBytes,o=e.size<e.lines*a?e.uncompress(e):me(e);t.value+=e.size;for(let t=0;t<e.blockHeight;t++){let i=r*e.blockHeight,s=t+e.scanOrder(i);if(s>=e.height)continue;let c=t*a,l=(e.height-1-s)*e.outLineWidth;for(let t=0;t<e.inputChannels.length;t++){let r=Xe.channels[t].name,i=e.channelByteOffsets[r]*e.columns,a=e.decodeChannels[r];if(a!==void 0){n.value=c+i;for(let t=0;t<e.columns;t++){let r=l+t*e.outputChannels+a;e.byteArray[r]=e.getter(o,n)}}}}}}function We(e,t,n){let r={};if(e.getUint32(0,!0)!=20000630)throw Error(`THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.`);r.version=e.getUint8(4);let i=e.getUint8(5);r.spec={singleTile:!!(i&2),longName:!!(i&4),deepFormat:!!(i&8),multiPart:!!(i&16)},n.value=8;let a=!0;for(;a;){let i=be(t,n);if(i===``)a=!1;else{let a=be(t,n),o=Re(e,t,n,a,M(e,n));o===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type \'${a}\'.`):r[i]=o}}if(i&-7)throw console.error(`THREE.EXRHeader:`,r),Error(`THREE.EXRLoader: Provided file is currently unsupported.`);return r}function Ge(e,t,n,r,i){let a={size:0,viewer:t,array:n,offset:r,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,inputChannels:e.channels,channelByteOffsets:{},scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:qe};switch(e.compression){case`NO_COMPRESSION`:a.blockHeight=1,a.uncompress=me;break;case`RLE_COMPRESSION`:a.blockHeight=1,a.uncompress=he;break;case`ZIPS_COMPRESSION`:a.blockHeight=1,a.uncompress=ge;break;case`ZIP_COMPRESSION`:a.blockHeight=16,a.uncompress=ge;break;case`PIZ_COMPRESSION`:a.blockHeight=32,a.uncompress=_e;break;case`PXR24_COMPRESSION`:a.blockHeight=16,a.uncompress=ve;break;case`DWAA_COMPRESSION`:a.blockHeight=32,a.uncompress=ye;break;case`DWAB_COMPRESSION`:a.blockHeight=256,a.uncompress=ye;break;default:throw Error(`EXRLoader.parse: `+e.compression+` is unsupported`)}let o={};for(let t of e.channels)switch(t.name){case`Y`:case`R`:case`G`:case`B`:case`A`:o[t.name]=!0,a.type=t.pixelType}let s=!1;if(o.R&&o.G&&o.B)s=!o.A,a.outputChannels=4,a.decodeChannels={R:0,G:1,B:2,A:3};else if(o.Y)a.outputChannels=1,a.decodeChannels={Y:0};else throw Error(`EXRLoader.parse: file contains unsupported data channels.`);if(a.type==1)switch(i){case x:a.getter=Oe;break;case S:a.getter=De;break}else if(a.type==2)switch(i){case x:a.getter=Te;break;case S:a.getter=Ee}else throw Error(`EXRLoader.parse: unsupported pixelType `+a.type+` for `+e.compression+`.`);a.columns=a.width;let c=a.width*a.height*a.outputChannels;switch(i){case x:a.byteArray=new Float32Array(c),s&&a.byteArray.fill(1,0,c);break;case S:a.byteArray=new Uint16Array(c),s&&a.byteArray.fill(15360,0,c);break;default:console.error(`THREE.EXRLoader: unsupported type: `,i);break}let l=0;for(let t of e.channels)a.decodeChannels[t.name]!==void 0&&(a.channelByteOffsets[t.name]=l),l+=t.pixelType*2;if(a.totalBytes=l,a.outLineWidth=a.width*a.outputChannels,e.lineOrder===`INCREASING_Y`?a.scanOrder=e=>e:a.scanOrder=e=>a.height-1-e,a.outputChannels==4?(a.format=k,a.colorSpace=qe):(a.format=ne,a.colorSpace=``),e.spec.singleTile){a.blockHeight=e.tiles.ySize,a.blockWidth=e.tiles.xSize;let n=Be(e.tiles,a.width,a.height),i=Ve(n,a.width,e.tiles.xSize,e.tiles.roundingMode),o=Ve(n,a.height,e.tiles.ySize,e.tiles.roundingMode);a.tileCount=i[0]*o[0];for(let e=0;e<n;e++)for(let n=0;n<o[e];n++)for(let n=0;n<i[e];n++)P(t,r);a.decode=He.bind(a)}else{a.blockWidth=a.width;let e=Math.ceil(a.height/a.blockHeight);for(let n=0;n<e;n++)P(t,r);a.decode=Ue.bind(a)}return a}let Ke={value:0},Je=new DataView(e),Ye=new Uint8Array(e),Xe=We(Je,e,Ke),Ze=Ge(Xe,Je,Ye,Ke,this.type);return Ze.decode(),{header:Xe,width:Ze.width,height:Ze.height,data:Ze.byteArray,format:Ze.format,colorSpace:Ze.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,r){function i(e,n){e.colorSpace=n.colorSpace,e.minFilter=f,e.magFilter=f,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,n)}return super.load(e,i,n,r)}};function V_(e,t){let{id:n,path:r}=t;return n===`neutral`?Promise.resolve({envMap:e.neutralEnvironment}):n===``?Promise.resolve({envMap:null}):new Promise((t,n)=>{new B_().load(r,n=>{let r=e.pmremGenerator.fromEquirectangular(n).texture;n.dispose(),e._loadedEnvironment&&e._loadedEnvironment!==r&&e._loadedEnvironment.dispose(),e._loadedEnvironment=r,t({envMap:r})},void 0,n)})}function H_(e){e.renderer.render(e.scene,e.activeCamera),e.renderer.domElement.toBlob(e=>{if(!e)return;let t=new Date().toISOString().replace(/[:.]/g,`-`).slice(0,19),n=URL.createObjectURL(e),r=document.createElement(`a`);r.download=`3d-screenshot-${t}.png`,r.href=n,r.click(),URL.revokeObjectURL(n)},`image/png`),U_(e)}function U_(e){let t=document.createElement(`div`);t.className=`screenshot-flash`,e.el.appendChild(t),t.addEventListener(`animationend`,()=>t.remove())}function W_(e,t){e.mixer&&=(e.mixer.stopAllAction(),e.mixer.uncacheRoot(e.mixer.getRoot()),null),e.clips=t,t.length&&(e.mixer=new Zo(e.content))}function G_(e){e.clips.forEach(t=>{e.mixer.clipAction(t).reset().play(),e.state.actionStates[t.name]=!0}),e.invalidate()}var K_=.35,q_=class{constructor(){this.model=null,this.mixer=null,this.clips=new Map,this.actions=new Map,this.currentName=null,this.currentAction=null,this.loader=new pu,this.onChange=null,this._gltfCache=new Map,this._animationDefs=[]}attach(e){this.detach(),this.model=e,this.mixer=new Zo(e),this.actions.clear(),this.currentAction=null,this.currentName=null;for(let[e,t]of this.clips){let n=this._retargetClip(t,e),r=this.mixer.clipAction(n);r.enabled=!0,this.actions.set(e,r)}}detach(){this.mixer&&=(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),null),this.model=null,this.actions.clear(),this.currentAction=null,this.currentName=null}setAnimationDefs(e){this._animationDefs=e}getAnimationDefs(){return this._animationDefs}async loadAnimation(e,t,n={}){if(this.clips.has(e))return this.clips.get(e);let r;this._gltfCache.has(t)?r=this._gltfCache.get(t):(r=await new Promise((e,n)=>{this.loader.load(t,e,void 0,n)}),this._gltfCache.set(t,r));let i;if(n.clipName?(i=r.animations.find(e=>e.name===n.clipName),i||=(console.warn(`[AnimationManager] Clip "${n.clipName}" not found in ${t}, using first clip`),r.animations[0])):i=r.animations[0],!i)throw Error(`No animation found in ${t}`);if(i=i.clone(),i.name=e,this.clips.set(e,i),this.model&&this.mixer){let t=this._retargetClip(i,e),r=this.mixer.clipAction(t);r.enabled=!0,r.setLoop(n.loop===!1?Ne:Pe),n.loop===!1&&(r.clampWhenFinished=!0),this.actions.set(e,r)}return i}async loadAll(){let e=this._animationDefs.map(async e=>{try{await this.loadAnimation(e.name,e.url,{loop:e.loop!==!1,clipName:e.clipName})}catch(t){console.warn(`[AnimationManager] Failed to load "${e.name}" from ${e.url}:`,t)}});await Promise.all(e)}play(e){let t=this.actions.get(e);if(!t){console.warn(`[AnimationManager] Animation "${e}" not loaded`);return}this.currentAction&&this.currentAction!==t&&this.currentAction.fadeOut(.01),t.reset().fadeIn(.01).play(),this.currentAction=t,this.currentName=e,this.onChange&&this.onChange(e)}crossfadeTo(e,t=K_){if(e===this.currentName)return;let n=this.actions.get(e);if(!n){console.warn(`[AnimationManager] Animation "${e}" not loaded`);return}n.reset(),n.play(),this.currentAction?this.currentAction.crossFadeTo(n,t,!0):n.fadeIn(t),this.currentAction=n,this.currentName=e,this.onChange&&this.onChange(e)}stopAll(){this.mixer&&this.mixer.stopAllAction(),this.currentAction=null,this.currentName=null,this.onChange&&this.onChange(null)}update(e){this.mixer&&this.mixer.update(e)}_retargetClip(e,t){if(!this.model)return e;let n=new Set;if(this.model.traverse(e=>{e.isBone&&n.add(e.name)}),n.size===0)return e;let r=new Set;for(let t of e.tracks){let e=t.name.split(`.`)[0];r.add(e)}let i=0;for(let e of r)n.has(e)&&i++;if(i/r.size>.5)return e;let a=this._buildBoneNameMap(n,r);return a?(e.tracks.map(e=>{let t=e.name.split(`.`),n=t[0],r=t.slice(1).join(`.`),i=a.get(n);if(!i)return null;let o=e.clone();return o.name=`${i}.${r}`,o}).filter(Boolean),e.clone().resetDuration()):e}_buildBoneNameMap(e,t){let n=new Map,r=[...e],i=[...t],a=e=>e.replace(/^mixamorig\d*[_:]?/i,``).replace(/^Armature[_/]?/i,``),o=new Map(r.map(e=>[a(e),e])),s=0;for(let e of i){let t=a(e);o.has(t)&&(n.set(e,o.get(t)),s++)}if(s/i.length>.5)return n;let c=new Map(r.map(e=>[e.toLowerCase(),e]));n.clear(),s=0;for(let e of i)c.has(e.toLowerCase())&&(n.set(e,c.get(e.toLowerCase())),s++);return s/i.length>.5?n:null}getLoadedNames(){return[...this.clips.keys()]}isLoaded(e){return this.clips.has(e)}dispose(){this.detach(),this.clips.clear(),this._gltfCache.clear(),this._animationDefs=[]}};ao.enabled=!0;var J_=class{constructor(e,t){this.el=e,this.options=t,this.lights=[],this.content=null,this.mixer=null,this.clips=[],this.gui=null,this.animationManager=new q_,this._animPanelEl=null,this.state={environment:t.preset===e_.ASSET_GENERATOR?rp.find(e=>e.id===`footprint-court`).name:rp[1].name,background:!1,playbackSpeed:1,actionStates:{},camera:$g,wireframe:!1,skeleton:!1,grid:!1,autoRotate:!1,punctualLights:!0,exposure:0,toneMapping:1,ambientIntensity:.3,ambientColor:`#FFFFFF`,directIntensity:.8*Math.PI,directColor:`#FFFFFF`,bgColor:`#000000`,transparentBg:!1,pointSize:1,showInfo:!0,showLabels:!1},this.prevTime=0,this.stats=new du,this.stats.dom.height=`48px`,[].forEach.call(this.stats.dom.children,e=>e.style.display=``),this.backgroundColor=new B(this.state.bgColor),this.scene=new Oi,this.scene.background=this.backgroundColor,this.defaultCamera=new yi(t.preset===e_.ASSET_GENERATOR?.8*180/Math.PI:60,e.clientWidth/e.clientHeight,.01,1e3),this.activeCamera=this.defaultCamera,this.scene.add(this.defaultCamera),this.renderer=window.renderer=new uu({antialias:!0,alpha:!0}),this.renderer.setClearColor(0,1),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(e.clientWidth,e.clientHeight),this.pmremGenerator=new Ps(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.neutralEnvironment=this.pmremGenerator.fromScene(new Id).texture,this.controls=new Cd(this.defaultCamera,this.renderer.domElement),this.controls.screenSpacePanning=!0,this._onControlsChange=()=>this.invalidate(),this.controls.addEventListener(`change`,this._onControlsChange),this.el.appendChild(this.renderer.domElement),this.cameraCtrl=null,this.cameraFolder=null,this.animFolder=null,this.animCtrls=[],this.morphFolder=null,this.morphCtrls=[],this.skeletonHelpers=[],this.gridHelper=null,this.axesHelper=null,this.modelInfo=null,this.annotationEls=[],this._tempVec=new R,this.addAxesHelper(),this.addGUI(),t.kiosk&&this.gui.close(),this.animate=this.animate.bind(this),this._rafId=null,this._visible=!0,this._tabVisible=!document.hidden,this._disposed=!1,this._loadedEnvironment=null,this._guiWrap=null,this._needsRender=!0,this._animating=!1,this._onVisibilityChange=()=>{let e=!this._tabVisible;this._tabVisible=!document.hidden,e&&this._tabVisible&&(this._needsRender=!0),this._updateRenderLoop()},document.addEventListener(`visibilitychange`,this._onVisibilityChange),typeof IntersectionObserver<`u`&&(this._intersectionObserver=new IntersectionObserver(e=>{let t=!this._visible;this._visible=e[e.length-1].isIntersecting,t&&this._visible&&(this._needsRender=!0),this._updateRenderLoop()},{threshold:0}),this._intersectionObserver.observe(this.el)),this._onResize=this.resize.bind(this),this._onKeyDown=e=>{(e.key===`p`||e.key===`P`)&&!this.isInputFocused()&&this.takeScreenshot()},this._updateRenderLoop(),window.addEventListener(`resize`,this._onResize,!1),window.addEventListener(`keydown`,this._onKeyDown)}invalidate(){this._disposed||(this._needsRender=!0,this._updateRenderLoop())}_recomputeAnimating(){let e=!1;if(this.state&&this.state.autoRotate&&(e=!0),!e&&this.mixer&&this.state){for(let t in this.state.actionStates)if(this.state.actionStates[t]){e=!0;break}}!e&&this.animationManager.currentAction&&(e=!0),this._animating=e}_updateRenderLoop(){if(this._disposed)return;let e=this._visible&&this._tabVisible;e&&(this._needsRender||this._animating)&&this._rafId===null?(this.prevTime=performance.now(),this._rafId=requestAnimationFrame(this.animate)):!e&&this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}animate(e){let t=(e-this.prevTime)/1e3;if(this.prevTime=e,this._recomputeAnimating(),this.controls.update(),this.stats.update(),this.mixer&&this.mixer.update(t),this.animationManager.update(t),this._afterAnimateHooks)for(let e=0;e<this._afterAnimateHooks.length;e++)this._afterAnimateHooks[e](t);this.render(),this._needsRender=!1,this._animating&&this._visible&&this._tabVisible&&!this._disposed?this._rafId=requestAnimationFrame(this.animate):this._rafId=null}isInputFocused(){let e=document.activeElement;return e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable)}render(){this.renderer.render(this.scene,this.activeCamera),this.state.grid&&(this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesRenderer.render(this.axesScene,this.axesCamera)),this.projectAnnotations()}takeScreenshot(){H_(this)}resize(){let{clientHeight:e,clientWidth:t}=this.el;this.defaultCamera.aspect=t/e,this.defaultCamera.updateProjectionMatrix(),this.renderer.setSize(t,e),this.axesCamera.aspect=this.axesDiv.clientWidth/this.axesDiv.clientHeight,this.axesCamera.updateProjectionMatrix(),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.invalidate()}load(e,t,n){let r=No.extractUrlBase(e);return new Promise((i,a)=>{t_.setURLModifier((e,i)=>{let a=t+decodeURI(e).replace(r,``).replace(/^(\.?\/)/,``);if(n.has(a)){let e=n.get(a),t=URL.createObjectURL(e);return s.push(t),t}return(i||``)+e});let o=new pu(t_).setCrossOrigin(`anonymous`).setDRACOLoader(r_).setKTX2Loader(i_.detectSupport(this.renderer)).setMeshoptDecoder(fd),s=[];o.load(e,e=>{window.VIEWER.json=e;let t=e.scene||e.scenes[0],n=e.animations||[];if(!t)throw Error(`This model contains no scene, and cannot be viewed here. However, it may contain individual 3D resources.`);this.setContent(t,n),s.forEach(URL.revokeObjectURL),i(e)},void 0,a)})}setContent(e,t){this.clear(),e.updateMatrixWorld();let n=new rn().setFromObject(e),r=n.getSize(new R).length(),i=n.getCenter(new R);this.controls.reset(),e.position.x-=i.x,e.position.y-=i.y,e.position.z-=i.z,this.controls.maxDistance=r*10,this.defaultCamera.near=r/100,this.defaultCamera.far=r*100,this.defaultCamera.updateProjectionMatrix(),this.options.cameraPosition?(this.defaultCamera.position.fromArray(this.options.cameraPosition),this.defaultCamera.lookAt(new R)):(this.defaultCamera.position.copy(i),this.defaultCamera.position.x+=r/2,this.defaultCamera.position.y+=r/5,this.defaultCamera.position.z+=r/2,this.defaultCamera.lookAt(i)),this.setCamera($g),this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesCamera.near=r/100,this.axesCamera.far=r*100,this.axesCamera.updateProjectionMatrix(),this.axesCorner.scale.set(r,r,r),this.controls.saveState(),this.scene.add(e),this.content=e,this.state.punctualLights=!0,this.content.traverse(e=>{e.isLight&&(this.state.punctualLights=!1)}),this.setClips(t),this.animationManager.attach(this.content),this._setupAnimationPanel(),this.updateLights(),this.updateGUI(),this.updateEnvironment(),this.updateDisplay(),this.updateModelInfo(e,t),this.updateAnnotations(),window.VIEWER.scene=this.content,this.printGraph(this.content),this.invalidate()}printGraph(e){console.group(` <`+e.type+`> `+e.name),e.children.forEach(e=>this.printGraph(e)),console.groupEnd()}setClips(e){W_(this,e)}playAllClips(){G_(this)}setCamera(e){e===`[default]`?(this.controls.enabled=!0,this.activeCamera=this.defaultCamera):(this.controls.enabled=!1,this.content.traverse(t=>{t.isCamera&&t.name===e&&(this.activeCamera=t)})),this.invalidate()}updateLights(){let e=this.state,t=this.lights;e.punctualLights&&!t.length?o_(this):!e.punctualLights&&t.length&&s_(this),this.renderer.toneMapping=Number(e.toneMapping),this.renderer.toneMappingExposure=2**e.exposure,t.length===2&&(t[0].intensity=e.ambientIntensity,t[0].color.set(e.ambientColor),t[1].intensity=e.directIntensity,t[1].color.set(e.directColor)),this.invalidate()}updateEnvironment(){let e=rp.filter(e=>e.name===this.state.environment)[0];V_(this,e).then(({envMap:e})=>{this._disposed||!this.scene||(this.scene.environment=e,this.scene.background=this.state.transparentBg?null:this.state.background?e:this.backgroundColor,this.invalidate())})}updateDisplay(){this.skeletonHelpers.length&&this.skeletonHelpers.forEach(e=>this.scene.remove(e)),a_(this.content,e=>{e.wireframe=this.state.wireframe,e instanceof Ca&&(e.size=this.state.pointSize)}),this.content.traverse(e=>{if(e.geometry&&e.skeleton&&this.state.skeleton){let t=new ns(e.skeleton.bones[0].parent);t.material.linewidth=3,this.scene.add(t),this.skeletonHelpers.push(t)}}),this.state.grid!==!!this.gridHelper&&(this.state.grid?(this.gridHelper=new is,this.axesHelper=new as,this.axesHelper.renderOrder=999,this.axesHelper.onBeforeRender=e=>e.clearDepth(),this.scene.add(this.gridHelper),this.scene.add(this.axesHelper)):(this.scene.remove(this.gridHelper),this.scene.remove(this.axesHelper),this.gridHelper=null,this.axesHelper=null,this.axesRenderer.clear())),this.controls.autoRotate=this.state.autoRotate,this.invalidate()}updateBackground(){this.backgroundColor.set(this.state.bgColor),this.state.transparentBg?(this.scene.background=null,this.renderer.setClearColor(0,0)):(this.scene.background=this.backgroundColor,this.renderer.setClearColor(0,1),this.updateEnvironment()),this.invalidate()}updateModelInfo(e,t){this.modelInfo&&=(this.modelInfo.remove(),null),this.state.showInfo&&e&&(this.modelInfo=pg(this.el,e,t))}updateAnnotations(){this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[],!(!this.state.showLabels||!this.content)&&(Sg(this.content).forEach(e=>{let t=Cg(e),n=document.createElement(`div`);n.classList.add(`annotation-label`),n.appendChild(t),this.el.appendChild(n),this.annotationEls.push({el:n,position:e.position})}),this.invalidate())}projectAnnotations(){if(this.annotationEls.length===0)return;let e=this.el.clientWidth,t=this.el.clientHeight,n=e/2,r=t/2,i=this._tempVec;this.annotationEls.forEach(({el:e,position:t})=>{if(i.copy(t),i.project(this.activeCamera),i.z>1){e.style.display=`none`;return}let a=i.x*n+n,o=-(i.y*r)+r;e.style.display=``,e.style.left=a+`px`,e.style.top=o+`px`})}addAxesHelper(){this.axesDiv=document.createElement(`div`),this.el.appendChild(this.axesDiv),this.axesDiv.classList.add(`axes`);let{clientWidth:e,clientHeight:t}=this.axesDiv;this.axesScene=new Oi,this.axesCamera=new yi(50,e/t,.1,10),this.axesScene.add(this.axesCamera),this.axesRenderer=new uu({alpha:!0}),this.axesRenderer.setPixelRatio(window.devicePixelRatio),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.axesCamera.up=this.defaultCamera.up,this.axesCorner=new as(5),this.axesScene.add(this.axesCorner),this.axesDiv.appendChild(this.axesRenderer.domElement)}addGUI(){let e=window.innerWidth<=700,t=this.gui=new np({autoPlace:!1,width:e?220:260,hideable:!0}),n=t.addFolder(`Display`);n.add(this.state,`background`).onChange(()=>this.updateEnvironment()),n.add(this.state,`autoRotate`).onChange(()=>this.updateDisplay()),n.add(this.state,`wireframe`).onChange(()=>this.updateDisplay()),n.add(this.state,`skeleton`).onChange(()=>this.updateDisplay()),n.add(this.state,`grid`).onChange(()=>this.updateDisplay()),n.add(this.controls,`screenSpacePanning`),n.add(this.state,`pointSize`,1,16).onChange(()=>this.updateDisplay()),n.add(this.state,`transparentBg`).name(`transparent bg`).onChange(()=>this.updateBackground()),n.addColor(this.state,`bgColor`).onChange(()=>this.updateBackground()),n.add({screenshot:()=>this.takeScreenshot()},`screenshot`).name(`Screenshot [P]`),n.add(this.state,`showInfo`).name(`model info`).onChange(()=>this.updateModelInfo(this.content,this.clips)),n.add(this.state,`showLabels`).name(`mesh labels`).onChange(()=>this.updateAnnotations());let r=t.addFolder(`Lighting`);r.add(this.state,`environment`,rp.map(e=>e.name)).onChange(()=>this.updateEnvironment()),[r.add(this.state,`toneMapping`,{Linear:1,"ACES Filmic":4}),r.add(this.state,`exposure`,-10,10,.01),r.add(this.state,`punctualLights`).listen(),r.add(this.state,`ambientIntensity`,0,2),r.addColor(this.state,`ambientColor`),r.add(this.state,`directIntensity`,0,4),r.addColor(this.state,`directColor`)].forEach(e=>e.onChange(()=>this.updateLights())),this.animFolder=t.addFolder(`Animation`),this.animFolder.domElement.style.display=`none`,this.animFolder.add(this.state,`playbackSpeed`,0,1).onChange(e=>{this.mixer&&(this.mixer.timeScale=e)}),this.animFolder.add({playAll:()=>this.playAllClips()},`playAll`),this.morphFolder=t.addFolder(`Morph Targets`),this.morphFolder.domElement.style.display=`none`,this.cameraFolder=t.addFolder(`Cameras`),this.cameraFolder.domElement.style.display=`none`;let i=t.addFolder(`Performance`),a=document.createElement(`li`);this.stats.dom.style.position=`static`,a.appendChild(this.stats.dom),a.classList.add(`gui-stats`),i.__ul.appendChild(a);let o=document.createElement(`div`);this.el.appendChild(o),o.classList.add(`gui-wrap`),o.classList.add(`gui-wrap--hidden`),o.appendChild(t.domElement),this._guiWrap=o;let s=document.createElement(`button`);s.className=`gui-toggle`,s.setAttribute(`title`,`Toggle advanced controls`),s.setAttribute(`aria-label`,`Toggle advanced controls`),s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg><span class="gui-toggle__label">Controls</span>`,s.addEventListener(`click`,()=>{let e=o.classList.toggle(`gui-wrap--hidden`);s.classList.toggle(`gui-toggle--active`,!e)}),this.el.appendChild(s),this._guiToggle=s,e?t.close():t.open()}updateGUI(){this.cameraFolder.domElement.style.display=`none`,this.morphCtrls.forEach(e=>e.remove()),this.morphCtrls.length=0,this.morphFolder.domElement.style.display=`none`,this.animCtrls.forEach(e=>e.remove()),this.animCtrls.length=0,this.animFolder.domElement.style.display=`none`;let e=[],t=[];if(this.content.traverse(n=>{n.geometry&&n.morphTargetInfluences&&t.push(n),n.isCamera&&(n.name=n.name||`VIEWER__camera_${e.length+1}`,e.push(n.name))}),e.length){this.cameraFolder.domElement.style.display=``,this.cameraCtrl&&this.cameraCtrl.remove();let t=[$g].concat(e);this.cameraCtrl=this.cameraFolder.add(this.state,`camera`,t),this.cameraCtrl.onChange(e=>this.setCamera(e))}if(t.length&&(this.morphFolder.domElement.style.display=``,t.forEach(e=>{if(e.morphTargetInfluences.length){let t=this.morphFolder.add({name:e.name||`Untitled`},`name`);this.morphCtrls.push(t)}for(let t=0;t<e.morphTargetInfluences.length;t++){let n=this.morphFolder.add(e.morphTargetInfluences,t,0,1,.01).listen();Object.keys(e.morphTargetDictionary).forEach(r=>{r&&e.morphTargetDictionary[r]===t&&n.name(r)}),this.morphCtrls.push(n)}})),this.clips.length){this.animFolder.domElement.style.display=``;let e=this.state.actionStates={};this.clips.forEach((t,n)=>{t.name=`${n+1}. ${t.name}`;let r;n===0?(e[t.name]=!0,r=this.mixer.clipAction(t),r.play()):e[t.name]=!1;let i=this.animFolder.add(e,t.name).listen();i.onChange(e=>{r||=this.mixer.clipAction(t),r.setEffectiveTimeScale(1),e?r.play():r.stop(),this.invalidate()}),this.animCtrls.push(i)})}}setAnimationDefs(e){this.animationManager.setAnimationDefs(e),this.content&&this._setupAnimationPanel()}_setupAnimationPanel(){this._animPanelEl&&=(this._animPanelEl.remove(),null);let e=this.animationManager.getAnimationDefs();if(e.length===0)return;let t=!1;if(this.content.traverse(e=>{e.isSkinnedMesh&&(t=!0)}),!t)return;let n=document.createElement(`div`);n.className=`anim-panel`,n.innerHTML=`<div class="anim-panel__header"><span class="anim-panel__title">Animations</span><button class="anim-panel__stop" title="Stop all">⏹</button></div><div class="anim-panel__grid"></div>`,this.el.appendChild(n),this._animPanelEl=n,this._renderAnimButtons(),this.animationManager.loadAll().then(()=>{if(this._renderAnimButtons(),!this.animationManager.currentName&&e.length>0){let t=e[0].name;this.animationManager.isLoaded(t)&&(this.animationManager.play(t),this._renderAnimButtons(),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop())}}),n.querySelector(`.anim-panel__stop`).addEventListener(`click`,()=>{this.animationManager.stopAll(),this._renderAnimButtons(),this.invalidate()}),this.animationManager.onChange=()=>{this._renderAnimButtons()}}_renderAnimButtons(){if(!this._animPanelEl)return;let e=this._animPanelEl.querySelector(`.anim-panel__grid`),t=this.animationManager.getAnimationDefs(),n=this.animationManager.currentName,r={idle:`🧍`,breathing:`🧍`,standing:`🧍`,walking:`🚶`,walk:`🚶`,running:`🏃`,run:`🏃`,waving:`👋`,wave:`👋`,dancing:`💃`,dance:`💃`,sitting:`🪑`,sit:`🪑`,jumping:`🦘`,jump:`🦘`,talking:`🗣️`,talk:`🗣️`,clapping:`👏`,clap:`👏`,punching:`👊`,punch:`👊`,kicking:`🦵`,kick:`🦵`};e.innerHTML=t.map((e,t)=>{let i=this.animationManager.isLoaded(e.name),a=n===e.name,o=e.icon||r[e.name.toLowerCase()]||`▶`,s=e.label||e.name.charAt(0).toUpperCase()+e.name.slice(1),c=t<9?t+1:``;return`<button class="anim-btn`+(a?` anim-btn--active`:``)+(i?``:` anim-btn--loading`)+`" data-anim="`+e.name+`" title="`+s+(c?` — press `+c:``)+`"`+(i?``:` disabled`)+`>`+(c?`<span class="anim-btn__key">`+c+`</span>`:``)+`<span class="anim-btn__icon">`+o+`</span><span class="anim-btn__label">`+s+`</span></button>`}).join(``),e.querySelectorAll(`.anim-btn:not([disabled])`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.anim;this.animationManager.crossfadeTo(t),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop()})}),this._animKeyBound||(this._animKeyBound=!0,document.addEventListener(`keydown`,e=>{if(e.target&&/INPUT|TEXTAREA|SELECT/.test(e.target.tagName)||e.metaKey||e.ctrlKey||e.altKey)return;let t=parseInt(e.key,10);if(!t||t<1||t>9)return;let n=this.animationManager.getAnimationDefs()[t-1];!n||!this.animationManager.isLoaded(n.name)||(this.animationManager.crossfadeTo(n.name),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop())}))}clear(){this.content&&(this.animationManager.detach(),this._animPanelEl&&=(this._animPanelEl.remove(),null),this.modelInfo&&=(this.modelInfo.remove(),null),this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[],this.scene.remove(this.content),this.content.traverse(e=>{e.geometry&&e.geometry.dispose()}),a_(this.content,e=>{for(let t in e)t!==`envMap`&&e[t]&&e[t].isTexture&&e[t].dispose()}),this.content=null,this._disposed||this.invalidate())}dispose(){if(!this._disposed){if(this._disposed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),document.removeEventListener(`visibilitychange`,this._onVisibilityChange),window.removeEventListener(`resize`,this._onResize,!1),window.removeEventListener(`keydown`,this._onKeyDown),this._intersectionObserver&&=(this._intersectionObserver.disconnect(),null),this.clear(),this.mixer){this.mixer.stopAllAction();let e=this.mixer.getRoot();e&&this.mixer.uncacheRoot(e),this.mixer=null}this.clips=[],this.animationManager.dispose(),this._animPanelEl&&=(this._animPanelEl.remove(),null),this.skeletonHelpers.length&&(this.skeletonHelpers.forEach(e=>{this.scene.remove(e),e.dispose?.()}),this.skeletonHelpers.length=0),this.gridHelper&&=(this.scene.remove(this.gridHelper),this.gridHelper.geometry?.dispose(),this.gridHelper.material?.dispose(),null),this.axesHelper&&=(this.scene.remove(this.axesHelper),this.axesHelper.geometry?.dispose(),this.axesHelper.material?.dispose(),null),this.axesCorner&&=(this.axesScene?.remove(this.axesCorner),this.axesCorner.geometry?.dispose(),this.axesCorner.material?.dispose(),null),this.lights.forEach(e=>e.parent?.remove(e)),this.lights=[],this.annotationEls.length&&(this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[]),this.modelInfo&&=(this.modelInfo.remove(),null),this.gui&&=(this.gui.destroy(),null),this._guiWrap&&=(this._guiWrap.remove(),null),this.stats?.dom&&this.stats.dom.remove(),this.controls?.dispose(),this.controls=null,this._loadedEnvironment&&=(this._loadedEnvironment.dispose(),null),this.neutralEnvironment&&=(this.neutralEnvironment.dispose(),null),this.scene&&(this.scene.environment=null,this.scene.background=null),this.pmremGenerator&&=(this.pmremGenerator.dispose(),null),this.axesRenderer&&=(this.axesRenderer.dispose(),this.axesRenderer.forceContextLoss?.(),this.axesRenderer.domElement?.remove(),null),this.axesDiv&&=(this.axesDiv.remove(),null),this.axesScene=null,this.axesCamera=null,this.renderer&&=(this.renderer.dispose(),this.renderer.forceContextLoss?.(),this.renderer.domElement?.remove(),window.renderer===this.renderer&&(window.renderer=null),null),this.scene=null,this.content=null,this.activeCamera=null,this.defaultCamera=null,this._afterAnimateHooks=null}}},Y_=class{constructor({model:e=`claude-opus-4-6`,proxyURL:t,apiKey:n,temperature:r=.7,maxTokens:i=4096,thinking:a=`auto`}={}){this.model=e,this.proxyURL=t,this.apiKey=n,this.temperature=r,this.maxTokens=i,this.thinking=a}async complete({system:e,messages:t,tools:n}){let r={model:this.model,max_tokens:this.maxTokens,temperature:this.temperature,system:e,messages:t};n&&n.length&&(r.tools=n),this.thinking===`always`&&(r.thinking={type:`enabled`,budget_tokens:2048});let i=this.proxyURL||`https://api.anthropic.com/v1/messages`,a={"content-type":`application/json`};this.apiKey&&(a[`x-api-key`]=this.apiKey,a[`anthropic-version`]=`2023-06-01`,a[`anthropic-dangerous-direct-browser-access`]=`true`);let o=await fetch(i,{method:`POST`,headers:a,body:JSON.stringify(r)});if(!o.ok){let e=await o.text();throw Error(`Anthropic ${o.status}: ${e}`)}let s=await o.json();return this._normalize(s)}_normalize(e){let t={text:``,toolCalls:[],thinking:``,stopReason:e.stop_reason};for(let n of e.content||[])n.type===`text`?t.text+=n.text:n.type===`thinking`?t.thinking+=n.thinking||``:n.type===`tool_use`&&t.toolCalls.push({id:n.id,name:n.name,input:n.input});return t}formatToolResults(e){return{role:`user`,content:e.map(e=>({type:`tool_result`,tool_use_id:e.id,content:typeof e.output==`string`?e.output:JSON.stringify(e.output),is_error:!!e.isError}))}}formatAssistantWithToolCalls(e,t){let n=[];e&&n.push({type:`text`,text:e});for(let e of t)n.push({type:`tool_use`,id:e.id,name:e.name,input:e.input});return{role:`assistant`,content:n}}},X_=class{async complete(){return{text:``,toolCalls:[],stopReason:`end_turn`}}formatToolResults(){return{role:`user`,content:[]}}formatAssistantWithToolCalls(e){return{role:`assistant`,content:e||``}}};function Z_(e={}){let t=e.provider||`anthropic`;if(t===`anthropic`)return new Y_(e);if(t===`none`)return new X_;throw Error(`Unsupported provider: ${t}. Supported: anthropic, none`)}var Q_=class{constructor({voiceId:e=`default`,rate:t=1,pitch:n=1,lang:r=`en-US`}={}){this.voiceId=e,this.rate=t,this.pitch=n,this.lang=r,this._queue=[],this._speaking=!1}async speak(e,{onStart:t,onEnd:n}={}){if(`speechSynthesis`in window)return new Promise(r=>{let i=new SpeechSynthesisUtterance(e);i.rate=this.rate,i.pitch=this.pitch,i.lang=this.lang;let a=this._pickVoice();a&&(i.voice=a),i.onstart=()=>{this._speaking=!0,t?.()},i.onend=()=>{this._speaking=!1,n?.(),r()},i.onerror=()=>{this._speaking=!1,r()},window.speechSynthesis.speak(i)})}cancel(){`speechSynthesis`in window&&window.speechSynthesis.cancel(),this._speaking=!1}get speaking(){return this._speaking}_pickVoice(){if(!(`speechSynthesis`in window))return null;let e=window.speechSynthesis.getVoices();if(this.voiceId&&this.voiceId!==`default`){let t=e.find(e=>e.name===this.voiceId||e.voiceURI===this.voiceId);if(t)return t}return e.find(e=>e.lang?.startsWith(this.lang.slice(0,2)))||null}},$_=class{constructor({language:e=`en-US`,continuous:t=!1,interimResults:n=!0}={}){this.language=e,this.continuous=t,this.interimResults=n,this._recognition=null,this._listening=!1}_ensure(){if(this._recognition)return this._recognition;let e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return null;let t=new e;return t.lang=this.language,t.continuous=this.continuous,t.interimResults=this.interimResults,this._recognition=t,t}async listen({onInterim:e,onFinal:t}={}){let n=this._ensure();if(!n)throw Error(`SpeechRecognition unavailable in this browser`);return new Promise((r,i)=>{let a=``;n.onresult=n=>{for(let r=n.resultIndex;r<n.results.length;r++){let i=n.results[r],o=i[0].transcript;i.isFinal?(a+=o,t?.(o)):e?.(o)}},n.onerror=e=>{this._listening=!1,i(e.error)},n.onend=()=>{this._listening=!1,r(a.trim())},this._listening=!0;try{n.start()}catch(e){this._listening=!1,i(e)}})}stop(){this._recognition&&this._listening&&this._recognition.stop()}get listening(){return this._listening}};function ev(e={}){let t=e.provider||`browser`;if(t===`none`)return null;if(t===`browser`)return new Q_(e);throw Error(`TTS provider "${t}" not implemented yet`)}function tv(e={}){let t=e.provider||`browser`;if(t===`none`)return null;if(t===`browser`)return new $_(e);throw Error(`STT provider "${t}" not implemented yet`)}var nv=[{name:`wave`,description:`Wave at the user. Use for greetings, farewells, or acknowledgments.`,input_schema:{type:`object`,properties:{duration_ms:{type:`integer`,minimum:500,maximum:5e3,default:1500}}}},{name:`lookAt`,description:`Direct the agent's gaze toward a target.`,input_schema:{type:`object`,properties:{target:{type:`string`,enum:[`user`,`camera`,`center`],description:`Where to look`}},required:[`target`]}},{name:`play_clip`,description:`Play a named animation clip from the loaded body.`,input_schema:{type:`object`,properties:{name:{type:`string`},loop:{type:`boolean`,default:!1},fade_ms:{type:`integer`,default:200}},required:[`name`]}},{name:`setExpression`,description:`Set facial expression via morph target preset.`,input_schema:{type:`object`,properties:{preset:{type:`string`,enum:[`neutral`,`happy`,`sad`,`surprised`,`confused`,`focused`]},intensity:{type:`number`,minimum:0,maximum:1,default:1}},required:[`preset`]}},{name:`speak`,description:`Say something out loud via TTS. Use this instead of plain text when voice is on.`,input_schema:{type:`object`,properties:{text:{type:`string`}},required:[`text`]}},{name:`remember`,description:`Save a durable memory about the user, a feedback rule, a project fact, or a reference.`,input_schema:{type:`object`,properties:{key:{type:`string`,description:`short snake_case filename, e.g. "user_role"`},name:{type:`string`},description:{type:`string`},type:{type:`string`,enum:[`user`,`feedback`,`project`,`reference`]},body:{type:`string`}},required:[`key`,`name`,`description`,`type`,`body`]}}],rv={async wave(e,t){let n=e.duration_ms||1500;return await t.viewer.playAnimationByHint?.(`wave`,{duration:n}),t.memory.note(`waved`,{duration_ms:n}),{ok:!0}},async lookAt(e,t){let n=e.target||`user`;return t.viewer.lookAt?.(n),{ok:!0,target:n}},async play_clip(e,t){let{name:n,loop:r=!1,fade_ms:i=200}=e;return t.viewer.playClipByName?.(n,{loop:r,fade_ms:i})?{ok:!0,name:n}:{ok:!1,error:`No clip named "${n}"`}},async setExpression(e,t){let{preset:n,intensity:r=1}=e;return t.viewer.setExpression?.(n,r),{ok:!0,preset:n}},async speak(e,t){return await t.speak(e.text),{ok:!0}},async remember(e,t){let{key:n,name:r,description:i,type:a,body:o}=e;return t.memory.write(n,{name:r,description:i,type:a,body:o}),{ok:!0,saved:n}}},iv=8,av=class extends EventTarget{constructor({manifest:e,viewer:t,memory:n,skills:r,providerConfig:i={},voiceConfig:a={}}={}){super(),this.manifest=e||{},this.viewer=t,this.memory=n,this.skills=r,this.provider=Z_({...this.manifest.brain,...i}),this.tts=ev({...this.manifest.voice?.tts,...a.tts}),this.stt=tv({...this.manifest.voice?.stt,...a.stt}),this.messages=[],this._busy=!1}get systemPrompt(){let e=[];return this.manifest.instructions&&e.push(this.manifest.instructions),this.memory&&e.push(`
<memory>
`+this.memory.contextBlock({maxTokens:this.manifest.memory?.maxTokens||8192})+`
@@ -3853,7 +3853,7 @@ void main() {
`)}_persist(){if(this.mode!==`local`||!this.namespace)return;let e=`agent:${this.namespace}:memory`,t={index:{text:this.indexText},files:Object.fromEntries(this.files),timeline:this.timeline.slice(-200)};try{localStorage.setItem(e,JSON.stringify(t))}catch(e){console.warn(`[memory] persist failed`,e)}}contextBlock({maxTokens:e=8192}={}){let t=e*4,n=[`# Agent Memory`,``,this.indexText],r=n.join(`
`).length;for(let[e,i]of this.files){if(r+i.length>t)break;n.push(``,`## ${e}`,i),r+=i.length}if(this.timeline.length){let e=this.timeline.slice(-20).map(e=>JSON.stringify(e)).join(`
`);r+e.length<t&&n.push(``,`## Recent timeline`,"```",e,"```")}return n.join(`
-`)}async export(){return{version:`memory/0.1`,index:this.indexText,files:Object.fromEntries(this.files),timeline:this.timeline}}async import(e,{strategy:t=`merge`}={}){if(t===`replace`)this.files=new Map(Object.entries(e.files||{})),this.timeline=e.timeline||[];else{for(let[t,n]of Object.entries(e.files||{}))this.files.has(t)||this.files.set(t,n);this.timeline=[...this.timeline,...e.timeline||[]].slice(-1e3)}this._rebuildIndex(),this._persist()}},yv=`6.16.0`;function bv(e,t,n){let r=t.split(`|`).map(e=>e.trim());for(let n=0;n<r.length;n++)switch(t){case`any`:return;case`bigint`:case`boolean`:case`number`:case`string`:if(typeof e===t)return}let i=Error(`invalid value for type ${t}`);throw i.code=`INVALID_ARGUMENT`,i.argument=`value.${n}`,i.value=e,i}async function xv(e){let t=Object.keys(e);return(await Promise.all(t.map(t=>Promise.resolve(e[t])))).reduce((e,n,r)=>(e[t[r]]=n,e),{})}function G(e,t,n){for(let r in t){let i=t[r],a=n?n[r]:null;a&&bv(i,a,r),Object.defineProperty(e,r,{enumerable:!0,value:i,writable:!1})}}function Sv(e,t){if(e==null)return`null`;if(t??=new Set,typeof e==`object`){if(t.has(e))return`[Circular]`;t.add(e)}if(Array.isArray(e))return`[ `+e.map(e=>Sv(e,t)).join(`, `)+` ]`;if(e instanceof Uint8Array){let t=`0123456789abcdef`,n=`0x`;for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[e[r]&15];return n}if(typeof e==`object`&&typeof e.toJSON==`function`)return Sv(e.toJSON(),t);switch(typeof e){case`boolean`:case`number`:case`symbol`:return e.toString();case`bigint`:return BigInt(e).toString();case`string`:return JSON.stringify(e);case`object`:{let n=Object.keys(e);return n.sort(),`{ `+n.map(n=>`${Sv(n,t)}: ${Sv(e[n],t)}`).join(`, `)+` }`}}return`[ COULD NOT SERIALIZE ]`}function Cv(e,t){return e&&e.code===t}function wv(e){return Cv(e,`CALL_EXCEPTION`)}function Tv(e,t,n){let r=e;{let r=[];if(n){if(`message`in n||`code`in n||`name`in n)throw Error(`value will overwrite populated values: ${Sv(n)}`);for(let e in n){if(e===`shortMessage`)continue;let t=n[e];r.push(e+`=`+Sv(t))}}r.push(`code=${t}`),r.push(`version=${yv}`),r.length&&(e+=` (`+r.join(`, `)+`)`)}let i;switch(t){case`INVALID_ARGUMENT`:i=TypeError(e);break;case`NUMERIC_FAULT`:case`BUFFER_OVERRUN`:i=RangeError(e);break;default:i=Error(e)}return G(i,{code:t}),n&&Object.assign(i,n),i.shortMessage??G(i,{shortMessage:r}),i}function K(e,t,n,r){if(!e)throw Tv(t,n,r)}function q(e,t,n,r){K(e,t,`INVALID_ARGUMENT`,{argument:n,value:r})}function Ev(e,t,n){n??=``,n&&=`: `+n,K(e>=t,`missing argument`+n,`MISSING_ARGUMENT`,{count:e,expectedCount:t}),K(e<=t,`too many arguments`+n,`UNEXPECTED_ARGUMENT`,{count:e,expectedCount:t})}var Dv=[`NFD`,`NFC`,`NFKD`,`NFKC`].reduce((e,t)=>{try{if(`test`.normalize(t)!==`test`)throw Error(`bad`);if(t===`NFD`&&`é`.normalize(`NFD`)!==`é`)throw Error(`broken`);e.push(t)}catch{}return e},[]);function Ov(e){K(Dv.indexOf(e)>=0,`platform missing String.prototype.normalize`,`UNSUPPORTED_OPERATION`,{operation:`String.prototype.normalize`,info:{form:e}})}function kv(e,t,n){if(n??=``,e!==t){let e=n,t=`new`;n&&(e+=`.`,t+=` `+n),K(!1,`private constructor; use ${e}from* methods`,`UNSUPPORTED_OPERATION`,{operation:t})}}function Av(e,t,n){if(e instanceof Uint8Array)return n?new Uint8Array(e):e;if(typeof e==`string`&&e.length%2==0&&e.match(/^0x[0-9a-f]*$/i)){let t=new Uint8Array((e.length-2)/2),n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}q(!1,`invalid BytesLike value`,t||`value`,e)}function J(e,t){return Av(e,t,!1)}function jv(e,t){return Av(e,t,!0)}function Mv(e,t){return!(typeof e!=`string`||!e.match(/^0x[0-9A-Fa-f]*$/)||typeof t==`number`&&e.length!==2+2*t||t===!0&&e.length%2!=0)}function Nv(e){return Mv(e,!0)||e instanceof Uint8Array}var Pv=`0123456789abcdef`;function Y(e){let t=J(e),n=`0x`;for(let e=0;e<t.length;e++){let r=t[e];n+=Pv[(r&240)>>4]+Pv[r&15]}return n}function Fv(e){return`0x`+e.map(e=>Y(e).substring(2)).join(``)}function Iv(e){return Mv(e,!0)?(e.length-2)/2:J(e).length}function Lv(e,t,n){let r=J(e);return n!=null&&n>r.length&&K(!1,`cannot slice beyond data bounds`,`BUFFER_OVERRUN`,{buffer:r,length:r.length,offset:n}),Y(r.slice(t??0,n??r.length))}function Rv(e,t,n){let r=J(e);K(t>=r.length,`padding exceeds data length`,`BUFFER_OVERRUN`,{buffer:new Uint8Array(r),length:t,offset:t+1});let i=new Uint8Array(t);return i.fill(0),n?i.set(r,t-r.length):i.set(r,0),Y(i)}function zv(e,t){return Rv(e,t,!0)}function Bv(e,t){return Rv(e,t,!1)}var Vv=BigInt(0),Hv=BigInt(1),Uv=9007199254740991;function Wv(e,t){let n=qv(e,`value`),r=BigInt(Z(t,`width`));if(K(n>>r===Vv,`overflow`,`NUMERIC_FAULT`,{operation:`fromTwos`,fault:`overflow`,value:e}),n>>r-Hv){let e=(Hv<<r)-Hv;return-((~n&e)+Hv)}return n}function Gv(e,t){let n=X(e,`value`),r=BigInt(Z(t,`width`)),i=Hv<<r-Hv;if(n<Vv){n=-n,K(n<=i,`too low`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});let t=(Hv<<r)-Hv;return(~n&t)+Hv}else K(n<i,`too high`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});return n}function Kv(e,t){return qv(e,`value`)&(Hv<<BigInt(Z(t,`bits`)))-Hv}function X(e,t){switch(typeof e){case`bigint`:return e;case`number`:return q(Number.isInteger(e),`underflow`,t||`value`,e),q(e>=-Uv&&e<=Uv,`overflow`,t||`value`,e),BigInt(e);case`string`:try{if(e===``)throw Error(`empty string`);return e[0]===`-`&&e[1]!==`-`?-BigInt(e.substring(1)):BigInt(e)}catch(n){q(!1,`invalid BigNumberish string: ${n.message}`,t||`value`,e)}}q(!1,`invalid BigNumberish value`,t||`value`,e)}function qv(e,t){let n=X(e,t);return K(n>=Vv,`unsigned value cannot be negative`,`NUMERIC_FAULT`,{fault:`overflow`,operation:`getUint`,value:e}),n}var Jv=`0123456789abcdef`;function Yv(e){if(e instanceof Uint8Array){let t=`0x0`;for(let n of e)t+=Jv[n>>4],t+=Jv[n&15];return BigInt(t)}return X(e)}function Z(e,t){switch(typeof e){case`bigint`:return q(e>=-Uv&&e<=Uv,`overflow`,t||`value`,e),Number(e);case`number`:return q(Number.isInteger(e),`underflow`,t||`value`,e),q(e>=-Uv&&e<=Uv,`overflow`,t||`value`,e),e;case`string`:try{if(e===``)throw Error(`empty string`);return Z(BigInt(e),t)}catch(n){q(!1,`invalid numeric string: ${n.message}`,t||`value`,e)}}q(!1,`invalid numeric value`,t||`value`,e)}function Xv(e){return Z(Yv(e))}function Zv(e,t){let n=qv(e,`value`),r=n.toString(16);if(t==null)r.length%2&&(r=`0`+r);else{let i=Z(t,`width`);if(i===0&&n===Vv)return`0x`;for(K(i*2>=r.length,`value exceeds width (${i} bytes)`,`NUMERIC_FAULT`,{operation:`toBeHex`,fault:`overflow`,value:e});r.length<i*2;)r=`0`+r}return`0x`+r}function Qv(e,t){let n=qv(e,`value`);if(n===Vv){let e=t==null?0:Z(t,`width`);return new Uint8Array(e)}let r=n.toString(16);if(r.length%2&&(r=`0`+r),t!=null){let n=Z(t,`width`);for(;r.length<n*2;)r=`00`+r;K(n*2===r.length,`value exceeds width (${n} bytes)`,`NUMERIC_FAULT`,{operation:`toBeArray`,fault:`overflow`,value:e})}let i=new Uint8Array(r.length/2);for(let e=0;e<i.length;e++){let t=e*2;i[e]=parseInt(r.substring(t,t+2),16)}return i}function $v(e){let t=Y(Nv(e)?e:Qv(e)).substring(2);for(;t.startsWith(`0`);)t=t.substring(1);return t===``&&(t=`0`),`0x`+t}var ey=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,ty=BigInt(58);function ny(e){let t=J(e),n=Yv(t),r=``;for(;n;)r=ey[Number(n%ty)]+r,n/=ty;for(let e=0;e<t.length&&!t[e];e++)r=ey[0]+r;return r}function ry(e){e=atob(e);let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return J(t)}function iy(e){let t=J(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}var ay=class{filter;emitter;#e;constructor(e,t,n){this.#e=t,G(this,{emitter:e,filter:n})}async removeListener(){this.#e!=null&&await this.emitter.off(this.filter,this.#e)}};function oy(e,t,n,r,i){q(!1,`invalid codepoint at offset ${t}; ${e}`,`bytes`,n)}function sy(e,t,n,r,i){if(e===`BAD_PREFIX`||e===`UNEXPECTED_CONTINUE`){let e=0;for(let r=t+1;r<n.length&&n[r]>>6==2;r++)e++;return e}return e===`OVERRUN`?n.length-t-1:0}function cy(e,t,n,r,i){return e===`OVERLONG`?(q(typeof i==`number`,`invalid bad code point for replacement`,`badCodepoint`,i),r.push(i),0):(r.push(65533),sy(e,t,n,r,i))}var ly=Object.freeze({error:oy,ignore:sy,replace:cy});function uy(e,t){t??=ly.error;let n=J(e,`bytes`),r=[],i=0;for(;i<n.length;){let e=n[i++];if(!(e>>7)){r.push(e);continue}let a=null,o=null;if((e&224)==192)a=1,o=127;else if((e&240)==224)a=2,o=2047;else if((e&248)==240)a=3,o=65535;else{(e&192)==128?i+=t(`UNEXPECTED_CONTINUE`,i-1,n,r):i+=t(`BAD_PREFIX`,i-1,n,r);continue}if(i-1+a>=n.length){i+=t(`OVERRUN`,i-1,n,r);continue}let s=e&(1<<8-a-1)-1;for(let e=0;e<a;e++){let e=n[i];if((e&192)!=128){i+=t(`MISSING_CONTINUE`,i,n,r),s=null;break}s=s<<6|e&63,i++}if(s!==null){if(s>1114111){i+=t(`OUT_OF_RANGE`,i-1-a,n,r,s);continue}if(s>=55296&&s<=57343){i+=t(`UTF16_SURROGATE`,i-1-a,n,r,s);continue}if(s<=o){i+=t(`OVERLONG`,i-1-a,n,r,s);continue}r.push(s)}}return r}function dy(e,t){q(typeof e==`string`,`invalid string value`,`str`,e),t!=null&&(Ov(t),e=e.normalize(t));let n=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<128)n.push(r);else if(r<2048)n.push(r>>6|192),n.push(r&63|128);else if((r&64512)==55296){t++;let i=e.charCodeAt(t);q(t<e.length&&(i&64512)==56320,`invalid surrogate pair`,`str`,e);let a=65536+((r&1023)<<10)+(i&1023);n.push(a>>18|240),n.push(a>>12&63|128),n.push(a>>6&63|128),n.push(a&63|128)}else n.push(r>>12|224),n.push(r>>6&63|128),n.push(r&63|128)}return new Uint8Array(n)}function fy(e){return e.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join(``)}function py(e,t){return fy(uy(e,t))}function my(e){async function t(t,n){K(n==null||!n.cancelled,`request cancelled before sending`,`CANCELLED`);let r=t.url.split(`:`)[0].toLowerCase();K(r===`http`||r===`https`,`unsupported protocol ${r}`,`UNSUPPORTED_OPERATION`,{info:{protocol:r},operation:`request`}),K(r===`https`||!t.credentials||t.allowInsecureAuthentication,`insecure authorized connections unsupported`,`UNSUPPORTED_OPERATION`,{operation:`request`});let i=null,a=new AbortController,o=setTimeout(()=>{i=Tv(`request timeout`,`TIMEOUT`),a.abort()},t.timeout);n&&n.addListener(()=>{i=Tv(`request cancelled`,`CANCELLED`),a.abort()});let s=Object.assign({},e,{method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:a.signal}),c;try{c=await fetch(t.url,s)}catch(e){throw clearTimeout(o),i||e}clearTimeout(o);let l={};c.headers.forEach((e,t)=>{l[t.toLowerCase()]=e});let u=await c.arrayBuffer(),d=u==null?null:new Uint8Array(u);return{statusCode:c.status,statusMessage:c.statusText,headers:l,body:d}}return t}var hy=12,gy=250,_y=my(),vy=RegExp(`^data:([^;:]*)?(;base64)?,(.*)$`,`i`),yy=RegExp(`^ipfs://(ipfs/)?(.*)$`,`i`),by=!1;async function xy(e,t){try{let t=e.match(vy);if(!t)throw Error(`invalid data`);return new Oy(200,`OK`,{"content-type":t[1]||`text/plain`},t[2]?ry(t[3]):Ay(t[3]))}catch{return new Oy(599,`BAD REQUEST (invalid data: URI)`,{},null,new Dy(e))}}function Sy(e){async function t(t,n){try{let n=t.match(yy);if(!n)throw Error(`invalid link`);return new Dy(`${e}${n[2]}`)}catch{return new Oy(599,`BAD REQUEST (invalid IPFS URI)`,{},null,new Dy(t))}}return t}var Cy={data:xy,ipfs:Sy(`https://gateway.ipfs.io/ipfs/`)},wy=new WeakMap,Ty=class{#e;#t;constructor(e){this.#e=[],this.#t=!1,wy.set(e,()=>{if(!this.#t){this.#t=!0;for(let e of this.#e)setTimeout(()=>{e()},0);this.#e=[]}})}addListener(e){K(!this.#t,`singal already cancelled`,`UNSUPPORTED_OPERATION`,{operation:`fetchCancelSignal.addCancelListener`}),this.#e.push(e)}get cancelled(){return this.#t}checkSignal(){K(!this.cancelled,`cancelled`,`CANCELLED`,{})}};function Ey(e){if(e==null)throw Error(`missing signal; should not happen`);return e.checkSignal(),e}var Dy=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;get url(){return this.#a}set url(e){this.#a=String(e)}get body(){return this.#o==null?null:new Uint8Array(this.#o)}set body(e){if(e==null)this.#o=void 0,this.#s=void 0;else if(typeof e==`string`)this.#o=dy(e),this.#s=`text/plain`;else if(e instanceof Uint8Array)this.#o=e,this.#s=`application/octet-stream`;else if(typeof e==`object`)this.#o=dy(JSON.stringify(e)),this.#s=`application/json`;else throw Error(`invalid body`)}hasBody(){return this.#o!=null}get method(){return this.#r?this.#r:this.hasBody()?`POST`:`GET`}set method(e){e??=``,this.#r=String(e).toUpperCase()}get headers(){let e=Object.assign({},this.#n);return this.#c&&(e.authorization=`Basic ${iy(dy(this.#c))}`),this.allowGzip&&(e[`accept-encoding`]=`gzip`),e[`content-type`]==null&&this.#s&&(e[`content-type`]=this.#s),this.body&&(e[`content-length`]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){this.#n[String(e).toLowerCase()]=String(t)}clearHeaders(){this.#n={}}[Symbol.iterator](){let e=this.headers,t=Object.keys(e),n=0;return{next:()=>{if(n<t.length){let r=t[n++];return{value:[r,e[r]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return this.#c||null}setCredentials(e,t){q(!e.match(/:/),`invalid basic authentication username`,`username`,`[REDACTED]`),this.#c=`${e}:${t}`}get allowGzip(){return this.#t}set allowGzip(e){this.#t=!!e}get allowInsecureAuthentication(){return!!this.#e}set allowInsecureAuthentication(e){this.#e=!!e}get timeout(){return this.#i}set timeout(e){q(e>=0,`timeout must be non-zero`,`timeout`,e),this.#i=e}get preflightFunc(){return this.#l||null}set preflightFunc(e){this.#l=e}get processFunc(){return this.#u||null}set processFunc(e){this.#u=e}get retryFunc(){return this.#d||null}set retryFunc(e){this.#d=e}get getUrlFunc(){return this.#m||_y}set getUrlFunc(e){this.#m=e}constructor(e){this.#a=String(e),this.#e=!1,this.#t=!0,this.#n={},this.#r=``,this.#i=3e5,this.#p={slotInterval:gy,maxAttempts:hy},this.#m=null}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#o?Y(this.#o):`null`}>`}setThrottleParams(e){e.slotInterval!=null&&(this.#p.slotInterval=e.slotInterval),e.maxAttempts!=null&&(this.#p.maxAttempts=e.maxAttempts)}async#h(e,t,n,r,i){if(e>=this.#p.maxAttempts)return i.makeServerError(`exceeded maximum retry limit`);K(ky()<=t,`timeout`,`TIMEOUT`,{operation:`request.send`,reason:`timeout`,request:r}),n>0&&await jy(n);let a=this.clone(),o=(a.url.split(`:`)[0]||``).toLowerCase();if(o in Cy){let e=await Cy[o](a.url,Ey(r.#f));if(e instanceof Oy){let t=e;if(this.processFunc){Ey(r.#f);try{t=await this.processFunc(a,t)}catch(e){(e.throttle==null||typeof e.stall!=`number`)&&t.makeServerError(`error in post-processing function`,e).assertOk()}}return t}a=e}this.preflightFunc&&(a=await this.preflightFunc(a));let s=await this.getUrlFunc(a,Ey(r.#f)),c=new Oy(s.statusCode,s.statusMessage,s.headers,s.body,r);if(c.statusCode===301||c.statusCode===302){try{let n=c.headers.location||``;return a.redirect(n).#h(e+1,t,0,r,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(a,c,e))){let n=c.headers[`retry-after`],i=this.#p.slotInterval*Math.trunc(Math.random()*2**e);return typeof n==`string`&&n.match(/^[1-9][0-9]*$/)&&(i=parseInt(n)),a.clone().#h(e+1,t,i,r,c)}if(this.processFunc){Ey(r.#f);try{c=await this.processFunc(a,c)}catch(n){(n.throttle==null||typeof n.stall!=`number`)&&c.makeServerError(`error in post-processing function`,n).assertOk();let i=this.#p.slotInterval*Math.trunc(Math.random()*2**e);return n.stall>=0&&(i=n.stall),a.clone().#h(e+1,t,i,r,c)}}return c}send(){return K(this.#f==null,`request already sent`,`UNSUPPORTED_OPERATION`,{operation:`fetchRequest.send`}),this.#f=new Ty(this),this.#h(0,ky()+this.timeout,0,this,new Oy(0,``,{},null,this))}cancel(){K(this.#f!=null,`request has not been sent`,`UNSUPPORTED_OPERATION`,{operation:`fetchRequest.cancel`});let e=wy.get(this);if(!e)throw Error(`missing signal; should not happen`);e()}redirect(t){let n=this.url.split(`:`)[0].toLowerCase(),r=t.split(`:`)[0].toLowerCase();K(this.method===`GET`&&(n!==`https`||r!==`http`)&&t.match(/^https?:/),`unsupported redirect`,`UNSUPPORTED_OPERATION`,{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});let i=new e(t);return i.method=`GET`,i.allowGzip=this.allowGzip,i.timeout=this.timeout,i.#n=Object.assign({},this.#n),this.#o&&(i.#o=new Uint8Array(this.#o)),i.#s=this.#s,i}clone(){let t=new e(this.url);return t.#r=this.#r,this.#o&&(t.#o=this.#o),t.#s=this.#s,t.#n=Object.assign({},this.#n),t.#c=this.#c,this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),t.#l=this.#l,t.#u=this.#u,t.#d=this.#d,t.#p=Object.assign({},this.#p),t.#m=this.#m,t}static lockConfig(){by=!0}static getGateway(e){return Cy[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e===`http`||e===`https`)throw Error(`cannot intercept ${e}; use registerGetUrl`);if(by)throw Error(`gateways locked`);Cy[e]=t}static registerGetUrl(e){if(by)throw Error(`gateways locked`);_y=e}static createGetUrlFunc(e){return my(e)}static createDataGateway(){return xy}static createIpfsGatewayFunc(e){return Sy(e)}},Oy=class e{#e;#t;#n;#r;#i;#a;toString(){return`<FetchResponse status=${this.statusCode} body=${this.#r?Y(this.#r):`null`}>`}get statusCode(){return this.#e}get statusMessage(){return this.#t}get headers(){return Object.assign({},this.#n)}get body(){return this.#r==null?null:new Uint8Array(this.#r)}get bodyText(){try{return this.#r==null?``:py(this.#r)}catch{K(!1,`response body is not valid UTF-8 data`,`UNSUPPORTED_OPERATION`,{operation:`bodyText`,info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{K(!1,`response body is not valid JSON`,`UNSUPPORTED_OPERATION`,{operation:`bodyJson`,info:{response:this}})}}[Symbol.iterator](){let e=this.headers,t=Object.keys(e),n=0;return{next:()=>{if(n<t.length){let r=t[n++];return{value:[r,e[r]],done:!1}}return{value:void 0,done:!0}}}}constructor(e,t,n,r,i){this.#e=e,this.#t=t,this.#n=Object.keys(n).reduce((e,t)=>(e[t.toLowerCase()]=String(n[t]),e),{}),this.#r=r==null?null:new Uint8Array(r),this.#i=i||null,this.#a={message:``}}makeServerError(t,n){let r;t?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:(t=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${t})`);let i=new e(599,r,this.headers,this.body,this.#i||void 0);return i.#a={message:t,error:n},i}throwThrottleError(e,t){t==null?t=-1:q(Number.isInteger(t)&&t>=0,`invalid stall timeout`,`stall`,t);let n=Error(e||`throttling requests`);throw G(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return this.#r!=null}get request(){return this.#i}ok(){return this.#a.message===``&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=this.#a;e===``&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let r=null;try{this.#r&&(r=py(this.#r))}catch{}K(!1,e,`SERVER_ERROR`,{request:this.request||`unknown request`,response:this,error:t,info:{requestUrl:n,responseBody:r,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};function ky(){return new Date().getTime()}function Ay(e){return dy(e.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function jy(e){return new Promise(t=>setTimeout(t,e))}function My(e){let t=e.toString(16);for(;t.length<2;)t=`0`+t;return`0x`+t}function Ny(e,t,n){let r=0;for(let i=0;i<n;i++)r=r*256+e[t+i];return r}function Py(e,t,n,r){let i=[];for(;n<t+1+r;){let a=Fy(e,n);i.push(a.result),n+=a.consumed,K(n<=t+1+r,`child data too short`,`BUFFER_OVERRUN`,{buffer:e,length:r,offset:t})}return{consumed:1+r,result:i}}function Fy(e,t){K(e.length!==0,`data too short`,`BUFFER_OVERRUN`,{buffer:e,length:0,offset:1});let n=t=>{K(t<=e.length,`data short segment too short`,`BUFFER_OVERRUN`,{buffer:e,length:e.length,offset:t})};if(e[t]>=248){let r=e[t]-247;n(t+1+r);let i=Ny(e,t+1,r);return n(t+1+r+i),Py(e,t,t+1+r,r+i)}else if(e[t]>=192){let r=e[t]-192;return n(t+1+r),Py(e,t,t+1,r)}else if(e[t]>=184){let r=e[t]-183;n(t+1+r);let i=Ny(e,t+1,r);n(t+1+r+i);let a=Y(e.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:a}}else if(e[t]>=128){let r=e[t]-128;n(t+1+r);let i=Y(e.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:My(e[t])}}function Iy(e){let t=J(e,`data`),n=Fy(t,0);return q(n.consumed===t.length,`unexpected junk after rlp payload`,`data`,e),n.result}function Ly(e){let t=[];for(;e;)t.unshift(e&255),e>>=8;return t}function Ry(e){if(Array.isArray(e)){let t=[];if(e.forEach(function(e){t=t.concat(Ry(e))}),t.length<=55)return t.unshift(192+t.length),t;let n=Ly(t.length);return n.unshift(247+n.length),n.concat(t)}let t=Array.prototype.slice.call(J(e,`object`));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;let n=Ly(t.length);return n.unshift(183+n.length),n.concat(t)}var zy=`0123456789abcdef`;function By(e){let t=`0x`;for(let n of Ry(e))t+=zy[n>>4],t+=zy[n&15];return t}var Vy=new Uint8Array(32),Hy=[`then`],Uy={},Wy=new WeakMap;function Gy(e){return Wy.get(e)}function Ky(e,t){Wy.set(e,t)}function qy(e,t){let n=Error(`deferred error during ABI decoding triggered accessing ${e}`);throw n.error=t,n}function Jy(e,t,n){return e.indexOf(null)>=0?t.map((e,t)=>e instanceof Yy?Jy(Gy(e),e,n):e):e.reduce((e,r,i)=>{let a=t.getValue(r);return r in e||(n&&a instanceof Yy&&(a=Jy(Gy(a),a,n)),e[r]=a),e},{})}var Yy=class e extends Array{#e;constructor(...e){let t=e[0],n=e[1],r=(e[2]||[]).slice(),i=!0;t!==Uy&&(n=e,r=[],i=!1),super(n.length),n.forEach((e,t)=>{this[t]=e});let a=r.reduce((e,t)=>(typeof t==`string`&&e.set(t,(e.get(t)||0)+1),e),new Map);if(Ky(this,Object.freeze(n.map((e,t)=>{let n=r[t];return n!=null&&a.get(n)===1?n:null}))),this.#e=[],this.#e??this.#e,!i)return;Object.freeze(this);let o=new Proxy(this,{get:(e,t,n)=>{if(typeof t==`string`){if(t.match(/^[0-9]+$/)){let n=Z(t,`%index`);if(n<0||n>=this.length)throw RangeError(`out of result range`);let r=e[n];return r instanceof Error&&qy(`index ${n}`,r),r}if(Hy.indexOf(t)>=0)return Reflect.get(e,t,n);let r=e[t];if(r instanceof Function)return function(...t){return r.apply(this===n?e:this,t)};if(!(t in e))return e.getValue.apply(this===n?e:this,[t])}return Reflect.get(e,t,n)}});return Ky(o,Gy(this)),o}toArray(t){let n=[];return this.forEach((r,i)=>{r instanceof Error&&qy(`index ${i}`,r),t&&r instanceof e&&(r=r.toArray(t)),n.push(r)}),n}toObject(e){let t=Gy(this);return t.reduce((n,r,i)=>(K(r!=null,`value at index ${i} unnamed`,`UNSUPPORTED_OPERATION`,{operation:`toObject()`}),Jy(t,this,e)),{})}slice(t,n){t??=0,t<0&&(t+=this.length,t<0&&(t=0)),n??=this.length,n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);let r=Gy(this),i=[],a=[];for(let e=t;e<n;e++)i.push(this[e]),a.push(r[e]);return new e(Uy,i,a)}filter(t,n){let r=Gy(this),i=[],a=[];for(let e=0;e<this.length;e++){let o=this[e];o instanceof Error&&qy(`index ${e}`,o),t.call(n,o,e,this)&&(i.push(o),a.push(r[e]))}return new e(Uy,i,a)}map(e,t){let n=[];for(let r=0;r<this.length;r++){let i=this[r];i instanceof Error&&qy(`index ${r}`,i),n.push(e.call(t,i,r,this))}return n}getValue(e){let t=Gy(this).indexOf(e);if(t===-1)return;let n=this[t];return n instanceof Error&&qy(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(t,n){return new e(Uy,t,n)}};function Xy(e){let t=Qv(e);return K(t.length<=32,`value out-of-bounds`,`BUFFER_OVERRUN`,{buffer:t,length:32,offset:t.length}),t.length!==32&&(t=jv(Fv([Vy.slice(t.length%32),t]))),t}var Zy=class{name;type;localName;dynamic;constructor(e,t,n,r){G(this,{name:e,type:t,localName:n,dynamic:r},{name:`string`,type:`string`,localName:`string`,dynamic:`boolean`})}_throwError(e,t){q(!1,e,this.localName,t)}},Qy=class{#e;#t;constructor(){this.#e=[],this.#t=0}get data(){return Fv(this.#e)}get length(){return this.#t}#n(e){return this.#e.push(e),this.#t+=e.length,e.length}appendWriter(e){return this.#n(jv(e.data))}writeBytes(e){let t=jv(e),n=t.length%32;return n&&(t=jv(Fv([t,Vy.slice(n)]))),this.#n(t)}writeValue(e){return this.#n(Xy(e))}writeUpdatableValue(){let e=this.#e.length;return this.#e.push(Vy),this.#t+=32,t=>{this.#e[e]=Xy(t)}}},$y=class e{allowLoose;#e;#t;#n;#r;#i;constructor(e,t,n){G(this,{allowLoose:!!t}),this.#e=jv(e),this.#n=0,this.#r=null,this.#i=n??1024,this.#t=0}get data(){return Y(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#t}get bytes(){return new Uint8Array(this.#e)}#a(e){if(this.#r)return this.#r.#a(e);this.#n+=e,K(this.#i<1||this.#n<=this.#i*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#i} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`,`BUFFER_OVERRUN`,{buffer:jv(this.#e),offset:this.#t,length:e,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#o(e,t,n){let r=Math.ceil(t/32)*32;return this.#t+r>this.#e.length&&(this.allowLoose&&n&&this.#t+t<=this.#e.length?r=t:K(!1,`data out-of-bounds`,`BUFFER_OVERRUN`,{buffer:jv(this.#e),length:this.#e.length,offset:this.#t+r})),this.#e.slice(this.#t,this.#t+r)}subReader(t){let n=new e(this.#e.slice(this.#t+t),this.allowLoose,this.#i);return n.#r=this,n}readBytes(e,t){let n=this.#o(0,e,!!t);return this.#a(e),this.#t+=n.length,n.slice(0,e)}readValue(){return Yv(this.readBytes(32))}readIndex(){return Xv(this.readBytes(32))}};function eb(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function tb(e,...t){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array`);if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function nb(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.wrapConstructor`);eb(e.outputLen),eb(e.blockLen)}function rb(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function ib(e,t){tb(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least ${n}`)}var ab=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0,ob=e=>e instanceof Uint8Array,sb=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),cb=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),lb=(e,t)=>e<<32-t|e>>>t;if(new Uint8Array(new Uint32Array([287454020]).buffer)[0]!==68)throw Error(`Non little-endian hardware is not supported`);function ub(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function db(e){if(typeof e==`string`&&(e=ub(e)),!ob(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}function fb(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!ob(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}var pb=class{clone(){return this._cloneInto()}};({}).toString;function mb(e){let t=t=>e().update(db(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function hb(e=32){if(ab&&typeof ab.getRandomValues==`function`)return ab.getRandomValues(new Uint8Array(e));throw Error(`crypto.getRandomValues must be defined`)}var gb=class extends pb{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,nb(e);let n=db(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return rb(this),this.iHash.update(e),this}digestInto(e){rb(this),tb(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_b=(e,t,n)=>new gb(e,t).update(n).digest();_b.create=(e,t)=>new gb(e,t);function vb(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}var yb=class extends pb{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=cb(this.buffer)}update(e){rb(this);let{view:t,buffer:n,blockLen:r}=this;e=db(e);let i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=cb(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){rb(this),ib(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;vb(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=cb(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=a,r%t&&e.buffer.set(n),e}},bb=(e,t,n)=>e&t^~e&n,xb=(e,t,n)=>e&t^e&n^t&n,Sb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Cb=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),wb=new Uint32Array(64),Tb=class extends yb{constructor(){super(64,32,8,!1),this.A=Cb[0]|0,this.B=Cb[1]|0,this.C=Cb[2]|0,this.D=Cb[3]|0,this.E=Cb[4]|0,this.F=Cb[5]|0,this.G=Cb[6]|0,this.H=Cb[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)wb[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=wb[e-15],n=wb[e-2],r=lb(t,7)^lb(t,18)^t>>>3;wb[e]=(lb(n,17)^lb(n,19)^n>>>10)+wb[e-7]+r+wb[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=lb(o,6)^lb(o,11)^lb(o,25),u=l+t+bb(o,s,c)+Sb[e]+wb[e]|0,d=(lb(n,2)^lb(n,13)^lb(n,22))+xb(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){wb.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Eb=mb(()=>new Tb),Db=BigInt(2**32-1),Ob=BigInt(32);function kb(e,t=!1){return t?{h:Number(e&Db),l:Number(e>>Ob&Db)}:{h:Number(e>>Ob&Db)|0,l:Number(e&Db)|0}}function Ab(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=kb(e[i],t);[n[i],r[i]]=[a,o]}return[n,r]}var jb=(e,t)=>BigInt(e>>>0)<<Ob|BigInt(t>>>0),Mb=(e,t,n)=>e>>>n,Nb=(e,t,n)=>e<<32-n|t>>>n,Pb=(e,t,n)=>e>>>n|t<<32-n,Fb=(e,t,n)=>e<<32-n|t>>>n,Ib=(e,t,n)=>e<<64-n|t>>>n-32,Lb=(e,t,n)=>e>>>n-32|t<<64-n,Rb=(e,t)=>t,zb=(e,t)=>e,Bb=(e,t,n)=>e<<n|t>>>32-n,Vb=(e,t,n)=>t<<n|e>>>32-n,Hb=(e,t,n)=>t<<n-32|e>>>64-n,Ub=(e,t,n)=>e<<n-32|t>>>64-n;function Wb(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var Q={fromBig:kb,split:Ab,toBig:jb,shrSH:Mb,shrSL:Nb,rotrSH:Pb,rotrSL:Fb,rotrBH:Ib,rotrBL:Lb,rotr32H:Rb,rotr32L:zb,rotlSH:Bb,rotlSL:Vb,rotlBH:Hb,rotlBL:Ub,add:Wb,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},[Gb,Kb]=Q.split(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),qb=new Uint32Array(80),Jb=new Uint32Array(80),Yb=class extends yb{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)qb[n]=e.getUint32(t),Jb[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=qb[e-15]|0,n=Jb[e-15]|0,r=Q.rotrSH(t,n,1)^Q.rotrSH(t,n,8)^Q.shrSH(t,n,7),i=Q.rotrSL(t,n,1)^Q.rotrSL(t,n,8)^Q.shrSL(t,n,7),a=qb[e-2]|0,o=Jb[e-2]|0,s=Q.rotrSH(a,o,19)^Q.rotrBH(a,o,61)^Q.shrSH(a,o,6),c=Q.rotrSL(a,o,19)^Q.rotrBL(a,o,61)^Q.shrSL(a,o,6),l=Q.add4L(i,c,Jb[e-7],Jb[e-16]);qb[e]=Q.add4H(l,r,s,qb[e-7],qb[e-16])|0,Jb[e]=l|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Q.rotrSH(u,d,14)^Q.rotrSH(u,d,18)^Q.rotrBH(u,d,41),v=Q.rotrSL(u,d,14)^Q.rotrSL(u,d,18)^Q.rotrBL(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=Q.add5L(_,v,b,Kb[e],Jb[e]),S=Q.add5H(x,g,t,y,Gb[e],qb[e]),C=x|0,w=Q.rotrSH(n,r,28)^Q.rotrBH(n,r,34)^Q.rotrBH(n,r,39),T=Q.rotrSL(n,r,28)^Q.rotrBL(n,r,34)^Q.rotrBL(n,r,39),E=n&i^n&o^i&o,D=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=Q.add(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let O=Q.add3L(C,T,D);n=Q.add3H(O,S,w,E),r=O|0}({h:n,l:r}=Q.add(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=Q.add(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=Q.add(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=Q.add(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Q.add(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Q.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=Q.add(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=Q.add(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){qb.fill(0),Jb.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Xb=mb(()=>new Yb);function Zb(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`unable to locate global object`)}var Qb=Zb();Qb.crypto||Qb.msCrypto;function $b(e){switch(e){case`sha256`:return Eb.create();case`sha512`:return Xb.create()}q(!1,`invalid hashing algorithm name`,`algorithm`,e)}var[ex,tx,nx]=[[],[],[]],rx=BigInt(0),ix=BigInt(1),ax=BigInt(2),ox=BigInt(7),sx=BigInt(256),cx=BigInt(113);for(let e=0,t=ix,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ex.push(2*(5*r+n)),tx.push((e+1)*(e+2)/2%64);let i=rx;for(let e=0;e<7;e++)t=(t<<ix^(t>>ox)*cx)%sx,t&ax&&(i^=ix<<(ix<<BigInt(e))-ix);nx.push(i)}var[lx,ux]=Ab(nx,!0),dx=(e,t,n)=>n>32?Hb(e,t,n):Bb(e,t,n),fx=(e,t,n)=>n>32?Ub(e,t,n):Vb(e,t,n);function px(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=dx(a,o,1)^n[r],c=fx(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=tx[n],a=dx(t,i,r),o=fx(t,i,r),s=ex[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=lx[r],e[1]^=ux[r]}n.fill(0)}var mx=class e extends pb{constructor(e,t,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,eb(n),0>=this.blockLen||this.blockLen>=200)throw Error(`Sha3 supports only keccak-f1600 function`);this.state=new Uint8Array(200),this.state32=sb(this.state)}keccak(){px(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){rb(this);let{blockLen:t,state:n}=this;e=db(e);let r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){rb(this,!1),tb(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return eb(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ib(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},hx=((e,t,n)=>mb(()=>new mx(t,e,n)))(1,136,256/8),gx=!1,_x=function(e){return hx(e)},vx=_x;function yx(e){let t=J(e,`data`);return Y(vx(t))}yx._=_x,yx.lock=function(){gx=!0},yx.register=function(e){if(gx)throw TypeError(`keccak256 is locked`);vx=e},Object.freeze(yx);var bx=function(e){return $b(`sha256`).update(e).digest()},xx=function(e){return $b(`sha512`).update(e).digest()},Sx=bx,Cx=xx,wx=!1,Tx=!1;function Ex(e){let t=J(e,`data`);return Y(Sx(t))}Ex._=bx,Ex.lock=function(){wx=!0},Ex.register=function(e){if(wx)throw Error(`sha256 is locked`);Sx=e},Object.freeze(Ex);function Dx(e){let t=J(e,`data`);return Y(Cx(t))}Dx._=xx,Dx.lock=function(){Tx=!0},Dx.register=function(e){if(Tx)throw Error(`sha512 is locked`);Cx=e},Object.freeze(Ex);var Ox=n({bitGet:()=>Jx,bitLen:()=>qx,bitMask:()=>Xx,bitSet:()=>Yx,bytesToHex:()=>Px,bytesToNumberBE:()=>Rx,bytesToNumberLE:()=>zx,concatBytes:()=>Wx,createHmacDrbg:()=>$x,ensureBytes:()=>Ux,equalBytes:()=>Gx,hexToBytes:()=>Lx,hexToNumber:()=>Ix,numberToBytesBE:()=>Bx,numberToBytesLE:()=>Vx,numberToHexUnpadded:()=>Fx,numberToVarBytesBE:()=>Hx,utf8ToBytes:()=>Kx,validateObject:()=>tS}),kx=BigInt(0),Ax=BigInt(1),jx=BigInt(2),Mx=e=>e instanceof Uint8Array,Nx=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Px(e){if(!Mx(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n<e.length;n++)t+=Nx[e[n]];return t}function Fx(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function Ix(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}function Lx(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=e.length;if(t%2)throw Error(`padded hex string expected, got unpadded hex of length `+t);let n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){let r=t*2,i=e.slice(r,r+2),a=Number.parseInt(i,16);if(Number.isNaN(a)||a<0)throw Error(`Invalid byte sequence`);n[t]=a}return n}function Rx(e){return Ix(Px(e))}function zx(e){if(!Mx(e))throw Error(`Uint8Array expected`);return Ix(Px(Uint8Array.from(e).reverse()))}function Bx(e,t){return Lx(e.toString(16).padStart(t*2,`0`))}function Vx(e,t){return Bx(e,t).reverse()}function Hx(e){return Lx(Fx(e))}function Ux(e,t,n){let r;if(typeof t==`string`)try{r=Lx(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(Mx(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(`${e} expected ${n} bytes, got ${i}`);return r}function Wx(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!Mx(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}function Gx(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Kx(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function qx(e){let t;for(t=0;e>kx;e>>=Ax,t+=1);return t}function Jx(e,t){return e>>BigInt(t)&Ax}var Yx=(e,t,n)=>e|(n?Ax:kx)<<BigInt(t),Xx=e=>(jx<<BigInt(e-1))-Ax,Zx=e=>new Uint8Array(e),Qx=e=>Uint8Array.from(e);function $x(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=Zx(e),i=Zx(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=Zx())=>{i=s(Qx([0]),e),r=s(),e.length!==0&&(i=s(Qx([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return Wx(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var eS={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,stringOrUint8Array:e=>typeof e==`string`||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function tS(e,t,n={}){let r=(t,n,r)=>{let i=eS[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}var nS=BigInt(0),rS=BigInt(1),iS=BigInt(2),aS=BigInt(3),oS=BigInt(4),sS=BigInt(5),cS=BigInt(8),lS=BigInt(16);function uS(e,t){let n=e%t;return n>=nS?n:t+n}function dS(e,t,n){if(n<=nS||t<nS)throw Error(`Expected power/modulo > 0`);if(n===rS)return nS;let r=rS;for(;t>nS;)t&rS&&(r=r*e%n),e=e*e%n,t>>=rS;return r}function fS(e,t,n){let r=e;for(;t-- >nS;)r*=r,r%=n;return r}function pS(e,t){if(e===nS||t<=nS)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=uS(e,t),r=t,i=nS,a=rS,o=rS,s=nS;for(;n!==nS;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==rS)throw Error(`invert: does not exist`);return uS(i,t)}function mS(e){let t=(e-rS)/iS,n,r,i;for(n=e-rS,r=0;n%iS===nS;n/=iS,r++);for(i=iS;i<e&&dS(i,t,e)!==e-rS;i++);if(r===1){let t=(e+rS)/oS;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}let a=(n+rS)/iS;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw Error(`Cannot find square root`);let s=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,a),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);let n=e.pow(c,rS<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),u=e.mul(u,c),s=t}return l}}function hS(e){if(e%oS===aS){let t=(e+rS)/oS;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}if(e%cS===sS){let t=(e-sS)/cS;return function(e,n){let r=e.mul(n,iS),i=e.pow(r,t),a=e.mul(n,i),o=e.mul(e.mul(a,iS),i),s=e.mul(a,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error(`Cannot find square root`);return s}}return e%lS,mS(e)}var gS=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function _S(e){return tS(e,gS.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`isSafeInteger`,BITS:`isSafeInteger`}))}function vS(e,t,n){if(n<nS)throw Error(`Expected power > 0`);if(n===nS)return e.ONE;if(n===rS)return t;let r=e.ONE,i=t;for(;n>nS;)n&rS&&(r=e.mul(r,i)),i=e.sqr(i),n>>=rS;return r}function yS(e,t){let n=Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function bS(e,t){let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function xS(e,t,n=!1,r={}){if(e<=nS)throw Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:a}=bS(e,t);if(a>2048)throw Error(`Field lengths over 2048 bytes are not supported`);let o=hS(e),s=Object.freeze({ORDER:e,BITS:i,BYTES:a,MASK:Xx(i),ZERO:nS,ONE:rS,create:t=>uS(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`Invalid field element: expected bigint, got ${typeof t}`);return nS<=t&&t<e},is0:e=>e===nS,isOdd:e=>(e&rS)===rS,neg:t=>uS(-t,e),eql:(e,t)=>e===t,sqr:t=>uS(t*t,e),add:(t,n)=>uS(t+n,e),sub:(t,n)=>uS(t-n,e),mul:(t,n)=>uS(t*n,e),pow:(e,t)=>vS(s,e,t),div:(t,n)=>uS(t*pS(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>pS(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>yS(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Vx(e,a):Bx(e,a),fromBytes:e=>{if(e.length!==a)throw Error(`Fp.fromBytes: expected ${a}, got ${e.length}`);return n?zx(e):Rx(e)}});return Object.freeze(s)}function SS(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function CS(e){let t=SS(e);return t+Math.ceil(t/2)}function wS(e,t,n=!1){let r=e.length,i=SS(t),a=CS(t);if(r<16||r<a||r>1024)throw Error(`expected ${a}-1024 bytes of input, got ${r}`);let o=uS(n?Rx(e):zx(e),t-rS)+rS;return n?Vx(o,i):Bx(o,i)}var TS=BigInt(0),ES=BigInt(1);function DS(e,t){let n=(e,t)=>{let n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>TS;)n&ES&&(r=r.add(i)),i=i.double(),n>>=ES;return r},precomputeWindow(e,t){let{windows:n,windowSize:i}=r(t),a=[],o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a},wNAF(t,i,a){let{windows:o,windowSize:s}=r(t),c=e.ZERO,l=e.BASE,u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){let t=e*s,r=Number(a&u);a>>=f,r>s&&(r-=d,a+=ES);let o=t,p=t+Math.abs(r)-1,m=e%2!=0,h=r<0;r===0?l=l.add(n(m,i[o])):c=c.add(n(h,i[p]))}return{p:c,f:l}},wNAFCached(e,t,n,r){let i=e._WINDOW_SIZE||1,a=t.get(e);return a||(a=this.precomputeWindow(e,i),i!==1&&t.set(e,r(a))),this.wNAF(i,a,n)}}}function OS(e){return _S(e.Fp),tS(e,{n:`bigint`,h:`bigint`,Gx:`field`,Gy:`field`},{nBitLength:`isSafeInteger`,nByteLength:`isSafeInteger`}),Object.freeze({...bS(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function kS(e){let t=OS(e);tS(t,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof n!=`object`||typeof n.beta!=`bigint`||typeof n.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...t})}var{bytesToNumberBE:AS,hexToBytes:jS}=Ox,MS={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=MS;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:AS(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=MS,n=typeof e==`string`?jS(e):e;if(!(n instanceof Uint8Array))throw Error(`ui8a expected`);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:a}=MS._parseInt(n.subarray(2)),{d:o,l:s}=MS._parseInt(a);if(s.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:o}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},NS=BigInt(0),PS=BigInt(1),FS=BigInt(2),IS=BigInt(3),LS=BigInt(4);function RS(e){let t=kS(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{let i=t.toAffine();return Wx(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{let t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){let{a:r,b:i}=t,a=n.sqr(e),o=n.mul(a,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw Error(`bad generator point: equation left != right`);function o(e){return typeof e==`bigint`&&NS<e&&e<t.n}function s(e){if(!o(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function c(e){let{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:a}=t;if(n&&typeof e!=`bigint`){if(e instanceof Uint8Array&&(e=Px(e)),typeof e!=`string`||!n.includes(e.length))throw Error(`Invalid key`);e=e.padStart(r*2,`0`)}let o;try{o=typeof e==`bigint`?e:Rx(Ux(`private key`,e,r))}catch{throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=uS(o,a)),s(o),o}let l=new Map;function u(e){if(!(e instanceof d))throw Error(`ProjectivePoint expected`)}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,e==null||!n.isValid(e))throw Error(`x required`);if(t==null||!n.isValid(t))throw Error(`y required`);if(r==null||!n.isValid(r))throw Error(`z required`)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error(`invalid affine point`);if(e instanceof d)throw Error(`projective point not allowed`);let i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){let t=d.fromAffine(i(Ux(`pointHex`,e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error(`bad point: ZERO`)}let{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error(`bad point: x or y not FE`);let i=n.sqr(r),o=a(e);if(!n.eql(i,o))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){u(e);let{px:t,py:r,pz:i}=this,{px:a,py:o,pz:s}=e,c=n.eql(n.mul(t,s),n.mul(a,i)),l=n.eql(n.mul(r,s),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){let{a:e,b:r}=t,i=n.mul(r,IS),{px:a,py:o,pz:s}=this,c=n.ZERO,l=n.ZERO,u=n.ZERO,f=n.mul(a,a),p=n.mul(o,o),m=n.mul(s,s),h=n.mul(a,o);return h=n.add(h,h),u=n.mul(a,s),u=n.add(u,u),c=n.mul(e,u),l=n.mul(i,m),l=n.add(c,l),c=n.sub(p,l),l=n.add(p,l),l=n.mul(c,l),c=n.mul(h,c),u=n.mul(i,u),m=n.mul(e,m),h=n.sub(f,m),h=n.mul(e,h),h=n.add(h,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,m),f=n.mul(f,h),l=n.add(l,f),m=n.mul(o,s),m=n.add(m,m),f=n.mul(m,h),c=n.sub(c,f),u=n.mul(m,p),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);let{px:r,py:i,pz:a}=this,{px:o,py:s,pz:c}=e,l=n.ZERO,f=n.ZERO,p=n.ZERO,m=t.a,h=n.mul(t.b,IS),g=n.mul(r,o),_=n.mul(i,s),v=n.mul(a,c),y=n.add(r,i),b=n.add(o,s);y=n.mul(y,b),b=n.add(g,_),y=n.sub(y,b),b=n.add(r,a);let x=n.add(o,c);return b=n.mul(b,x),x=n.add(g,v),b=n.sub(b,x),x=n.add(i,a),l=n.add(s,c),x=n.mul(x,l),l=n.add(_,v),x=n.sub(x,l),p=n.mul(m,b),l=n.mul(h,v),p=n.add(l,p),l=n.sub(_,p),p=n.add(_,p),f=n.mul(l,p),_=n.add(g,g),_=n.add(_,g),v=n.mul(m,v),b=n.mul(h,b),_=n.add(_,v),v=n.sub(g,v),v=n.mul(m,v),b=n.add(b,v),g=n.mul(_,b),f=n.add(f,g),g=n.mul(x,b),l=n.mul(y,l),l=n.sub(l,g),g=n.mul(y,_),p=n.mul(x,p),p=n.add(p,g),new d(l,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,l,e,e=>{let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){let r=d.ZERO;if(e===NS)return r;if(s(e),e===PS)return this;let{endo:i}=t;if(!i)return p.unsafeLadder(this,e);let{k1neg:a,k1:o,k2neg:c,k2:l}=i.splitScalar(e),u=r,f=r,m=this;for(;o>NS||l>NS;)o&PS&&(u=u.add(m)),l&PS&&(f=f.add(m)),m=m.double(),o>>=PS,l>>=PS;return a&&(u=u.negate()),c&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){s(e);let r=e,i,a,{endo:o}=t;if(o){let{k1neg:e,k1:t,k2neg:s,k2:c}=o.splitScalar(r),{p:l,f:u}=this.wNAF(t),{p:f,f:m}=this.wNAF(c);l=p.constTimeNegate(e,l),f=p.constTimeNegate(s,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=l.add(f),a=u.add(m)}else{let{p:e,f:t}=this.wNAF(r);i=e,a=t}return d.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){let r=d.BASE,i=(e,t)=>t===NS||t===PS||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:r,pz:i}=this,a=this.is0();e??=a?n.ONE:n.inv(i);let o=n.mul(t,e),s=n.mul(r,e),c=n.mul(i,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw Error(`invZ was invalid`);return{x:o,y:s}}isTorsionFree(){let{h:e,isTorsionFree:n}=t;if(e===PS)return!0;if(n)return n(d,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:n}=t;return e===PS?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return Px(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);let f=t.nBitLength,p=DS(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function zS(e){let t=OS(e);return tS(t,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...t})}function BS(e){let t=zS(e),{Fp:n,n:r}=t,i=n.BYTES+1,a=2*n.BYTES+1;function o(e){return NS<e&&e<n.ORDER}function s(e){return uS(e,r)}function c(e){return pS(e,r)}let{ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=RS({...t,toBytes(e,t,r){let i=t.toAffine(),a=n.toBytes(i.x),o=Wx;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),a):o(Uint8Array.from([4]),a,n.toBytes(i.y))},fromBytes(e){let t=e.length,r=e[0],s=e.subarray(1);if(t===i&&(r===2||r===3)){let e=Rx(s);if(!o(e))throw Error(`Point is not on curve`);let t=d(e),i=n.sqrt(t),a=(i&PS)===PS;return(r&1)==1!==a&&(i=n.neg(i)),{x:e,y:i}}else if(t===a&&r===4)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};else throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),p=e=>Px(Bx(e,t.nByteLength));function m(e){return e>r>>PS}function h(e){return m(e)?s(-e):e}let g=(e,t,n)=>Rx(e.slice(t,n));class _{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){let n=t.nByteLength;return e=Ux(`compactSignature`,e,n*2),new _(g(e,0,n),g(e,n,2*n))}static fromDER(e){let{r:t,s:n}=MS.toSig(Ux(`DER`,e));return new _(t,n)}assertValidity(){if(!f(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!f(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new _(this.r,this.s,e)}recoverPublicKey(e){let{r,s:i,recovery:a}=this,o=C(Ux(`msgHash`,e));if(a==null||![0,1,2,3].includes(a))throw Error(`recovery id invalid`);let u=a===2||a===3?r+t.n:r;if(u>=n.ORDER)throw Error(`recovery id 2 or 3 invalid`);let d=a&1?`03`:`02`,f=l.fromHex(d+p(u)),m=c(u),h=s(-o*m),g=s(i*m),_=l.BASE.multiplyAndAddUnsafe(f,h,g);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Lx(this.toDERHex())}toDERHex(){return MS.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Lx(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let v={isValidPrivateKey(e){try{return u(e),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let e=CS(t.n);return wS(t.randomBytes(e),t.n)},precompute(e=8,t=l.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)}function b(e){let t=e instanceof Uint8Array,n=typeof e==`string`,r=(t||n)&&e.length;return t?r===i||r===a:n?r===2*i||r===2*a:e instanceof l}function x(e,t,n=!0){if(b(e))throw Error(`first arg must be private key`);if(!b(t))throw Error(`second arg must be public key`);return l.fromHex(t).multiply(u(e)).toRawBytes(n)}let S=t.bits2int||function(e){let n=Rx(e),r=e.length*8-t.nBitLength;return r>0?n>>BigInt(r):n},C=t.bits2int_modN||function(e){return s(S(e))},w=Xx(t.nBitLength);function T(e){if(typeof e!=`bigint`)throw Error(`bigint expected`);if(!(NS<=e&&e<w))throw Error(`bigint expected < 2^${t.nBitLength}`);return Bx(e,t.nByteLength)}function E(e,r,i=D){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{hash:a,randomBytes:o}=t,{lowS:d,prehash:p,extraEntropy:g}=i;d??=!0,e=Ux(`msgHash`,e),p&&(e=Ux(`prehashed msgHash`,a(e)));let v=C(e),y=u(r),b=[T(y),T(v)];if(g!=null){let e=g===!0?o(n.BYTES):g;b.push(Ux(`extraEntropy`,e))}let x=Wx(...b),w=v;function E(e){let t=S(e);if(!f(t))return;let n=c(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===NS)return;let a=s(n*s(w+i*y));if(a===NS)return;let o=(r.x===i?0:2)|Number(r.y&PS),u=a;return d&&m(a)&&(u=h(a),o^=1),new _(i,u,o)}return{seed:x,k2sig:E}}let D={lowS:t.lowS,prehash:!1},O={lowS:t.lowS,prehash:!1};function k(e,n,r=D){let{seed:i,k2sig:a}=E(e,n,r),o=t;return $x(o.hash.outputLen,o.nByteLength,o.hmac)(i,a)}l.BASE._setWindowSize(8);function ee(e,n,r,i=O){let a=e;if(n=Ux(`msgHash`,n),r=Ux(`publicKey`,r),`strict`in i)throw Error(`options.strict was renamed to lowS`);let{lowS:o,prehash:u}=i,d,f;try{if(typeof a==`string`||a instanceof Uint8Array)try{d=_.fromDER(a)}catch(e){if(!(e instanceof MS.Err))throw e;d=_.fromCompact(a)}else if(typeof a==`object`&&typeof a.r==`bigint`&&typeof a.s==`bigint`){let{r:e,s:t}=a;d=new _(e,t)}else throw Error(`PARSE`);f=l.fromHex(r)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(o&&d.hasHighS())return!1;u&&(n=t.hash(n));let{r:p,s:m}=d,h=C(n),g=c(m),v=s(h*g),y=s(p*g),b=l.BASE.multiplyAndAddUnsafe(f,v,y)?.toAffine();return b?s(b.x)===p:!1}return{CURVE:t,getPublicKey:y,getSharedSecret:x,sign:k,verify:ee,ProjectivePoint:l,Signature:_,utils:v}}function VS(e,t){let n=e.ORDER,r=NS;for(let e=n-PS;e%FS===NS;e/=FS)r+=PS;let i=r,a=FS<<i-PS-PS,o=a*FS,s=(n-PS)/o,c=(s-PS)/FS,l=o-PS,u=a,d=e.pow(t,s),f=e.pow(t,(s+PS)/FS),p=(t,n)=>{let r=d,a=e.pow(n,l),o=e.sqr(a);o=e.mul(o,n);let s=e.mul(t,o);s=e.pow(s,c),s=e.mul(s,a),a=e.mul(s,n),o=e.mul(s,t);let p=e.mul(o,a);s=e.pow(p,u);let m=e.eql(s,e.ONE);a=e.mul(o,f),s=e.mul(p,r),o=e.cmov(a,o,m),p=e.cmov(s,p,m);for(let t=i;t>PS;t--){let n=t-FS;n=FS<<n-PS;let i=e.pow(p,n),s=e.eql(i,e.ONE);a=e.mul(o,r),r=e.mul(r,r),i=e.mul(p,r),o=e.cmov(a,o,s),p=e.cmov(i,p,s)}return{isValid:m,value:o}};if(e.ORDER%LS===IS){let n=(e.ORDER-IS)/LS,r=e.sqrt(e.neg(t));p=(t,i)=>{let a=e.sqr(i),o=e.mul(t,i);a=e.mul(a,o);let s=e.pow(a,n);s=e.mul(s,o);let c=e.mul(s,r),l=e.mul(e.sqr(s),i),u=e.eql(l,t);return{isValid:u,value:e.cmov(c,s,u)}}}return p}function HS(e,t){if(_S(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw Error(`mapToCurveSimpleSWU: invalid opts`);let n=VS(e,t.Z);if(!e.isOdd)throw Error(`Fp.isOdd is not implemented!`);return r=>{let i,a,o,s,c,l,u,d;i=e.sqr(r),i=e.mul(i,t.Z),a=e.sqr(i),a=e.add(a,i),o=e.add(a,e.ONE),o=e.mul(o,t.B),s=e.cmov(t.Z,e.neg(a),!e.eql(a,e.ZERO)),s=e.mul(s,t.A),a=e.sqr(o),l=e.sqr(s),c=e.mul(l,t.A),a=e.add(a,c),a=e.mul(a,o),l=e.mul(l,s),c=e.mul(l,t.B),a=e.add(a,c),u=e.mul(i,o);let{isValid:f,value:p}=n(a,l);d=e.mul(i,r),d=e.mul(d,p),u=e.cmov(u,o,f),d=e.cmov(d,p,f);let m=e.isOdd(r)===e.isOdd(d);return d=e.cmov(e.neg(d),d,m),u=e.div(u,s),{x:u,y:d}}}function US(e){if(e instanceof Uint8Array)return e;if(typeof e==`string`)return Kx(e);throw Error(`DST must be Uint8Array or string`)}var WS=Rx;function GS(e,t){if(e<0||e>=1<<8*t)throw Error(`bad I2OSP call: value=${e} length=${t}`);let n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function KS(e,t){let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function qS(e){if(!(e instanceof Uint8Array))throw Error(`Uint8Array expected`)}function JS(e){if(!Number.isSafeInteger(e))throw Error(`number expected`)}function YS(e,t,n,r){qS(e),qS(t),JS(n),t.length>255&&(t=r(Wx(Kx(`H2C-OVERSIZE-DST-`),t)));let{outputLen:i,blockLen:a}=r,o=Math.ceil(n/i);if(o>255)throw Error(`Invalid xmd length`);let s=Wx(t,GS(t.length,1)),c=GS(0,a),l=GS(n,2),u=Array(o),d=r(Wx(c,e,l,GS(0,1),s));u[0]=r(Wx(d,GS(1,1),s));for(let e=1;e<=o;e++)u[e]=r(Wx(KS(d,u[e-1]),GS(e+1,1),s));return Wx(...u).slice(0,n)}function XS(e,t,n,r,i){if(qS(e),qS(t),JS(n),t.length>255){let e=Math.ceil(2*r/8);t=i.create({dkLen:e}).update(Kx(`H2C-OVERSIZE-DST-`)).update(t).digest()}if(n>65535||t.length>255)throw Error(`expand_message_xof: invalid lenInBytes`);return i.create({dkLen:n}).update(e).update(GS(n,2)).update(t).update(GS(t.length,1)).digest()}function ZS(e,t,n){tS(n,{DST:`stringOrUint8Array`,p:`bigint`,m:`isSafeInteger`,k:`isSafeInteger`,hash:`hash`});let{p:r,k:i,m:a,hash:o,expand:s,DST:c}=n;qS(e),JS(t);let l=US(c),u=r.toString(2).length,d=Math.ceil((u+i)/8),f=t*a*d,p;if(s===`xmd`)p=YS(e,l,f,o);else if(s===`xof`)p=XS(e,l,f,i,o);else if(s===`_internal_pass`)p=e;else throw Error(`expand must be "xmd" or "xof"`);let m=Array(t);for(let e=0;e<t;e++){let t=Array(a);for(let n=0;n<a;n++){let i=d*(n+e*a);t[n]=uS(WS(p.subarray(i,i+d)),r)}m[e]=t}return m}function QS(e,t){let n=t.map(e=>Array.from(e).reverse());return(t,r)=>{let[i,a,o,s]=n.map(n=>n.reduce((n,r)=>e.add(e.mul(n,t),r)));return t=e.div(i,a),r=e.mul(r,e.div(o,s)),{x:t,y:r}}}function $S(e,t,n){if(typeof t!=`function`)throw Error(`mapToCurve() must be defined`);return{hashToCurve(r,i){let a=ZS(r,2,{...n,DST:n.DST,...i}),o=e.fromAffine(t(a[0])),s=e.fromAffine(t(a[1])),c=o.add(s).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){let a=ZS(r,1,{...n,DST:n.encodeDST,...i}),o=e.fromAffine(t(a[0])).clearCofactor();return o.assertValidity(),o}}}function eC(e){return{hash:e,hmac:(t,...n)=>_b(e,t,fb(...n)),randomBytes:hb}}function tC(e,t){let n=t=>BS({...e,...eC(t)});return Object.freeze({...n(t),create:n})}var nC=BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),rC=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),iC=BigInt(1),aC=BigInt(2),oC=(e,t)=>(e+t/aC)/t;function sC(e){let t=nC,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=fS(fS(fS(u,n,t)*u%t,n,t)*u%t,aC,t)*l%t,f=fS(d,i,t)*d%t,p=fS(f,a,t)*f%t,m=fS(p,s,t)*p%t,h=fS(fS(fS(fS(fS(fS(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,aC,t);if(!cC.eql(cC.sqr(h),e))throw Error(`Cannot find square root`);return h}var cC=xS(nC,void 0,void 0,{sqrt:sC}),lC=tC({a:BigInt(0),b:BigInt(7),Fp:cC,n:rC,Gx:BigInt(`55066263022277343669578718895168534326250603453777594175500187360389116729240`),Gy:BigInt(`32670510020758816978083085130507043184471273380659243275938904335757337482424`),h:BigInt(1),lowS:!0,endo:{beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),splitScalar:e=>{let t=rC,n=BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),r=-iC*BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`),i=BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),a=n,o=BigInt(`0x100000000000000000000000000000000`),s=oC(a*e,t),c=oC(-r*e,t),l=uS(e-s*n-c*i,t),u=uS(-s*r-c*a,t),d=l>o,f=u>o;if(d&&(l=t-l),f&&(u=t-u),l>o||u>o)throw Error(`splitScalar: Endomorphism failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},Eb);lC.ProjectivePoint,lC.utils.randomPrivateKey;var uC=QS(cC,[[`0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7`,`0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581`,`0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262`,`0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c`],[`0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b`,`0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14`,`0x0000000000000000000000000000000000000000000000000000000000000001`],[`0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c`,`0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3`,`0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931`,`0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84`],[`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b`,`0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573`,`0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f`,`0x0000000000000000000000000000000000000000000000000000000000000001`]].map(e=>e.map(e=>BigInt(e)))),dC=HS(cC,{A:BigInt(`0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533`),B:BigInt(`1771`),Z:cC.create(BigInt(`-11`))}),fC=$S(lC.ProjectivePoint,e=>{let{x:t,y:n}=dC(cC.create(e[0]));return uC(t,n)},{DST:`secp256k1_XMD:SHA-256_SSWU_RO_`,encodeDST:`secp256k1_XMD:SHA-256_SSWU_NU_`,p:cC.ORDER,m:1,k:128,expand:`xmd`,hash:Eb});fC.hashToCurve,fC.encodeToCurve;var pC=`0x0000000000000000000000000000000000000000`,mC=`0x0000000000000000000000000000000000000000000000000000000000000000`,hC=BigInt(0),gC=BigInt(1),_C=BigInt(2),vC=BigInt(27),yC=BigInt(28),bC=BigInt(35),xC=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),SC=xC/_C,CC=Symbol.for(`nodejs.util.inspect.custom`),wC={};function TC(e){return zv(Qv(e),32)}var EC=class e{#e;#t;#n;#r;get r(){return this.#e}set r(e){q(Iv(e)===32,`invalid r`,`value`,e),this.#e=Y(e)}get s(){return q(parseInt(this.#t.substring(0,3))<8,`non-canonical s; use ._s`,`s`,this.#t),this.#t}set s(e){q(Iv(e)===32,`invalid s`,`value`,e),this.#t=Y(e)}get _s(){return this.#t}isValid(){return BigInt(this.#t)<=SC}get v(){return this.#n}set v(e){let t=Z(e,`value`);q(t===27||t===28,`invalid v`,`v`,e),this.#n=t}get networkV(){return this.#r}get legacyChainId(){let t=this.networkV;return t==null?null:e.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){let e=J(this.s);return this.yParity&&(e[0]|=128),Y(e)}get compactSerialized(){return Fv([this.r,this.yParityAndS])}get serialized(){return Fv([this.r,this.s,this.yParity?`0x1c`:`0x1b`])}constructor(e,t,n,r){kv(e,wC,`Signature`),this.#e=t,this.#t=n,this.#n=r,this.#r=null}getCanonical(){if(this.isValid())return this;let t=xC-BigInt(this._s),n=55-this.v,r=new e(wC,this.r,TC(t),n);return this.networkV&&(r.#r=this.networkV),r}clone(){let t=new e(wC,this.r,this._s,this.v);return this.networkV&&(t.#r=this.networkV),t}toJSON(){let e=this.networkV;return{_type:`signature`,networkV:e==null?null:e.toString(),r:this.r,s:this._s,v:this.v}}[CC](){return this.toString()}toString(){return this.isValid()?`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v} }`:`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v}, valid: false }`}static getChainId(e){let t=X(e,`v`);return t==vC||t==yC?hC:(q(t>=bC,`invalid EIP-155 v`,`v`,e),(t-bC)/_C)}static getChainIdV(e,t){return X(e)*_C+BigInt(35+t-27)}static getNormalizedV(e){let t=X(e);return t===hC||t===vC?27:t===gC||t===yC?28:(q(t>=bC,`invalid v`,`v`,e),t&gC?27:28)}static from(t){function n(e,n){q(e,n,`signature`,t)}if(t==null)return new e(wC,mC,mC,27);if(typeof t==`string`){let r=J(t,`signature`);if(r.length===64){let t=Y(r.slice(0,32)),n=r.slice(32,64),i=n[0]&128?28:27;return n[0]&=127,new e(wC,t,Y(n),i)}if(r.length===65)return new e(wC,Y(r.slice(0,32)),Y(r.slice(32,64)),e.getNormalizedV(r[64]));n(!1,`invalid raw signature length`)}if(t instanceof e)return t.clone();let r=t.r;n(r!=null,`missing r`);let i=TC(r),a=(function(e,t){if(e!=null)return TC(e);if(t!=null){n(Mv(t,32),`invalid yParityAndS`);let e=J(t);return e[0]&=127,Y(e)}n(!1,`missing s`)})(t.s,t.yParityAndS),{networkV:o,v:s}=(function(t,r,i){if(t!=null){let n=X(t);return{networkV:n>=bC?n:void 0,v:e.getNormalizedV(n)}}if(r!=null)return n(Mv(r,32),`invalid yParityAndS`),{v:J(r)[0]&128?28:27};if(i!=null){switch(Z(i,`sig.yParity`)){case 0:return{v:27};case 1:return{v:28}}n(!1,`invalid yParity`)}n(!1,`missing v`)})(t.v,t.yParityAndS,t.yParity),c=new e(wC,i,a,s);return o&&(c.#r=o),n(t.yParity==null||Z(t.yParity,`sig.yParity`)===c.yParity,`yParity mismatch`),n(t.yParityAndS==null||t.yParityAndS===c.yParityAndS,`yParityAndS mismatch`),c}},DC=class e{#e;constructor(e){q(Iv(e)===32,`invalid private key`,`privateKey`,`[REDACTED]`),this.#e=Y(e)}get privateKey(){return this.#e}get publicKey(){return e.computePublicKey(this.#e)}get compressedPublicKey(){return e.computePublicKey(this.#e,!0)}sign(e){q(Iv(e)===32,`invalid digest length`,`digest`,e);let t=lC.sign(jv(e),jv(this.#e),{lowS:!0});return EC.from({r:Zv(t.r,32),s:Zv(t.s,32),v:t.recovery?28:27})}computeSharedSecret(t){let n=e.computePublicKey(t);return Y(lC.getSharedSecret(jv(this.#e),J(n),!1))}static computePublicKey(e,t){let n=J(e,`key`);if(n.length===32)return Y(lC.getPublicKey(n,!!t));if(n.length===64){let e=new Uint8Array(65);e[0]=4,e.set(n,1),n=e}return Y(lC.ProjectivePoint.fromHex(n).toRawBytes(t))}static recoverPublicKey(e,t){q(Iv(e)===32,`invalid digest length`,`digest`,e);let n=EC.from(t),r=lC.Signature.fromCompact(jv(Fv([n.r,n.s])));r=r.addRecoveryBit(n.yParity);let i=r.recoverPublicKey(jv(e));return q(i!=null,`invalid signature for digest`,`signature`,t),`0x`+i.toHex(!1)}static addPoints(t,n,r){let i=lC.ProjectivePoint.fromHex(e.computePublicKey(t).substring(2)),a=lC.ProjectivePoint.fromHex(e.computePublicKey(n).substring(2));return`0x`+i.add(a).toHex(!!r)}},OC=BigInt(0),kC=BigInt(36);function AC(e){e=e.toLowerCase();let t=e.substring(2).split(``),n=new Uint8Array(40);for(let e=0;e<40;e++)n[e]=t[e].charCodeAt(0);let r=J(yx(n));for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&(t[e]=t[e].toUpperCase()),(r[e>>1]&15)>=8&&(t[e+1]=t[e+1].toUpperCase());return`0x`+t.join(``)}var jC={};for(let e=0;e<10;e++)jC[String(e)]=String(e);for(let e=0;e<26;e++)jC[String.fromCharCode(65+e)]=String(10+e);var MC=15;function NC(e){e=e.toUpperCase(),e=e.substring(4)+e.substring(0,2)+`00`;let t=e.split(``).map(e=>jC[e]).join(``);for(;t.length>=MC;){let e=t.substring(0,MC);t=parseInt(e,10)%97+t.substring(e.length)}let n=String(98-parseInt(t,10)%97);for(;n.length<2;)n=`0`+n;return n}var PC=(function(){let e={};for(let t=0;t<36;t++){let n=`0123456789abcdefghijklmnopqrstuvwxyz`[t];e[n]=BigInt(t)}return e})();function FC(e){e=e.toLowerCase();let t=OC;for(let n=0;n<e.length;n++)t=t*kC+PC[e[n]];return t}function IC(e){if(q(typeof e==`string`,`invalid address`,`address`,e),e.match(/^(0x)?[0-9a-fA-F]{40}$/)){e.startsWith(`0x`)||(e=`0x`+e);let t=AC(e);return q(!e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===e,`bad address checksum`,`address`,e),t}if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){q(e.substring(2,4)===NC(e),`bad icap checksum`,`address`,e);let t=FC(e.substring(4)).toString(16);for(;t.length<40;)t=`0`+t;return AC(`0x`+t)}q(!1,`invalid address`,`address`,e)}function LC(e){let t=IC(e.from),n=X(e.nonce,`tx.nonce`).toString(16);return n=n===`0`?`0x`:n.length%2?`0x0`+n:`0x`+n,IC(Lv(yx(By([t,n])),12))}function RC(e){return e&&typeof e.getAddress==`function`}async function zC(e,t){let n=await t;return(n==null||n===`0x0000000000000000000000000000000000000000`)&&(K(typeof e!=`string`,`unconfigured name`,`UNCONFIGURED_NAME`,{value:e}),q(!1,`invalid AddressLike value; did not resolve to a value address`,`target`,e)),IC(n)}function BC(e,t){if(typeof e==`string`)return e.match(/^0x[0-9a-f]{40}$/i)?IC(e):(K(t!=null,`ENS resolution requires a provider`,`UNSUPPORTED_OPERATION`,{operation:`resolveName`}),zC(e,t.resolveName(e)));if(RC(e))return zC(e,e.getAddress());if(e&&typeof e.then==`function`)return zC(e,e);q(!1,`unsupported addressable value`,`target`,e)}var VC={};function $(e,t){let n=!1;return t<0&&(n=!0,t*=-1),new WC(VC,`${n?``:`u`}int${t}`,e,{signed:n,width:t})}function HC(e,t){return new WC(VC,`bytes${t||``}`,e,{size:t})}var UC=Symbol.for(`_ethers_typed`),WC=class e{type;value;#e;_typedSymbol;constructor(e,t,n,r){r??=null,kv(VC,e,`Typed`),G(this,{_typedSymbol:UC,type:t,value:n}),this.#e=r,this.format()}format(){if(this.type===`array`||this.type===`dynamicArray`)throw Error(``);return this.type===`tuple`?`tuple(${this.value.map(e=>e.format()).join(`,`)})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith(`bytes`)}isString(){return this.type===`string`}get tupleName(){if(this.type!==`tuple`)throw TypeError(`not a tuple`);return this.#e}get arrayLength(){if(this.type!==`array`)throw TypeError(`not an array`);return this.#e===!0?-1:this.#e===!1?this.value.length:null}static from(t,n){return new e(VC,t,n)}static uint8(e){return $(e,8)}static uint16(e){return $(e,16)}static uint24(e){return $(e,24)}static uint32(e){return $(e,32)}static uint40(e){return $(e,40)}static uint48(e){return $(e,48)}static uint56(e){return $(e,56)}static uint64(e){return $(e,64)}static uint72(e){return $(e,72)}static uint80(e){return $(e,80)}static uint88(e){return $(e,88)}static uint96(e){return $(e,96)}static uint104(e){return $(e,104)}static uint112(e){return $(e,112)}static uint120(e){return $(e,120)}static uint128(e){return $(e,128)}static uint136(e){return $(e,136)}static uint144(e){return $(e,144)}static uint152(e){return $(e,152)}static uint160(e){return $(e,160)}static uint168(e){return $(e,168)}static uint176(e){return $(e,176)}static uint184(e){return $(e,184)}static uint192(e){return $(e,192)}static uint200(e){return $(e,200)}static uint208(e){return $(e,208)}static uint216(e){return $(e,216)}static uint224(e){return $(e,224)}static uint232(e){return $(e,232)}static uint240(e){return $(e,240)}static uint248(e){return $(e,248)}static uint256(e){return $(e,256)}static uint(e){return $(e,256)}static int8(e){return $(e,-8)}static int16(e){return $(e,-16)}static int24(e){return $(e,-24)}static int32(e){return $(e,-32)}static int40(e){return $(e,-40)}static int48(e){return $(e,-48)}static int56(e){return $(e,-56)}static int64(e){return $(e,-64)}static int72(e){return $(e,-72)}static int80(e){return $(e,-80)}static int88(e){return $(e,-88)}static int96(e){return $(e,-96)}static int104(e){return $(e,-104)}static int112(e){return $(e,-112)}static int120(e){return $(e,-120)}static int128(e){return $(e,-128)}static int136(e){return $(e,-136)}static int144(e){return $(e,-144)}static int152(e){return $(e,-152)}static int160(e){return $(e,-160)}static int168(e){return $(e,-168)}static int176(e){return $(e,-176)}static int184(e){return $(e,-184)}static int192(e){return $(e,-192)}static int200(e){return $(e,-200)}static int208(e){return $(e,-208)}static int216(e){return $(e,-216)}static int224(e){return $(e,-224)}static int232(e){return $(e,-232)}static int240(e){return $(e,-240)}static int248(e){return $(e,-248)}static int256(e){return $(e,-256)}static int(e){return $(e,-256)}static bytes1(e){return HC(e,1)}static bytes2(e){return HC(e,2)}static bytes3(e){return HC(e,3)}static bytes4(e){return HC(e,4)}static bytes5(e){return HC(e,5)}static bytes6(e){return HC(e,6)}static bytes7(e){return HC(e,7)}static bytes8(e){return HC(e,8)}static bytes9(e){return HC(e,9)}static bytes10(e){return HC(e,10)}static bytes11(e){return HC(e,11)}static bytes12(e){return HC(e,12)}static bytes13(e){return HC(e,13)}static bytes14(e){return HC(e,14)}static bytes15(e){return HC(e,15)}static bytes16(e){return HC(e,16)}static bytes17(e){return HC(e,17)}static bytes18(e){return HC(e,18)}static bytes19(e){return HC(e,19)}static bytes20(e){return HC(e,20)}static bytes21(e){return HC(e,21)}static bytes22(e){return HC(e,22)}static bytes23(e){return HC(e,23)}static bytes24(e){return HC(e,24)}static bytes25(e){return HC(e,25)}static bytes26(e){return HC(e,26)}static bytes27(e){return HC(e,27)}static bytes28(e){return HC(e,28)}static bytes29(e){return HC(e,29)}static bytes30(e){return HC(e,30)}static bytes31(e){return HC(e,31)}static bytes32(e){return HC(e,32)}static address(t){return new e(VC,`address`,t)}static bool(t){return new e(VC,`bool`,!!t)}static bytes(t){return new e(VC,`bytes`,t)}static string(t){return new e(VC,`string`,t)}static array(e,t){throw Error(`not implemented yet`)}static tuple(e,t){throw Error(`not implemented yet`)}static overrides(t){return new e(VC,`overrides`,Object.assign({},t))}static isTyped(e){return e&&typeof e==`object`&&`_typedSymbol`in e&&e._typedSymbol===UC}static dereference(t,n){if(e.isTyped(t)){if(t.type!==n)throw Error(`invalid type: expecetd ${n}, got ${t.type}`);return t.value}return t}},GC=class extends Zy{constructor(e){super(`address`,`address`,e,!1)}defaultValue(){return`0x0000000000000000000000000000000000000000`}encode(e,t){let n=WC.dereference(t,`string`);try{n=IC(n)}catch(e){return this._throwError(e.message,t)}return e.writeValue(n)}decode(e){return IC(Zv(e.readValue(),20))}},KC=class extends Zy{coder;constructor(e){super(e.name,e.type,`_`,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}};function qC(e,t,n){let r=[];if(Array.isArray(n))r=n;else if(n&&typeof n==`object`){let e={};r=t.map(t=>{let r=t.localName;return K(r,`cannot encode object for signature with missing names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),K(!e[r],`cannot encode object for signature with duplicate names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),e[r]=!0,n[r]})}else q(!1,`invalid tuple value`,`tuple`,n);q(t.length===r.length,`types/value length mismatch`,`tuple`,n);let i=new Qy,a=new Qy,o=[];t.forEach((e,t)=>{let n=r[t];if(e.dynamic){let t=a.length;e.encode(a,n);let r=i.writeUpdatableValue();o.push(e=>{r(e+t)})}else e.encode(i,n)}),o.forEach(e=>{e(i.length)});let s=e.appendWriter(i);return s+=e.appendWriter(a),s}function JC(e,t){let n=[],r=[],i=e.subReader(0);return t.forEach(t=>{let a=null;if(t.dynamic){let n=e.readIndex(),r=i.subReader(n);try{a=t.decode(r)}catch(e){if(Cv(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}}else try{a=t.decode(e)}catch(e){if(Cv(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}if(a==null)throw Error(`investigate`);n.push(a),r.push(t.localName||null)}),Yy.fromItems(n,r)}var YC=class extends Zy{coder;length;constructor(e,t,n){let r=e.type+`[`+(t>=0?t:``)+`]`,i=t===-1||e.dynamic;super(`array`,r,n,i),G(this,{coder:e,length:t})}defaultValue(){let e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){let n=WC.dereference(t,`array`);Array.isArray(n)||this._throwError(`expected array value`,n);let r=this.length;r===-1&&(r=n.length,e.writeValue(n.length)),Ev(n.length,r,`coder array`+(this.localName?` `+this.localName:``));let i=[];for(let e=0;e<n.length;e++)i.push(this.coder);return qC(e,i,n)}decode(e){let t=this.length;t===-1&&(t=e.readIndex(),K(t*32<=e.dataLength,`insufficient data length`,`BUFFER_OVERRUN`,{buffer:e.bytes,offset:t*32,length:e.dataLength}));let n=[];for(let e=0;e<t;e++)n.push(new KC(this.coder));return JC(e,n)}},XC=class extends Zy{constructor(e){super(`bool`,`bool`,e,!1)}defaultValue(){return!1}encode(e,t){let n=WC.dereference(t,`bool`);return e.writeValue(+!!n)}decode(e){return!!e.readValue()}},ZC=class extends Zy{constructor(e,t){super(e,e,t,!0)}defaultValue(){return`0x`}encode(e,t){t=jv(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}},QC=class extends ZC{constructor(e){super(`bytes`,e)}decode(e){return Y(super.decode(e))}},$C=class extends Zy{size;constructor(e,t){let n=`bytes`+String(e);super(n,n,t,!1),G(this,{size:e},{size:`number`})}defaultValue(){return`0x0000000000000000000000000000000000000000000000000000000000000000`.substring(0,2+this.size*2)}encode(e,t){let n=jv(WC.dereference(t,this.type));return n.length!==this.size&&this._throwError(`incorrect data length`,t),e.writeBytes(n)}decode(e){return Y(e.readBytes(this.size))}},ew=new Uint8Array([]),tw=class extends Zy{constructor(e){super(`null`,``,e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError(`not null`,t),e.writeBytes(ew)}decode(e){return e.readBytes(0),null}},nw=BigInt(0),rw=BigInt(1),iw=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),aw=class extends Zy{size;signed;constructor(e,t,n){let r=(t?`int`:`uint`)+e*8;super(r,r,n,!1),G(this,{size:e,signed:t},{size:`number`,signed:`boolean`})}defaultValue(){return 0}encode(e,t){let n=X(WC.dereference(t,this.type)),r=Kv(iw,256);if(this.signed){let e=Kv(r,this.size*8-1);(n>e||n<-(e+rw))&&this._throwError(`value out-of-bounds`,t),n=Gv(n,256)}else (n<nw||n>Kv(r,this.size*8))&&this._throwError(`value out-of-bounds`,t);return e.writeValue(n)}decode(e){let t=Kv(e.readValue(),this.size*8);return this.signed&&(t=Wv(t,this.size*8)),t}},ow=class extends ZC{constructor(e){super(`string`,e)}defaultValue(){return``}encode(e,t){return super.encode(e,dy(WC.dereference(t,`string`)))}decode(e){return py(super.decode(e))}},sw=class extends Zy{coders;constructor(e,t){let n=!1,r=[];e.forEach(e=>{e.dynamic&&(n=!0),r.push(e.type)});let i=`tuple(`+r.join(`,`)+`)`;super(`tuple`,i,t,n),G(this,{coders:Object.freeze(e.slice())})}defaultValue(){let e=[];this.coders.forEach(t=>{e.push(t.defaultValue())});let t=this.coders.reduce((e,t)=>{let n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e},{});return this.coders.forEach((n,r)=>{let i=n.localName;!i||t[i]!==1||(i===`length`&&(i=`_length`),e[i]??(e[i]=e[r]))}),Object.freeze(e)}encode(e,t){let n=WC.dereference(t,`tuple`);return qC(e,this.coders,n)}decode(e){return JC(e,this.coders)}};function cw(e,t){return{address:IC(e),storageKeys:t.map((e,t)=>(q(Mv(e,32),`invalid slot`,`storageKeys[${t}]`,e),e.toLowerCase()))}}function lw(e){if(Array.isArray(e))return e.map((t,n)=>Array.isArray(t)?(q(t.length===2,`invalid slot set`,`value[${n}]`,t),cw(t[0],t[1])):(q(typeof t==`object`&&!!t,`invalid address-slot set`,`value`,e),cw(t.address,t.storageKeys)));q(typeof e==`object`&&!!e,`invalid access list`,`value`,e);let t=Object.keys(e).map(t=>{let n=e[t].reduce((e,t)=>(e[t]=!0,e),{});return cw(t,Object.keys(n).sort())});return t.sort((e,t)=>e.address.localeCompare(t.address)),t}function uw(e){return{address:IC(e.address),nonce:X(e.nonce==null?0:e.nonce),chainId:X(e.chainId==null?0:e.chainId),signature:EC.from(e.signature)}}function dw(e){let t;return t=typeof e==`string`?DC.computePublicKey(e,!1):e.publicKey,IC(yx(`0x`+t.substring(4)).substring(26))}function fw(e,t){return dw(DC.recoverPublicKey(e,t))}var pw=BigInt(0),mw=BigInt(2),hw=BigInt(27),gw=BigInt(28),_w=BigInt(35),vw=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),yw=Symbol.for(`nodejs.util.inspect.custom`),bw=4096*32,xw=128;function Sw(e){return{blobToKzgCommitment:t=>{if(`computeBlobProof`in e){if(`blobToKzgCommitment`in e&&typeof e.blobToKzgCommitment==`function`)return J(e.blobToKzgCommitment(Y(t)))}else if(`blobToKzgCommitment`in e&&typeof e.blobToKzgCommitment==`function`)return J(e.blobToKzgCommitment(t));if(`blobToKZGCommitment`in e&&typeof e.blobToKZGCommitment==`function`)return J(e.blobToKZGCommitment(Y(t)));q(!1,`unsupported KZG library`,`kzg`,e)},computeBlobKzgProof:(t,n)=>{if(`computeBlobProof`in e&&typeof e.computeBlobProof==`function`)return J(e.computeBlobProof(Y(t),Y(n)));if(`computeBlobKzgProof`in e&&typeof e.computeBlobKzgProof==`function`)return e.computeBlobKzgProof(t,n);if(`computeBlobKZGProof`in e&&typeof e.computeBlobKZGProof==`function`)return J(e.computeBlobKZGProof(Y(t),Y(n)));q(!1,`unsupported KZG library`,`kzg`,e)}}}function Cw(e,t){let n=e.toString(16);for(;n.length<2;)n=`0`+n;return n+=Ex(t).substring(4),`0x`+n}function ww(e){return e===`0x`?null:IC(e)}function Tw(e,t){try{return lw(e)}catch(n){q(!1,n.message,t,e)}}function Ew(e,t){try{if(!Array.isArray(e))throw Error(`authorizationList: invalid array`);let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(!Array.isArray(r))throw Error(`authorization[${n}]: invalid array`);if(r.length!==6)throw Error(`authorization[${n}]: wrong length`);if(!r[1])throw Error(`authorization[${n}]: null address`);t.push({address:ww(r[1]),nonce:Ow(r[2],`nonce`),chainId:Ow(r[0],`chainId`),signature:EC.from({yParity:Dw(r[3],`yParity`),r:zv(r[4],32),s:zv(r[5],32)})})}return t}catch(n){q(!1,n.message,t,e)}}function Dw(e,t){return e===`0x`?0:Z(e,t)}function Ow(e,t){if(e===`0x`)return pw;let n=X(e,t);return q(n<=vw,`value exceeds uint size`,t,n),n}function kw(e,t){let n=X(e,`value`),r=Qv(n);return q(r.length<=32,`value too large`,`tx.${t}`,n),r}function Aw(e){return lw(e).map(e=>[e.address,e.storageKeys])}function jw(e){return e.map(e=>[kw(e.chainId,`chainId`),e.address,kw(e.nonce,`nonce`),kw(e.signature.yParity,`yParity`),Qv(e.signature.r),Qv(e.signature._s)])}function Mw(e,t){q(Array.isArray(e),`invalid ${t}`,`value`,e);for(let t=0;t<e.length;t++)q(Mv(e[t],32),"invalid ${ param } hash",`value[${t}]`,e[t]);return e}function Nw(e){let t=Iy(e);q(Array.isArray(t)&&(t.length===9||t.length===6),`invalid field count for legacy transaction`,`data`,e);let n={type:0,nonce:Dw(t[0],`nonce`),gasPrice:Ow(t[1],`gasPrice`),gasLimit:Ow(t[2],`gasLimit`),to:ww(t[3]),value:Ow(t[4],`value`),data:Y(t[5]),chainId:pw};if(t.length===6)return n;let r=Ow(t[6],`v`),i=Ow(t[7],`r`),a=Ow(t[8],`s`);if(i===pw&&a===pw)n.chainId=r;else{let e=(r-_w)/mw;e<pw&&(e=pw),n.chainId=e,q(e!==pw||r===hw||r===gw,`non-canonical legacy v`,`v`,t[6]),n.signature=EC.from({r:zv(t[7],32),s:zv(t[8],32),v:r})}return n}function Pw(e,t){let n=[kw(e.nonce,`nonce`),kw(e.gasPrice||0,`gasPrice`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data],r=pw;if(e.chainId!=pw)r=X(e.chainId,`tx.chainId`),q(!t||t.networkV==null||t.legacyChainId===r,`tx.chainId/sig.v mismatch`,`sig`,t);else if(e.signature){let t=e.signature.legacyChainId;t!=null&&(r=t)}if(!t)return r!==pw&&(n.push(Qv(r)),n.push(`0x`),n.push(`0x`)),By(n);let i=BigInt(27+t.yParity);return r===pw?BigInt(t.v)!==i&&q(!1,`tx.chainId/sig.v mismatch`,`sig`,t):i=EC.getChainIdV(r,t.v),n.push(Qv(i)),n.push(Qv(t.r)),n.push(Qv(t._s)),By(n)}function Fw(e,t){let n;try{if(n=Dw(t[0],`yParity`),n!==0&&n!==1)throw Error(`bad yParity`)}catch{q(!1,`invalid yParity`,`yParity`,t[0])}let r=zv(t[1],32),i=zv(t[2],32);e.signature=EC.from({r,s:i,yParity:n})}function Iw(e){let t=Iy(J(e).slice(1));q(Array.isArray(t)&&(t.length===9||t.length===12),`invalid field count for transaction type: 2`,`data`,Y(e));let n={type:2,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),maxPriorityFeePerGas:Ow(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ow(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ow(t[4],`gasLimit`),to:ww(t[5]),value:Ow(t[6],`value`),data:Y(t[7]),accessList:Tw(t[8],`accessList`)};return t.length===9||Fw(n,t.slice(9)),n}function Lw(e,t){let n=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),kw(e.maxFeePerGas||0,`maxFeePerGas`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data,Aw(e.accessList||[])];return t&&(n.push(kw(t.yParity,`yParity`)),n.push(Qv(t.r)),n.push(Qv(t.s))),Fv([`0x02`,By(n)])}function Rw(e){let t=Iy(J(e).slice(1));q(Array.isArray(t)&&(t.length===8||t.length===11),`invalid field count for transaction type: 1`,`data`,Y(e));let n={type:1,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),gasPrice:Ow(t[2],`gasPrice`),gasLimit:Ow(t[3],`gasLimit`),to:ww(t[4]),value:Ow(t[5],`value`),data:Y(t[6]),accessList:Tw(t[7],`accessList`)};return t.length===8||Fw(n,t.slice(8)),n}function zw(e,t){let n=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.gasPrice||0,`gasPrice`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data,Aw(e.accessList||[])];return t&&(n.push(kw(t.yParity,`recoveryParam`)),n.push(Qv(t.r)),n.push(Qv(t.s))),Fv([`0x01`,By(n)])}function Bw(e){let t=Iy(J(e).slice(1)),n=`3`,r=null,i=null;if(t.length===4&&Array.isArray(t[0])){n=`3 (network format)`;let e=t[1],r=t[2],a=t[3];q(Array.isArray(e),`invalid network format: blobs not an array`,`fields[1]`,e),q(Array.isArray(r),`invalid network format: commitments not an array`,`fields[2]`,r),q(Array.isArray(a),`invalid network format: proofs not an array`,`fields[3]`,a),q(e.length===r.length,`invalid network format: blobs/commitments length mismatch`,`fields`,t),q(e.length===a.length,`invalid network format: blobs/proofs length mismatch`,`fields`,t),i=[];for(let n=0;n<t[1].length;n++)i.push({data:e[n],commitment:r[n],proof:a[n]});t=t[0]}else if(t.length===5&&Array.isArray(t[0])){n=`3 (EIP-7594 network format)`,r=Z(t[1]);let e=t[2],a=t[3],o=t[4];q(r===1,`unsupported EIP-7594 network format version: ${r}`,`fields[1]`,r),q(Array.isArray(e),`invalid EIP-7594 network format: blobs not an array`,`fields[2]`,e),q(Array.isArray(a),`invalid EIP-7594 network format: commitments not an array`,`fields[3]`,a),q(Array.isArray(o),`invalid EIP-7594 network format: proofs not an array`,`fields[4]`,o),q(e.length===a.length,`invalid network format: blobs/commitments length mismatch`,`fields`,t),q(e.length*xw===o.length,`invalid network format: blobs/proofs length mismatch`,`fields`,t),i=[];for(let t=0;t<e.length;t++){let n=[];for(let e=0;e<xw;e++)n.push(o[t*xw+e]);i.push({data:e[t],commitment:a[t],proof:Fv(n)})}t=t[0]}q(Array.isArray(t)&&(t.length===11||t.length===14),`invalid field count for transaction type: ${n}`,`data`,Y(e));let a={type:3,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),maxPriorityFeePerGas:Ow(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ow(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ow(t[4],`gasLimit`),to:ww(t[5]),value:Ow(t[6],`value`),data:Y(t[7]),accessList:Tw(t[8],`accessList`),maxFeePerBlobGas:Ow(t[9],`maxFeePerBlobGas`),blobVersionedHashes:t[10],blobWrapperVersion:r};i&&(a.blobs=i),q(a.to!=null,`invalid address for transaction type: ${n}`,`data`,e),q(Array.isArray(a.blobVersionedHashes),`invalid blobVersionedHashes: must be an array`,`data`,e);for(let t=0;t<a.blobVersionedHashes.length;t++)q(Mv(a.blobVersionedHashes[t],32),`invalid blobVersionedHash at index ${t}: must be length 32`,`data`,e);return t.length===11||Fw(a,t.slice(11)),a}function Vw(e,t,n){let r=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),kw(e.maxFeePerGas||0,`maxFeePerGas`),kw(e.gasLimit,`gasLimit`),e.to||`0x0000000000000000000000000000000000000000`,kw(e.value,`value`),e.data,Aw(e.accessList||[]),kw(e.maxFeePerBlobGas||0,`maxFeePerBlobGas`),Mw(e.blobVersionedHashes||[],`blobVersionedHashes`)];if(t&&(r.push(kw(t.yParity,`yParity`)),r.push(Qv(t.r)),r.push(Qv(t.s)),n)){if(e.blobWrapperVersion!=null){let t=Qv(e.blobWrapperVersion),i=[];for(let{proof:e}of n){let t=J(e),n=t.length/xw;for(let e=0;e<t.length;e+=n)i.push(t.subarray(e,e+n))}return Fv([`0x03`,By([r,t,n.map(e=>e.data),n.map(e=>e.commitment),i])])}return Fv([`0x03`,By([r,n.map(e=>e.data),n.map(e=>e.commitment),n.map(e=>e.proof)])])}return Fv([`0x03`,By(r)])}function Hw(e){let t=Iy(J(e).slice(1));q(Array.isArray(t)&&(t.length===10||t.length===13),`invalid field count for transaction type: 4`,`data`,Y(e));let n={type:4,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),maxPriorityFeePerGas:Ow(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ow(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ow(t[4],`gasLimit`),to:ww(t[5]),value:Ow(t[6],`value`),data:Y(t[7]),accessList:Tw(t[8],`accessList`),authorizationList:Ew(t[9],`authorizationList`)};return t.length===10||Fw(n,t.slice(10)),n}function Uw(e,t){let n=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),kw(e.maxFeePerGas||0,`maxFeePerGas`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data,Aw(e.accessList||[]),jw(e.authorizationList||[])];return t&&(n.push(kw(t.yParity,`yParity`)),n.push(Qv(t.r)),n.push(Qv(t.s))),Fv([`0x04`,By(n)])}var Ww=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;get type(){return this.#e}set type(e){switch(e){case null:this.#e=null;break;case 0:case`legacy`:this.#e=0;break;case 1:case`berlin`:case`eip-2930`:this.#e=1;break;case 2:case`london`:case`eip-1559`:this.#e=2;break;case 3:case`cancun`:case`eip-4844`:this.#e=3;break;case 4:case`pectra`:case`eip-7702`:this.#e=4;break;default:q(!1,`unsupported transaction type`,`type`,e)}}get typeName(){switch(this.type){case 0:return`legacy`;case 1:return`eip-2930`;case 2:return`eip-1559`;case 3:return`eip-4844`;case 4:return`eip-7702`}return null}get to(){let e=this.#t;return e==null&&this.type===3?pC:e}set to(e){this.#t=e==null?null:IC(e)}get nonce(){return this.#r}set nonce(e){this.#r=Z(e,`value`)}get gasLimit(){return this.#i}set gasLimit(e){this.#i=X(e)}get gasPrice(){let e=this.#a;return e==null&&(this.type===0||this.type===1)?pw:e}set gasPrice(e){this.#a=e==null?null:X(e,`gasPrice`)}get maxPriorityFeePerGas(){return this.#o??(this.type===2||this.type===3?pw:null)}set maxPriorityFeePerGas(e){this.#o=e==null?null:X(e,`maxPriorityFeePerGas`)}get maxFeePerGas(){return this.#s??(this.type===2||this.type===3?pw:null)}set maxFeePerGas(e){this.#s=e==null?null:X(e,`maxFeePerGas`)}get data(){return this.#n}set data(e){this.#n=Y(e)}get value(){return this.#c}set value(e){this.#c=X(e,`value`)}get chainId(){return this.#l}set chainId(e){this.#l=X(e)}get signature(){return this.#u||null}set signature(e){this.#u=e==null?null:EC.from(e)}isValid(){let e=this.signature;if(e&&!e.isValid())return!1;let t=this.authorizationList;if(t){for(let e of t)if(!e.signature.isValid())return!1}return!0}get accessList(){return(this.#d||null)??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){this.#d=e==null?null:lw(e)}get authorizationList(){let e=this.#g||null;return e==null&&this.type===4?[]:e}set authorizationList(e){this.#g=e==null?null:e.map(e=>uw(e))}get maxFeePerBlobGas(){let e=this.#f;return e==null&&this.type===3?pw:e}set maxFeePerBlobGas(e){this.#f=e==null?null:X(e,`maxFeePerBlobGas`)}get blobVersionedHashes(){let e=this.#p;return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){q(Array.isArray(e),`blobVersionedHashes must be an Array`,`value`,e),e=e.slice();for(let t=0;t<e.length;t++)q(Mv(e[t],32),`invalid blobVersionedHash`,`value[${t}]`,e[t])}this.#p=e}get blobs(){return this.#h==null?null:this.#h.map(e=>Object.assign({},e))}set blobs(e){if(e==null){this.#h=null;return}let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(Nv(i)){K(this.#m,`adding a raw blob requires a KZG library`,`UNSUPPORTED_OPERATION`,{operation:`set blobs()`});let e=J(i);if(q(e.length<=bw,`blob is too large`,`blobs[${r}]`,i),e.length!==bw){let t=new Uint8Array(bw);t.set(e),e=t}let a=this.#m.blobToKzgCommitment(e),o=Y(this.#m.computeBlobKzgProof(e,a));t.push({data:Y(e),commitment:Y(a),proof:o}),n.push(Cw(1,a))}else{let e=Y(i.data),r=Y(i.commitment),a=Y(i.proof);t.push({data:e,commitment:r,proof:a}),n.push(Cw(1,r))}}this.#h=t,this.#p=n}get kzg(){return this.#m}set kzg(e){e==null?this.#m=null:this.#m=Sw(e)}get blobWrapperVersion(){return this.#_}set blobWrapperVersion(e){this.#_=e}constructor(){this.#e=null,this.#t=null,this.#r=0,this.#i=pw,this.#a=null,this.#o=null,this.#s=null,this.#n=`0x`,this.#c=pw,this.#l=pw,this.#u=null,this.#d=null,this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null,this.#_=null}get hash(){return this.signature==null?null:yx(this.#v(!0,!1))}get unsignedHash(){return yx(this.unsignedSerialized)}get from(){return this.signature==null?null:fw(this.unsignedHash,this.signature.getCanonical())}get fromPublicKey(){return this.signature==null?null:DC.recoverPublicKey(this.unsignedHash,this.signature.getCanonical())}isSigned(){return this.signature!=null}#v(e,t){K(!e||this.signature!=null,`cannot serialize unsigned transaction; maybe you meant .unsignedSerialized`,`UNSUPPORTED_OPERATION`,{operation:`.serialized`});let n=e?this.signature:null;switch(this.inferType()){case 0:return Pw(this,n);case 1:return zw(this,n);case 2:return Lw(this,n);case 3:return Vw(this,n,t?this.blobs:null);case 4:return Uw(this,n)}K(!1,`unsupported transaction type`,`UNSUPPORTED_OPERATION`,{operation:`.serialized`})}get serialized(){return this.#v(!0,!0)}get unsignedSerialized(){return this.#v(!1,!1)}inferType(){let e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){let e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,r=this.#f!=null||this.#p;this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&K(this.maxFeePerGas>=this.maxPriorityFeePerGas,`priorityFee cannot be more than maxFee`,`BAD_DATA`,{value:this}),K(!t||this.type!==0&&this.type!==1,`transaction type cannot have maxFeePerGas or maxPriorityFeePerGas`,`BAD_DATA`,{value:this}),K(this.type!==0||!n,`legacy transaction cannot have accessList`,`BAD_DATA`,{value:this});let i=[];return this.type==null?this.authorizationList&&this.authorizationList.length?i.push(4):t?i.push(2):e?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):r&&this.to?i.push(3):(i.push(0),i.push(1),i.push(2),i.push(3)):i.push(this.type),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return e.from(this)}toJSON(){let e=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}[yw](){return this.toString()}toString(){let e=[],t=t=>{let n=this[t];typeof n==`string`&&(n=JSON.stringify(n)),e.push(`${t}: ${n}`)};this.type&&t(`type`),t(`to`),t(`data`),t(`nonce`),t(`gasLimit`),t(`value`),this.chainId!=null&&t(`chainId`),this.signature&&(t(`from`),e.push(`signature: ${this.signature.toString()}`));let n=this.authorizationList;if(n){let t=[];for(let e of n){let n=[];n.push(`address: ${JSON.stringify(e.address)}`),e.nonce!=null&&n.push(`nonce: ${e.nonce}`),e.chainId!=null&&n.push(`chainId: ${e.chainId}`),e.signature&&n.push(`signature: ${e.signature.toString()}`),t.push(`Authorization { ${n.join(`, `)} }`)}e.push(`authorizations: [ ${t.join(`, `)} ]`)}return`Transaction { ${e.join(`, `)} }`}static from(t){if(t==null)return new e;if(typeof t==`string`){let n=J(t);if(n[0]>=127)return e.from(Nw(n));switch(n[0]){case 1:return e.from(Rw(n));case 2:return e.from(Iw(n));case 3:return e.from(Bw(n));case 4:return e.from(Hw(n))}K(!1,`unsupported transaction type`,`UNSUPPORTED_OPERATION`,{operation:`from`})}let n=new e;return t.type!=null&&(n.type=t.type),t.to!=null&&(n.to=t.to),t.nonce!=null&&(n.nonce=t.nonce),t.gasLimit!=null&&(n.gasLimit=t.gasLimit),t.gasPrice!=null&&(n.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(n.maxFeePerGas=t.maxFeePerGas),t.maxFeePerBlobGas!=null&&(n.maxFeePerBlobGas=t.maxFeePerBlobGas),t.data!=null&&(n.data=t.data),t.value!=null&&(n.value=t.value),t.chainId!=null&&(n.chainId=t.chainId),t.signature!=null&&(n.signature=EC.from(t.signature)),t.accessList!=null&&(n.accessList=t.accessList),t.authorizationList!=null&&(n.authorizationList=t.authorizationList),t.blobVersionedHashes!=null&&(n.blobVersionedHashes=t.blobVersionedHashes),t.kzg!=null&&(n.kzg=t.kzg),t.blobWrapperVersion!=null&&(n.blobWrapperVersion=t.blobWrapperVersion),t.blobs!=null&&(n.blobs=t.blobs),t.hash!=null&&(q(n.isSigned(),`unsigned transaction cannot define '.hash'`,`tx`,t),q(n.hash===t.hash,`hash mismatch`,`tx`,t)),t.from!=null&&(q(n.isSigned(),`unsigned transaction cannot define '.from'`,`tx`,t),q(n.from.toLowerCase()===(t.from||``).toLowerCase(),`from mismatch`,`tx`,t)),n}};function Gw(e){return yx(dy(e))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eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI`,qw=new Map([[8217,`apostrophe`],[8260,`fraction slash`],[12539,`middle dot`]]),Jw=4;function Yw(e){let t=0;function n(){return e[t++]<<8|e[t++]}let r=n(),i=1,a=[0,1];for(let e=1;e<r;e++)a.push(i+=n());let o=n(),s=t;t+=o;let c=0,l=0;function u(){return c==0&&(l=l<<8|e[t++],c=8),l>>--c&1}let d=2**31,f=d>>>1,p=f>>1,m=d-1,h=0;for(let e=0;e<31;e++)h=h<<1|u();let g=[],_=0,v=d;for(;;){let e=Math.floor(((h-_+1)*i-1)/v),t=0,n=r;for(;n-t>1;){let r=t+n>>>1;e<a[r]?n=r:t=r}if(t==0)break;g.push(t);let o=_+Math.floor(v*a[t]/i),s=_+Math.floor(v*a[t+1]/i)-1;for(;((o^s)&f)==0;)h=h<<1&m|u(),o=o<<1&m,s=s<<1&m|1;for(;o&~s&p;)h=h&f|h<<1&m>>>1|u(),o=o<<1^f,s=(s^f)<<1|f|1;_=o,v=1+s-o}let y=r-4;return g.map(t=>{switch(t-y){case 3:return y+65792+(e[s++]<<16|e[s++]<<8|e[s++]);case 2:return y+256+(e[s++]<<8|e[s++]);case 1:return y+e[s++];default:return t-1}})}function Xw(e){let t=0;return()=>e[t++]}function Zw(e){return Xw(Yw(Qw(e)))}function Qw(e){let t=[];[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`].forEach((e,n)=>t[e.charCodeAt(0)]=n);let n=e.length,r=new Uint8Array(6*n>>3);for(let i=0,a=0,o=0,s=0;i<n;i++)s=s<<6|t[e.charCodeAt(i)],o+=6,o>=8&&(r[a++]=s>>(o-=8));return r}function $w(e){return e&1?~e>>1:e>>1}function eT(e,t){let n=Array(e);for(let r=0,i=0;r<e;r++)n[r]=i+=$w(t());return n}function tT(e,t=0){let n=[];for(;;){let r=e(),i=e();if(!i)break;t+=r;for(let e=0;e<i;e++)n.push(t+e);t+=i+1}return n}function nT(e){return iT(()=>{let t=tT(e);if(t.length)return t})}function rT(e){let t=[];for(;;){let n=e();if(n==0)break;t.push(oT(n,e))}for(;;){let n=e()-1;if(n<0)break;t.push(sT(n,e))}return t.flat()}function iT(e){let t=[];for(;;){let n=e(t.length);if(!n)break;t.push(n)}return t}function aT(e,t,n){let r=Array(e).fill().map(()=>[]);for(let i=0;i<t;i++)eT(e,n).forEach((e,t)=>r[t].push(e));return r}function oT(e,t){let n=1+t(),r=t(),i=iT(t);return aT(i.length,1+e,t).flatMap((e,t)=>{let[a,...o]=e;return Array(i[t]).fill().map((e,t)=>{let i=t*r;return[a+t*n,o.map(e=>e+i)]})})}function sT(e,t){return aT(1+t(),1+e,t).map(e=>[e[0],e.slice(1)])}function cT(e){let t=[],n=tT(e);return i(r([]),[]),t;function r(t){return{S:e(),B:iT(()=>{let t=tT(e).map(e=>n[e]);if(t.length)return r(t)}),Q:t}}function i({S:e,B:n},r,a){if(!(e&4&&a===r[r.length-1])){e&2&&(a=r[r.length-1]),e&1&&t.push(r);for(let e of n)for(let t of e.Q)i(e,[...r,t],a)}}}function lT(e){return e.toString(16).toUpperCase().padStart(2,`0`)}function uT(e){return`{${lT(e)}}`}function dT(e){let t=[];for(let n=0,r=e.length;n<r;){let r=e.codePointAt(n);n+=r<65536?1:2,t.push(r)}return t}function fT(e){let t=4096,n=e.length;if(n<t)return String.fromCodePoint(...e);let r=[];for(let i=0;i<n;)r.push(String.fromCodePoint(...e.slice(i,i+=t)));return r.join(``)}function pT(e,t){let n=e.length,r=n-t.length;for(let i=0;r==0&&i<n;i++)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,ET=vT+xT;function DT(e){return e>>24&255}function OT(e){return e&16777215}var kT,AT,jT,MT;function NT(){let e=Zw(mT);kT=new Map(nT(e).flatMap((e,t)=>e.map(e=>[e,t+1<<24]))),AT=new Set(tT(e)),jT=new Map,MT=new Map;for(let[t,n]of rT(e)){if(!AT.has(t)&&n.length==2){let[e,r]=n,i=MT.get(e);i||(i=new Map,MT.set(e,i)),i.set(r,t)}jT.set(t,n.reverse())}}function PT(e){return e>=hT&&e<CT}function FT(e,t){if(e>=gT&&e<wT&&t>=_T&&t<TT)return hT+(e-gT)*ST+(t-_T)*xT;if(PT(e)&&t>vT&&t<ET&&(e-hT)%xT==0)return e+(t-vT);{let n=MT.get(e);return n&&(n=n.get(t),n)?n:-1}}function IT(e){kT||NT();let t=[],n=[],r=!1;function i(e){let n=kT.get(e);n&&(r=!0,e|=n),t.push(e)}for(let r of e)for(;;){if(r<128)t.push(r);else if(PT(r)){let e=r-hT,t=e/ST|0,n=e%ST/xT|0,a=e%xT;i(gT+t),i(_T+n),a>0&&i(vT+a)}else{let e=jT.get(r);e?n.push(...e):i(r)}if(!n.length)break;r=n.pop()}if(r&&t.length>1){let e=DT(t[0]);for(let n=1;n<t.length;n++){let r=DT(t[n]);if(r==0||e<=r){e=r;continue}let i=n-1;for(;;){let n=t[i+1];if(t[i+1]=t[i],t[i]=n,!i||(e=DT(t[--i]),e<=r))break}e=DT(t[n])}}return t}function LT(e){let t=[],n=[],r=-1,i=0;for(let a of e){let e=DT(a),o=OT(a);if(r==-1)e==0?r=o:t.push(o);else if(i>0&&i>=e)e==0?(t.push(r,...n),n.length=0,r=o):n.push(o),i=e;else{let a=FT(r,o);a>=0?r=a:i==0&&e==0?(t.push(r),r=o):(n.push(o),i=e)}}return r>=0&&t.push(r,...n),t}function RT(e){return IT(e).map(OT)}function zT(e){return LT(IT(e))}var BT=45,VT=`.`,HT=65039,UT=1,WT=e=>Array.from(e);function GT(e,t){return e.P.has(t)||e.Q.has(t)}var KT=class extends Array{get is_emoji(){return!0}},qT,JT,YT,XT,ZT,QT,$T,eE,tE,nE,rE;function iE(){if(qT)return;let e=Zw(Kw),t=()=>tT(e),n=()=>new Set(t()),r=(e,t)=>t.forEach(t=>e.add(t));qT=new Map(rT(e)),JT=n(),YT=t(),XT=new Set(t().map(e=>YT[e])),YT=new Set(YT),ZT=n(),n();let i=nT(e),a=e(),o=()=>{let e=new Set;return t().forEach(t=>r(e,i[t])),r(e,t()),e};QT=iT(t=>{let n=iT(e).map(e=>e+96);if(n.length){let r=t>=a;n[0]-=32,n=fT(n),r&&(n=`Restricted[${n}]`);let i=o(),s=o(),c=!e();return{N:n,P:i,Q:s,M:c,R:r}}}),$T=n(),eE=new Map;let s=t().concat(WT($T)).sort((e,t)=>e-t);s.forEach((t,n)=>{let r=e(),i=s[n]=r?s[n-r]:{V:[],M:new Map};i.V.push(t),$T.has(t)||eE.set(t,i)});for(let{V:e,M:t}of new Set(eE.values())){let n=[];for(let t of e){let e=QT.filter(e=>GT(e,t)),i=n.find(({G:t})=>e.some(e=>t.has(e)));i||(i={G:new Set,V:[]},n.push(i)),i.V.push(t),r(i.G,e)}let i=n.flatMap(e=>WT(e.G));for(let{G:e,V:r}of n){let n=new Set(i.filter(t=>!e.has(t)));for(let e of r)t.set(e,n)}}tE=new Set;let c=new Set,l=e=>tE.has(e)?c.add(e):tE.add(e);for(let e of QT){for(let t of e.P)l(t);for(let t of e.Q)l(t)}for(let e of tE)!eE.has(e)&&!c.has(e)&&eE.set(e,UT);r(tE,RT(tE)),nE=cT(e).map(e=>KT.from(e)).sort(pT),rE=new Map;for(let e of nE){let t=[rE];for(let n of e){let e=t.map(e=>{let t=e.get(n);return t||(t=new Map,e.set(n,t)),t});n===HT?t.push(...e):t=e}for(let n of t)n.V=e}}function aE(e){return(fE(e)?``:`${oE(uE([e]))} `)+uT(e)}function oE(e){return`"${e}"\u200E`}function sE(e){if(e.length>=4&&e[2]==BT&&e[3]==BT)throw Error(`invalid label extension: "${fT(e.slice(0,4))}"`)}function cE(e){for(let t=e.lastIndexOf(95);t>0;)if(e[--t]!==95)throw Error(`underscore allowed only at start`)}function lE(e){let t=e[0],n=qw.get(t);if(n)throw bE(`leading ${n}`);let r=e.length,i=-1;for(let a=1;a<r;a++){t=e[a];let r=qw.get(t);if(r){if(i==a)throw bE(`${n} + ${r}`);i=a+1,n=r}}if(i==r)throw bE(`trailing ${n}`)}function uE(e,t=1/0,n=uT){let r=[];dE(e[0])&&r.push(`◌`),e.length>t&&(t>>=1,e=[...e.slice(0,t),8230,...e.slice(-t)]);let i=0,a=e.length;for(let t=0;t<a;t++){let a=e[t];fE(a)&&(r.push(fT(e.slice(i,t))),r.push(n(a)),i=t+1)}return r.push(fT(e.slice(i,a))),r.join(``)}function dE(e){return iE(),YT.has(e)}function fE(e){return iE(),ZT.has(e)}function pE(e){return _E(mE(e,zT,CE))}function mE(e,t,n){if(!e)return[];iE();let r=0;return e.split(VT).map(e=>{let i=dT(e),a={input:i,offset:r};r+=i.length+1;try{let e=a.tokens=SE(i,t,n),r=e.length,o;if(!r)throw Error(`empty label`);let s=a.output=e.flat();if(cE(s),!(a.emoji=r>1||e[0].is_emoji)&&s.every(e=>e<128))sE(s),o=`ASCII`;else{let t=e.flatMap(e=>e.is_emoji?[]:e);if(!t.length)o=`Emoji`;else{if(YT.has(s[0]))throw bE(`leading combining mark`);for(let t=1;t<r;t++){let n=e[t];if(!n.is_emoji&&YT.has(n[0]))throw bE(`emoji + combining mark: "${fT(e[t-1])} + ${uE([n[0]])}"`)}lE(s);let n=WT(new Set(t)),[i]=gE(n);xE(i,t),hE(i,n),o=i.N}}a.type=o}catch(e){a.error=e}return a})}function hE(e,t){let n,r=[];for(let e of t){let t=eE.get(e);if(t===UT)return;if(t){let r=t.M.get(e);if(n=n?n.filter(e=>r.has(e)):WT(r),!n.length)return}else r.push(e)}if(n){for(let t of n)if(r.every(e=>GT(t,e)))throw Error(`whole-script confusable: ${e.N}/${t.N}`)}}function gE(e){let t=QT;for(let n of e){let e=t.filter(e=>GT(e,n));if(!e.length)throw QT.some(e=>GT(e,n))?yE(t[0],n):vE(n);if(t=e,e.length==1)break}return t}function _E(e){return e.map(({input:t,error:n,output:r})=>{if(n){let r=n.message;throw Error(e.length==1?r:`Invalid label ${oE(uE(t,63))}: ${r}`)}return fT(r)}).join(VT)}function vE(e){return Error(`disallowed character: ${aE(e)}`)}function yE(e,t){let n=aE(t),r=QT.find(e=>e.P.has(t));return r&&(n=`${r.N} ${n}`),Error(`illegal mixture: ${e.N} + ${n}`)}function bE(e){return Error(`illegal placement: ${e}`)}function xE(e,t){for(let n of t)if(!GT(e,n))throw yE(e,n);if(e.M){let e=RT(t);for(let t=1,n=e.length;t<n;t++)if(XT.has(e[t])){let r=t+1;for(let i;r<n&&XT.has(i=e[r]);r++)for(let n=t;n<r;n++)if(e[n]==i)throw Error(`duplicate non-spacing marks: ${aE(i)}`);if(r-t>Jw)throw Error(`excessive non-spacing marks: ${oE(uE(e.slice(t-1,r)))} (${r-t}/${Jw})`);t=r}}}function SE(e,t,n){let r=[],i=[];for(e=e.slice().reverse();e.length;){let a=wE(e);if(a)i.length&&(r.push(t(i)),i=[]),r.push(n(a));else{let t=e.pop();if(tE.has(t))i.push(t);else{let e=qT.get(t);if(e)i.push(...e);else if(!JT.has(t))throw vE(t)}}}return i.length&&r.push(t(i)),r}function CE(e){return e.filter(e=>e!=HT)}function wE(e,t){let n=rE,r,i=e.length;for(;i&&(n=n.get(e[--i]),n);){let{V:a}=n;a&&(r=a,t&&t.push(...e.slice(i).reverse()),e.length=i)}return r}var TE=new Uint8Array(32);TE.fill(0);function EE(e){return q(e.length!==0,`invalid ENS name; empty component`,`comp`,e),e}function DE(e){let t=dy(OE(e)),n=[];if(e.length===0)return n;let r=0;for(let e=0;e<t.length;e++)t[e]===46&&(n.push(EE(t.slice(r,e))),r=e+1);return q(r<t.length,`invalid ENS name; empty component`,`name`,e),n.push(EE(t.slice(r))),n}function OE(e){try{if(e.length===0)throw Error(`empty label`);return pE(e)}catch(t){q(!1,`invalid ENS name (${t.message})`,`name`,e)}}function kE(e){q(typeof e==`string`,`invalid ENS name; not a string`,`name`,e),q(e.length,`invalid ENS name (empty label)`,`name`,e);let t=TE,n=DE(e);for(;n.length;)t=yx(Fv([t,yx(n.pop())]));return Y(t)}function AE(e,t){let n=t??63;return q(n<=255,`DNS encoded label cannot exceed 255`,`length`,n),Y(Fv(DE(e).map(t=>{q(t.length<=n,`label ${JSON.stringify(e)} exceeds ${n} bytes`,`name`,e);let r=new Uint8Array(t.length+1);return r.set(t,1),r[0]=r.length-1,r})))+`00`}var jE=new Uint8Array(32);jE.fill(0);var ME=BigInt(-1),NE=BigInt(0),PE=BigInt(1),FE=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`);function IE(e){let t=J(e),n=t.length%32;return n?Fv([t,jE.slice(n)]):Y(t)}var LE=Zv(PE,32),RE=Zv(NE,32),zE={name:`string`,version:`string`,chainId:`uint256`,verifyingContract:`address`,salt:`bytes32`},BE=[`name`,`version`,`chainId`,`verifyingContract`,`salt`];function VE(e){return function(t){return q(typeof t==`string`,`invalid domain value for ${JSON.stringify(e)}`,`domain.${e}`,t),t}}var HE={name:VE(`name`),version:VE(`version`),chainId:function(e){let t=X(e,`domain.chainId`);return q(t>=0,`invalid chain ID`,`domain.chainId`,e),Number.isSafeInteger(t)?Number(t):$v(t)},verifyingContract:function(e){try{return IC(e).toLowerCase()}catch{}q(!1,`invalid domain value "verifyingContract"`,`domain.verifyingContract`,e)},salt:function(e){let t=J(e,`domain.salt`);return q(t.length===32,`invalid domain value "salt"`,`domain.salt`,e),Y(t)}};function UE(e){{let t=e.match(/^(u?)int(\d+)$/);if(t){let n=t[1]===``,r=parseInt(t[2]);q(r%8==0&&r!==0&&r<=256&&t[2]===String(r),`invalid numeric width`,`type`,e);let i=Kv(FE,n?r-1:r),a=n?(i+PE)*ME:NE;return function(t){let r=X(t,`value`);return q(r>=a&&r<=i,`value out-of-bounds for ${e}`,`value`,r),Zv(n?Gv(r,256):r,32)}}}{let t=e.match(/^bytes(\d+)$/);if(t){let n=parseInt(t[1]);return q(n!==0&&n<=32&&t[1]===String(n),`invalid bytes width`,`type`,e),function(t){return q(J(t).length===n,`invalid length for ${e}`,`value`,t),IE(t)}}}switch(e){case`address`:return function(e){return zv(IC(e),32)};case`bool`:return function(e){return e?LE:RE};case`bytes`:return function(e){return yx(e)};case`string`:return function(e){return Gw(e)}}return null}function WE(e,t){return`${e}(${t.map(({name:e,type:t})=>t+` `+e).join(`,`)})`}function GE(e){let t=e.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return t?{base:t[1],index:t[2]+t[4],array:{base:t[1],prefix:t[1]+t[2],count:t[5]?parseInt(t[5]):-1}}:{base:e}}var KE=class e{primaryType;#e;get types(){return JSON.parse(this.#e)}#t;#n;constructor(e){this.#t=new Map,this.#n=new Map;let t=new Map,n=new Map,r=new Map,i={};Object.keys(e).forEach(a=>{i[a]=e[a].map(({name:t,type:n})=>{let{base:r,index:i}=GE(n);return r===`int`&&!e.int&&(r=`int256`),r===`uint`&&!e.uint&&(r=`uint256`),{name:t,type:r+(i||``)}}),t.set(a,new Set),n.set(a,[]),r.set(a,new Set)}),this.#e=JSON.stringify(i);for(let r in i){let a=new Set;for(let o of i[r]){q(!a.has(o.name),`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(r)}`,`types`,e),a.add(o.name);let i=GE(o.type).base;q(i!==r,`circular type reference to ${JSON.stringify(i)}`,`types`,e),!UE(i)&&(q(n.has(i),`unknown type ${JSON.stringify(i)}`,`types`,e),n.get(i).push(r),t.get(r).add(i))}}let a=Array.from(n.keys()).filter(e=>n.get(e).length===0);q(a.length!==0,`missing primary type`,`types`,e),q(a.length===1,`ambiguous primary types or unused types: ${a.map(e=>JSON.stringify(e)).join(`, `)}`,`types`,e),G(this,{primaryType:a[0]});function o(i,a){q(!a.has(i),`circular type reference to ${JSON.stringify(i)}`,`types`,e),a.add(i);for(let e of t.get(i))if(n.has(e)){o(e,a);for(let t of a)r.get(t).add(e)}a.delete(i)}o(this.primaryType,new Set);for(let[e,t]of r){let n=Array.from(t);n.sort(),this.#t.set(e,WE(e,i[e])+n.map(e=>WE(e,i[e])).join(``))}}getEncoder(e){let t=this.#n.get(e);return t||(t=this.#r(e),this.#n.set(e,t)),t}#r(e){{let t=UE(e);if(t)return t}let t=GE(e).array;if(t){let e=t.prefix,n=this.getEncoder(e);return r=>{q(t.count===-1||t.count===r.length,`array length mismatch; expected length ${t.count}`,`value`,r);let i=r.map(n);return this.#t.has(e)&&(i=i.map(yx)),yx(Fv(i))}}let n=this.types[e];if(n){let t=Gw(this.#t.get(e));return e=>{let r=n.map(({name:t,type:n})=>{let r=this.getEncoder(n)(e[t]);return this.#t.has(n)?yx(r):r});return r.unshift(t),Fv(r)}}q(!1,`unknown type: ${e}`,`type`,e)}encodeType(e){let t=this.#t.get(e);return q(t,`unknown type: ${JSON.stringify(e)}`,`name`,e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return yx(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(UE(e))return n(e,t);let r=GE(e).array;if(r)return q(r.count===-1||r.count===t.length,`array length mismatch; expected length ${r.count}`,`value`,t),t.map(e=>this._visit(r.prefix,e,n));let i=this.types[e];if(i)return i.reduce((e,{name:r,type:i})=>(e[r]=this._visit(i,t[r],n),e),{});q(!1,`unknown type: ${e}`,`type`,e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(t){return new e(t)}static getPrimaryType(t){return e.from(t).primaryType}static hashStruct(t,n,r){return e.from(n).hashStruct(t,r)}static hashDomain(t){let n=[];for(let e in t){if(t[e]==null)continue;let r=zE[e];q(r,`invalid typed-data domain key: ${JSON.stringify(e)}`,`domain`,t),n.push({name:e,type:r})}return n.sort((e,t)=>BE.indexOf(e.name)-BE.indexOf(t.name)),e.hashStruct(`EIP712Domain`,{EIP712Domain:n},t)}static encode(t,n,r){return Fv([`0x1901`,e.hashDomain(t),e.from(n).hash(r)])}static hash(t,n,r){return yx(e.encode(t,n,r))}static async resolveNames(t,n,r,i){t=Object.assign({},t);for(let e in t)t[e]??delete t[e];let a={};t.verifyingContract&&!Mv(t.verifyingContract,20)&&(a[t.verifyingContract]=`0x`);let o=e.from(n);o.visit(r,(e,t)=>(e===`address`&&!Mv(t,20)&&(a[t]=`0x`),t));for(let e in a)a[e]=await i(e);return t.verifyingContract&&a[t.verifyingContract]&&(t.verifyingContract=a[t.verifyingContract]),r=o.visit(r,(e,t)=>e===`address`&&a[t]?a[t]:t),{domain:t,value:r}}static getPayload(t,n,r){e.hashDomain(t);let i={},a=[];BE.forEach(e=>{let n=t[e];n!=null&&(i[e]=HE[e](n),a.push({name:e,type:zE[e]}))});let o=e.from(n);n=o.types;let s=Object.assign({},n);return q(s.EIP712Domain==null,`types must not contain EIP712Domain type`,`types.EIP712Domain`,n),s.EIP712Domain=a,o.encode(r),{types:s,domain:i,primaryType:o.primaryType,message:o.visit(r,(e,t)=>{if(e.match(/^bytes(\d*)/))return Y(J(t));if(e.match(/^u?int/))return X(t).toString();switch(e){case`address`:return t.toLowerCase();case`bool`:return!!t;case`string`:return q(typeof t==`string`,`invalid string`,`value`,t),t}q(!1,`unsupported type`,`type`,e)})}}};function qE(e){let t=new Set;return e.forEach(e=>t.add(e)),Object.freeze(t)}var JE=qE(`external public payable override`.split(` `)),YE=`constant external internal payable private public pure view override`,XE=qE(YE.split(` `)),ZE=`constructor error event fallback function receive struct`,QE=qE(ZE.split(` `)),$E=`calldata memory storage payable indexed`,eD=qE($E.split(` `)),tD=qE([ZE,$E,`tuple returns`,YE].join(` `).split(` `)),nD={"(":`OPEN_PAREN`,")":`CLOSE_PAREN`,"[":`OPEN_BRACKET`,"]":`CLOSE_BRACKET`,",":`COMMA`,"@":`AT`},rD=RegExp(`^(\\s*)`),iD=RegExp(`^([0-9]+)`),aD=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)`),oD=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)$`),sD=RegExp(`^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$`),cD=class e{#e;#t;get offset(){return this.#e}get length(){return this.#t.length-this.#e}constructor(e){this.#e=0,this.#t=e.slice()}clone(){return new e(this.#t)}reset(){this.#e=0}#n(t=0,n=0){return new e(this.#t.slice(t,n).map(e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t}))))}popKeyword(e){let t=this.peek();if(t.type!==`KEYWORD`||!e.has(t.text))throw Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){let t=this.peek();throw Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=this.#n(this.#e+1,e.match+1);return this.#e=e.match+1,t}popParams(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=[];for(;this.#e<e.match-1;){let e=this.peek().linkNext;t.push(this.#n(this.#e+1,e)),this.#e=e}return this.#e=e.match+1,t}peek(){if(this.#e>=this.#t.length)throw Error(`out-of-bounds`);return this.#t[this.#e]}peekKeyword(e){let t=this.peekType(`KEYWORD`);return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;let t=this.peek();return t.type===e?t.text:null}pop(){let e=this.peek();return this.#e++,e}toString(){let e=[];for(let t=this.#e;t<this.#t.length;t++){let n=this.#t[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(` `)}>`}};function lD(e){let t=[],n=t=>{let n=a<e.length?JSON.stringify(e[a]):`$EOI`;throw Error(`invalid token ${n} at ${a}: ${t}`)},r=[],i=[],a=0;for(;a<e.length;){let o=e.substring(a),s=o.match(rD);s&&(a+=s[1].length,o=e.substring(a));let c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:``,text:``,offset:a,value:-1};t.push(c);let l=nD[o[0]]||``;if(l){if(c.type=l,c.text=o[0],a++,l===`OPEN_PAREN`)r.push(t.length-1),i.push(t.length-1);else if(l==`CLOSE_PAREN`)r.length===0&&n(`no matching open bracket`),c.match=r.pop(),t[c.match].match=t.length-1,c.depth--,c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1;else if(l===`COMMA`)c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(l===`OPEN_BRACKET`)c.type=`BRACKET`;else if(l===`CLOSE_BRACKET`){let e=t.pop().text;if(t.length>0&&t[t.length-1].type===`NUMBER`){let n=t.pop().text;e=n+e,t[t.length-1].value=Z(n)}if(t.length===0||t[t.length-1].type!==`BRACKET`)throw Error(`missing opening bracket`);t[t.length-1].text+=e}continue}if(s=o.match(aD),s){if(c.text=s[1],a+=c.text.length,tD.has(c.text)){c.type=`KEYWORD`;continue}if(c.text.match(sD)){c.type=`TYPE`;continue}c.type=`ID`;continue}if(s=o.match(iD),s){c.text=s[1],c.type=`NUMBER`,a+=c.text.length;continue}throw Error(`unexpected token ${JSON.stringify(o[0])} at position ${a}`)}return new cD(t.map(e=>Object.freeze(e)))}function uD(e,t){let n=[];for(let r in t.keys())e.has(r)&&n.push(r);if(n.length>1)throw Error(`conflicting types: ${n.join(`, `)}`)}function dD(e,t){if(t.peekKeyword(QE)){let n=t.pop().text;if(n!==e)throw Error(`expected ${e}, got ${n}`)}return t.popType(`ID`)}function fD(e,t){let n=new Set;for(;;){let r=e.peekType(`KEYWORD`);if(r==null||t&&!t.has(r))break;if(e.pop(),n.has(r))throw Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}function pD(e){let t=fD(e,XE);return uD(t,qE(`constant payable nonpayable`.split(` `))),uD(t,qE(`pure view payable nonpayable`.split(` `))),t.has(`view`)?`view`:t.has(`pure`)?`pure`:t.has(`payable`)?`payable`:t.has(`nonpayable`)?`nonpayable`:t.has(`constant`)?`view`:`nonpayable`}function mD(e,t){return e.popParams().map(e=>OD.from(e,t))}function hD(e){if(e.peekType(`AT`)){if(e.pop(),e.peekType(`NUMBER`))return X(e.pop().text);throw Error(`invalid gas`)}return null}function gD(e){if(e.length)throw Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`)}var _D=new RegExp(/^(.*)\[([0-9]*)\]$/);function vD(e){let t=e.match(sD);if(q(t,`invalid type`,`type`,e),e===`uint`)return`uint256`;if(e===`int`)return`int256`;if(t[2]){let n=parseInt(t[2]);q(n!==0&&n<=32,`invalid bytes length`,`type`,e)}else if(t[3]){let n=parseInt(t[3]);q(n!==0&&n<=256&&n%8==0,`invalid numeric width`,`type`,e)}return e}var yD={},bD=Symbol.for(`_ethers_internal`),xD=`_ParamTypeInternal`,SD=`_ErrorInternal`,CD=`_EventInternal`,wD=`_ConstructorInternal`,TD=`_FallbackInternal`,ED=`_FunctionInternal`,DD=`_StructInternal`,OD=class e{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(e,t,n,r,i,a,o,s){if(kv(e,yD,`ParamType`),Object.defineProperty(this,bD,{value:xD}),a&&=Object.freeze(a.slice()),r===`array`){if(o==null||s==null)throw Error(``)}else if(o!=null||s!=null)throw Error(``);if(r===`tuple`){if(a==null)throw Error(``)}else if(a!=null)throw Error(``);G(this,{name:t,type:n,baseType:r,indexed:i,components:a,arrayLength:o,arrayChildren:s})}format(e){if(e??=`sighash`,e===`json`){let t=this.name||``;if(this.isArray()){let e=JSON.parse(this.arrayChildren.format(`json`));return e.name=t,e.type+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`,JSON.stringify(e)}let n={type:this.baseType===`tuple`?`tuple`:this.type,name:t};return typeof this.indexed==`boolean`&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map(t=>JSON.parse(t.format(e)))),JSON.stringify(n)}let t=``;return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`):this.isTuple()?t+=`(`+this.components.map(t=>t.format(e)).join(e===`full`?`, `:`,`)+`)`:t+=this.type,e!==`sighash`&&(this.indexed===!0&&(t+=` indexed`),e===`full`&&this.name&&(t+=` `+this.name)),t}isArray(){return this.baseType===`array`}isTuple(){return this.baseType===`tuple`}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw Error(`invalid array value`);if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw Error(`array is wrong length`);let n=this;return e.map(e=>n.arrayChildren.walk(e,t))}if(this.isTuple()){if(!Array.isArray(e))throw Error(`invalid tuple value`);if(e.length!==this.components.length)throw Error(`array is wrong length`);let n=this;return e.map((e,r)=>n.components[r].walk(e,t))}return t(this.type,e)}#e(e,t,n,r){if(this.isArray()){if(!Array.isArray(t))throw Error(`invalid array value`);if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw Error(`array is wrong length`);let i=this.arrayChildren,a=t.slice();a.forEach((t,r)=>{i.#e(e,t,n,e=>{a[r]=e})}),r(a);return}if(this.isTuple()){let i=this.components,a;if(Array.isArray(t))a=t.slice();else{if(typeof t!=`object`||!t)throw Error(`invalid tuple value`);a=i.map(e=>{if(!e.name)throw Error(`cannot use object value with unnamed components`);if(!(e.name in t))throw Error(`missing value for component ${e.name}`);return t[e.name]})}if(a.length!==this.components.length)throw Error(`array is wrong length`);a.forEach((t,r)=>{i[r].#e(e,t,n,e=>{a[r]=e})}),r(a);return}let i=n(this.type,t);i.then?e.push((async function(){r(await i)})()):r(i)}async walkAsync(e,t){let n=[],r=[e];return this.#e(n,e,t,e=>{r[0]=e}),n.length&&await Promise.all(n),r[0]}static from(t,n){if(e.isParamType(t))return t;if(typeof t==`string`)try{return e.from(lD(t),n)}catch{q(!1,`invalid param type`,`obj`,t)}else if(t instanceof cD){let r=``,i=``,a=null;fD(t,qE([`tuple`])).has(`tuple`)||t.peekType(`OPEN_PAREN`)?(i=`tuple`,a=t.popParams().map(t=>e.from(t)),r=`tuple(${a.map(e=>e.format()).join(`,`)})`):(r=vD(t.popType(`TYPE`)),i=r);let o=null,s=null;for(;t.length&&t.peekType(`BRACKET`);){let n=t.pop();o=new e(yD,``,r,i,null,a,s,o),s=n.value,r+=n.text,i=`array`,a=null}let c=null;if(fD(t,eD).has(`indexed`)){if(!n)throw Error(``);c=!0}let l=t.peekType(`ID`)?t.pop().text:``;if(t.length)throw Error(`leftover tokens`);return new e(yD,l,r,i,c,a,s,o)}let r=t.name;q(!r||typeof r==`string`&&r.match(oD),`invalid name`,`obj.name`,r);let i=t.indexed;i!=null&&(q(n,`parameter cannot be indexed`,`obj.indexed`,t.indexed),i=!!i);let a=t.type,o=a.match(_D);if(o){let n=parseInt(o[2]||`-1`),s=e.from({type:o[1],components:t.components});return new e(yD,r||``,a,`array`,i,null,n,s)}if(a===`tuple`||a.startsWith(`tuple(`)||a.startsWith(`(`)){let n=t.components==null?null:t.components.map(t=>e.from(t));return new e(yD,r||``,a,`tuple`,i,n,null,null)}return a=vD(t.type),new e(yD,r||``,a,a,i,null,null,null)}static isParamType(e){return e&&e[bD]===xD}},kD=class e{type;inputs;constructor(e,t,n){kv(e,yD,`Fragment`),n=Object.freeze(n.slice()),G(this,{type:t,inputs:n})}static from(t){if(typeof t==`string`){try{e.from(JSON.parse(t))}catch{}return e.from(lD(t))}if(t instanceof cD)switch(t.peekKeyword(QE)){case`constructor`:return PD.from(t);case`error`:return MD.from(t);case`event`:return ND.from(t);case`fallback`:case`receive`:return FD.from(t);case`function`:return ID.from(t);case`struct`:return LD.from(t)}else if(typeof t==`object`){switch(t.type){case`constructor`:return PD.from(t);case`error`:return MD.from(t);case`event`:return ND.from(t);case`fallback`:case`receive`:return FD.from(t);case`function`:return ID.from(t);case`struct`:return LD.from(t)}K(!1,`unsupported type: ${t.type}`,`UNSUPPORTED_OPERATION`,{operation:`Fragment.from`})}q(!1,`unsupported frgament object`,`obj`,t)}static isConstructor(e){return PD.isFragment(e)}static isError(e){return MD.isFragment(e)}static isEvent(e){return ND.isFragment(e)}static isFunction(e){return ID.isFragment(e)}static isStruct(e){return LD.isFragment(e)}},AD=class extends kD{name;constructor(e,t,n,r){super(e,t,r),q(typeof n==`string`&&n.match(oD),`invalid identifier`,`name`,n),r=Object.freeze(r.slice()),G(this,{name:n})}};function jD(e,t){return`(`+t.map(t=>t.format(e)).join(e===`full`?`, `:`,`)+`)`}var MD=class e extends AD{constructor(e,t,n){super(e,`error`,t,n),Object.defineProperty(this,bD,{value:SD})}get selector(){return Gw(this.format(`sighash`)).substring(0,10)}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`error`,name:this.name,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`error`),t.push(this.name+jD(e,this.inputs)),t.join(` `)}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)return e.from(lD(t));if(t instanceof cD){let n=dD(`error`,t),r=mD(t);return gD(t),new e(yD,n,r)}return new e(yD,t.name,t.inputs?t.inputs.map(OD.from):[])}static isFragment(e){return e&&e[bD]===SD}},ND=class e extends AD{anonymous;constructor(e,t,n,r){super(e,`event`,t,n),Object.defineProperty(this,bD,{value:CD}),G(this,{anonymous:r})}get topicHash(){return Gw(this.format(`sighash`))}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`event`,anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`event`),t.push(this.name+jD(e,this.inputs)),e!==`sighash`&&this.anonymous&&t.push(`anonymous`),t.join(` `)}static getTopicHash(t,n){return n=(n||[]).map(e=>OD.from(e)),new e(yD,t,n,!1).topicHash}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid event fragment`,`obj`,t)}else if(t instanceof cD){let n=dD(`event`,t),r=mD(t,!0),i=!!fD(t,qE([`anonymous`])).has(`anonymous`);return gD(t),new e(yD,n,r,i)}return new e(yD,t.name,t.inputs?t.inputs.map(e=>OD.from(e,!0)):[],!!t.anonymous)}static isFragment(e){return e&&e[bD]===CD}},PD=class e extends kD{payable;gas;constructor(e,t,n,r,i){super(e,t,n),Object.defineProperty(this,bD,{value:wD}),G(this,{payable:r,gas:i})}format(e){if(K(e!=null&&e!==`sighash`,`cannot format a constructor for sighash`,`UNSUPPORTED_OPERATION`,{operation:`format(sighash)`}),e===`json`)return JSON.stringify({type:`constructor`,stateMutability:this.payable?`payable`:`undefined`,payable:this.payable,gas:this.gas==null?void 0:this.gas,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[`constructor${jD(e,this.inputs)}`];return this.payable&&t.push(`payable`),this.gas!=null&&t.push(`@${this.gas.toString()}`),t.join(` `)}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid constuctor fragment`,`obj`,t)}else if(t instanceof cD){fD(t,qE([`constructor`]));let n=mD(t),r=!!fD(t,JE).has(`payable`),i=hD(t);return gD(t),new e(yD,`constructor`,n,r,i)}return new e(yD,`constructor`,t.inputs?t.inputs.map(OD.from):[],!!t.payable,t.gas==null?null:t.gas)}static isFragment(e){return e&&e[bD]===wD}},FD=class e extends kD{payable;constructor(e,t,n){super(e,`fallback`,t),Object.defineProperty(this,bD,{value:TD}),G(this,{payable:n})}format(e){let t=this.inputs.length===0?`receive`:`fallback`;if(e===`json`){let e=this.payable?`payable`:`nonpayable`;return JSON.stringify({type:t,stateMutability:e})}return`${t}()${this.payable?` payable`:``}`}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid fallback fragment`,`obj`,t)}else if(t instanceof cD){let n=t.toString();if(q(t.peekKeyword(qE([`fallback`,`receive`])),`type must be fallback or receive`,`obj`,n),t.popKeyword(qE([`fallback`,`receive`]))===`receive`){let n=mD(t);return q(n.length===0,`receive cannot have arguments`,`obj.inputs`,n),fD(t,qE([`payable`])),gD(t),new e(yD,[],!0)}let r=mD(t);r.length?q(r.length===1&&r[0].type===`bytes`,`invalid fallback inputs`,`obj.inputs`,r.map(e=>e.format(`minimal`)).join(`, `)):r=[OD.from(`bytes`)];let i=pD(t);if(q(i===`nonpayable`||i===`payable`,`fallback cannot be constants`,`obj.stateMutability`,i),fD(t,qE([`returns`])).has(`returns`)){let e=mD(t);q(e.length===1&&e[0].type===`bytes`,`invalid fallback outputs`,`obj.outputs`,e.map(e=>e.format(`minimal`)).join(`, `))}return gD(t),new e(yD,r,i===`payable`)}if(t.type===`receive`)return new e(yD,[],!0);if(t.type===`fallback`)return new e(yD,[OD.from(`bytes`)],t.stateMutability===`payable`);q(!1,`invalid fallback description`,`obj`,t)}static isFragment(e){return e&&e[bD]===TD}},ID=class e extends AD{constant;outputs;stateMutability;payable;gas;constructor(e,t,n,r,i,a){super(e,`function`,t,r),Object.defineProperty(this,bD,{value:ED}),i=Object.freeze(i.slice()),G(this,{constant:n===`view`||n===`pure`,gas:a,outputs:i,payable:n===`payable`,stateMutability:n})}get selector(){return Gw(this.format(`sighash`)).substring(0,10)}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`function`,name:this.name,constant:this.constant,stateMutability:this.stateMutability===`nonpayable`?void 0:this.stateMutability,payable:this.payable,gas:this.gas==null?void 0:this.gas,inputs:this.inputs.map(t=>JSON.parse(t.format(e))),outputs:this.outputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`function`),t.push(this.name+jD(e,this.inputs)),e!==`sighash`&&(this.stateMutability!==`nonpayable`&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push(`returns`),t.push(jD(e,this.outputs))),this.gas!=null&&t.push(`@${this.gas.toString()}`)),t.join(` `)}static getSelector(t,n){return n=(n||[]).map(e=>OD.from(e)),new e(yD,t,`view`,n,[],null).selector}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid function fragment`,`obj`,t)}else if(t instanceof cD){let n=dD(`function`,t),r=mD(t),i=pD(t),a=[];fD(t,qE([`returns`])).has(`returns`)&&(a=mD(t));let o=hD(t);return gD(t),new e(yD,n,i,r,a,o)}let n=t.stateMutability;return n??(n=`payable`,typeof t.constant==`boolean`?(n=`view`,t.constant||(n=`payable`,typeof t.payable==`boolean`&&!t.payable&&(n=`nonpayable`))):typeof t.payable==`boolean`&&!t.payable&&(n=`nonpayable`)),new e(yD,t.name,n,t.inputs?t.inputs.map(OD.from):[],t.outputs?t.outputs.map(OD.from):[],t.gas==null?null:t.gas)}static isFragment(e){return e&&e[bD]===ED}},LD=class e extends AD{constructor(e,t,n){super(e,`struct`,t,n),Object.defineProperty(this,bD,{value:DD})}format(){throw Error(`@TODO`)}static from(t){if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid struct fragment`,`obj`,t)}else if(t instanceof cD){let n=dD(`struct`,t),r=mD(t);return gD(t),new e(yD,n,r)}return new e(yD,t.name,t.inputs?t.inputs.map(OD.from):[])}static isFragment(e){return e&&e[bD]===DD}},RD=new Map;RD.set(0,`GENERIC_PANIC`),RD.set(1,`ASSERT_FALSE`),RD.set(17,`OVERFLOW`),RD.set(18,`DIVIDE_BY_ZERO`),RD.set(33,`ENUM_RANGE_ERROR`),RD.set(34,`BAD_STORAGE_DATA`),RD.set(49,`STACK_UNDERFLOW`),RD.set(50,`ARRAY_RANGE_ERROR`),RD.set(65,`OUT_OF_MEMORY`),RD.set(81,`UNINITIALIZED_FUNCTION_CALL`);var zD=new RegExp(/^bytes([0-9]*)$/),BD=new RegExp(/^(u?int)([0-9]*)$/),VD=null,HD=1024;function UD(e,t,n,r){let i=`missing revert data`,a=null,o=null;if(n){i=`execution reverted`;let e=J(n);if(n=Y(n),e.length===0)i+=` (no data present; likely require(false) occurred`,a=`require(false)`;else if(e.length%32!=4)i+=` (could not decode reason; invalid data length)`;else if(Y(e.slice(0,4))===`0x08c379a0`)try{a=r.decode([`string`],e.slice(4))[0],o={signature:`Error(string)`,name:`Error`,args:[a]},i+=`: ${JSON.stringify(a)}`}catch{i+=` (could not decode reason; invalid string data)`}else if(Y(e.slice(0,4))===`0x4e487b71`)try{let t=Number(r.decode([`uint256`],e.slice(4))[0]);o={signature:`Panic(uint256)`,name:`Panic`,args:[t]},a=`Panic due to ${RD.get(t)||`UNKNOWN`}(${t})`,i+=`: ${a}`}catch{i+=` (could not decode panic code)`}else i+=` (unknown custom error)`}let s={to:t.to?IC(t.to):null,data:t.data||`0x`};return t.from&&(s.from=IC(t.from)),Tv(i,`CALL_EXCEPTION`,{action:e,data:n,reason:a,transaction:s,invocation:null,revert:o})}var WD=class e{#e(e){if(e.isArray())return new YC(this.#e(e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new sw(e.components.map(e=>this.#e(e)),e.name);switch(e.baseType){case`address`:return new GC(e.name);case`bool`:return new XC(e.name);case`string`:return new ow(e.name);case`bytes`:return new QC(e.name);case``:return new tw(e.name)}let t=e.type.match(BD);if(t){let n=parseInt(t[2]||`256`);return q(n!==0&&n<=256&&n%8==0,`invalid `+t[1]+` bit length`,`param`,e),new aw(n/8,t[1]===`int`,e.name)}if(t=e.type.match(zD),t){let n=parseInt(t[1]);return q(n!==0&&n<=32,`invalid bytes length`,`param`,e),new $C(n,e.name)}q(!1,`invalid type`,`type`,e.type)}getDefaultValue(e){return new sw(e.map(e=>this.#e(OD.from(e))),`_`).defaultValue()}encode(e,t){Ev(t.length,e.length,`types/values length mismatch`);let n=new sw(e.map(e=>this.#e(OD.from(e))),`_`),r=new Qy;return n.encode(r,t),r.data}decode(e,t,n){return new sw(e.map(e=>this.#e(OD.from(e))),`_`).decode(new $y(t,n,HD))}static _setDefaultMaxInflation(e){q(typeof e==`number`&&Number.isInteger(e),`invalid defaultMaxInflation factor`,`value`,e),HD=e}static defaultAbiCoder(){return VD??=new e,VD}static getBuiltinCallException(t,n,r){return UD(t,n,r,e.defaultAbiCoder())}},GD=class{fragment;name;signature;topic;args;constructor(e,t,n){let r=e.name,i=e.format();G(this,{fragment:e,name:r,signature:i,topic:t,args:n})}},KD=class{fragment;name;args;signature;selector;value;constructor(e,t,n,r){let i=e.name,a=e.format();G(this,{fragment:e,name:i,args:n,signature:a,selector:t,value:r})}},qD=class{fragment;name;args;signature;selector;constructor(e,t,n){let r=e.name,i=e.format();G(this,{fragment:e,name:r,args:n,signature:i,selector:t})}},JD=class{hash;_isIndexed;static isIndexed(e){return!!(e&&e._isIndexed)}constructor(e){G(this,{hash:e,_isIndexed:!0})}},YD={0:`generic panic`,1:`assert(false)`,17:`arithmetic overflow`,18:`division or modulo by zero`,33:`enum overflow`,34:`invalid encoded storage byte array accessed`,49:`out-of-bounds array access; popping on an empty array`,50:`out-of-bounds access of an array or bytesN`,65:`out of memory`,81:`uninitialized function`},XD={"0x08c379a0":{signature:`Error(string)`,name:`Error`,inputs:[`string`],reason:e=>`reverted with reason string ${JSON.stringify(e)}`},"0x4e487b71":{signature:`Panic(uint256)`,name:`Panic`,inputs:[`uint256`],reason:e=>{let t=`unknown panic code`;return e>=0&&e<=255&&YD[e.toString()]&&(t=YD[e.toString()]),`reverted with panic code 0x${e.toString(16)} (${t})`}}},ZD=class e{fragments;deploy;fallback;receive;#e;#t;#n;#r;constructor(e){let t=[];t=typeof e==`string`?JSON.parse(e):e,this.#n=new Map,this.#e=new Map,this.#t=new Map;let n=[];for(let e of t)try{n.push(kD.from(e))}catch(t){console.log(`[Warning] Invalid Fragment ${JSON.stringify(e)}:`,t.message)}G(this,{fragments:Object.freeze(n)});let r=null,i=!1;this.#r=this.getAbiCoder(),this.fragments.forEach((e,t)=>{let n;switch(e.type){case`constructor`:if(this.deploy){console.log(`duplicate definition - constructor`);return}G(this,{deploy:e});return;case`fallback`:e.inputs.length===0?i=!0:(q(!r||e.payable!==r.payable,`conflicting fallback fragments`,`fragments[${t}]`,e),r=e,i=r.payable);return;case`function`:n=this.#n;break;case`event`:n=this.#t;break;case`error`:n=this.#e;break;default:return}let a=e.format();n.has(a)||n.set(a,e)}),this.deploy||G(this,{deploy:PD.from(`constructor()`)}),G(this,{fallback:r,receive:i})}format(e){let t=e?`minimal`:`full`;return this.fragments.map(e=>e.format(t))}formatJson(){let e=this.fragments.map(e=>e.format(`json`));return JSON.stringify(e.map(e=>JSON.parse(e)))}getAbiCoder(){return WD.defaultAbiCoder()}#i(e,t,n){if(Mv(e)){let t=e.toLowerCase();for(let e of this.#n.values())if(t===e.selector)return e;return null}if(e.indexOf(`(`)===-1){let r=[];for(let[t,n]of this.#n)t.split(`(`)[0]===e&&r.push(n);if(t){let e=t.length>0?t[t.length-1]:null,n=t.length,i=!0;WC.isTyped(e)&&e.type===`overrides`&&(i=!1,n--);for(let e=r.length-1;e>=0;e--){let t=r[e].inputs.length;t!==n&&(!i||t!==n-1)&&r.splice(e,1)}for(let e=r.length-1;e>=0;e--){let n=r[e].inputs;for(let i=0;i<t.length;i++)if(WC.isTyped(t[i])){if(i>=n.length){if(t[i].type===`overrides`)continue;r.splice(e,1);break}if(t[i].type!==n[i].baseType){r.splice(e,1);break}}}}if(r.length===1&&t&&t.length!==r[0].inputs.length){let e=t[t.length-1];(e==null||Array.isArray(e)||typeof e!=`object`)&&r.splice(0,1)}return r.length===0?null:(r.length>1&&n&&q(!1,`ambiguous function description (i.e. matches ${r.map(e=>JSON.stringify(e.format())).join(`, `)})`,`key`,e),r[0])}return this.#n.get(ID.from(e).format())||null}getFunctionName(e){let t=this.#i(e,null,!1);return q(t,`no matching function`,`key`,e),t.name}hasFunction(e){return!!this.#i(e,null,!1)}getFunction(e,t){return this.#i(e,t||null,!0)}forEachFunction(e){let t=Array.from(this.#n.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#n.get(r),n)}}#a(e,t,n){if(Mv(e)){let t=e.toLowerCase();for(let e of this.#t.values())if(t===e.topicHash)return e;return null}if(e.indexOf(`(`)===-1){let r=[];for(let[t,n]of this.#t)t.split(`(`)[0]===e&&r.push(n);if(t){for(let e=r.length-1;e>=0;e--)r[e].inputs.length<t.length&&r.splice(e,1);for(let e=r.length-1;e>=0;e--){let n=r[e].inputs;for(let i=0;i<t.length;i++)if(WC.isTyped(t[i])&&t[i].type!==n[i].baseType){r.splice(e,1);break}}}return r.length===0?null:(r.length>1&&n&&q(!1,`ambiguous event description (i.e. matches ${r.map(e=>JSON.stringify(e.format())).join(`, `)})`,`key`,e),r[0])}return this.#t.get(ND.from(e).format())||null}getEventName(e){let t=this.#a(e,null,!1);return q(t,`no matching event`,`key`,e),t.name}hasEvent(e){return!!this.#a(e,null,!1)}getEvent(e,t){return this.#a(e,t||null,!0)}forEachEvent(e){let t=Array.from(this.#t.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#t.get(r),n)}}getError(e,t){if(Mv(e)){let t=e.toLowerCase();if(XD[t])return MD.from(XD[t].signature);for(let e of this.#e.values())if(t===e.selector)return e;return null}if(e.indexOf(`(`)===-1){let t=[];for(let[n,r]of this.#e)n.split(`(`)[0]===e&&t.push(r);return t.length===0?e===`Error`?MD.from(`error Error(string)`):e===`Panic`?MD.from(`error Panic(uint256)`):null:(t.length>1&&q(!1,`ambiguous error description (i.e. ${t.map(e=>JSON.stringify(e.format())).join(`, `)})`,`name`,e),t[0])}return e=MD.from(e).format(),e===`Error(string)`?MD.from(`error Error(string)`):e===`Panic(uint256)`?MD.from(`error Panic(uint256)`):this.#e.get(e)||null}forEachError(e){let t=Array.from(this.#e.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#e.get(r),n)}}_decodeParams(e,t){return this.#r.decode(e,t)}_encodeParams(e,t){return this.#r.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e==`string`){let t=this.getError(e);q(t,`unknown error`,`fragment`,e),e=t}return q(Lv(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,`data`,t),this._decodeParams(e.inputs,Lv(t,4))}encodeErrorResult(e,t){if(typeof e==`string`){let t=this.getError(e);q(t,`unknown error`,`fragment`,e),e=t}return Fv([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}return q(Lv(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,`data`,t),this._decodeParams(e.inputs,Lv(t,4))}encodeFunctionData(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}return Fv([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}let n=`invalid length for result data`,r=jv(t);if(r.length%32==0)try{return this.#r.decode(e.outputs,r)}catch{n=`could not decode result data`}K(!1,n,`BAD_DATA`,{value:Y(r),info:{method:e.name,signature:e.format()}})}makeError(e,t){let n=J(e,`data`),r=WD.getBuiltinCallException(`call`,t,n);if(r.message.startsWith(`execution reverted (unknown custom error)`)){let e=Y(n.slice(0,4)),t=this.getError(e);if(t)try{let e=this.#r.decode(t.inputs,n.slice(4));r.revert={name:t.name,signature:t.format(),args:e},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch{r.message=`execution reverted (coult not decode custom error)`}}let i=this.parseTransaction(t);return i&&(r.invocation={method:i.name,signature:i.signature,args:i.args}),r}encodeFunctionResult(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}return Y(this.#r.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e==`string`){let t=this.getEvent(e);q(t,`unknown event`,`eventFragment`,e),e=t}K(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,`UNEXPECTED_ARGUMENT`,{count:t.length,expectedCount:e.inputs.length});let n=[];e.anonymous||n.push(e.topicHash);let r=(e,t)=>e.type===`string`?Gw(t):e.type===`bytes`?yx(Y(t)):(e.type===`bool`&&typeof t==`boolean`?t=t?`0x01`:`0x00`:e.type.match(/^u?int/)?t=Zv(t):e.type.match(/^bytes/)?t=Bv(t,32):e.type===`address`&&this.#r.encode([`address`],[t]),zv(Y(t),32));for(t.forEach((t,i)=>{let a=e.inputs[i];if(!a.indexed){q(t==null,`cannot filter non-indexed parameters; must be null`,`contract.`+a.name,t);return}t==null?n.push(null):a.baseType===`array`||a.baseType===`tuple`?q(!1,`filtering with tuples or arrays not supported`,`contract.`+a.name,t):Array.isArray(t)?n.push(t.map(e=>r(a,e))):n.push(r(a,t))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e==`string`){let t=this.getEvent(e);q(t,`unknown event`,`eventFragment`,e),e=t}let n=[],r=[],i=[];return e.anonymous||n.push(e.topicHash),q(t.length===e.inputs.length,`event arguments/values mismatch`,`values`,t),e.inputs.forEach((e,a)=>{let o=t[a];if(e.indexed)if(e.type===`string`)n.push(Gw(o));else if(e.type===`bytes`)n.push(yx(o));else if(e.baseType===`tuple`||e.baseType===`array`)throw Error(`not implemented`);else n.push(this.#r.encode([e.type],[o]));else r.push(e),i.push(o)}),{data:this.#r.encode(r,i),topics:n}}decodeEventLog(e,t,n){if(typeof e==`string`){let t=this.getEvent(e);q(t,`unknown event`,`eventFragment`,e),e=t}if(n!=null&&!e.anonymous){let t=e.topicHash;q(Mv(n[0],32)&&n[0].toLowerCase()===t,`fragment/topic mismatch`,`topics[0]`,n[0]),n=n.slice(1)}let r=[],i=[],a=[];e.inputs.forEach((e,t)=>{e.indexed?e.type===`string`||e.type===`bytes`||e.baseType===`tuple`||e.baseType===`array`?(r.push(OD.from({type:`bytes32`,name:e.name})),a.push(!0)):(r.push(e),a.push(!1)):(i.push(e),a.push(!1))});let o=n==null?null:this.#r.decode(r,Fv(n)),s=this.#r.decode(i,t,!0),c=[],l=[],u=0,d=0;return e.inputs.forEach((e,t)=>{let n=null;if(e.indexed)if(o==null)n=new JD(null);else if(a[t])n=new JD(o[d++]);else try{n=o[d++]}catch(e){n=e}else try{n=s[u++]}catch(e){n=e}c.push(n),l.push(e.name||null)}),Yy.fromItems(c,l)}parseTransaction(e){let t=J(e.data,`tx.data`),n=X(e.value==null?0:e.value,`tx.value`),r=this.getFunction(Y(t.slice(0,4)));if(!r)return null;let i=this.#r.decode(r.inputs,t.slice(4));return new KD(r,r.selector,i,n)}parseCallResult(e){throw Error(`@TODO`)}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new GD(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){let t=Y(e),n=this.getError(Lv(t,0,4));if(!n)return null;let r=this.#r.decode(n.inputs,Lv(t,4));return new qD(n,n.selector,r)}static from(t){return t instanceof e?t:typeof t==`string`?new e(JSON.parse(t)):typeof t.formatJson==`function`?new e(t.formatJson()):typeof t.format==`function`?new e(t.format(`json`)):new e(t)}},QD=BigInt(0);function $D(e){return e??null}function eO(e){return e==null?null:e.toString()}var tO=class{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(e,t,n){G(this,{gasPrice:$D(e),maxFeePerGas:$D(t),maxPriorityFeePerGas:$D(n)})}toJSON(){let{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:`FeeData`,gasPrice:eO(e),maxFeePerGas:eO(t),maxPriorityFeePerGas:eO(n)}}};function nO(e){let t={};e.to&&(t.to=e.to),e.from&&(t.from=e.from),e.data&&(t.data=Y(e.data));let n=`chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value`.split(/,/);for(let r of n)!(r in e)||e[r]==null||(t[r]=X(e[r],`request.${r}`));let r=`type,nonce`.split(/,/);for(let n of r)!(n in e)||e[n]==null||(t[n]=Z(e[n],`request.${n}`));return e.accessList&&(t.accessList=lw(e.accessList)),e.authorizationList&&(t.authorizationList=e.authorizationList.slice()),`blockTag`in e&&(t.blockTag=e.blockTag),`enableCcipRead`in e&&(t.enableCcipRead=!!e.enableCcipRead),`customData`in e&&(t.customData=e.customData),`blobVersionedHashes`in e&&e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.slice()),`kzg`in e&&(t.kzg=e.kzg),`blobWrapperVersion`in e&&(t.blobWrapperVersion=e.blobWrapperVersion),`blobs`in e&&e.blobs&&(t.blobs=e.blobs.map(e=>Nv(e)?Y(e):Object.assign({},e))),t}var rO=class{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#e;constructor(e,t){this.#e=e.transactions.map(e=>typeof e==`string`?e:new oO(e,t)),G(this,{provider:t,hash:$D(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:$D(e.prevRandao),extraData:e.extraData,baseFeePerGas:$D(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return this.#e.map(e=>typeof e==`string`?e:e.hash)}get prefetchedTransactions(){let e=this.#e.slice();return e.length===0?[]:(K(typeof e[0]==`object`,`transactions were not prefetched with block request`,`UNSUPPORTED_OPERATION`,{operation:`transactionResponses()`}),e)}toJSON(){let{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:r,gasUsed:i,hash:a,miner:o,prevRandao:s,nonce:c,number:l,parentHash:u,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:p,timestamp:m,transactions:h}=this;return{_type:`Block`,baseFeePerGas:eO(e),difficulty:eO(t),extraData:n,gasLimit:eO(r),gasUsed:eO(i),blobGasUsed:eO(this.blobGasUsed),excessBlobGas:eO(this.excessBlobGas),hash:a,miner:o,prevRandao:s,nonce:c,number:l,parentHash:u,timestamp:m,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:p,transactions:h}}[Symbol.iterator](){let e=0,t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#e.length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e==`number`)t=this.#e[e];else{let n=e.toLowerCase();for(let e of this.#e)if(typeof e==`string`){if(e!==n)continue;t=e;break}else{if(e.hash!==n)continue;t=e;break}}if(t==null)throw Error(`no such tx`);return typeof t==`string`?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){let t=this.prefetchedTransactions;if(typeof e==`number`)return t[e];e=e.toLowerCase();for(let n of t)if(n.hash===e)return n;q(!1,`no matching transaction`,`indexOrHash`,e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw Error(``);return sO(this)}},iO=class{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(e,t){this.provider=t;let n=Object.freeze(e.topics.slice());G(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){let{address:e,blockHash:t,blockNumber:n,data:r,index:i,removed:a,topics:o,transactionHash:s,transactionIndex:c}=this;return{_type:`log`,address:e,blockHash:t,blockNumber:n,data:r,index:i,removed:a,topics:o,transactionHash:s,transactionIndex:c}}async getBlock(){let e=await this.provider.getBlock(this.blockHash);return K(!!e,`failed to find transaction`,`UNKNOWN_ERROR`,{}),e}async getTransaction(){let e=await this.provider.getTransaction(this.transactionHash);return K(!!e,`failed to find transaction`,`UNKNOWN_ERROR`,{}),e}async getTransactionReceipt(){let e=await this.provider.getTransactionReceipt(this.transactionHash);return K(!!e,`failed to find transaction receipt`,`UNKNOWN_ERROR`,{}),e}removedEvent(){return uO(this)}},aO=class{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#e;constructor(e,t){this.#e=Object.freeze(e.logs.map(e=>new iO(e,t)));let n=QD;e.effectiveGasPrice==null?e.gasPrice!=null&&(n=e.gasPrice):n=e.effectiveGasPrice,G(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return this.#e}toJSON(){let{to:e,from:t,contractAddress:n,hash:r,index:i,blockHash:a,blockNumber:o,logsBloom:s,logs:c,status:l,root:u}=this;return{_type:`TransactionReceipt`,blockHash:a,blockNumber:o,contractAddress:n,cumulativeGasUsed:eO(this.cumulativeGasUsed),from:t,gasPrice:eO(this.gasPrice),blobGasUsed:eO(this.blobGasUsed),blobGasPrice:eO(this.blobGasPrice),gasUsed:eO(this.gasUsed),hash:r,index:i,logs:c,logsBloom:s,root:u,status:l,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){let e=await this.provider.getBlock(this.blockHash);if(e==null)throw Error(`TODO`);return e}async getTransaction(){let e=await this.provider.getTransaction(this.hash);if(e==null)throw Error(`TODO`);return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return lO(this)}reorderedEvent(e){return K(!e||e.isMined(),`unmined 'other' transction cannot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`reorderedEvent(other)`}),cO(this,e)}},oO=class e{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;authorizationList;#e;constructor(e,t){this.provider=t,this.blockNumber=e.blockNumber==null?null:e.blockNumber,this.blockHash=e.blockHash==null?null:e.blockHash,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas==null?null:e.maxPriorityFeePerGas,this.maxFeePerGas=e.maxFeePerGas==null?null:e.maxFeePerGas,this.maxFeePerBlobGas=e.maxFeePerBlobGas==null?null:e.maxFeePerBlobGas,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList==null?null:e.accessList,this.blobVersionedHashes=e.blobVersionedHashes==null?null:e.blobVersionedHashes,this.authorizationList=e.authorizationList==null?null:e.authorizationList,this.#e=-1}toJSON(){let{blockNumber:e,blockHash:t,index:n,hash:r,type:i,to:a,from:o,nonce:s,data:c,signature:l,accessList:u,blobVersionedHashes:d}=this;return{_type:`TransactionResponse`,accessList:u,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:eO(this.chainId),data:c,from:o,gasLimit:eO(this.gasLimit),gasPrice:eO(this.gasPrice),hash:r,maxFeePerGas:eO(this.maxFeePerGas),maxPriorityFeePerGas:eO(this.maxPriorityFeePerGas),maxFeePerBlobGas:eO(this.maxFeePerBlobGas),nonce:s,signature:l,to:a,index:n,type:i,value:eO(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){let t=await this.getTransaction();t&&(e=t.blockNumber)}if(e==null)return null;let t=this.provider.getBlock(e);if(t==null)throw Error(`TODO`);return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){let{tx:e,blockNumber:t}=await xv({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:t-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){let n=e??1,r=t??0,i=this.#e,a=-1,o=i===-1,s=async()=>{if(o)return null;let{blockNumber:e,nonce:t}=await xv({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(t<this.nonce){i=e;return}if(o)return null;let r=await this.getTransaction();if(!(r&&r.blockNumber!=null))for(a===-1&&(a=i-3,a<this.#e&&(a=this.#e));a<=e;){if(o)return null;let t=await this.provider.getBlock(a,!0);if(t==null)return;for(let e of t)if(e===this.hash)return;for(let r=0;r<t.length;r++){let a=await t.getTransaction(r);if(a.from===this.from&&a.nonce===this.nonce){if(o)return null;let t=await this.provider.getTransactionReceipt(a.hash);if(t==null||e-t.blockNumber+1<n)return;let r=`replaced`;a.data===this.data&&a.to===this.to&&a.value===this.value?r=`repriced`:a.data===`0x`&&a.from===a.to&&a.value===QD&&(r=`cancelled`),K(!1,`transaction was replaced`,`TRANSACTION_REPLACED`,{cancelled:r===`replaced`||r===`cancelled`,reason:r,replacement:a.replaceableTransaction(i),hash:a.hash,receipt:t})}}a++}},c=e=>{if(e==null||e.status!==0)return e;K(!1,`transaction execution reverted`,`CALL_EXCEPTION`,{action:`sendTransaction`,data:null,reason:null,invocation:null,revert:null,transaction:{to:e.to,from:e.from,data:``},receipt:e})},l=await this.provider.getTransactionReceipt(this.hash);if(n===0)return c(l);if(l){if(n===1||await l.confirmations()>=n)return c(l)}else if(await s(),n===0)return null;return await new Promise((e,t)=>{let a=[],l=()=>{a.forEach(e=>e())};if(a.push(()=>{o=!0}),r>0){let e=setTimeout(()=>{l(),t(Tv(`wait for transaction timeout`,`TIMEOUT`))},r);a.push(()=>{clearTimeout(e)})}let u=async r=>{if(await r.confirmations()>=n){l();try{e(c(r))}catch(e){t(e)}}};if(a.push(()=>{this.provider.off(this.hash,u)}),this.provider.on(this.hash,u),i>=0){let e=async()=>{try{await s()}catch(e){if(Cv(e,`TRANSACTION_REPLACED`)){l(),t(e);return}}o||this.provider.once(`block`,e)};a.push(()=>{this.provider.off(`block`,e)}),this.provider.once(`block`,e)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return K(this.isMined(),`unmined transaction canot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`removeEvent()`}),lO(this)}reorderedEvent(e){return K(this.isMined(),`unmined transaction canot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`removeEvent()`}),K(!e||e.isMined(),`unmined 'other' transaction canot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`removeEvent()`}),cO(this,e)}replaceableTransaction(t){q(Number.isInteger(t)&&t>=0,`invalid startBlock`,`startBlock`,t);let n=new e(this,this.provider);return n.#e=t,n}};function sO(e){return{orphan:`drop-block`,hash:e.hash,number:e.number}}function cO(e,t){return{orphan:`reorder-transaction`,tx:e,other:t}}function lO(e){return{orphan:`drop-transaction`,tx:e}}function uO(e){return{orphan:`drop-log`,log:{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,address:e.address,data:e.data,topics:Object.freeze(e.topics.slice()),index:e.index}}}var dO=class extends iO{interface;fragment;args;constructor(e,t,n){super(e,e.provider);let r=t.decodeEventLog(n,e.data,e.topics);G(this,{args:r,fragment:n,interface:t})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}},fO=class extends iO{error;constructor(e,t){super(e,e.provider),G(this,{error:t})}},pO=class extends aO{#e;constructor(e,t,n){super(n,t),this.#e=e}get logs(){return super.logs.map(e=>{let t=e.topics.length?this.#e.getEvent(e.topics[0]):null;if(t)try{return new dO(e,this.#e,t)}catch(t){return new fO(e,t)}return e})}},mO=class extends oO{#e;constructor(e,t,n){super(n,t),this.#e=e}async wait(e,t){let n=await super.wait(e,t);return n==null?null:new pO(this.#e,this.provider,n)}},hO=class extends ay{log;constructor(e,t,n,r){super(e,t,n),G(this,{log:r})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}},gO=class extends hO{constructor(e,t,n,r,i){super(e,t,n,new dO(i,e.interface,r));let a=e.interface.decodeEventLog(r,this.log.data,this.log.topics);G(this,{args:a,fragment:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}},_O=BigInt(0);function vO(e){return e&&typeof e.call==`function`}function yO(e){return e&&typeof e.estimateGas==`function`}function bO(e){return e&&typeof e.resolveName==`function`}function xO(e){return e&&typeof e.sendTransaction==`function`}function SO(e){if(e!=null){if(bO(e))return e;if(e.provider)return e.provider}}var CO=class{#e;fragment;constructor(e,t,n){if(G(this,{fragment:t}),t.inputs.length<n.length)throw Error(`too many arguments`);let r=wO(e.runner,`resolveName`),i=bO(r)?r:null;this.#e=(async function(){let r=await Promise.all(t.inputs.map((e,t)=>n[t]==null?null:e.walkAsync(n[t],(e,t)=>e===`address`?Array.isArray(t)?Promise.all(t.map(e=>BC(e,i))):BC(t,i):t)));return e.interface.encodeFilterTopics(t,r)})()}getTopicFilter(){return this.#e}};function wO(e,t){return e==null?null:typeof e[t]==`function`?e:e.provider&&typeof e.provider[t]==`function`?e.provider:null}function TO(e){return e==null?null:e.provider||null}async function EO(e,t){let n=WC.dereference(e,`overrides`);q(typeof n==`object`,`invalid overrides parameter`,`overrides`,e);let r=nO(n);return q(r.to==null||(t||[]).indexOf(`to`)>=0,`cannot override to`,`overrides.to`,r.to),q(r.data==null||(t||[]).indexOf(`data`)>=0,`cannot override data`,`overrides.data`,r.data),r.from&&=r.from,r}async function DO(e,t,n){let r=wO(e,`resolveName`),i=bO(r)?r:null;return await Promise.all(t.map((e,t)=>e.walkAsync(n[t],(e,t)=>(t=WC.dereference(t,e),e===`address`?BC(t,i):t))))}function OO(e){let t=async function(t){let n=await EO(t,[`data`]);n.to=await e.getAddress(),n.from&&=await BC(n.from,SO(e.runner));let r=e.interface,i=X(n.value||_O,`overrides.value`)===_O,a=(n.data||`0x`)===`0x`;return r.fallback&&!r.fallback.payable&&r.receive&&!a&&!i&&q(!1,`cannot send data to receive or send value to non-payable fallback`,`overrides`,t),q(r.fallback||a,`cannot send data to receive-only contract`,`overrides.data`,n.data),q(r.receive||r.fallback&&r.fallback.payable||i,`cannot send value to non-payable fallback`,`overrides.value`,n.value),q(r.fallback||a,`cannot send data to receive-only contract`,`overrides.data`,n.data),n},n=async function(n){let r=wO(e.runner,`call`);K(vO(r),`contract runner does not support calling`,`UNSUPPORTED_OPERATION`,{operation:`call`});let i=await t(n);try{return await r.call(i)}catch(t){throw wv(t)&&t.data?e.interface.makeError(t.data,i):t}},r=async function(n){let r=e.runner;K(xO(r),`contract runner does not support sending transactions`,`UNSUPPORTED_OPERATION`,{operation:`sendTransaction`});let i=await r.sendTransaction(await t(n)),a=TO(e.runner);return new mO(e.interface,a,i)},i=async function(n){let r=wO(e.runner,`estimateGas`);return K(yO(r),`contract runner does not support gas estimation`,`UNSUPPORTED_OPERATION`,{operation:`estimateGas`}),await r.estimateGas(await t(n))},a=async e=>await r(e);return G(a,{_contract:e,estimateGas:i,populateTransaction:t,send:r,staticCall:n}),a}function kO(e,t){let n=function(...n){let r=e.interface.getFunction(t,n);return K(r,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t,args:n}}),r},r=async function(...t){let r=n(...t),i={};if(r.inputs.length+1===t.length&&(i=await EO(t.pop()),i.from&&=await BC(i.from,SO(e.runner))),r.inputs.length!==t.length)throw Error(`internal error: fragment inputs doesn't match arguments; should not happen`);let a=await DO(e.runner,r.inputs,t);return Object.assign({},i,await xv({to:e.getAddress(),data:e.interface.encodeFunctionData(r,a)}))},i=async function(...e){let t=await s(...e);return t.length===1?t[0]:t},a=async function(...t){let n=e.runner;K(xO(n),`contract runner does not support sending transactions`,`UNSUPPORTED_OPERATION`,{operation:`sendTransaction`});let i=await n.sendTransaction(await r(...t)),a=TO(e.runner);return new mO(e.interface,a,i)},o=async function(...t){let n=wO(e.runner,`estimateGas`);return K(yO(n),`contract runner does not support gas estimation`,`UNSUPPORTED_OPERATION`,{operation:`estimateGas`}),await n.estimateGas(await r(...t))},s=async function(...t){let i=wO(e.runner,`call`);K(vO(i),`contract runner does not support calling`,`UNSUPPORTED_OPERATION`,{operation:`call`});let a=await r(...t),o=`0x`;try{o=await i.call(a)}catch(t){throw wv(t)&&t.data?e.interface.makeError(t.data,a):t}let s=n(...t);return e.interface.decodeFunctionResult(s,o)},c=async(...e)=>n(...e).constant?await i(...e):await a(...e);return G(c,{name:e.interface.getFunctionName(t),_contract:e,_key:t,getFragment:n,estimateGas:o,populateTransaction:r,send:a,staticCall:i,staticCallResult:s}),Object.defineProperty(c,`fragment`,{configurable:!1,enumerable:!0,get:()=>{let n=e.interface.getFunction(t);return K(n,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t}}),n}}),c}function AO(e,t){let n=function(...n){let r=e.interface.getEvent(t,n);return K(r,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t,args:n}}),r},r=function(...t){return new CO(e,n(...t),t)};return G(r,{name:e.interface.getEventName(t),_contract:e,_key:t,getFragment:n}),Object.defineProperty(r,`fragment`,{configurable:!1,enumerable:!0,get:()=>{let n=e.interface.getEvent(t);return K(n,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t}}),n}}),r}var jO=Symbol.for(`_ethersInternal_contract`),MO=new WeakMap;function NO(e,t){MO.set(e[jO],t)}function PO(e){return MO.get(e[jO])}function FO(e){return e&&typeof e==`object`&&`getTopicFilter`in e&&typeof e.getTopicFilter==`function`&&e.fragment}async function IO(e,t){let n,r=null;if(Array.isArray(t)){let r=function(t){if(Mv(t,32))return t;let n=e.interface.getEvent(t);return q(n,`unknown fragment`,`name`,t),n.topicHash};n=t.map(e=>e==null?null:Array.isArray(e)?e.map(r):r(e))}else t===`*`?n=[null]:typeof t==`string`?Mv(t,32)?n=[t]:(r=e.interface.getEvent(t),q(r,`unknown fragment`,`event`,t),n=[r.topicHash]):FO(t)?n=await t.getTopicFilter():`fragment`in t?(r=t.fragment,n=[r.topicHash]):q(!1,`unknown event name`,`event`,t);n=n.map(e=>{if(e==null)return null;if(Array.isArray(e)){let t=Array.from(new Set(e.map(e=>e.toLowerCase())).values());return t.length===1?t[0]:(t.sort(),t)}return e.toLowerCase()});let i=n.map(e=>e==null?`null`:Array.isArray(e)?e.join(`|`):e).join(`&`);return{fragment:r,tag:i,topics:n}}async function LO(e,t){let{subs:n}=PO(e);return n.get((await IO(e,t)).tag)||null}async function RO(e,t,n){let r=TO(e.runner);K(r,`contract runner does not support subscribing`,`UNSUPPORTED_OPERATION`,{operation:t});let{fragment:i,tag:a,topics:o}=await IO(e,n),{addr:s,subs:c}=PO(e),l=c.get(a);if(!l){let t={address:s||e,topics:o},u=t=>{let r=i;if(r==null)try{r=e.interface.getEvent(t.topics[0])}catch{}if(r){let a=r;VO(e,n,i?e.interface.decodeEventLog(i,t.data,t.topics):[],r=>new gO(e,r,n,a,t))}else VO(e,n,[],r=>new hO(e,r,n,t))},d=[];l={tag:a,listeners:[],start:()=>{d.length||d.push(r.on(t,u))},stop:async()=>{if(d.length==0)return;let e=d;d=[],await Promise.all(e),r.off(t,u)}},c.set(a,l)}return l}var zO=Promise.resolve();async function BO(e,t,n,r){await zO;let i=await LO(e,t);if(!i)return!1;let a=i.listeners.length;return i.listeners=i.listeners.filter(({listener:t,once:i})=>{let a=Array.from(n);r&&a.push(r(i?null:t));try{t.call(e,...a)}catch{}return!i}),i.listeners.length===0&&(i.stop(),PO(e).subs.delete(i.tag)),a>0}async function VO(e,t,n,r){try{await zO}catch{}let i=BO(e,t,n,r);return zO=i,await i}var HO=[`then`],UO=class e{target;interface;runner;filters;[jO];fallback;constructor(e,t,n,r){q(typeof e==`string`||RC(e),`invalid value for Contract target`,`target`,e),n??=null;let i=ZD.from(t);G(this,{target:e,runner:n,interface:i}),Object.defineProperty(this,jO,{value:{}});let a,o=null,s=null;if(r){let e=TO(n);s=new mO(this.interface,e,r)}let c=new Map;if(typeof e==`string`)if(Mv(e))o=e,a=Promise.resolve(e);else{let t=wO(n,`resolveName`);if(!bO(t))throw Tv(`contract runner does not support name resolution`,`UNSUPPORTED_OPERATION`,{operation:`resolveName`});a=t.resolveName(e).then(t=>{if(t==null)throw Tv(`an ENS name used for a contract target must be correctly configured`,`UNCONFIGURED_NAME`,{value:e});return PO(this).addr=t,t})}else a=e.getAddress().then(e=>{if(e==null)throw Error(`TODO`);return PO(this).addr=e,e});NO(this,{addrPromise:a,addr:o,deployTx:s,subs:c});let l=new Proxy({},{get:(e,t,n)=>{if(typeof t==`symbol`||HO.indexOf(t)>=0)return Reflect.get(e,t,n);try{return this.getEvent(t)}catch(e){if(!Cv(e,`INVALID_ARGUMENT`)||e.argument!==`key`)throw e}},has:(e,t)=>HO.indexOf(t)>=0?Reflect.has(e,t):Reflect.has(e,t)||this.interface.hasEvent(String(t))});return G(this,{filters:l}),G(this,{fallback:i.receive||i.fallback?OO(this):null}),new Proxy(this,{get:(e,t,n)=>{if(typeof t==`symbol`||t in e||HO.indexOf(t)>=0)return Reflect.get(e,t,n);try{return e.getFunction(t)}catch(e){if(!Cv(e,`INVALID_ARGUMENT`)||e.argument!==`key`)throw e}},has:(e,t)=>typeof t==`symbol`||t in e||HO.indexOf(t)>=0?Reflect.has(e,t):e.interface.hasFunction(t)})}connect(t){return new e(this.target,this.interface,t)}attach(t){return new e(t,this.interface,this.runner)}async getAddress(){return await PO(this).addrPromise}async getDeployedCode(){let e=TO(this.runner);K(e,`runner does not support .provider`,`UNSUPPORTED_OPERATION`,{operation:`getDeployedCode`});let t=await e.getCode(await this.getAddress());return t===`0x`?null:t}async waitForDeployment(){let e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;let t=TO(this.runner);return K(t!=null,`contract runner does not support .provider`,`UNSUPPORTED_OPERATION`,{operation:`waitForDeployment`}),new Promise((e,n)=>{let r=async()=>{try{if(await this.getDeployedCode()!=null)return e(this);t.once(`block`,r)}catch(e){n(e)}};r()})}deploymentTransaction(){return PO(this).deployTx}getFunction(e){return typeof e!=`string`&&(e=e.format()),kO(this,e)}getEvent(e){return typeof e!=`string`&&(e=e.format()),AO(this,e)}async queryTransaction(e){throw Error(`@TODO`)}async queryFilter(e,t,n){t??=0,n??=`latest`;let{addr:r,addrPromise:i}=PO(this),a=r||await i,{fragment:o,topics:s}=await IO(this,e),c={address:a,topics:s,fromBlock:t,toBlock:n},l=TO(this.runner);return K(l,`contract runner does not have a provider`,`UNSUPPORTED_OPERATION`,{operation:`queryFilter`}),(await l.getLogs(c)).map(e=>{let t=o;if(t==null)try{t=this.interface.getEvent(e.topics[0])}catch{}if(t)try{return new dO(e,this.interface,t)}catch(t){return new fO(e,t)}return new iO(e,l)})}async on(e,t){let n=await RO(this,`on`,e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){let n=await RO(this,`once`,e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await VO(this,e,t,null)}async listenerCount(e){if(e){let t=await LO(this,e);return t?t.listeners.length:0}let{subs:t}=PO(this),n=0;for(let{listeners:e}of t.values())n+=e.length;return n}async listeners(e){if(e){let t=await LO(this,e);return t?t.listeners.map(({listener:e})=>e):[]}let{subs:t}=PO(this),n=[];for(let{listeners:e}of t.values())n=n.concat(e.map(({listener:e})=>e));return n}async off(e,t){let n=await LO(this,e);if(!n)return this;if(t){let e=n.listeners.map(({listener:e})=>e).indexOf(t);e>=0&&n.listeners.splice(e,1)}return(t==null||n.listeners.length===0)&&(n.stop(),PO(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){let t=await LO(this,e);if(!t)return this;t.stop(),PO(this).subs.delete(t.tag)}else{let{subs:e}=PO(this);for(let{tag:t,stop:n}of e.values())n(),e.delete(t)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(t){class n extends e{constructor(e,n=null){super(e,t,n)}}return n}static from(e,t,n){return n??=null,new this(e,t,n)}};function WO(){return UO}var GO=class extends WO(){};function KO(e){return e.match(/^ipfs:\/\/ipfs\//i)?e=e.substring(12):e.match(/^ipfs:\/\//i)?e=e.substring(7):q(!1,`unsupported IPFS format`,`link`,e),`https:/\/gateway.ipfs.io/ipfs/${e}`}var qO=class{name;constructor(e){G(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw Error(`unsupported coin`)}async decodeAddress(e,t){throw Error(`unsupported coin`)}},JO=RegExp(`^(ipfs)://(.*)$`,`i`),YO=[RegExp(`^(https)://(.*)$`,`i`),RegExp(`^(data):(.*)$`,`i`),JO,RegExp(`^eip155:[0-9]+/(erc[0-9]+):(.*)$`,`i`)],XO=class e{provider;address;name;#e;#t;constructor(e,t,n){G(this,{provider:e,address:t,name:n}),this.#e=null,this.#t=new GO(t,[`function supportsInterface(bytes4) view returns (bool)`,`function resolve(bytes, bytes) view returns (bytes)`,`function addr(bytes32) view returns (address)`,`function addr(bytes32, uint) view returns (bytes)`,`function text(bytes32, string) view returns (string)`,`function contenthash(bytes32) view returns (bytes)`],e)}async supportsWildcard(){return this.#e??=(async()=>{try{return await this.#t.supportsInterface(`0x9061b923`)}catch(e){if(Cv(e,`CALL_EXCEPTION`))return!1;throw this.#e=null,e}})(),await this.#e}async#n(e,t){t=(t||[]).slice();let n=this.#t.interface;t.unshift(kE(this.name));let r=null;await this.supportsWildcard()&&(r=n.getFunction(e),K(r,`missing fragment`,`UNKNOWN_ERROR`,{info:{funcName:e}}),t=[AE(this.name,255),n.encodeFunctionData(r,t)],e=`resolve(bytes,bytes)`),t.push({enableCcipRead:!0});try{let i=await this.#t[e](...t);return r?n.decodeFunctionResult(r,i)[0]:i}catch(e){if(!Cv(e,`CALL_EXCEPTION`))throw e}return null}async getAddress(e){if(e??=60,e===60)try{let e=await this.#n(`addr(bytes32)`);return e==null||e===`0x0000000000000000000000000000000000000000`?null:e}catch(e){if(Cv(e,`CALL_EXCEPTION`))return null;throw e}if(e>=0&&e<2147483648){let t=e+2147483648,n=await this.#n(`addr(bytes32,uint)`,[t]);if(Mv(n,20))return IC(n)}let t=null;for(let n of this.provider.plugins)if(n instanceof qO&&n.supportsCoinType(e)){t=n;break}if(t==null)return null;let n=await this.#n(`addr(bytes32,uint)`,[e]);if(n==null||n===`0x`)return null;let r=await t.decodeAddress(e,n);if(r!=null)return r;K(!1,`invalid coin data`,`UNSUPPORTED_OPERATION`,{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){let t=await this.#n(`text(bytes32,string)`,[e]);return t==null||t===`0x`?null:t}async getContentHash(){let e=await this.#n(`contenthash(bytes32)`);if(e==null||e===`0x`)return null;let t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){let e=t[1]===`e3010170`?`ipfs`:`ipns`,n=parseInt(t[4],16);if(t[5].length===n*2)return`${e}:/\/${ny(`0x`+t[2])}`}let n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz:/\/${n[1]}`;K(!1,`invalid or unsupported content hash data`,`UNSUPPORTED_OPERATION`,{operation:`getContentHash()`,info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){let e=[{type:`name`,value:this.name}];try{let t=await this.getText(`avatar`);if(t==null)return e.push({type:`!avatar`,value:``}),{url:null,linkage:e};e.push({type:`avatar`,value:t});for(let n=0;n<YO.length;n++){let r=t.match(YO[n]);if(r==null)continue;let i=r[1].toLowerCase();switch(i){case`https`:case`data`:return e.push({type:`url`,value:t}),{linkage:e,url:t};case`ipfs`:{let n=KO(t);return e.push({type:`ipfs`,value:t}),e.push({type:`url`,value:n}),{linkage:e,url:n}}case`erc721`:case`erc1155`:{let n=i===`erc721`?`tokenURI(uint256)`:`uri(uint256)`;e.push({type:i,value:t});let a=await this.getAddress();if(a==null)return e.push({type:`!owner`,value:``}),{url:null,linkage:e};let o=(r[2]||``).split(`/`);if(o.length!==2)return e.push({type:`!${i}caip`,value:r[2]||``}),{url:null,linkage:e};let s=o[1],c=new GO(o[0],[`function tokenURI(uint) view returns (string)`,`function ownerOf(uint) view returns (address)`,`function uri(uint) view returns (string)`,`function balanceOf(address, uint256) view returns (uint)`],this.provider);if(i===`erc721`){let t=await c.ownerOf(s);if(a!==t)return e.push({type:`!owner`,value:t}),{url:null,linkage:e};e.push({type:`owner`,value:t})}else if(i===`erc1155`){let t=await c.balanceOf(a,s);if(!t)return e.push({type:`!balance`,value:`0`}),{url:null,linkage:e};e.push({type:`balance`,value:t.toString()})}let l=await c[n](s);if(l==null||l===`0x`)return e.push({type:`!metadata-url`,value:``}),{url:null,linkage:e};e.push({type:`metadata-url-base`,value:l}),i===`erc1155`&&(l=l.replace(`{id}`,Zv(s,32).substring(2)),e.push({type:`metadata-url-expanded`,value:l})),l.match(/^ipfs:/i)&&(l=KO(l)),e.push({type:`metadata-url`,value:l});let u={},d=await new Dy(l).send();d.assertOk();try{u=d.bodyJson}catch{try{e.push({type:`!metadata`,value:d.bodyText})}catch{let t=d.body;return t&&e.push({type:`!metadata`,value:Y(t)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!u)return e.push({type:`!metadata`,value:``}),{url:null,linkage:e};e.push({type:`metadata`,value:JSON.stringify(u)});let f=u.image;if(typeof f!=`string`)return e.push({type:`!imageUrl`,value:``}),{url:null,linkage:e};if(!f.match(/^(https:\/\/|data:)/i)){if(f.match(JO)==null)return e.push({type:`!imageUrl-ipfs`,value:f}),{url:null,linkage:e};e.push({type:`imageUrl-ipfs`,value:f}),f=KO(f)}return e.push({type:`url`,value:f}),{linkage:e,url:f}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){let t=await e.getNetwork(),n=t.getPlugin(`org.ethers.plugins.network.Ens`);return K(n,`network does not support ENS`,`UNSUPPORTED_OPERATION`,{operation:`getEnsAddress`,info:{network:t}}),n.address}static async#r(t,n){let r=await e.getEnsAddress(t);try{let e=await new GO(r,[`function resolver(bytes32) view returns (address)`],t).resolver(kE(n),{enableCcipRead:!0});return e===`0x0000000000000000000000000000000000000000`?null:e}catch(e){throw e}return null}static async fromName(t,n){let r=n;for(;;){if(r===``||r===`.`||n!==`eth`&&r===`eth`)return null;let i=await e.#r(t,r);if(i!=null){let a=new e(t,i,n);return r!==n&&!await a.supportsWildcard()?null:a}r=r.split(`.`).slice(1).join(`.`)}}},ZO=BigInt(0);function QO(e,t){return(function(n){return n==null?t:e(n)})}function $O(e,t){return(n=>{if(t&&n==null)return null;if(!Array.isArray(n))throw Error(`not an array`);return n.map(t=>e(t))})}function ek(e,t){return(n=>{let r={};for(let i in e){let a=i;if(t&&i in t&&!(a in n)){for(let e of t[i])if(e in n){a=e;break}}try{let t=e[i](n[a]);t!==void 0&&(r[i]=t)}catch(e){K(!1,`invalid value for value.${i} (${e instanceof Error?e.message:`not-an-error`})`,`BAD_DATA`,{value:n})}}return r})}function tk(e){switch(e){case!0:case`true`:return!0;case!1:case`false`:return!1}q(!1,`invalid boolean; ${JSON.stringify(e)}`,`value`,e)}function nk(e){return q(Mv(e,!0),`invalid data`,`value`,e),e}function rk(e){return q(Mv(e,32),`invalid hash`,`value`,e),e}var ik=ek({address:IC,blockHash:rk,blockNumber:Z,data:nk,index:Z,removed:QO(tk,!1),topics:$O(rk),transactionHash:rk,transactionIndex:Z},{index:[`logIndex`]});function ak(e){return ik(e)}var ok=ek({hash:QO(rk),parentHash:rk,parentBeaconBlockRoot:QO(rk,null),number:Z,timestamp:Z,nonce:QO(nk),difficulty:X,gasLimit:X,gasUsed:X,stateRoot:QO(rk,null),receiptsRoot:QO(rk,null),blobGasUsed:QO(X,null),excessBlobGas:QO(X,null),miner:QO(IC),prevRandao:QO(rk,null),extraData:nk,baseFeePerGas:QO(X)},{prevRandao:[`mixHash`]});function sk(e){let t=ok(e);return t.transactions=e.transactions.map(e=>typeof e==`string`?e:fk(e)),t}var ck=ek({transactionIndex:Z,blockNumber:Z,transactionHash:rk,address:IC,topics:$O(rk),data:nk,index:Z,blockHash:rk},{index:[`logIndex`]});function lk(e){return ck(e)}var uk=ek({to:QO(IC,null),from:QO(IC,null),contractAddress:QO(IC,null),index:Z,root:QO(Y),gasUsed:X,blobGasUsed:QO(X,null),logsBloom:QO(nk),blockHash:rk,hash:rk,logs:$O(lk),blockNumber:Z,cumulativeGasUsed:X,effectiveGasPrice:QO(X),blobGasPrice:QO(X,null),status:QO(Z),type:QO(Z,0)},{effectiveGasPrice:[`gasPrice`],hash:[`transactionHash`],index:[`transactionIndex`]});function dk(e){return uk(e)}function fk(e){e.to&&X(e.to)===ZO&&(e.to=`0x0000000000000000000000000000000000000000`);let t=ek({hash:rk,index:QO(Z,void 0),type:e=>e===`0x`||e==null?0:Z(e),accessList:QO(lw,null),blobVersionedHashes:QO($O(rk,!0),null),authorizationList:QO($O(e=>{let t;if(e.signature)t=e.signature;else{let n=e.yParity;n===`0x1b`?n=0:n===`0x1c`&&(n=1),t=Object.assign({},e,{yParity:n})}return{address:IC(e.address),chainId:X(e.chainId),nonce:X(e.nonce),signature:EC.from(t)}},!1),null),blockHash:QO(rk,null),blockNumber:QO(Z,null),transactionIndex:QO(Z,null),from:IC,gasPrice:QO(X),maxPriorityFeePerGas:QO(X),maxFeePerGas:QO(X),maxFeePerBlobGas:QO(X,null),gasLimit:X,to:QO(IC,null),value:X,nonce:Z,data:nk,creates:QO(IC,null),chainId:QO(X,null)},{data:[`input`],gasLimit:[`gas`],index:[`transactionIndex`]})(e);if(t.to==null&&t.creates==null&&(t.creates=LC(t)),(e.type===1||e.type===2)&&e.accessList==null&&(t.accessList=[]),e.signature?t.signature=EC.from(e.signature):t.signature=EC.from(e),t.chainId==null){let e=t.signature.legacyChainId;e!=null&&(t.chainId=e)}return t.blockHash&&X(t.blockHash)===ZO&&(t.blockHash=null),t}var pk=`0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e`,mk=class e{name;constructor(e){G(this,{name:e})}clone(){return new e(this.name)}},hk=class e extends mk{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(e,t){e??=0,super(`org.ethers.network.plugins.GasCost#${e||0}`);let n={effectiveBlock:e};function r(e,r){let i=(t||{})[e];i??=r,q(typeof i==`number`,`invalud value for ${e}`,`costs`,t),n[e]=i}r(`txBase`,21e3),r(`txCreate`,32e3),r(`txDataZero`,4),r(`txDataNonzero`,16),r(`txAccessListStorageKey`,1900),r(`txAccessListAddress`,2400),G(this,n)}clone(){return new e(this.effectiveBlock,this)}},gk=class e extends mk{address;targetNetwork;constructor(e,t){super(`org.ethers.plugins.network.Ens`),G(this,{address:e||pk,targetNetwork:t??1})}clone(){return new e(this.address,this.targetNetwork)}},_k=class extends mk{#e;#t;get url(){return this.#e}get processFunc(){return this.#t}constructor(e,t){super(`org.ethers.plugins.network.FetchUrlFeeDataPlugin`),this.#e=e,this.#t=t}clone(){return this}},vk=new Map,yk=class e{#e;#t;#n;constructor(e,t){this.#e=e,this.#t=X(t),this.#n=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#e}set name(e){this.#e=e}get chainId(){return this.#t}set chainId(e){this.#t=X(e,`chainId`)}matches(e){if(e==null)return!1;if(typeof e==`string`){try{return this.chainId===X(e)}catch{}return this.name===e}if(typeof e==`number`||typeof e==`bigint`){try{return this.chainId===X(e)}catch{}return!1}if(typeof e==`object`){if(e.chainId!=null){try{return this.chainId===X(e.chainId)}catch{}return!1}return e.name==null?!1:this.name===e.name}return!1}get plugins(){return Array.from(this.#n.values())}attachPlugin(e){if(this.#n.get(e.name))throw Error(`cannot replace existing plugin: ${e.name} `);return this.#n.set(e.name,e.clone()),this}getPlugin(e){return this.#n.get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split(`#`)[0]===e)}clone(){let t=new e(this.name,this.chainId);return this.plugins.forEach(e=>{t.attachPlugin(e.clone())}),t}computeIntrinsicGas(e){let t=this.getPlugin(`org.ethers.plugins.network.GasCost`)||new hk,n=t.txBase;if(e.to??(n+=t.txCreate),e.data)for(let r=2;r<e.data.length;r+=2)e.data.substring(r,r+2)===`00`?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){let r=lw(e.accessList);for(let e in r)n+=t.txAccessListAddress+t.txAccessListStorageKey*r[e].storageKeys.length}return n}static from(t){if(Ck(),t==null)return e.from(`mainnet`);if(typeof t==`number`&&(t=BigInt(t)),typeof t==`string`||typeof t==`bigint`){let n=vk.get(t);if(n)return n();if(typeof t==`bigint`)return new e(`unknown`,t);q(!1,`unknown network`,`network`,t)}if(typeof t.clone==`function`)return t.clone();if(typeof t==`object`){q(typeof t.name==`string`&&typeof t.chainId==`number`,`invalid network object name or chainId`,`network`,t);let n=new e(t.name,t.chainId);return(t.ensAddress||t.ensNetwork!=null)&&n.attachPlugin(new gk(t.ensAddress,t.ensNetwork)),n}q(!1,`invalid network`,`network`,t)}static register(e,t){typeof e==`number`&&(e=BigInt(e));let n=vk.get(e);n&&q(!1,`conflicting network for ${JSON.stringify(n.name)}`,`nameOrChainId`,e),vk.set(e,t)}};function bk(e,t){let n=String(e);if(!n.match(/^[0-9.]+$/))throw Error(`invalid gwei value: ${e}`);let r=n.split(`.`);if(r.length===1&&r.push(``),r.length!==2)throw Error(`invalid gwei value: ${e}`);for(;r[1].length<t;)r[1]+=`0`;if(r[1].length>9){let e=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||e++,r[1]=e.toString()}return BigInt(r[0]+r[1])}function xk(e){return new _k(e,async(e,t,n)=>{n.setHeader(`User-Agent`,`ethers`);let r;try{let[t,i]=await Promise.all([n.send(),e()]);r=t;let a=r.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:bk(a.maxFee,9),maxPriorityFeePerGas:bk(a.maxPriorityFee,9)}}catch(e){K(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,`SERVER_ERROR`,{request:n,response:r,error:e})}})}var Sk=!1;function Ck(){if(Sk)return;Sk=!0;function e(e,t,n){let r=function(){let r=new yk(e,t);return n.ensNetwork!=null&&r.attachPlugin(new gk(null,n.ensNetwork)),r.attachPlugin(new hk),(n.plugins||[]).forEach(e=>{r.attachPlugin(e)}),r};yk.register(e,r),yk.register(t,r),n.altNames&&n.altNames.forEach(e=>{yk.register(e,r)})}e(`mainnet`,1,{ensNetwork:1,altNames:[`homestead`]}),e(`ropsten`,3,{ensNetwork:3}),e(`rinkeby`,4,{ensNetwork:4}),e(`goerli`,5,{ensNetwork:5}),e(`kovan`,42,{ensNetwork:42}),e(`sepolia`,11155111,{ensNetwork:11155111}),e(`holesky`,17e3,{ensNetwork:17e3}),e(`classic`,61,{}),e(`classicKotti`,6,{}),e(`arbitrum`,42161,{ensNetwork:1}),e(`arbitrum-goerli`,421613,{}),e(`arbitrum-sepolia`,421614,{}),e(`base`,8453,{ensNetwork:1}),e(`base-goerli`,84531,{}),e(`base-sepolia`,84532,{}),e(`bnb`,56,{ensNetwork:1}),e(`bnbt`,97,{}),e(`filecoin`,314,{}),e(`filecoin-calibration`,314159,{}),e(`linea`,59144,{ensNetwork:1}),e(`linea-goerli`,59140,{}),e(`linea-sepolia`,59141,{}),e(`matic`,137,{ensNetwork:1,plugins:[xk(`https://gasstation.polygon.technology/v2`)]}),e(`matic-amoy`,80002,{}),e(`matic-mumbai`,80001,{altNames:[`maticMumbai`,`maticmum`],plugins:[xk(`https://gasstation-testnet.polygon.technology/v2`)]}),e(`optimism`,10,{ensNetwork:1,plugins:[]}),e(`optimism-goerli`,420,{}),e(`optimism-sepolia`,11155420,{}),e(`xdai`,100,{ensNetwork:1})}function wk(e){return JSON.parse(JSON.stringify(e))}var Tk=class{#e;#t;#n;#r;constructor(e){this.#e=e,this.#t=null,this.#n=4e3,this.#r=-2}get pollingInterval(){return this.#n}set pollingInterval(e){this.#n=e}async#i(){try{let e=await this.#e.getBlockNumber();if(this.#r===-2){this.#r=e;return}if(e!==this.#r){for(let t=this.#r+1;t<=e;t++){if(this.#t==null)return;await this.#e.emit(`block`,t)}this.#r=e}}catch{}this.#t!=null&&(this.#t=this.#e._setTimeout(this.#i.bind(this),this.#n))}start(){this.#t||(this.#t=this.#e._setTimeout(this.#i.bind(this),this.#n),this.#i())}stop(){this.#t&&=(this.#e._clearTimeout(this.#t),null)}pause(e){this.stop(),e&&(this.#r=-2)}resume(){this.start()}},Ek=class{#e;#t;#n;constructor(e){this.#e=e,this.#n=!1,this.#t=e=>{this._poll(e,this.#e)}}async _poll(e,t){throw Error(`sub-classes must override this`)}start(){this.#n||(this.#n=!0,this.#t(-2),this.#e.on(`block`,this.#t))}stop(){this.#n&&(this.#n=!1,this.#e.off(`block`,this.#t))}pause(e){this.stop()}resume(){this.start()}},Dk=class extends Ek{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=-2}pause(e){e&&(this.#t=-2),super.pause(e)}async _poll(e,t){let n=await t.getBlock(this.#e);n!=null&&(this.#t===-2?this.#t=n.number:n.number>this.#t&&(t.emit(this.#e,n.number),this.#t=n.number))}},Ok=class extends Ek{#e;constructor(e,t){super(e),this.#e=wk(t)}async _poll(e,t){throw Error(`@TODO`)}},kk=class extends Ek{#e;constructor(e,t){super(e),this.#e=t}async _poll(e,t){let n=await t.getTransactionReceipt(this.#e);n&&t.emit(this.#e,n)}},Ak=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=wk(t),this.#n=this.#a.bind(this),this.#r=!1,this.#i=-2}async#a(e){if(this.#i===-2)return;let t=wk(this.#t);t.fromBlock=this.#i+1,t.toBlock=e;let n=await this.#e.getLogs(t);if(n.length===0){this.#i<e-60&&(this.#i=e-60);return}for(let e of n)this.#e.emit(this.#t,e),this.#i=e.blockNumber}start(){this.#r||(this.#r=!0,this.#i===-2&&this.#e.getBlockNumber().then(e=>{this.#i=e}),this.#e.on(`block`,this.#n))}stop(){this.#r&&(this.#r=!1,this.#e.off(`block`,this.#n))}pause(e){this.stop(),e&&(this.#i=-2)}resume(){this.start()}},jk=BigInt(2),Mk=10;function Nk(e){return e&&typeof e.then==`function`}function Pk(e,t){return e+`:`+JSON.stringify(t,(e,t)=>{if(t==null)return`null`;if(typeof t==`bigint`)return`bigint:${t.toString()}`;if(typeof t==`string`)return t.toLowerCase();if(typeof t==`object`&&!Array.isArray(t)){let e=Object.keys(t);return e.sort(),e.reduce((e,n)=>(e[n]=t[n],e),{})}return t})}var Fk=class{name;constructor(e){G(this,{name:e})}start(){}stop(){}pause(e){}resume(){}};function Ik(e){return JSON.parse(JSON.stringify(e))}function Lk(e){return e=Array.from(new Set(e).values()),e.sort(),e}async function Rk(e,t){if(e==null)throw Error(`invalid event`);if(Array.isArray(e)&&(e={topics:e}),typeof e==`string`)switch(e){case`block`:case`debug`:case`error`:case`finalized`:case`network`:case`pending`:case`safe`:return{type:e,tag:e}}if(Mv(e,32)){let t=e.toLowerCase();return{type:`transaction`,tag:Pk(`tx`,{hash:t}),hash:t}}if(e.orphan){let t=e;return{type:`orphan`,tag:Pk(`orphan`,t),filter:Ik(t)}}if(e.address||e.topics){let n=e,r={topics:(n.topics||[]).map(e=>e==null?null:Array.isArray(e)?Lk(e.map(e=>e.toLowerCase())):e.toLowerCase())};if(n.address){let e=[],i=[],a=n=>{Mv(n)?e.push(n):i.push((async()=>{e.push(await BC(n,t))})())};Array.isArray(n.address)?n.address.forEach(a):a(n.address),i.length&&await Promise.all(i),r.address=Lk(e.map(e=>e.toLowerCase()))}return{filter:r,tag:Pk(`event`,r),type:`event`}}q(!1,`unknown ProviderEvent`,`event`,e)}function zk(){return new Date().getTime()}var Bk={cacheTimeout:250,pollingInterval:4e3},Vk=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t){if(this.#d=Object.assign({},Bk,t||{}),e===`any`)this.#a=!0,this.#i=null;else if(e){let t=yk.from(e);this.#a=!1,this.#i=Promise.resolve(t),setTimeout(()=>{this.emit(`network`,t,null)},0)}else this.#a=!1,this.#i=null;this.#s=-1,this.#o=new Map,this.#e=new Map,this.#t=new Map,this.#n=null,this.#r=!1,this.#c=1,this.#l=new Map,this.#u=!1}get pollingInterval(){return this.#d.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#t.values())}attachPlugin(e){if(this.#t.get(e.name))throw Error(`cannot replace existing plugin: ${e.name} `);return this.#t.set(e.name,e.connect(this)),this}getPlugin(e){return this.#t.get(e)||null}get disableCcipRead(){return this.#u}set disableCcipRead(e){this.#u=!!e}async#f(e){let t=this.#d.cacheTimeout;if(t<0)return await this._perform(e);let n=Pk(e.method,e),r=this.#o.get(n);return r||(r=this._perform(e),this.#o.set(n,r),setTimeout(()=>{this.#o.get(n)===r&&this.#o.delete(n)},t)),await r}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;let r=e.to.toLowerCase(),i=t.toLowerCase(),a=[];for(let t=0;t<n.length;t++){let o=n[t],s=new Dy(o.replace(`{sender}`,r).replace(`{data}`,i));o.indexOf(`{data}`)===-1&&(s.body={data:i,sender:r}),this.emit(`debug`,{action:`sendCcipReadFetchRequest`,request:s,index:t,urls:n});let c=`unknown error`,l;try{l=await s.send()}catch(e){a.push(e.message),this.emit(`debug`,{action:`receiveCcipReadFetchError`,request:s,result:{error:e}});continue}try{let e=l.bodyJson;if(e.data)return this.emit(`debug`,{action:`receiveCcipReadFetchResult`,request:s,result:e}),e.data;e.message&&(c=e.message),this.emit(`debug`,{action:`receiveCcipReadFetchError`,request:s,result:e})}catch{}K(l.statusCode<400||l.statusCode>=500,`response not found during CCIP fetch: ${c}`,`OFFCHAIN_FAULT`,{reason:`404_MISSING_RESOURCE`,transaction:e,info:{url:o,errorMessage:c}}),a.push(c)}K(!1,`error encountered during CCIP fetch: ${a.map(e=>JSON.stringify(e)).join(`, `)}`,`OFFCHAIN_FAULT`,{reason:`500_SERVER_ERROR`,transaction:e,info:{urls:n,errorMessages:a}})}_wrapBlock(e,t){return new rO(sk(e),this)}_wrapLog(e,t){return new iO(ak(e),this)}_wrapTransactionReceipt(e,t){return new aO(dk(e),this)}_wrapTransactionResponse(e,t){return new oO(fk(e),this)}_detectNetwork(){K(!1,`sub-classes must implement this`,`UNSUPPORTED_OPERATION`,{operation:`_detectNetwork`})}async _perform(e){K(!1,`unsupported method: ${e.method}`,`UNSUPPORTED_OPERATION`,{operation:e.method,info:e})}async getBlockNumber(){let e=Z(await this.#f({method:`getBlockNumber`}),`%response`);return this.#s>=0&&(this.#s=e),e}_getAddress(e){return BC(e,this)}_getBlockTag(e){if(e==null)return`latest`;switch(e){case`earliest`:return`0x0`;case`finalized`:case`latest`:case`pending`:case`safe`:return e}if(Mv(e))return Mv(e,32)?e:$v(e);if(typeof e==`bigint`&&(e=Z(e,`blockTag`)),typeof e==`number`)return e>=0?$v(e):this.#s>=0?$v(this.#s+e):this.getBlockNumber().then(t=>$v(t+e));q(!1,`invalid blockTag`,`blockTag`,e)}_getFilter(e){let t=(e.topics||[]).map(e=>e==null?null:Array.isArray(e)?Lk(e.map(e=>e.toLowerCase())):e.toLowerCase()),n=`blockHash`in e?e.blockHash:void 0,r=(e,r,i)=>{let a;switch(e.length){case 0:break;case 1:a=e[0];break;default:e.sort(),a=e}if(n&&(r!=null||i!=null))throw Error(`invalid filter`);let o={};return a&&(o.address=a),t.length&&(o.topics=t),r&&(o.fromBlock=r),i&&(o.toBlock=i),n&&(o.blockHash=n),o},i=[];if(e.address)if(Array.isArray(e.address))for(let t of e.address)i.push(this._getAddress(t));else i.push(this._getAddress(e.address));let a;`fromBlock`in e&&(a=this._getBlockTag(e.fromBlock));let o;return`toBlock`in e&&(o=this._getBlockTag(e.toBlock)),i.filter(e=>typeof e!=`string`).length||a!=null&&typeof a!=`string`||o!=null&&typeof o!=`string`?Promise.all([Promise.all(i),a,o]).then(e=>r(e[0],e[1],e[2])):r(i,a,o)}_getTransactionRequest(e){let t=nO(e),n=[];if([`to`,`from`].forEach(e=>{if(t[e]==null)return;let r=BC(t[e],this);Nk(r)?n.push((async function(){t[e]=await r})()):t[e]=r}),t.blockTag!=null){let e=this._getBlockTag(t.blockTag);Nk(e)?n.push((async function(){t.blockTag=await e})()):t.blockTag=e}return n.length?(async function(){return await Promise.all(n),t})():t}async getNetwork(){if(this.#i==null){let e=(async()=>{try{let e=await this._detectNetwork();return this.emit(`network`,e,null),e}catch(t){throw this.#i===e&&(this.#i=null),t}})();return this.#i=e,(await e).clone()}let e=this.#i,[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(this.#a?(this.emit(`network`,n,t),this.#i===e&&(this.#i=Promise.resolve(n))):K(!1,`network changed: ${t.chainId} => ${n.chainId} `,`NETWORK_ERROR`,{event:`changed`})),t.clone()}async getFeeData(){let e=await this.getNetwork(),t=async()=>{let{_block:t,gasPrice:n,priorityFee:r}=await xv({_block:this.#g(`latest`,!1),gasPrice:(async()=>{try{return X(await this.#f({method:`getGasPrice`}),`%response`)}catch{}return null})(),priorityFee:(async()=>{try{return X(await this.#f({method:`getPriorityFee`}),`%response`)}catch{}return null})()}),i=null,a=null,o=this._wrapBlock(t,e);return o&&o.baseFeePerGas&&(a=r??BigInt(`1000000000`),i=o.baseFeePerGas*jk+a),new tO(n,i,a)},n=e.getPlugin(`org.ethers.plugins.network.FetchUrlFeeDataPlugin`);if(n){let e=new Dy(n.url),r=await n.processFunc(t,this,e);return new tO(r.gasPrice,r.maxFeePerGas,r.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Nk(t)&&(t=await t),X(await this.#f({method:`estimateGas`,transaction:t}),`%response`)}async#p(e,t,n){K(n<Mk,`CCIP read exceeded maximum redirections`,`OFFCHAIN_FAULT`,{reason:`TOO_MANY_REDIRECTS`,transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});let r=nO(e);try{return Y(await this._perform({method:`call`,transaction:r,blockTag:t}))}catch(e){if(!this.disableCcipRead&&wv(e)&&e.data&&n>=0&&t===`latest`&&r.to!=null&&Lv(e.data,0,4)===`0x556f1830`){let i=e.data,a=await BC(r.to,this),o;try{o=Yk(Lv(e.data,4))}catch(e){K(!1,e.message,`OFFCHAIN_FAULT`,{reason:`BAD_DATA`,transaction:r,info:{data:i}})}K(o.sender.toLowerCase()===a.toLowerCase(),`CCIP Read sender mismatch`,`CALL_EXCEPTION`,{action:`call`,data:i,reason:`OffchainLookup`,transaction:r,invocation:null,revert:{signature:`OffchainLookup(address,string[],bytes,bytes4,bytes)`,name:`OffchainLookup`,args:o.errorArgs}});let s=await this.ccipReadFetch(r,o.calldata,o.urls);K(s!=null,`CCIP Read failed to fetch data`,`OFFCHAIN_FAULT`,{reason:`FETCH_FAILED`,transaction:r,info:{data:e.data,errorArgs:o.errorArgs}});let c={to:a,data:Fv([o.selector,qk([s,o.extraData])])};this.emit(`debug`,{action:`sendCcipReadCall`,transaction:c});try{let e=await this.#p(c,t,n+1);return this.emit(`debug`,{action:`receiveCcipReadCallResult`,transaction:Object.assign({},c),result:e}),e}catch(e){throw this.emit(`debug`,{action:`receiveCcipReadCallError`,transaction:Object.assign({},c),error:e}),e}}throw e}}async#m(e){let{value:t}=await xv({network:this.getNetwork(),value:e});return t}async call(e){let{tx:t,blockTag:n}=await xv({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await this.#m(this.#p(t,n,e.enableCcipRead?0:-1))}async#h(e,t,n){let r=this._getAddress(t),i=this._getBlockTag(n);return(typeof r!=`string`||typeof i!=`string`)&&([r,i]=await Promise.all([r,i])),await this.#m(this.#f(Object.assign(e,{address:r,blockTag:i})))}async getBalance(e,t){return X(await this.#h({method:`getBalance`},e,t),`%response`)}async getTransactionCount(e,t){return Z(await this.#h({method:`getTransactionCount`},e,t),`%response`)}async getCode(e,t){return Y(await this.#h({method:`getCode`},e,t))}async getStorage(e,t,n){let r=X(t,`position`);return Y(await this.#h({method:`getStorage`,position:r},e,n))}async broadcastTransaction(e){let{blockNumber:t,hash:n,network:r}=await xv({blockNumber:this.getBlockNumber(),hash:this._perform({method:`broadcastTransaction`,signedTransaction:e}),network:this.getNetwork()}),i=Ww.from(e);if(i.hash!==n)throw Error(`@TODO: the returned hash did not match`);return this._wrapTransactionResponse(i,r).replaceableTransaction(t)}async#g(e,t){if(Mv(e,32))return await this.#f({method:`getBlock`,blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!=`string`&&(n=await n),await this.#f({method:`getBlock`,blockTag:n,includeTransactions:t})}async getBlock(e,t){let{network:n,params:r}=await xv({network:this.getNetwork(),params:this.#g(e,!!t)});return r==null?null:this._wrapBlock(r,n)}async getTransaction(e){let{network:t,params:n}=await xv({network:this.getNetwork(),params:this.#f({method:`getTransaction`,hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){let{network:t,params:n}=await xv({network:this.getNetwork(),params:this.#f({method:`getTransactionReceipt`,hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){let t=await this.#f({method:`getTransaction`,hash:e});if(t==null)throw Error(`report this; could not find tx or effectiveGasPrice`);n.effectiveGasPrice=t.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){let{result:t}=await xv({network:this.getNetwork(),result:this.#f({method:`getTransactionResult`,hash:e})});return t==null?null:Y(t)}async getLogs(e){let t=this._getFilter(e);Nk(t)&&(t=await t);let{network:n,params:r}=await xv({network:this.getNetwork(),params:this.#f({method:`getLogs`,filter:t})});return r.map(e=>this._wrapLog(e,n))}_getProvider(e){K(!1,`provider cannot connect to target network`,`UNSUPPORTED_OPERATION`,{operation:`_getProvider()`})}async getResolver(e){return await XO.fromName(this,e)}async getAvatar(e){let t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){let t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=IC(e);let t=kE(e.substring(2).toLowerCase()+`.addr.reverse`);try{let n=await new GO(await XO.getEnsAddress(this),[`function resolver(bytes32) view returns (address)`],this).resolver(t);if(n==null||n===`0x0000000000000000000000000000000000000000`)return null;let r=await new GO(n,[`function name(bytes32) view returns (string)`],this).name(t);return await this.resolveName(r)===e?r:null}catch(e){if(Cv(e,`BAD_DATA`)&&e.value===`0x`||Cv(e,`CALL_EXCEPTION`))return null;throw e}return null}async waitForTransaction(e,t,n){let r=t??1;return r===0?this.getTransactionReceipt(e):new Promise(async(t,i)=>{let a=null,o=(async n=>{try{let i=await this.getTransactionReceipt(e);if(i!=null&&n-i.blockNumber+1>=r){t(i),a&&=(clearTimeout(a),null);return}}catch(e){console.log(`EEE`,e)}this.once(`block`,o)});n!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off(`block`,o),i(Tv(`timeout`,`TIMEOUT`,{reason:`timeout`})))},n)),o(await this.getBlockNumber())})}async waitForBlock(e){K(!1,`not implemented yet`,`NOT_IMPLEMENTED`,{operation:`waitForBlock`})}_clearTimeout(e){let t=this.#l.get(e);t&&(t.timer&&clearTimeout(t.timer),this.#l.delete(e))}_setTimeout(e,t){t??=0;let n=this.#c++,r=()=>{this.#l.delete(n),e()};if(this.paused)this.#l.set(n,{timer:null,func:r,time:t});else{let e=setTimeout(r,t);this.#l.set(n,{timer:e,func:r,time:zk()})}return n}_forEachSubscriber(e){for(let t of this.#e.values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case`debug`:case`error`:case`network`:return new Fk(e.type);case`block`:{let e=new Tk(this);return e.pollingInterval=this.pollingInterval,e}case`safe`:case`finalized`:return new Dk(this,e.type);case`event`:return new Ak(this,e.filter);case`transaction`:return new kk(this,e.hash);case`orphan`:return new Ok(this,e.filter)}throw Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(let n of this.#e.values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),this.#n!=null&&t.pause(this.#n);break}}async#_(e,t){let n=await Rk(e,this);return n.type===`event`&&t&&t.length>0&&t[0].removed===!0&&(n=await Rk({orphan:`drop-log`,log:t[0]},this)),this.#e.get(n.tag)||null}async#v(e){let t=await Rk(e,this),n=t.tag,r=this.#e.get(n);return r||(r={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#e.set(n,r)),r}async on(e,t){let n=await this.#v(e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async once(e,t){let n=await this.#v(e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async emit(e,...t){let n=await this.#_(e,t);if(!n||n.listeners.length===0)return!1;let r=n.listeners.length;return n.listeners=n.listeners.filter(({listener:n,once:r})=>{let i=new ay(this,r?null:n,e);try{n.call(this,...t,i)}catch{}return!r}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),r>0}async listenerCount(e){if(e){let t=await this.#_(e);return t?t.listeners.length:0}let t=0;for(let{listeners:e}of this.#e.values())t+=e.length;return t}async listeners(e){if(e){let t=await this.#_(e);return t?t.listeners.map(({listener:e})=>e):[]}let t=[];for(let{listeners:e}of this.#e.values())t=t.concat(e.map(({listener:e})=>e));return t}async off(e,t){let n=await this.#_(e);if(!n)return this;if(t){let e=n.listeners.map(({listener:e})=>e).indexOf(t);e>=0&&n.listeners.splice(e,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),this}async removeAllListeners(e){if(e){let{tag:t,started:n,subscriber:r}=await this.#v(e);n&&r.stop(),this.#e.delete(t)}else for(let[e,{started:t,subscriber:n}]of this.#e)t&&n.stop(),this.#e.delete(e);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return this.#r}destroy(){this.removeAllListeners();for(let e of this.#l.keys())this._clearTimeout(e);this.#r=!0}get paused(){return this.#n!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(this.#s=-1,this.#n!=null){if(this.#n==!!e)return;K(!1,`cannot change pause type; resume first`,`UNSUPPORTED_OPERATION`,{operation:`pause`})}this._forEachSubscriber(t=>t.pause(e)),this.#n=!!e;for(let e of this.#l.values())e.timer&&clearTimeout(e.timer),e.time=zk()-e.time}resume(){if(this.#n!=null){this._forEachSubscriber(e=>e.resume()),this.#n=null;for(let e of this.#l.values()){let t=e.time;t<0&&(t=0),e.time=zk(),setTimeout(e.func,t)}}}};function Hk(e,t){try{let n=Uk(e,t);if(n)return py(n)}catch{}return null}function Uk(e,t){if(e===`0x`)return null;try{let n=Z(Lv(e,t,t+32)),r=Z(Lv(e,n,n+32));return Lv(e,n+32,n+32+r)}catch{}return null}function Wk(e){let t=Qv(e);if(t.length>32)throw Error(`internal; should not happen`);let n=new Uint8Array(32);return n.set(t,32-t.length),n}function Gk(e){if(e.length%32==0)return e;let t=new Uint8Array(Math.ceil(e.length/32)*32);return t.set(e),t}var Kk=new Uint8Array([]);function qk(e){let t=[],n=0;for(let r=0;r<e.length;r++)t.push(Kk),n+=32;for(let r=0;r<e.length;r++){let i=J(e[r]);t[r]=Wk(n),t.push(Wk(i.length)),t.push(Gk(i)),n+=32+Math.ceil(i.length/32)*32}return Fv(t)}var Jk=`0x0000000000000000000000000000000000000000000000000000000000000000`;function Yk(e){let t={sender:``,urls:[],calldata:``,selector:``,extraData:``,errorArgs:[]};K(Iv(e)>=160,`insufficient OffchainLookup data`,`OFFCHAIN_FAULT`,{reason:`insufficient OffchainLookup data`});let n=Lv(e,0,32);K(Lv(n,0,12)===Lv(Jk,0,12),`corrupt OffchainLookup sender`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup sender`}),t.sender=Lv(n,12);try{let n=[],r=Z(Lv(e,32,64)),i=Z(Lv(e,r,r+32)),a=Lv(e,r+32);for(let e=0;e<i;e++){let t=Hk(a,e*32);if(t==null)throw Error(`abort`);n.push(t)}t.urls=n}catch{K(!1,`corrupt OffchainLookup urls`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup urls`})}try{let n=Uk(e,64);if(n==null)throw Error(`abort`);t.calldata=n}catch{K(!1,`corrupt OffchainLookup calldata`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup calldata`})}K(Lv(e,100,128)===Lv(Jk,0,28),`corrupt OffchainLookup callbaackSelector`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup callbaackSelector`}),t.selector=Lv(e,96,100);try{let n=Uk(e,128);if(n==null)throw Error(`abort`);t.extraData=n}catch{K(!1,`corrupt OffchainLookup extraData`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup extraData`})}return t.errorArgs=`sender,urls,calldata,selector,extraData`.split(/,/).map(e=>t[e]),t}function Xk(e,t){if(e.provider)return e.provider;K(!1,`missing provider`,`UNSUPPORTED_OPERATION`,{operation:t})}async function Zk(e,t){let n=nO(t);if(n.to!=null&&(n.to=BC(n.to,e)),n.from!=null){let t=n.from;n.from=Promise.all([e.getAddress(),BC(t,e)]).then(([e,t])=>(q(e.toLowerCase()===t.toLowerCase(),`transaction from mismatch`,`tx.from`,t),e))}else n.from=e.getAddress();return await xv(n)}var Qk=class{provider;constructor(e){G(this,{provider:e||null})}async getNonce(e){return Xk(this,`getTransactionCount`).getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await Zk(this,e)}async populateTransaction(e){let t=Xk(this,`populateTransaction`),n=await Zk(this,e);n.nonce??=await this.getNonce(`pending`),n.gasLimit??=await this.estimateGas(n);let r=await this.provider.getNetwork();n.chainId==null?n.chainId=r.chainId:q(X(n.chainId)===r.chainId,`transaction chainId mismatch`,`tx.chainId`,e.chainId);let i=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||i)?q(!1,`eip-1559 transaction do not support gasPrice`,`tx`,e):(n.type===0||n.type===1)&&i&&q(!1,`pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas`,`tx`,e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){let e=await t.getFeeData();K(e.gasPrice!=null,`network does not support gasPrice`,`UNSUPPORTED_OPERATION`,{operation:`getGasPrice`}),n.gasPrice??=e.gasPrice}else{let e=await t.getFeeData();if(n.type==null)if(e.maxFeePerGas!=null&&e.maxPriorityFeePerGas!=null)if(n.authorizationList&&n.authorizationList.length?n.type=4:n.type=2,n.gasPrice!=null){let e=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=e,n.maxPriorityFeePerGas=e}else n.maxFeePerGas??=e.maxFeePerGas,n.maxPriorityFeePerGas??=e.maxPriorityFeePerGas;else e.gasPrice==null?K(!1,`failed to get consistent fee data`,`UNSUPPORTED_OPERATION`,{operation:`signer.getFeeData`}):(K(!i,`network does not support EIP-1559`,`UNSUPPORTED_OPERATION`,{operation:`populateTransaction`}),n.gasPrice??=e.gasPrice,n.type=0);else (n.type===2||n.type===3||n.type===4)&&(n.maxFeePerGas??=e.maxFeePerGas,n.maxPriorityFeePerGas??=e.maxPriorityFeePerGas)}return await xv(n)}async populateAuthorization(e){let t=Object.assign({},e);return t.chainId??=(await Xk(this,`getNetwork`).getNetwork()).chainId,t.nonce??=await this.getNonce(),t}async estimateGas(e){return Xk(this,`estimateGas`).estimateGas(await this.populateCall(e))}async call(e){return Xk(this,`call`).call(await this.populateCall(e))}async resolveName(e){return await Xk(this,`resolveName`).resolveName(e)}async sendTransaction(e){let t=Xk(this,`sendTransaction`),n=await this.populateTransaction(e);delete n.from;let r=Ww.from(n);return await t.broadcastTransaction(await this.signTransaction(r))}authorize(e){K(!1,`authorization not implemented for this signer`,`UNSUPPORTED_OPERATION`,{operation:`authorize`})}};function $k(e){return JSON.parse(JSON.stringify(e))}var eA=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e,this.#t=null,this.#n=this.#o.bind(this),this.#r=!1,this.#i=null,this.#a=!1}_subscribe(e){throw Error(`subclasses must override this`)}_emitResults(e,t){throw Error(`subclasses must override this`)}_recover(e){throw Error(`subclasses must override this`)}async#o(e){try{this.#t??=this._subscribe(this.#e);let e=null;try{e=await this.#t}catch(e){if(!Cv(e,`UNSUPPORTED_OPERATION`)||e.operation!==`eth_newFilter`)throw e}if(e==null){this.#t=null,this.#e._recoverSubscriber(this,this._recover(this.#e));return}let t=await this.#e.getNetwork();if(this.#i||=t,this.#i.chainId!==t.chainId)throw Error(`chaid changed`);if(this.#a)return;let n=await this.#e.send(`eth_getFilterChanges`,[e]);await this._emitResults(this.#e,n)}catch(e){console.log(`@TODO`,e)}this.#e.once(`block`,this.#n)}#s(){let e=this.#t;e&&(this.#t=null,e.then(e=>{this.#e.destroyed||this.#e.send(`eth_uninstallFilter`,[e])}))}start(){this.#r||(this.#r=!0,this.#o(-2))}stop(){this.#r&&(this.#r=!1,this.#a=!0,this.#s(),this.#e.off(`block`,this.#n))}pause(e){e&&this.#s(),this.#e.off(`block`,this.#n)}resume(){this.start()}},tA=class extends eA{#e;constructor(e,t){super(e),this.#e=$k(t)}_recover(e){return new Ak(e,this.#e)}async _subscribe(e){return await e.send(`eth_newFilter`,[this.#e])}async _emitResults(e,t){for(let n of t)e.emit(this.#e,e._wrapLog(n,e._network))}},nA=class extends eA{async _subscribe(e){return await e.send(`eth_newPendingTransactionFilter`,[])}async _emitResults(e,t){for(let n of t)e.emit(`pending`,n)}},rA=`bigint,boolean,function,number,string,symbol`.split(/,/g);function iA(e){if(e==null||rA.indexOf(typeof e)>=0||typeof e.getAddress==`function`)return e;if(Array.isArray(e))return e.map(iA);if(typeof e==`object`)return Object.keys(e).reduce((t,n)=>(t[n]=e[n],t),{});throw Error(`should not happen: ${e} (${typeof e})`)}function aA(e){return new Promise(t=>{setTimeout(t,e)})}function oA(e){return e&&e.toLowerCase()}function sA(e){return e&&typeof e.pollingInterval==`number`}var cA={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3},lA=class extends Qk{address;constructor(e,t){super(e),t=IC(t),G(this,{address:t})}connect(e){K(!1,`cannot reconnect JsonRpcSigner`,`UNSUPPORTED_OPERATION`,{operation:`signer.connect`})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){let t=iA(e),n=[];if(t.from){let r=t.from;n.push((async()=>{let n=await BC(r,this.provider);q(n!=null&&n.toLowerCase()===this.address.toLowerCase(),`from address mismatch`,`transaction`,e),t.from=n})())}else t.from=this.address;if(t.gasLimit??n.push((async()=>{t.gasLimit=await this.provider.estimateGas({...t,from:this.address})})()),t.to!=null){let e=t.to;n.push((async()=>{t.to=await BC(e,this.provider)})())}n.length&&await Promise.all(n);let r=this.provider.getRpcTransaction(t);return this.provider.send(`eth_sendTransaction`,[r])}async sendTransaction(e){let t=await this.provider.getBlockNumber(),n=await this.sendUncheckedTransaction(e);return await new Promise((e,r)=>{let i=[1e3,100],a=0,o=async()=>{try{let r=await this.provider.getTransaction(n);if(r!=null){e(r.replaceableTransaction(t));return}}catch(e){if(Cv(e,`CANCELLED`)||Cv(e,`BAD_DATA`)||Cv(e,`NETWORK_ERROR`)||Cv(e,`UNSUPPORTED_OPERATION`)){e.info??={},e.info.sendTransactionHash=n,r(e);return}if(Cv(e,`INVALID_ARGUMENT`)&&(a++,e.info??={},e.info.sendTransactionHash=n,a>10)){r(e);return}this.provider.emit(`error`,Tv(`failed to fetch transation after sending (will try again)`,`UNKNOWN_ERROR`,{error:e}))}this.provider._setTimeout(()=>{o()},i.pop()||4e3)};o()})}async signTransaction(e){let t=iA(e);if(t.from){let n=await BC(t.from,this.provider);q(n!=null&&n.toLowerCase()===this.address.toLowerCase(),`from address mismatch`,`transaction`,e),t.from=n}else t.from=this.address;let n=this.provider.getRpcTransaction(t);return await this.provider.send(`eth_signTransaction`,[n])}async signMessage(e){let t=typeof e==`string`?dy(e):e;return await this.provider.send(`personal_sign`,[Y(t),this.address.toLowerCase()])}async signTypedData(e,t,n){let r=iA(n),i=await KE.resolveNames(e,t,r,async e=>{let t=await BC(e);return q(t!=null,`TypedData does not support null address`,`value`,e),t});return await this.provider.send(`eth_signTypedData_v4`,[this.address.toLowerCase(),JSON.stringify(KE.getPayload(i.domain,t,i.value))])}async unlock(e){return this.provider.send(`personal_unlockAccount`,[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){let t=typeof e==`string`?dy(e):e;return await this.provider.send(`eth_sign`,[this.address.toLowerCase(),Y(t)])}},uA=class extends Vk{#e;#t;#n;#r;#i;#a;#o;#s(){if(this.#r)return;let e=this._getOption(`batchMaxCount`)===1?0:this._getOption(`batchStallTime`);this.#r=setTimeout(()=>{this.#r=null;let e=this.#n;for(this.#n=[];e.length;){let t=[e.shift()];for(;e.length&&t.length!==this.#e.batchMaxCount;)if(t.push(e.shift()),JSON.stringify(t.map(e=>e.payload)).length>this.#e.batchMaxSize){e.unshift(t.pop());break}(async()=>{let e=t.length===1?t[0].payload:t.map(e=>e.payload);this.emit(`debug`,{action:`sendRpcPayload`,payload:e});try{let n=await this._send(e);this.emit(`debug`,{action:`receiveRpcResult`,result:n});for(let{resolve:e,reject:r,payload:i}of t){if(this.destroyed){r(Tv(`provider destroyed; cancelled request`,`UNSUPPORTED_OPERATION`,{operation:i.method}));continue}let t=n.filter(e=>e.id===i.id)[0];if(t==null){let e=Tv(`missing response for request`,`BAD_DATA`,{value:n,info:{payload:i}});this.emit(`error`,e),r(e);continue}if(`error`in t){r(this.getRpcError(i,t));continue}e(t.result)}}catch(e){this.emit(`debug`,{action:`receiveRpcError`,error:e});for(let{reject:n}of t)n(e)}})()}},e)}constructor(e,t){super(e,t),this.#t=1,this.#e=Object.assign({},cA,t||{}),this.#n=[],this.#r=null,this.#a=null,this.#o=null;{let e=null;this.#i={promise:new Promise(t=>{e=t}),resolve:e}}let n=this._getOption(`staticNetwork`);typeof n==`boolean`?(q(!n||e!==`any`,`staticNetwork cannot be used on special network 'any'`,`options`,t),n&&e!=null&&(this.#a=yk.from(e))):n&&(q(e==null||n.matches(e),`staticNetwork MUST match network object`,`options`,t),this.#a=n)}_getOption(e){return this.#e[e]}get _network(){return K(this.#a,`network is not available yet`,`NETWORK_ERROR`),this.#a}async _perform(e){if(e.method===`call`||e.method===`estimateGas`){let t=e.transaction;if(t&&t.type!=null&&X(t.type)&&t.maxFeePerGas==null&&t.maxPriorityFeePerGas==null){let n=await this.getFeeData();n.maxFeePerGas==null&&n.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}let t=this.getRpcRequest(e);return t==null?super._perform(e):await this.send(t.method,t.args)}async _detectNetwork(){let e=this._getOption(`staticNetwork`);if(e)if(e===!0){if(this.#a)return this.#a}else return e;return this.#o?await this.#o:this.ready?(this.#o=(async()=>{try{let e=yk.from(X(await this.send(`eth_chainId`,[])));return this.#o=null,e}catch(e){throw this.#o=null,e}})(),await this.#o):(this.#o=(async()=>{let e={id:this.#t++,method:`eth_chainId`,params:[],jsonrpc:`2.0`};this.emit(`debug`,{action:`sendRpcPayload`,payload:e});let t;try{t=(await this._send(e))[0],this.#o=null}catch(e){throw this.#o=null,this.emit(`debug`,{action:`receiveRpcError`,error:e}),e}if(this.emit(`debug`,{action:`receiveRpcResult`,result:t}),`result`in t)return yk.from(X(t.result));throw this.getRpcError(e,t)})(),await this.#o)}_start(){this.#i==null||this.#i.resolve==null||(this.#i.resolve(),this.#i=null,(async()=>{for(;this.#a==null&&!this.destroyed;)try{this.#a=await this._detectNetwork()}catch(e){if(this.destroyed)break;console.log(`JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)`),this.emit(`error`,Tv(`failed to bootstrap network detection`,`NETWORK_ERROR`,{event:`initial-network-discovery`,info:{error:e}})),await aA(1e3)}this.#s()})())}async _waitUntilReady(){if(this.#i!=null)return await this.#i.promise}_getSubscriber(e){return e.type===`pending`?new nA(this):e.type===`event`?this._getOption(`polling`)?new Ak(this,e.filter):new tA(this,e.filter):e.type===`orphan`&&e.filter.orphan===`drop-log`?new Fk(`orphan`):super._getSubscriber(e)}get ready(){return this.#i==null}getRpcTransaction(e){let t={};return[`chainId`,`gasLimit`,`gasPrice`,`type`,`maxFeePerGas`,`maxPriorityFeePerGas`,`nonce`,`value`].forEach(n=>{if(e[n]==null)return;let r=n;n===`gasLimit`&&(r=`gas`),t[r]=$v(X(e[n],`tx.${n}`))}),[`from`,`to`,`data`].forEach(n=>{e[n]!=null&&(t[n]=Y(e[n]))}),e.accessList&&(t.accessList=lw(e.accessList)),e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.map(e=>e.toLowerCase())),e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>{let t=uw(e);return{address:t.address,nonce:$v(t.nonce),chainId:$v(t.chainId),yParity:$v(t.signature.yParity),r:$v(t.signature.r),s:$v(t.signature.s)}})),t}getRpcRequest(e){switch(e.method){case`chainId`:return{method:`eth_chainId`,args:[]};case`getBlockNumber`:return{method:`eth_blockNumber`,args:[]};case`getGasPrice`:return{method:`eth_gasPrice`,args:[]};case`getPriorityFee`:return{method:`eth_maxPriorityFeePerGas`,args:[]};case`getBalance`:return{method:`eth_getBalance`,args:[oA(e.address),e.blockTag]};case`getTransactionCount`:return{method:`eth_getTransactionCount`,args:[oA(e.address),e.blockTag]};case`getCode`:return{method:`eth_getCode`,args:[oA(e.address),e.blockTag]};case`getStorage`:return{method:`eth_getStorageAt`,args:[oA(e.address),`0x`+e.position.toString(16),e.blockTag]};case`broadcastTransaction`:return{method:`eth_sendRawTransaction`,args:[e.signedTransaction]};case`getBlock`:if(`blockTag`in e)return{method:`eth_getBlockByNumber`,args:[e.blockTag,!!e.includeTransactions]};if(`blockHash`in e)return{method:`eth_getBlockByHash`,args:[e.blockHash,!!e.includeTransactions]};break;case`getTransaction`:return{method:`eth_getTransactionByHash`,args:[e.hash]};case`getTransactionReceipt`:return{method:`eth_getTransactionReceipt`,args:[e.hash]};case`call`:return{method:`eth_call`,args:[this.getRpcTransaction(e.transaction),e.blockTag]};case`estimateGas`:return{method:`eth_estimateGas`,args:[this.getRpcTransaction(e.transaction)]};case`getLogs`:return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(oA):e.filter.address=oA(e.filter.address)),{method:`eth_getLogs`,args:[e.filter]}}return null}getRpcError(e,t){let{method:n}=e,{error:r}=t;if(n===`eth_estimateGas`&&r.message){let t=r.message;if(!t.match(/revert/i)&&t.match(/insufficient funds/i))return Tv(`insufficient funds`,`INSUFFICIENT_FUNDS`,{transaction:e.params[0],info:{payload:e,error:r}});if(t.match(/nonce/i)&&t.match(/too low/i))return Tv(`nonce has already been used`,`NONCE_EXPIRED`,{transaction:e.params[0],info:{payload:e,error:r}})}if(n===`eth_call`||n===`eth_estimateGas`){let t=pA(r),i=WD.getBuiltinCallException(n===`eth_call`?`call`:`estimateGas`,e.params[0],t?t.data:null);return i.info={error:r,payload:e},i}let i=JSON.stringify(hA(r));if(typeof r.message==`string`&&r.message.match(/user denied|ethers-user-denied/i))return Tv(`user rejected action`,`ACTION_REJECTED`,{action:{eth_sign:`signMessage`,personal_sign:`signMessage`,eth_signTypedData_v4:`signTypedData`,eth_signTransaction:`signTransaction`,eth_sendTransaction:`sendTransaction`,eth_requestAccounts:`requestAccess`,wallet_requestAccounts:`requestAccess`}[n]||`unknown`,reason:`rejected`,info:{payload:e,error:r}});if(n===`eth_sendRawTransaction`||n===`eth_sendTransaction`){let t=e.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Tv(`insufficient funds for intrinsic transaction cost`,`INSUFFICIENT_FUNDS`,{transaction:t,info:{error:r}});if(i.match(/nonce/i)&&i.match(/too low/i))return Tv(`nonce has already been used`,`NONCE_EXPIRED`,{transaction:t,info:{error:r}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Tv(`replacement fee too low`,`REPLACEMENT_UNDERPRICED`,{transaction:t,info:{error:r}});if(i.match(/only replay-protected/i))return Tv(`legacy pre-eip-155 transactions not supported`,`UNSUPPORTED_OPERATION`,{operation:n,info:{transaction:t,info:{error:r}}})}let a=!!i.match(/the method .* does not exist/i);return a||r&&r.details&&r.details.startsWith(`Unauthorized method:`)&&(a=!0),a?Tv(`unsupported operation`,`UNSUPPORTED_OPERATION`,{operation:e.method,info:{error:r,payload:e}}):Tv(`could not coalesce error`,`UNKNOWN_ERROR`,{error:r,payload:e})}send(e,t){if(this.destroyed)return Promise.reject(Tv(`provider destroyed; cancelled request`,`UNSUPPORTED_OPERATION`,{operation:e}));let n=this.#t++,r=new Promise((r,i)=>{this.#n.push({resolve:r,reject:i,payload:{method:e,params:t,id:n,jsonrpc:`2.0`}})});return this.#s(),r}async getSigner(e){e??=0;let t=this.send(`eth_accounts`,[]);if(typeof e==`number`){let n=await t;if(e>=n.length)throw Error(`no such account`);return new lA(this,n[e])}let{accounts:n}=await xv({network:this.getNetwork(),accounts:t});e=IC(e);for(let t of n)if(IC(t)===e)return new lA(this,e);throw Error(`invalid account`)}async listAccounts(){return(await this.send(`eth_accounts`,[])).map(e=>new lA(this,e))}destroy(){this.#r&&=(clearTimeout(this.#r),null);for(let{payload:e,reject:t}of this.#n)t(Tv(`provider destroyed; cancelled request`,`UNSUPPORTED_OPERATION`,{operation:e.method}));this.#n=[],super.destroy()}},dA=class extends uA{#e;constructor(e,t){super(e,t);let n=this._getOption(`pollingInterval`);n??=cA.pollingInterval,this.#e=n}_getSubscriber(e){let t=super._getSubscriber(e);return sA(t)&&(t.pollingInterval=this.#e),t}get pollingInterval(){return this.#e}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw Error(`invalid interval`);this.#e=e,this._forEachSubscriber(e=>{sA(e)&&(e.pollingInterval=this.#e)})}},fA=class extends dA{#e;constructor(e,t,n){e??=`http://localhost:8545`,super(t,n),typeof e==`string`?this.#e=new Dy(e):this.#e=e.clone()}_getConnection(){return this.#e.clone()}async send(e,t){return await this._start(),await super.send(e,t)}async _send(e){let t=this._getConnection();t.body=JSON.stringify(e),t.setHeader(`content-type`,`application/json`);let n=await t.send();n.assertOk();let r=n.bodyJson;return Array.isArray(r)||(r=[r]),r}};function pA(e){if(e==null)return null;if(typeof e.message==`string`&&e.message.match(/revert/i)&&Mv(e.data))return{message:e.message,data:e.data};if(typeof e==`object`){for(let t in e){let n=pA(e[t]);if(n)return n}return null}if(typeof e==`string`)try{return pA(JSON.parse(e))}catch{}return null}function mA(e,t){if(e!=null){if(typeof e.message==`string`&&t.push(e.message),typeof e==`object`)for(let n in e)mA(e[n],t);if(typeof e==`string`)try{return mA(JSON.parse(e),t)}catch{}}}function hA(e){let t=[];return mA(e,t),t}var gA=[`function register(string agentURI) external returns (uint256 agentId)`,`function register(string agentURI, tuple(string metadataKey, bytes metadataValue)[] metadata) external returns (uint256 agentId)`,`function register() external returns (uint256 agentId)`,`function setAgentURI(uint256 agentId, string newURI) external`,`function tokenURI(uint256 agentId) external view returns (string)`,`function setAgentWallet(uint256 agentId, address newWallet, uint256 deadline, bytes signature) external`,`function getAgentWallet(uint256 agentId) external view returns (address)`,`function unsetAgentWallet(uint256 agentId) external`,`function nonces(address owner) external view returns (uint256)`,`function DOMAIN_SEPARATOR() external view returns (bytes32)`,`function getMetadata(uint256 agentId, string metadataKey) external view returns (bytes)`,`function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue) external`,`function ownerOf(uint256 tokenId) external view returns (address)`,`function balanceOf(address owner) external view returns (uint256)`,`function totalSupply() external view returns (uint256)`,`function isAgent(uint256 agentId) external view returns (bool)`,`event Registered(uint256 indexed agentId, string agentURI, address indexed owner)`,`event URIUpdated(uint256 indexed agentId, string newURI, address indexed updatedBy)`,`event WalletSet(uint256 indexed agentId, address indexed wallet)`,`event WalletUnset(uint256 indexed agentId)`,`event MetadataSet(uint256 indexed agentId, string indexed indexedMetadataKey, string metadataKey, bytes metadataValue)`,`event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)`],_A={8453:{identityRegistry:``,reputationRegistry:``,validationRegistry:``},84532:{identityRegistry:``,reputationRegistry:``,validationRegistry:``},1:{identityRegistry:``,reputationRegistry:``,validationRegistry:``}},vA={base:8453,"base-mainnet":8453,"base-sepolia":84532,ethereum:1,mainnet:1},yA={8453:`https://mainnet.base.org`,84532:`https://sepolia.base.org`,1:`https://eth.llamarpc.com`};async function bA(e,{rpcURL:t,registry:n}={}){if(!e)throw Error(`loadManifest: source required`);if(e.startsWith(`agent://`))return xA(e,{rpcURL:t,registryOverride:n});if(e.startsWith(`ipfs://`)||e.startsWith(`ar://`)){let t=cv(e);return CA(await SA(t),{baseURI:wA(t)})}if(e.startsWith(`http`))return CA(await SA(e),{baseURI:wA(e)});throw Error(`Unsupported manifest source: ${e}`)}async function xA(e,{rpcURL:t,registryOverride:n}){let r=e.match(/^agent:\/\/([^/]+)\/(\d+)$/);if(!r)throw Error(`Malformed agent URI: ${e}`);let[,i,a]=r,o=vA[i.toLowerCase()]||Number(i);if(!o)throw Error(`Unknown chain: ${i}`);let s=_A[o],c=n||s?.identityRegistry;if(!c)throw Error(`No registry deployed on chain ${o}. Pass registry= override.`);let l=new GO(c,gA,new fA(t||yA[o])),u=BigInt(a),d=await l.tokenURI(u);if(!d)throw Error(`Agent ${a} on chain ${o} has no URI`);let f=cv(d),p=CA(await SA(f),{baseURI:wA(f)});return p.id={...p.id,chain:i,chainId:o,registry:c,agentId:a},p}async function SA(e){let t;try{t=await fetch(e)}catch{t=await lv(e)}if(!t.ok)throw Error(`Manifest fetch failed: ${e} (${t.status})`);return t.json()}function CA(e,{baseURI:t=``}={}){if(e.spec&&e.spec.startsWith(`agent-manifest/`)){let n={...e,_baseURI:t};return n.body=n.body||{},!n.body.uri&&n.image&&(n.body.uri=n.image),n}return e.type&&e.type.includes(`eip-8004`)?{spec:`agent-manifest/0.1`,_baseURI:t,_source:`erc8004-registration`,id:{agentId:(e.registrations?.[0]||{}).agentId?.toString()},name:e.name,description:e.description,image:e.image,body:{uri:e.image,format:`gltf-binary`},brain:{provider:`none`},voice:{tts:{provider:`browser`},stt:{provider:`browser`}},skills:[],memory:{mode:`local`},tools:[`wave`,`lookAt`,`play_clip`,`setExpression`],version:`0.1.0`}:{spec:`agent-manifest/0.1`,_baseURI:t,name:e.name||`Unnamed agent`,description:e.description||``,body:{uri:e.body?.uri||e.image||e.model||``,format:e.body?.format||`gltf-binary`},brain:e.brain||{provider:`none`},voice:e.voice||{tts:{provider:`browser`},stt:{provider:`browser`}},skills:e.skills||[],memory:e.memory||{mode:`local`},tools:e.tools||[`wave`,`lookAt`,`play_clip`,`setExpression`],version:e.version||`0.1.0`}}function wA(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t+1):e}async function TA(e,t){if(!e._baseURI)return null;try{let n=new URL(t,e._baseURI).href,r=await fetch(n);return r.ok?r.text():null}catch{return null}}var EA=[`inline`,`floating`,`section`,`fullscreen`],DA=`
+`)}async export(){return{version:`memory/0.1`,index:this.indexText,files:Object.fromEntries(this.files),timeline:this.timeline}}async import(e,{strategy:t=`merge`}={}){if(t===`replace`)this.files=new Map(Object.entries(e.files||{})),this.timeline=e.timeline||[];else{for(let[t,n]of Object.entries(e.files||{}))this.files.has(t)||this.files.set(t,n);this.timeline=[...this.timeline,...e.timeline||[]].slice(-1e3)}this._rebuildIndex(),this._persist()}},yv=`6.16.0`;function bv(e,t,n){let r=t.split(`|`).map(e=>e.trim());for(let n=0;n<r.length;n++)switch(t){case`any`:return;case`bigint`:case`boolean`:case`number`:case`string`:if(typeof e===t)return}let i=Error(`invalid value for type ${t}`);throw i.code=`INVALID_ARGUMENT`,i.argument=`value.${n}`,i.value=e,i}async function xv(e){let t=Object.keys(e);return(await Promise.all(t.map(t=>Promise.resolve(e[t])))).reduce((e,n,r)=>(e[t[r]]=n,e),{})}function G(e,t,n){for(let r in t){let i=t[r],a=n?n[r]:null;a&&bv(i,a,r),Object.defineProperty(e,r,{enumerable:!0,value:i,writable:!1})}}function Sv(e,t){if(e==null)return`null`;if(t??=new Set,typeof e==`object`){if(t.has(e))return`[Circular]`;t.add(e)}if(Array.isArray(e))return`[ `+e.map(e=>Sv(e,t)).join(`, `)+` ]`;if(e instanceof Uint8Array){let t=`0123456789abcdef`,n=`0x`;for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[e[r]&15];return n}if(typeof e==`object`&&typeof e.toJSON==`function`)return Sv(e.toJSON(),t);switch(typeof e){case`boolean`:case`number`:case`symbol`:return e.toString();case`bigint`:return BigInt(e).toString();case`string`:return JSON.stringify(e);case`object`:{let n=Object.keys(e);return n.sort(),`{ `+n.map(n=>`${Sv(n,t)}: ${Sv(e[n],t)}`).join(`, `)+` }`}}return`[ COULD NOT SERIALIZE ]`}function Cv(e,t){return e&&e.code===t}function wv(e){return Cv(e,`CALL_EXCEPTION`)}function Tv(e,t,n){let r=e;{let r=[];if(n){if(`message`in n||`code`in n||`name`in n)throw Error(`value will overwrite populated values: ${Sv(n)}`);for(let e in n){if(e===`shortMessage`)continue;let t=n[e];r.push(e+`=`+Sv(t))}}r.push(`code=${t}`),r.push(`version=${yv}`),r.length&&(e+=` (`+r.join(`, `)+`)`)}let i;switch(t){case`INVALID_ARGUMENT`:i=TypeError(e);break;case`NUMERIC_FAULT`:case`BUFFER_OVERRUN`:i=RangeError(e);break;default:i=Error(e)}return G(i,{code:t}),n&&Object.assign(i,n),i.shortMessage??G(i,{shortMessage:r}),i}function K(e,t,n,r){if(!e)throw Tv(t,n,r)}function q(e,t,n,r){K(e,t,`INVALID_ARGUMENT`,{argument:n,value:r})}function Ev(e,t,n){n??=``,n&&=`: `+n,K(e>=t,`missing argument`+n,`MISSING_ARGUMENT`,{count:e,expectedCount:t}),K(e<=t,`too many arguments`+n,`UNEXPECTED_ARGUMENT`,{count:e,expectedCount:t})}var Dv=[`NFD`,`NFC`,`NFKD`,`NFKC`].reduce((e,t)=>{try{if(`test`.normalize(t)!==`test`)throw Error(`bad`);if(t===`NFD`&&`é`.normalize(`NFD`)!==`é`)throw Error(`broken`);e.push(t)}catch{}return e},[]);function Ov(e){K(Dv.indexOf(e)>=0,`platform missing String.prototype.normalize`,`UNSUPPORTED_OPERATION`,{operation:`String.prototype.normalize`,info:{form:e}})}function kv(e,t,n){if(n??=``,e!==t){let e=n,t=`new`;n&&(e+=`.`,t+=` `+n),K(!1,`private constructor; use ${e}from* methods`,`UNSUPPORTED_OPERATION`,{operation:t})}}function Av(e,t,n){if(e instanceof Uint8Array)return n?new Uint8Array(e):e;if(typeof e==`string`&&e.length%2==0&&e.match(/^0x[0-9a-f]*$/i)){let t=new Uint8Array((e.length-2)/2),n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}q(!1,`invalid BytesLike value`,t||`value`,e)}function J(e,t){return Av(e,t,!1)}function jv(e,t){return Av(e,t,!0)}function Mv(e,t){return!(typeof e!=`string`||!e.match(/^0x[0-9A-Fa-f]*$/)||typeof t==`number`&&e.length!==2+2*t||t===!0&&e.length%2!=0)}function Nv(e){return Mv(e,!0)||e instanceof Uint8Array}var Pv=`0123456789abcdef`;function Y(e){let t=J(e),n=`0x`;for(let e=0;e<t.length;e++){let r=t[e];n+=Pv[(r&240)>>4]+Pv[r&15]}return n}function Fv(e){return`0x`+e.map(e=>Y(e).substring(2)).join(``)}function Iv(e){return Mv(e,!0)?(e.length-2)/2:J(e).length}function Lv(e,t,n){let r=J(e);return n!=null&&n>r.length&&K(!1,`cannot slice beyond data bounds`,`BUFFER_OVERRUN`,{buffer:r,length:r.length,offset:n}),Y(r.slice(t??0,n??r.length))}function Rv(e,t,n){let r=J(e);K(t>=r.length,`padding exceeds data length`,`BUFFER_OVERRUN`,{buffer:new Uint8Array(r),length:t,offset:t+1});let i=new Uint8Array(t);return i.fill(0),n?i.set(r,t-r.length):i.set(r,0),Y(i)}function zv(e,t){return Rv(e,t,!0)}function Bv(e,t){return Rv(e,t,!1)}var Vv=BigInt(0),Hv=BigInt(1),Uv=9007199254740991;function Wv(e,t){let n=qv(e,`value`),r=BigInt(Z(t,`width`));if(K(n>>r===Vv,`overflow`,`NUMERIC_FAULT`,{operation:`fromTwos`,fault:`overflow`,value:e}),n>>r-Hv){let e=(Hv<<r)-Hv;return-((~n&e)+Hv)}return n}function Gv(e,t){let n=X(e,`value`),r=BigInt(Z(t,`width`)),i=Hv<<r-Hv;if(n<Vv){n=-n,K(n<=i,`too low`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});let t=(Hv<<r)-Hv;return(~n&t)+Hv}else K(n<i,`too high`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});return n}function Kv(e,t){return qv(e,`value`)&(Hv<<BigInt(Z(t,`bits`)))-Hv}function X(e,t){switch(typeof e){case`bigint`:return e;case`number`:return q(Number.isInteger(e),`underflow`,t||`value`,e),q(e>=-Uv&&e<=Uv,`overflow`,t||`value`,e),BigInt(e);case`string`:try{if(e===``)throw Error(`empty string`);return e[0]===`-`&&e[1]!==`-`?-BigInt(e.substring(1)):BigInt(e)}catch(n){q(!1,`invalid BigNumberish string: ${n.message}`,t||`value`,e)}}q(!1,`invalid BigNumberish value`,t||`value`,e)}function qv(e,t){let n=X(e,t);return K(n>=Vv,`unsigned value cannot be negative`,`NUMERIC_FAULT`,{fault:`overflow`,operation:`getUint`,value:e}),n}var Jv=`0123456789abcdef`;function Yv(e){if(e instanceof Uint8Array){let t=`0x0`;for(let n of e)t+=Jv[n>>4],t+=Jv[n&15];return BigInt(t)}return X(e)}function Z(e,t){switch(typeof e){case`bigint`:return q(e>=-Uv&&e<=Uv,`overflow`,t||`value`,e),Number(e);case`number`:return q(Number.isInteger(e),`underflow`,t||`value`,e),q(e>=-Uv&&e<=Uv,`overflow`,t||`value`,e),e;case`string`:try{if(e===``)throw Error(`empty string`);return Z(BigInt(e),t)}catch(n){q(!1,`invalid numeric string: ${n.message}`,t||`value`,e)}}q(!1,`invalid numeric value`,t||`value`,e)}function Xv(e){return Z(Yv(e))}function Zv(e,t){let n=qv(e,`value`),r=n.toString(16);if(t==null)r.length%2&&(r=`0`+r);else{let i=Z(t,`width`);if(i===0&&n===Vv)return`0x`;for(K(i*2>=r.length,`value exceeds width (${i} bytes)`,`NUMERIC_FAULT`,{operation:`toBeHex`,fault:`overflow`,value:e});r.length<i*2;)r=`0`+r}return`0x`+r}function Qv(e,t){let n=qv(e,`value`);if(n===Vv){let e=t==null?0:Z(t,`width`);return new Uint8Array(e)}let r=n.toString(16);if(r.length%2&&(r=`0`+r),t!=null){let n=Z(t,`width`);for(;r.length<n*2;)r=`00`+r;K(n*2===r.length,`value exceeds width (${n} bytes)`,`NUMERIC_FAULT`,{operation:`toBeArray`,fault:`overflow`,value:e})}let i=new Uint8Array(r.length/2);for(let e=0;e<i.length;e++){let t=e*2;i[e]=parseInt(r.substring(t,t+2),16)}return i}function $v(e){let t=Y(Nv(e)?e:Qv(e)).substring(2);for(;t.startsWith(`0`);)t=t.substring(1);return t===``&&(t=`0`),`0x`+t}var ey=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,ty=BigInt(58);function ny(e){let t=J(e),n=Yv(t),r=``;for(;n;)r=ey[Number(n%ty)]+r,n/=ty;for(let e=0;e<t.length&&!t[e];e++)r=ey[0]+r;return r}function ry(e){e=atob(e);let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return J(t)}function iy(e){let t=J(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}var ay=class{filter;emitter;#e;constructor(e,t,n){this.#e=t,G(this,{emitter:e,filter:n})}async removeListener(){this.#e!=null&&await this.emitter.off(this.filter,this.#e)}};function oy(e,t,n,r,i){q(!1,`invalid codepoint at offset ${t}; ${e}`,`bytes`,n)}function sy(e,t,n,r,i){if(e===`BAD_PREFIX`||e===`UNEXPECTED_CONTINUE`){let e=0;for(let r=t+1;r<n.length&&n[r]>>6==2;r++)e++;return e}return e===`OVERRUN`?n.length-t-1:0}function cy(e,t,n,r,i){return e===`OVERLONG`?(q(typeof i==`number`,`invalid bad code point for replacement`,`badCodepoint`,i),r.push(i),0):(r.push(65533),sy(e,t,n,r,i))}var ly=Object.freeze({error:oy,ignore:sy,replace:cy});function uy(e,t){t??=ly.error;let n=J(e,`bytes`),r=[],i=0;for(;i<n.length;){let e=n[i++];if(!(e>>7)){r.push(e);continue}let a=null,o=null;if((e&224)==192)a=1,o=127;else if((e&240)==224)a=2,o=2047;else if((e&248)==240)a=3,o=65535;else{(e&192)==128?i+=t(`UNEXPECTED_CONTINUE`,i-1,n,r):i+=t(`BAD_PREFIX`,i-1,n,r);continue}if(i-1+a>=n.length){i+=t(`OVERRUN`,i-1,n,r);continue}let s=e&(1<<8-a-1)-1;for(let e=0;e<a;e++){let e=n[i];if((e&192)!=128){i+=t(`MISSING_CONTINUE`,i,n,r),s=null;break}s=s<<6|e&63,i++}if(s!==null){if(s>1114111){i+=t(`OUT_OF_RANGE`,i-1-a,n,r,s);continue}if(s>=55296&&s<=57343){i+=t(`UTF16_SURROGATE`,i-1-a,n,r,s);continue}if(s<=o){i+=t(`OVERLONG`,i-1-a,n,r,s);continue}r.push(s)}}return r}function dy(e,t){q(typeof e==`string`,`invalid string value`,`str`,e),t!=null&&(Ov(t),e=e.normalize(t));let n=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<128)n.push(r);else if(r<2048)n.push(r>>6|192),n.push(r&63|128);else if((r&64512)==55296){t++;let i=e.charCodeAt(t);q(t<e.length&&(i&64512)==56320,`invalid surrogate pair`,`str`,e);let a=65536+((r&1023)<<10)+(i&1023);n.push(a>>18|240),n.push(a>>12&63|128),n.push(a>>6&63|128),n.push(a&63|128)}else n.push(r>>12|224),n.push(r>>6&63|128),n.push(r&63|128)}return new Uint8Array(n)}function fy(e){return e.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join(``)}function py(e,t){return fy(uy(e,t))}function my(e){async function t(t,n){K(n==null||!n.cancelled,`request cancelled before sending`,`CANCELLED`);let r=t.url.split(`:`)[0].toLowerCase();K(r===`http`||r===`https`,`unsupported protocol ${r}`,`UNSUPPORTED_OPERATION`,{info:{protocol:r},operation:`request`}),K(r===`https`||!t.credentials||t.allowInsecureAuthentication,`insecure authorized connections unsupported`,`UNSUPPORTED_OPERATION`,{operation:`request`});let i=null,a=new AbortController,o=setTimeout(()=>{i=Tv(`request timeout`,`TIMEOUT`),a.abort()},t.timeout);n&&n.addListener(()=>{i=Tv(`request cancelled`,`CANCELLED`),a.abort()});let s=Object.assign({},e,{method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:a.signal}),c;try{c=await fetch(t.url,s)}catch(e){throw clearTimeout(o),i||e}clearTimeout(o);let l={};c.headers.forEach((e,t)=>{l[t.toLowerCase()]=e});let u=await c.arrayBuffer(),d=u==null?null:new Uint8Array(u);return{statusCode:c.status,statusMessage:c.statusText,headers:l,body:d}}return t}var hy=12,gy=250,_y=my(),vy=RegExp(`^data:([^;:]*)?(;base64)?,(.*)$`,`i`),yy=RegExp(`^ipfs://(ipfs/)?(.*)$`,`i`),by=!1;async function xy(e,t){try{let t=e.match(vy);if(!t)throw Error(`invalid data`);return new Oy(200,`OK`,{"content-type":t[1]||`text/plain`},t[2]?ry(t[3]):Ay(t[3]))}catch{return new Oy(599,`BAD REQUEST (invalid data: URI)`,{},null,new Dy(e))}}function Sy(e){async function t(t,n){try{let n=t.match(yy);if(!n)throw Error(`invalid link`);return new Dy(`${e}${n[2]}`)}catch{return new Oy(599,`BAD REQUEST (invalid IPFS URI)`,{},null,new Dy(t))}}return t}var Cy={data:xy,ipfs:Sy(`https://gateway.ipfs.io/ipfs/`)},wy=new WeakMap,Ty=class{#e;#t;constructor(e){this.#e=[],this.#t=!1,wy.set(e,()=>{if(!this.#t){this.#t=!0;for(let e of this.#e)setTimeout(()=>{e()},0);this.#e=[]}})}addListener(e){K(!this.#t,`singal already cancelled`,`UNSUPPORTED_OPERATION`,{operation:`fetchCancelSignal.addCancelListener`}),this.#e.push(e)}get cancelled(){return this.#t}checkSignal(){K(!this.cancelled,`cancelled`,`CANCELLED`,{})}};function Ey(e){if(e==null)throw Error(`missing signal; should not happen`);return e.checkSignal(),e}var Dy=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;get url(){return this.#a}set url(e){this.#a=String(e)}get body(){return this.#o==null?null:new Uint8Array(this.#o)}set body(e){if(e==null)this.#o=void 0,this.#s=void 0;else if(typeof e==`string`)this.#o=dy(e),this.#s=`text/plain`;else if(e instanceof Uint8Array)this.#o=e,this.#s=`application/octet-stream`;else if(typeof e==`object`)this.#o=dy(JSON.stringify(e)),this.#s=`application/json`;else throw Error(`invalid body`)}hasBody(){return this.#o!=null}get method(){return this.#r?this.#r:this.hasBody()?`POST`:`GET`}set method(e){e??=``,this.#r=String(e).toUpperCase()}get headers(){let e=Object.assign({},this.#n);return this.#c&&(e.authorization=`Basic ${iy(dy(this.#c))}`),this.allowGzip&&(e[`accept-encoding`]=`gzip`),e[`content-type`]==null&&this.#s&&(e[`content-type`]=this.#s),this.body&&(e[`content-length`]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){this.#n[String(e).toLowerCase()]=String(t)}clearHeaders(){this.#n={}}[Symbol.iterator](){let e=this.headers,t=Object.keys(e),n=0;return{next:()=>{if(n<t.length){let r=t[n++];return{value:[r,e[r]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return this.#c||null}setCredentials(e,t){q(!e.match(/:/),`invalid basic authentication username`,`username`,`[REDACTED]`),this.#c=`${e}:${t}`}get allowGzip(){return this.#t}set allowGzip(e){this.#t=!!e}get allowInsecureAuthentication(){return!!this.#e}set allowInsecureAuthentication(e){this.#e=!!e}get timeout(){return this.#i}set timeout(e){q(e>=0,`timeout must be non-zero`,`timeout`,e),this.#i=e}get preflightFunc(){return this.#l||null}set preflightFunc(e){this.#l=e}get processFunc(){return this.#u||null}set processFunc(e){this.#u=e}get retryFunc(){return this.#d||null}set retryFunc(e){this.#d=e}get getUrlFunc(){return this.#m||_y}set getUrlFunc(e){this.#m=e}constructor(e){this.#a=String(e),this.#e=!1,this.#t=!0,this.#n={},this.#r=``,this.#i=3e5,this.#p={slotInterval:gy,maxAttempts:hy},this.#m=null}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#o?Y(this.#o):`null`}>`}setThrottleParams(e){e.slotInterval!=null&&(this.#p.slotInterval=e.slotInterval),e.maxAttempts!=null&&(this.#p.maxAttempts=e.maxAttempts)}async#h(e,t,n,r,i){if(e>=this.#p.maxAttempts)return i.makeServerError(`exceeded maximum retry limit`);K(ky()<=t,`timeout`,`TIMEOUT`,{operation:`request.send`,reason:`timeout`,request:r}),n>0&&await jy(n);let a=this.clone(),o=(a.url.split(`:`)[0]||``).toLowerCase();if(o in Cy){let e=await Cy[o](a.url,Ey(r.#f));if(e instanceof Oy){let t=e;if(this.processFunc){Ey(r.#f);try{t=await this.processFunc(a,t)}catch(e){(e.throttle==null||typeof e.stall!=`number`)&&t.makeServerError(`error in post-processing function`,e).assertOk()}}return t}a=e}this.preflightFunc&&(a=await this.preflightFunc(a));let s=await this.getUrlFunc(a,Ey(r.#f)),c=new Oy(s.statusCode,s.statusMessage,s.headers,s.body,r);if(c.statusCode===301||c.statusCode===302){try{let n=c.headers.location||``;return a.redirect(n).#h(e+1,t,0,r,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(a,c,e))){let n=c.headers[`retry-after`],i=this.#p.slotInterval*Math.trunc(Math.random()*2**e);return typeof n==`string`&&n.match(/^[1-9][0-9]*$/)&&(i=parseInt(n)),a.clone().#h(e+1,t,i,r,c)}if(this.processFunc){Ey(r.#f);try{c=await this.processFunc(a,c)}catch(n){(n.throttle==null||typeof n.stall!=`number`)&&c.makeServerError(`error in post-processing function`,n).assertOk();let i=this.#p.slotInterval*Math.trunc(Math.random()*2**e);return n.stall>=0&&(i=n.stall),a.clone().#h(e+1,t,i,r,c)}}return c}send(){return K(this.#f==null,`request already sent`,`UNSUPPORTED_OPERATION`,{operation:`fetchRequest.send`}),this.#f=new Ty(this),this.#h(0,ky()+this.timeout,0,this,new Oy(0,``,{},null,this))}cancel(){K(this.#f!=null,`request has not been sent`,`UNSUPPORTED_OPERATION`,{operation:`fetchRequest.cancel`});let e=wy.get(this);if(!e)throw Error(`missing signal; should not happen`);e()}redirect(t){let n=this.url.split(`:`)[0].toLowerCase(),r=t.split(`:`)[0].toLowerCase();K(this.method===`GET`&&(n!==`https`||r!==`http`)&&t.match(/^https?:/),`unsupported redirect`,`UNSUPPORTED_OPERATION`,{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});let i=new e(t);return i.method=`GET`,i.allowGzip=this.allowGzip,i.timeout=this.timeout,i.#n=Object.assign({},this.#n),this.#o&&(i.#o=new Uint8Array(this.#o)),i.#s=this.#s,i}clone(){let t=new e(this.url);return t.#r=this.#r,this.#o&&(t.#o=this.#o),t.#s=this.#s,t.#n=Object.assign({},this.#n),t.#c=this.#c,this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),t.#l=this.#l,t.#u=this.#u,t.#d=this.#d,t.#p=Object.assign({},this.#p),t.#m=this.#m,t}static lockConfig(){by=!0}static getGateway(e){return Cy[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e===`http`||e===`https`)throw Error(`cannot intercept ${e}; use registerGetUrl`);if(by)throw Error(`gateways locked`);Cy[e]=t}static registerGetUrl(e){if(by)throw Error(`gateways locked`);_y=e}static createGetUrlFunc(e){return my(e)}static createDataGateway(){return xy}static createIpfsGatewayFunc(e){return Sy(e)}},Oy=class e{#e;#t;#n;#r;#i;#a;toString(){return`<FetchResponse status=${this.statusCode} body=${this.#r?Y(this.#r):`null`}>`}get statusCode(){return this.#e}get statusMessage(){return this.#t}get headers(){return Object.assign({},this.#n)}get body(){return this.#r==null?null:new Uint8Array(this.#r)}get bodyText(){try{return this.#r==null?``:py(this.#r)}catch{K(!1,`response body is not valid UTF-8 data`,`UNSUPPORTED_OPERATION`,{operation:`bodyText`,info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{K(!1,`response body is not valid JSON`,`UNSUPPORTED_OPERATION`,{operation:`bodyJson`,info:{response:this}})}}[Symbol.iterator](){let e=this.headers,t=Object.keys(e),n=0;return{next:()=>{if(n<t.length){let r=t[n++];return{value:[r,e[r]],done:!1}}return{value:void 0,done:!0}}}}constructor(e,t,n,r,i){this.#e=e,this.#t=t,this.#n=Object.keys(n).reduce((e,t)=>(e[t.toLowerCase()]=String(n[t]),e),{}),this.#r=r==null?null:new Uint8Array(r),this.#i=i||null,this.#a={message:``}}makeServerError(t,n){let r;t?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:(t=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${t})`);let i=new e(599,r,this.headers,this.body,this.#i||void 0);return i.#a={message:t,error:n},i}throwThrottleError(e,t){t==null?t=-1:q(Number.isInteger(t)&&t>=0,`invalid stall timeout`,`stall`,t);let n=Error(e||`throttling requests`);throw G(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return this.#r!=null}get request(){return this.#i}ok(){return this.#a.message===``&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=this.#a;e===``&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let r=null;try{this.#r&&(r=py(this.#r))}catch{}K(!1,e,`SERVER_ERROR`,{request:this.request||`unknown request`,response:this,error:t,info:{requestUrl:n,responseBody:r,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};function ky(){return new Date().getTime()}function Ay(e){return dy(e.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function jy(e){return new Promise(t=>setTimeout(t,e))}function My(e){let t=e.toString(16);for(;t.length<2;)t=`0`+t;return`0x`+t}function Ny(e,t,n){let r=0;for(let i=0;i<n;i++)r=r*256+e[t+i];return r}function Py(e,t,n,r){let i=[];for(;n<t+1+r;){let a=Fy(e,n);i.push(a.result),n+=a.consumed,K(n<=t+1+r,`child data too short`,`BUFFER_OVERRUN`,{buffer:e,length:r,offset:t})}return{consumed:1+r,result:i}}function Fy(e,t){K(e.length!==0,`data too short`,`BUFFER_OVERRUN`,{buffer:e,length:0,offset:1});let n=t=>{K(t<=e.length,`data short segment too short`,`BUFFER_OVERRUN`,{buffer:e,length:e.length,offset:t})};if(e[t]>=248){let r=e[t]-247;n(t+1+r);let i=Ny(e,t+1,r);return n(t+1+r+i),Py(e,t,t+1+r,r+i)}else if(e[t]>=192){let r=e[t]-192;return n(t+1+r),Py(e,t,t+1,r)}else if(e[t]>=184){let r=e[t]-183;n(t+1+r);let i=Ny(e,t+1,r);n(t+1+r+i);let a=Y(e.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:a}}else if(e[t]>=128){let r=e[t]-128;n(t+1+r);let i=Y(e.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:My(e[t])}}function Iy(e){let t=J(e,`data`),n=Fy(t,0);return q(n.consumed===t.length,`unexpected junk after rlp payload`,`data`,e),n.result}function Ly(e){let t=[];for(;e;)t.unshift(e&255),e>>=8;return t}function Ry(e){if(Array.isArray(e)){let t=[];if(e.forEach(function(e){t=t.concat(Ry(e))}),t.length<=55)return t.unshift(192+t.length),t;let n=Ly(t.length);return n.unshift(247+n.length),n.concat(t)}let t=Array.prototype.slice.call(J(e,`object`));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;let n=Ly(t.length);return n.unshift(183+n.length),n.concat(t)}var zy=`0123456789abcdef`;function By(e){let t=`0x`;for(let n of Ry(e))t+=zy[n>>4],t+=zy[n&15];return t}var Vy=new Uint8Array(32),Hy=[`then`],Uy={},Wy=new WeakMap;function Gy(e){return Wy.get(e)}function Ky(e,t){Wy.set(e,t)}function qy(e,t){let n=Error(`deferred error during ABI decoding triggered accessing ${e}`);throw n.error=t,n}function Jy(e,t,n){return e.indexOf(null)>=0?t.map((e,t)=>e instanceof Yy?Jy(Gy(e),e,n):e):e.reduce((e,r,i)=>{let a=t.getValue(r);return r in e||(n&&a instanceof Yy&&(a=Jy(Gy(a),a,n)),e[r]=a),e},{})}var Yy=class e extends Array{#e;constructor(...e){let t=e[0],n=e[1],r=(e[2]||[]).slice(),i=!0;t!==Uy&&(n=e,r=[],i=!1),super(n.length),n.forEach((e,t)=>{this[t]=e});let a=r.reduce((e,t)=>(typeof t==`string`&&e.set(t,(e.get(t)||0)+1),e),new Map);if(Ky(this,Object.freeze(n.map((e,t)=>{let n=r[t];return n!=null&&a.get(n)===1?n:null}))),this.#e=[],this.#e??this.#e,!i)return;Object.freeze(this);let o=new Proxy(this,{get:(e,t,n)=>{if(typeof t==`string`){if(t.match(/^[0-9]+$/)){let n=Z(t,`%index`);if(n<0||n>=this.length)throw RangeError(`out of result range`);let r=e[n];return r instanceof Error&&qy(`index ${n}`,r),r}if(Hy.indexOf(t)>=0)return Reflect.get(e,t,n);let r=e[t];if(r instanceof Function)return function(...t){return r.apply(this===n?e:this,t)};if(!(t in e))return e.getValue.apply(this===n?e:this,[t])}return Reflect.get(e,t,n)}});return Ky(o,Gy(this)),o}toArray(t){let n=[];return this.forEach((r,i)=>{r instanceof Error&&qy(`index ${i}`,r),t&&r instanceof e&&(r=r.toArray(t)),n.push(r)}),n}toObject(e){let t=Gy(this);return t.reduce((n,r,i)=>(K(r!=null,`value at index ${i} unnamed`,`UNSUPPORTED_OPERATION`,{operation:`toObject()`}),Jy(t,this,e)),{})}slice(t,n){t??=0,t<0&&(t+=this.length,t<0&&(t=0)),n??=this.length,n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);let r=Gy(this),i=[],a=[];for(let e=t;e<n;e++)i.push(this[e]),a.push(r[e]);return new e(Uy,i,a)}filter(t,n){let r=Gy(this),i=[],a=[];for(let e=0;e<this.length;e++){let o=this[e];o instanceof Error&&qy(`index ${e}`,o),t.call(n,o,e,this)&&(i.push(o),a.push(r[e]))}return new e(Uy,i,a)}map(e,t){let n=[];for(let r=0;r<this.length;r++){let i=this[r];i instanceof Error&&qy(`index ${r}`,i),n.push(e.call(t,i,r,this))}return n}getValue(e){let t=Gy(this).indexOf(e);if(t===-1)return;let n=this[t];return n instanceof Error&&qy(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(t,n){return new e(Uy,t,n)}};function Xy(e){let t=Qv(e);return K(t.length<=32,`value out-of-bounds`,`BUFFER_OVERRUN`,{buffer:t,length:32,offset:t.length}),t.length!==32&&(t=jv(Fv([Vy.slice(t.length%32),t]))),t}var Zy=class{name;type;localName;dynamic;constructor(e,t,n,r){G(this,{name:e,type:t,localName:n,dynamic:r},{name:`string`,type:`string`,localName:`string`,dynamic:`boolean`})}_throwError(e,t){q(!1,e,this.localName,t)}},Qy=class{#e;#t;constructor(){this.#e=[],this.#t=0}get data(){return Fv(this.#e)}get length(){return this.#t}#n(e){return this.#e.push(e),this.#t+=e.length,e.length}appendWriter(e){return this.#n(jv(e.data))}writeBytes(e){let t=jv(e),n=t.length%32;return n&&(t=jv(Fv([t,Vy.slice(n)]))),this.#n(t)}writeValue(e){return this.#n(Xy(e))}writeUpdatableValue(){let e=this.#e.length;return this.#e.push(Vy),this.#t+=32,t=>{this.#e[e]=Xy(t)}}},$y=class e{allowLoose;#e;#t;#n;#r;#i;constructor(e,t,n){G(this,{allowLoose:!!t}),this.#e=jv(e),this.#n=0,this.#r=null,this.#i=n??1024,this.#t=0}get data(){return Y(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#t}get bytes(){return new Uint8Array(this.#e)}#a(e){if(this.#r)return this.#r.#a(e);this.#n+=e,K(this.#i<1||this.#n<=this.#i*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#i} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`,`BUFFER_OVERRUN`,{buffer:jv(this.#e),offset:this.#t,length:e,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#o(e,t,n){let r=Math.ceil(t/32)*32;return this.#t+r>this.#e.length&&(this.allowLoose&&n&&this.#t+t<=this.#e.length?r=t:K(!1,`data out-of-bounds`,`BUFFER_OVERRUN`,{buffer:jv(this.#e),length:this.#e.length,offset:this.#t+r})),this.#e.slice(this.#t,this.#t+r)}subReader(t){let n=new e(this.#e.slice(this.#t+t),this.allowLoose,this.#i);return n.#r=this,n}readBytes(e,t){let n=this.#o(0,e,!!t);return this.#a(e),this.#t+=n.length,n.slice(0,e)}readValue(){return Yv(this.readBytes(32))}readIndex(){return Xv(this.readBytes(32))}};function eb(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function tb(e,...t){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array`);if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function nb(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.wrapConstructor`);eb(e.outputLen),eb(e.blockLen)}function rb(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function ib(e,t){tb(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least ${n}`)}var ab=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0,ob=e=>e instanceof Uint8Array,sb=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),cb=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),lb=(e,t)=>e<<32-t|e>>>t;if(new Uint8Array(new Uint32Array([287454020]).buffer)[0]!==68)throw Error(`Non little-endian hardware is not supported`);function ub(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function db(e){if(typeof e==`string`&&(e=ub(e)),!ob(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}function fb(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!ob(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}var pb=class{clone(){return this._cloneInto()}};({}).toString;function mb(e){let t=t=>e().update(db(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function hb(e=32){if(ab&&typeof ab.getRandomValues==`function`)return ab.getRandomValues(new Uint8Array(e));throw Error(`crypto.getRandomValues must be defined`)}var gb=class extends pb{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,nb(e);let n=db(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return rb(this),this.iHash.update(e),this}digestInto(e){rb(this),tb(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_b=(e,t,n)=>new gb(e,t).update(n).digest();_b.create=(e,t)=>new gb(e,t);function vb(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}var yb=class extends pb{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=cb(this.buffer)}update(e){rb(this);let{view:t,buffer:n,blockLen:r}=this;e=db(e);let i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=cb(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){rb(this),ib(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;vb(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=cb(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=a,r%t&&e.buffer.set(n),e}},bb=(e,t,n)=>e&t^~e&n,xb=(e,t,n)=>e&t^e&n^t&n,Sb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Cb=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),wb=new Uint32Array(64),Tb=class extends yb{constructor(){super(64,32,8,!1),this.A=Cb[0]|0,this.B=Cb[1]|0,this.C=Cb[2]|0,this.D=Cb[3]|0,this.E=Cb[4]|0,this.F=Cb[5]|0,this.G=Cb[6]|0,this.H=Cb[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)wb[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=wb[e-15],n=wb[e-2],r=lb(t,7)^lb(t,18)^t>>>3;wb[e]=(lb(n,17)^lb(n,19)^n>>>10)+wb[e-7]+r+wb[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=lb(o,6)^lb(o,11)^lb(o,25),u=l+t+bb(o,s,c)+Sb[e]+wb[e]|0,d=(lb(n,2)^lb(n,13)^lb(n,22))+xb(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){wb.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Eb=mb(()=>new Tb),Db=BigInt(2**32-1),Ob=BigInt(32);function kb(e,t=!1){return t?{h:Number(e&Db),l:Number(e>>Ob&Db)}:{h:Number(e>>Ob&Db)|0,l:Number(e&Db)|0}}function Ab(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=kb(e[i],t);[n[i],r[i]]=[a,o]}return[n,r]}var jb=(e,t)=>BigInt(e>>>0)<<Ob|BigInt(t>>>0),Mb=(e,t,n)=>e>>>n,Nb=(e,t,n)=>e<<32-n|t>>>n,Pb=(e,t,n)=>e>>>n|t<<32-n,Fb=(e,t,n)=>e<<32-n|t>>>n,Ib=(e,t,n)=>e<<64-n|t>>>n-32,Lb=(e,t,n)=>e>>>n-32|t<<64-n,Rb=(e,t)=>t,zb=(e,t)=>e,Bb=(e,t,n)=>e<<n|t>>>32-n,Vb=(e,t,n)=>t<<n|e>>>32-n,Hb=(e,t,n)=>t<<n-32|e>>>64-n,Ub=(e,t,n)=>e<<n-32|t>>>64-n;function Wb(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var Q={fromBig:kb,split:Ab,toBig:jb,shrSH:Mb,shrSL:Nb,rotrSH:Pb,rotrSL:Fb,rotrBH:Ib,rotrBL:Lb,rotr32H:Rb,rotr32L:zb,rotlSH:Bb,rotlSL:Vb,rotlBH:Hb,rotlBL:Ub,add:Wb,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},[Gb,Kb]=Q.split(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),qb=new Uint32Array(80),Jb=new Uint32Array(80),Yb=class extends yb{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)qb[n]=e.getUint32(t),Jb[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=qb[e-15]|0,n=Jb[e-15]|0,r=Q.rotrSH(t,n,1)^Q.rotrSH(t,n,8)^Q.shrSH(t,n,7),i=Q.rotrSL(t,n,1)^Q.rotrSL(t,n,8)^Q.shrSL(t,n,7),a=qb[e-2]|0,o=Jb[e-2]|0,s=Q.rotrSH(a,o,19)^Q.rotrBH(a,o,61)^Q.shrSH(a,o,6),c=Q.rotrSL(a,o,19)^Q.rotrBL(a,o,61)^Q.shrSL(a,o,6),l=Q.add4L(i,c,Jb[e-7],Jb[e-16]);qb[e]=Q.add4H(l,r,s,qb[e-7],qb[e-16])|0,Jb[e]=l|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Q.rotrSH(u,d,14)^Q.rotrSH(u,d,18)^Q.rotrBH(u,d,41),v=Q.rotrSL(u,d,14)^Q.rotrSL(u,d,18)^Q.rotrBL(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=Q.add5L(_,v,b,Kb[e],Jb[e]),S=Q.add5H(x,g,t,y,Gb[e],qb[e]),C=x|0,w=Q.rotrSH(n,r,28)^Q.rotrBH(n,r,34)^Q.rotrBH(n,r,39),T=Q.rotrSL(n,r,28)^Q.rotrBL(n,r,34)^Q.rotrBL(n,r,39),E=n&i^n&o^i&o,D=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=Q.add(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let O=Q.add3L(C,T,D);n=Q.add3H(O,S,w,E),r=O|0}({h:n,l:r}=Q.add(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=Q.add(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=Q.add(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=Q.add(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Q.add(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Q.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=Q.add(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=Q.add(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){qb.fill(0),Jb.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Xb=mb(()=>new Yb);function Zb(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`unable to locate global object`)}var Qb=Zb();Qb.crypto||Qb.msCrypto;function $b(e){switch(e){case`sha256`:return Eb.create();case`sha512`:return Xb.create()}q(!1,`invalid hashing algorithm name`,`algorithm`,e)}var[ex,tx,nx]=[[],[],[]],rx=BigInt(0),ix=BigInt(1),ax=BigInt(2),ox=BigInt(7),sx=BigInt(256),cx=BigInt(113);for(let e=0,t=ix,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ex.push(2*(5*r+n)),tx.push((e+1)*(e+2)/2%64);let i=rx;for(let e=0;e<7;e++)t=(t<<ix^(t>>ox)*cx)%sx,t&ax&&(i^=ix<<(ix<<BigInt(e))-ix);nx.push(i)}var[lx,ux]=Ab(nx,!0),dx=(e,t,n)=>n>32?Hb(e,t,n):Bb(e,t,n),fx=(e,t,n)=>n>32?Ub(e,t,n):Vb(e,t,n);function px(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=dx(a,o,1)^n[r],c=fx(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=tx[n],a=dx(t,i,r),o=fx(t,i,r),s=ex[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=lx[r],e[1]^=ux[r]}n.fill(0)}var mx=class e extends pb{constructor(e,t,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,eb(n),0>=this.blockLen||this.blockLen>=200)throw Error(`Sha3 supports only keccak-f1600 function`);this.state=new Uint8Array(200),this.state32=sb(this.state)}keccak(){px(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){rb(this);let{blockLen:t,state:n}=this;e=db(e);let r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){rb(this,!1),tb(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return eb(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ib(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},hx=((e,t,n)=>mb(()=>new mx(t,e,n)))(1,136,256/8),gx=!1,_x=function(e){return hx(e)},vx=_x;function yx(e){let t=J(e,`data`);return Y(vx(t))}yx._=_x,yx.lock=function(){gx=!0},yx.register=function(e){if(gx)throw TypeError(`keccak256 is locked`);vx=e},Object.freeze(yx);var bx=function(e){return $b(`sha256`).update(e).digest()},xx=function(e){return $b(`sha512`).update(e).digest()},Sx=bx,Cx=xx,wx=!1,Tx=!1;function Ex(e){let t=J(e,`data`);return Y(Sx(t))}Ex._=bx,Ex.lock=function(){wx=!0},Ex.register=function(e){if(wx)throw Error(`sha256 is locked`);Sx=e},Object.freeze(Ex);function Dx(e){let t=J(e,`data`);return Y(Cx(t))}Dx._=xx,Dx.lock=function(){Tx=!0},Dx.register=function(e){if(Tx)throw Error(`sha512 is locked`);Cx=e},Object.freeze(Ex);var Ox=n({bitGet:()=>Jx,bitLen:()=>qx,bitMask:()=>Xx,bitSet:()=>Yx,bytesToHex:()=>Px,bytesToNumberBE:()=>Rx,bytesToNumberLE:()=>zx,concatBytes:()=>Wx,createHmacDrbg:()=>$x,ensureBytes:()=>Ux,equalBytes:()=>Gx,hexToBytes:()=>Lx,hexToNumber:()=>Ix,numberToBytesBE:()=>Bx,numberToBytesLE:()=>Vx,numberToHexUnpadded:()=>Fx,numberToVarBytesBE:()=>Hx,utf8ToBytes:()=>Kx,validateObject:()=>tS}),kx=BigInt(0),Ax=BigInt(1),jx=BigInt(2),Mx=e=>e instanceof Uint8Array,Nx=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Px(e){if(!Mx(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n<e.length;n++)t+=Nx[e[n]];return t}function Fx(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function Ix(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}function Lx(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=e.length;if(t%2)throw Error(`padded hex string expected, got unpadded hex of length `+t);let n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){let r=t*2,i=e.slice(r,r+2),a=Number.parseInt(i,16);if(Number.isNaN(a)||a<0)throw Error(`Invalid byte sequence`);n[t]=a}return n}function Rx(e){return Ix(Px(e))}function zx(e){if(!Mx(e))throw Error(`Uint8Array expected`);return Ix(Px(Uint8Array.from(e).reverse()))}function Bx(e,t){return Lx(e.toString(16).padStart(t*2,`0`))}function Vx(e,t){return Bx(e,t).reverse()}function Hx(e){return Lx(Fx(e))}function Ux(e,t,n){let r;if(typeof t==`string`)try{r=Lx(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(Mx(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(`${e} expected ${n} bytes, got ${i}`);return r}function Wx(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!Mx(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}function Gx(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Kx(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function qx(e){let t;for(t=0;e>kx;e>>=Ax,t+=1);return t}function Jx(e,t){return e>>BigInt(t)&Ax}var Yx=(e,t,n)=>e|(n?Ax:kx)<<BigInt(t),Xx=e=>(jx<<BigInt(e-1))-Ax,Zx=e=>new Uint8Array(e),Qx=e=>Uint8Array.from(e);function $x(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=Zx(e),i=Zx(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=Zx())=>{i=s(Qx([0]),e),r=s(),e.length!==0&&(i=s(Qx([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return Wx(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var eS={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,stringOrUint8Array:e=>typeof e==`string`||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function tS(e,t,n={}){let r=(t,n,r)=>{let i=eS[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}var nS=BigInt(0),rS=BigInt(1),iS=BigInt(2),aS=BigInt(3),oS=BigInt(4),sS=BigInt(5),cS=BigInt(8),lS=BigInt(16);function uS(e,t){let n=e%t;return n>=nS?n:t+n}function dS(e,t,n){if(n<=nS||t<nS)throw Error(`Expected power/modulo > 0`);if(n===rS)return nS;let r=rS;for(;t>nS;)t&rS&&(r=r*e%n),e=e*e%n,t>>=rS;return r}function fS(e,t,n){let r=e;for(;t-- >nS;)r*=r,r%=n;return r}function pS(e,t){if(e===nS||t<=nS)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=uS(e,t),r=t,i=nS,a=rS,o=rS,s=nS;for(;n!==nS;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==rS)throw Error(`invert: does not exist`);return uS(i,t)}function mS(e){let t=(e-rS)/iS,n,r,i;for(n=e-rS,r=0;n%iS===nS;n/=iS,r++);for(i=iS;i<e&&dS(i,t,e)!==e-rS;i++);if(r===1){let t=(e+rS)/oS;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}let a=(n+rS)/iS;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw Error(`Cannot find square root`);let s=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,a),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);let n=e.pow(c,rS<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),u=e.mul(u,c),s=t}return l}}function hS(e){if(e%oS===aS){let t=(e+rS)/oS;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}if(e%cS===sS){let t=(e-sS)/cS;return function(e,n){let r=e.mul(n,iS),i=e.pow(r,t),a=e.mul(n,i),o=e.mul(e.mul(a,iS),i),s=e.mul(a,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error(`Cannot find square root`);return s}}return e%lS,mS(e)}var gS=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function _S(e){return tS(e,gS.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`isSafeInteger`,BITS:`isSafeInteger`}))}function vS(e,t,n){if(n<nS)throw Error(`Expected power > 0`);if(n===nS)return e.ONE;if(n===rS)return t;let r=e.ONE,i=t;for(;n>nS;)n&rS&&(r=e.mul(r,i)),i=e.sqr(i),n>>=rS;return r}function yS(e,t){let n=Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function bS(e,t){let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function xS(e,t,n=!1,r={}){if(e<=nS)throw Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:a}=bS(e,t);if(a>2048)throw Error(`Field lengths over 2048 bytes are not supported`);let o=hS(e),s=Object.freeze({ORDER:e,BITS:i,BYTES:a,MASK:Xx(i),ZERO:nS,ONE:rS,create:t=>uS(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`Invalid field element: expected bigint, got ${typeof t}`);return nS<=t&&t<e},is0:e=>e===nS,isOdd:e=>(e&rS)===rS,neg:t=>uS(-t,e),eql:(e,t)=>e===t,sqr:t=>uS(t*t,e),add:(t,n)=>uS(t+n,e),sub:(t,n)=>uS(t-n,e),mul:(t,n)=>uS(t*n,e),pow:(e,t)=>vS(s,e,t),div:(t,n)=>uS(t*pS(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>pS(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>yS(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Vx(e,a):Bx(e,a),fromBytes:e=>{if(e.length!==a)throw Error(`Fp.fromBytes: expected ${a}, got ${e.length}`);return n?zx(e):Rx(e)}});return Object.freeze(s)}function SS(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function CS(e){let t=SS(e);return t+Math.ceil(t/2)}function wS(e,t,n=!1){let r=e.length,i=SS(t),a=CS(t);if(r<16||r<a||r>1024)throw Error(`expected ${a}-1024 bytes of input, got ${r}`);let o=uS(n?Rx(e):zx(e),t-rS)+rS;return n?Vx(o,i):Bx(o,i)}var TS=BigInt(0),ES=BigInt(1);function DS(e,t){let n=(e,t)=>{let n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>TS;)n&ES&&(r=r.add(i)),i=i.double(),n>>=ES;return r},precomputeWindow(e,t){let{windows:n,windowSize:i}=r(t),a=[],o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a},wNAF(t,i,a){let{windows:o,windowSize:s}=r(t),c=e.ZERO,l=e.BASE,u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){let t=e*s,r=Number(a&u);a>>=f,r>s&&(r-=d,a+=ES);let o=t,p=t+Math.abs(r)-1,m=e%2!=0,h=r<0;r===0?l=l.add(n(m,i[o])):c=c.add(n(h,i[p]))}return{p:c,f:l}},wNAFCached(e,t,n,r){let i=e._WINDOW_SIZE||1,a=t.get(e);return a||(a=this.precomputeWindow(e,i),i!==1&&t.set(e,r(a))),this.wNAF(i,a,n)}}}function OS(e){return _S(e.Fp),tS(e,{n:`bigint`,h:`bigint`,Gx:`field`,Gy:`field`},{nBitLength:`isSafeInteger`,nByteLength:`isSafeInteger`}),Object.freeze({...bS(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function kS(e){let t=OS(e);tS(t,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof n!=`object`||typeof n.beta!=`bigint`||typeof n.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...t})}var{bytesToNumberBE:AS,hexToBytes:jS}=Ox,MS={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=MS;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:AS(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=MS,n=typeof e==`string`?jS(e):e;if(!(n instanceof Uint8Array))throw Error(`ui8a expected`);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:a}=MS._parseInt(n.subarray(2)),{d:o,l:s}=MS._parseInt(a);if(s.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:o}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},NS=BigInt(0),PS=BigInt(1),FS=BigInt(2),IS=BigInt(3),LS=BigInt(4);function RS(e){let t=kS(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{let i=t.toAffine();return Wx(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{let t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){let{a:r,b:i}=t,a=n.sqr(e),o=n.mul(a,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw Error(`bad generator point: equation left != right`);function o(e){return typeof e==`bigint`&&NS<e&&e<t.n}function s(e){if(!o(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function c(e){let{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:a}=t;if(n&&typeof e!=`bigint`){if(e instanceof Uint8Array&&(e=Px(e)),typeof e!=`string`||!n.includes(e.length))throw Error(`Invalid key`);e=e.padStart(r*2,`0`)}let o;try{o=typeof e==`bigint`?e:Rx(Ux(`private key`,e,r))}catch{throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=uS(o,a)),s(o),o}let l=new Map;function u(e){if(!(e instanceof d))throw Error(`ProjectivePoint expected`)}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,e==null||!n.isValid(e))throw Error(`x required`);if(t==null||!n.isValid(t))throw Error(`y required`);if(r==null||!n.isValid(r))throw Error(`z required`)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error(`invalid affine point`);if(e instanceof d)throw Error(`projective point not allowed`);let i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){let t=d.fromAffine(i(Ux(`pointHex`,e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error(`bad point: ZERO`)}let{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error(`bad point: x or y not FE`);let i=n.sqr(r),o=a(e);if(!n.eql(i,o))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){u(e);let{px:t,py:r,pz:i}=this,{px:a,py:o,pz:s}=e,c=n.eql(n.mul(t,s),n.mul(a,i)),l=n.eql(n.mul(r,s),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){let{a:e,b:r}=t,i=n.mul(r,IS),{px:a,py:o,pz:s}=this,c=n.ZERO,l=n.ZERO,u=n.ZERO,f=n.mul(a,a),p=n.mul(o,o),m=n.mul(s,s),h=n.mul(a,o);return h=n.add(h,h),u=n.mul(a,s),u=n.add(u,u),c=n.mul(e,u),l=n.mul(i,m),l=n.add(c,l),c=n.sub(p,l),l=n.add(p,l),l=n.mul(c,l),c=n.mul(h,c),u=n.mul(i,u),m=n.mul(e,m),h=n.sub(f,m),h=n.mul(e,h),h=n.add(h,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,m),f=n.mul(f,h),l=n.add(l,f),m=n.mul(o,s),m=n.add(m,m),f=n.mul(m,h),c=n.sub(c,f),u=n.mul(m,p),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);let{px:r,py:i,pz:a}=this,{px:o,py:s,pz:c}=e,l=n.ZERO,f=n.ZERO,p=n.ZERO,m=t.a,h=n.mul(t.b,IS),g=n.mul(r,o),_=n.mul(i,s),v=n.mul(a,c),y=n.add(r,i),b=n.add(o,s);y=n.mul(y,b),b=n.add(g,_),y=n.sub(y,b),b=n.add(r,a);let x=n.add(o,c);return b=n.mul(b,x),x=n.add(g,v),b=n.sub(b,x),x=n.add(i,a),l=n.add(s,c),x=n.mul(x,l),l=n.add(_,v),x=n.sub(x,l),p=n.mul(m,b),l=n.mul(h,v),p=n.add(l,p),l=n.sub(_,p),p=n.add(_,p),f=n.mul(l,p),_=n.add(g,g),_=n.add(_,g),v=n.mul(m,v),b=n.mul(h,b),_=n.add(_,v),v=n.sub(g,v),v=n.mul(m,v),b=n.add(b,v),g=n.mul(_,b),f=n.add(f,g),g=n.mul(x,b),l=n.mul(y,l),l=n.sub(l,g),g=n.mul(y,_),p=n.mul(x,p),p=n.add(p,g),new d(l,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,l,e,e=>{let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){let r=d.ZERO;if(e===NS)return r;if(s(e),e===PS)return this;let{endo:i}=t;if(!i)return p.unsafeLadder(this,e);let{k1neg:a,k1:o,k2neg:c,k2:l}=i.splitScalar(e),u=r,f=r,m=this;for(;o>NS||l>NS;)o&PS&&(u=u.add(m)),l&PS&&(f=f.add(m)),m=m.double(),o>>=PS,l>>=PS;return a&&(u=u.negate()),c&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){s(e);let r=e,i,a,{endo:o}=t;if(o){let{k1neg:e,k1:t,k2neg:s,k2:c}=o.splitScalar(r),{p:l,f:u}=this.wNAF(t),{p:f,f:m}=this.wNAF(c);l=p.constTimeNegate(e,l),f=p.constTimeNegate(s,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=l.add(f),a=u.add(m)}else{let{p:e,f:t}=this.wNAF(r);i=e,a=t}return d.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){let r=d.BASE,i=(e,t)=>t===NS||t===PS||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:r,pz:i}=this,a=this.is0();e??=a?n.ONE:n.inv(i);let o=n.mul(t,e),s=n.mul(r,e),c=n.mul(i,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw Error(`invZ was invalid`);return{x:o,y:s}}isTorsionFree(){let{h:e,isTorsionFree:n}=t;if(e===PS)return!0;if(n)return n(d,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:n}=t;return e===PS?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return Px(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);let f=t.nBitLength,p=DS(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function zS(e){let t=OS(e);return tS(t,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...t})}function BS(e){let t=zS(e),{Fp:n,n:r}=t,i=n.BYTES+1,a=2*n.BYTES+1;function o(e){return NS<e&&e<n.ORDER}function s(e){return uS(e,r)}function c(e){return pS(e,r)}let{ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=RS({...t,toBytes(e,t,r){let i=t.toAffine(),a=n.toBytes(i.x),o=Wx;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),a):o(Uint8Array.from([4]),a,n.toBytes(i.y))},fromBytes(e){let t=e.length,r=e[0],s=e.subarray(1);if(t===i&&(r===2||r===3)){let e=Rx(s);if(!o(e))throw Error(`Point is not on curve`);let t=d(e),i=n.sqrt(t),a=(i&PS)===PS;return(r&1)==1!==a&&(i=n.neg(i)),{x:e,y:i}}else if(t===a&&r===4)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};else throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),p=e=>Px(Bx(e,t.nByteLength));function m(e){return e>r>>PS}function h(e){return m(e)?s(-e):e}let g=(e,t,n)=>Rx(e.slice(t,n));class _{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){let n=t.nByteLength;return e=Ux(`compactSignature`,e,n*2),new _(g(e,0,n),g(e,n,2*n))}static fromDER(e){let{r:t,s:n}=MS.toSig(Ux(`DER`,e));return new _(t,n)}assertValidity(){if(!f(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!f(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new _(this.r,this.s,e)}recoverPublicKey(e){let{r,s:i,recovery:a}=this,o=C(Ux(`msgHash`,e));if(a==null||![0,1,2,3].includes(a))throw Error(`recovery id invalid`);let u=a===2||a===3?r+t.n:r;if(u>=n.ORDER)throw Error(`recovery id 2 or 3 invalid`);let d=a&1?`03`:`02`,f=l.fromHex(d+p(u)),m=c(u),h=s(-o*m),g=s(i*m),_=l.BASE.multiplyAndAddUnsafe(f,h,g);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Lx(this.toDERHex())}toDERHex(){return MS.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Lx(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let v={isValidPrivateKey(e){try{return u(e),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let e=CS(t.n);return wS(t.randomBytes(e),t.n)},precompute(e=8,t=l.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)}function b(e){let t=e instanceof Uint8Array,n=typeof e==`string`,r=(t||n)&&e.length;return t?r===i||r===a:n?r===2*i||r===2*a:e instanceof l}function x(e,t,n=!0){if(b(e))throw Error(`first arg must be private key`);if(!b(t))throw Error(`second arg must be public key`);return l.fromHex(t).multiply(u(e)).toRawBytes(n)}let S=t.bits2int||function(e){let n=Rx(e),r=e.length*8-t.nBitLength;return r>0?n>>BigInt(r):n},C=t.bits2int_modN||function(e){return s(S(e))},w=Xx(t.nBitLength);function T(e){if(typeof e!=`bigint`)throw Error(`bigint expected`);if(!(NS<=e&&e<w))throw Error(`bigint expected < 2^${t.nBitLength}`);return Bx(e,t.nByteLength)}function E(e,r,i=D){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{hash:a,randomBytes:o}=t,{lowS:d,prehash:p,extraEntropy:g}=i;d??=!0,e=Ux(`msgHash`,e),p&&(e=Ux(`prehashed msgHash`,a(e)));let v=C(e),y=u(r),b=[T(y),T(v)];if(g!=null){let e=g===!0?o(n.BYTES):g;b.push(Ux(`extraEntropy`,e))}let x=Wx(...b),w=v;function E(e){let t=S(e);if(!f(t))return;let n=c(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===NS)return;let a=s(n*s(w+i*y));if(a===NS)return;let o=(r.x===i?0:2)|Number(r.y&PS),u=a;return d&&m(a)&&(u=h(a),o^=1),new _(i,u,o)}return{seed:x,k2sig:E}}let D={lowS:t.lowS,prehash:!1},O={lowS:t.lowS,prehash:!1};function k(e,n,r=D){let{seed:i,k2sig:a}=E(e,n,r),o=t;return $x(o.hash.outputLen,o.nByteLength,o.hmac)(i,a)}l.BASE._setWindowSize(8);function ee(e,n,r,i=O){let a=e;if(n=Ux(`msgHash`,n),r=Ux(`publicKey`,r),`strict`in i)throw Error(`options.strict was renamed to lowS`);let{lowS:o,prehash:u}=i,d,f;try{if(typeof a==`string`||a instanceof Uint8Array)try{d=_.fromDER(a)}catch(e){if(!(e instanceof MS.Err))throw e;d=_.fromCompact(a)}else if(typeof a==`object`&&typeof a.r==`bigint`&&typeof a.s==`bigint`){let{r:e,s:t}=a;d=new _(e,t)}else throw Error(`PARSE`);f=l.fromHex(r)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(o&&d.hasHighS())return!1;u&&(n=t.hash(n));let{r:p,s:m}=d,h=C(n),g=c(m),v=s(h*g),y=s(p*g),b=l.BASE.multiplyAndAddUnsafe(f,v,y)?.toAffine();return b?s(b.x)===p:!1}return{CURVE:t,getPublicKey:y,getSharedSecret:x,sign:k,verify:ee,ProjectivePoint:l,Signature:_,utils:v}}function VS(e,t){let n=e.ORDER,r=NS;for(let e=n-PS;e%FS===NS;e/=FS)r+=PS;let i=r,a=FS<<i-PS-PS,o=a*FS,s=(n-PS)/o,c=(s-PS)/FS,l=o-PS,u=a,d=e.pow(t,s),f=e.pow(t,(s+PS)/FS),p=(t,n)=>{let r=d,a=e.pow(n,l),o=e.sqr(a);o=e.mul(o,n);let s=e.mul(t,o);s=e.pow(s,c),s=e.mul(s,a),a=e.mul(s,n),o=e.mul(s,t);let p=e.mul(o,a);s=e.pow(p,u);let m=e.eql(s,e.ONE);a=e.mul(o,f),s=e.mul(p,r),o=e.cmov(a,o,m),p=e.cmov(s,p,m);for(let t=i;t>PS;t--){let n=t-FS;n=FS<<n-PS;let i=e.pow(p,n),s=e.eql(i,e.ONE);a=e.mul(o,r),r=e.mul(r,r),i=e.mul(p,r),o=e.cmov(a,o,s),p=e.cmov(i,p,s)}return{isValid:m,value:o}};if(e.ORDER%LS===IS){let n=(e.ORDER-IS)/LS,r=e.sqrt(e.neg(t));p=(t,i)=>{let a=e.sqr(i),o=e.mul(t,i);a=e.mul(a,o);let s=e.pow(a,n);s=e.mul(s,o);let c=e.mul(s,r),l=e.mul(e.sqr(s),i),u=e.eql(l,t);return{isValid:u,value:e.cmov(c,s,u)}}}return p}function HS(e,t){if(_S(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw Error(`mapToCurveSimpleSWU: invalid opts`);let n=VS(e,t.Z);if(!e.isOdd)throw Error(`Fp.isOdd is not implemented!`);return r=>{let i,a,o,s,c,l,u,d;i=e.sqr(r),i=e.mul(i,t.Z),a=e.sqr(i),a=e.add(a,i),o=e.add(a,e.ONE),o=e.mul(o,t.B),s=e.cmov(t.Z,e.neg(a),!e.eql(a,e.ZERO)),s=e.mul(s,t.A),a=e.sqr(o),l=e.sqr(s),c=e.mul(l,t.A),a=e.add(a,c),a=e.mul(a,o),l=e.mul(l,s),c=e.mul(l,t.B),a=e.add(a,c),u=e.mul(i,o);let{isValid:f,value:p}=n(a,l);d=e.mul(i,r),d=e.mul(d,p),u=e.cmov(u,o,f),d=e.cmov(d,p,f);let m=e.isOdd(r)===e.isOdd(d);return d=e.cmov(e.neg(d),d,m),u=e.div(u,s),{x:u,y:d}}}function US(e){if(e instanceof Uint8Array)return e;if(typeof e==`string`)return Kx(e);throw Error(`DST must be Uint8Array or string`)}var WS=Rx;function GS(e,t){if(e<0||e>=1<<8*t)throw Error(`bad I2OSP call: value=${e} length=${t}`);let n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function KS(e,t){let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function qS(e){if(!(e instanceof Uint8Array))throw Error(`Uint8Array expected`)}function JS(e){if(!Number.isSafeInteger(e))throw Error(`number expected`)}function YS(e,t,n,r){qS(e),qS(t),JS(n),t.length>255&&(t=r(Wx(Kx(`H2C-OVERSIZE-DST-`),t)));let{outputLen:i,blockLen:a}=r,o=Math.ceil(n/i);if(o>255)throw Error(`Invalid xmd length`);let s=Wx(t,GS(t.length,1)),c=GS(0,a),l=GS(n,2),u=Array(o),d=r(Wx(c,e,l,GS(0,1),s));u[0]=r(Wx(d,GS(1,1),s));for(let e=1;e<=o;e++)u[e]=r(Wx(KS(d,u[e-1]),GS(e+1,1),s));return Wx(...u).slice(0,n)}function XS(e,t,n,r,i){if(qS(e),qS(t),JS(n),t.length>255){let e=Math.ceil(2*r/8);t=i.create({dkLen:e}).update(Kx(`H2C-OVERSIZE-DST-`)).update(t).digest()}if(n>65535||t.length>255)throw Error(`expand_message_xof: invalid lenInBytes`);return i.create({dkLen:n}).update(e).update(GS(n,2)).update(t).update(GS(t.length,1)).digest()}function ZS(e,t,n){tS(n,{DST:`stringOrUint8Array`,p:`bigint`,m:`isSafeInteger`,k:`isSafeInteger`,hash:`hash`});let{p:r,k:i,m:a,hash:o,expand:s,DST:c}=n;qS(e),JS(t);let l=US(c),u=r.toString(2).length,d=Math.ceil((u+i)/8),f=t*a*d,p;if(s===`xmd`)p=YS(e,l,f,o);else if(s===`xof`)p=XS(e,l,f,i,o);else if(s===`_internal_pass`)p=e;else throw Error(`expand must be "xmd" or "xof"`);let m=Array(t);for(let e=0;e<t;e++){let t=Array(a);for(let n=0;n<a;n++){let i=d*(n+e*a);t[n]=uS(WS(p.subarray(i,i+d)),r)}m[e]=t}return m}function QS(e,t){let n=t.map(e=>Array.from(e).reverse());return(t,r)=>{let[i,a,o,s]=n.map(n=>n.reduce((n,r)=>e.add(e.mul(n,t),r)));return t=e.div(i,a),r=e.mul(r,e.div(o,s)),{x:t,y:r}}}function $S(e,t,n){if(typeof t!=`function`)throw Error(`mapToCurve() must be defined`);return{hashToCurve(r,i){let a=ZS(r,2,{...n,DST:n.DST,...i}),o=e.fromAffine(t(a[0])),s=e.fromAffine(t(a[1])),c=o.add(s).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){let a=ZS(r,1,{...n,DST:n.encodeDST,...i}),o=e.fromAffine(t(a[0])).clearCofactor();return o.assertValidity(),o}}}function eC(e){return{hash:e,hmac:(t,...n)=>_b(e,t,fb(...n)),randomBytes:hb}}function tC(e,t){let n=t=>BS({...e,...eC(t)});return Object.freeze({...n(t),create:n})}var nC=BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),rC=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),iC=BigInt(1),aC=BigInt(2),oC=(e,t)=>(e+t/aC)/t;function sC(e){let t=nC,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=fS(fS(fS(u,n,t)*u%t,n,t)*u%t,aC,t)*l%t,f=fS(d,i,t)*d%t,p=fS(f,a,t)*f%t,m=fS(p,s,t)*p%t,h=fS(fS(fS(fS(fS(fS(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,aC,t);if(!cC.eql(cC.sqr(h),e))throw Error(`Cannot find square root`);return h}var cC=xS(nC,void 0,void 0,{sqrt:sC}),lC=tC({a:BigInt(0),b:BigInt(7),Fp:cC,n:rC,Gx:BigInt(`55066263022277343669578718895168534326250603453777594175500187360389116729240`),Gy:BigInt(`32670510020758816978083085130507043184471273380659243275938904335757337482424`),h:BigInt(1),lowS:!0,endo:{beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),splitScalar:e=>{let t=rC,n=BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),r=-iC*BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`),i=BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),a=n,o=BigInt(`0x100000000000000000000000000000000`),s=oC(a*e,t),c=oC(-r*e,t),l=uS(e-s*n-c*i,t),u=uS(-s*r-c*a,t),d=l>o,f=u>o;if(d&&(l=t-l),f&&(u=t-u),l>o||u>o)throw Error(`splitScalar: Endomorphism failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},Eb);lC.ProjectivePoint,lC.utils.randomPrivateKey;var uC=QS(cC,[[`0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7`,`0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581`,`0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262`,`0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c`],[`0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b`,`0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14`,`0x0000000000000000000000000000000000000000000000000000000000000001`],[`0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c`,`0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3`,`0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931`,`0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84`],[`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b`,`0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573`,`0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f`,`0x0000000000000000000000000000000000000000000000000000000000000001`]].map(e=>e.map(e=>BigInt(e)))),dC=HS(cC,{A:BigInt(`0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533`),B:BigInt(`1771`),Z:cC.create(BigInt(`-11`))}),fC=$S(lC.ProjectivePoint,e=>{let{x:t,y:n}=dC(cC.create(e[0]));return uC(t,n)},{DST:`secp256k1_XMD:SHA-256_SSWU_RO_`,encodeDST:`secp256k1_XMD:SHA-256_SSWU_NU_`,p:cC.ORDER,m:1,k:128,expand:`xmd`,hash:Eb});fC.hashToCurve,fC.encodeToCurve;var pC=`0x0000000000000000000000000000000000000000`,mC=`0x0000000000000000000000000000000000000000000000000000000000000000`,hC=BigInt(0),gC=BigInt(1),_C=BigInt(2),vC=BigInt(27),yC=BigInt(28),bC=BigInt(35),xC=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),SC=xC/_C,CC=Symbol.for(`nodejs.util.inspect.custom`),wC={};function TC(e){return zv(Qv(e),32)}var EC=class e{#e;#t;#n;#r;get r(){return this.#e}set r(e){q(Iv(e)===32,`invalid r`,`value`,e),this.#e=Y(e)}get s(){return q(parseInt(this.#t.substring(0,3))<8,`non-canonical s; use ._s`,`s`,this.#t),this.#t}set s(e){q(Iv(e)===32,`invalid s`,`value`,e),this.#t=Y(e)}get _s(){return this.#t}isValid(){return BigInt(this.#t)<=SC}get v(){return this.#n}set v(e){let t=Z(e,`value`);q(t===27||t===28,`invalid v`,`v`,e),this.#n=t}get networkV(){return this.#r}get legacyChainId(){let t=this.networkV;return t==null?null:e.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){let e=J(this.s);return this.yParity&&(e[0]|=128),Y(e)}get compactSerialized(){return Fv([this.r,this.yParityAndS])}get serialized(){return Fv([this.r,this.s,this.yParity?`0x1c`:`0x1b`])}constructor(e,t,n,r){kv(e,wC,`Signature`),this.#e=t,this.#t=n,this.#n=r,this.#r=null}getCanonical(){if(this.isValid())return this;let t=xC-BigInt(this._s),n=55-this.v,r=new e(wC,this.r,TC(t),n);return this.networkV&&(r.#r=this.networkV),r}clone(){let t=new e(wC,this.r,this._s,this.v);return this.networkV&&(t.#r=this.networkV),t}toJSON(){let e=this.networkV;return{_type:`signature`,networkV:e==null?null:e.toString(),r:this.r,s:this._s,v:this.v}}[CC](){return this.toString()}toString(){return this.isValid()?`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v} }`:`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v}, valid: false }`}static getChainId(e){let t=X(e,`v`);return t==vC||t==yC?hC:(q(t>=bC,`invalid EIP-155 v`,`v`,e),(t-bC)/_C)}static getChainIdV(e,t){return X(e)*_C+BigInt(35+t-27)}static getNormalizedV(e){let t=X(e);return t===hC||t===vC?27:t===gC||t===yC?28:(q(t>=bC,`invalid v`,`v`,e),t&gC?27:28)}static from(t){function n(e,n){q(e,n,`signature`,t)}if(t==null)return new e(wC,mC,mC,27);if(typeof t==`string`){let r=J(t,`signature`);if(r.length===64){let t=Y(r.slice(0,32)),n=r.slice(32,64),i=n[0]&128?28:27;return n[0]&=127,new e(wC,t,Y(n),i)}if(r.length===65)return new e(wC,Y(r.slice(0,32)),Y(r.slice(32,64)),e.getNormalizedV(r[64]));n(!1,`invalid raw signature length`)}if(t instanceof e)return t.clone();let r=t.r;n(r!=null,`missing r`);let i=TC(r),a=(function(e,t){if(e!=null)return TC(e);if(t!=null){n(Mv(t,32),`invalid yParityAndS`);let e=J(t);return e[0]&=127,Y(e)}n(!1,`missing s`)})(t.s,t.yParityAndS),{networkV:o,v:s}=(function(t,r,i){if(t!=null){let n=X(t);return{networkV:n>=bC?n:void 0,v:e.getNormalizedV(n)}}if(r!=null)return n(Mv(r,32),`invalid yParityAndS`),{v:J(r)[0]&128?28:27};if(i!=null){switch(Z(i,`sig.yParity`)){case 0:return{v:27};case 1:return{v:28}}n(!1,`invalid yParity`)}n(!1,`missing v`)})(t.v,t.yParityAndS,t.yParity),c=new e(wC,i,a,s);return o&&(c.#r=o),n(t.yParity==null||Z(t.yParity,`sig.yParity`)===c.yParity,`yParity mismatch`),n(t.yParityAndS==null||t.yParityAndS===c.yParityAndS,`yParityAndS mismatch`),c}},DC=class e{#e;constructor(e){q(Iv(e)===32,`invalid private key`,`privateKey`,`[REDACTED]`),this.#e=Y(e)}get privateKey(){return this.#e}get publicKey(){return e.computePublicKey(this.#e)}get compressedPublicKey(){return e.computePublicKey(this.#e,!0)}sign(e){q(Iv(e)===32,`invalid digest length`,`digest`,e);let t=lC.sign(jv(e),jv(this.#e),{lowS:!0});return EC.from({r:Zv(t.r,32),s:Zv(t.s,32),v:t.recovery?28:27})}computeSharedSecret(t){let n=e.computePublicKey(t);return Y(lC.getSharedSecret(jv(this.#e),J(n),!1))}static computePublicKey(e,t){let n=J(e,`key`);if(n.length===32)return Y(lC.getPublicKey(n,!!t));if(n.length===64){let e=new Uint8Array(65);e[0]=4,e.set(n,1),n=e}return Y(lC.ProjectivePoint.fromHex(n).toRawBytes(t))}static recoverPublicKey(e,t){q(Iv(e)===32,`invalid digest length`,`digest`,e);let n=EC.from(t),r=lC.Signature.fromCompact(jv(Fv([n.r,n.s])));r=r.addRecoveryBit(n.yParity);let i=r.recoverPublicKey(jv(e));return q(i!=null,`invalid signature for digest`,`signature`,t),`0x`+i.toHex(!1)}static addPoints(t,n,r){let i=lC.ProjectivePoint.fromHex(e.computePublicKey(t).substring(2)),a=lC.ProjectivePoint.fromHex(e.computePublicKey(n).substring(2));return`0x`+i.add(a).toHex(!!r)}},OC=BigInt(0),kC=BigInt(36);function AC(e){e=e.toLowerCase();let t=e.substring(2).split(``),n=new Uint8Array(40);for(let e=0;e<40;e++)n[e]=t[e].charCodeAt(0);let r=J(yx(n));for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&(t[e]=t[e].toUpperCase()),(r[e>>1]&15)>=8&&(t[e+1]=t[e+1].toUpperCase());return`0x`+t.join(``)}var jC={};for(let e=0;e<10;e++)jC[String(e)]=String(e);for(let e=0;e<26;e++)jC[String.fromCharCode(65+e)]=String(10+e);var MC=15;function NC(e){e=e.toUpperCase(),e=e.substring(4)+e.substring(0,2)+`00`;let t=e.split(``).map(e=>jC[e]).join(``);for(;t.length>=MC;){let e=t.substring(0,MC);t=parseInt(e,10)%97+t.substring(e.length)}let n=String(98-parseInt(t,10)%97);for(;n.length<2;)n=`0`+n;return n}var PC=(function(){let e={};for(let t=0;t<36;t++){let n=`0123456789abcdefghijklmnopqrstuvwxyz`[t];e[n]=BigInt(t)}return e})();function FC(e){e=e.toLowerCase();let t=OC;for(let n=0;n<e.length;n++)t=t*kC+PC[e[n]];return t}function IC(e){if(q(typeof e==`string`,`invalid address`,`address`,e),e.match(/^(0x)?[0-9a-fA-F]{40}$/)){e.startsWith(`0x`)||(e=`0x`+e);let t=AC(e);return q(!e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===e,`bad address checksum`,`address`,e),t}if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){q(e.substring(2,4)===NC(e),`bad icap checksum`,`address`,e);let t=FC(e.substring(4)).toString(16);for(;t.length<40;)t=`0`+t;return AC(`0x`+t)}q(!1,`invalid address`,`address`,e)}function LC(e){let t=IC(e.from),n=X(e.nonce,`tx.nonce`).toString(16);return n=n===`0`?`0x`:n.length%2?`0x0`+n:`0x`+n,IC(Lv(yx(By([t,n])),12))}function RC(e){return e&&typeof e.getAddress==`function`}async function zC(e,t){let n=await t;return(n==null||n===`0x0000000000000000000000000000000000000000`)&&(K(typeof e!=`string`,`unconfigured name`,`UNCONFIGURED_NAME`,{value:e}),q(!1,`invalid AddressLike value; did not resolve to a value address`,`target`,e)),IC(n)}function BC(e,t){if(typeof e==`string`)return e.match(/^0x[0-9a-f]{40}$/i)?IC(e):(K(t!=null,`ENS resolution requires a provider`,`UNSUPPORTED_OPERATION`,{operation:`resolveName`}),zC(e,t.resolveName(e)));if(RC(e))return zC(e,e.getAddress());if(e&&typeof e.then==`function`)return zC(e,e);q(!1,`unsupported addressable value`,`target`,e)}var VC={};function $(e,t){let n=!1;return t<0&&(n=!0,t*=-1),new WC(VC,`${n?``:`u`}int${t}`,e,{signed:n,width:t})}function HC(e,t){return new WC(VC,`bytes${t||``}`,e,{size:t})}var UC=Symbol.for(`_ethers_typed`),WC=class e{type;value;#e;_typedSymbol;constructor(e,t,n,r){r??=null,kv(VC,e,`Typed`),G(this,{_typedSymbol:UC,type:t,value:n}),this.#e=r,this.format()}format(){if(this.type===`array`||this.type===`dynamicArray`)throw Error(``);return this.type===`tuple`?`tuple(${this.value.map(e=>e.format()).join(`,`)})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith(`bytes`)}isString(){return this.type===`string`}get tupleName(){if(this.type!==`tuple`)throw TypeError(`not a tuple`);return this.#e}get arrayLength(){if(this.type!==`array`)throw TypeError(`not an array`);return this.#e===!0?-1:this.#e===!1?this.value.length:null}static from(t,n){return new e(VC,t,n)}static uint8(e){return $(e,8)}static uint16(e){return $(e,16)}static uint24(e){return $(e,24)}static uint32(e){return $(e,32)}static uint40(e){return $(e,40)}static uint48(e){return $(e,48)}static uint56(e){return $(e,56)}static uint64(e){return $(e,64)}static uint72(e){return $(e,72)}static uint80(e){return $(e,80)}static uint88(e){return $(e,88)}static uint96(e){return $(e,96)}static uint104(e){return $(e,104)}static uint112(e){return $(e,112)}static uint120(e){return $(e,120)}static uint128(e){return $(e,128)}static uint136(e){return $(e,136)}static uint144(e){return $(e,144)}static uint152(e){return $(e,152)}static uint160(e){return $(e,160)}static uint168(e){return $(e,168)}static uint176(e){return $(e,176)}static uint184(e){return $(e,184)}static uint192(e){return $(e,192)}static uint200(e){return $(e,200)}static uint208(e){return $(e,208)}static uint216(e){return $(e,216)}static uint224(e){return $(e,224)}static uint232(e){return $(e,232)}static uint240(e){return $(e,240)}static uint248(e){return $(e,248)}static uint256(e){return $(e,256)}static uint(e){return $(e,256)}static int8(e){return $(e,-8)}static int16(e){return $(e,-16)}static int24(e){return $(e,-24)}static int32(e){return $(e,-32)}static int40(e){return $(e,-40)}static int48(e){return $(e,-48)}static int56(e){return $(e,-56)}static int64(e){return $(e,-64)}static int72(e){return $(e,-72)}static int80(e){return $(e,-80)}static int88(e){return $(e,-88)}static int96(e){return $(e,-96)}static int104(e){return $(e,-104)}static int112(e){return $(e,-112)}static int120(e){return $(e,-120)}static int128(e){return $(e,-128)}static int136(e){return $(e,-136)}static int144(e){return $(e,-144)}static int152(e){return $(e,-152)}static int160(e){return $(e,-160)}static int168(e){return $(e,-168)}static int176(e){return $(e,-176)}static int184(e){return $(e,-184)}static int192(e){return $(e,-192)}static int200(e){return $(e,-200)}static int208(e){return $(e,-208)}static int216(e){return $(e,-216)}static int224(e){return $(e,-224)}static int232(e){return $(e,-232)}static int240(e){return $(e,-240)}static int248(e){return $(e,-248)}static int256(e){return $(e,-256)}static int(e){return $(e,-256)}static bytes1(e){return HC(e,1)}static bytes2(e){return HC(e,2)}static bytes3(e){return HC(e,3)}static bytes4(e){return HC(e,4)}static bytes5(e){return HC(e,5)}static bytes6(e){return HC(e,6)}static bytes7(e){return HC(e,7)}static bytes8(e){return HC(e,8)}static bytes9(e){return HC(e,9)}static bytes10(e){return HC(e,10)}static bytes11(e){return HC(e,11)}static bytes12(e){return HC(e,12)}static bytes13(e){return HC(e,13)}static bytes14(e){return HC(e,14)}static bytes15(e){return HC(e,15)}static bytes16(e){return HC(e,16)}static bytes17(e){return HC(e,17)}static bytes18(e){return HC(e,18)}static bytes19(e){return HC(e,19)}static bytes20(e){return HC(e,20)}static bytes21(e){return HC(e,21)}static bytes22(e){return HC(e,22)}static bytes23(e){return HC(e,23)}static bytes24(e){return HC(e,24)}static bytes25(e){return HC(e,25)}static bytes26(e){return HC(e,26)}static bytes27(e){return HC(e,27)}static bytes28(e){return HC(e,28)}static bytes29(e){return HC(e,29)}static bytes30(e){return HC(e,30)}static bytes31(e){return HC(e,31)}static bytes32(e){return HC(e,32)}static address(t){return new e(VC,`address`,t)}static bool(t){return new e(VC,`bool`,!!t)}static bytes(t){return new e(VC,`bytes`,t)}static string(t){return new e(VC,`string`,t)}static array(e,t){throw Error(`not implemented yet`)}static tuple(e,t){throw Error(`not implemented yet`)}static overrides(t){return new e(VC,`overrides`,Object.assign({},t))}static isTyped(e){return e&&typeof e==`object`&&`_typedSymbol`in e&&e._typedSymbol===UC}static dereference(t,n){if(e.isTyped(t)){if(t.type!==n)throw Error(`invalid type: expecetd ${n}, got ${t.type}`);return t.value}return t}},GC=class extends Zy{constructor(e){super(`address`,`address`,e,!1)}defaultValue(){return`0x0000000000000000000000000000000000000000`}encode(e,t){let n=WC.dereference(t,`string`);try{n=IC(n)}catch(e){return this._throwError(e.message,t)}return e.writeValue(n)}decode(e){return IC(Zv(e.readValue(),20))}},KC=class extends Zy{coder;constructor(e){super(e.name,e.type,`_`,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}};function qC(e,t,n){let r=[];if(Array.isArray(n))r=n;else if(n&&typeof n==`object`){let e={};r=t.map(t=>{let r=t.localName;return K(r,`cannot encode object for signature with missing names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),K(!e[r],`cannot encode object for signature with duplicate names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),e[r]=!0,n[r]})}else q(!1,`invalid tuple value`,`tuple`,n);q(t.length===r.length,`types/value length mismatch`,`tuple`,n);let i=new Qy,a=new Qy,o=[];t.forEach((e,t)=>{let n=r[t];if(e.dynamic){let t=a.length;e.encode(a,n);let r=i.writeUpdatableValue();o.push(e=>{r(e+t)})}else e.encode(i,n)}),o.forEach(e=>{e(i.length)});let s=e.appendWriter(i);return s+=e.appendWriter(a),s}function JC(e,t){let n=[],r=[],i=e.subReader(0);return t.forEach(t=>{let a=null;if(t.dynamic){let n=e.readIndex(),r=i.subReader(n);try{a=t.decode(r)}catch(e){if(Cv(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}}else try{a=t.decode(e)}catch(e){if(Cv(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}if(a==null)throw Error(`investigate`);n.push(a),r.push(t.localName||null)}),Yy.fromItems(n,r)}var YC=class extends Zy{coder;length;constructor(e,t,n){let r=e.type+`[`+(t>=0?t:``)+`]`,i=t===-1||e.dynamic;super(`array`,r,n,i),G(this,{coder:e,length:t})}defaultValue(){let e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){let n=WC.dereference(t,`array`);Array.isArray(n)||this._throwError(`expected array value`,n);let r=this.length;r===-1&&(r=n.length,e.writeValue(n.length)),Ev(n.length,r,`coder array`+(this.localName?` `+this.localName:``));let i=[];for(let e=0;e<n.length;e++)i.push(this.coder);return qC(e,i,n)}decode(e){let t=this.length;t===-1&&(t=e.readIndex(),K(t*32<=e.dataLength,`insufficient data length`,`BUFFER_OVERRUN`,{buffer:e.bytes,offset:t*32,length:e.dataLength}));let n=[];for(let e=0;e<t;e++)n.push(new KC(this.coder));return JC(e,n)}},XC=class extends Zy{constructor(e){super(`bool`,`bool`,e,!1)}defaultValue(){return!1}encode(e,t){let n=WC.dereference(t,`bool`);return e.writeValue(+!!n)}decode(e){return!!e.readValue()}},ZC=class extends Zy{constructor(e,t){super(e,e,t,!0)}defaultValue(){return`0x`}encode(e,t){t=jv(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}},QC=class extends ZC{constructor(e){super(`bytes`,e)}decode(e){return Y(super.decode(e))}},$C=class extends Zy{size;constructor(e,t){let n=`bytes`+String(e);super(n,n,t,!1),G(this,{size:e},{size:`number`})}defaultValue(){return`0x0000000000000000000000000000000000000000000000000000000000000000`.substring(0,2+this.size*2)}encode(e,t){let n=jv(WC.dereference(t,this.type));return n.length!==this.size&&this._throwError(`incorrect data length`,t),e.writeBytes(n)}decode(e){return Y(e.readBytes(this.size))}},ew=new Uint8Array([]),tw=class extends Zy{constructor(e){super(`null`,``,e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError(`not null`,t),e.writeBytes(ew)}decode(e){return e.readBytes(0),null}},nw=BigInt(0),rw=BigInt(1),iw=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),aw=class extends Zy{size;signed;constructor(e,t,n){let r=(t?`int`:`uint`)+e*8;super(r,r,n,!1),G(this,{size:e,signed:t},{size:`number`,signed:`boolean`})}defaultValue(){return 0}encode(e,t){let n=X(WC.dereference(t,this.type)),r=Kv(iw,256);if(this.signed){let e=Kv(r,this.size*8-1);(n>e||n<-(e+rw))&&this._throwError(`value out-of-bounds`,t),n=Gv(n,256)}else (n<nw||n>Kv(r,this.size*8))&&this._throwError(`value out-of-bounds`,t);return e.writeValue(n)}decode(e){let t=Kv(e.readValue(),this.size*8);return this.signed&&(t=Wv(t,this.size*8)),t}},ow=class extends ZC{constructor(e){super(`string`,e)}defaultValue(){return``}encode(e,t){return super.encode(e,dy(WC.dereference(t,`string`)))}decode(e){return py(super.decode(e))}},sw=class extends Zy{coders;constructor(e,t){let n=!1,r=[];e.forEach(e=>{e.dynamic&&(n=!0),r.push(e.type)});let i=`tuple(`+r.join(`,`)+`)`;super(`tuple`,i,t,n),G(this,{coders:Object.freeze(e.slice())})}defaultValue(){let e=[];this.coders.forEach(t=>{e.push(t.defaultValue())});let t=this.coders.reduce((e,t)=>{let n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e},{});return this.coders.forEach((n,r)=>{let i=n.localName;!i||t[i]!==1||(i===`length`&&(i=`_length`),e[i]??(e[i]=e[r]))}),Object.freeze(e)}encode(e,t){let n=WC.dereference(t,`tuple`);return qC(e,this.coders,n)}decode(e){return JC(e,this.coders)}};function cw(e,t){return{address:IC(e),storageKeys:t.map((e,t)=>(q(Mv(e,32),`invalid slot`,`storageKeys[${t}]`,e),e.toLowerCase()))}}function lw(e){if(Array.isArray(e))return e.map((t,n)=>Array.isArray(t)?(q(t.length===2,`invalid slot set`,`value[${n}]`,t),cw(t[0],t[1])):(q(typeof t==`object`&&!!t,`invalid address-slot set`,`value`,e),cw(t.address,t.storageKeys)));q(typeof e==`object`&&!!e,`invalid access list`,`value`,e);let t=Object.keys(e).map(t=>{let n=e[t].reduce((e,t)=>(e[t]=!0,e),{});return cw(t,Object.keys(n).sort())});return t.sort((e,t)=>e.address.localeCompare(t.address)),t}function uw(e){return{address:IC(e.address),nonce:X(e.nonce==null?0:e.nonce),chainId:X(e.chainId==null?0:e.chainId),signature:EC.from(e.signature)}}function dw(e){let t;return t=typeof e==`string`?DC.computePublicKey(e,!1):e.publicKey,IC(yx(`0x`+t.substring(4)).substring(26))}function fw(e,t){return dw(DC.recoverPublicKey(e,t))}var pw=BigInt(0),mw=BigInt(2),hw=BigInt(27),gw=BigInt(28),_w=BigInt(35),vw=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),yw=Symbol.for(`nodejs.util.inspect.custom`),bw=4096*32,xw=128;function Sw(e){return{blobToKzgCommitment:t=>{if(`computeBlobProof`in e){if(`blobToKzgCommitment`in e&&typeof e.blobToKzgCommitment==`function`)return J(e.blobToKzgCommitment(Y(t)))}else if(`blobToKzgCommitment`in e&&typeof e.blobToKzgCommitment==`function`)return J(e.blobToKzgCommitment(t));if(`blobToKZGCommitment`in e&&typeof e.blobToKZGCommitment==`function`)return J(e.blobToKZGCommitment(Y(t)));q(!1,`unsupported KZG library`,`kzg`,e)},computeBlobKzgProof:(t,n)=>{if(`computeBlobProof`in e&&typeof e.computeBlobProof==`function`)return J(e.computeBlobProof(Y(t),Y(n)));if(`computeBlobKzgProof`in e&&typeof e.computeBlobKzgProof==`function`)return e.computeBlobKzgProof(t,n);if(`computeBlobKZGProof`in e&&typeof e.computeBlobKZGProof==`function`)return J(e.computeBlobKZGProof(Y(t),Y(n)));q(!1,`unsupported KZG library`,`kzg`,e)}}}function Cw(e,t){let n=e.toString(16);for(;n.length<2;)n=`0`+n;return n+=Ex(t).substring(4),`0x`+n}function ww(e){return e===`0x`?null:IC(e)}function Tw(e,t){try{return lw(e)}catch(n){q(!1,n.message,t,e)}}function Ew(e,t){try{if(!Array.isArray(e))throw Error(`authorizationList: invalid array`);let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(!Array.isArray(r))throw Error(`authorization[${n}]: invalid array`);if(r.length!==6)throw Error(`authorization[${n}]: wrong length`);if(!r[1])throw Error(`authorization[${n}]: null address`);t.push({address:ww(r[1]),nonce:Ow(r[2],`nonce`),chainId:Ow(r[0],`chainId`),signature:EC.from({yParity:Dw(r[3],`yParity`),r:zv(r[4],32),s:zv(r[5],32)})})}return t}catch(n){q(!1,n.message,t,e)}}function Dw(e,t){return e===`0x`?0:Z(e,t)}function Ow(e,t){if(e===`0x`)return pw;let n=X(e,t);return q(n<=vw,`value exceeds uint size`,t,n),n}function kw(e,t){let n=X(e,`value`),r=Qv(n);return q(r.length<=32,`value too large`,`tx.${t}`,n),r}function Aw(e){return lw(e).map(e=>[e.address,e.storageKeys])}function jw(e){return e.map(e=>[kw(e.chainId,`chainId`),e.address,kw(e.nonce,`nonce`),kw(e.signature.yParity,`yParity`),Qv(e.signature.r),Qv(e.signature._s)])}function Mw(e,t){q(Array.isArray(e),`invalid ${t}`,`value`,e);for(let t=0;t<e.length;t++)q(Mv(e[t],32),"invalid ${ param } hash",`value[${t}]`,e[t]);return e}function Nw(e){let t=Iy(e);q(Array.isArray(t)&&(t.length===9||t.length===6),`invalid field count for legacy transaction`,`data`,e);let n={type:0,nonce:Dw(t[0],`nonce`),gasPrice:Ow(t[1],`gasPrice`),gasLimit:Ow(t[2],`gasLimit`),to:ww(t[3]),value:Ow(t[4],`value`),data:Y(t[5]),chainId:pw};if(t.length===6)return n;let r=Ow(t[6],`v`),i=Ow(t[7],`r`),a=Ow(t[8],`s`);if(i===pw&&a===pw)n.chainId=r;else{let e=(r-_w)/mw;e<pw&&(e=pw),n.chainId=e,q(e!==pw||r===hw||r===gw,`non-canonical legacy v`,`v`,t[6]),n.signature=EC.from({r:zv(t[7],32),s:zv(t[8],32),v:r})}return n}function Pw(e,t){let n=[kw(e.nonce,`nonce`),kw(e.gasPrice||0,`gasPrice`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data],r=pw;if(e.chainId!=pw)r=X(e.chainId,`tx.chainId`),q(!t||t.networkV==null||t.legacyChainId===r,`tx.chainId/sig.v mismatch`,`sig`,t);else if(e.signature){let t=e.signature.legacyChainId;t!=null&&(r=t)}if(!t)return r!==pw&&(n.push(Qv(r)),n.push(`0x`),n.push(`0x`)),By(n);let i=BigInt(27+t.yParity);return r===pw?BigInt(t.v)!==i&&q(!1,`tx.chainId/sig.v mismatch`,`sig`,t):i=EC.getChainIdV(r,t.v),n.push(Qv(i)),n.push(Qv(t.r)),n.push(Qv(t._s)),By(n)}function Fw(e,t){let n;try{if(n=Dw(t[0],`yParity`),n!==0&&n!==1)throw Error(`bad yParity`)}catch{q(!1,`invalid yParity`,`yParity`,t[0])}let r=zv(t[1],32),i=zv(t[2],32);e.signature=EC.from({r,s:i,yParity:n})}function Iw(e){let t=Iy(J(e).slice(1));q(Array.isArray(t)&&(t.length===9||t.length===12),`invalid field count for transaction type: 2`,`data`,Y(e));let n={type:2,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),maxPriorityFeePerGas:Ow(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ow(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ow(t[4],`gasLimit`),to:ww(t[5]),value:Ow(t[6],`value`),data:Y(t[7]),accessList:Tw(t[8],`accessList`)};return t.length===9||Fw(n,t.slice(9)),n}function Lw(e,t){let n=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),kw(e.maxFeePerGas||0,`maxFeePerGas`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data,Aw(e.accessList||[])];return t&&(n.push(kw(t.yParity,`yParity`)),n.push(Qv(t.r)),n.push(Qv(t.s))),Fv([`0x02`,By(n)])}function Rw(e){let t=Iy(J(e).slice(1));q(Array.isArray(t)&&(t.length===8||t.length===11),`invalid field count for transaction type: 1`,`data`,Y(e));let n={type:1,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),gasPrice:Ow(t[2],`gasPrice`),gasLimit:Ow(t[3],`gasLimit`),to:ww(t[4]),value:Ow(t[5],`value`),data:Y(t[6]),accessList:Tw(t[7],`accessList`)};return t.length===8||Fw(n,t.slice(8)),n}function zw(e,t){let n=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.gasPrice||0,`gasPrice`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data,Aw(e.accessList||[])];return t&&(n.push(kw(t.yParity,`recoveryParam`)),n.push(Qv(t.r)),n.push(Qv(t.s))),Fv([`0x01`,By(n)])}function Bw(e){let t=Iy(J(e).slice(1)),n=`3`,r=null,i=null;if(t.length===4&&Array.isArray(t[0])){n=`3 (network format)`;let e=t[1],r=t[2],a=t[3];q(Array.isArray(e),`invalid network format: blobs not an array`,`fields[1]`,e),q(Array.isArray(r),`invalid network format: commitments not an array`,`fields[2]`,r),q(Array.isArray(a),`invalid network format: proofs not an array`,`fields[3]`,a),q(e.length===r.length,`invalid network format: blobs/commitments length mismatch`,`fields`,t),q(e.length===a.length,`invalid network format: blobs/proofs length mismatch`,`fields`,t),i=[];for(let n=0;n<t[1].length;n++)i.push({data:e[n],commitment:r[n],proof:a[n]});t=t[0]}else if(t.length===5&&Array.isArray(t[0])){n=`3 (EIP-7594 network format)`,r=Z(t[1]);let e=t[2],a=t[3],o=t[4];q(r===1,`unsupported EIP-7594 network format version: ${r}`,`fields[1]`,r),q(Array.isArray(e),`invalid EIP-7594 network format: blobs not an array`,`fields[2]`,e),q(Array.isArray(a),`invalid EIP-7594 network format: commitments not an array`,`fields[3]`,a),q(Array.isArray(o),`invalid EIP-7594 network format: proofs not an array`,`fields[4]`,o),q(e.length===a.length,`invalid network format: blobs/commitments length mismatch`,`fields`,t),q(e.length*xw===o.length,`invalid network format: blobs/proofs length mismatch`,`fields`,t),i=[];for(let t=0;t<e.length;t++){let n=[];for(let e=0;e<xw;e++)n.push(o[t*xw+e]);i.push({data:e[t],commitment:a[t],proof:Fv(n)})}t=t[0]}q(Array.isArray(t)&&(t.length===11||t.length===14),`invalid field count for transaction type: ${n}`,`data`,Y(e));let a={type:3,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),maxPriorityFeePerGas:Ow(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ow(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ow(t[4],`gasLimit`),to:ww(t[5]),value:Ow(t[6],`value`),data:Y(t[7]),accessList:Tw(t[8],`accessList`),maxFeePerBlobGas:Ow(t[9],`maxFeePerBlobGas`),blobVersionedHashes:t[10],blobWrapperVersion:r};i&&(a.blobs=i),q(a.to!=null,`invalid address for transaction type: ${n}`,`data`,e),q(Array.isArray(a.blobVersionedHashes),`invalid blobVersionedHashes: must be an array`,`data`,e);for(let t=0;t<a.blobVersionedHashes.length;t++)q(Mv(a.blobVersionedHashes[t],32),`invalid blobVersionedHash at index ${t}: must be length 32`,`data`,e);return t.length===11||Fw(a,t.slice(11)),a}function Vw(e,t,n){let r=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),kw(e.maxFeePerGas||0,`maxFeePerGas`),kw(e.gasLimit,`gasLimit`),e.to||`0x0000000000000000000000000000000000000000`,kw(e.value,`value`),e.data,Aw(e.accessList||[]),kw(e.maxFeePerBlobGas||0,`maxFeePerBlobGas`),Mw(e.blobVersionedHashes||[],`blobVersionedHashes`)];if(t&&(r.push(kw(t.yParity,`yParity`)),r.push(Qv(t.r)),r.push(Qv(t.s)),n)){if(e.blobWrapperVersion!=null){let t=Qv(e.blobWrapperVersion),i=[];for(let{proof:e}of n){let t=J(e),n=t.length/xw;for(let e=0;e<t.length;e+=n)i.push(t.subarray(e,e+n))}return Fv([`0x03`,By([r,t,n.map(e=>e.data),n.map(e=>e.commitment),i])])}return Fv([`0x03`,By([r,n.map(e=>e.data),n.map(e=>e.commitment),n.map(e=>e.proof)])])}return Fv([`0x03`,By(r)])}function Hw(e){let t=Iy(J(e).slice(1));q(Array.isArray(t)&&(t.length===10||t.length===13),`invalid field count for transaction type: 4`,`data`,Y(e));let n={type:4,chainId:Ow(t[0],`chainId`),nonce:Dw(t[1],`nonce`),maxPriorityFeePerGas:Ow(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ow(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ow(t[4],`gasLimit`),to:ww(t[5]),value:Ow(t[6],`value`),data:Y(t[7]),accessList:Tw(t[8],`accessList`),authorizationList:Ew(t[9],`authorizationList`)};return t.length===10||Fw(n,t.slice(10)),n}function Uw(e,t){let n=[kw(e.chainId,`chainId`),kw(e.nonce,`nonce`),kw(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),kw(e.maxFeePerGas||0,`maxFeePerGas`),kw(e.gasLimit,`gasLimit`),e.to||`0x`,kw(e.value,`value`),e.data,Aw(e.accessList||[]),jw(e.authorizationList||[])];return t&&(n.push(kw(t.yParity,`yParity`)),n.push(Qv(t.r)),n.push(Qv(t.s))),Fv([`0x04`,By(n)])}var Ww=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;get type(){return this.#e}set type(e){switch(e){case null:this.#e=null;break;case 0:case`legacy`:this.#e=0;break;case 1:case`berlin`:case`eip-2930`:this.#e=1;break;case 2:case`london`:case`eip-1559`:this.#e=2;break;case 3:case`cancun`:case`eip-4844`:this.#e=3;break;case 4:case`pectra`:case`eip-7702`:this.#e=4;break;default:q(!1,`unsupported transaction type`,`type`,e)}}get typeName(){switch(this.type){case 0:return`legacy`;case 1:return`eip-2930`;case 2:return`eip-1559`;case 3:return`eip-4844`;case 4:return`eip-7702`}return null}get to(){let e=this.#t;return e==null&&this.type===3?pC:e}set to(e){this.#t=e==null?null:IC(e)}get nonce(){return this.#r}set nonce(e){this.#r=Z(e,`value`)}get gasLimit(){return this.#i}set gasLimit(e){this.#i=X(e)}get gasPrice(){let e=this.#a;return e==null&&(this.type===0||this.type===1)?pw:e}set gasPrice(e){this.#a=e==null?null:X(e,`gasPrice`)}get maxPriorityFeePerGas(){return this.#o??(this.type===2||this.type===3?pw:null)}set maxPriorityFeePerGas(e){this.#o=e==null?null:X(e,`maxPriorityFeePerGas`)}get maxFeePerGas(){return this.#s??(this.type===2||this.type===3?pw:null)}set maxFeePerGas(e){this.#s=e==null?null:X(e,`maxFeePerGas`)}get data(){return this.#n}set data(e){this.#n=Y(e)}get value(){return this.#c}set value(e){this.#c=X(e,`value`)}get chainId(){return this.#l}set chainId(e){this.#l=X(e)}get signature(){return this.#u||null}set signature(e){this.#u=e==null?null:EC.from(e)}isValid(){let e=this.signature;if(e&&!e.isValid())return!1;let t=this.authorizationList;if(t){for(let e of t)if(!e.signature.isValid())return!1}return!0}get accessList(){return(this.#d||null)??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){this.#d=e==null?null:lw(e)}get authorizationList(){let e=this.#g||null;return e==null&&this.type===4?[]:e}set authorizationList(e){this.#g=e==null?null:e.map(e=>uw(e))}get maxFeePerBlobGas(){let e=this.#f;return e==null&&this.type===3?pw:e}set maxFeePerBlobGas(e){this.#f=e==null?null:X(e,`maxFeePerBlobGas`)}get blobVersionedHashes(){let e=this.#p;return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){q(Array.isArray(e),`blobVersionedHashes must be an Array`,`value`,e),e=e.slice();for(let t=0;t<e.length;t++)q(Mv(e[t],32),`invalid blobVersionedHash`,`value[${t}]`,e[t])}this.#p=e}get blobs(){return this.#h==null?null:this.#h.map(e=>Object.assign({},e))}set blobs(e){if(e==null){this.#h=null;return}let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(Nv(i)){K(this.#m,`adding a raw blob requires a KZG library`,`UNSUPPORTED_OPERATION`,{operation:`set blobs()`});let e=J(i);if(q(e.length<=bw,`blob is too large`,`blobs[${r}]`,i),e.length!==bw){let t=new Uint8Array(bw);t.set(e),e=t}let a=this.#m.blobToKzgCommitment(e),o=Y(this.#m.computeBlobKzgProof(e,a));t.push({data:Y(e),commitment:Y(a),proof:o}),n.push(Cw(1,a))}else{let e=Y(i.data),r=Y(i.commitment),a=Y(i.proof);t.push({data:e,commitment:r,proof:a}),n.push(Cw(1,r))}}this.#h=t,this.#p=n}get kzg(){return this.#m}set kzg(e){e==null?this.#m=null:this.#m=Sw(e)}get blobWrapperVersion(){return this.#_}set blobWrapperVersion(e){this.#_=e}constructor(){this.#e=null,this.#t=null,this.#r=0,this.#i=pw,this.#a=null,this.#o=null,this.#s=null,this.#n=`0x`,this.#c=pw,this.#l=pw,this.#u=null,this.#d=null,this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null,this.#_=null}get hash(){return this.signature==null?null:yx(this.#v(!0,!1))}get unsignedHash(){return yx(this.unsignedSerialized)}get from(){return this.signature==null?null:fw(this.unsignedHash,this.signature.getCanonical())}get fromPublicKey(){return this.signature==null?null:DC.recoverPublicKey(this.unsignedHash,this.signature.getCanonical())}isSigned(){return this.signature!=null}#v(e,t){K(!e||this.signature!=null,`cannot serialize unsigned transaction; maybe you meant .unsignedSerialized`,`UNSUPPORTED_OPERATION`,{operation:`.serialized`});let n=e?this.signature:null;switch(this.inferType()){case 0:return Pw(this,n);case 1:return zw(this,n);case 2:return Lw(this,n);case 3:return Vw(this,n,t?this.blobs:null);case 4:return Uw(this,n)}K(!1,`unsupported transaction type`,`UNSUPPORTED_OPERATION`,{operation:`.serialized`})}get serialized(){return this.#v(!0,!0)}get unsignedSerialized(){return this.#v(!1,!1)}inferType(){let e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){let e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,r=this.#f!=null||this.#p;this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&K(this.maxFeePerGas>=this.maxPriorityFeePerGas,`priorityFee cannot be more than maxFee`,`BAD_DATA`,{value:this}),K(!t||this.type!==0&&this.type!==1,`transaction type cannot have maxFeePerGas or maxPriorityFeePerGas`,`BAD_DATA`,{value:this}),K(this.type!==0||!n,`legacy transaction cannot have accessList`,`BAD_DATA`,{value:this});let i=[];return this.type==null?this.authorizationList&&this.authorizationList.length?i.push(4):t?i.push(2):e?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):r&&this.to?i.push(3):(i.push(0),i.push(1),i.push(2),i.push(3)):i.push(this.type),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return e.from(this)}toJSON(){let e=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}[yw](){return this.toString()}toString(){let e=[],t=t=>{let n=this[t];typeof n==`string`&&(n=JSON.stringify(n)),e.push(`${t}: ${n}`)};this.type&&t(`type`),t(`to`),t(`data`),t(`nonce`),t(`gasLimit`),t(`value`),this.chainId!=null&&t(`chainId`),this.signature&&(t(`from`),e.push(`signature: ${this.signature.toString()}`));let n=this.authorizationList;if(n){let t=[];for(let e of n){let n=[];n.push(`address: ${JSON.stringify(e.address)}`),e.nonce!=null&&n.push(`nonce: ${e.nonce}`),e.chainId!=null&&n.push(`chainId: ${e.chainId}`),e.signature&&n.push(`signature: ${e.signature.toString()}`),t.push(`Authorization { ${n.join(`, `)} }`)}e.push(`authorizations: [ ${t.join(`, `)} ]`)}return`Transaction { ${e.join(`, `)} }`}static from(t){if(t==null)return new e;if(typeof t==`string`){let n=J(t);if(n[0]>=127)return e.from(Nw(n));switch(n[0]){case 1:return e.from(Rw(n));case 2:return e.from(Iw(n));case 3:return e.from(Bw(n));case 4:return e.from(Hw(n))}K(!1,`unsupported transaction type`,`UNSUPPORTED_OPERATION`,{operation:`from`})}let n=new e;return t.type!=null&&(n.type=t.type),t.to!=null&&(n.to=t.to),t.nonce!=null&&(n.nonce=t.nonce),t.gasLimit!=null&&(n.gasLimit=t.gasLimit),t.gasPrice!=null&&(n.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(n.maxFeePerGas=t.maxFeePerGas),t.maxFeePerBlobGas!=null&&(n.maxFeePerBlobGas=t.maxFeePerBlobGas),t.data!=null&&(n.data=t.data),t.value!=null&&(n.value=t.value),t.chainId!=null&&(n.chainId=t.chainId),t.signature!=null&&(n.signature=EC.from(t.signature)),t.accessList!=null&&(n.accessList=t.accessList),t.authorizationList!=null&&(n.authorizationList=t.authorizationList),t.blobVersionedHashes!=null&&(n.blobVersionedHashes=t.blobVersionedHashes),t.kzg!=null&&(n.kzg=t.kzg),t.blobWrapperVersion!=null&&(n.blobWrapperVersion=t.blobWrapperVersion),t.blobs!=null&&(n.blobs=t.blobs),t.hash!=null&&(q(n.isSigned(),`unsigned transaction cannot define '.hash'`,`tx`,t),q(n.hash===t.hash,`hash mismatch`,`tx`,t)),t.from!=null&&(q(n.isSigned(),`unsigned transaction cannot define '.from'`,`tx`,t),q(n.from.toLowerCase()===(t.from||``).toLowerCase(),`from mismatch`,`tx`,t)),n}};function Gw(e){return yx(dy(e))}var Kw=`AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5H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jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI`,qw=new Map([[8217,`apostrophe`],[8260,`fraction slash`],[12539,`middle dot`]]),Jw=4;function Yw(e){let t=0;function n(){return e[t++]<<8|e[t++]}let r=n(),i=1,a=[0,1];for(let e=1;e<r;e++)a.push(i+=n());let o=n(),s=t;t+=o;let c=0,l=0;function u(){return c==0&&(l=l<<8|e[t++],c=8),l>>--c&1}let d=2**31,f=d>>>1,p=f>>1,m=d-1,h=0;for(let e=0;e<31;e++)h=h<<1|u();let g=[],_=0,v=d;for(;;){let e=Math.floor(((h-_+1)*i-1)/v),t=0,n=r;for(;n-t>1;){let r=t+n>>>1;e<a[r]?n=r:t=r}if(t==0)break;g.push(t);let o=_+Math.floor(v*a[t]/i),s=_+Math.floor(v*a[t+1]/i)-1;for(;((o^s)&f)==0;)h=h<<1&m|u(),o=o<<1&m,s=s<<1&m|1;for(;o&~s&p;)h=h&f|h<<1&m>>>1|u(),o=o<<1^f,s=(s^f)<<1|f|1;_=o,v=1+s-o}let y=r-4;return g.map(t=>{switch(t-y){case 3:return y+65792+(e[s++]<<16|e[s++]<<8|e[s++]);case 2:return y+256+(e[s++]<<8|e[s++]);case 1:return y+e[s++];default:return t-1}})}function Xw(e){let t=0;return()=>e[t++]}function Zw(e){return Xw(Yw(Qw(e)))}function Qw(e){let t=[];[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`].forEach((e,n)=>t[e.charCodeAt(0)]=n);let n=e.length,r=new Uint8Array(6*n>>3);for(let i=0,a=0,o=0,s=0;i<n;i++)s=s<<6|t[e.charCodeAt(i)],o+=6,o>=8&&(r[a++]=s>>(o-=8));return r}function $w(e){return e&1?~e>>1:e>>1}function eT(e,t){let n=Array(e);for(let r=0,i=0;r<e;r++)n[r]=i+=$w(t());return n}function tT(e,t=0){let n=[];for(;;){let r=e(),i=e();if(!i)break;t+=r;for(let e=0;e<i;e++)n.push(t+e);t+=i+1}return n}function nT(e){return iT(()=>{let t=tT(e);if(t.length)return t})}function rT(e){let t=[];for(;;){let n=e();if(n==0)break;t.push(oT(n,e))}for(;;){let n=e()-1;if(n<0)break;t.push(sT(n,e))}return t.flat()}function iT(e){let t=[];for(;;){let n=e(t.length);if(!n)break;t.push(n)}return t}function aT(e,t,n){let r=Array(e).fill().map(()=>[]);for(let i=0;i<t;i++)eT(e,n).forEach((e,t)=>r[t].push(e));return r}function oT(e,t){let n=1+t(),r=t(),i=iT(t);return aT(i.length,1+e,t).flatMap((e,t)=>{let[a,...o]=e;return Array(i[t]).fill().map((e,t)=>{let i=t*r;return[a+t*n,o.map(e=>e+i)]})})}function sT(e,t){return aT(1+t(),1+e,t).map(e=>[e[0],e.slice(1)])}function cT(e){let t=[],n=tT(e);return i(r([]),[]),t;function r(t){return{S:e(),B:iT(()=>{let t=tT(e).map(e=>n[e]);if(t.length)return r(t)}),Q:t}}function i({S:e,B:n},r,a){if(!(e&4&&a===r[r.length-1])){e&2&&(a=r[r.length-1]),e&1&&t.push(r);for(let e of n)for(let t of e.Q)i(e,[...r,t],a)}}}function lT(e){return e.toString(16).toUpperCase().padStart(2,`0`)}function uT(e){return`{${lT(e)}}`}function dT(e){let t=[];for(let n=0,r=e.length;n<r;){let r=e.codePointAt(n);n+=r<65536?1:2,t.push(r)}return t}function fT(e){let t=4096,n=e.length;if(n<t)return String.fromCodePoint(...e);let r=[];for(let i=0;i<n;)r.push(String.fromCodePoint(...e.slice(i,i+=t)));return r.join(``)}function pT(e,t){let n=e.length,r=n-t.length;for(let i=0;r==0&&i<n;i++)r=e[i]-t[i];return r}var mT=`AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsD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2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g`,hT=44032,gT=4352,_T=4449,vT=4519,yT=19,bT=21,xT=28,ST=bT*xT,CT=hT+yT*ST,wT=gT+yT,TT=_T+bT,ET=vT+xT;function DT(e){return e>>24&255}function OT(e){return e&16777215}var kT,AT,jT,MT;function NT(){let e=Zw(mT);kT=new Map(nT(e).flatMap((e,t)=>e.map(e=>[e,t+1<<24]))),AT=new Set(tT(e)),jT=new Map,MT=new Map;for(let[t,n]of rT(e)){if(!AT.has(t)&&n.length==2){let[e,r]=n,i=MT.get(e);i||(i=new Map,MT.set(e,i)),i.set(r,t)}jT.set(t,n.reverse())}}function PT(e){return e>=hT&&e<CT}function FT(e,t){if(e>=gT&&e<wT&&t>=_T&&t<TT)return hT+(e-gT)*ST+(t-_T)*xT;if(PT(e)&&t>vT&&t<ET&&(e-hT)%xT==0)return e+(t-vT);{let n=MT.get(e);return n&&(n=n.get(t),n)?n:-1}}function IT(e){kT||NT();let t=[],n=[],r=!1;function i(e){let n=kT.get(e);n&&(r=!0,e|=n),t.push(e)}for(let r of e)for(;;){if(r<128)t.push(r);else if(PT(r)){let e=r-hT,t=e/ST|0,n=e%ST/xT|0,a=e%xT;i(gT+t),i(_T+n),a>0&&i(vT+a)}else{let e=jT.get(r);e?n.push(...e):i(r)}if(!n.length)break;r=n.pop()}if(r&&t.length>1){let e=DT(t[0]);for(let n=1;n<t.length;n++){let r=DT(t[n]);if(r==0||e<=r){e=r;continue}let i=n-1;for(;;){let n=t[i+1];if(t[i+1]=t[i],t[i]=n,!i||(e=DT(t[--i]),e<=r))break}e=DT(t[n])}}return t}function LT(e){let t=[],n=[],r=-1,i=0;for(let a of e){let e=DT(a),o=OT(a);if(r==-1)e==0?r=o:t.push(o);else if(i>0&&i>=e)e==0?(t.push(r,...n),n.length=0,r=o):n.push(o),i=e;else{let a=FT(r,o);a>=0?r=a:i==0&&e==0?(t.push(r),r=o):(n.push(o),i=e)}}return r>=0&&t.push(r,...n),t}function RT(e){return IT(e).map(OT)}function zT(e){return LT(IT(e))}var BT=45,VT=`.`,HT=65039,UT=1,WT=e=>Array.from(e);function GT(e,t){return e.P.has(t)||e.Q.has(t)}var KT=class extends Array{get is_emoji(){return!0}},qT,JT,YT,XT,ZT,QT,$T,eE,tE,nE,rE;function iE(){if(qT)return;let e=Zw(Kw),t=()=>tT(e),n=()=>new Set(t()),r=(e,t)=>t.forEach(t=>e.add(t));qT=new Map(rT(e)),JT=n(),YT=t(),XT=new Set(t().map(e=>YT[e])),YT=new Set(YT),ZT=n(),n();let i=nT(e),a=e(),o=()=>{let e=new Set;return t().forEach(t=>r(e,i[t])),r(e,t()),e};QT=iT(t=>{let n=iT(e).map(e=>e+96);if(n.length){let r=t>=a;n[0]-=32,n=fT(n),r&&(n=`Restricted[${n}]`);let i=o(),s=o(),c=!e();return{N:n,P:i,Q:s,M:c,R:r}}}),$T=n(),eE=new Map;let s=t().concat(WT($T)).sort((e,t)=>e-t);s.forEach((t,n)=>{let r=e(),i=s[n]=r?s[n-r]:{V:[],M:new Map};i.V.push(t),$T.has(t)||eE.set(t,i)});for(let{V:e,M:t}of new Set(eE.values())){let n=[];for(let t of e){let e=QT.filter(e=>GT(e,t)),i=n.find(({G:t})=>e.some(e=>t.has(e)));i||(i={G:new Set,V:[]},n.push(i)),i.V.push(t),r(i.G,e)}let i=n.flatMap(e=>WT(e.G));for(let{G:e,V:r}of n){let n=new Set(i.filter(t=>!e.has(t)));for(let e of r)t.set(e,n)}}tE=new Set;let c=new Set,l=e=>tE.has(e)?c.add(e):tE.add(e);for(let e of QT){for(let t of e.P)l(t);for(let t of e.Q)l(t)}for(let e of tE)!eE.has(e)&&!c.has(e)&&eE.set(e,UT);r(tE,RT(tE)),nE=cT(e).map(e=>KT.from(e)).sort(pT),rE=new Map;for(let e of nE){let t=[rE];for(let n of e){let e=t.map(e=>{let t=e.get(n);return t||(t=new Map,e.set(n,t)),t});n===HT?t.push(...e):t=e}for(let n of t)n.V=e}}function aE(e){return(fE(e)?``:`${oE(uE([e]))} `)+uT(e)}function oE(e){return`"${e}"\u200E`}function sE(e){if(e.length>=4&&e[2]==BT&&e[3]==BT)throw Error(`invalid label extension: "${fT(e.slice(0,4))}"`)}function cE(e){for(let t=e.lastIndexOf(95);t>0;)if(e[--t]!==95)throw Error(`underscore allowed only at start`)}function lE(e){let t=e[0],n=qw.get(t);if(n)throw bE(`leading ${n}`);let r=e.length,i=-1;for(let a=1;a<r;a++){t=e[a];let r=qw.get(t);if(r){if(i==a)throw bE(`${n} + ${r}`);i=a+1,n=r}}if(i==r)throw bE(`trailing ${n}`)}function uE(e,t=1/0,n=uT){let r=[];dE(e[0])&&r.push(`◌`),e.length>t&&(t>>=1,e=[...e.slice(0,t),8230,...e.slice(-t)]);let i=0,a=e.length;for(let t=0;t<a;t++){let a=e[t];fE(a)&&(r.push(fT(e.slice(i,t))),r.push(n(a)),i=t+1)}return r.push(fT(e.slice(i,a))),r.join(``)}function dE(e){return iE(),YT.has(e)}function fE(e){return iE(),ZT.has(e)}function pE(e){return _E(mE(e,zT,CE))}function mE(e,t,n){if(!e)return[];iE();let r=0;return e.split(VT).map(e=>{let i=dT(e),a={input:i,offset:r};r+=i.length+1;try{let e=a.tokens=SE(i,t,n),r=e.length,o;if(!r)throw Error(`empty label`);let s=a.output=e.flat();if(cE(s),!(a.emoji=r>1||e[0].is_emoji)&&s.every(e=>e<128))sE(s),o=`ASCII`;else{let t=e.flatMap(e=>e.is_emoji?[]:e);if(!t.length)o=`Emoji`;else{if(YT.has(s[0]))throw bE(`leading combining mark`);for(let t=1;t<r;t++){let n=e[t];if(!n.is_emoji&&YT.has(n[0]))throw bE(`emoji + combining mark: "${fT(e[t-1])} + ${uE([n[0]])}"`)}lE(s);let n=WT(new Set(t)),[i]=gE(n);xE(i,t),hE(i,n),o=i.N}}a.type=o}catch(e){a.error=e}return a})}function hE(e,t){let n,r=[];for(let e of t){let t=eE.get(e);if(t===UT)return;if(t){let r=t.M.get(e);if(n=n?n.filter(e=>r.has(e)):WT(r),!n.length)return}else r.push(e)}if(n){for(let t of n)if(r.every(e=>GT(t,e)))throw Error(`whole-script confusable: ${e.N}/${t.N}`)}}function gE(e){let t=QT;for(let n of e){let e=t.filter(e=>GT(e,n));if(!e.length)throw QT.some(e=>GT(e,n))?yE(t[0],n):vE(n);if(t=e,e.length==1)break}return t}function _E(e){return e.map(({input:t,error:n,output:r})=>{if(n){let r=n.message;throw Error(e.length==1?r:`Invalid label ${oE(uE(t,63))}: ${r}`)}return fT(r)}).join(VT)}function vE(e){return Error(`disallowed character: ${aE(e)}`)}function yE(e,t){let n=aE(t),r=QT.find(e=>e.P.has(t));return r&&(n=`${r.N} ${n}`),Error(`illegal mixture: ${e.N} + ${n}`)}function bE(e){return Error(`illegal placement: ${e}`)}function xE(e,t){for(let n of t)if(!GT(e,n))throw yE(e,n);if(e.M){let e=RT(t);for(let t=1,n=e.length;t<n;t++)if(XT.has(e[t])){let r=t+1;for(let i;r<n&&XT.has(i=e[r]);r++)for(let n=t;n<r;n++)if(e[n]==i)throw Error(`duplicate non-spacing marks: ${aE(i)}`);if(r-t>Jw)throw Error(`excessive non-spacing marks: ${oE(uE(e.slice(t-1,r)))} (${r-t}/${Jw})`);t=r}}}function SE(e,t,n){let r=[],i=[];for(e=e.slice().reverse();e.length;){let a=wE(e);if(a)i.length&&(r.push(t(i)),i=[]),r.push(n(a));else{let t=e.pop();if(tE.has(t))i.push(t);else{let e=qT.get(t);if(e)i.push(...e);else if(!JT.has(t))throw vE(t)}}}return i.length&&r.push(t(i)),r}function CE(e){return e.filter(e=>e!=HT)}function wE(e,t){let n=rE,r,i=e.length;for(;i&&(n=n.get(e[--i]),n);){let{V:a}=n;a&&(r=a,t&&t.push(...e.slice(i).reverse()),e.length=i)}return r}var TE=new Uint8Array(32);TE.fill(0);function EE(e){return q(e.length!==0,`invalid ENS name; empty component`,`comp`,e),e}function DE(e){let t=dy(OE(e)),n=[];if(e.length===0)return n;let r=0;for(let e=0;e<t.length;e++)t[e]===46&&(n.push(EE(t.slice(r,e))),r=e+1);return q(r<t.length,`invalid ENS name; empty component`,`name`,e),n.push(EE(t.slice(r))),n}function OE(e){try{if(e.length===0)throw Error(`empty label`);return pE(e)}catch(t){q(!1,`invalid ENS name (${t.message})`,`name`,e)}}function kE(e){q(typeof e==`string`,`invalid ENS name; not a string`,`name`,e),q(e.length,`invalid ENS name (empty label)`,`name`,e);let t=TE,n=DE(e);for(;n.length;)t=yx(Fv([t,yx(n.pop())]));return Y(t)}function AE(e,t){let n=t??63;return q(n<=255,`DNS encoded label cannot exceed 255`,`length`,n),Y(Fv(DE(e).map(t=>{q(t.length<=n,`label ${JSON.stringify(e)} exceeds ${n} bytes`,`name`,e);let r=new Uint8Array(t.length+1);return r.set(t,1),r[0]=r.length-1,r})))+`00`}var jE=new Uint8Array(32);jE.fill(0);var ME=BigInt(-1),NE=BigInt(0),PE=BigInt(1),FE=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`);function IE(e){let t=J(e),n=t.length%32;return n?Fv([t,jE.slice(n)]):Y(t)}var LE=Zv(PE,32),RE=Zv(NE,32),zE={name:`string`,version:`string`,chainId:`uint256`,verifyingContract:`address`,salt:`bytes32`},BE=[`name`,`version`,`chainId`,`verifyingContract`,`salt`];function VE(e){return function(t){return q(typeof t==`string`,`invalid domain value for ${JSON.stringify(e)}`,`domain.${e}`,t),t}}var HE={name:VE(`name`),version:VE(`version`),chainId:function(e){let t=X(e,`domain.chainId`);return q(t>=0,`invalid chain ID`,`domain.chainId`,e),Number.isSafeInteger(t)?Number(t):$v(t)},verifyingContract:function(e){try{return IC(e).toLowerCase()}catch{}q(!1,`invalid domain value "verifyingContract"`,`domain.verifyingContract`,e)},salt:function(e){let t=J(e,`domain.salt`);return q(t.length===32,`invalid domain value "salt"`,`domain.salt`,e),Y(t)}};function UE(e){{let t=e.match(/^(u?)int(\d+)$/);if(t){let n=t[1]===``,r=parseInt(t[2]);q(r%8==0&&r!==0&&r<=256&&t[2]===String(r),`invalid numeric width`,`type`,e);let i=Kv(FE,n?r-1:r),a=n?(i+PE)*ME:NE;return function(t){let r=X(t,`value`);return q(r>=a&&r<=i,`value out-of-bounds for ${e}`,`value`,r),Zv(n?Gv(r,256):r,32)}}}{let t=e.match(/^bytes(\d+)$/);if(t){let n=parseInt(t[1]);return q(n!==0&&n<=32&&t[1]===String(n),`invalid bytes width`,`type`,e),function(t){return q(J(t).length===n,`invalid length for ${e}`,`value`,t),IE(t)}}}switch(e){case`address`:return function(e){return zv(IC(e),32)};case`bool`:return function(e){return e?LE:RE};case`bytes`:return function(e){return yx(e)};case`string`:return function(e){return Gw(e)}}return null}function WE(e,t){return`${e}(${t.map(({name:e,type:t})=>t+` `+e).join(`,`)})`}function GE(e){let t=e.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return t?{base:t[1],index:t[2]+t[4],array:{base:t[1],prefix:t[1]+t[2],count:t[5]?parseInt(t[5]):-1}}:{base:e}}var KE=class e{primaryType;#e;get types(){return JSON.parse(this.#e)}#t;#n;constructor(e){this.#t=new Map,this.#n=new Map;let t=new Map,n=new Map,r=new Map,i={};Object.keys(e).forEach(a=>{i[a]=e[a].map(({name:t,type:n})=>{let{base:r,index:i}=GE(n);return r===`int`&&!e.int&&(r=`int256`),r===`uint`&&!e.uint&&(r=`uint256`),{name:t,type:r+(i||``)}}),t.set(a,new Set),n.set(a,[]),r.set(a,new Set)}),this.#e=JSON.stringify(i);for(let r in i){let a=new Set;for(let o of i[r]){q(!a.has(o.name),`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(r)}`,`types`,e),a.add(o.name);let i=GE(o.type).base;q(i!==r,`circular type reference to ${JSON.stringify(i)}`,`types`,e),!UE(i)&&(q(n.has(i),`unknown type ${JSON.stringify(i)}`,`types`,e),n.get(i).push(r),t.get(r).add(i))}}let a=Array.from(n.keys()).filter(e=>n.get(e).length===0);q(a.length!==0,`missing primary type`,`types`,e),q(a.length===1,`ambiguous primary types or unused types: ${a.map(e=>JSON.stringify(e)).join(`, `)}`,`types`,e),G(this,{primaryType:a[0]});function o(i,a){q(!a.has(i),`circular type reference to ${JSON.stringify(i)}`,`types`,e),a.add(i);for(let e of t.get(i))if(n.has(e)){o(e,a);for(let t of a)r.get(t).add(e)}a.delete(i)}o(this.primaryType,new Set);for(let[e,t]of r){let n=Array.from(t);n.sort(),this.#t.set(e,WE(e,i[e])+n.map(e=>WE(e,i[e])).join(``))}}getEncoder(e){let t=this.#n.get(e);return t||(t=this.#r(e),this.#n.set(e,t)),t}#r(e){{let t=UE(e);if(t)return t}let t=GE(e).array;if(t){let e=t.prefix,n=this.getEncoder(e);return r=>{q(t.count===-1||t.count===r.length,`array length mismatch; expected length ${t.count}`,`value`,r);let i=r.map(n);return this.#t.has(e)&&(i=i.map(yx)),yx(Fv(i))}}let n=this.types[e];if(n){let t=Gw(this.#t.get(e));return e=>{let r=n.map(({name:t,type:n})=>{let r=this.getEncoder(n)(e[t]);return this.#t.has(n)?yx(r):r});return r.unshift(t),Fv(r)}}q(!1,`unknown type: ${e}`,`type`,e)}encodeType(e){let t=this.#t.get(e);return q(t,`unknown type: ${JSON.stringify(e)}`,`name`,e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return yx(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(UE(e))return n(e,t);let r=GE(e).array;if(r)return q(r.count===-1||r.count===t.length,`array length mismatch; expected length ${r.count}`,`value`,t),t.map(e=>this._visit(r.prefix,e,n));let i=this.types[e];if(i)return i.reduce((e,{name:r,type:i})=>(e[r]=this._visit(i,t[r],n),e),{});q(!1,`unknown type: ${e}`,`type`,e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(t){return new e(t)}static getPrimaryType(t){return e.from(t).primaryType}static hashStruct(t,n,r){return e.from(n).hashStruct(t,r)}static hashDomain(t){let n=[];for(let e in t){if(t[e]==null)continue;let r=zE[e];q(r,`invalid typed-data domain key: ${JSON.stringify(e)}`,`domain`,t),n.push({name:e,type:r})}return n.sort((e,t)=>BE.indexOf(e.name)-BE.indexOf(t.name)),e.hashStruct(`EIP712Domain`,{EIP712Domain:n},t)}static encode(t,n,r){return Fv([`0x1901`,e.hashDomain(t),e.from(n).hash(r)])}static hash(t,n,r){return yx(e.encode(t,n,r))}static async resolveNames(t,n,r,i){t=Object.assign({},t);for(let e in t)t[e]??delete t[e];let a={};t.verifyingContract&&!Mv(t.verifyingContract,20)&&(a[t.verifyingContract]=`0x`);let o=e.from(n);o.visit(r,(e,t)=>(e===`address`&&!Mv(t,20)&&(a[t]=`0x`),t));for(let e in a)a[e]=await i(e);return t.verifyingContract&&a[t.verifyingContract]&&(t.verifyingContract=a[t.verifyingContract]),r=o.visit(r,(e,t)=>e===`address`&&a[t]?a[t]:t),{domain:t,value:r}}static getPayload(t,n,r){e.hashDomain(t);let i={},a=[];BE.forEach(e=>{let n=t[e];n!=null&&(i[e]=HE[e](n),a.push({name:e,type:zE[e]}))});let o=e.from(n);n=o.types;let s=Object.assign({},n);return q(s.EIP712Domain==null,`types must not contain EIP712Domain type`,`types.EIP712Domain`,n),s.EIP712Domain=a,o.encode(r),{types:s,domain:i,primaryType:o.primaryType,message:o.visit(r,(e,t)=>{if(e.match(/^bytes(\d*)/))return Y(J(t));if(e.match(/^u?int/))return X(t).toString();switch(e){case`address`:return t.toLowerCase();case`bool`:return!!t;case`string`:return q(typeof t==`string`,`invalid string`,`value`,t),t}q(!1,`unsupported type`,`type`,e)})}}};function qE(e){let t=new Set;return e.forEach(e=>t.add(e)),Object.freeze(t)}var JE=qE(`external public payable override`.split(` `)),YE=`constant external internal payable private public pure view override`,XE=qE(YE.split(` `)),ZE=`constructor error event fallback function receive struct`,QE=qE(ZE.split(` `)),$E=`calldata memory storage payable indexed`,eD=qE($E.split(` `)),tD=qE([ZE,$E,`tuple returns`,YE].join(` `).split(` `)),nD={"(":`OPEN_PAREN`,")":`CLOSE_PAREN`,"[":`OPEN_BRACKET`,"]":`CLOSE_BRACKET`,",":`COMMA`,"@":`AT`},rD=RegExp(`^(\\s*)`),iD=RegExp(`^([0-9]+)`),aD=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)`),oD=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)$`),sD=RegExp(`^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$`),cD=class e{#e;#t;get offset(){return this.#e}get length(){return this.#t.length-this.#e}constructor(e){this.#e=0,this.#t=e.slice()}clone(){return new e(this.#t)}reset(){this.#e=0}#n(t=0,n=0){return new e(this.#t.slice(t,n).map(e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t}))))}popKeyword(e){let t=this.peek();if(t.type!==`KEYWORD`||!e.has(t.text))throw Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){let t=this.peek();throw Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=this.#n(this.#e+1,e.match+1);return this.#e=e.match+1,t}popParams(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=[];for(;this.#e<e.match-1;){let e=this.peek().linkNext;t.push(this.#n(this.#e+1,e)),this.#e=e}return this.#e=e.match+1,t}peek(){if(this.#e>=this.#t.length)throw Error(`out-of-bounds`);return this.#t[this.#e]}peekKeyword(e){let t=this.peekType(`KEYWORD`);return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;let t=this.peek();return t.type===e?t.text:null}pop(){let e=this.peek();return this.#e++,e}toString(){let e=[];for(let t=this.#e;t<this.#t.length;t++){let n=this.#t[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(` `)}>`}};function lD(e){let t=[],n=t=>{let n=a<e.length?JSON.stringify(e[a]):`$EOI`;throw Error(`invalid token ${n} at ${a}: ${t}`)},r=[],i=[],a=0;for(;a<e.length;){let o=e.substring(a),s=o.match(rD);s&&(a+=s[1].length,o=e.substring(a));let c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:``,text:``,offset:a,value:-1};t.push(c);let l=nD[o[0]]||``;if(l){if(c.type=l,c.text=o[0],a++,l===`OPEN_PAREN`)r.push(t.length-1),i.push(t.length-1);else if(l==`CLOSE_PAREN`)r.length===0&&n(`no matching open bracket`),c.match=r.pop(),t[c.match].match=t.length-1,c.depth--,c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1;else if(l===`COMMA`)c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(l===`OPEN_BRACKET`)c.type=`BRACKET`;else if(l===`CLOSE_BRACKET`){let e=t.pop().text;if(t.length>0&&t[t.length-1].type===`NUMBER`){let n=t.pop().text;e=n+e,t[t.length-1].value=Z(n)}if(t.length===0||t[t.length-1].type!==`BRACKET`)throw Error(`missing opening bracket`);t[t.length-1].text+=e}continue}if(s=o.match(aD),s){if(c.text=s[1],a+=c.text.length,tD.has(c.text)){c.type=`KEYWORD`;continue}if(c.text.match(sD)){c.type=`TYPE`;continue}c.type=`ID`;continue}if(s=o.match(iD),s){c.text=s[1],c.type=`NUMBER`,a+=c.text.length;continue}throw Error(`unexpected token ${JSON.stringify(o[0])} at position ${a}`)}return new cD(t.map(e=>Object.freeze(e)))}function uD(e,t){let n=[];for(let r in t.keys())e.has(r)&&n.push(r);if(n.length>1)throw Error(`conflicting types: ${n.join(`, `)}`)}function dD(e,t){if(t.peekKeyword(QE)){let n=t.pop().text;if(n!==e)throw Error(`expected ${e}, got ${n}`)}return t.popType(`ID`)}function fD(e,t){let n=new Set;for(;;){let r=e.peekType(`KEYWORD`);if(r==null||t&&!t.has(r))break;if(e.pop(),n.has(r))throw Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}function pD(e){let t=fD(e,XE);return uD(t,qE(`constant payable nonpayable`.split(` `))),uD(t,qE(`pure view payable nonpayable`.split(` `))),t.has(`view`)?`view`:t.has(`pure`)?`pure`:t.has(`payable`)?`payable`:t.has(`nonpayable`)?`nonpayable`:t.has(`constant`)?`view`:`nonpayable`}function mD(e,t){return e.popParams().map(e=>OD.from(e,t))}function hD(e){if(e.peekType(`AT`)){if(e.pop(),e.peekType(`NUMBER`))return X(e.pop().text);throw Error(`invalid gas`)}return null}function gD(e){if(e.length)throw Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`)}var _D=new RegExp(/^(.*)\[([0-9]*)\]$/);function vD(e){let t=e.match(sD);if(q(t,`invalid type`,`type`,e),e===`uint`)return`uint256`;if(e===`int`)return`int256`;if(t[2]){let n=parseInt(t[2]);q(n!==0&&n<=32,`invalid bytes length`,`type`,e)}else if(t[3]){let n=parseInt(t[3]);q(n!==0&&n<=256&&n%8==0,`invalid numeric width`,`type`,e)}return e}var yD={},bD=Symbol.for(`_ethers_internal`),xD=`_ParamTypeInternal`,SD=`_ErrorInternal`,CD=`_EventInternal`,wD=`_ConstructorInternal`,TD=`_FallbackInternal`,ED=`_FunctionInternal`,DD=`_StructInternal`,OD=class e{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(e,t,n,r,i,a,o,s){if(kv(e,yD,`ParamType`),Object.defineProperty(this,bD,{value:xD}),a&&=Object.freeze(a.slice()),r===`array`){if(o==null||s==null)throw Error(``)}else if(o!=null||s!=null)throw Error(``);if(r===`tuple`){if(a==null)throw Error(``)}else if(a!=null)throw Error(``);G(this,{name:t,type:n,baseType:r,indexed:i,components:a,arrayLength:o,arrayChildren:s})}format(e){if(e??=`sighash`,e===`json`){let t=this.name||``;if(this.isArray()){let e=JSON.parse(this.arrayChildren.format(`json`));return e.name=t,e.type+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`,JSON.stringify(e)}let n={type:this.baseType===`tuple`?`tuple`:this.type,name:t};return typeof this.indexed==`boolean`&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map(t=>JSON.parse(t.format(e)))),JSON.stringify(n)}let t=``;return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`):this.isTuple()?t+=`(`+this.components.map(t=>t.format(e)).join(e===`full`?`, `:`,`)+`)`:t+=this.type,e!==`sighash`&&(this.indexed===!0&&(t+=` indexed`),e===`full`&&this.name&&(t+=` `+this.name)),t}isArray(){return this.baseType===`array`}isTuple(){return this.baseType===`tuple`}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw Error(`invalid array value`);if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw Error(`array is wrong length`);let n=this;return e.map(e=>n.arrayChildren.walk(e,t))}if(this.isTuple()){if(!Array.isArray(e))throw Error(`invalid tuple value`);if(e.length!==this.components.length)throw Error(`array is wrong length`);let n=this;return e.map((e,r)=>n.components[r].walk(e,t))}return t(this.type,e)}#e(e,t,n,r){if(this.isArray()){if(!Array.isArray(t))throw Error(`invalid array value`);if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw Error(`array is wrong length`);let i=this.arrayChildren,a=t.slice();a.forEach((t,r)=>{i.#e(e,t,n,e=>{a[r]=e})}),r(a);return}if(this.isTuple()){let i=this.components,a;if(Array.isArray(t))a=t.slice();else{if(typeof t!=`object`||!t)throw Error(`invalid tuple value`);a=i.map(e=>{if(!e.name)throw Error(`cannot use object value with unnamed components`);if(!(e.name in t))throw Error(`missing value for component ${e.name}`);return t[e.name]})}if(a.length!==this.components.length)throw Error(`array is wrong length`);a.forEach((t,r)=>{i[r].#e(e,t,n,e=>{a[r]=e})}),r(a);return}let i=n(this.type,t);i.then?e.push((async function(){r(await i)})()):r(i)}async walkAsync(e,t){let n=[],r=[e];return this.#e(n,e,t,e=>{r[0]=e}),n.length&&await Promise.all(n),r[0]}static from(t,n){if(e.isParamType(t))return t;if(typeof t==`string`)try{return e.from(lD(t),n)}catch{q(!1,`invalid param type`,`obj`,t)}else if(t instanceof cD){let r=``,i=``,a=null;fD(t,qE([`tuple`])).has(`tuple`)||t.peekType(`OPEN_PAREN`)?(i=`tuple`,a=t.popParams().map(t=>e.from(t)),r=`tuple(${a.map(e=>e.format()).join(`,`)})`):(r=vD(t.popType(`TYPE`)),i=r);let o=null,s=null;for(;t.length&&t.peekType(`BRACKET`);){let n=t.pop();o=new e(yD,``,r,i,null,a,s,o),s=n.value,r+=n.text,i=`array`,a=null}let c=null;if(fD(t,eD).has(`indexed`)){if(!n)throw Error(``);c=!0}let l=t.peekType(`ID`)?t.pop().text:``;if(t.length)throw Error(`leftover tokens`);return new e(yD,l,r,i,c,a,s,o)}let r=t.name;q(!r||typeof r==`string`&&r.match(oD),`invalid name`,`obj.name`,r);let i=t.indexed;i!=null&&(q(n,`parameter cannot be indexed`,`obj.indexed`,t.indexed),i=!!i);let a=t.type,o=a.match(_D);if(o){let n=parseInt(o[2]||`-1`),s=e.from({type:o[1],components:t.components});return new e(yD,r||``,a,`array`,i,null,n,s)}if(a===`tuple`||a.startsWith(`tuple(`)||a.startsWith(`(`)){let n=t.components==null?null:t.components.map(t=>e.from(t));return new e(yD,r||``,a,`tuple`,i,n,null,null)}return a=vD(t.type),new e(yD,r||``,a,a,i,null,null,null)}static isParamType(e){return e&&e[bD]===xD}},kD=class e{type;inputs;constructor(e,t,n){kv(e,yD,`Fragment`),n=Object.freeze(n.slice()),G(this,{type:t,inputs:n})}static from(t){if(typeof t==`string`){try{e.from(JSON.parse(t))}catch{}return e.from(lD(t))}if(t instanceof cD)switch(t.peekKeyword(QE)){case`constructor`:return PD.from(t);case`error`:return MD.from(t);case`event`:return ND.from(t);case`fallback`:case`receive`:return FD.from(t);case`function`:return ID.from(t);case`struct`:return LD.from(t)}else if(typeof t==`object`){switch(t.type){case`constructor`:return PD.from(t);case`error`:return MD.from(t);case`event`:return ND.from(t);case`fallback`:case`receive`:return FD.from(t);case`function`:return ID.from(t);case`struct`:return LD.from(t)}K(!1,`unsupported type: ${t.type}`,`UNSUPPORTED_OPERATION`,{operation:`Fragment.from`})}q(!1,`unsupported frgament object`,`obj`,t)}static isConstructor(e){return PD.isFragment(e)}static isError(e){return MD.isFragment(e)}static isEvent(e){return ND.isFragment(e)}static isFunction(e){return ID.isFragment(e)}static isStruct(e){return LD.isFragment(e)}},AD=class extends kD{name;constructor(e,t,n,r){super(e,t,r),q(typeof n==`string`&&n.match(oD),`invalid identifier`,`name`,n),r=Object.freeze(r.slice()),G(this,{name:n})}};function jD(e,t){return`(`+t.map(t=>t.format(e)).join(e===`full`?`, `:`,`)+`)`}var MD=class e extends AD{constructor(e,t,n){super(e,`error`,t,n),Object.defineProperty(this,bD,{value:SD})}get selector(){return Gw(this.format(`sighash`)).substring(0,10)}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`error`,name:this.name,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`error`),t.push(this.name+jD(e,this.inputs)),t.join(` `)}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)return e.from(lD(t));if(t instanceof cD){let n=dD(`error`,t),r=mD(t);return gD(t),new e(yD,n,r)}return new e(yD,t.name,t.inputs?t.inputs.map(OD.from):[])}static isFragment(e){return e&&e[bD]===SD}},ND=class e extends AD{anonymous;constructor(e,t,n,r){super(e,`event`,t,n),Object.defineProperty(this,bD,{value:CD}),G(this,{anonymous:r})}get topicHash(){return Gw(this.format(`sighash`))}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`event`,anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`event`),t.push(this.name+jD(e,this.inputs)),e!==`sighash`&&this.anonymous&&t.push(`anonymous`),t.join(` `)}static getTopicHash(t,n){return n=(n||[]).map(e=>OD.from(e)),new e(yD,t,n,!1).topicHash}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid event fragment`,`obj`,t)}else if(t instanceof cD){let n=dD(`event`,t),r=mD(t,!0),i=!!fD(t,qE([`anonymous`])).has(`anonymous`);return gD(t),new e(yD,n,r,i)}return new e(yD,t.name,t.inputs?t.inputs.map(e=>OD.from(e,!0)):[],!!t.anonymous)}static isFragment(e){return e&&e[bD]===CD}},PD=class e extends kD{payable;gas;constructor(e,t,n,r,i){super(e,t,n),Object.defineProperty(this,bD,{value:wD}),G(this,{payable:r,gas:i})}format(e){if(K(e!=null&&e!==`sighash`,`cannot format a constructor for sighash`,`UNSUPPORTED_OPERATION`,{operation:`format(sighash)`}),e===`json`)return JSON.stringify({type:`constructor`,stateMutability:this.payable?`payable`:`undefined`,payable:this.payable,gas:this.gas==null?void 0:this.gas,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[`constructor${jD(e,this.inputs)}`];return this.payable&&t.push(`payable`),this.gas!=null&&t.push(`@${this.gas.toString()}`),t.join(` `)}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid constuctor fragment`,`obj`,t)}else if(t instanceof cD){fD(t,qE([`constructor`]));let n=mD(t),r=!!fD(t,JE).has(`payable`),i=hD(t);return gD(t),new e(yD,`constructor`,n,r,i)}return new e(yD,`constructor`,t.inputs?t.inputs.map(OD.from):[],!!t.payable,t.gas==null?null:t.gas)}static isFragment(e){return e&&e[bD]===wD}},FD=class e extends kD{payable;constructor(e,t,n){super(e,`fallback`,t),Object.defineProperty(this,bD,{value:TD}),G(this,{payable:n})}format(e){let t=this.inputs.length===0?`receive`:`fallback`;if(e===`json`){let e=this.payable?`payable`:`nonpayable`;return JSON.stringify({type:t,stateMutability:e})}return`${t}()${this.payable?` payable`:``}`}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid fallback fragment`,`obj`,t)}else if(t instanceof cD){let n=t.toString();if(q(t.peekKeyword(qE([`fallback`,`receive`])),`type must be fallback or receive`,`obj`,n),t.popKeyword(qE([`fallback`,`receive`]))===`receive`){let n=mD(t);return q(n.length===0,`receive cannot have arguments`,`obj.inputs`,n),fD(t,qE([`payable`])),gD(t),new e(yD,[],!0)}let r=mD(t);r.length?q(r.length===1&&r[0].type===`bytes`,`invalid fallback inputs`,`obj.inputs`,r.map(e=>e.format(`minimal`)).join(`, `)):r=[OD.from(`bytes`)];let i=pD(t);if(q(i===`nonpayable`||i===`payable`,`fallback cannot be constants`,`obj.stateMutability`,i),fD(t,qE([`returns`])).has(`returns`)){let e=mD(t);q(e.length===1&&e[0].type===`bytes`,`invalid fallback outputs`,`obj.outputs`,e.map(e=>e.format(`minimal`)).join(`, `))}return gD(t),new e(yD,r,i===`payable`)}if(t.type===`receive`)return new e(yD,[],!0);if(t.type===`fallback`)return new e(yD,[OD.from(`bytes`)],t.stateMutability===`payable`);q(!1,`invalid fallback description`,`obj`,t)}static isFragment(e){return e&&e[bD]===TD}},ID=class e extends AD{constant;outputs;stateMutability;payable;gas;constructor(e,t,n,r,i,a){super(e,`function`,t,r),Object.defineProperty(this,bD,{value:ED}),i=Object.freeze(i.slice()),G(this,{constant:n===`view`||n===`pure`,gas:a,outputs:i,payable:n===`payable`,stateMutability:n})}get selector(){return Gw(this.format(`sighash`)).substring(0,10)}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`function`,name:this.name,constant:this.constant,stateMutability:this.stateMutability===`nonpayable`?void 0:this.stateMutability,payable:this.payable,gas:this.gas==null?void 0:this.gas,inputs:this.inputs.map(t=>JSON.parse(t.format(e))),outputs:this.outputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`function`),t.push(this.name+jD(e,this.inputs)),e!==`sighash`&&(this.stateMutability!==`nonpayable`&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push(`returns`),t.push(jD(e,this.outputs))),this.gas!=null&&t.push(`@${this.gas.toString()}`)),t.join(` `)}static getSelector(t,n){return n=(n||[]).map(e=>OD.from(e)),new e(yD,t,`view`,n,[],null).selector}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid function fragment`,`obj`,t)}else if(t instanceof cD){let n=dD(`function`,t),r=mD(t),i=pD(t),a=[];fD(t,qE([`returns`])).has(`returns`)&&(a=mD(t));let o=hD(t);return gD(t),new e(yD,n,i,r,a,o)}let n=t.stateMutability;return n??(n=`payable`,typeof t.constant==`boolean`?(n=`view`,t.constant||(n=`payable`,typeof t.payable==`boolean`&&!t.payable&&(n=`nonpayable`))):typeof t.payable==`boolean`&&!t.payable&&(n=`nonpayable`)),new e(yD,t.name,n,t.inputs?t.inputs.map(OD.from):[],t.outputs?t.outputs.map(OD.from):[],t.gas==null?null:t.gas)}static isFragment(e){return e&&e[bD]===ED}},LD=class e extends AD{constructor(e,t,n){super(e,`struct`,t,n),Object.defineProperty(this,bD,{value:DD})}format(){throw Error(`@TODO`)}static from(t){if(typeof t==`string`)try{return e.from(lD(t))}catch{q(!1,`invalid struct fragment`,`obj`,t)}else if(t instanceof cD){let n=dD(`struct`,t),r=mD(t);return gD(t),new e(yD,n,r)}return new e(yD,t.name,t.inputs?t.inputs.map(OD.from):[])}static isFragment(e){return e&&e[bD]===DD}},RD=new Map;RD.set(0,`GENERIC_PANIC`),RD.set(1,`ASSERT_FALSE`),RD.set(17,`OVERFLOW`),RD.set(18,`DIVIDE_BY_ZERO`),RD.set(33,`ENUM_RANGE_ERROR`),RD.set(34,`BAD_STORAGE_DATA`),RD.set(49,`STACK_UNDERFLOW`),RD.set(50,`ARRAY_RANGE_ERROR`),RD.set(65,`OUT_OF_MEMORY`),RD.set(81,`UNINITIALIZED_FUNCTION_CALL`);var zD=new RegExp(/^bytes([0-9]*)$/),BD=new RegExp(/^(u?int)([0-9]*)$/),VD=null,HD=1024;function UD(e,t,n,r){let i=`missing revert data`,a=null,o=null;if(n){i=`execution reverted`;let e=J(n);if(n=Y(n),e.length===0)i+=` (no data present; likely require(false) occurred`,a=`require(false)`;else if(e.length%32!=4)i+=` (could not decode reason; invalid data length)`;else if(Y(e.slice(0,4))===`0x08c379a0`)try{a=r.decode([`string`],e.slice(4))[0],o={signature:`Error(string)`,name:`Error`,args:[a]},i+=`: ${JSON.stringify(a)}`}catch{i+=` (could not decode reason; invalid string data)`}else if(Y(e.slice(0,4))===`0x4e487b71`)try{let t=Number(r.decode([`uint256`],e.slice(4))[0]);o={signature:`Panic(uint256)`,name:`Panic`,args:[t]},a=`Panic due to ${RD.get(t)||`UNKNOWN`}(${t})`,i+=`: ${a}`}catch{i+=` (could not decode panic code)`}else i+=` (unknown custom error)`}let s={to:t.to?IC(t.to):null,data:t.data||`0x`};return t.from&&(s.from=IC(t.from)),Tv(i,`CALL_EXCEPTION`,{action:e,data:n,reason:a,transaction:s,invocation:null,revert:o})}var WD=class e{#e(e){if(e.isArray())return new YC(this.#e(e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new sw(e.components.map(e=>this.#e(e)),e.name);switch(e.baseType){case`address`:return new GC(e.name);case`bool`:return new XC(e.name);case`string`:return new ow(e.name);case`bytes`:return new QC(e.name);case``:return new tw(e.name)}let t=e.type.match(BD);if(t){let n=parseInt(t[2]||`256`);return q(n!==0&&n<=256&&n%8==0,`invalid `+t[1]+` bit length`,`param`,e),new aw(n/8,t[1]===`int`,e.name)}if(t=e.type.match(zD),t){let n=parseInt(t[1]);return q(n!==0&&n<=32,`invalid bytes length`,`param`,e),new $C(n,e.name)}q(!1,`invalid type`,`type`,e.type)}getDefaultValue(e){return new sw(e.map(e=>this.#e(OD.from(e))),`_`).defaultValue()}encode(e,t){Ev(t.length,e.length,`types/values length mismatch`);let n=new sw(e.map(e=>this.#e(OD.from(e))),`_`),r=new Qy;return n.encode(r,t),r.data}decode(e,t,n){return new sw(e.map(e=>this.#e(OD.from(e))),`_`).decode(new $y(t,n,HD))}static _setDefaultMaxInflation(e){q(typeof e==`number`&&Number.isInteger(e),`invalid defaultMaxInflation factor`,`value`,e),HD=e}static defaultAbiCoder(){return VD??=new e,VD}static getBuiltinCallException(t,n,r){return UD(t,n,r,e.defaultAbiCoder())}},GD=class{fragment;name;signature;topic;args;constructor(e,t,n){let r=e.name,i=e.format();G(this,{fragment:e,name:r,signature:i,topic:t,args:n})}},KD=class{fragment;name;args;signature;selector;value;constructor(e,t,n,r){let i=e.name,a=e.format();G(this,{fragment:e,name:i,args:n,signature:a,selector:t,value:r})}},qD=class{fragment;name;args;signature;selector;constructor(e,t,n){let r=e.name,i=e.format();G(this,{fragment:e,name:r,args:n,signature:i,selector:t})}},JD=class{hash;_isIndexed;static isIndexed(e){return!!(e&&e._isIndexed)}constructor(e){G(this,{hash:e,_isIndexed:!0})}},YD={0:`generic panic`,1:`assert(false)`,17:`arithmetic overflow`,18:`division or modulo by zero`,33:`enum overflow`,34:`invalid encoded storage byte array accessed`,49:`out-of-bounds array access; popping on an empty array`,50:`out-of-bounds access of an array or bytesN`,65:`out of memory`,81:`uninitialized function`},XD={"0x08c379a0":{signature:`Error(string)`,name:`Error`,inputs:[`string`],reason:e=>`reverted with reason string ${JSON.stringify(e)}`},"0x4e487b71":{signature:`Panic(uint256)`,name:`Panic`,inputs:[`uint256`],reason:e=>{let t=`unknown panic code`;return e>=0&&e<=255&&YD[e.toString()]&&(t=YD[e.toString()]),`reverted with panic code 0x${e.toString(16)} (${t})`}}},ZD=class e{fragments;deploy;fallback;receive;#e;#t;#n;#r;constructor(e){let t=[];t=typeof e==`string`?JSON.parse(e):e,this.#n=new Map,this.#e=new Map,this.#t=new Map;let n=[];for(let e of t)try{n.push(kD.from(e))}catch(t){console.log(`[Warning] Invalid Fragment ${JSON.stringify(e)}:`,t.message)}G(this,{fragments:Object.freeze(n)});let r=null,i=!1;this.#r=this.getAbiCoder(),this.fragments.forEach((e,t)=>{let n;switch(e.type){case`constructor`:if(this.deploy){console.log(`duplicate definition - constructor`);return}G(this,{deploy:e});return;case`fallback`:e.inputs.length===0?i=!0:(q(!r||e.payable!==r.payable,`conflicting fallback fragments`,`fragments[${t}]`,e),r=e,i=r.payable);return;case`function`:n=this.#n;break;case`event`:n=this.#t;break;case`error`:n=this.#e;break;default:return}let a=e.format();n.has(a)||n.set(a,e)}),this.deploy||G(this,{deploy:PD.from(`constructor()`)}),G(this,{fallback:r,receive:i})}format(e){let t=e?`minimal`:`full`;return this.fragments.map(e=>e.format(t))}formatJson(){let e=this.fragments.map(e=>e.format(`json`));return JSON.stringify(e.map(e=>JSON.parse(e)))}getAbiCoder(){return WD.defaultAbiCoder()}#i(e,t,n){if(Mv(e)){let t=e.toLowerCase();for(let e of this.#n.values())if(t===e.selector)return e;return null}if(e.indexOf(`(`)===-1){let r=[];for(let[t,n]of this.#n)t.split(`(`)[0]===e&&r.push(n);if(t){let e=t.length>0?t[t.length-1]:null,n=t.length,i=!0;WC.isTyped(e)&&e.type===`overrides`&&(i=!1,n--);for(let e=r.length-1;e>=0;e--){let t=r[e].inputs.length;t!==n&&(!i||t!==n-1)&&r.splice(e,1)}for(let e=r.length-1;e>=0;e--){let n=r[e].inputs;for(let i=0;i<t.length;i++)if(WC.isTyped(t[i])){if(i>=n.length){if(t[i].type===`overrides`)continue;r.splice(e,1);break}if(t[i].type!==n[i].baseType){r.splice(e,1);break}}}}if(r.length===1&&t&&t.length!==r[0].inputs.length){let e=t[t.length-1];(e==null||Array.isArray(e)||typeof e!=`object`)&&r.splice(0,1)}return r.length===0?null:(r.length>1&&n&&q(!1,`ambiguous function description (i.e. matches ${r.map(e=>JSON.stringify(e.format())).join(`, `)})`,`key`,e),r[0])}return this.#n.get(ID.from(e).format())||null}getFunctionName(e){let t=this.#i(e,null,!1);return q(t,`no matching function`,`key`,e),t.name}hasFunction(e){return!!this.#i(e,null,!1)}getFunction(e,t){return this.#i(e,t||null,!0)}forEachFunction(e){let t=Array.from(this.#n.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#n.get(r),n)}}#a(e,t,n){if(Mv(e)){let t=e.toLowerCase();for(let e of this.#t.values())if(t===e.topicHash)return e;return null}if(e.indexOf(`(`)===-1){let r=[];for(let[t,n]of this.#t)t.split(`(`)[0]===e&&r.push(n);if(t){for(let e=r.length-1;e>=0;e--)r[e].inputs.length<t.length&&r.splice(e,1);for(let e=r.length-1;e>=0;e--){let n=r[e].inputs;for(let i=0;i<t.length;i++)if(WC.isTyped(t[i])&&t[i].type!==n[i].baseType){r.splice(e,1);break}}}return r.length===0?null:(r.length>1&&n&&q(!1,`ambiguous event description (i.e. matches ${r.map(e=>JSON.stringify(e.format())).join(`, `)})`,`key`,e),r[0])}return this.#t.get(ND.from(e).format())||null}getEventName(e){let t=this.#a(e,null,!1);return q(t,`no matching event`,`key`,e),t.name}hasEvent(e){return!!this.#a(e,null,!1)}getEvent(e,t){return this.#a(e,t||null,!0)}forEachEvent(e){let t=Array.from(this.#t.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#t.get(r),n)}}getError(e,t){if(Mv(e)){let t=e.toLowerCase();if(XD[t])return MD.from(XD[t].signature);for(let e of this.#e.values())if(t===e.selector)return e;return null}if(e.indexOf(`(`)===-1){let t=[];for(let[n,r]of this.#e)n.split(`(`)[0]===e&&t.push(r);return t.length===0?e===`Error`?MD.from(`error Error(string)`):e===`Panic`?MD.from(`error Panic(uint256)`):null:(t.length>1&&q(!1,`ambiguous error description (i.e. ${t.map(e=>JSON.stringify(e.format())).join(`, `)})`,`name`,e),t[0])}return e=MD.from(e).format(),e===`Error(string)`?MD.from(`error Error(string)`):e===`Panic(uint256)`?MD.from(`error Panic(uint256)`):this.#e.get(e)||null}forEachError(e){let t=Array.from(this.#e.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#e.get(r),n)}}_decodeParams(e,t){return this.#r.decode(e,t)}_encodeParams(e,t){return this.#r.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e==`string`){let t=this.getError(e);q(t,`unknown error`,`fragment`,e),e=t}return q(Lv(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,`data`,t),this._decodeParams(e.inputs,Lv(t,4))}encodeErrorResult(e,t){if(typeof e==`string`){let t=this.getError(e);q(t,`unknown error`,`fragment`,e),e=t}return Fv([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}return q(Lv(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,`data`,t),this._decodeParams(e.inputs,Lv(t,4))}encodeFunctionData(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}return Fv([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}let n=`invalid length for result data`,r=jv(t);if(r.length%32==0)try{return this.#r.decode(e.outputs,r)}catch{n=`could not decode result data`}K(!1,n,`BAD_DATA`,{value:Y(r),info:{method:e.name,signature:e.format()}})}makeError(e,t){let n=J(e,`data`),r=WD.getBuiltinCallException(`call`,t,n);if(r.message.startsWith(`execution reverted (unknown custom error)`)){let e=Y(n.slice(0,4)),t=this.getError(e);if(t)try{let e=this.#r.decode(t.inputs,n.slice(4));r.revert={name:t.name,signature:t.format(),args:e},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch{r.message=`execution reverted (coult not decode custom error)`}}let i=this.parseTransaction(t);return i&&(r.invocation={method:i.name,signature:i.signature,args:i.args}),r}encodeFunctionResult(e,t){if(typeof e==`string`){let t=this.getFunction(e);q(t,`unknown function`,`fragment`,e),e=t}return Y(this.#r.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e==`string`){let t=this.getEvent(e);q(t,`unknown event`,`eventFragment`,e),e=t}K(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,`UNEXPECTED_ARGUMENT`,{count:t.length,expectedCount:e.inputs.length});let n=[];e.anonymous||n.push(e.topicHash);let r=(e,t)=>e.type===`string`?Gw(t):e.type===`bytes`?yx(Y(t)):(e.type===`bool`&&typeof t==`boolean`?t=t?`0x01`:`0x00`:e.type.match(/^u?int/)?t=Zv(t):e.type.match(/^bytes/)?t=Bv(t,32):e.type===`address`&&this.#r.encode([`address`],[t]),zv(Y(t),32));for(t.forEach((t,i)=>{let a=e.inputs[i];if(!a.indexed){q(t==null,`cannot filter non-indexed parameters; must be null`,`contract.`+a.name,t);return}t==null?n.push(null):a.baseType===`array`||a.baseType===`tuple`?q(!1,`filtering with tuples or arrays not supported`,`contract.`+a.name,t):Array.isArray(t)?n.push(t.map(e=>r(a,e))):n.push(r(a,t))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e==`string`){let t=this.getEvent(e);q(t,`unknown event`,`eventFragment`,e),e=t}let n=[],r=[],i=[];return e.anonymous||n.push(e.topicHash),q(t.length===e.inputs.length,`event arguments/values mismatch`,`values`,t),e.inputs.forEach((e,a)=>{let o=t[a];if(e.indexed)if(e.type===`string`)n.push(Gw(o));else if(e.type===`bytes`)n.push(yx(o));else if(e.baseType===`tuple`||e.baseType===`array`)throw Error(`not implemented`);else n.push(this.#r.encode([e.type],[o]));else r.push(e),i.push(o)}),{data:this.#r.encode(r,i),topics:n}}decodeEventLog(e,t,n){if(typeof e==`string`){let t=this.getEvent(e);q(t,`unknown event`,`eventFragment`,e),e=t}if(n!=null&&!e.anonymous){let t=e.topicHash;q(Mv(n[0],32)&&n[0].toLowerCase()===t,`fragment/topic mismatch`,`topics[0]`,n[0]),n=n.slice(1)}let r=[],i=[],a=[];e.inputs.forEach((e,t)=>{e.indexed?e.type===`string`||e.type===`bytes`||e.baseType===`tuple`||e.baseType===`array`?(r.push(OD.from({type:`bytes32`,name:e.name})),a.push(!0)):(r.push(e),a.push(!1)):(i.push(e),a.push(!1))});let o=n==null?null:this.#r.decode(r,Fv(n)),s=this.#r.decode(i,t,!0),c=[],l=[],u=0,d=0;return e.inputs.forEach((e,t)=>{let n=null;if(e.indexed)if(o==null)n=new JD(null);else if(a[t])n=new JD(o[d++]);else try{n=o[d++]}catch(e){n=e}else try{n=s[u++]}catch(e){n=e}c.push(n),l.push(e.name||null)}),Yy.fromItems(c,l)}parseTransaction(e){let t=J(e.data,`tx.data`),n=X(e.value==null?0:e.value,`tx.value`),r=this.getFunction(Y(t.slice(0,4)));if(!r)return null;let i=this.#r.decode(r.inputs,t.slice(4));return new KD(r,r.selector,i,n)}parseCallResult(e){throw Error(`@TODO`)}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new GD(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){let t=Y(e),n=this.getError(Lv(t,0,4));if(!n)return null;let r=this.#r.decode(n.inputs,Lv(t,4));return new qD(n,n.selector,r)}static from(t){return t instanceof e?t:typeof t==`string`?new e(JSON.parse(t)):typeof t.formatJson==`function`?new e(t.formatJson()):typeof t.format==`function`?new e(t.format(`json`)):new e(t)}},QD=BigInt(0);function $D(e){return e??null}function eO(e){return e==null?null:e.toString()}var tO=class{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(e,t,n){G(this,{gasPrice:$D(e),maxFeePerGas:$D(t),maxPriorityFeePerGas:$D(n)})}toJSON(){let{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:`FeeData`,gasPrice:eO(e),maxFeePerGas:eO(t),maxPriorityFeePerGas:eO(n)}}};function nO(e){let t={};e.to&&(t.to=e.to),e.from&&(t.from=e.from),e.data&&(t.data=Y(e.data));let n=`chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value`.split(/,/);for(let r of n)!(r in e)||e[r]==null||(t[r]=X(e[r],`request.${r}`));let r=`type,nonce`.split(/,/);for(let n of r)!(n in e)||e[n]==null||(t[n]=Z(e[n],`request.${n}`));return e.accessList&&(t.accessList=lw(e.accessList)),e.authorizationList&&(t.authorizationList=e.authorizationList.slice()),`blockTag`in e&&(t.blockTag=e.blockTag),`enableCcipRead`in e&&(t.enableCcipRead=!!e.enableCcipRead),`customData`in e&&(t.customData=e.customData),`blobVersionedHashes`in e&&e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.slice()),`kzg`in e&&(t.kzg=e.kzg),`blobWrapperVersion`in e&&(t.blobWrapperVersion=e.blobWrapperVersion),`blobs`in e&&e.blobs&&(t.blobs=e.blobs.map(e=>Nv(e)?Y(e):Object.assign({},e))),t}var rO=class{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#e;constructor(e,t){this.#e=e.transactions.map(e=>typeof e==`string`?e:new oO(e,t)),G(this,{provider:t,hash:$D(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:$D(e.prevRandao),extraData:e.extraData,baseFeePerGas:$D(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return this.#e.map(e=>typeof e==`string`?e:e.hash)}get prefetchedTransactions(){let e=this.#e.slice();return e.length===0?[]:(K(typeof e[0]==`object`,`transactions were not prefetched with block request`,`UNSUPPORTED_OPERATION`,{operation:`transactionResponses()`}),e)}toJSON(){let{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:r,gasUsed:i,hash:a,miner:o,prevRandao:s,nonce:c,number:l,parentHash:u,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:p,timestamp:m,transactions:h}=this;return{_type:`Block`,baseFeePerGas:eO(e),difficulty:eO(t),extraData:n,gasLimit:eO(r),gasUsed:eO(i),blobGasUsed:eO(this.blobGasUsed),excessBlobGas:eO(this.excessBlobGas),hash:a,miner:o,prevRandao:s,nonce:c,number:l,parentHash:u,timestamp:m,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:p,transactions:h}}[Symbol.iterator](){let e=0,t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#e.length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e==`number`)t=this.#e[e];else{let n=e.toLowerCase();for(let e of this.#e)if(typeof e==`string`){if(e!==n)continue;t=e;break}else{if(e.hash!==n)continue;t=e;break}}if(t==null)throw Error(`no such tx`);return typeof t==`string`?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){let t=this.prefetchedTransactions;if(typeof e==`number`)return t[e];e=e.toLowerCase();for(let n of t)if(n.hash===e)return n;q(!1,`no matching transaction`,`indexOrHash`,e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw Error(``);return sO(this)}},iO=class{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(e,t){this.provider=t;let n=Object.freeze(e.topics.slice());G(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){let{address:e,blockHash:t,blockNumber:n,data:r,index:i,removed:a,topics:o,transactionHash:s,transactionIndex:c}=this;return{_type:`log`,address:e,blockHash:t,blockNumber:n,data:r,index:i,removed:a,topics:o,transactionHash:s,transactionIndex:c}}async getBlock(){let e=await this.provider.getBlock(this.blockHash);return K(!!e,`failed to find transaction`,`UNKNOWN_ERROR`,{}),e}async getTransaction(){let e=await this.provider.getTransaction(this.transactionHash);return K(!!e,`failed to find transaction`,`UNKNOWN_ERROR`,{}),e}async getTransactionReceipt(){let e=await this.provider.getTransactionReceipt(this.transactionHash);return K(!!e,`failed to find transaction receipt`,`UNKNOWN_ERROR`,{}),e}removedEvent(){return uO(this)}},aO=class{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#e;constructor(e,t){this.#e=Object.freeze(e.logs.map(e=>new iO(e,t)));let n=QD;e.effectiveGasPrice==null?e.gasPrice!=null&&(n=e.gasPrice):n=e.effectiveGasPrice,G(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return this.#e}toJSON(){let{to:e,from:t,contractAddress:n,hash:r,index:i,blockHash:a,blockNumber:o,logsBloom:s,logs:c,status:l,root:u}=this;return{_type:`TransactionReceipt`,blockHash:a,blockNumber:o,contractAddress:n,cumulativeGasUsed:eO(this.cumulativeGasUsed),from:t,gasPrice:eO(this.gasPrice),blobGasUsed:eO(this.blobGasUsed),blobGasPrice:eO(this.blobGasPrice),gasUsed:eO(this.gasUsed),hash:r,index:i,logs:c,logsBloom:s,root:u,status:l,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){let e=await this.provider.getBlock(this.blockHash);if(e==null)throw Error(`TODO`);return e}async getTransaction(){let e=await this.provider.getTransaction(this.hash);if(e==null)throw Error(`TODO`);return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return lO(this)}reorderedEvent(e){return K(!e||e.isMined(),`unmined 'other' transction cannot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`reorderedEvent(other)`}),cO(this,e)}},oO=class e{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;authorizationList;#e;constructor(e,t){this.provider=t,this.blockNumber=e.blockNumber==null?null:e.blockNumber,this.blockHash=e.blockHash==null?null:e.blockHash,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas==null?null:e.maxPriorityFeePerGas,this.maxFeePerGas=e.maxFeePerGas==null?null:e.maxFeePerGas,this.maxFeePerBlobGas=e.maxFeePerBlobGas==null?null:e.maxFeePerBlobGas,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList==null?null:e.accessList,this.blobVersionedHashes=e.blobVersionedHashes==null?null:e.blobVersionedHashes,this.authorizationList=e.authorizationList==null?null:e.authorizationList,this.#e=-1}toJSON(){let{blockNumber:e,blockHash:t,index:n,hash:r,type:i,to:a,from:o,nonce:s,data:c,signature:l,accessList:u,blobVersionedHashes:d}=this;return{_type:`TransactionResponse`,accessList:u,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:eO(this.chainId),data:c,from:o,gasLimit:eO(this.gasLimit),gasPrice:eO(this.gasPrice),hash:r,maxFeePerGas:eO(this.maxFeePerGas),maxPriorityFeePerGas:eO(this.maxPriorityFeePerGas),maxFeePerBlobGas:eO(this.maxFeePerBlobGas),nonce:s,signature:l,to:a,index:n,type:i,value:eO(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){let t=await this.getTransaction();t&&(e=t.blockNumber)}if(e==null)return null;let t=this.provider.getBlock(e);if(t==null)throw Error(`TODO`);return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){let{tx:e,blockNumber:t}=await xv({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:t-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){let n=e??1,r=t??0,i=this.#e,a=-1,o=i===-1,s=async()=>{if(o)return null;let{blockNumber:e,nonce:t}=await xv({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(t<this.nonce){i=e;return}if(o)return null;let r=await this.getTransaction();if(!(r&&r.blockNumber!=null))for(a===-1&&(a=i-3,a<this.#e&&(a=this.#e));a<=e;){if(o)return null;let t=await this.provider.getBlock(a,!0);if(t==null)return;for(let e of t)if(e===this.hash)return;for(let r=0;r<t.length;r++){let a=await t.getTransaction(r);if(a.from===this.from&&a.nonce===this.nonce){if(o)return null;let t=await this.provider.getTransactionReceipt(a.hash);if(t==null||e-t.blockNumber+1<n)return;let r=`replaced`;a.data===this.data&&a.to===this.to&&a.value===this.value?r=`repriced`:a.data===`0x`&&a.from===a.to&&a.value===QD&&(r=`cancelled`),K(!1,`transaction was replaced`,`TRANSACTION_REPLACED`,{cancelled:r===`replaced`||r===`cancelled`,reason:r,replacement:a.replaceableTransaction(i),hash:a.hash,receipt:t})}}a++}},c=e=>{if(e==null||e.status!==0)return e;K(!1,`transaction execution reverted`,`CALL_EXCEPTION`,{action:`sendTransaction`,data:null,reason:null,invocation:null,revert:null,transaction:{to:e.to,from:e.from,data:``},receipt:e})},l=await this.provider.getTransactionReceipt(this.hash);if(n===0)return c(l);if(l){if(n===1||await l.confirmations()>=n)return c(l)}else if(await s(),n===0)return null;return await new Promise((e,t)=>{let a=[],l=()=>{a.forEach(e=>e())};if(a.push(()=>{o=!0}),r>0){let e=setTimeout(()=>{l(),t(Tv(`wait for transaction timeout`,`TIMEOUT`))},r);a.push(()=>{clearTimeout(e)})}let u=async r=>{if(await r.confirmations()>=n){l();try{e(c(r))}catch(e){t(e)}}};if(a.push(()=>{this.provider.off(this.hash,u)}),this.provider.on(this.hash,u),i>=0){let e=async()=>{try{await s()}catch(e){if(Cv(e,`TRANSACTION_REPLACED`)){l(),t(e);return}}o||this.provider.once(`block`,e)};a.push(()=>{this.provider.off(`block`,e)}),this.provider.once(`block`,e)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return K(this.isMined(),`unmined transaction canot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`removeEvent()`}),lO(this)}reorderedEvent(e){return K(this.isMined(),`unmined transaction canot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`removeEvent()`}),K(!e||e.isMined(),`unmined 'other' transaction canot be orphaned`,`UNSUPPORTED_OPERATION`,{operation:`removeEvent()`}),cO(this,e)}replaceableTransaction(t){q(Number.isInteger(t)&&t>=0,`invalid startBlock`,`startBlock`,t);let n=new e(this,this.provider);return n.#e=t,n}};function sO(e){return{orphan:`drop-block`,hash:e.hash,number:e.number}}function cO(e,t){return{orphan:`reorder-transaction`,tx:e,other:t}}function lO(e){return{orphan:`drop-transaction`,tx:e}}function uO(e){return{orphan:`drop-log`,log:{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,address:e.address,data:e.data,topics:Object.freeze(e.topics.slice()),index:e.index}}}var dO=class extends iO{interface;fragment;args;constructor(e,t,n){super(e,e.provider);let r=t.decodeEventLog(n,e.data,e.topics);G(this,{args:r,fragment:n,interface:t})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}},fO=class extends iO{error;constructor(e,t){super(e,e.provider),G(this,{error:t})}},pO=class extends aO{#e;constructor(e,t,n){super(n,t),this.#e=e}get logs(){return super.logs.map(e=>{let t=e.topics.length?this.#e.getEvent(e.topics[0]):null;if(t)try{return new dO(e,this.#e,t)}catch(t){return new fO(e,t)}return e})}},mO=class extends oO{#e;constructor(e,t,n){super(n,t),this.#e=e}async wait(e,t){let n=await super.wait(e,t);return n==null?null:new pO(this.#e,this.provider,n)}},hO=class extends ay{log;constructor(e,t,n,r){super(e,t,n),G(this,{log:r})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}},gO=class extends hO{constructor(e,t,n,r,i){super(e,t,n,new dO(i,e.interface,r));let a=e.interface.decodeEventLog(r,this.log.data,this.log.topics);G(this,{args:a,fragment:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}},_O=BigInt(0);function vO(e){return e&&typeof e.call==`function`}function yO(e){return e&&typeof e.estimateGas==`function`}function bO(e){return e&&typeof e.resolveName==`function`}function xO(e){return e&&typeof e.sendTransaction==`function`}function SO(e){if(e!=null){if(bO(e))return e;if(e.provider)return e.provider}}var CO=class{#e;fragment;constructor(e,t,n){if(G(this,{fragment:t}),t.inputs.length<n.length)throw Error(`too many arguments`);let r=wO(e.runner,`resolveName`),i=bO(r)?r:null;this.#e=(async function(){let r=await Promise.all(t.inputs.map((e,t)=>n[t]==null?null:e.walkAsync(n[t],(e,t)=>e===`address`?Array.isArray(t)?Promise.all(t.map(e=>BC(e,i))):BC(t,i):t)));return e.interface.encodeFilterTopics(t,r)})()}getTopicFilter(){return this.#e}};function wO(e,t){return e==null?null:typeof e[t]==`function`?e:e.provider&&typeof e.provider[t]==`function`?e.provider:null}function TO(e){return e==null?null:e.provider||null}async function EO(e,t){let n=WC.dereference(e,`overrides`);q(typeof n==`object`,`invalid overrides parameter`,`overrides`,e);let r=nO(n);return q(r.to==null||(t||[]).indexOf(`to`)>=0,`cannot override to`,`overrides.to`,r.to),q(r.data==null||(t||[]).indexOf(`data`)>=0,`cannot override data`,`overrides.data`,r.data),r.from&&=r.from,r}async function DO(e,t,n){let r=wO(e,`resolveName`),i=bO(r)?r:null;return await Promise.all(t.map((e,t)=>e.walkAsync(n[t],(e,t)=>(t=WC.dereference(t,e),e===`address`?BC(t,i):t))))}function OO(e){let t=async function(t){let n=await EO(t,[`data`]);n.to=await e.getAddress(),n.from&&=await BC(n.from,SO(e.runner));let r=e.interface,i=X(n.value||_O,`overrides.value`)===_O,a=(n.data||`0x`)===`0x`;return r.fallback&&!r.fallback.payable&&r.receive&&!a&&!i&&q(!1,`cannot send data to receive or send value to non-payable fallback`,`overrides`,t),q(r.fallback||a,`cannot send data to receive-only contract`,`overrides.data`,n.data),q(r.receive||r.fallback&&r.fallback.payable||i,`cannot send value to non-payable fallback`,`overrides.value`,n.value),q(r.fallback||a,`cannot send data to receive-only contract`,`overrides.data`,n.data),n},n=async function(n){let r=wO(e.runner,`call`);K(vO(r),`contract runner does not support calling`,`UNSUPPORTED_OPERATION`,{operation:`call`});let i=await t(n);try{return await r.call(i)}catch(t){throw wv(t)&&t.data?e.interface.makeError(t.data,i):t}},r=async function(n){let r=e.runner;K(xO(r),`contract runner does not support sending transactions`,`UNSUPPORTED_OPERATION`,{operation:`sendTransaction`});let i=await r.sendTransaction(await t(n)),a=TO(e.runner);return new mO(e.interface,a,i)},i=async function(n){let r=wO(e.runner,`estimateGas`);return K(yO(r),`contract runner does not support gas estimation`,`UNSUPPORTED_OPERATION`,{operation:`estimateGas`}),await r.estimateGas(await t(n))},a=async e=>await r(e);return G(a,{_contract:e,estimateGas:i,populateTransaction:t,send:r,staticCall:n}),a}function kO(e,t){let n=function(...n){let r=e.interface.getFunction(t,n);return K(r,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t,args:n}}),r},r=async function(...t){let r=n(...t),i={};if(r.inputs.length+1===t.length&&(i=await EO(t.pop()),i.from&&=await BC(i.from,SO(e.runner))),r.inputs.length!==t.length)throw Error(`internal error: fragment inputs doesn't match arguments; should not happen`);let a=await DO(e.runner,r.inputs,t);return Object.assign({},i,await xv({to:e.getAddress(),data:e.interface.encodeFunctionData(r,a)}))},i=async function(...e){let t=await s(...e);return t.length===1?t[0]:t},a=async function(...t){let n=e.runner;K(xO(n),`contract runner does not support sending transactions`,`UNSUPPORTED_OPERATION`,{operation:`sendTransaction`});let i=await n.sendTransaction(await r(...t)),a=TO(e.runner);return new mO(e.interface,a,i)},o=async function(...t){let n=wO(e.runner,`estimateGas`);return K(yO(n),`contract runner does not support gas estimation`,`UNSUPPORTED_OPERATION`,{operation:`estimateGas`}),await n.estimateGas(await r(...t))},s=async function(...t){let i=wO(e.runner,`call`);K(vO(i),`contract runner does not support calling`,`UNSUPPORTED_OPERATION`,{operation:`call`});let a=await r(...t),o=`0x`;try{o=await i.call(a)}catch(t){throw wv(t)&&t.data?e.interface.makeError(t.data,a):t}let s=n(...t);return e.interface.decodeFunctionResult(s,o)},c=async(...e)=>n(...e).constant?await i(...e):await a(...e);return G(c,{name:e.interface.getFunctionName(t),_contract:e,_key:t,getFragment:n,estimateGas:o,populateTransaction:r,send:a,staticCall:i,staticCallResult:s}),Object.defineProperty(c,`fragment`,{configurable:!1,enumerable:!0,get:()=>{let n=e.interface.getFunction(t);return K(n,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t}}),n}}),c}function AO(e,t){let n=function(...n){let r=e.interface.getEvent(t,n);return K(r,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t,args:n}}),r},r=function(...t){return new CO(e,n(...t),t)};return G(r,{name:e.interface.getEventName(t),_contract:e,_key:t,getFragment:n}),Object.defineProperty(r,`fragment`,{configurable:!1,enumerable:!0,get:()=>{let n=e.interface.getEvent(t);return K(n,`no matching fragment`,`UNSUPPORTED_OPERATION`,{operation:`fragment`,info:{key:t}}),n}}),r}var jO=Symbol.for(`_ethersInternal_contract`),MO=new WeakMap;function NO(e,t){MO.set(e[jO],t)}function PO(e){return MO.get(e[jO])}function FO(e){return e&&typeof e==`object`&&`getTopicFilter`in e&&typeof e.getTopicFilter==`function`&&e.fragment}async function IO(e,t){let n,r=null;if(Array.isArray(t)){let r=function(t){if(Mv(t,32))return t;let n=e.interface.getEvent(t);return q(n,`unknown fragment`,`name`,t),n.topicHash};n=t.map(e=>e==null?null:Array.isArray(e)?e.map(r):r(e))}else t===`*`?n=[null]:typeof t==`string`?Mv(t,32)?n=[t]:(r=e.interface.getEvent(t),q(r,`unknown fragment`,`event`,t),n=[r.topicHash]):FO(t)?n=await t.getTopicFilter():`fragment`in t?(r=t.fragment,n=[r.topicHash]):q(!1,`unknown event name`,`event`,t);n=n.map(e=>{if(e==null)return null;if(Array.isArray(e)){let t=Array.from(new Set(e.map(e=>e.toLowerCase())).values());return t.length===1?t[0]:(t.sort(),t)}return e.toLowerCase()});let i=n.map(e=>e==null?`null`:Array.isArray(e)?e.join(`|`):e).join(`&`);return{fragment:r,tag:i,topics:n}}async function LO(e,t){let{subs:n}=PO(e);return n.get((await IO(e,t)).tag)||null}async function RO(e,t,n){let r=TO(e.runner);K(r,`contract runner does not support subscribing`,`UNSUPPORTED_OPERATION`,{operation:t});let{fragment:i,tag:a,topics:o}=await IO(e,n),{addr:s,subs:c}=PO(e),l=c.get(a);if(!l){let t={address:s||e,topics:o},u=t=>{let r=i;if(r==null)try{r=e.interface.getEvent(t.topics[0])}catch{}if(r){let a=r;VO(e,n,i?e.interface.decodeEventLog(i,t.data,t.topics):[],r=>new gO(e,r,n,a,t))}else VO(e,n,[],r=>new hO(e,r,n,t))},d=[];l={tag:a,listeners:[],start:()=>{d.length||d.push(r.on(t,u))},stop:async()=>{if(d.length==0)return;let e=d;d=[],await Promise.all(e),r.off(t,u)}},c.set(a,l)}return l}var zO=Promise.resolve();async function BO(e,t,n,r){await zO;let i=await LO(e,t);if(!i)return!1;let a=i.listeners.length;return i.listeners=i.listeners.filter(({listener:t,once:i})=>{let a=Array.from(n);r&&a.push(r(i?null:t));try{t.call(e,...a)}catch{}return!i}),i.listeners.length===0&&(i.stop(),PO(e).subs.delete(i.tag)),a>0}async function VO(e,t,n,r){try{await zO}catch{}let i=BO(e,t,n,r);return zO=i,await i}var HO=[`then`],UO=class e{target;interface;runner;filters;[jO];fallback;constructor(e,t,n,r){q(typeof e==`string`||RC(e),`invalid value for Contract target`,`target`,e),n??=null;let i=ZD.from(t);G(this,{target:e,runner:n,interface:i}),Object.defineProperty(this,jO,{value:{}});let a,o=null,s=null;if(r){let e=TO(n);s=new mO(this.interface,e,r)}let c=new Map;if(typeof e==`string`)if(Mv(e))o=e,a=Promise.resolve(e);else{let t=wO(n,`resolveName`);if(!bO(t))throw Tv(`contract runner does not support name resolution`,`UNSUPPORTED_OPERATION`,{operation:`resolveName`});a=t.resolveName(e).then(t=>{if(t==null)throw Tv(`an ENS name used for a contract target must be correctly configured`,`UNCONFIGURED_NAME`,{value:e});return PO(this).addr=t,t})}else a=e.getAddress().then(e=>{if(e==null)throw Error(`TODO`);return PO(this).addr=e,e});NO(this,{addrPromise:a,addr:o,deployTx:s,subs:c});let l=new Proxy({},{get:(e,t,n)=>{if(typeof t==`symbol`||HO.indexOf(t)>=0)return Reflect.get(e,t,n);try{return this.getEvent(t)}catch(e){if(!Cv(e,`INVALID_ARGUMENT`)||e.argument!==`key`)throw e}},has:(e,t)=>HO.indexOf(t)>=0?Reflect.has(e,t):Reflect.has(e,t)||this.interface.hasEvent(String(t))});return G(this,{filters:l}),G(this,{fallback:i.receive||i.fallback?OO(this):null}),new Proxy(this,{get:(e,t,n)=>{if(typeof t==`symbol`||t in e||HO.indexOf(t)>=0)return Reflect.get(e,t,n);try{return e.getFunction(t)}catch(e){if(!Cv(e,`INVALID_ARGUMENT`)||e.argument!==`key`)throw e}},has:(e,t)=>typeof t==`symbol`||t in e||HO.indexOf(t)>=0?Reflect.has(e,t):e.interface.hasFunction(t)})}connect(t){return new e(this.target,this.interface,t)}attach(t){return new e(t,this.interface,this.runner)}async getAddress(){return await PO(this).addrPromise}async getDeployedCode(){let e=TO(this.runner);K(e,`runner does not support .provider`,`UNSUPPORTED_OPERATION`,{operation:`getDeployedCode`});let t=await e.getCode(await this.getAddress());return t===`0x`?null:t}async waitForDeployment(){let e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;let t=TO(this.runner);return K(t!=null,`contract runner does not support .provider`,`UNSUPPORTED_OPERATION`,{operation:`waitForDeployment`}),new Promise((e,n)=>{let r=async()=>{try{if(await this.getDeployedCode()!=null)return e(this);t.once(`block`,r)}catch(e){n(e)}};r()})}deploymentTransaction(){return PO(this).deployTx}getFunction(e){return typeof e!=`string`&&(e=e.format()),kO(this,e)}getEvent(e){return typeof e!=`string`&&(e=e.format()),AO(this,e)}async queryTransaction(e){throw Error(`@TODO`)}async queryFilter(e,t,n){t??=0,n??=`latest`;let{addr:r,addrPromise:i}=PO(this),a=r||await i,{fragment:o,topics:s}=await IO(this,e),c={address:a,topics:s,fromBlock:t,toBlock:n},l=TO(this.runner);return K(l,`contract runner does not have a provider`,`UNSUPPORTED_OPERATION`,{operation:`queryFilter`}),(await l.getLogs(c)).map(e=>{let t=o;if(t==null)try{t=this.interface.getEvent(e.topics[0])}catch{}if(t)try{return new dO(e,this.interface,t)}catch(t){return new fO(e,t)}return new iO(e,l)})}async on(e,t){let n=await RO(this,`on`,e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){let n=await RO(this,`once`,e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await VO(this,e,t,null)}async listenerCount(e){if(e){let t=await LO(this,e);return t?t.listeners.length:0}let{subs:t}=PO(this),n=0;for(let{listeners:e}of t.values())n+=e.length;return n}async listeners(e){if(e){let t=await LO(this,e);return t?t.listeners.map(({listener:e})=>e):[]}let{subs:t}=PO(this),n=[];for(let{listeners:e}of t.values())n=n.concat(e.map(({listener:e})=>e));return n}async off(e,t){let n=await LO(this,e);if(!n)return this;if(t){let e=n.listeners.map(({listener:e})=>e).indexOf(t);e>=0&&n.listeners.splice(e,1)}return(t==null||n.listeners.length===0)&&(n.stop(),PO(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){let t=await LO(this,e);if(!t)return this;t.stop(),PO(this).subs.delete(t.tag)}else{let{subs:e}=PO(this);for(let{tag:t,stop:n}of e.values())n(),e.delete(t)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(t){class n extends e{constructor(e,n=null){super(e,t,n)}}return n}static from(e,t,n){return n??=null,new this(e,t,n)}};function WO(){return UO}var GO=class extends WO(){};function KO(e){return e.match(/^ipfs:\/\/ipfs\//i)?e=e.substring(12):e.match(/^ipfs:\/\//i)?e=e.substring(7):q(!1,`unsupported IPFS format`,`link`,e),`https:/\/gateway.ipfs.io/ipfs/${e}`}var qO=class{name;constructor(e){G(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw Error(`unsupported coin`)}async decodeAddress(e,t){throw Error(`unsupported coin`)}},JO=RegExp(`^(ipfs)://(.*)$`,`i`),YO=[RegExp(`^(https)://(.*)$`,`i`),RegExp(`^(data):(.*)$`,`i`),JO,RegExp(`^eip155:[0-9]+/(erc[0-9]+):(.*)$`,`i`)],XO=class e{provider;address;name;#e;#t;constructor(e,t,n){G(this,{provider:e,address:t,name:n}),this.#e=null,this.#t=new GO(t,[`function supportsInterface(bytes4) view returns (bool)`,`function resolve(bytes, bytes) view returns (bytes)`,`function addr(bytes32) view returns (address)`,`function addr(bytes32, uint) view returns (bytes)`,`function text(bytes32, string) view returns (string)`,`function contenthash(bytes32) view returns (bytes)`],e)}async supportsWildcard(){return this.#e??=(async()=>{try{return await this.#t.supportsInterface(`0x9061b923`)}catch(e){if(Cv(e,`CALL_EXCEPTION`))return!1;throw this.#e=null,e}})(),await this.#e}async#n(e,t){t=(t||[]).slice();let n=this.#t.interface;t.unshift(kE(this.name));let r=null;await this.supportsWildcard()&&(r=n.getFunction(e),K(r,`missing fragment`,`UNKNOWN_ERROR`,{info:{funcName:e}}),t=[AE(this.name,255),n.encodeFunctionData(r,t)],e=`resolve(bytes,bytes)`),t.push({enableCcipRead:!0});try{let i=await this.#t[e](...t);return r?n.decodeFunctionResult(r,i)[0]:i}catch(e){if(!Cv(e,`CALL_EXCEPTION`))throw e}return null}async getAddress(e){if(e??=60,e===60)try{let e=await this.#n(`addr(bytes32)`);return e==null||e===`0x0000000000000000000000000000000000000000`?null:e}catch(e){if(Cv(e,`CALL_EXCEPTION`))return null;throw e}if(e>=0&&e<2147483648){let t=e+2147483648,n=await this.#n(`addr(bytes32,uint)`,[t]);if(Mv(n,20))return IC(n)}let t=null;for(let n of this.provider.plugins)if(n instanceof qO&&n.supportsCoinType(e)){t=n;break}if(t==null)return null;let n=await this.#n(`addr(bytes32,uint)`,[e]);if(n==null||n===`0x`)return null;let r=await t.decodeAddress(e,n);if(r!=null)return r;K(!1,`invalid coin data`,`UNSUPPORTED_OPERATION`,{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){let t=await this.#n(`text(bytes32,string)`,[e]);return t==null||t===`0x`?null:t}async getContentHash(){let e=await this.#n(`contenthash(bytes32)`);if(e==null||e===`0x`)return null;let t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){let e=t[1]===`e3010170`?`ipfs`:`ipns`,n=parseInt(t[4],16);if(t[5].length===n*2)return`${e}:/\/${ny(`0x`+t[2])}`}let n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz:/\/${n[1]}`;K(!1,`invalid or unsupported content hash data`,`UNSUPPORTED_OPERATION`,{operation:`getContentHash()`,info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){let e=[{type:`name`,value:this.name}];try{let t=await this.getText(`avatar`);if(t==null)return e.push({type:`!avatar`,value:``}),{url:null,linkage:e};e.push({type:`avatar`,value:t});for(let n=0;n<YO.length;n++){let r=t.match(YO[n]);if(r==null)continue;let i=r[1].toLowerCase();switch(i){case`https`:case`data`:return e.push({type:`url`,value:t}),{linkage:e,url:t};case`ipfs`:{let n=KO(t);return e.push({type:`ipfs`,value:t}),e.push({type:`url`,value:n}),{linkage:e,url:n}}case`erc721`:case`erc1155`:{let n=i===`erc721`?`tokenURI(uint256)`:`uri(uint256)`;e.push({type:i,value:t});let a=await this.getAddress();if(a==null)return e.push({type:`!owner`,value:``}),{url:null,linkage:e};let o=(r[2]||``).split(`/`);if(o.length!==2)return e.push({type:`!${i}caip`,value:r[2]||``}),{url:null,linkage:e};let s=o[1],c=new GO(o[0],[`function tokenURI(uint) view returns (string)`,`function ownerOf(uint) view returns (address)`,`function uri(uint) view returns (string)`,`function balanceOf(address, uint256) view returns (uint)`],this.provider);if(i===`erc721`){let t=await c.ownerOf(s);if(a!==t)return e.push({type:`!owner`,value:t}),{url:null,linkage:e};e.push({type:`owner`,value:t})}else if(i===`erc1155`){let t=await c.balanceOf(a,s);if(!t)return e.push({type:`!balance`,value:`0`}),{url:null,linkage:e};e.push({type:`balance`,value:t.toString()})}let l=await c[n](s);if(l==null||l===`0x`)return e.push({type:`!metadata-url`,value:``}),{url:null,linkage:e};e.push({type:`metadata-url-base`,value:l}),i===`erc1155`&&(l=l.replace(`{id}`,Zv(s,32).substring(2)),e.push({type:`metadata-url-expanded`,value:l})),l.match(/^ipfs:/i)&&(l=KO(l)),e.push({type:`metadata-url`,value:l});let u={},d=await new Dy(l).send();d.assertOk();try{u=d.bodyJson}catch{try{e.push({type:`!metadata`,value:d.bodyText})}catch{let t=d.body;return t&&e.push({type:`!metadata`,value:Y(t)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!u)return e.push({type:`!metadata`,value:``}),{url:null,linkage:e};e.push({type:`metadata`,value:JSON.stringify(u)});let f=u.image;if(typeof f!=`string`)return e.push({type:`!imageUrl`,value:``}),{url:null,linkage:e};if(!f.match(/^(https:\/\/|data:)/i)){if(f.match(JO)==null)return e.push({type:`!imageUrl-ipfs`,value:f}),{url:null,linkage:e};e.push({type:`imageUrl-ipfs`,value:f}),f=KO(f)}return e.push({type:`url`,value:f}),{linkage:e,url:f}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){let t=await e.getNetwork(),n=t.getPlugin(`org.ethers.plugins.network.Ens`);return K(n,`network does not support ENS`,`UNSUPPORTED_OPERATION`,{operation:`getEnsAddress`,info:{network:t}}),n.address}static async#r(t,n){let r=await e.getEnsAddress(t);try{let e=await new GO(r,[`function resolver(bytes32) view returns (address)`],t).resolver(kE(n),{enableCcipRead:!0});return e===`0x0000000000000000000000000000000000000000`?null:e}catch(e){throw e}return null}static async fromName(t,n){let r=n;for(;;){if(r===``||r===`.`||n!==`eth`&&r===`eth`)return null;let i=await e.#r(t,r);if(i!=null){let a=new e(t,i,n);return r!==n&&!await a.supportsWildcard()?null:a}r=r.split(`.`).slice(1).join(`.`)}}},ZO=BigInt(0);function QO(e,t){return(function(n){return n==null?t:e(n)})}function $O(e,t){return(n=>{if(t&&n==null)return null;if(!Array.isArray(n))throw Error(`not an array`);return n.map(t=>e(t))})}function ek(e,t){return(n=>{let r={};for(let i in e){let a=i;if(t&&i in t&&!(a in n)){for(let e of t[i])if(e in n){a=e;break}}try{let t=e[i](n[a]);t!==void 0&&(r[i]=t)}catch(e){K(!1,`invalid value for value.${i} (${e instanceof Error?e.message:`not-an-error`})`,`BAD_DATA`,{value:n})}}return r})}function tk(e){switch(e){case!0:case`true`:return!0;case!1:case`false`:return!1}q(!1,`invalid boolean; ${JSON.stringify(e)}`,`value`,e)}function nk(e){return q(Mv(e,!0),`invalid data`,`value`,e),e}function rk(e){return q(Mv(e,32),`invalid hash`,`value`,e),e}var ik=ek({address:IC,blockHash:rk,blockNumber:Z,data:nk,index:Z,removed:QO(tk,!1),topics:$O(rk),transactionHash:rk,transactionIndex:Z},{index:[`logIndex`]});function ak(e){return ik(e)}var ok=ek({hash:QO(rk),parentHash:rk,parentBeaconBlockRoot:QO(rk,null),number:Z,timestamp:Z,nonce:QO(nk),difficulty:X,gasLimit:X,gasUsed:X,stateRoot:QO(rk,null),receiptsRoot:QO(rk,null),blobGasUsed:QO(X,null),excessBlobGas:QO(X,null),miner:QO(IC),prevRandao:QO(rk,null),extraData:nk,baseFeePerGas:QO(X)},{prevRandao:[`mixHash`]});function sk(e){let t=ok(e);return t.transactions=e.transactions.map(e=>typeof e==`string`?e:fk(e)),t}var ck=ek({transactionIndex:Z,blockNumber:Z,transactionHash:rk,address:IC,topics:$O(rk),data:nk,index:Z,blockHash:rk},{index:[`logIndex`]});function lk(e){return ck(e)}var uk=ek({to:QO(IC,null),from:QO(IC,null),contractAddress:QO(IC,null),index:Z,root:QO(Y),gasUsed:X,blobGasUsed:QO(X,null),logsBloom:QO(nk),blockHash:rk,hash:rk,logs:$O(lk),blockNumber:Z,cumulativeGasUsed:X,effectiveGasPrice:QO(X),blobGasPrice:QO(X,null),status:QO(Z),type:QO(Z,0)},{effectiveGasPrice:[`gasPrice`],hash:[`transactionHash`],index:[`transactionIndex`]});function dk(e){return uk(e)}function fk(e){e.to&&X(e.to)===ZO&&(e.to=`0x0000000000000000000000000000000000000000`);let t=ek({hash:rk,index:QO(Z,void 0),type:e=>e===`0x`||e==null?0:Z(e),accessList:QO(lw,null),blobVersionedHashes:QO($O(rk,!0),null),authorizationList:QO($O(e=>{let t;if(e.signature)t=e.signature;else{let n=e.yParity;n===`0x1b`?n=0:n===`0x1c`&&(n=1),t=Object.assign({},e,{yParity:n})}return{address:IC(e.address),chainId:X(e.chainId),nonce:X(e.nonce),signature:EC.from(t)}},!1),null),blockHash:QO(rk,null),blockNumber:QO(Z,null),transactionIndex:QO(Z,null),from:IC,gasPrice:QO(X),maxPriorityFeePerGas:QO(X),maxFeePerGas:QO(X),maxFeePerBlobGas:QO(X,null),gasLimit:X,to:QO(IC,null),value:X,nonce:Z,data:nk,creates:QO(IC,null),chainId:QO(X,null)},{data:[`input`],gasLimit:[`gas`],index:[`transactionIndex`]})(e);if(t.to==null&&t.creates==null&&(t.creates=LC(t)),(e.type===1||e.type===2)&&e.accessList==null&&(t.accessList=[]),e.signature?t.signature=EC.from(e.signature):t.signature=EC.from(e),t.chainId==null){let e=t.signature.legacyChainId;e!=null&&(t.chainId=e)}return t.blockHash&&X(t.blockHash)===ZO&&(t.blockHash=null),t}var pk=`0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e`,mk=class e{name;constructor(e){G(this,{name:e})}clone(){return new e(this.name)}},hk=class e extends mk{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(e,t){e??=0,super(`org.ethers.network.plugins.GasCost#${e||0}`);let n={effectiveBlock:e};function r(e,r){let i=(t||{})[e];i??=r,q(typeof i==`number`,`invalud value for ${e}`,`costs`,t),n[e]=i}r(`txBase`,21e3),r(`txCreate`,32e3),r(`txDataZero`,4),r(`txDataNonzero`,16),r(`txAccessListStorageKey`,1900),r(`txAccessListAddress`,2400),G(this,n)}clone(){return new e(this.effectiveBlock,this)}},gk=class e extends mk{address;targetNetwork;constructor(e,t){super(`org.ethers.plugins.network.Ens`),G(this,{address:e||pk,targetNetwork:t??1})}clone(){return new e(this.address,this.targetNetwork)}},_k=class extends mk{#e;#t;get url(){return this.#e}get processFunc(){return this.#t}constructor(e,t){super(`org.ethers.plugins.network.FetchUrlFeeDataPlugin`),this.#e=e,this.#t=t}clone(){return this}},vk=new Map,yk=class e{#e;#t;#n;constructor(e,t){this.#e=e,this.#t=X(t),this.#n=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#e}set name(e){this.#e=e}get chainId(){return this.#t}set chainId(e){this.#t=X(e,`chainId`)}matches(e){if(e==null)return!1;if(typeof e==`string`){try{return this.chainId===X(e)}catch{}return this.name===e}if(typeof e==`number`||typeof e==`bigint`){try{return this.chainId===X(e)}catch{}return!1}if(typeof e==`object`){if(e.chainId!=null){try{return this.chainId===X(e.chainId)}catch{}return!1}return e.name==null?!1:this.name===e.name}return!1}get plugins(){return Array.from(this.#n.values())}attachPlugin(e){if(this.#n.get(e.name))throw Error(`cannot replace existing plugin: ${e.name} `);return this.#n.set(e.name,e.clone()),this}getPlugin(e){return this.#n.get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split(`#`)[0]===e)}clone(){let t=new e(this.name,this.chainId);return this.plugins.forEach(e=>{t.attachPlugin(e.clone())}),t}computeIntrinsicGas(e){let t=this.getPlugin(`org.ethers.plugins.network.GasCost`)||new hk,n=t.txBase;if(e.to??(n+=t.txCreate),e.data)for(let r=2;r<e.data.length;r+=2)e.data.substring(r,r+2)===`00`?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){let r=lw(e.accessList);for(let e in r)n+=t.txAccessListAddress+t.txAccessListStorageKey*r[e].storageKeys.length}return n}static from(t){if(Ck(),t==null)return e.from(`mainnet`);if(typeof t==`number`&&(t=BigInt(t)),typeof t==`string`||typeof t==`bigint`){let n=vk.get(t);if(n)return n();if(typeof t==`bigint`)return new e(`unknown`,t);q(!1,`unknown network`,`network`,t)}if(typeof t.clone==`function`)return t.clone();if(typeof t==`object`){q(typeof t.name==`string`&&typeof t.chainId==`number`,`invalid network object name or chainId`,`network`,t);let n=new e(t.name,t.chainId);return(t.ensAddress||t.ensNetwork!=null)&&n.attachPlugin(new gk(t.ensAddress,t.ensNetwork)),n}q(!1,`invalid network`,`network`,t)}static register(e,t){typeof e==`number`&&(e=BigInt(e));let n=vk.get(e);n&&q(!1,`conflicting network for ${JSON.stringify(n.name)}`,`nameOrChainId`,e),vk.set(e,t)}};function bk(e,t){let n=String(e);if(!n.match(/^[0-9.]+$/))throw Error(`invalid gwei value: ${e}`);let r=n.split(`.`);if(r.length===1&&r.push(``),r.length!==2)throw Error(`invalid gwei value: ${e}`);for(;r[1].length<t;)r[1]+=`0`;if(r[1].length>9){let e=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||e++,r[1]=e.toString()}return BigInt(r[0]+r[1])}function xk(e){return new _k(e,async(e,t,n)=>{n.setHeader(`User-Agent`,`ethers`);let r;try{let[t,i]=await Promise.all([n.send(),e()]);r=t;let a=r.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:bk(a.maxFee,9),maxPriorityFeePerGas:bk(a.maxPriorityFee,9)}}catch(e){K(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,`SERVER_ERROR`,{request:n,response:r,error:e})}})}var Sk=!1;function Ck(){if(Sk)return;Sk=!0;function e(e,t,n){let r=function(){let r=new yk(e,t);return n.ensNetwork!=null&&r.attachPlugin(new gk(null,n.ensNetwork)),r.attachPlugin(new hk),(n.plugins||[]).forEach(e=>{r.attachPlugin(e)}),r};yk.register(e,r),yk.register(t,r),n.altNames&&n.altNames.forEach(e=>{yk.register(e,r)})}e(`mainnet`,1,{ensNetwork:1,altNames:[`homestead`]}),e(`ropsten`,3,{ensNetwork:3}),e(`rinkeby`,4,{ensNetwork:4}),e(`goerli`,5,{ensNetwork:5}),e(`kovan`,42,{ensNetwork:42}),e(`sepolia`,11155111,{ensNetwork:11155111}),e(`holesky`,17e3,{ensNetwork:17e3}),e(`classic`,61,{}),e(`classicKotti`,6,{}),e(`arbitrum`,42161,{ensNetwork:1}),e(`arbitrum-goerli`,421613,{}),e(`arbitrum-sepolia`,421614,{}),e(`base`,8453,{ensNetwork:1}),e(`base-goerli`,84531,{}),e(`base-sepolia`,84532,{}),e(`bnb`,56,{ensNetwork:1}),e(`bnbt`,97,{}),e(`filecoin`,314,{}),e(`filecoin-calibration`,314159,{}),e(`linea`,59144,{ensNetwork:1}),e(`linea-goerli`,59140,{}),e(`linea-sepolia`,59141,{}),e(`matic`,137,{ensNetwork:1,plugins:[xk(`https://gasstation.polygon.technology/v2`)]}),e(`matic-amoy`,80002,{}),e(`matic-mumbai`,80001,{altNames:[`maticMumbai`,`maticmum`],plugins:[xk(`https://gasstation-testnet.polygon.technology/v2`)]}),e(`optimism`,10,{ensNetwork:1,plugins:[]}),e(`optimism-goerli`,420,{}),e(`optimism-sepolia`,11155420,{}),e(`xdai`,100,{ensNetwork:1})}function wk(e){return JSON.parse(JSON.stringify(e))}var Tk=class{#e;#t;#n;#r;constructor(e){this.#e=e,this.#t=null,this.#n=4e3,this.#r=-2}get pollingInterval(){return this.#n}set pollingInterval(e){this.#n=e}async#i(){try{let e=await this.#e.getBlockNumber();if(this.#r===-2){this.#r=e;return}if(e!==this.#r){for(let t=this.#r+1;t<=e;t++){if(this.#t==null)return;await this.#e.emit(`block`,t)}this.#r=e}}catch{}this.#t!=null&&(this.#t=this.#e._setTimeout(this.#i.bind(this),this.#n))}start(){this.#t||(this.#t=this.#e._setTimeout(this.#i.bind(this),this.#n),this.#i())}stop(){this.#t&&=(this.#e._clearTimeout(this.#t),null)}pause(e){this.stop(),e&&(this.#r=-2)}resume(){this.start()}},Ek=class{#e;#t;#n;constructor(e){this.#e=e,this.#n=!1,this.#t=e=>{this._poll(e,this.#e)}}async _poll(e,t){throw Error(`sub-classes must override this`)}start(){this.#n||(this.#n=!0,this.#t(-2),this.#e.on(`block`,this.#t))}stop(){this.#n&&(this.#n=!1,this.#e.off(`block`,this.#t))}pause(e){this.stop()}resume(){this.start()}},Dk=class extends Ek{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=-2}pause(e){e&&(this.#t=-2),super.pause(e)}async _poll(e,t){let n=await t.getBlock(this.#e);n!=null&&(this.#t===-2?this.#t=n.number:n.number>this.#t&&(t.emit(this.#e,n.number),this.#t=n.number))}},Ok=class extends Ek{#e;constructor(e,t){super(e),this.#e=wk(t)}async _poll(e,t){throw Error(`@TODO`)}},kk=class extends Ek{#e;constructor(e,t){super(e),this.#e=t}async _poll(e,t){let n=await t.getTransactionReceipt(this.#e);n&&t.emit(this.#e,n)}},Ak=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=wk(t),this.#n=this.#a.bind(this),this.#r=!1,this.#i=-2}async#a(e){if(this.#i===-2)return;let t=wk(this.#t);t.fromBlock=this.#i+1,t.toBlock=e;let n=await this.#e.getLogs(t);if(n.length===0){this.#i<e-60&&(this.#i=e-60);return}for(let e of n)this.#e.emit(this.#t,e),this.#i=e.blockNumber}start(){this.#r||(this.#r=!0,this.#i===-2&&this.#e.getBlockNumber().then(e=>{this.#i=e}),this.#e.on(`block`,this.#n))}stop(){this.#r&&(this.#r=!1,this.#e.off(`block`,this.#n))}pause(e){this.stop(),e&&(this.#i=-2)}resume(){this.start()}},jk=BigInt(2),Mk=10;function Nk(e){return e&&typeof e.then==`function`}function Pk(e,t){return e+`:`+JSON.stringify(t,(e,t)=>{if(t==null)return`null`;if(typeof t==`bigint`)return`bigint:${t.toString()}`;if(typeof t==`string`)return t.toLowerCase();if(typeof t==`object`&&!Array.isArray(t)){let e=Object.keys(t);return e.sort(),e.reduce((e,n)=>(e[n]=t[n],e),{})}return t})}var Fk=class{name;constructor(e){G(this,{name:e})}start(){}stop(){}pause(e){}resume(){}};function Ik(e){return JSON.parse(JSON.stringify(e))}function Lk(e){return e=Array.from(new Set(e).values()),e.sort(),e}async function Rk(e,t){if(e==null)throw Error(`invalid event`);if(Array.isArray(e)&&(e={topics:e}),typeof e==`string`)switch(e){case`block`:case`debug`:case`error`:case`finalized`:case`network`:case`pending`:case`safe`:return{type:e,tag:e}}if(Mv(e,32)){let t=e.toLowerCase();return{type:`transaction`,tag:Pk(`tx`,{hash:t}),hash:t}}if(e.orphan){let t=e;return{type:`orphan`,tag:Pk(`orphan`,t),filter:Ik(t)}}if(e.address||e.topics){let n=e,r={topics:(n.topics||[]).map(e=>e==null?null:Array.isArray(e)?Lk(e.map(e=>e.toLowerCase())):e.toLowerCase())};if(n.address){let e=[],i=[],a=n=>{Mv(n)?e.push(n):i.push((async()=>{e.push(await BC(n,t))})())};Array.isArray(n.address)?n.address.forEach(a):a(n.address),i.length&&await Promise.all(i),r.address=Lk(e.map(e=>e.toLowerCase()))}return{filter:r,tag:Pk(`event`,r),type:`event`}}q(!1,`unknown ProviderEvent`,`event`,e)}function zk(){return new Date().getTime()}var Bk={cacheTimeout:250,pollingInterval:4e3},Vk=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t){if(this.#d=Object.assign({},Bk,t||{}),e===`any`)this.#a=!0,this.#i=null;else if(e){let t=yk.from(e);this.#a=!1,this.#i=Promise.resolve(t),setTimeout(()=>{this.emit(`network`,t,null)},0)}else this.#a=!1,this.#i=null;this.#s=-1,this.#o=new Map,this.#e=new Map,this.#t=new Map,this.#n=null,this.#r=!1,this.#c=1,this.#l=new Map,this.#u=!1}get pollingInterval(){return this.#d.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#t.values())}attachPlugin(e){if(this.#t.get(e.name))throw Error(`cannot replace existing plugin: ${e.name} `);return this.#t.set(e.name,e.connect(this)),this}getPlugin(e){return this.#t.get(e)||null}get disableCcipRead(){return this.#u}set disableCcipRead(e){this.#u=!!e}async#f(e){let t=this.#d.cacheTimeout;if(t<0)return await this._perform(e);let n=Pk(e.method,e),r=this.#o.get(n);return r||(r=this._perform(e),this.#o.set(n,r),setTimeout(()=>{this.#o.get(n)===r&&this.#o.delete(n)},t)),await r}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;let r=e.to.toLowerCase(),i=t.toLowerCase(),a=[];for(let t=0;t<n.length;t++){let o=n[t],s=new Dy(o.replace(`{sender}`,r).replace(`{data}`,i));o.indexOf(`{data}`)===-1&&(s.body={data:i,sender:r}),this.emit(`debug`,{action:`sendCcipReadFetchRequest`,request:s,index:t,urls:n});let c=`unknown error`,l;try{l=await s.send()}catch(e){a.push(e.message),this.emit(`debug`,{action:`receiveCcipReadFetchError`,request:s,result:{error:e}});continue}try{let e=l.bodyJson;if(e.data)return this.emit(`debug`,{action:`receiveCcipReadFetchResult`,request:s,result:e}),e.data;e.message&&(c=e.message),this.emit(`debug`,{action:`receiveCcipReadFetchError`,request:s,result:e})}catch{}K(l.statusCode<400||l.statusCode>=500,`response not found during CCIP fetch: ${c}`,`OFFCHAIN_FAULT`,{reason:`404_MISSING_RESOURCE`,transaction:e,info:{url:o,errorMessage:c}}),a.push(c)}K(!1,`error encountered during CCIP fetch: ${a.map(e=>JSON.stringify(e)).join(`, `)}`,`OFFCHAIN_FAULT`,{reason:`500_SERVER_ERROR`,transaction:e,info:{urls:n,errorMessages:a}})}_wrapBlock(e,t){return new rO(sk(e),this)}_wrapLog(e,t){return new iO(ak(e),this)}_wrapTransactionReceipt(e,t){return new aO(dk(e),this)}_wrapTransactionResponse(e,t){return new oO(fk(e),this)}_detectNetwork(){K(!1,`sub-classes must implement this`,`UNSUPPORTED_OPERATION`,{operation:`_detectNetwork`})}async _perform(e){K(!1,`unsupported method: ${e.method}`,`UNSUPPORTED_OPERATION`,{operation:e.method,info:e})}async getBlockNumber(){let e=Z(await this.#f({method:`getBlockNumber`}),`%response`);return this.#s>=0&&(this.#s=e),e}_getAddress(e){return BC(e,this)}_getBlockTag(e){if(e==null)return`latest`;switch(e){case`earliest`:return`0x0`;case`finalized`:case`latest`:case`pending`:case`safe`:return e}if(Mv(e))return Mv(e,32)?e:$v(e);if(typeof e==`bigint`&&(e=Z(e,`blockTag`)),typeof e==`number`)return e>=0?$v(e):this.#s>=0?$v(this.#s+e):this.getBlockNumber().then(t=>$v(t+e));q(!1,`invalid blockTag`,`blockTag`,e)}_getFilter(e){let t=(e.topics||[]).map(e=>e==null?null:Array.isArray(e)?Lk(e.map(e=>e.toLowerCase())):e.toLowerCase()),n=`blockHash`in e?e.blockHash:void 0,r=(e,r,i)=>{let a;switch(e.length){case 0:break;case 1:a=e[0];break;default:e.sort(),a=e}if(n&&(r!=null||i!=null))throw Error(`invalid filter`);let o={};return a&&(o.address=a),t.length&&(o.topics=t),r&&(o.fromBlock=r),i&&(o.toBlock=i),n&&(o.blockHash=n),o},i=[];if(e.address)if(Array.isArray(e.address))for(let t of e.address)i.push(this._getAddress(t));else i.push(this._getAddress(e.address));let a;`fromBlock`in e&&(a=this._getBlockTag(e.fromBlock));let o;return`toBlock`in e&&(o=this._getBlockTag(e.toBlock)),i.filter(e=>typeof e!=`string`).length||a!=null&&typeof a!=`string`||o!=null&&typeof o!=`string`?Promise.all([Promise.all(i),a,o]).then(e=>r(e[0],e[1],e[2])):r(i,a,o)}_getTransactionRequest(e){let t=nO(e),n=[];if([`to`,`from`].forEach(e=>{if(t[e]==null)return;let r=BC(t[e],this);Nk(r)?n.push((async function(){t[e]=await r})()):t[e]=r}),t.blockTag!=null){let e=this._getBlockTag(t.blockTag);Nk(e)?n.push((async function(){t.blockTag=await e})()):t.blockTag=e}return n.length?(async function(){return await Promise.all(n),t})():t}async getNetwork(){if(this.#i==null){let e=(async()=>{try{let e=await this._detectNetwork();return this.emit(`network`,e,null),e}catch(t){throw this.#i===e&&(this.#i=null),t}})();return this.#i=e,(await e).clone()}let e=this.#i,[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(this.#a?(this.emit(`network`,n,t),this.#i===e&&(this.#i=Promise.resolve(n))):K(!1,`network changed: ${t.chainId} => ${n.chainId} `,`NETWORK_ERROR`,{event:`changed`})),t.clone()}async getFeeData(){let e=await this.getNetwork(),t=async()=>{let{_block:t,gasPrice:n,priorityFee:r}=await xv({_block:this.#g(`latest`,!1),gasPrice:(async()=>{try{return X(await this.#f({method:`getGasPrice`}),`%response`)}catch{}return null})(),priorityFee:(async()=>{try{return X(await this.#f({method:`getPriorityFee`}),`%response`)}catch{}return null})()}),i=null,a=null,o=this._wrapBlock(t,e);return o&&o.baseFeePerGas&&(a=r??BigInt(`1000000000`),i=o.baseFeePerGas*jk+a),new tO(n,i,a)},n=e.getPlugin(`org.ethers.plugins.network.FetchUrlFeeDataPlugin`);if(n){let e=new Dy(n.url),r=await n.processFunc(t,this,e);return new tO(r.gasPrice,r.maxFeePerGas,r.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Nk(t)&&(t=await t),X(await this.#f({method:`estimateGas`,transaction:t}),`%response`)}async#p(e,t,n){K(n<Mk,`CCIP read exceeded maximum redirections`,`OFFCHAIN_FAULT`,{reason:`TOO_MANY_REDIRECTS`,transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});let r=nO(e);try{return Y(await this._perform({method:`call`,transaction:r,blockTag:t}))}catch(e){if(!this.disableCcipRead&&wv(e)&&e.data&&n>=0&&t===`latest`&&r.to!=null&&Lv(e.data,0,4)===`0x556f1830`){let i=e.data,a=await BC(r.to,this),o;try{o=Yk(Lv(e.data,4))}catch(e){K(!1,e.message,`OFFCHAIN_FAULT`,{reason:`BAD_DATA`,transaction:r,info:{data:i}})}K(o.sender.toLowerCase()===a.toLowerCase(),`CCIP Read sender mismatch`,`CALL_EXCEPTION`,{action:`call`,data:i,reason:`OffchainLookup`,transaction:r,invocation:null,revert:{signature:`OffchainLookup(address,string[],bytes,bytes4,bytes)`,name:`OffchainLookup`,args:o.errorArgs}});let s=await this.ccipReadFetch(r,o.calldata,o.urls);K(s!=null,`CCIP Read failed to fetch data`,`OFFCHAIN_FAULT`,{reason:`FETCH_FAILED`,transaction:r,info:{data:e.data,errorArgs:o.errorArgs}});let c={to:a,data:Fv([o.selector,qk([s,o.extraData])])};this.emit(`debug`,{action:`sendCcipReadCall`,transaction:c});try{let e=await this.#p(c,t,n+1);return this.emit(`debug`,{action:`receiveCcipReadCallResult`,transaction:Object.assign({},c),result:e}),e}catch(e){throw this.emit(`debug`,{action:`receiveCcipReadCallError`,transaction:Object.assign({},c),error:e}),e}}throw e}}async#m(e){let{value:t}=await xv({network:this.getNetwork(),value:e});return t}async call(e){let{tx:t,blockTag:n}=await xv({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await this.#m(this.#p(t,n,e.enableCcipRead?0:-1))}async#h(e,t,n){let r=this._getAddress(t),i=this._getBlockTag(n);return(typeof r!=`string`||typeof i!=`string`)&&([r,i]=await Promise.all([r,i])),await this.#m(this.#f(Object.assign(e,{address:r,blockTag:i})))}async getBalance(e,t){return X(await this.#h({method:`getBalance`},e,t),`%response`)}async getTransactionCount(e,t){return Z(await this.#h({method:`getTransactionCount`},e,t),`%response`)}async getCode(e,t){return Y(await this.#h({method:`getCode`},e,t))}async getStorage(e,t,n){let r=X(t,`position`);return Y(await this.#h({method:`getStorage`,position:r},e,n))}async broadcastTransaction(e){let{blockNumber:t,hash:n,network:r}=await xv({blockNumber:this.getBlockNumber(),hash:this._perform({method:`broadcastTransaction`,signedTransaction:e}),network:this.getNetwork()}),i=Ww.from(e);if(i.hash!==n)throw Error(`@TODO: the returned hash did not match`);return this._wrapTransactionResponse(i,r).replaceableTransaction(t)}async#g(e,t){if(Mv(e,32))return await this.#f({method:`getBlock`,blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!=`string`&&(n=await n),await this.#f({method:`getBlock`,blockTag:n,includeTransactions:t})}async getBlock(e,t){let{network:n,params:r}=await xv({network:this.getNetwork(),params:this.#g(e,!!t)});return r==null?null:this._wrapBlock(r,n)}async getTransaction(e){let{network:t,params:n}=await xv({network:this.getNetwork(),params:this.#f({method:`getTransaction`,hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){let{network:t,params:n}=await xv({network:this.getNetwork(),params:this.#f({method:`getTransactionReceipt`,hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){let t=await this.#f({method:`getTransaction`,hash:e});if(t==null)throw Error(`report this; could not find tx or effectiveGasPrice`);n.effectiveGasPrice=t.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){let{result:t}=await xv({network:this.getNetwork(),result:this.#f({method:`getTransactionResult`,hash:e})});return t==null?null:Y(t)}async getLogs(e){let t=this._getFilter(e);Nk(t)&&(t=await t);let{network:n,params:r}=await xv({network:this.getNetwork(),params:this.#f({method:`getLogs`,filter:t})});return r.map(e=>this._wrapLog(e,n))}_getProvider(e){K(!1,`provider cannot connect to target network`,`UNSUPPORTED_OPERATION`,{operation:`_getProvider()`})}async getResolver(e){return await XO.fromName(this,e)}async getAvatar(e){let t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){let t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=IC(e);let t=kE(e.substring(2).toLowerCase()+`.addr.reverse`);try{let n=await new GO(await XO.getEnsAddress(this),[`function resolver(bytes32) view returns (address)`],this).resolver(t);if(n==null||n===`0x0000000000000000000000000000000000000000`)return null;let r=await new GO(n,[`function name(bytes32) view returns (string)`],this).name(t);return await this.resolveName(r)===e?r:null}catch(e){if(Cv(e,`BAD_DATA`)&&e.value===`0x`||Cv(e,`CALL_EXCEPTION`))return null;throw e}return null}async waitForTransaction(e,t,n){let r=t??1;return r===0?this.getTransactionReceipt(e):new Promise(async(t,i)=>{let a=null,o=(async n=>{try{let i=await this.getTransactionReceipt(e);if(i!=null&&n-i.blockNumber+1>=r){t(i),a&&=(clearTimeout(a),null);return}}catch(e){console.log(`EEE`,e)}this.once(`block`,o)});n!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off(`block`,o),i(Tv(`timeout`,`TIMEOUT`,{reason:`timeout`})))},n)),o(await this.getBlockNumber())})}async waitForBlock(e){K(!1,`not implemented yet`,`NOT_IMPLEMENTED`,{operation:`waitForBlock`})}_clearTimeout(e){let t=this.#l.get(e);t&&(t.timer&&clearTimeout(t.timer),this.#l.delete(e))}_setTimeout(e,t){t??=0;let n=this.#c++,r=()=>{this.#l.delete(n),e()};if(this.paused)this.#l.set(n,{timer:null,func:r,time:t});else{let e=setTimeout(r,t);this.#l.set(n,{timer:e,func:r,time:zk()})}return n}_forEachSubscriber(e){for(let t of this.#e.values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case`debug`:case`error`:case`network`:return new Fk(e.type);case`block`:{let e=new Tk(this);return e.pollingInterval=this.pollingInterval,e}case`safe`:case`finalized`:return new Dk(this,e.type);case`event`:return new Ak(this,e.filter);case`transaction`:return new kk(this,e.hash);case`orphan`:return new Ok(this,e.filter)}throw Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(let n of this.#e.values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),this.#n!=null&&t.pause(this.#n);break}}async#_(e,t){let n=await Rk(e,this);return n.type===`event`&&t&&t.length>0&&t[0].removed===!0&&(n=await Rk({orphan:`drop-log`,log:t[0]},this)),this.#e.get(n.tag)||null}async#v(e){let t=await Rk(e,this),n=t.tag,r=this.#e.get(n);return r||(r={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#e.set(n,r)),r}async on(e,t){let n=await this.#v(e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async once(e,t){let n=await this.#v(e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async emit(e,...t){let n=await this.#_(e,t);if(!n||n.listeners.length===0)return!1;let r=n.listeners.length;return n.listeners=n.listeners.filter(({listener:n,once:r})=>{let i=new ay(this,r?null:n,e);try{n.call(this,...t,i)}catch{}return!r}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),r>0}async listenerCount(e){if(e){let t=await this.#_(e);return t?t.listeners.length:0}let t=0;for(let{listeners:e}of this.#e.values())t+=e.length;return t}async listeners(e){if(e){let t=await this.#_(e);return t?t.listeners.map(({listener:e})=>e):[]}let t=[];for(let{listeners:e}of this.#e.values())t=t.concat(e.map(({listener:e})=>e));return t}async off(e,t){let n=await this.#_(e);if(!n)return this;if(t){let e=n.listeners.map(({listener:e})=>e).indexOf(t);e>=0&&n.listeners.splice(e,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),this}async removeAllListeners(e){if(e){let{tag:t,started:n,subscriber:r}=await this.#v(e);n&&r.stop(),this.#e.delete(t)}else for(let[e,{started:t,subscriber:n}]of this.#e)t&&n.stop(),this.#e.delete(e);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return this.#r}destroy(){this.removeAllListeners();for(let e of this.#l.keys())this._clearTimeout(e);this.#r=!0}get paused(){return this.#n!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(this.#s=-1,this.#n!=null){if(this.#n==!!e)return;K(!1,`cannot change pause type; resume first`,`UNSUPPORTED_OPERATION`,{operation:`pause`})}this._forEachSubscriber(t=>t.pause(e)),this.#n=!!e;for(let e of this.#l.values())e.timer&&clearTimeout(e.timer),e.time=zk()-e.time}resume(){if(this.#n!=null){this._forEachSubscriber(e=>e.resume()),this.#n=null;for(let e of this.#l.values()){let t=e.time;t<0&&(t=0),e.time=zk(),setTimeout(e.func,t)}}}};function Hk(e,t){try{let n=Uk(e,t);if(n)return py(n)}catch{}return null}function Uk(e,t){if(e===`0x`)return null;try{let n=Z(Lv(e,t,t+32)),r=Z(Lv(e,n,n+32));return Lv(e,n+32,n+32+r)}catch{}return null}function Wk(e){let t=Qv(e);if(t.length>32)throw Error(`internal; should not happen`);let n=new Uint8Array(32);return n.set(t,32-t.length),n}function Gk(e){if(e.length%32==0)return e;let t=new Uint8Array(Math.ceil(e.length/32)*32);return t.set(e),t}var Kk=new Uint8Array([]);function qk(e){let t=[],n=0;for(let r=0;r<e.length;r++)t.push(Kk),n+=32;for(let r=0;r<e.length;r++){let i=J(e[r]);t[r]=Wk(n),t.push(Wk(i.length)),t.push(Gk(i)),n+=32+Math.ceil(i.length/32)*32}return Fv(t)}var Jk=`0x0000000000000000000000000000000000000000000000000000000000000000`;function Yk(e){let t={sender:``,urls:[],calldata:``,selector:``,extraData:``,errorArgs:[]};K(Iv(e)>=160,`insufficient OffchainLookup data`,`OFFCHAIN_FAULT`,{reason:`insufficient OffchainLookup data`});let n=Lv(e,0,32);K(Lv(n,0,12)===Lv(Jk,0,12),`corrupt OffchainLookup sender`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup sender`}),t.sender=Lv(n,12);try{let n=[],r=Z(Lv(e,32,64)),i=Z(Lv(e,r,r+32)),a=Lv(e,r+32);for(let e=0;e<i;e++){let t=Hk(a,e*32);if(t==null)throw Error(`abort`);n.push(t)}t.urls=n}catch{K(!1,`corrupt OffchainLookup urls`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup urls`})}try{let n=Uk(e,64);if(n==null)throw Error(`abort`);t.calldata=n}catch{K(!1,`corrupt OffchainLookup calldata`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup calldata`})}K(Lv(e,100,128)===Lv(Jk,0,28),`corrupt OffchainLookup callbaackSelector`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup callbaackSelector`}),t.selector=Lv(e,96,100);try{let n=Uk(e,128);if(n==null)throw Error(`abort`);t.extraData=n}catch{K(!1,`corrupt OffchainLookup extraData`,`OFFCHAIN_FAULT`,{reason:`corrupt OffchainLookup extraData`})}return t.errorArgs=`sender,urls,calldata,selector,extraData`.split(/,/).map(e=>t[e]),t}function Xk(e,t){if(e.provider)return e.provider;K(!1,`missing provider`,`UNSUPPORTED_OPERATION`,{operation:t})}async function Zk(e,t){let n=nO(t);if(n.to!=null&&(n.to=BC(n.to,e)),n.from!=null){let t=n.from;n.from=Promise.all([e.getAddress(),BC(t,e)]).then(([e,t])=>(q(e.toLowerCase()===t.toLowerCase(),`transaction from mismatch`,`tx.from`,t),e))}else n.from=e.getAddress();return await xv(n)}var Qk=class{provider;constructor(e){G(this,{provider:e||null})}async getNonce(e){return Xk(this,`getTransactionCount`).getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await Zk(this,e)}async populateTransaction(e){let t=Xk(this,`populateTransaction`),n=await Zk(this,e);n.nonce??=await this.getNonce(`pending`),n.gasLimit??=await this.estimateGas(n);let r=await this.provider.getNetwork();n.chainId==null?n.chainId=r.chainId:q(X(n.chainId)===r.chainId,`transaction chainId mismatch`,`tx.chainId`,e.chainId);let i=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||i)?q(!1,`eip-1559 transaction do not support gasPrice`,`tx`,e):(n.type===0||n.type===1)&&i&&q(!1,`pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas`,`tx`,e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){let e=await t.getFeeData();K(e.gasPrice!=null,`network does not support gasPrice`,`UNSUPPORTED_OPERATION`,{operation:`getGasPrice`}),n.gasPrice??=e.gasPrice}else{let e=await t.getFeeData();if(n.type==null)if(e.maxFeePerGas!=null&&e.maxPriorityFeePerGas!=null)if(n.authorizationList&&n.authorizationList.length?n.type=4:n.type=2,n.gasPrice!=null){let e=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=e,n.maxPriorityFeePerGas=e}else n.maxFeePerGas??=e.maxFeePerGas,n.maxPriorityFeePerGas??=e.maxPriorityFeePerGas;else e.gasPrice==null?K(!1,`failed to get consistent fee data`,`UNSUPPORTED_OPERATION`,{operation:`signer.getFeeData`}):(K(!i,`network does not support EIP-1559`,`UNSUPPORTED_OPERATION`,{operation:`populateTransaction`}),n.gasPrice??=e.gasPrice,n.type=0);else (n.type===2||n.type===3||n.type===4)&&(n.maxFeePerGas??=e.maxFeePerGas,n.maxPriorityFeePerGas??=e.maxPriorityFeePerGas)}return await xv(n)}async populateAuthorization(e){let t=Object.assign({},e);return t.chainId??=(await Xk(this,`getNetwork`).getNetwork()).chainId,t.nonce??=await this.getNonce(),t}async estimateGas(e){return Xk(this,`estimateGas`).estimateGas(await this.populateCall(e))}async call(e){return Xk(this,`call`).call(await this.populateCall(e))}async resolveName(e){return await Xk(this,`resolveName`).resolveName(e)}async sendTransaction(e){let t=Xk(this,`sendTransaction`),n=await this.populateTransaction(e);delete n.from;let r=Ww.from(n);return await t.broadcastTransaction(await this.signTransaction(r))}authorize(e){K(!1,`authorization not implemented for this signer`,`UNSUPPORTED_OPERATION`,{operation:`authorize`})}};function $k(e){return JSON.parse(JSON.stringify(e))}var eA=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e,this.#t=null,this.#n=this.#o.bind(this),this.#r=!1,this.#i=null,this.#a=!1}_subscribe(e){throw Error(`subclasses must override this`)}_emitResults(e,t){throw Error(`subclasses must override this`)}_recover(e){throw Error(`subclasses must override this`)}async#o(e){try{this.#t??=this._subscribe(this.#e);let e=null;try{e=await this.#t}catch(e){if(!Cv(e,`UNSUPPORTED_OPERATION`)||e.operation!==`eth_newFilter`)throw e}if(e==null){this.#t=null,this.#e._recoverSubscriber(this,this._recover(this.#e));return}let t=await this.#e.getNetwork();if(this.#i||=t,this.#i.chainId!==t.chainId)throw Error(`chaid changed`);if(this.#a)return;let n=await this.#e.send(`eth_getFilterChanges`,[e]);await this._emitResults(this.#e,n)}catch(e){console.log(`@TODO`,e)}this.#e.once(`block`,this.#n)}#s(){let e=this.#t;e&&(this.#t=null,e.then(e=>{this.#e.destroyed||this.#e.send(`eth_uninstallFilter`,[e])}))}start(){this.#r||(this.#r=!0,this.#o(-2))}stop(){this.#r&&(this.#r=!1,this.#a=!0,this.#s(),this.#e.off(`block`,this.#n))}pause(e){e&&this.#s(),this.#e.off(`block`,this.#n)}resume(){this.start()}},tA=class extends eA{#e;constructor(e,t){super(e),this.#e=$k(t)}_recover(e){return new Ak(e,this.#e)}async _subscribe(e){return await e.send(`eth_newFilter`,[this.#e])}async _emitResults(e,t){for(let n of t)e.emit(this.#e,e._wrapLog(n,e._network))}},nA=class extends eA{async _subscribe(e){return await e.send(`eth_newPendingTransactionFilter`,[])}async _emitResults(e,t){for(let n of t)e.emit(`pending`,n)}},rA=`bigint,boolean,function,number,string,symbol`.split(/,/g);function iA(e){if(e==null||rA.indexOf(typeof e)>=0||typeof e.getAddress==`function`)return e;if(Array.isArray(e))return e.map(iA);if(typeof e==`object`)return Object.keys(e).reduce((t,n)=>(t[n]=e[n],t),{});throw Error(`should not happen: ${e} (${typeof e})`)}function aA(e){return new Promise(t=>{setTimeout(t,e)})}function oA(e){return e&&e.toLowerCase()}function sA(e){return e&&typeof e.pollingInterval==`number`}var cA={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3},lA=class extends Qk{address;constructor(e,t){super(e),t=IC(t),G(this,{address:t})}connect(e){K(!1,`cannot reconnect JsonRpcSigner`,`UNSUPPORTED_OPERATION`,{operation:`signer.connect`})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){let t=iA(e),n=[];if(t.from){let r=t.from;n.push((async()=>{let n=await BC(r,this.provider);q(n!=null&&n.toLowerCase()===this.address.toLowerCase(),`from address mismatch`,`transaction`,e),t.from=n})())}else t.from=this.address;if(t.gasLimit??n.push((async()=>{t.gasLimit=await this.provider.estimateGas({...t,from:this.address})})()),t.to!=null){let e=t.to;n.push((async()=>{t.to=await BC(e,this.provider)})())}n.length&&await Promise.all(n);let r=this.provider.getRpcTransaction(t);return this.provider.send(`eth_sendTransaction`,[r])}async sendTransaction(e){let t=await this.provider.getBlockNumber(),n=await this.sendUncheckedTransaction(e);return await new Promise((e,r)=>{let i=[1e3,100],a=0,o=async()=>{try{let r=await this.provider.getTransaction(n);if(r!=null){e(r.replaceableTransaction(t));return}}catch(e){if(Cv(e,`CANCELLED`)||Cv(e,`BAD_DATA`)||Cv(e,`NETWORK_ERROR`)||Cv(e,`UNSUPPORTED_OPERATION`)){e.info??={},e.info.sendTransactionHash=n,r(e);return}if(Cv(e,`INVALID_ARGUMENT`)&&(a++,e.info??={},e.info.sendTransactionHash=n,a>10)){r(e);return}this.provider.emit(`error`,Tv(`failed to fetch transation after sending (will try again)`,`UNKNOWN_ERROR`,{error:e}))}this.provider._setTimeout(()=>{o()},i.pop()||4e3)};o()})}async signTransaction(e){let t=iA(e);if(t.from){let n=await BC(t.from,this.provider);q(n!=null&&n.toLowerCase()===this.address.toLowerCase(),`from address mismatch`,`transaction`,e),t.from=n}else t.from=this.address;let n=this.provider.getRpcTransaction(t);return await this.provider.send(`eth_signTransaction`,[n])}async signMessage(e){let t=typeof e==`string`?dy(e):e;return await this.provider.send(`personal_sign`,[Y(t),this.address.toLowerCase()])}async signTypedData(e,t,n){let r=iA(n),i=await KE.resolveNames(e,t,r,async e=>{let t=await BC(e);return q(t!=null,`TypedData does not support null address`,`value`,e),t});return await this.provider.send(`eth_signTypedData_v4`,[this.address.toLowerCase(),JSON.stringify(KE.getPayload(i.domain,t,i.value))])}async unlock(e){return this.provider.send(`personal_unlockAccount`,[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){let t=typeof e==`string`?dy(e):e;return await this.provider.send(`eth_sign`,[this.address.toLowerCase(),Y(t)])}},uA=class extends Vk{#e;#t;#n;#r;#i;#a;#o;#s(){if(this.#r)return;let e=this._getOption(`batchMaxCount`)===1?0:this._getOption(`batchStallTime`);this.#r=setTimeout(()=>{this.#r=null;let e=this.#n;for(this.#n=[];e.length;){let t=[e.shift()];for(;e.length&&t.length!==this.#e.batchMaxCount;)if(t.push(e.shift()),JSON.stringify(t.map(e=>e.payload)).length>this.#e.batchMaxSize){e.unshift(t.pop());break}(async()=>{let e=t.length===1?t[0].payload:t.map(e=>e.payload);this.emit(`debug`,{action:`sendRpcPayload`,payload:e});try{let n=await this._send(e);this.emit(`debug`,{action:`receiveRpcResult`,result:n});for(let{resolve:e,reject:r,payload:i}of t){if(this.destroyed){r(Tv(`provider destroyed; cancelled request`,`UNSUPPORTED_OPERATION`,{operation:i.method}));continue}let t=n.filter(e=>e.id===i.id)[0];if(t==null){let e=Tv(`missing response for request`,`BAD_DATA`,{value:n,info:{payload:i}});this.emit(`error`,e),r(e);continue}if(`error`in t){r(this.getRpcError(i,t));continue}e(t.result)}}catch(e){this.emit(`debug`,{action:`receiveRpcError`,error:e});for(let{reject:n}of t)n(e)}})()}},e)}constructor(e,t){super(e,t),this.#t=1,this.#e=Object.assign({},cA,t||{}),this.#n=[],this.#r=null,this.#a=null,this.#o=null;{let e=null;this.#i={promise:new Promise(t=>{e=t}),resolve:e}}let n=this._getOption(`staticNetwork`);typeof n==`boolean`?(q(!n||e!==`any`,`staticNetwork cannot be used on special network 'any'`,`options`,t),n&&e!=null&&(this.#a=yk.from(e))):n&&(q(e==null||n.matches(e),`staticNetwork MUST match network object`,`options`,t),this.#a=n)}_getOption(e){return this.#e[e]}get _network(){return K(this.#a,`network is not available yet`,`NETWORK_ERROR`),this.#a}async _perform(e){if(e.method===`call`||e.method===`estimateGas`){let t=e.transaction;if(t&&t.type!=null&&X(t.type)&&t.maxFeePerGas==null&&t.maxPriorityFeePerGas==null){let n=await this.getFeeData();n.maxFeePerGas==null&&n.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}let t=this.getRpcRequest(e);return t==null?super._perform(e):await this.send(t.method,t.args)}async _detectNetwork(){let e=this._getOption(`staticNetwork`);if(e)if(e===!0){if(this.#a)return this.#a}else return e;return this.#o?await this.#o:this.ready?(this.#o=(async()=>{try{let e=yk.from(X(await this.send(`eth_chainId`,[])));return this.#o=null,e}catch(e){throw this.#o=null,e}})(),await this.#o):(this.#o=(async()=>{let e={id:this.#t++,method:`eth_chainId`,params:[],jsonrpc:`2.0`};this.emit(`debug`,{action:`sendRpcPayload`,payload:e});let t;try{t=(await this._send(e))[0],this.#o=null}catch(e){throw this.#o=null,this.emit(`debug`,{action:`receiveRpcError`,error:e}),e}if(this.emit(`debug`,{action:`receiveRpcResult`,result:t}),`result`in t)return yk.from(X(t.result));throw this.getRpcError(e,t)})(),await this.#o)}_start(){this.#i==null||this.#i.resolve==null||(this.#i.resolve(),this.#i=null,(async()=>{for(;this.#a==null&&!this.destroyed;)try{this.#a=await this._detectNetwork()}catch(e){if(this.destroyed)break;console.log(`JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)`),this.emit(`error`,Tv(`failed to bootstrap network detection`,`NETWORK_ERROR`,{event:`initial-network-discovery`,info:{error:e}})),await aA(1e3)}this.#s()})())}async _waitUntilReady(){if(this.#i!=null)return await this.#i.promise}_getSubscriber(e){return e.type===`pending`?new nA(this):e.type===`event`?this._getOption(`polling`)?new Ak(this,e.filter):new tA(this,e.filter):e.type===`orphan`&&e.filter.orphan===`drop-log`?new Fk(`orphan`):super._getSubscriber(e)}get ready(){return this.#i==null}getRpcTransaction(e){let t={};return[`chainId`,`gasLimit`,`gasPrice`,`type`,`maxFeePerGas`,`maxPriorityFeePerGas`,`nonce`,`value`].forEach(n=>{if(e[n]==null)return;let r=n;n===`gasLimit`&&(r=`gas`),t[r]=$v(X(e[n],`tx.${n}`))}),[`from`,`to`,`data`].forEach(n=>{e[n]!=null&&(t[n]=Y(e[n]))}),e.accessList&&(t.accessList=lw(e.accessList)),e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.map(e=>e.toLowerCase())),e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>{let t=uw(e);return{address:t.address,nonce:$v(t.nonce),chainId:$v(t.chainId),yParity:$v(t.signature.yParity),r:$v(t.signature.r),s:$v(t.signature.s)}})),t}getRpcRequest(e){switch(e.method){case`chainId`:return{method:`eth_chainId`,args:[]};case`getBlockNumber`:return{method:`eth_blockNumber`,args:[]};case`getGasPrice`:return{method:`eth_gasPrice`,args:[]};case`getPriorityFee`:return{method:`eth_maxPriorityFeePerGas`,args:[]};case`getBalance`:return{method:`eth_getBalance`,args:[oA(e.address),e.blockTag]};case`getTransactionCount`:return{method:`eth_getTransactionCount`,args:[oA(e.address),e.blockTag]};case`getCode`:return{method:`eth_getCode`,args:[oA(e.address),e.blockTag]};case`getStorage`:return{method:`eth_getStorageAt`,args:[oA(e.address),`0x`+e.position.toString(16),e.blockTag]};case`broadcastTransaction`:return{method:`eth_sendRawTransaction`,args:[e.signedTransaction]};case`getBlock`:if(`blockTag`in e)return{method:`eth_getBlockByNumber`,args:[e.blockTag,!!e.includeTransactions]};if(`blockHash`in e)return{method:`eth_getBlockByHash`,args:[e.blockHash,!!e.includeTransactions]};break;case`getTransaction`:return{method:`eth_getTransactionByHash`,args:[e.hash]};case`getTransactionReceipt`:return{method:`eth_getTransactionReceipt`,args:[e.hash]};case`call`:return{method:`eth_call`,args:[this.getRpcTransaction(e.transaction),e.blockTag]};case`estimateGas`:return{method:`eth_estimateGas`,args:[this.getRpcTransaction(e.transaction)]};case`getLogs`:return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(oA):e.filter.address=oA(e.filter.address)),{method:`eth_getLogs`,args:[e.filter]}}return null}getRpcError(e,t){let{method:n}=e,{error:r}=t;if(n===`eth_estimateGas`&&r.message){let t=r.message;if(!t.match(/revert/i)&&t.match(/insufficient funds/i))return Tv(`insufficient funds`,`INSUFFICIENT_FUNDS`,{transaction:e.params[0],info:{payload:e,error:r}});if(t.match(/nonce/i)&&t.match(/too low/i))return Tv(`nonce has already been used`,`NONCE_EXPIRED`,{transaction:e.params[0],info:{payload:e,error:r}})}if(n===`eth_call`||n===`eth_estimateGas`){let t=pA(r),i=WD.getBuiltinCallException(n===`eth_call`?`call`:`estimateGas`,e.params[0],t?t.data:null);return i.info={error:r,payload:e},i}let i=JSON.stringify(hA(r));if(typeof r.message==`string`&&r.message.match(/user denied|ethers-user-denied/i))return Tv(`user rejected action`,`ACTION_REJECTED`,{action:{eth_sign:`signMessage`,personal_sign:`signMessage`,eth_signTypedData_v4:`signTypedData`,eth_signTransaction:`signTransaction`,eth_sendTransaction:`sendTransaction`,eth_requestAccounts:`requestAccess`,wallet_requestAccounts:`requestAccess`}[n]||`unknown`,reason:`rejected`,info:{payload:e,error:r}});if(n===`eth_sendRawTransaction`||n===`eth_sendTransaction`){let t=e.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Tv(`insufficient funds for intrinsic transaction cost`,`INSUFFICIENT_FUNDS`,{transaction:t,info:{error:r}});if(i.match(/nonce/i)&&i.match(/too low/i))return Tv(`nonce has already been used`,`NONCE_EXPIRED`,{transaction:t,info:{error:r}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Tv(`replacement fee too low`,`REPLACEMENT_UNDERPRICED`,{transaction:t,info:{error:r}});if(i.match(/only replay-protected/i))return Tv(`legacy pre-eip-155 transactions not supported`,`UNSUPPORTED_OPERATION`,{operation:n,info:{transaction:t,info:{error:r}}})}let a=!!i.match(/the method .* does not exist/i);return a||r&&r.details&&r.details.startsWith(`Unauthorized method:`)&&(a=!0),a?Tv(`unsupported operation`,`UNSUPPORTED_OPERATION`,{operation:e.method,info:{error:r,payload:e}}):Tv(`could not coalesce error`,`UNKNOWN_ERROR`,{error:r,payload:e})}send(e,t){if(this.destroyed)return Promise.reject(Tv(`provider destroyed; cancelled request`,`UNSUPPORTED_OPERATION`,{operation:e}));let n=this.#t++,r=new Promise((r,i)=>{this.#n.push({resolve:r,reject:i,payload:{method:e,params:t,id:n,jsonrpc:`2.0`}})});return this.#s(),r}async getSigner(e){e??=0;let t=this.send(`eth_accounts`,[]);if(typeof e==`number`){let n=await t;if(e>=n.length)throw Error(`no such account`);return new lA(this,n[e])}let{accounts:n}=await xv({network:this.getNetwork(),accounts:t});e=IC(e);for(let t of n)if(IC(t)===e)return new lA(this,e);throw Error(`invalid account`)}async listAccounts(){return(await this.send(`eth_accounts`,[])).map(e=>new lA(this,e))}destroy(){this.#r&&=(clearTimeout(this.#r),null);for(let{payload:e,reject:t}of this.#n)t(Tv(`provider destroyed; cancelled request`,`UNSUPPORTED_OPERATION`,{operation:e.method}));this.#n=[],super.destroy()}},dA=class extends uA{#e;constructor(e,t){super(e,t);let n=this._getOption(`pollingInterval`);n??=cA.pollingInterval,this.#e=n}_getSubscriber(e){let t=super._getSubscriber(e);return sA(t)&&(t.pollingInterval=this.#e),t}get pollingInterval(){return this.#e}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw Error(`invalid interval`);this.#e=e,this._forEachSubscriber(e=>{sA(e)&&(e.pollingInterval=this.#e)})}},fA=class extends dA{#e;constructor(e,t,n){e??=`http://localhost:8545`,super(t,n),typeof e==`string`?this.#e=new Dy(e):this.#e=e.clone()}_getConnection(){return this.#e.clone()}async send(e,t){return await this._start(),await super.send(e,t)}async _send(e){let t=this._getConnection();t.body=JSON.stringify(e),t.setHeader(`content-type`,`application/json`);let n=await t.send();n.assertOk();let r=n.bodyJson;return Array.isArray(r)||(r=[r]),r}};function pA(e){if(e==null)return null;if(typeof e.message==`string`&&e.message.match(/revert/i)&&Mv(e.data))return{message:e.message,data:e.data};if(typeof e==`object`){for(let t in e){let n=pA(e[t]);if(n)return n}return null}if(typeof e==`string`)try{return pA(JSON.parse(e))}catch{}return null}function mA(e,t){if(e!=null){if(typeof e.message==`string`&&t.push(e.message),typeof e==`object`)for(let n in e)mA(e[n],t);if(typeof e==`string`)try{return mA(JSON.parse(e),t)}catch{}}}function hA(e){let t=[];return mA(e,t),t}var gA=[`function register(string agentURI) external returns (uint256 agentId)`,`function register(string agentURI, tuple(string metadataKey, bytes metadataValue)[] metadata) external returns (uint256 agentId)`,`function register() external returns (uint256 agentId)`,`function setAgentURI(uint256 agentId, string newURI) external`,`function tokenURI(uint256 agentId) external view returns (string)`,`function setAgentWallet(uint256 agentId, address newWallet, uint256 deadline, bytes signature) external`,`function getAgentWallet(uint256 agentId) external view returns (address)`,`function unsetAgentWallet(uint256 agentId) external`,`function nonces(address owner) external view returns (uint256)`,`function DOMAIN_SEPARATOR() external view returns (bytes32)`,`function getMetadata(uint256 agentId, string metadataKey) external view returns (bytes)`,`function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue) external`,`function ownerOf(uint256 tokenId) external view returns (address)`,`function balanceOf(address owner) external view returns (uint256)`,`function totalSupply() external view returns (uint256)`,`function isAgent(uint256 agentId) external view returns (bool)`,`event Registered(uint256 indexed agentId, string agentURI, address indexed owner)`,`event URIUpdated(uint256 indexed agentId, string newURI, address indexed updatedBy)`,`event WalletSet(uint256 indexed agentId, address indexed wallet)`,`event WalletUnset(uint256 indexed agentId)`,`event MetadataSet(uint256 indexed agentId, string indexed indexedMetadataKey, string metadataKey, bytes metadataValue)`,`event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)`],_A={8453:{identityRegistry:``,reputationRegistry:``,validationRegistry:``},84532:{identityRegistry:``,reputationRegistry:``,validationRegistry:``},1:{identityRegistry:``,reputationRegistry:``,validationRegistry:``}},vA={base:8453,"base-mainnet":8453,"base-sepolia":84532,ethereum:1,mainnet:1},yA={8453:`https://mainnet.base.org`,84532:`https://sepolia.base.org`,1:`https://eth.llamarpc.com`};async function bA(e,{rpcURL:t,registry:n}={}){if(!e)throw Error(`loadManifest: source required`);if(e.startsWith(`agent://`))return xA(e,{rpcURL:t,registryOverride:n});if(e.startsWith(`ipfs://`)||e.startsWith(`ar://`)){let t=cv(e);return CA(await SA(t),{baseURI:wA(t)})}if(e.startsWith(`http`))return CA(await SA(e),{baseURI:wA(e)});throw Error(`Unsupported manifest source: ${e}`)}async function xA(e,{rpcURL:t,registryOverride:n}){let r=e.match(/^agent:\/\/([^/]+)\/(\d+)$/);if(!r)throw Error(`Malformed agent URI: ${e}`);let[,i,a]=r,o=vA[i.toLowerCase()]||Number(i);if(!o)throw Error(`Unknown chain: ${i}`);let s=_A[o],c=n||s?.identityRegistry;if(!c)throw Error(`No registry deployed on chain ${o}. Pass registry= override.`);let l=new GO(c,gA,new fA(t||yA[o])),u=BigInt(a),d=await l.tokenURI(u);if(!d)throw Error(`Agent ${a} on chain ${o} has no URI`);let f=cv(d),p=CA(await SA(f),{baseURI:wA(f)});return p.id={...p.id,chain:i,chainId:o,registry:c,agentId:a},p}async function SA(e){let t;try{t=await fetch(e)}catch{t=await lv(e)}if(!t.ok)throw Error(`Manifest fetch failed: ${e} (${t.status})`);return t.json()}function CA(e,{baseURI:t=``}={}){if(e.spec&&e.spec.startsWith(`agent-manifest/`)){let n={...e,_baseURI:t};return n.body=n.body||{},!n.body.uri&&n.image&&(n.body.uri=n.image),n}return e.type&&e.type.includes(`eip-8004`)?{spec:`agent-manifest/0.1`,_baseURI:t,_source:`erc8004-registration`,id:{agentId:(e.registrations?.[0]||{}).agentId?.toString()},name:e.name,description:e.description,image:e.image,body:{uri:e.image,format:`gltf-binary`},brain:{provider:`none`},voice:{tts:{provider:`browser`},stt:{provider:`browser`}},skills:[],memory:{mode:`local`},tools:[`wave`,`lookAt`,`play_clip`,`setExpression`],version:`0.1.0`}:{spec:`agent-manifest/0.1`,_baseURI:t,name:e.name||`Unnamed agent`,description:e.description||``,body:{uri:e.body?.uri||e.image||e.model||``,format:e.body?.format||`gltf-binary`},brain:e.brain||{provider:`none`},voice:e.voice||{tts:{provider:`browser`},stt:{provider:`browser`}},skills:e.skills||[],memory:e.memory||{mode:`local`},tools:e.tools||[`wave`,`lookAt`,`play_clip`,`setExpression`],version:e.version||`0.1.0`}}function wA(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t+1):e}async function TA(e,t){if(!e._baseURI)return null;try{let n=new URL(t,e._baseURI).href,r=await fetch(n);return r.ok?r.text():null}catch{return null}}var EA=class extends Error{constructor(e,t,{status:n}={}){super(t),this.name=`AgentResolveError`,this.code=e,n!==void 0&&(this.status=n)}};async function DA(e,{fetchFn:t}){let n;try{n=await t(e,{credentials:`include`})}catch(t){throw new EA(`network`,`network error fetching ${e}: ${t.message||t}`)}if(n.status===401||n.status===403)throw new EA(`unauthorized`,`unauthorized fetching ${e} (${n.status})`,{status:n.status});if(n.status===404)throw new EA(`not_found`,`resource not found: ${e}`,{status:404});if(!n.ok)throw new EA(`network`,`request failed: ${e} (${n.status})`,{status:n.status});try{return await n.json()}catch(t){throw new EA(`network`,`invalid JSON from ${e}: ${t.message||t}`)}}async function OA(e,{origin:t=typeof location<`u`?location.origin:``,fetchFn:n=fetch}={}){if(!e)throw new EA(`not_found`,`agentId required`);let r=n.bind(typeof globalThis<`u`?globalThis:void 0),i=(await DA(`${t}/api/agents/${encodeURIComponent(e)}`,{fetchFn:r}))?.agent;if(!i)throw new EA(`not_found`,`agent ${e} not found`);if(!i.avatar_id)throw new EA(`no_avatar`,`agent ${e} has no avatar bound`);let a=(await DA(`${t}/api/avatars/${encodeURIComponent(i.avatar_id)}`,{fetchFn:r}))?.avatar;if(!a||!a.url)throw new EA(`no_avatar`,`avatar ${i.avatar_id} has no url`);let o=Array.isArray(i.skills)?i.skills.map(e=>typeof e==`string`?{name:e}:e).filter(Boolean):[];return{spec:`agent-manifest/0.1`,name:i.name||`Agent`,description:i.description||``,id:{agentId:i.id,owner:i.wallet_address,chainId:i.chain_id,walletAddress:i.wallet_address},body:{uri:a.url,format:`gltf-binary`},brain:{},voice:{tts:{provider:`browser`},stt:{provider:`browser`}},skills:o,memory:{mode:`remote`,namespace:i.id},tools:[`wave`,`lookAt`,`play_clip`,`setExpression`,`speak`,`remember`],version:`0.1.0`,_baseURI:`${t}/agent/${i.id}/`,_source:`agent-id`}}var kA=[`inline`,`floating`,`section`,`fullscreen`],AA=`
:host {
display: block;
position: relative;
@@ -3978,4 +3978,4 @@ void main() {
padding: 16px;
font: 14px var(--agent-chat-font);
}
-`,OA=class extends HTMLElement{static get observedAttributes(){return[`src`,`manifest`,`body`,`mode`,`position`,`width`,`height`,`voice`,`api-key`,`key-proxy`]}constructor(){super(),this.attachShadow({mode:`open`}),this._viewer=null,this._scene=null,this._runtime=null,this._memory=null,this._skills=null,this._manifest=null,this._mounted=!1,this._booting=!1,this._listening=!1}connectedCallback(){this._renderShell(),this._applyLayout(),this._observeViewport(),this.hasAttribute(`eager`)&&this._boot()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){this._mounted&&([`mode`,`position`,`width`,`height`].includes(e)&&this._applyLayout(),[`src`,`manifest`,`body`].includes(e)&&(this._teardown(),this._boot()))}_renderShell(){let e=document.createElement(`style`);e.textContent=DA,this.shadowRoot.appendChild(e);let t=document.createElement(`div`);t.className=`stage`,t.part=`stage`,this.shadowRoot.appendChild(t),this._stageEl=t;let n=document.createElement(`div`);n.className=`poster`,this.getAttribute(`poster`)&&(n.style.backgroundImage=`url(${this.getAttribute(`poster`)})`),this.shadowRoot.appendChild(n),this._posterEl=n;let r=document.createElement(`div`);if(r.className=`loading`,r.textContent=`Loading...`,r.hidden=!0,this.shadowRoot.appendChild(r),this._loadingEl=r,!this.hasAttribute(`kiosk`)){let e=document.createElement(`div`);e.className=`chrome`,e.part=`chrome`;let t=document.createElement(`div`);t.className=`chat`,t.part=`chat`;let n=document.createElement(`div`);n.className=`input-row`;let r=document.createElement(`input`);r.type=`text`,r.placeholder=`Say something...`,r.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&r.value.trim()){let e=r.value.trim();r.value=``,this.say(e)}});let i=document.createElement(`button`);i.className=`icon mic`,i.title=`Push to talk`,i.innerHTML=`🎙`,i.addEventListener(`click`,()=>this._toggleMic()),n.appendChild(r),n.appendChild(i),e.appendChild(t),e.appendChild(n),this.shadowRoot.appendChild(e),this._chatEl=t,this._inputEl=r,this._micEl=i}}_applyLayout(){let e=this.getAttribute(`mode`)||`inline`;if(!EA.includes(e))return;if(e===`floating`){let e=this.getAttribute(`position`)||`bottom-right`,t=(this.getAttribute(`offset`)||`24px 24px`).split(/\s+/),[n,r]=[t[0],t[1]||t[0]];this.style.top=this.style.bottom=this.style.left=this.style.right=``,e.includes(`top`)?this.style.top=n:this.style.bottom=n,e.includes(`left`)?this.style.left=r:e.includes(`right`)?this.style.right=r:e.includes(`center`)&&(this.style.left=`50%`,this.style.transform=`translateX(-50%)`)}else this.style.top=this.style.bottom=this.style.left=this.style.right=this.style.transform=``;let t=this.getAttribute(`width`),n=this.getAttribute(`height`);t&&this.style.setProperty(`--agent-width`,t),n&&this.style.setProperty(`--agent-height`,n),e===`inline`&&(t&&(this.style.width=t),n&&(this.style.height=n))}_observeViewport(){if(!this.hasAttribute(`eager`)){if(typeof IntersectionObserver>`u`){this._boot();return}this._io=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(this._io.disconnect(),this._boot())}),this._io.observe(this)}}async _boot(){if(!(this._booting||this._mounted)){this._booting=!0;try{this._loadingEl.hidden=!1,this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`manifest`,pct:.1}}));let e=await this._resolveManifest();if(this._manifest=e,this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`manifest`,pct:.3}})),typeof e.brain?.instructions==`string`&&e.brain.instructions.endsWith(`.md`)){let t=await TA(e,e.brain.instructions);t&&(e.instructions=kA(t))}else e.brain?.instructions&&(e.instructions=e.brain.instructions);this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`body`,pct:.45}}));let t=new J_(this._stageEl,{kiosk:this.hasAttribute(`kiosk`)});this._viewer=t;let n=cv(e.body?.uri);n&&await t.load(n,``,new Map),this._scene=new dv(t),this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`memory`,pct:.6}}));let r=e.id?.agentId||this.getAttribute(`memory-key`)||e.name||`anon`;this._memory=await vv.load({mode:this.getAttribute(`memory`)||e.memory?.mode||`local`,namespace:r,manifestURI:e._baseURI+`manifest.json`,fetchFn:fetch.bind(globalThis)}),this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`skills`,pct:.75}})),this._skills=new mv({trust:this.getAttribute(`skill-trust`)||`owned-only`,ownerAddress:e.id?.owner});let i=e.skills||[];for(let t of i)try{let n=await this._skills.install(t,{bundleBase:e._baseURI});this.dispatchEvent(new CustomEvent(`skill:loaded`,{detail:{name:n.name,uri:n.uri}}))}catch(e){console.warn(`[agent-3d] skill load failed`,t,e)}this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`brain`,pct:.9}}));let a={apiKey:this.getAttribute(`api-key`)||void 0,proxyURL:this.getAttribute(`key-proxy`)||void 0};this._runtime=new av({manifest:e,viewer:this._scene,memory:this._memory,skills:this._skills,providerConfig:a});for(let e of[`brain:thinking`,`brain:message`,`skill:tool-called`,`voice:speech-start`,`voice:speech-end`,`voice:transcript`,`voice:listen-start`,`memory:write`])this._runtime.addEventListener(e,t=>{this.dispatchEvent(new CustomEvent(e,{detail:t.detail,bubbles:!0,composed:!0})),e===`brain:message`&&this._chatEl&&this._renderMessage(t.detail)});this._mounted=!0,this._loadingEl.hidden=!0,this._posterEl.style.opacity=`0`,this.dispatchEvent(new CustomEvent(`agent:ready`,{detail:{agent:this,manifest:e},bubbles:!0,composed:!0}))}catch(e){console.error(`[agent-3d] boot failed`,e),this._loadingEl.hidden=!0,this._showError(e),this.dispatchEvent(new CustomEvent(`agent:error`,{detail:{phase:`boot`,error:e},bubbles:!0,composed:!0}))}finally{this._booting=!1}}}async _resolveManifest(){let e=this.getAttribute(`src`),t=this.getAttribute(`manifest`),n=this.getAttribute(`body`);if(e)return bA(e,{rpcURL:this.getAttribute(`rpc-url`),registry:this.getAttribute(`registry`)});if(t)return bA(t);if(n){let e=this.getAttribute(`instructions`);return{spec:`agent-manifest/0.1`,_baseURI:``,name:this.getAttribute(`name`)||`Agent`,body:{uri:n,format:`gltf-binary`},brain:{provider:this.getAttribute(`brain`)?`anthropic`:`none`,model:this.getAttribute(`brain`)||void 0,instructions:e||`You are an embodied 3D agent.`},instructions:e||`You are an embodied 3D agent.`,voice:{tts:{provider:`browser`},stt:{provider:`browser`}},skills:(this.getAttribute(`skills`)||``).split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>({uri:e})),memory:{mode:this.getAttribute(`memory`)||`local`},tools:[`wave`,`lookAt`,`play_clip`,`setExpression`,`speak`,`remember`],version:`0.1.0`}}throw Error(`<agent-3d> requires src=, manifest=, or body= attribute`)}_renderMessage({role:e,content:t}){if(!this._chatEl||!t)return;let n=document.createElement(`div`);n.className=`msg`,n.innerHTML=`<div class="role">${e}</div><div class="body"></div>`,n.querySelector(`.body`).textContent=t,this._chatEl.appendChild(n),this._chatEl.scrollTop=this._chatEl.scrollHeight}_showError(e){let t=document.createElement(`div`);t.className=`error`,t.textContent=`Couldn't load agent: ${e.message||e}`,this.shadowRoot.appendChild(t)}async _toggleMic(){if(this._runtime){if(this._listening){this._runtime.stt?.stop(),this._listening=!1,this._micEl.dataset.listening=`false`;return}this._listening=!0,this._micEl.dataset.listening=`true`;try{let e=await this._runtime.listen();e&&await this.say(e,{voice:!0})}catch(e){console.warn(`[agent-3d] listen failed`,e)}finally{this._listening=!1,this._micEl.dataset.listening=`false`}}}_teardown(){try{this._io?.disconnect()}catch{}try{this._runtime?.destroy()}catch{}try{this._viewer?.dispose?.()}catch{}this._mounted=!1,this._runtime=this._viewer=this._scene=this._memory=this._skills=null}async say(e,t={}){return this._runtime||await this._waitForReady(),this._runtime.send(e,{voice:t.voice??this.hasAttribute(`voice`)})}async ask(e,t={}){return(await this.say(e,t))?.text||``}clearConversation(){this._runtime?.clearConversation()}async wave(e){return this._scene?.playAnimationByHint(`wave`,e)}async lookAt(e){return this._scene?.lookAt(e)}async play(e,t){return this._scene?.playClipByName(e,t)}async installSkill(e){if(!this._skills)throw Error(`Agent not mounted`);return this._skills.install({uri:e})}uninstallSkill(e){return this._skills?.uninstall(e)}get skills(){return this._skills?.all()||[]}get memory(){return this._memory}get manifest(){return this._manifest}get runtime(){return this._runtime}setMode(e){this.setAttribute(`mode`,e)}setPosition(e,t){this.setAttribute(`position`,e),t&&this.setAttribute(`offset`,t)}setSize(e,t){this.setAttribute(`width`,e),this.setAttribute(`height`,t)}pause(){this._runtime?.pause()}resume(){}destroy(){this._teardown()}_waitForReady(){return this._mounted?Promise.resolve():new Promise(e=>{let t=()=>{this.removeEventListener(`agent:ready`,t),e()};this.addEventListener(`agent:ready`,t),this._booting||this._boot()})}};function kA(e){let t=e.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/);return t?t[1]:e}customElements.get(`agent-3d`)||customElements.define(`agent-3d`,OA),e.Agent3DElement=OA,e.Memory=vv,e.Runtime=av,e.SceneController=dv,e.Skill=pv,e.SkillRegistry=mv,e.Viewer=J_,e.defineElement=(e=`agent-3d`)=>{customElements.get(e)||customElements.define(e,OA)},e.fetchRelative=TA,e.fetchWithFallback=lv,e.loadManifest=bA,e.normalize=CA,e.resolveURI=cv});
\ No newline at end of file
+`,jA=class extends HTMLElement{static get observedAttributes(){return[`src`,`manifest`,`body`,`agent-id`,`mode`,`position`,`width`,`height`,`voice`,`api-key`,`key-proxy`]}constructor(){super(),this.attachShadow({mode:`open`}),this._viewer=null,this._scene=null,this._runtime=null,this._memory=null,this._skills=null,this._manifest=null,this._mounted=!1,this._booting=!1,this._listening=!1}connectedCallback(){this._renderShell(),this._applyLayout(),this._observeViewport(),this.hasAttribute(`eager`)&&this._boot()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){this._mounted&&([`mode`,`position`,`width`,`height`].includes(e)&&this._applyLayout(),[`src`,`manifest`,`body`,`agent-id`].includes(e)&&(this._teardown(),this._boot()))}_renderShell(){let e=document.createElement(`style`);e.textContent=AA,this.shadowRoot.appendChild(e);let t=document.createElement(`div`);t.className=`stage`,t.part=`stage`,this.shadowRoot.appendChild(t),this._stageEl=t;let n=document.createElement(`div`);n.className=`poster`,this.getAttribute(`poster`)&&(n.style.backgroundImage=`url(${this.getAttribute(`poster`)})`),this.shadowRoot.appendChild(n),this._posterEl=n;let r=document.createElement(`div`);if(r.className=`loading`,r.textContent=`Loading...`,r.hidden=!0,this.shadowRoot.appendChild(r),this._loadingEl=r,!this.hasAttribute(`kiosk`)){let e=document.createElement(`div`);e.className=`chrome`,e.part=`chrome`;let t=document.createElement(`div`);t.className=`chat`,t.part=`chat`;let n=document.createElement(`div`);n.className=`input-row`;let r=document.createElement(`input`);r.type=`text`,r.placeholder=`Say something...`,r.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&r.value.trim()){let e=r.value.trim();r.value=``,this.say(e)}});let i=document.createElement(`button`);i.className=`icon mic`,i.title=`Push to talk`,i.innerHTML=`🎙`,i.addEventListener(`click`,()=>this._toggleMic()),n.appendChild(r),n.appendChild(i),e.appendChild(t),e.appendChild(n),this.shadowRoot.appendChild(e),this._chatEl=t,this._inputEl=r,this._micEl=i}}_applyLayout(){let e=this.getAttribute(`mode`)||`inline`;if(!kA.includes(e))return;if(e===`floating`){let e=this.getAttribute(`position`)||`bottom-right`,t=(this.getAttribute(`offset`)||`24px 24px`).split(/\s+/),[n,r]=[t[0],t[1]||t[0]];this.style.top=this.style.bottom=this.style.left=this.style.right=``,e.includes(`top`)?this.style.top=n:this.style.bottom=n,e.includes(`left`)?this.style.left=r:e.includes(`right`)?this.style.right=r:e.includes(`center`)&&(this.style.left=`50%`,this.style.transform=`translateX(-50%)`)}else this.style.top=this.style.bottom=this.style.left=this.style.right=this.style.transform=``;let t=this.getAttribute(`width`),n=this.getAttribute(`height`);t&&this.style.setProperty(`--agent-width`,t),n&&this.style.setProperty(`--agent-height`,n),e===`inline`&&(t&&(this.style.width=t),n&&(this.style.height=n))}_observeViewport(){if(!this.hasAttribute(`eager`)){if(typeof IntersectionObserver>`u`){this._boot();return}this._io=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(this._io.disconnect(),this._boot())}),this._io.observe(this)}}async _boot(){if(!(this._booting||this._mounted)){this._booting=!0;try{this._loadingEl.hidden=!1,this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`manifest`,pct:.1}}));let e=await this._resolveManifest();if(this._manifest=e,this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`manifest`,pct:.3}})),typeof e.brain?.instructions==`string`&&e.brain.instructions.endsWith(`.md`)){let t=await TA(e,e.brain.instructions);t&&(e.instructions=MA(t))}else e.brain?.instructions&&(e.instructions=e.brain.instructions);this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`body`,pct:.45}}));let t=new J_(this._stageEl,{kiosk:this.hasAttribute(`kiosk`)});this._viewer=t;let n=cv(e.body?.uri);n&&await t.load(n,``,new Map),this._scene=new dv(t),this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`memory`,pct:.6}}));let r=e.id?.agentId||this.getAttribute(`memory-key`)||e.name||`anon`;this._memory=await vv.load({mode:this.getAttribute(`memory`)||e.memory?.mode||`local`,namespace:r,manifestURI:e._baseURI+`manifest.json`,fetchFn:fetch.bind(globalThis)}),this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`skills`,pct:.75}})),this._skills=new mv({trust:this.getAttribute(`skill-trust`)||`owned-only`,ownerAddress:e.id?.owner});let i=e.skills||[];for(let t of i)try{let n=await this._skills.install(t,{bundleBase:e._baseURI});this.dispatchEvent(new CustomEvent(`skill:loaded`,{detail:{name:n.name,uri:n.uri}}))}catch(e){console.warn(`[agent-3d] skill load failed`,t,e)}this.dispatchEvent(new CustomEvent(`agent:load-progress`,{detail:{phase:`brain`,pct:.9}}));let a={apiKey:this.getAttribute(`api-key`)||void 0,proxyURL:this.getAttribute(`key-proxy`)||void 0};this._runtime=new av({manifest:e,viewer:this._scene,memory:this._memory,skills:this._skills,providerConfig:a});for(let e of[`brain:thinking`,`brain:message`,`skill:tool-called`,`voice:speech-start`,`voice:speech-end`,`voice:transcript`,`voice:listen-start`,`memory:write`])this._runtime.addEventListener(e,t=>{this.dispatchEvent(new CustomEvent(e,{detail:t.detail,bubbles:!0,composed:!0})),e===`brain:message`&&this._chatEl&&this._renderMessage(t.detail)});this._mounted=!0,this._loadingEl.hidden=!0,this._posterEl.style.opacity=`0`,this.dispatchEvent(new CustomEvent(`agent:ready`,{detail:{agent:this,manifest:e},bubbles:!0,composed:!0}))}catch(e){console.error(`[agent-3d] boot failed`,e),this._loadingEl.hidden=!0,this._showError(e),this.dispatchEvent(new CustomEvent(`agent:error`,{detail:{phase:`boot`,error:e},bubbles:!0,composed:!0}))}finally{this._booting=!1}}}async _resolveManifest(){let e=this.getAttribute(`src`),t=this.getAttribute(`manifest`),n=this.getAttribute(`body`),r=this.getAttribute(`agent-id`);if(e)return r&&console.warn(`[agent-3d] both src and agent-id provided; using src`),bA(e,{rpcURL:this.getAttribute(`rpc-url`),registry:this.getAttribute(`registry`)});if(r)return OA(r);if(t)return bA(t);if(n){let e=this.getAttribute(`instructions`);return{spec:`agent-manifest/0.1`,_baseURI:``,name:this.getAttribute(`name`)||`Agent`,body:{uri:n,format:`gltf-binary`},brain:{provider:this.getAttribute(`brain`)?`anthropic`:`none`,model:this.getAttribute(`brain`)||void 0,instructions:e||`You are an embodied 3D agent.`},instructions:e||`You are an embodied 3D agent.`,voice:{tts:{provider:`browser`},stt:{provider:`browser`}},skills:(this.getAttribute(`skills`)||``).split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>({uri:e})),memory:{mode:this.getAttribute(`memory`)||`local`},tools:[`wave`,`lookAt`,`play_clip`,`setExpression`,`speak`,`remember`],version:`0.1.0`}}throw Error(`<agent-3d> requires src=, manifest=, or body= attribute`)}_renderMessage({role:e,content:t}){if(!this._chatEl||!t)return;let n=document.createElement(`div`);n.className=`msg`,n.innerHTML=`<div class="role">${e}</div><div class="body"></div>`,n.querySelector(`.body`).textContent=t,this._chatEl.appendChild(n),this._chatEl.scrollTop=this._chatEl.scrollHeight}_showError(e){let t=document.createElement(`div`);t.className=`error`,t.textContent=`Couldn't load agent: ${e.message||e}`,this.shadowRoot.appendChild(t)}async _toggleMic(){if(this._runtime){if(this._listening){this._runtime.stt?.stop(),this._listening=!1,this._micEl.dataset.listening=`false`;return}this._listening=!0,this._micEl.dataset.listening=`true`;try{let e=await this._runtime.listen();e&&await this.say(e,{voice:!0})}catch(e){console.warn(`[agent-3d] listen failed`,e)}finally{this._listening=!1,this._micEl.dataset.listening=`false`}}}_teardown(){try{this._io?.disconnect()}catch{}try{this._runtime?.destroy()}catch{}try{this._viewer?.dispose?.()}catch{}this._mounted=!1,this._runtime=this._viewer=this._scene=this._memory=this._skills=null}async say(e,t={}){return this._runtime||await this._waitForReady(),this._runtime.send(e,{voice:t.voice??this.hasAttribute(`voice`)})}async ask(e,t={}){return(await this.say(e,t))?.text||``}clearConversation(){this._runtime?.clearConversation()}async wave(e){return this._scene?.playAnimationByHint(`wave`,e)}async lookAt(e){return this._scene?.lookAt(e)}async play(e,t){return this._scene?.playClipByName(e,t)}async installSkill(e){if(!this._skills)throw Error(`Agent not mounted`);return this._skills.install({uri:e})}uninstallSkill(e){return this._skills?.uninstall(e)}get skills(){return this._skills?.all()||[]}get memory(){return this._memory}get manifest(){return this._manifest}get runtime(){return this._runtime}setMode(e){this.setAttribute(`mode`,e)}setPosition(e,t){this.setAttribute(`position`,e),t&&this.setAttribute(`offset`,t)}setSize(e,t){this.setAttribute(`width`,e),this.setAttribute(`height`,t)}pause(){this._runtime?.pause()}resume(){}destroy(){this._teardown()}_waitForReady(){return this._mounted?Promise.resolve():new Promise(e=>{let t=()=>{this.removeEventListener(`agent:ready`,t),e()};this.addEventListener(`agent:ready`,t),this._booting||this._boot()})}};function MA(e){let t=e.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/);return t?t[1]:e}customElements.get(`agent-3d`)||customElements.define(`agent-3d`,jA),e.Agent3DElement=jA,e.Memory=vv,e.Runtime=av,e.SceneController=dv,e.Skill=pv,e.SkillRegistry=mv,e.Viewer=J_,e.defineElement=(e=`agent-3d`)=>{customElements.get(e)||customElements.define(e,jA)},e.fetchRelative=TA,e.fetchWithFallback=lv,e.loadManifest=bA,e.normalize=CA,e.resolveURI=cv});
\ No newline at end of file
diff --git a/dist-lib/agent/embed.html b/dist-lib/agent/embed.html
new file mode 100644
index 000000000..4ce762626
--- /dev/null
+++ b/dist-lib/agent/embed.html
@@ -0,0 +1,91 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8" />
+ <title>Agent</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="Embedded 3D agent avatar." />
+ <meta name="robots" content="noindex" />
+ <style>
+ html, body { margin: 0; padding: 0; height: 100%; width: 100%; background: transparent; overflow: hidden; font-family: system-ui, sans-serif; }
+ #stage { position: absolute; inset: 0; }
+ #stage canvas { display: block; width: 100% !important; height: 100% !important; }
+ #stage .gui-wrap, #stage .gui-toggle, #stage .annotation-canvas { display: none !important; }
+ #stage .model-info { display: none !important; }
+ #name-plate {
+ position: absolute; left: 12px; bottom: 10px; z-index: 2; pointer-events: none;
+ font-size: 11px; color: rgba(255,255,255,0.55); letter-spacing: 0.04em;
+ text-shadow: 0 1px 2px rgba(0,0,0,0.6);
+ }
+ #error {
+ position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
+ color: rgba(255,255,255,0.4); font-size: 12px; padding: 1rem; text-align: center;
+ }
+ body.bg-dark { background: #0b0d10; }
+ body.bg-light { background: #f5f5f5; }
+ </style>
+</head>
+<body>
+ <div id="stage"></div>
+ <div id="name-plate"></div>
+ <div id="error"></div>
+
+ <script type="module">
+ import { Viewer } from '/src/viewer.js';
+ import { AgentIdentity } from '/src/agent-identity.js';
+ import { AgentAvatar } from '/src/agent-avatar.js';
+ import { protocol } from '/src/agent-protocol.js';
+
+ const params = new URL(location.href).searchParams;
+ const bg = params.get('bg') || 'transparent';
+ if (bg === 'dark') document.body.classList.add('bg-dark');
+ if (bg === 'light') document.body.classList.add('bg-light');
+
+ const plateOn = params.get('name') !== '0';
+ const parts = location.pathname.split('/').filter(Boolean);
+ const agentId = parts[parts.indexOf('agent') + 1];
+
+ async function main() {
+ const identity = new AgentIdentity({ agentId, autoLoad: false });
+ await identity.load();
+
+ if (plateOn && identity.name) {
+ document.getElementById('name-plate').textContent = identity.name;
+ }
+
+ if (!identity.avatarId) throw new Error('agent has no avatar body');
+
+ const resp = await fetch(`/api/avatars/${identity.avatarId}`, { credentials: 'include' });
+ if (!resp.ok) throw new Error(`avatar ${resp.status}`);
+ const { avatar } = await resp.json();
+ const glbUrl = avatar?.url;
+ if (!glbUrl) throw new Error('no avatar url');
+
+ const stage = document.getElementById('stage');
+ const viewer = new Viewer(stage, { kiosk: true });
+ if (bg === 'transparent') {
+ viewer.renderer?.setClearAlpha(0);
+ if (viewer.scene) viewer.scene.background = null;
+ }
+ await viewer.load(glbUrl, '', new Map());
+
+ const avatarCtl = new AgentAvatar(viewer, protocol, identity);
+ avatarCtl.attach();
+
+ // Expose to host via postMessage bridge
+ window.addEventListener('message', (ev) => {
+ const msg = ev.data;
+ if (!msg || msg.__agent !== agentId) return;
+ if (msg.type === 'action' && msg.action) protocol.emit(msg.action);
+ });
+ parent?.postMessage({ __agent: agentId, type: 'ready', name: identity.name }, '*');
+ }
+
+ main().catch(err => {
+ const el = document.getElementById('error');
+ el.textContent = err.message || 'Could not load agent';
+ el.style.display = 'flex';
+ });
+ </script>
+</body>
+</html>
diff --git a/dist-lib/agent/index.html b/dist-lib/agent/index.html
index 7ef5f08d4..196449ddd 100644
--- a/dist-lib/agent/index.html
+++ b/dist-lib/agent/index.html
@@ -13,6 +13,18 @@
<link rel="stylesheet" href="/style.css" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap" rel="stylesheet" />
+ <!-- unfurl (populated at runtime from identity) -->
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="Agent" id="og-title" />
+ <meta property="og:description" content="An embodied 3D agent." id="og-description" />
+ <meta property="og:image" content="" id="og-image" />
+ <meta property="og:url" content="" id="og-url" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="Agent" id="tw-title" />
+ <meta name="twitter:description" content="" id="tw-description" />
+ <meta name="twitter:image" content="" id="tw-image" />
+ <link rel="alternate" type="application/json+oembed" href="" id="oembed-link" title="Agent oEmbed" />
+
<style>
body {
overflow: auto;
@@ -83,23 +95,79 @@
padding: 0 1rem;
}
+ .agent-embed-tabs {
+ display: flex;
+ gap: 0.382rem;
+ margin-bottom: 0.618rem;
+ }
+
+ .agent-embed-tab {
+ background: transparent;
+ border: 1px solid rgba(255,255,255,0.1);
+ color: rgba(255,255,255,0.5);
+ font-size: 0.618rem;
+ padding: 0.236rem 0.618rem;
+ border-radius: 999px;
+ cursor: pointer;
+ font-family: inherit;
+ }
+
+ .agent-embed-tab.active {
+ background: rgba(255,255,255,0.08);
+ color: rgba(255,255,255,0.9);
+ border-color: rgba(255,255,255,0.2);
+ }
+
+ .agent-embed-code-wrap {
+ position: relative;
+ }
+
.agent-embed-code {
background: rgba(255,255,255,0.04);
border: 1px solid rgba(255,255,255,0.08);
border-radius: 8px;
padding: 0.618rem 1rem;
+ padding-right: 3.8rem;
font-family: monospace;
font-size: 0.618rem;
- color: rgba(255,255,255,0.4);
+ color: rgba(255,255,255,0.55);
word-break: break-all;
+ line-height: 1.5;
}
+ .agent-embed-copy {
+ position: absolute;
+ top: 0.382rem;
+ right: 0.382rem;
+ background: rgba(255,255,255,0.06);
+ border: 1px solid rgba(255,255,255,0.1);
+ color: rgba(255,255,255,0.6);
+ font-size: 0.618rem;
+ padding: 0.236rem 0.618rem;
+ border-radius: 6px;
+ cursor: pointer;
+ font-family: inherit;
+ }
+
+ .agent-embed-copy:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.1); }
+ .agent-embed-copy.copied { color: #86efac; border-color: rgba(134,239,172,0.3); }
+
.agent-embed-label {
font-size: 0.618rem;
color: rgba(255,255,255,0.25);
margin-bottom: 0.382rem;
}
+ .agent-embed-preview-link {
+ display: inline-block;
+ margin-top: 0.618rem;
+ font-size: 0.618rem;
+ color: rgba(255,255,255,0.35);
+ text-decoration: none;
+ }
+
+ .agent-embed-preview-link:hover { color: rgba(255,255,255,0.7); }
+
.agent-skills-full {
max-width: 420px;
margin: 1.618rem auto 0;
@@ -175,8 +243,17 @@
<!-- Embed code -->
<div class="agent-embed-hint" id="agent-embed-section" style="display:none">
- <div class="agent-embed-label">Embed this agent</div>
- <div class="agent-embed-code" id="agent-embed-code"></div>
+ <div class="agent-embed-label">Share &amp; embed</div>
+ <div class="agent-embed-tabs" role="tablist">
+ <button class="agent-embed-tab active" data-tab="iframe">iframe</button>
+ <button class="agent-embed-tab" data-tab="link">link</button>
+ <button class="agent-embed-tab" data-tab="webcomponent">&lt;agent-3d&gt;</button>
+ </div>
+ <div class="agent-embed-code-wrap">
+ <div class="agent-embed-code" id="agent-embed-code"></div>
+ <button class="agent-embed-copy" id="agent-embed-copy">copy</button>
+ </div>
+ <a class="agent-embed-preview-link" id="agent-embed-preview" target="_blank" rel="noopener">preview embed →</a>
</div>
<script type="module">
@@ -225,9 +302,40 @@
// Embed code
const embedSection = document.getElementById('agent-embed-section');
const embedCode = document.getElementById('agent-embed-code');
- const embedUrl = `${location.origin}/agent/${identity.id}`;
+ const embedCopy = document.getElementById('agent-embed-copy');
+ const embedPreview = document.getElementById('agent-embed-preview');
+ const origin = location.origin;
+ const embedUrl = `${origin}/agent/${identity.id}/embed`;
+ const agentUrl = `${origin}/agent/${identity.id}`;
+
+ const snippets = {
+ iframe: `<iframe src="${embedUrl}" width="420" height="520" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking"></iframe>`,
+ link: agentUrl,
+ webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d agent-id="${identity.id}" style="width:420px;height:520px"></agent-3d>`,
+ };
+
+ let current = 'iframe';
+ const render = () => { embedCode.textContent = snippets[current]; };
+ render();
embedSection.style.display = '';
- embedCode.textContent = `<iframe src="${embedUrl}" width="420" height="520" frameborder="0" style="border-radius:12px;border:none;"></iframe>`;
+ embedPreview.href = embedUrl;
+
+ document.querySelectorAll('.agent-embed-tab').forEach(btn => {
+ btn.addEventListener('click', () => {
+ current = btn.dataset.tab;
+ document.querySelectorAll('.agent-embed-tab').forEach(b => b.classList.toggle('active', b === btn));
+ render();
+ });
+ });
+
+ embedCopy.addEventListener('click', async () => {
+ try {
+ await navigator.clipboard.writeText(snippets[current]);
+ embedCopy.textContent = 'copied';
+ embedCopy.classList.add('copied');
+ setTimeout(() => { embedCopy.textContent = 'copy'; embedCopy.classList.remove('copied'); }, 1400);
+ } catch {}
+ });
}
main().catch(err => {
diff --git a/dist-lib/robots.txt b/dist-lib/robots.txt
index 223358ba6..fb4b4747d 100644
--- a/dist-lib/robots.txt
+++ b/dist-lib/robots.txt
@@ -1,3 +1,3 @@
User-agent: *
Allow: /
-Sitemap: https://3d.irish/sitemap.xml
+Sitemap: https://3dagent.vercel.app/sitemap.xml
diff --git a/dist-lib/sitemap.xml b/dist-lib/sitemap.xml
index 9c7e903d2..068b429e5 100644
--- a/dist-lib/sitemap.xml
+++ b/dist-lib/sitemap.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
- <loc>https://3d.irish/</loc>
+ <loc>https://3dagent.vercel.app/</loc>
<lastmod>2026-04-14</lastmod>
<priority>1.0</priority>
</url>
diff --git a/prompts/embed/01-og-oembed.md b/prompts/embed/01-og-oembed.md
new file mode 100644
index 000000000..00f51c793
--- /dev/null
+++ b/prompts/embed/01-og-oembed.md
@@ -0,0 +1,99 @@
+# Task 01 — Link unfurl: OG image + oEmbed for `/agent/:id`
+
+## Why this exists
+
+When anyone pastes an agent URL like `https://3dagent.vercel.app/agent/ab12cd` into Slack, X, Discord, iMessage, or Notion, it should unfurl into a rich card with a thumbnail of the avatar, the agent's name, and its description. Today it shows the generic site favicon. That is the single highest-leverage discovery surface for embodied agents — fix it.
+
+## Shared context
+
+- Routes already exist: `/agent/:id` (home card) and `/agent/:id/embed` (bare avatar). Do not change those.
+- [public/agent/index.html](../../public/agent/index.html) is the HTML shell the home route renders. It currently has static `<title>Agent Home — 3D Agent</title>` and no OG / Twitter / oEmbed meta tags.
+- The share panel on that page is already built and works. You only need to improve what link-previewers see — do not touch the share-panel UI.
+- Agent records are fetched via `GET /api/agents/:id` → `{ agent: { id, name, description, avatar_id, ... } }` (see [api/agents/[id].js](../../api/agents/[id].js)).
+- Avatar records: `GET /api/avatars/:id` → `{ avatar: { url, thumbnail_url, ... } }`. Use `thumbnail_url` if present; otherwise render the OG image from the GLB (see "OG image implementation" below).
+- HTTP helpers: [api/_lib/http.js](../../api/_lib/http.js) exports `cors`, `json`, `error`, `wrap`, `method`.
+- Avatar helpers: [api/_lib/avatars.js](../../api/_lib/avatars.js) exports `getAvatar`, `resolveAvatarUrl`.
+
+## What to build
+
+### 1. `GET /api/agent/:id/og` → PNG (1200×630)
+
+New file: `api/agent-og.js`.
+
+- If the avatar record has a `thumbnail_url`, 302 redirect to it with `Cache-Control: public, max-age=3600`. Done — that's the happy path.
+- If no thumbnail exists, respond with a minimal SVG-as-PNG card rendered server-side: dark background (`#0b0d10`), agent name large, description small, a small `◎` glyph. Use `Content-Type: image/svg+xml` (Slack/X/Discord accept SVG for OG images) — **do not** pull in a canvas or image-processing dependency. Wrap in `wrap()` and support `OPTIONS` via `cors()`.
+- If the agent doesn't exist, return 404 with a placeholder SVG that says "Agent not found".
+- Cache header: `public, max-age=3600, s-maxage=86400`.
+
+### 2. `GET /api/oembed?url=<agent-url>[&format=json]` → oEmbed JSON
+
+New file: `api/agent-oembed.js`.
+
+- Spec: https://oembed.com/ — type `rich` with an HTML payload that is a sandboxed iframe pointing at `/agent/:id/embed`.
+- Required fields: `type`, `version: "1.0"`, `provider_name: "3D Agent"`, `provider_url`, `title`, `html`, `width`, `height`, `thumbnail_url`, `thumbnail_width`, `thumbnail_height`, `author_name` (agent name).
+- Validate `url` is on the same origin and matches `/agent/[A-Za-z0-9_-]+` — reject otherwise with 404.
+- If `format=xml`, return oEmbed XML. Otherwise JSON. Default JSON.
+- Cache header: `public, max-age=900`.
+
+### 3. Head-tag injection on `/agent/:id`
+
+Edit [public/agent/index.html](../../public/agent/index.html) — **only inside `<head>`**, do not touch `<body>` or scripts.
+
+Add these tags. Use placeholder `__AGENT__` tokens for any per-agent values — then in the existing `<script type="module">` block's `main()` function, after `identity.load()`, write a helper that mutates the relevant `<meta>` / `<link>` elements from `identity.name`, `identity.description`, and the known agent id. **Scope your edit to adding a single helper call at the end of the existing `main()` function plus the new `<head>` tags. Do not refactor the surrounding script.**
+
+```html
+<!-- unfurl (populated at runtime from identity) -->
+<meta property="og:type" content="website" />
+<meta property="og:title" content="Agent" id="og-title" />
+<meta property="og:description" content="An embodied 3D agent." id="og-description" />
+<meta property="og:image" content="" id="og-image" />
+<meta property="og:url" content="" id="og-url" />
+<meta name="twitter:card" content="summary_large_image" />
+<meta name="twitter:title" content="Agent" id="tw-title" />
+<meta name="twitter:description" content="" id="tw-description" />
+<meta name="twitter:image" content="" id="tw-image" />
+<link rel="alternate" type="application/json+oembed" href="" id="oembed-link" title="Agent oEmbed" />
+```
+
+In the runtime helper, populate every `id` above once identity loads. `og:image` and `twitter:image` → `/api/agent/{id}/og`. `og:url` → `location.href`. `oembed-link.href` → `/api/oembed?url=<encoded agent url>`.
+
+### 4. Route wiring
+
+Edit [vercel.json](../../vercel.json). Add these two lines **immediately after** the `"src": "/api/agent-memory"` line (line ~27), so they live with the other `/api/agent-*` routes:
+
+```json
+{ "src": "/api/agent/([^/]+)/og", "dest": "/api/agent-og?id=$1" },
+{ "src": "/api/oembed", "dest": "/api/agent-oembed" },
+```
+
+Do not touch any other route.
+
+## Files you own (create / edit)
+
+- Create: `api/agent-og.js`, `api/agent-oembed.js`
+- Edit: `public/agent/index.html` (`<head>` + one helper added to `main()`), `vercel.json` (two route adds)
+
+## Files off-limits (other tasks are editing these)
+
+- `src/element.js`, `src/agent-resolver.js` — owned by task 02
+- `public/agent/embed.html`, `api/agents/[id]/embed-policy.js`, anything under `public/dashboard/` — owned by task 03
+- The `<body>` of `public/agent/index.html` (share panel) — already built, do not edit
+
+## Acceptance test
+
+1. `node --check api/agent-og.js api/agent-oembed.js` passes.
+2. `npx vite build` — note result.
+3. Manual URL checks (report the response shape):
+ - `GET /api/agent/SOMEID/og` → 200 image or 302 to thumbnail.
+ - `GET /api/oembed?url=http://localhost:3000/agent/SOMEID` → 200 JSON with `html` containing an iframe pointing at `/agent/SOMEID/embed`.
+ - `GET /agent/SOMEID` → `<head>` contains populated `og:image` with `/api/agent/SOMEID/og`.
+4. Paste a real agent URL into https://www.opengraph.xyz/ or Slack's link-preview debugger and confirm the card renders (manual — flag if you can't test this).
+
+## Reporting
+
+Report:
+- Files created and line counts
+- Files edited with which sections touched
+- `node --check` / `vite build` results
+- Any unrelated bugs noticed
+- Any deviation from the spec above, with reasoning
diff --git a/prompts/embed/02-agent-id-resolver.md b/prompts/embed/02-agent-id-resolver.md
new file mode 100644
index 000000000..29db44f6d
--- /dev/null
+++ b/prompts/embed/02-agent-id-resolver.md
@@ -0,0 +1,107 @@
+# Task 02 — `<agent-3d agent-id="...">` native resolver
+
+## Why this exists
+
+The `<agent-3d>` web component in [src/element.js](../../src/element.js) today only accepts `src="agent://chain/id"` or a manifest URL. The share panel on `/agent/:id` exposes a web-component snippet, but for a fresh hosted agent (no on-chain record, no manifest file yet), there is no way to embed via the component — only iframe works.
+
+We want: `<agent-3d agent-id="ab12cd">` resolves directly against the hosted API (`/api/agents/:id` + `/api/avatars/:avatarId`) and builds an in-memory manifest on the fly. Zero on-chain dependency. Zero filesystem manifest required.
+
+## Shared context
+
+- [src/element.js](../../src/element.js) is the full `<agent-3d>` custom element. Its `_boot()` method currently:
+ 1. Calls `_resolveManifest()` which reads the `src` attribute.
+ 2. Loads the manifest, resolves `manifest.body.uri` as a GLB, constructs a `Viewer`, loads the GLB, wires Memory/Skills/Runtime.
+- You are adding a **third path** into `_resolveManifest()` that activates when the element has an `agent-id` attribute (and no `src`).
+- API:
+ - `GET /api/agents/:id` → `{ agent: { id, name, description, avatar_id, skills, wallet_address, chain_id, meta, ... } }`
+ - `GET /api/avatars/:id` → `{ avatar: { url, thumbnail_url, ... } }` — `url` is the GLB
+- The existing manifest loader is in [src/manifest.js](../../src/manifest.js). The in-memory manifest you build should be shaped the same way a file-based manifest looks, so downstream code (`manifest.brain`, `manifest.body.uri`, `manifest.skills`, `manifest.id`, `manifest._baseURI`) just works.
+
+## What to build
+
+### 1. New resolver module
+
+Create `src/agent-resolver.js`. Exports one function:
+
+```js
+export async function resolveAgentById(agentId, { origin = location.origin, fetchFn = fetch } = {}) {
+ // 1. Fetch /api/agents/:id — throw a typed error on non-200
+ // 2. Fetch /api/avatars/:avatar_id — throw if no avatar bound
+ // 3. Return a manifest-shaped object:
+ // {
+ // name, description,
+ // id: { agentId, owner, chainId, walletAddress },
+ // body: { uri: avatar.url },
+ // brain: {},
+ // skills: agent.skills ?? [],
+ // memory: { mode: 'remote', namespace: agentId },
+ // _baseURI: `${origin}/agent/${agentId}/`,
+ // _source: 'agent-id',
+ // }
+}
+```
+
+- No new dependencies.
+- Use `credentials: 'include'` on both fetches (agents may be private).
+- Throw instances of a local `AgentResolveError` class with a `.code` property (`not_found`, `no_avatar`, `network`, `unauthorized`) so callers can branch.
+- Export the error class too.
+
+### 2. Wire it into `<agent-3d>`
+
+Edit [src/element.js](../../src/element.js):
+
+- Add `'agent-id'` to the observed-attributes list (search for `observedAttributes` — if it exists). If re-renders on attribute change aren't supported for other attributes, don't add observation; just require it to be present on connect.
+- In `_resolveManifest()` (or wherever `src` is read), add an early branch: if `this.hasAttribute('agent-id')` and no `src`, call `resolveAgentById(this.getAttribute('agent-id'))` and return its result. Bypass the rest of the URL/IPFS resolution path.
+- If both `agent-id` and `src` are present, prefer `src` (the existing path) and log a one-line console warning.
+- On resolver error, dispatch the existing error-phase event the element uses for manifest failures. Do not invent a new event type.
+- Import:
+ ```js
+ import { resolveAgentById, AgentResolveError } from './agent-resolver.js';
+ ```
+
+### 3. Update the share-panel snippet (one-line edit)
+
+In [public/agent/index.html](../../public/agent/index.html), find the `webcomponent` snippet in the `snippets` object:
+
+```js
+webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d src="${agentUrl}/manifest.json" style="width:420px;height:520px"></agent-3d>`,
+```
+
+Change it to use `agent-id`:
+
+```js
+webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d agent-id="${identity.id}" style="width:420px;height:520px"></agent-3d>`,
+```
+
+**Only this one line.** Do not touch anything else in `public/agent/index.html` — task 01 is editing `<head>` there.
+
+## Files you own (create / edit)
+
+- Create: `src/agent-resolver.js`
+- Edit: `src/element.js`, `public/agent/index.html` (exactly the one line above)
+
+## Files off-limits (other tasks are editing these)
+
+- `public/agent/embed.html`, `api/agents/[id]/embed-policy.js`, anything under `public/dashboard/` — owned by task 03
+- `api/agent-og.js`, `api/agent-oembed.js`, `<head>` of `public/agent/index.html`, `vercel.json` — owned by task 01
+- `api/agents/[id].js`, `api/avatars/[id].js` — do not modify server endpoints; use them as-is
+
+## Acceptance test
+
+1. `node --check src/agent-resolver.js src/element.js` passes.
+2. `npx vite build` — note result (the web-component bundle should still build).
+3. Manual test — write a tiny ad-hoc HTML page (do not commit it) that loads `<agent-3d agent-id="REAL_AGENT_ID">` against a local or deployed backend and confirm:
+ - Avatar GLB loads in the stage
+ - Agent name appears in the chrome
+ - Console shows no unhandled errors
+4. Edge case: `<agent-3d agent-id="does-not-exist">` — confirm it dispatches the manifest-error event without throwing uncaught.
+
+## Reporting
+
+Report:
+- `src/agent-resolver.js` line count and exported symbols
+- Exact diff summary for `src/element.js` (which methods touched)
+- The one-line diff for `public/agent/index.html`
+- `node --check` / `vite build` results
+- Whether manual smoke test passed, or why it couldn't be run
+- Any unrelated bugs noticed in `src/element.js` (there may be dead code; don't fix, just note)
diff --git a/prompts/embed/03-embed-allowlist.md b/prompts/embed/03-embed-allowlist.md
new file mode 100644
index 000000000..3723bcce4
--- /dev/null
+++ b/prompts/embed/03-embed-allowlist.md
@@ -0,0 +1,113 @@
+# Task 03 — Per-agent embed referrer allowlist
+
+## Why this exists
+
+Right now `/agent/:id/embed` renders for anyone who iframes it. Agent owners may want to gate where their avatar appears — e.g. "only embed on my portfolio and my Substack, block everywhere else." This is the control surface that makes owners comfortable sharing the embed URL publicly.
+
+## Shared context
+
+- Embed page: [public/agent/embed.html](../../public/agent/embed.html) — loads the avatar, no chrome. You will add a **referrer check** that runs before the 3D scene mounts.
+- Agent records are stored server-side; there is no `embed_policy` field yet — you add it.
+- Auth helpers: [api/_lib/auth.js](../../api/_lib/auth.js) exports `getSessionUser`, `authenticateBearer`, `extractBearer`, `hasScope`.
+- HTTP helpers: [api/_lib/http.js](../../api/_lib/http.js) exports `cors`, `json`, `error`, `wrap`, `method`, `readJson`.
+- Existing agent endpoint: [api/agents/[id].js](../../api/agents/[id].js) — do **not** modify it. Add a sibling endpoint for policy (spec below).
+- DB layer: agents are in table `agent_identities`. Find the current schema file (search for `CREATE TABLE agent_identities` in the repo) and extend it with your migration file. Do not modify existing migrations.
+
+## What to build
+
+### 1. Schema migration — add `embed_policy` column
+
+- Add a migration file alongside existing ones (follow whatever naming pattern you find — e.g. `specs/schema/NNN-embed-policy.sql`, or wherever migrations live). If you cannot locate a migrations directory, create `specs/schema/embed-policy.sql` with just the `ALTER TABLE` and a comment explaining it needs to be applied manually.
+- Column: `embed_policy JSONB` — nullable (null = "allow all embeds," the current behavior).
+- Shape when non-null:
+ ```json
+ { "mode": "allowlist", "hosts": ["example.com", "*.substack.com"] }
+ ```
+ `mode` is `"allowlist"` or `"denylist"`. `hosts` supports exact matches and a single leading-wildcard segment (`*.foo.com`).
+
+### 2. Server endpoint — `GET / PUT /api/agents/:id/embed-policy`
+
+New file: `api/agents/[id]/embed-policy.js`.
+
+- `GET` is **public** and returns `{ policy: <object or null> }`. No auth required — the embed page calls this.
+- `PUT` requires session auth (the signed-in owner of the agent) via `getSessionUser()`. Validates body as `{ mode: "allowlist"|"denylist", hosts: string[] }`. Returns the updated policy. 403 if the caller isn't the agent's owner.
+- `DELETE` clears the policy (back to "allow all"). Owner-only.
+- Use `cors`, `method`, `wrap`, `readJson`, `error`, `json`. Follow the shape of [api/avatars/[id].js](../../api/avatars/[id].js) as a reference.
+- Validate with `zod` (already a project dep — see how [api/avatars/[id].js](../../api/avatars/[id].js) uses it).
+
+Route wiring in [vercel.json](../../vercel.json): add **immediately after** the `"src": "/api/agents/([^/]+)/wallet"` line (~line 22), so it lives with the other `/api/agents/:id/...` routes:
+
+```json
+{ "src": "/api/agents/([^/]+)/embed-policy", "dest": "/api/agents/[id]/embed-policy?id=$1" },
+```
+
+Do not touch any other route.
+
+### 3. Referrer check in the embed page
+
+Edit [public/agent/embed.html](../../public/agent/embed.html):
+
+- Before creating the `Viewer`, fetch `GET /api/agents/${agentId}/embed-policy`.
+- If `policy === null` → proceed (current behavior, allow all).
+- Otherwise, derive the embedding host from `document.referrer` (top-level) or `window.location.ancestorOrigins?.[0]` when available. Parse the hostname.
+ - Browser note: `ancestorOrigins` is Chromium/Safari only. `document.referrer` is the correct cross-browser signal for the parent origin of a first-party iframe. Prefer `ancestorOrigins` when present; fall back to `referrer`.
+- Match the host against `policy.hosts` with leading-`*` wildcard support.
+- On block: replace the stage with a small centered message — "This agent can only be embedded on approved sites." — style to match the existing `#error` div. Do not render the avatar.
+- On allow: proceed as before.
+- Add a query-string override `?preview=1` that skips the check — used by the owner's share-panel preview link and by the `/agent/:id` page when it links to `/embed` from the same origin.
+
+Keep the edit scoped: add one `async checkPolicy()` helper and call it at the top of `main()`. Do not refactor the rest of the script.
+
+### 4. Dashboard UI — owner-side allowlist editor
+
+Create a new page (or panel, depending on the dashboard's structure — inspect [public/dashboard/index.html](../../public/dashboard/index.html) first):
+
+- Preferred: new file `public/dashboard/embed-policy.html` reachable as `/dashboard/embed-policy?agent=ID`. Use the dashboard's existing CSS and header chrome.
+- It lists the agent's current policy, lets the owner toggle mode (off / allowlist / denylist), edit the hosts list, and save. Use `fetch` against `/api/agents/:id/embed-policy` with `credentials: 'include'`.
+- If you find the dashboard already uses a SPA pattern with a common shell, add a panel instead of a new page — whichever is less invasive. Document which pattern you followed in your report.
+
+### 5. Wire a link from the agent page
+
+In [public/agent/index.html](../../public/agent/index.html), near the existing "preview embed →" link (it already exists — grep for `agent-embed-preview`), add **one sibling link** right after it:
+
+```html
+<a class="agent-embed-preview-link" id="agent-embed-settings" href="" target="_blank" rel="noopener">embed settings →</a>
+```
+
+And in the existing script, set `.href = '/dashboard/embed-policy?agent=' + identity.id`. Only this link — do not touch anything else in the file.
+
+## Files you own (create / edit)
+
+- Create: `api/agents/[id]/embed-policy.js`, schema migration file, `public/dashboard/embed-policy.html` (or equivalent panel file)
+- Edit: `public/agent/embed.html` (add `checkPolicy` helper + call), `vercel.json` (one route add), `public/agent/index.html` (exactly the one `<a>` + one js line described above)
+
+## Files off-limits (other tasks are editing these)
+
+- `src/element.js`, `src/agent-resolver.js` — owned by task 02
+- The webcomponent snippet line in `public/agent/index.html` — owned by task 02
+- `api/agent-og.js`, `api/agent-oembed.js`, `<head>` of `public/agent/index.html` — owned by task 01
+- `api/agents/[id].js`, `api/avatars/[id].js` — do not modify
+
+## Acceptance test
+
+1. `node --check api/agents/[id]/embed-policy.js` passes.
+2. `npx vite build` — note result.
+3. Manual:
+ - `GET /api/agents/SOMEID/embed-policy` → `{ policy: null }` when unset.
+ - As owner, `PUT /api/agents/SOMEID/embed-policy` with `{ mode: "allowlist", hosts: ["example.com"] }` → returns the policy.
+ - `GET` again returns it.
+ - `DELETE` clears it.
+ - Open `/agent/SOMEID/embed` from the project origin — still loads (same-origin implicit allow OR `?preview=1`).
+ - Open an iframe of `/agent/SOMEID/embed` from a page on a disallowed host — confirm the block message renders instead of the avatar.
+4. Dashboard page loads, shows current policy, saves a change, reload reflects it.
+
+## Reporting
+
+Report:
+- All created files with line counts
+- Files edited with which sections touched (keep edits narrowly scoped — call out if you had to go beyond the spec)
+- Migration file path and exact SQL
+- `node --check` / `vite build` results
+- Manual curl commands you ran and their output (one-liners)
+- Browser behavior of the referrer check — which signal you used (`ancestorOrigins` vs `referrer`) and known gaps
+- Any unrelated bugs noticed
diff --git a/prompts/embed/README.md b/prompts/embed/README.md
new file mode 100644
index 000000000..b1842cf5a
--- /dev/null
+++ b/prompts/embed/README.md
@@ -0,0 +1,35 @@
+# Embed & share task prompts
+
+Self-contained prompt files for follow-up work on the "share/embed any agent avatar" feature. Each file is designed to be dropped into a fresh Claude Code agent prompt without extra context.
+
+## What already exists (do not redo)
+
+- Route `/agent/:id/embed` → [public/agent/embed.html](../../public/agent/embed.html) — bare 3D avatar, empathy layer, transparent-bg capable, `postMessage` bridge.
+- Share panel on [public/agent/index.html](../../public/agent/index.html) — three tabs (iframe / link / `<agent-3d>`) with a copy button.
+- Web component `<agent-3d>` in [src/element.js](../../src/element.js) — currently requires a manifest URL via `src="..."`.
+- Avatar fetch: `GET /api/avatars/:id` returns `{ avatar: { url, ... } }` — the `url` is the GLB.
+- Identity fetch: `AgentIdentity.load()` from [src/agent-identity.js](../../src/agent-identity.js) resolves agent record by id, exposes `avatarId`, `name`, `description`, `skills`, `walletAddress`.
+
+## Tasks — designed to run in parallel
+
+All three tasks can run simultaneously in separate chats. File ownership is disjoint except for `vercel.json` (each task adds routes in a distinct block, so git merges cleanly).
+
+| Task | What it ships | File ownership |
+|---|---|---|
+| [01-og-oembed.md](./01-og-oembed.md) | Link unfurls — OG image + oembed endpoint so pasted `/agent/:id` links preview on Slack/X/Discord | owns `api/agent-og.js`, `api/agent-oembed.js`; edits `<head>` of `public/agent/index.html` + `vercel.json` |
+| [02-agent-id-resolver.md](./02-agent-id-resolver.md) | Native `<agent-3d agent-id="...">` attribute so the web-component embed works without a manifest URL | owns `src/agent-resolver.js`; edits `src/element.js` only |
+| [03-embed-allowlist.md](./03-embed-allowlist.md) | Per-agent embed referrer allowlist + dashboard UI for owners to gate where their avatar renders | owns `api/agents/[id]/embed-policy.js`, new dashboard panel; edits `public/agent/embed.html` + `vercel.json` |
+
+## Rules that apply to all tasks
+
+- No new runtime dependencies (devDeps only if strictly needed for the task).
+- No new docs files (no README.md, no CLAUDE.md) unless explicitly stated in the task.
+- `node --check` every modified JS file before reporting done.
+- Run `npx vite build` and note whether the build breaks. Pre-existing `@avaturn/sdk` resolution error in `src/avatar-creator.js` is unrelated — ignore it.
+- Respect file ownership in the table above. If you need to touch a file outside your ownership, stop and report instead — another task may be editing it.
+- For `vercel.json` edits, add routes in the block indicated by your task (task 01 puts them near the `/api/agent-*` group; task 03 puts them with `/api/agents/...` group). Do not reorder existing routes.
+- If you discover an unrelated bug during your task, note it in the reporting section. Do not fix it in the same change.
+
+## Reporting
+
+Each task ends with a short report of: files created, files edited, files checked, manual test URLs to hit, and any surprises.
diff --git a/public/agent/index.html b/public/agent/index.html
index 246bfeca5..0c1f988a1 100644
--- a/public/agent/index.html
+++ b/public/agent/index.html
@@ -13,6 +13,18 @@
<link rel="stylesheet" href="/style.css" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap" rel="stylesheet" />
+ <!-- unfurl (populated at runtime from identity) -->
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="Agent" id="og-title" />
+ <meta property="og:description" content="An embodied 3D agent." id="og-description" />
+ <meta property="og:image" content="" id="og-image" />
+ <meta property="og:url" content="" id="og-url" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="Agent" id="tw-title" />
+ <meta name="twitter:description" content="" id="tw-description" />
+ <meta name="twitter:image" content="" id="tw-image" />
+ <link rel="alternate" type="application/json+oembed" href="" id="oembed-link" title="Agent oEmbed" />
+
<style>
body {
overflow: auto;
@@ -299,7 +311,7 @@
const snippets = {
iframe: `<iframe src="${embedUrl}" width="420" height="520" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking"></iframe>`,
link: agentUrl,
- webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d src="${agentUrl}/manifest.json" style="width:420px;height:520px"></agent-3d>`,
+ webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d agent-id="${identity.id}" style="width:420px;height:520px"></agent-3d>`,
};
let current = 'iframe';
@@ -324,6 +336,31 @@
setTimeout(() => { embedCopy.textContent = 'copy'; embedCopy.classList.remove('copied'); }, 1400);
} catch {}
});
+
+ populateUnfurlMeta(identity);
+ }
+
+ function populateUnfurlMeta(identity) {
+ const id = identity?.id;
+ if (!id) return;
+ const origin = location.origin;
+ const name = identity.name || 'Agent';
+ const desc = identity.description || 'An embodied 3D agent.';
+ const agentUrl = `${origin}/agent/${id}`;
+ const img = `${origin}/api/agent/${id}/og`;
+ const setAttr = (elId, attr, value) => {
+ const el = document.getElementById(elId);
+ if (el) el.setAttribute(attr, value);
+ };
+ setAttr('og-title', 'content', name);
+ setAttr('og-description', 'content', desc);
+ setAttr('og-image', 'content', img);
+ setAttr('og-url', 'content', agentUrl);
+ setAttr('tw-title', 'content', name);
+ setAttr('tw-description', 'content', desc);
+ setAttr('tw-image', 'content', img);
+ setAttr('oembed-link', 'href', `${origin}/api/oembed?url=${encodeURIComponent(agentUrl)}`);
+ document.title = `${name} — 3D Agent`;
}
main().catch(err => {
diff --git a/public/animations/manifest.json b/public/animations/manifest.json
index ab417c98a..7ceee1ecc 100644
--- a/public/animations/manifest.json
+++ b/public/animations/manifest.json
@@ -1,51 +1,114 @@
[
+ {
+ "name": "dance",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Dance",
+ "label": "Dance",
+ "icon": "💃",
+ "loop": true
+ },
+ {
+ "name": "death",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Death",
+ "label": "Death",
+ "icon": "💀",
+ "loop": false
+ },
{
"name": "idle",
- "url": "/animations/idle.glb",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Idle",
"label": "Idle",
"icon": "🧍",
"loop": true
},
{
- "name": "walking",
- "url": "/animations/walking.glb",
- "label": "Walking",
- "icon": "🚶",
- "loop": true
+ "name": "jump",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Jump",
+ "label": "Jump",
+ "icon": "🦘",
+ "loop": false
},
{
- "name": "running",
- "url": "/animations/running.glb",
- "label": "Running",
- "icon": "🏃",
- "loop": true
+ "name": "no",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "No",
+ "label": "No",
+ "icon": "🚫",
+ "loop": false
},
{
- "name": "waving",
- "url": "/animations/waving.glb",
- "label": "Waving",
- "icon": "👋",
+ "name": "punch",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Punch",
+ "label": "Punch",
+ "icon": "👊",
"loop": false
},
{
- "name": "dancing",
- "url": "/animations/dancing.glb",
- "label": "Dancing",
- "icon": "💃",
+ "name": "running",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Running",
+ "label": "Running",
+ "icon": "🏃",
"loop": true
},
{
"name": "sitting",
- "url": "/animations/sitting.glb",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Sitting",
"label": "Sitting",
"icon": "🪑",
"loop": true
},
{
- "name": "jumping",
- "url": "/animations/jumping.glb",
- "label": "Jumping",
- "icon": "🦘",
+ "name": "standing",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Standing",
+ "label": "Standing",
+ "icon": "🧍",
+ "loop": true
+ },
+ {
+ "name": "thumbsup",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "ThumbsUp",
+ "label": "ThumbsUp",
+ "icon": "👍",
+ "loop": false
+ },
+ {
+ "name": "walking",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Walking",
+ "label": "Walking",
+ "icon": "🚶",
+ "loop": true
+ },
+ {
+ "name": "walkjump",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "WalkJump",
+ "label": "WalkJump",
+ "icon": "▶",
+ "loop": false
+ },
+ {
+ "name": "wave",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Wave",
+ "label": "Wave",
+ "icon": "👋",
+ "loop": false
+ },
+ {
+ "name": "yes",
+ "url": "/animations/robotexpressive.glb",
+ "clipName": "Yes",
+ "label": "Yes",
+ "icon": "✅",
"loop": false
}
]
diff --git a/public/animations/robotexpressive.glb b/public/animations/robotexpressive.glb
new file mode 100644
index 000000000..6fec9cfb4
Binary files /dev/null and b/public/animations/robotexpressive.glb differ
diff --git a/public/animations/soldier.glb b/public/animations/soldier.glb
new file mode 100644
index 000000000..1788f122d
Binary files /dev/null and b/public/animations/soldier.glb differ
diff --git a/specs/schema/embed-policy.sql b/specs/schema/embed-policy.sql
new file mode 100644
index 000000000..0a0c68870
--- /dev/null
+++ b/specs/schema/embed-policy.sql
@@ -0,0 +1,18 @@
+-- Task 03 — Per-agent embed referrer allowlist
+--
+-- Adds an `embed_policy` column to `agent_identities` that controls where the
+-- `/agent/:id/embed` page is allowed to be iframed. NULL means "no policy",
+-- which preserves the current behaviour of allowing any embedding site.
+--
+-- When non-null, the column stores JSON of the shape:
+-- { "mode": "allowlist" | "denylist", "hosts": ["example.com", "*.substack.com"] }
+-- Hosts support exact matches and a single leading-wildcard segment.
+--
+-- No dedicated migrations directory exists in this repo yet. Apply manually
+-- against the target database (e.g. Neon) before deploying the embed-policy
+-- endpoint and UI:
+--
+-- psql "$DATABASE_URL" -f specs/schema/embed-policy.sql
+
+ALTER TABLE agent_identities
+ ADD COLUMN IF NOT EXISTS embed_policy JSONB;
diff --git a/src/agent-resolver.js b/src/agent-resolver.js
new file mode 100644
index 000000000..2651a0b14
--- /dev/null
+++ b/src/agent-resolver.js
@@ -0,0 +1,81 @@
+// Resolve a hosted agent by id against the backend API, producing an in-memory
+// manifest shaped like a file-based one so the rest of the <agent-3d> boot
+// path (manifest.body.uri, manifest.brain, manifest.skills, manifest._baseURI)
+// works unchanged.
+
+export class AgentResolveError extends Error {
+ constructor(code, message, { status } = {}) {
+ super(message);
+ this.name = 'AgentResolveError';
+ this.code = code;
+ if (status !== undefined) this.status = status;
+ }
+}
+
+async function fetchJSON(url, { fetchFn }) {
+ let res;
+ try {
+ res = await fetchFn(url, { credentials: 'include' });
+ } catch (err) {
+ throw new AgentResolveError('network', `network error fetching ${url}: ${err.message || err}`);
+ }
+ if (res.status === 401 || res.status === 403) {
+ throw new AgentResolveError('unauthorized', `unauthorized fetching ${url} (${res.status})`, { status: res.status });
+ }
+ if (res.status === 404) {
+ throw new AgentResolveError('not_found', `resource not found: ${url}`, { status: 404 });
+ }
+ if (!res.ok) {
+ throw new AgentResolveError('network', `request failed: ${url} (${res.status})`, { status: res.status });
+ }
+ try {
+ return await res.json();
+ } catch (err) {
+ throw new AgentResolveError('network', `invalid JSON from ${url}: ${err.message || err}`);
+ }
+}
+
+export async function resolveAgentById(agentId, { origin = typeof location !== 'undefined' ? location.origin : '', fetchFn = fetch } = {}) {
+ if (!agentId) throw new AgentResolveError('not_found', 'agentId required');
+
+ const boundFetch = fetchFn.bind(typeof globalThis !== 'undefined' ? globalThis : undefined);
+
+ const agentRes = await fetchJSON(`${origin}/api/agents/${encodeURIComponent(agentId)}`, { fetchFn: boundFetch });
+ const agent = agentRes?.agent;
+ if (!agent) throw new AgentResolveError('not_found', `agent ${agentId} not found`);
+
+ if (!agent.avatar_id) {
+ throw new AgentResolveError('no_avatar', `agent ${agentId} has no avatar bound`);
+ }
+
+ const avatarRes = await fetchJSON(`${origin}/api/avatars/${encodeURIComponent(agent.avatar_id)}`, { fetchFn: boundFetch });
+ const avatar = avatarRes?.avatar;
+ if (!avatar || !avatar.url) {
+ throw new AgentResolveError('no_avatar', `avatar ${agent.avatar_id} has no url`);
+ }
+
+ const skills = Array.isArray(agent.skills)
+ ? agent.skills.map((s) => (typeof s === 'string' ? { name: s } : s)).filter(Boolean)
+ : [];
+
+ return {
+ spec: 'agent-manifest/0.1',
+ name: agent.name || 'Agent',
+ description: agent.description || '',
+ id: {
+ agentId: agent.id,
+ owner: agent.wallet_address,
+ chainId: agent.chain_id,
+ walletAddress: agent.wallet_address,
+ },
+ body: { uri: avatar.url, format: 'gltf-binary' },
+ brain: {},
+ voice: { tts: { provider: 'browser' }, stt: { provider: 'browser' } },
+ skills,
+ memory: { mode: 'remote', namespace: agent.id },
+ tools: ['wave', 'lookAt', 'play_clip', 'setExpression', 'speak', 'remember'],
+ version: '0.1.0',
+ _baseURI: `${origin}/agent/${agent.id}/`,
+ _source: 'agent-id',
+ };
+}
diff --git a/src/element.js b/src/element.js
index 549480763..6e0f8201e 100644
--- a/src/element.js
+++ b/src/element.js
@@ -8,6 +8,7 @@ import { SkillRegistry } from './skills/index.js';
import { Memory } from './memory/index.js';
import { loadManifest, fetchRelative } from './manifest.js';
import { resolveURI } from './ipfs.js';
+import { resolveAgentById, AgentResolveError } from './agent-resolver.js';
const MODES = ['inline', 'floating', 'section', 'fullscreen'];
@@ -140,7 +141,7 @@ const BASE_STYLE = `
class Agent3DElement extends HTMLElement {
static get observedAttributes() {
- return ['src', 'manifest', 'body', 'mode', 'position', 'width', 'height', 'voice', 'api-key', 'key-proxy'];
+ return ['src', 'manifest', 'body', 'agent-id', 'mode', 'position', 'width', 'height', 'voice', 'api-key', 'key-proxy'];
}
constructor() {
@@ -172,7 +173,7 @@ class Agent3DElement extends HTMLElement {
attributeChangedCallback(name, oldVal, newVal) {
if (!this._mounted) return;
if (['mode', 'position', 'width', 'height'].includes(name)) this._applyLayout();
- if (['src', 'manifest', 'body'].includes(name)) {
+ if (['src', 'manifest', 'body', 'agent-id'].includes(name)) {
// Source change — reboot
this._teardown();
this._boot();
@@ -389,7 +390,12 @@ class Agent3DElement extends HTMLElement {
const src = this.getAttribute('src');
const manifestAttr = this.getAttribute('manifest');
const body = this.getAttribute('body');
- if (src) return loadManifest(src, { rpcURL: this.getAttribute('rpc-url'), registry: this.getAttribute('registry') });
+ const agentIdAttr = this.getAttribute('agent-id');
+ if (src) {
+ if (agentIdAttr) console.warn('[agent-3d] both src and agent-id provided; using src');
+ return loadManifest(src, { rpcURL: this.getAttribute('rpc-url'), registry: this.getAttribute('registry') });
+ }
+ if (agentIdAttr) return resolveAgentById(agentIdAttr);
if (manifestAttr) return loadManifest(manifestAttr);
if (body) {
// Ad-hoc agent from a bare GLB
diff --git a/vercel.json b/vercel.json
index bab17893a..ea8a91b37 100644
--- a/vercel.json
+++ b/vercel.json
@@ -20,6 +20,7 @@
{ "src": "/api/agents/me", "dest": "/api/agents" },
{ "src": "/api/agents/([^/]+)/wallet", "dest": "/api/agents/[id]" },
+ { "src": "/api/agents/([^/]+)/embed-policy", "dest": "/api/agents/[id]/embed-policy?id=$1" },
{ "src": "/api/agents/([^/]+)", "dest": "/api/agents/[id]" },
{ "src": "/api/agents", "dest": "/api/agents" },
{ "src": "/api/agent-actions", "dest": "/api/agent-actions" },