From 5952c7e65726773c36032430737176d8b9145796 Mon Sep 17 00:00:00 2001
From: mleku
Date: Sat, 11 Oct 2025 08:46:30 +0100
Subject: [PATCH] Revert "Update project structure and enhance build process"
This reverts commit 4cf3d9cfb5908bac31ce7677917e53f3bea91b5f.
---
.gitignore | 5 +
app/web/.gitignore | 1 +
app/web/bun.lock | 69 ------
app/web/dist/build/bundle.css | 2 -
app/web/dist/build/bundle.js | 2 -
app/web/dist/bundle.css | 72 ------
app/web/dist/bundle.js | 23 --
app/web/dist/favicon.png | Bin 526586 -> 0 bytes
app/web/dist/global.css | 69 ------
app/web/dist/index.html | 19 +-
app/web/dist/orly-favicon.png | Bin 387663 -> 0 bytes
app/web/dist/orly.png | Bin 526586 -> 0 bytes
app/web/package-lock.json | 416 ----------------------------------
app/web/package.json | 1 -
app/web/rollup.config.js | 8 -
15 files changed, 14 insertions(+), 673 deletions(-)
delete mode 100644 app/web/dist/build/bundle.css
delete mode 100644 app/web/dist/build/bundle.js
delete mode 100644 app/web/dist/bundle.css
delete mode 100644 app/web/dist/bundle.js
delete mode 100644 app/web/dist/favicon.png
delete mode 100644 app/web/dist/global.css
delete mode 100644 app/web/dist/orly-favicon.png
delete mode 100644 app/web/dist/orly.png
diff --git a/.gitignore b/.gitignore
index 4a50824..f57a6fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -94,6 +94,10 @@ cmd/benchmark/data
!contrib/stella/.dockerignore
!*.jsx
!*.tsx
+!app/web/dist
+!/app/web/dist
+!/app/web/dist/*
+!/app/web/dist/**
!bun.lock
!*.svelte
# ...even if they are in subdirectories
@@ -118,3 +122,4 @@ pkg/database/testrealy
/.idea/.name
/ctxproxy.config.yml
cmd/benchmark/external/**
+app/web/dist/**
diff --git a/app/web/.gitignore b/app/web/.gitignore
index f0d5e34..f84807d 100644
--- a/app/web/.gitignore
+++ b/app/web/.gitignore
@@ -1,4 +1,5 @@
node_modules/
+dist/
.vite/
.tanstack/
.idea/
diff --git a/app/web/bun.lock b/app/web/bun.lock
index 8ac9849..985d872 100644
--- a/app/web/bun.lock
+++ b/app/web/bun.lock
@@ -12,7 +12,6 @@
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-terser": "^0.4.0",
"rollup": "^3.15.0",
- "rollup-plugin-copy": "^3.5.0",
"rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.1.2",
@@ -43,12 +42,6 @@
"@noble/secp256k1": ["@noble/secp256k1@2.3.0", "", {}, "sha512-0TQed2gcBbIrh7Ccyw+y/uZQvbJwm7Ao4scBUxqpBCcsOlZG0O4KGfjtNAy/li4W8n1xt3dxrwJ0beZ2h2G6Kw=="],
- "@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
-
- "@nodelib/fs.stat": ["@nodelib/fs.stat@2.0.5", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="],
-
- "@nodelib/fs.walk": ["@nodelib/fs.walk@1.2.8", "", { "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg=="],
-
"@nostr-dev-kit/ndk": ["@nostr-dev-kit/ndk@2.17.3", "", { "dependencies": { "@codesandbox/sandpack-client": "^2.19.8", "@noble/curves": "^1.6.0", "@noble/hashes": "^1.5.0", "@noble/secp256k1": "^2.1.0", "@scure/base": "^1.1.9", "debug": "^4.3.6", "light-bolt11-decoder": "^3.2.0", "shiki": "^3.13.0", "tseep": "^1.3.1", "typescript-lru-cache": "^2" }, "peerDependencies": { "nostr-tools": "^2" } }, "sha512-CwOTRPxyOcxg5X4VEBzI7leA/bE7t4Yv9tZ6KpG4H4fDhuI6YXRbb9oKLG9KJqVOIbRrYT27sBF82Z6dE3B1qw=="],
"@open-draft/deferred-promise": ["@open-draft/deferred-promise@2.2.0", "", {}, "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA=="],
@@ -85,18 +78,10 @@
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
- "@types/fs-extra": ["@types/fs-extra@8.1.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-0dzKcwO+S8s2kuF5Z9oUWatQJj5Uq/iqphEtE3GQJVRRYm/tD1LglU2UnXi2A8jLq5umkGouOXOR9y0n613ZwQ=="],
-
- "@types/glob": ["@types/glob@7.2.0", "", { "dependencies": { "@types/minimatch": "*", "@types/node": "*" } }, "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA=="],
-
"@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
"@types/mdast": ["@types/mdast@4.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA=="],
- "@types/minimatch": ["@types/minimatch@6.0.0", "", { "dependencies": { "minimatch": "*" } }, "sha512-zmPitbQ8+6zNutpwgcQuLcsEpn/Cj54Kbn7L5pX0Os5kdWplB7xPgEh/g+SWOB/qmows2gpuCaPyduq8ZZRnxA=="],
-
- "@types/node": ["@types/node@24.7.1", "", { "dependencies": { "undici-types": "~7.14.0" } }, "sha512-CmyhGZanP88uuC5GpWU9q+fI61j2SkhO3UGMUdfYRE6Bcy0ccyzn1Rqj9YAB/ZY4kOXmNf0ocah5GtphmLMP6Q=="],
-
"@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="],
"@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
@@ -107,8 +92,6 @@
"anymatch": ["anymatch@3.1.3", "", { "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" } }, "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw=="],
- "array-union": ["array-union@2.1.0", "", {}, "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="],
-
"balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
"base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],
@@ -131,16 +114,12 @@
"chokidar": ["chokidar@3.6.0", "", { "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw=="],
- "colorette": ["colorette@1.4.0", "", {}, "sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g=="],
-
"comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
"commander": ["commander@2.20.3", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="],
"commondir": ["commondir@1.0.1", "", {}, "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg=="],
- "concat-map": ["concat-map@0.0.1", "", {}, "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="],
-
"console-clear": ["console-clear@1.1.1", "", {}, "sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ=="],
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
@@ -151,20 +130,12 @@
"devlop": ["devlop@1.1.0", "", { "dependencies": { "dequal": "^2.0.0" } }, "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA=="],
- "dir-glob": ["dir-glob@3.0.1", "", { "dependencies": { "path-type": "^4.0.0" } }, "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA=="],
-
"dotenv": ["dotenv@16.6.1", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],
"estree-walker": ["estree-walker@2.0.2", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="],
- "fast-glob": ["fast-glob@3.3.3", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.8" } }, "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg=="],
-
- "fastq": ["fastq@1.19.1", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="],
-
"fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
- "fs-extra": ["fs-extra@8.1.0", "", { "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } }, "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g=="],
-
"fs.realpath": ["fs.realpath@1.0.0", "", {}, "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="],
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
@@ -177,10 +148,6 @@
"glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="],
- "globby": ["globby@10.0.1", "", { "dependencies": { "@types/glob": "^7.1.1", "array-union": "^2.1.0", "dir-glob": "^3.0.1", "fast-glob": "^3.0.3", "glob": "^7.1.3", "ignore": "^5.1.1", "merge2": "^1.2.3", "slash": "^3.0.0" } }, "sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A=="],
-
- "graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
-
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
"hast-util-to-html": ["hast-util-to-html@9.0.5", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw=="],
@@ -191,8 +158,6 @@
"ieee754": ["ieee754@1.2.1", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
- "ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="],
-
"inflight": ["inflight@1.0.6", "", { "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA=="],
"inherits": ["inherits@2.0.4", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],
@@ -209,12 +174,8 @@
"is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
- "is-plain-object": ["is-plain-object@3.0.1", "", {}, "sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g=="],
-
"is-reference": ["is-reference@1.2.1", "", { "dependencies": { "@types/estree": "*" } }, "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ=="],
- "jsonfile": ["jsonfile@4.0.0", "", { "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg=="],
-
"kleur": ["kleur@4.1.5", "", {}, "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ=="],
"light-bolt11-decoder": ["light-bolt11-decoder@3.2.0", "", { "dependencies": { "@scure/base": "1.1.1" } }, "sha512-3QEofgiBOP4Ehs9BI+RkZdXZNtSys0nsJ6fyGeSiAGCBsMwHGUDS/JQlY/sTnWs91A2Nh0S9XXfA8Sy9g6QpuQ=="],
@@ -229,8 +190,6 @@
"mdast-util-to-hast": ["mdast-util-to-hast@13.2.0", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/mdast": "^4.0.0", "@ungap/structured-clone": "^1.0.0", "devlop": "^1.0.0", "micromark-util-sanitize-uri": "^2.0.0", "trim-lines": "^3.0.0", "unist-util-position": "^5.0.0", "unist-util-visit": "^5.0.0", "vfile": "^6.0.0" } }, "sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA=="],
- "merge2": ["merge2@1.4.1", "", {}, "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg=="],
-
"micromark-util-character": ["micromark-util-character@2.1.1", "", { "dependencies": { "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q=="],
"micromark-util-encode": ["micromark-util-encode@2.0.1", "", {}, "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw=="],
@@ -241,8 +200,6 @@
"micromark-util-types": ["micromark-util-types@2.0.2", "", {}, "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA=="],
- "micromatch": ["micromatch@4.0.8", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="],
-
"mime-db": ["mime-db@1.54.0", "", {}, "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ=="],
"minimatch": ["minimatch@5.1.6", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g=="],
@@ -269,18 +226,12 @@
"outvariant": ["outvariant@1.4.0", "", {}, "sha512-AlWY719RF02ujitly7Kk/0QlV+pXGFDHrHf9O2OKqyqgBieaPOIeuSkL8sRK6j2WK+/ZAURq2kZsY0d8JapUiw=="],
- "path-is-absolute": ["path-is-absolute@1.0.1", "", {}, "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg=="],
-
"path-parse": ["path-parse@1.0.7", "", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="],
- "path-type": ["path-type@4.0.0", "", {}, "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="],
-
"picomatch": ["picomatch@4.0.3", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
"property-information": ["property-information@7.1.0", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="],
- "queue-microtask": ["queue-microtask@1.2.3", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="],
-
"randombytes": ["randombytes@2.1.0", "", { "dependencies": { "safe-buffer": "^5.1.0" } }, "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ=="],
"readdirp": ["readdirp@3.6.0", "", { "dependencies": { "picomatch": "^2.2.1" } }, "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA=="],
@@ -295,20 +246,14 @@
"resolve.exports": ["resolve.exports@2.0.3", "", {}, "sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A=="],
- "reusify": ["reusify@1.1.0", "", {}, "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw=="],
-
"rollup": ["rollup@3.29.5", "", { "optionalDependencies": { "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w=="],
- "rollup-plugin-copy": ["rollup-plugin-copy@3.5.0", "", { "dependencies": { "@types/fs-extra": "^8.0.1", "colorette": "^1.1.0", "fs-extra": "^8.1.0", "globby": "10.0.1", "is-plain-object": "^3.0.0" } }, "sha512-wI8D5dvYovRMx/YYKtUNt3Yxaw4ORC9xo6Gt9t22kveWz1enG9QrhVlagzwrxSC455xD1dHMKhIJkbsQ7d48BA=="],
-
"rollup-plugin-css-only": ["rollup-plugin-css-only@4.5.5", "", { "dependencies": { "@rollup/pluginutils": "5" }, "peerDependencies": { "rollup": "<5" } }, "sha512-O2m2Sj8qsAtjUVqZyGTDXJypaOFFNV4knz8OlS6wJBws6XEICIiLsXmI56SbQEmWDqYU5TgRgWmslGj4THofJQ=="],
"rollup-plugin-livereload": ["rollup-plugin-livereload@2.0.5", "", { "dependencies": { "livereload": "^0.9.1" } }, "sha512-vqQZ/UQowTW7VoiKEM5ouNW90wE5/GZLfdWuR0ELxyKOJUIaj+uismPZZaICU4DnWPVjnpCDDxEqwU7pcKY/PA=="],
"rollup-plugin-svelte": ["rollup-plugin-svelte@7.2.3", "", { "dependencies": { "@rollup/pluginutils": "^4.1.0", "resolve.exports": "^2.0.0" }, "peerDependencies": { "rollup": ">=2.0.0", "svelte": ">=3.5.0" } }, "sha512-LlniP+h00DfM+E4eav/Kk8uGjgPUjGIBfrAS/IxQvsuFdqSM0Y2sXf31AdxuIGSW9GsmocDqOfaxR5QNno/Tgw=="],
- "run-parallel": ["run-parallel@1.2.0", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="],
-
"sade": ["sade@1.8.1", "", { "dependencies": { "mri": "^1.1.0" } }, "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A=="],
"safe-buffer": ["safe-buffer@5.2.1", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="],
@@ -323,8 +268,6 @@
"sirv-cli": ["sirv-cli@2.0.2", "", { "dependencies": { "console-clear": "^1.1.0", "get-port": "^3.2.0", "kleur": "^4.1.4", "local-access": "^1.0.1", "sade": "^1.6.0", "semiver": "^1.0.0", "sirv": "^2.0.0", "tinydate": "^1.0.0" }, "bin": { "sirv": "bin.js" } }, "sha512-OtSJDwxsF1NWHc7ps3Sa0s+dPtP15iQNJzfKVz+MxkEo3z72mCD+yu30ct79rPr0CaV1HXSOBp+MIY5uIhHZ1A=="],
- "slash": ["slash@3.0.0", "", {}, "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="],
-
"smob": ["smob@1.5.0", "", {}, "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig=="],
"source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
@@ -357,8 +300,6 @@
"typescript-lru-cache": ["typescript-lru-cache@2.0.0", "", {}, "sha512-Jp57Qyy8wXeMkdNuZiglE6v2Cypg13eDA1chHwDG6kq51X7gk4K7P7HaDdzZKCxkegXkVHNcPD0n5aW6OZH3aA=="],
- "undici-types": ["undici-types@7.14.0", "", {}, "sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA=="],
-
"unist-util-is": ["unist-util-is@6.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw=="],
"unist-util-position": ["unist-util-position@5.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA=="],
@@ -369,8 +310,6 @@
"unist-util-visit-parents": ["unist-util-visit-parents@6.0.1", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0" } }, "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw=="],
- "universalify": ["universalify@0.1.2", "", {}, "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="],
-
"vfile": ["vfile@6.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "vfile-message": "^4.0.0" } }, "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q=="],
"vfile-message": ["vfile-message@4.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw=="],
@@ -393,12 +332,8 @@
"anymatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
- "globby/glob": ["glob@7.2.3", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q=="],
-
"light-bolt11-decoder/@scure/base": ["@scure/base@1.1.1", "", {}, "sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA=="],
- "micromatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
-
"nostr-tools/@noble/curves": ["@noble/curves@1.2.0", "", { "dependencies": { "@noble/hashes": "1.3.2" } }, "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw=="],
"nostr-tools/@noble/hashes": ["@noble/hashes@1.3.1", "", {}, "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA=="],
@@ -411,12 +346,8 @@
"@scure/bip32/@noble/curves/@noble/hashes": ["@noble/hashes@1.3.1", "", {}, "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA=="],
- "globby/glob/minimatch": ["minimatch@3.1.2", "", { "dependencies": { "brace-expansion": "^1.1.7" } }, "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw=="],
-
"nostr-tools/@noble/curves/@noble/hashes": ["@noble/hashes@1.3.2", "", {}, "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ=="],
"rollup-plugin-svelte/@rollup/pluginutils/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
-
- "globby/glob/minimatch/brace-expansion": ["brace-expansion@1.1.12", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg=="],
}
}
diff --git a/app/web/dist/build/bundle.css b/app/web/dist/build/bundle.css
deleted file mode 100644
index ed3dcdf..0000000
--- a/app/web/dist/build/bundle.css
+++ /dev/null
@@ -1,2 +0,0 @@
-.modal-overlay.svelte-9yzcwg.svelte-9yzcwg{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000}.modal.svelte-9yzcwg.svelte-9yzcwg{background:var(--bg-color);border-radius:8px;box-shadow:0 4px 20px rgba(0, 0, 0, 0.3);width:90%;max-width:500px;max-height:90vh;overflow-y:auto;border:1px solid var(--border-color)}.modal-header.svelte-9yzcwg.svelte-9yzcwg{display:flex;justify-content:space-between;align-items:center;padding:20px;border-bottom:1px solid var(--border-color)}.modal-header.svelte-9yzcwg h2.svelte-9yzcwg{margin:0;color:var(--text-color);font-size:1.5rem}.close-btn.svelte-9yzcwg.svelte-9yzcwg{background:none;border:none;font-size:1.5rem;cursor:pointer;color:var(--text-color);padding:0;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border-radius:50%;transition:background-color 0.2s}.close-btn.svelte-9yzcwg.svelte-9yzcwg:hover{background-color:var(--tab-hover-bg)}.tab-container.svelte-9yzcwg.svelte-9yzcwg{padding:20px}.tabs.svelte-9yzcwg.svelte-9yzcwg{display:flex;border-bottom:1px solid var(--border-color);margin-bottom:20px}.tab-btn.svelte-9yzcwg.svelte-9yzcwg{flex:1;padding:12px 16px;background:none;border:none;cursor:pointer;color:var(--text-color);font-size:1rem;transition:all 0.2s;border-bottom:2px solid transparent}.tab-btn.svelte-9yzcwg.svelte-9yzcwg:hover{background-color:var(--tab-hover-bg)}.tab-btn.active.svelte-9yzcwg.svelte-9yzcwg{border-bottom-color:var(--primary);color:var(--primary)}.tab-content.svelte-9yzcwg.svelte-9yzcwg{min-height:200px}.extension-login.svelte-9yzcwg.svelte-9yzcwg,.nsec-login.svelte-9yzcwg.svelte-9yzcwg{display:flex;flex-direction:column;gap:16px}.extension-login.svelte-9yzcwg p.svelte-9yzcwg,.nsec-login.svelte-9yzcwg p.svelte-9yzcwg{margin:0;color:var(--text-color);line-height:1.5}.login-extension-btn.svelte-9yzcwg.svelte-9yzcwg,.login-nsec-btn.svelte-9yzcwg.svelte-9yzcwg{padding:12px 24px;background:var(--primary);color:white;border:none;border-radius:6px;cursor:pointer;font-size:1rem;transition:background-color 0.2s}.login-extension-btn.svelte-9yzcwg.svelte-9yzcwg:hover:not(:disabled),.login-nsec-btn.svelte-9yzcwg.svelte-9yzcwg:hover:not(:disabled){background:#00ACC1}.login-extension-btn.svelte-9yzcwg.svelte-9yzcwg:disabled,.login-nsec-btn.svelte-9yzcwg.svelte-9yzcwg:disabled{background:#ccc;cursor:not-allowed}.nsec-input.svelte-9yzcwg.svelte-9yzcwg{padding:12px;border:1px solid var(--input-border);border-radius:6px;font-size:1rem;background:var(--bg-color);color:var(--text-color)}.nsec-input.svelte-9yzcwg.svelte-9yzcwg:focus{outline:none;border-color:var(--primary)}.message.svelte-9yzcwg.svelte-9yzcwg{padding:10px;border-radius:4px;margin-top:16px;text-align:center}.error-message.svelte-9yzcwg.svelte-9yzcwg{background:#ffebee;color:#c62828;border:1px solid #ffcdd2}.success-message.svelte-9yzcwg.svelte-9yzcwg{background:#e8f5e8;color:#2e7d32;border:1px solid #c8e6c9}.modal.dark-theme.svelte-9yzcwg .error-message.svelte-9yzcwg{background:#4a2c2a;color:#ffcdd2;border:1px solid #6d4c41}.modal.dark-theme.svelte-9yzcwg .success-message.svelte-9yzcwg{background:#2e4a2e;color:#a5d6a7;border:1px solid #4caf50}
-body{margin:0;padding:0;--bg-color:#ddd;--header-bg:#eee;--border-color:#dee2e6;--text-color:#444444;--sidebar-bg:#eeeeee;--tab-hover-bg:#ddd;--input-border:#ccc;--button-bg:#ddd;--button-hover-bg:#eee;--primary:#00BCD4;--warning:#ff3e00}body.dark-theme{--bg-color:#263238;--header-bg:#1e272c;--border-color:#404040;--text-color:#ffffff;--sidebar-bg:#1e272c;--tab-hover-bg:#263238;--input-border:#555;--button-bg:#263238;--button-hover-bg:#1e272c;--primary:#00BCD4;--warning:#ff3e00}.main-header.svelte-m62qks.svelte-m62qks{height:3em;background-color:var(--header-bg);position:fixed;top:0;left:0;right:0;z-index:1000;color:var(--text-color)}.header-content.svelte-m62qks.svelte-m62qks{height:100%;display:flex;align-items:center;padding:0;gap:0}.logo.svelte-m62qks.svelte-m62qks{height:2.5em;width:2.5em;object-fit:contain;flex-shrink:0}.tab-label-area.svelte-m62qks.svelte-m62qks{flex:1;height:100%;display:flex;align-items:center;gap:0;padding:0 1rem}.selected-tab-label.svelte-m62qks.svelte-m62qks{font-size:1em;font-weight:600;text-transform:capitalize;color:var(--text-color)}.theme-toggle-btn.svelte-m62qks.svelte-m62qks{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.theme-toggle-btn.svelte-m62qks.svelte-m62qks:hover{background-color:var(--button-bg)}.login-btn.svelte-m62qks.svelte-m62qks{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--primary);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.login-btn.svelte-m62qks.svelte-m62qks:hover{background-color:#0056b3}.app-container.svelte-m62qks.svelte-m62qks{display:flex;margin-top:3em;height:calc(100vh - 3em)}.sidebar.svelte-m62qks.svelte-m62qks{position:fixed;left:0;top:3em;bottom:0;width:140px;background-color:var(--sidebar-bg);transition:width 0.3s ease;overflow:hidden;color:var(--text-color);z-index:100}.sidebar.collapsed.svelte-m62qks.svelte-m62qks{width:60px}.sidebar-content.svelte-m62qks.svelte-m62qks{height:100%;display:flex;flex-direction:column;padding:0}.tabs.svelte-m62qks.svelte-m62qks{flex:1}.tab.svelte-m62qks.svelte-m62qks{height:2.5em;display:flex;align-items:center;padding:0 1rem;cursor:pointer;transition:background-color 0.2s ease;margin-bottom:0.5em;gap:0.75rem;border:none;background:none;width:100%;text-align:left}.tab.svelte-m62qks.svelte-m62qks:hover{background-color:var(--tab-hover-bg)}.tab.active.svelte-m62qks.svelte-m62qks{background-color:var(--tab-hover-bg);border-right:3px solid var(--primary)}.tab-icon.svelte-m62qks.svelte-m62qks{font-size:1.2em;flex-shrink:0;width:1.5em;text-align:center}.tab-label.svelte-m62qks.svelte-m62qks{font-size:0.9em;font-weight:500;white-space:nowrap}.toggle-btn.svelte-m62qks.svelte-m62qks{height:2.5em;margin:0;padding:0.5em 1em;background-color:transparent;cursor:pointer;transition:background-color 0.2s ease;color:var(--text-color);border:none}.toggle-btn.svelte-m62qks.svelte-m62qks:hover{background-color:var(--tab-hover-bg)}.main-content.svelte-m62qks.svelte-m62qks{position:fixed;left:140px;top:3em;right:0;bottom:0;padding:2rem;overflow-y:auto;background-color:var(--bg-color);color:var(--text-color);transition:left 0.3s ease}.app-container.svelte-m62qks:has(.sidebar.collapsed) .main-content.svelte-m62qks{left:60px}.main-content.svelte-m62qks h1.svelte-m62qks{color:#ff3e00;text-transform:uppercase;font-size:4em;font-weight:100;text-align:center}@media(max-width: 640px){.header-content.svelte-m62qks.svelte-m62qks{padding:0}.sidebar.svelte-m62qks.svelte-m62qks{width:120px}.sidebar.collapsed.svelte-m62qks.svelte-m62qks{width:50px}.main-content.svelte-m62qks.svelte-m62qks{left:120px;padding:1rem}.app-container.svelte-m62qks:has(.sidebar.collapsed) .main-content.svelte-m62qks{left:50px}.main-content.svelte-m62qks h1.svelte-m62qks{font-size:2.5em}}.user-info.svelte-m62qks.svelte-m62qks{display:flex;align-items:flex-start;padding:0;height:3em}.logout-btn.svelte-m62qks.svelte-m62qks{padding:0;border:none;border-radius:0;background-color:var(--warning);color:white;cursor:pointer;flex-shrink:0;height:3em;width:3em;display:flex;align-items:center;justify-content:center}.user-profile-btn.svelte-m62qks.svelte-m62qks{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.user-profile-btn.svelte-m62qks.svelte-m62qks:hover{background-color:var(--button-bg)}.user-avatar.svelte-m62qks.svelte-m62qks,.user-avatar-placeholder.svelte-m62qks.svelte-m62qks{width:1em;height:1em;object-fit:cover}.user-avatar-placeholder.svelte-m62qks.svelte-m62qks{display:flex;align-items:center;justify-content:center;font-size:0.5em;padding:0.5em}.user-name.svelte-m62qks.svelte-m62qks{font-size:0.8rem;font-weight:500;max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.drawer-overlay.svelte-m62qks.svelte-m62qks{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.5);z-index:1000;display:flex;justify-content:flex-end}.settings-drawer.svelte-m62qks.svelte-m62qks{width:640px;height:100%;background:var(--bg-color);overflow-y:auto;animation:svelte-m62qks-slideIn 0.3s ease}@keyframes svelte-m62qks-slideIn{from{transform:translateX(100%)}to{transform:translateX(0)}}.drawer-header.svelte-m62qks.svelte-m62qks{display:flex;align-items:center;justify-content:space-between;background:var(--header-bg)}.drawer-header.svelte-m62qks h2.svelte-m62qks{margin:0;color:var(--text-color);font-size:1em;padding:1rem}.close-btn.svelte-m62qks.svelte-m62qks{background:none;border:none;font-size:1em;cursor:pointer;color:var(--text-color);padding:0.5em;transition:background-color 0.2s;align-items:center}.close-btn.svelte-m62qks.svelte-m62qks:hover{background:var(--button-hover-bg)}.profile-section.svelte-m62qks.svelte-m62qks{margin-bottom:2rem}.profile-hero.svelte-m62qks.svelte-m62qks{position:relative}.profile-banner.svelte-m62qks.svelte-m62qks{width:100%;height:160px;object-fit:cover;border-radius:0;display:block}.profile-avatar.svelte-m62qks.svelte-m62qks,.profile-avatar-placeholder.svelte-m62qks.svelte-m62qks{width:72px;height:72px;border-radius:50%;object-fit:cover;flex-shrink:0;box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid var(--bg-color)}.overlap.svelte-m62qks.svelte-m62qks{position:absolute;left:12px;bottom:-36px;z-index:2;background:var(--button-hover-bg);display:flex;align-items:center;justify-content:center;font-size:1.5rem}.name-row.svelte-m62qks.svelte-m62qks{position:absolute;left:calc(12px + 72px + 12px);bottom:8px;right:12px;display:flex;align-items:baseline;gap:8px;z-index:1;shadow:0 3px 6px rgba(0,0,0,0.6)}.profile-username.svelte-m62qks.svelte-m62qks{margin:0;font-size:1.1rem;color:#000;text-shadow:0 3px 6px rgba(255,255,255,1)}.profile-nip05-inline.svelte-m62qks.svelte-m62qks{font-size:0.85rem;color:#000;font-family:monospace;opacity:0.95;text-shadow:0 3px 6px rgba(255,255,255,1)}.about-card.svelte-m62qks.svelte-m62qks{background:var(--header-bg);padding:12px 12px 12px 96px;position:relative;word-break:auto-phrase}.profile-about.svelte-m62qks.svelte-m62qks{margin:0;color:var(--text-color);font-size:0.9rem;line-height:1.4}@media(max-width: 640px){.settings-drawer.svelte-m62qks.svelte-m62qks{width:100%}.name-row.svelte-m62qks.svelte-m62qks{left:calc(8px + 56px + 8px);bottom:6px;right:8px;gap:6px}.profile-username.svelte-m62qks.svelte-m62qks{font-size:1rem}.profile-nip05-inline.svelte-m62qks.svelte-m62qks{font-size:0.8rem}}
diff --git a/app/web/dist/build/bundle.js b/app/web/dist/build/bundle.js
deleted file mode 100644
index 22087e0..0000000
--- a/app/web/dist/build/bundle.js
+++ /dev/null
@@ -1,2 +0,0 @@
-var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function o(e){e.forEach(t)}function s(e){return"function"==typeof e}function c(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let l;function r(e,t){return l||(l=document.createElement("a")),l.href=t,e===l.href}const a="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function i(e,t){e.appendChild(t)}function u(e,t,n){e.insertBefore(t,n||null)}function d(e){e.parentNode&&e.parentNode.removeChild(e)}function m(e){return document.createElement(e)}function f(e){return document.createTextNode(e)}function p(){return f(" ")}function g(e,t,n,o){return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)}function h(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function b(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function y(e,t){t=""+t,e.data!==t&&(e.data=t)}function v(e,t){e.value=null==t?"":t}function w(e,t,n){e.classList[n?"add":"remove"](t)}let k;function $(e){k=e}function x(){const e=function(){if(!k)throw new Error("Function called outside component initialization");return k}();return(t,n,{cancelable:o=!1}={})=>{const s=e.$$.callbacks[t];if(s){const c=function(e,t,{bubbles:n=!1,cancelable:o=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,o,t),s}(t,n,{cancelable:o});return s.slice().forEach(t=>{t.call(e,c)}),!c.defaultPrevented}return!0}}function S(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const E=[],q=[];let _=[];const N=[],C=Promise.resolve();let P=!1;function T(e){_.push(e)}const I=new Set;let O=0;function z(){if(0!==O)return;const e=k;do{try{for(;O{const n=e.$$.on_mount.map(t).filter(s);e.$$.on_destroy?e.$$.on_destroy.push(...n):o(n),e.$$.on_mount=[]}),a.forEach(T)}function F(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];_.forEach(o=>-1===e.indexOf(o)?t.push(o):n.push(o)),n.forEach(e=>e()),_=t}(n.after_update),o(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function U(e,t){-1===e.$$.dirty[0]&&(E.push(e),P||(P=!0,C.then(z)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const s=o.length?o[0]:n;return f.ctx&&r(f.ctx[e],f.ctx[e]=s)&&(!f.skip_bound&&f.bound[e]&&f.bound[e](s),p&&U(t,e)),n}):[],f.update(),p=!0,o(f.before_update),f.fragment=!!l&&l(f.ctx),s.target){if(s.hydrate){const e=function(e){return Array.from(e.childNodes)}(s.target);f.fragment&&f.fragment.l(e),e.forEach(d)}else f.fragment&&f.fragment.c();s.intro&&D(t.$$.fragment),A(t,s.target,s.anchor,s.customElement),z()}$(m)}class J{$destroy(){F(this,1),this.$destroy=e}$on(t,n){if(!s(n))return e;const o=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return o.push(n),()=>{const e=o.indexOf(n);-1!==e&&o.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const{window:K}=a;function W(e){let t,n,s,c,l,r,a,f,y,v,k,$,x,S,E,q,_,N;function C(e,t){return"extension"===e[2]?H:B}let P=C(e),T=P(e),I=e[5]&&R(e),O=e[6]&&V(e);return{c(){t=m("div"),n=m("div"),s=m("div"),c=m("h2"),c.textContent="Login to Nostr",l=p(),r=m("button"),r.textContent="×",a=p(),f=m("div"),y=m("div"),v=m("button"),v.textContent="Extension",k=p(),$=m("button"),$.textContent="Nsec",x=p(),S=m("div"),T.c(),E=p(),I&&I.c(),q=p(),O&&O.c(),b(c,"class","svelte-9yzcwg"),b(r,"class","close-btn svelte-9yzcwg"),b(s,"class","modal-header svelte-9yzcwg"),b(v,"class","tab-btn svelte-9yzcwg"),w(v,"active","extension"===e[2]),b($,"class","tab-btn svelte-9yzcwg"),w($,"active","nsec"===e[2]),b(y,"class","tabs svelte-9yzcwg"),b(S,"class","tab-content svelte-9yzcwg"),b(f,"class","tab-container svelte-9yzcwg"),b(n,"class","modal svelte-9yzcwg"),w(n,"dark-theme",e[1]),b(t,"class","modal-overlay svelte-9yzcwg"),b(t,"role","button"),b(t,"tabindex","0")},m(o,d){u(o,t,d),i(t,n),i(n,s),i(s,c),i(s,l),i(s,r),i(n,a),i(n,f),i(f,y),i(y,v),i(y,k),i(y,$),i(f,x),i(f,S),T.m(S,null),i(S,E),I&&I.m(S,null),i(S,q),O&&O.m(S,null),_||(N=[g(r,"click",e[7]),g(v,"click",e[14]),g($,"click",e[15]),g(n,"click",h(e[12])),g(n,"keydown",h(e[13])),g(t,"click",e[7]),g(t,"keydown",e[17])],_=!0)},p(e,t){4&t&&w(v,"active","extension"===e[2]),4&t&&w($,"active","nsec"===e[2]),P===(P=C(e))&&T?T.p(e,t):(T.d(1),T=P(e),T&&(T.c(),T.m(S,E))),e[5]?I?I.p(e,t):(I=R(e),I.c(),I.m(S,q)):I&&(I.d(1),I=null),e[6]?O?O.p(e,t):(O=V(e),O.c(),O.m(S,null)):O&&(O.d(1),O=null),2&t&&w(n,"dark-theme",e[1])},d(e){e&&d(t),T.d(),I&&I.d(),O&&O.d(),_=!1,o(N)}}}function B(e){let t,n,s,c,l,r,a,h,w,k,$=e[4]?"Logging in...":"Log in with nsec";return{c(){t=m("div"),n=m("p"),n.textContent="Enter your nsec (private key) to login. This will be stored securely in your browser.",s=p(),c=m("input"),l=p(),r=m("button"),a=f($),b(n,"class","svelte-9yzcwg"),b(c,"type","password"),b(c,"placeholder","nsec1..."),c.disabled=e[4],b(c,"class","nsec-input svelte-9yzcwg"),b(r,"class","login-nsec-btn svelte-9yzcwg"),r.disabled=h=e[4]||!e[3].trim(),b(t,"class","nsec-login svelte-9yzcwg")},m(o,d){u(o,t,d),i(t,n),i(t,s),i(t,c),v(c,e[3]),i(t,l),i(t,r),i(r,a),w||(k=[g(c,"input",e[16]),g(r,"click",e[10])],w=!0)},p(e,t){16&t&&(c.disabled=e[4]),8&t&&c.value!==e[3]&&v(c,e[3]),16&t&&$!==($=e[4]?"Logging in...":"Log in with nsec")&&y(a,$),24&t&&h!==(h=e[4]||!e[3].trim())&&(r.disabled=h)},d(e){e&&d(t),w=!1,o(k)}}}function H(e){let t,n,o,s,c,l,r,a=e[4]?"Connecting...":"Log in using extension";return{c(){t=m("div"),n=m("p"),n.textContent="Login using a NIP-07 compatible browser extension like nos2x or Alby.",o=p(),s=m("button"),c=f(a),b(n,"class","svelte-9yzcwg"),b(s,"class","login-extension-btn svelte-9yzcwg"),s.disabled=e[4],b(t,"class","extension-login svelte-9yzcwg")},m(a,d){u(a,t,d),i(t,n),i(t,o),i(t,s),i(s,c),l||(r=g(s,"click",e[9]),l=!0)},p(e,t){16&t&&a!==(a=e[4]?"Connecting...":"Log in using extension")&&y(c,a),16&t&&(s.disabled=e[4])},d(e){e&&d(t),l=!1,r()}}}function R(e){let t,n;return{c(){t=m("div"),n=f(e[5]),b(t,"class","message error-message svelte-9yzcwg")},m(e,o){u(e,t,o),i(t,n)},p(e,t){32&t&&y(n,e[5])},d(e){e&&d(t)}}}function V(e){let t,n;return{c(){t=m("div"),n=f(e[6]),b(t,"class","message success-message svelte-9yzcwg")},m(e,o){u(e,t,o),i(t,n)},p(e,t){64&t&&y(n,e[6])},d(e){e&&d(t)}}}function Q(t){let n,o,s,c=t[0]&&W(t);return{c(){c&&c.c(),n=f("")},m(e,l){c&&c.m(e,l),u(e,n,l),o||(s=g(K,"keydown",t[11]),o=!0)},p(e,[t]){e[0]?c?c.p(e,t):(c=W(e),c.c(),c.m(n.parentNode,n)):c&&(c.d(1),c=null)},i:e,o:e,d(e){c&&c.d(e),e&&d(n),o=!1,s()}}}function G(e,t,n){const o=x();let{showModal:s=!1}=t,{isDarkTheme:c=!1}=t,l="extension",r="",a=!1,i="",u="";function d(){n(0,s=!1),n(3,r=""),n(5,i=""),n(6,u=""),o("close")}function m(e){n(2,l=e),n(5,i=""),n(6,u="")}async function f(){n(4,a=!0),n(5,i=""),n(6,u="");try{if(!r.trim())throw new Error("Please enter your nsec");if(!(e=r.trim()).startsWith("nsec1")||(e.length<60||e.length>70))throw new Error('Invalid nsec format. Must start with "nsec1"');const t=function(e){try{return"mock_"+e.slice(5).slice(0,32)}catch(e){throw new Error("Invalid nsec format")}}(r.trim()),s="derived_"+t.slice(5,37);localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",s),localStorage.setItem("nostr_privkey",t),n(6,u="Successfully logged in with nsec!"),o("login",{method:"nsec",pubkey:s,privateKey:t}),setTimeout(()=>{d()},1500)}catch(e){n(5,i=e.message)}finally{n(4,a=!1)}var e}return e.$$set=e=>{"showModal"in e&&n(0,s=e.showModal),"isDarkTheme"in e&&n(1,c=e.isDarkTheme)},[s,c,l,r,a,i,u,d,m,async function(){n(4,a=!0),n(5,i=""),n(6,u="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(6,u="Successfully logged in with extension!"),o("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{d()},1500))}catch(e){n(5,i=e.message)}finally{n(4,a=!1)}},f,function(e){"Escape"===e.key&&d(),"Enter"===e.key&&"nsec"===l&&f()},function(t){S.call(this,e,t)},function(t){S.call(this,e,t)},()=>m("extension"),()=>m("nsec"),function(){r=this.value,n(3,r)},e=>"Escape"===e.key&&d()]}class X extends J{constructor(e){super(),j(this,e,G,Q,c,{showModal:0,isDarkTheme:1})}}const Y=["wss://relay.damus.io","wss://relay.nostr.band","wss://nos.lol","wss://relay.nostr.net","wss://relay.minibits.cash","wss://relay.coinos.io/","wss://nwc.primal.net","wss://relay.orly.dev"];const Z=new class{constructor(){this.relays=new Map,this.subscriptions=new Map}async connect(){console.log("Starting connection to",Y.length,"relays...");const e=Y.map(e=>new Promise(t=>{try{console.log(`Attempting to connect to ${e}`);const n=new WebSocket(e);n.onopen=()=>{console.log(`✓ Successfully connected to ${e}`),t(!0)},n.onerror=n=>{console.error(`✗ Error connecting to ${e}:`,n),t(!1)},n.onclose=t=>{console.warn(`Connection closed to ${e}:`,t.code,t.reason)},n.onmessage=t=>{console.log(`Message from ${e}:`,t.data);try{this.handleMessage(e,JSON.parse(t.data))}catch(n){console.error(`Failed to parse message from ${e}:`,n,t.data)}},this.relays.set(e,n),setTimeout(()=>{n.readyState!==WebSocket.OPEN&&(console.warn(`Connection timeout for ${e}`),t(!1))},5e3)}catch(n){console.error(`Failed to create WebSocket for ${e}:`,n),t(!1)}})),t=(await Promise.all(e)).filter(Boolean).length;console.log(`Connected to ${t}/${Y.length} relays`),await new Promise(e=>setTimeout(e,1e3))}handleMessage(e,t){console.log(`Processing message from ${e}:`,t);const[n,o,s,...c]=t;if(console.log(`Message type: ${n}, subscriptionId: ${o}`),"EVENT"===n)if(console.log(`Received EVENT for subscription ${o}:`,s),this.subscriptions.has(o)){console.log(`Found callback for subscription ${o}, executing...`);this.subscriptions.get(o)(s)}else console.warn(`No callback found for subscription ${o}`);else"EOSE"===n?console.log(`End of stored events for subscription ${o} from ${e}`):"NOTICE"===n?console.warn(`Notice from ${e}:`,o):console.log(`Unknown message type ${n} from ${e}:`,t)}subscribe(e,t){const n=Math.random().toString(36).substring(7);console.log(`Creating subscription ${n} with filters:`,e),this.subscriptions.set(n,t);const o=["REQ",n,e];console.log("Subscription message:",JSON.stringify(o));let s=0;for(const[e,t]of this.relays)if(console.log(`Checking relay ${e}, readyState: ${t.readyState} (${t.readyState===WebSocket.OPEN?"OPEN":"NOT OPEN"})`),t.readyState===WebSocket.OPEN)try{t.send(JSON.stringify(o)),console.log(`✓ Sent subscription to ${e}`),s++}catch(t){console.error(`✗ Failed to send subscription to ${e}:`,t)}else console.warn(`✗ Cannot send to ${e}, connection not ready`);return console.log(`Subscription ${n} sent to ${s}/${this.relays.size} relays`),n}unsubscribe(e){this.subscriptions.delete(e);const t=["CLOSE",e];for(const[e,n]of this.relays)n.readyState===WebSocket.OPEN&&n.send(JSON.stringify(t))}disconnect(){for(const[e,t]of this.relays)t.close();this.relays.clear(),this.subscriptions.clear()}},ee="events";function te(){return new Promise((e,t)=>{try{const n=indexedDB.open("nostrCache",1);n.onupgradeneeded=()=>{const e=n.result;if(!e.objectStoreNames.contains(ee)){const t=e.createObjectStore(ee,{keyPath:"id"});t.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),t.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1})}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){t(e)}})}function ne(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function oe(e){return new Promise(async(t,n)=>{console.log(`Starting profile fetch for pubkey: ${e}`);let o=!1,s=null,c=null,l=null,r=null;function a(){if(r)try{Z.unsubscribe(r)}catch{}c&&clearTimeout(c),l&&clearTimeout(l)}try{const n=await async function(e){try{const t=await te();return await new Promise((n,o)=>{const s=t.transaction(ee,"readonly").objectStore(ee).index("byKindAuthorCreated"),c=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),l=s.openCursor(c,"prev");l.onsuccess=()=>{const e=l.result;n(e?e.value:null)},l.onerror=()=>o(l.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(n){console.log("Using cached profile event");const e=ne(n);o=!0,t(e)}}catch(e){console.warn("Failed to load cached profile",e)}l=setTimeout(()=>{s?o||t(ne(s)):(console.log("Profile fetch timeout reached"),o||n(new Error("Profile fetch timeout"))),a()},15e3),setTimeout(()=>{console.log("Starting subscription after connection delay..."),r=Z.subscribe({kinds:[0],authors:[e]},n=>{n&&0===n.kind&&(console.log("Profile event received:",n),(!s||(n.created_at||0)>(s.created_at||0))&&(s=n),c&&clearTimeout(c),c=setTimeout(async()=>{try{if(s){await async function(e){try{const t=await te();await new Promise((n,o)=>{const s=t.transaction(ee,"readwrite");s.oncomplete=()=>n(),s.onerror=()=>o(s.error),s.objectStore(ee).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}(s);const n=ne(s);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:n,event:s}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}o||(t(n),o=!0)}}finally{a()}},800))})},2e3)})}function se(e,t,n){const o=e.slice();return o[27]=t[n],o}function ce(t){let n,o,s;return{c(){n=m("button"),n.textContent="📥",b(n,"class","login-btn svelte-m62qks")},m(e,c){u(e,n,c),o||(s=g(n,"click",t[15]),o=!0)},p:e,d(e){e&&d(n),o=!1,s()}}}function le(e){let t,n,s,c,l,r,a,h,v,w=(e[3]?.name||e[7].slice(0,8)+"...")+"";function k(e,t){return e[3]?.picture?ae:re}let $=k(e),x=$(e);return{c(){t=m("div"),n=m("button"),x.c(),s=p(),c=m("span"),l=f(w),r=p(),a=m("button"),a.textContent="🚪",b(c,"class","user-name svelte-m62qks"),b(n,"class","user-profile-btn svelte-m62qks"),b(a,"class","logout-btn svelte-m62qks"),b(t,"class","user-info svelte-m62qks")},m(o,d){u(o,t,d),i(t,n),x.m(n,null),i(n,s),i(n,c),i(c,l),i(t,r),i(t,a),h||(v=[g(n,"click",e[19]),g(a,"click",e[17])],h=!0)},p(e,t){$===($=k(e))&&x?x.p(e,t):(x.d(1),x=$(e),x&&(x.c(),x.m(n,s))),136&t&&w!==(w=(e[3]?.name||e[7].slice(0,8)+"...")+"")&&y(l,w)},d(e){e&&d(t),x.d(),h=!1,o(v)}}}function re(t){let n;return{c(){n=m("div"),n.textContent="👤",b(n,"class","user-avatar-placeholder svelte-m62qks")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ae(e){let t,n;return{c(){t=m("img"),r(t.src,n=e[3].picture)||b(t,"src",n),b(t,"alt","User avatar"),b(t,"class","user-avatar svelte-m62qks")},m(e,n){u(e,t,n)},p(e,o){8&o&&!r(t.src,n=e[3].picture)&&b(t,"src",n)},d(e){e&&d(t)}}}function ie(t){let n,o,s=t[27].label+"";return{c(){n=m("span"),o=f(s),b(n,"class","tab-label svelte-m62qks")},m(e,t){u(e,n,t),i(n,o)},p:e,d(e){e&&d(n)}}}function ue(e){let t,n,o,s,c,l,r,a=e[27].icon+"",h=e[4]&&ie(e);function y(){return e[23](e[27])}return{c(){t=m("button"),n=m("span"),o=f(a),s=p(),h&&h.c(),c=p(),b(n,"class","tab-icon svelte-m62qks"),b(t,"class","tab svelte-m62qks"),w(t,"active",e[2]===e[27].id)},m(e,a){u(e,t,a),i(t,n),i(n,o),i(t,s),h&&h.m(t,null),i(t,c),l||(r=g(t,"click",y),l=!0)},p(n,o){(e=n)[4]?h?h.p(e,o):(h=ie(e),h.c(),h.m(t,c)):h&&(h.d(1),h=null),2052&o&&w(t,"active",e[2]===e[27].id)},d(e){e&&d(t),h&&h.d(),l=!1,r()}}}function de(e){let t,n,s,c,l,r,a,f,y,v,k=e[3]&&me(e);return{c(){t=m("div"),n=m("div"),s=m("div"),c=m("h2"),c.textContent="Settings",l=p(),r=m("button"),r.textContent="✕",a=p(),f=m("div"),k&&k.c(),b(c,"class","svelte-m62qks"),b(r,"class","close-btn svelte-m62qks"),b(s,"class","drawer-header svelte-m62qks"),b(f,"class","drawer-content svelte-m62qks"),b(n,"class","settings-drawer svelte-m62qks"),w(n,"dark-theme",e[1]),b(t,"class","drawer-overlay svelte-m62qks"),b(t,"role","button"),b(t,"tabindex","0")},m(o,d){u(o,t,d),i(t,n),i(n,s),i(s,c),i(s,l),i(s,r),i(n,a),i(n,f),k&&k.m(f,null),y||(v=[g(r,"click",e[20]),g(n,"click",h(e[21])),g(n,"keydown",h(e[22])),g(t,"click",e[20]),g(t,"keydown",e[24])],y=!0)},p(e,t){e[3]?k?k.p(e,t):(k=me(e),k.c(),k.m(f,null)):k&&(k.d(1),k=null),2&t&&w(n,"dark-theme",e[1])},d(e){e&&d(t),k&&k.d(),y=!1,o(v)}}}function me(e){let t,n,o,s,c,l,r,a,g,h=(e[3].name||"Unknown User")+"",v=e[3].banner&&fe(e);function w(e,t){return e[3].picture?ge:pe}let k=w(e),$=k(e),x=e[3].nip05&&he(e),S=e[3].about&&be(e);return{c(){t=m("div"),n=m("div"),v&&v.c(),o=p(),$.c(),s=p(),c=m("div"),l=m("h3"),r=f(h),a=p(),x&&x.c(),g=p(),S&&S.c(),b(l,"class","profile-username svelte-m62qks"),b(c,"class","name-row svelte-m62qks"),b(n,"class","profile-hero svelte-m62qks"),b(t,"class","profile-section svelte-m62qks")},m(e,d){u(e,t,d),i(t,n),v&&v.m(n,null),i(n,o),$.m(n,null),i(n,s),i(n,c),i(c,l),i(l,r),i(c,a),x&&x.m(c,null),i(t,g),S&&S.m(t,null)},p(e,l){e[3].banner?v?v.p(e,l):(v=fe(e),v.c(),v.m(n,o)):v&&(v.d(1),v=null),k===(k=w(e))&&$?$.p(e,l):($.d(1),$=k(e),$&&($.c(),$.m(n,s))),8&l&&h!==(h=(e[3].name||"Unknown User")+"")&&y(r,h),e[3].nip05?x?x.p(e,l):(x=he(e),x.c(),x.m(c,null)):x&&(x.d(1),x=null),e[3].about?S?S.p(e,l):(S=be(e),S.c(),S.m(t,null)):S&&(S.d(1),S=null)},d(e){e&&d(t),v&&v.d(),$.d(),x&&x.d(),S&&S.d()}}}function fe(e){let t,n;return{c(){t=m("img"),r(t.src,n=e[3].banner)||b(t,"src",n),b(t,"alt","Profile banner"),b(t,"class","profile-banner svelte-m62qks")},m(e,n){u(e,t,n)},p(e,o){8&o&&!r(t.src,n=e[3].banner)&&b(t,"src",n)},d(e){e&&d(t)}}}function pe(t){let n;return{c(){n=m("div"),n.textContent="👤",b(n,"class","profile-avatar-placeholder overlap svelte-m62qks")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ge(e){let t,n;return{c(){t=m("img"),r(t.src,n=e[3].picture)||b(t,"src",n),b(t,"alt","User avatar"),b(t,"class","profile-avatar overlap svelte-m62qks")},m(e,n){u(e,t,n)},p(e,o){8&o&&!r(t.src,n=e[3].picture)&&b(t,"src",n)},d(e){e&&d(t)}}}function he(e){let t,n,o=e[3].nip05+"";return{c(){t=m("span"),n=f(o),b(t,"class","profile-nip05-inline svelte-m62qks")},m(e,o){u(e,t,o),i(t,n)},p(e,t){8&t&&o!==(o=e[3].nip05+"")&&y(n,o)},d(e){e&&d(t)}}}function be(e){let t,n;return{c(){t=m("div"),n=m("p"),b(n,"class","profile-about svelte-m62qks"),b(t,"class","about-card svelte-m62qks")},m(o,s){u(o,t,s),i(t,n),n.innerHTML=e[10]},p(e,t){1024&t&&(n.innerHTML=e[10])},d(e){e&&d(t)}}}function ye(e){let t,n,s,c,l,a,h,v,k,$,x,S,E,_,C,P,T,I,O,z,L,U,j,J,K,W,B,H,R,V,Q,G,Y,Z=e[9].label+"",ee=e[1]?"☀️":"🌙",te=e[4]?"◀":"▶";function ne(e,t){return e[6]?le:ce}let oe=ne(e),re=oe(e),ae=e[11],ie=[];for(let t=0;tfunction(e,t,n){const o=e.$$.props[t];void 0!==o&&(e.$$.bound[o]=n,n(e.$$.ctx[o]))}(R,"showModal",fe)),R.$on("login",e[16]),R.$on("close",e[18]),{c(){t=m("header"),n=m("div"),s=m("img"),l=p(),a=m("div"),h=m("span"),v=f(Z),k=p(),$=m("button"),x=f(ee),S=p(),re.c(),E=p(),_=m("div"),C=m("aside"),P=m("div"),T=m("div");for(let e=0;eV=!1,N.push(c)),R.$set(s)},i(e){Q||(D(R.$$.fragment,e),Q=!0)},o(e){!function(e,t,n,o){if(e&&e.o){if(M.has(e))return;M.add(e),(void 0).c.push(()=>{M.delete(e),o&&(n&&e.d(1),o())}),e.o(t)}else o&&o()}(R.$$.fragment,e),Q=!1},d(e){e&&d(t),re.d(),e&&d(E),e&&d(_),function(e,t){for(let n=0;n{"name"in e&&n(0,c=e.name)},e.$$.update=()=>{var t;8&e.$$.dirty&&n(10,o=m?.about?(t=m.about,String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")).replace(/\n{2,}/g,"
"):""),4&e.$$.dirty&&n(9,s=p.find(e=>e.id===a)),2&e.$$.dirty&&"undefined"!=typeof document&&(r?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme"))},[c,r,a,m,l,i,u,d,f,s,o,p,function(){n(4,l=!l)},function(){n(1,r=!r),"undefined"!=typeof localStorage&&localStorage.setItem("isDarkTheme",JSON.stringify(r))},g,function(){u||n(5,i=!0)},async function(e){const{method:t,pubkey:o,privateKey:s,signer:c}=e.detail;n(6,u=!0),n(7,d=o),n(5,i=!1);try{await async function(){await Z.connect()}(),n(3,m=await oe(o)),console.log("Profile loaded:",m)}catch(e){console.error("Failed to load profile:",e)}},function(){n(6,u=!1),n(7,d=""),n(3,m=null),n(8,f=!1),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(5,i=!1)},function(){n(8,f=!0)},h,function(t){S.call(this,e,t)},function(t){S.call(this,e,t)},e=>g(e.id),e=>"Escape"===e.key&&h(),function(e){i=e,n(5,i)}]}return new class extends J{constructor(e){super(),j(this,e,ve,ye,c,{name:0})}}({target:document.body,props:{name:"world"}})}();
-//# sourceMappingURL=bundle.js.map
diff --git a/app/web/dist/bundle.css b/app/web/dist/bundle.css
deleted file mode 100644
index 2459e63..0000000
--- a/app/web/dist/bundle.css
+++ /dev/null
@@ -1,72 +0,0 @@
-.modal-overlay.svelte-9yzcwg.svelte-9yzcwg{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000}.modal.svelte-9yzcwg.svelte-9yzcwg{background:var(--bg-color);border-radius:8px;box-shadow:0 4px 20px rgba(0, 0, 0, 0.3);width:90%;max-width:500px;max-height:90vh;overflow-y:auto;border:1px solid var(--border-color)}.modal-header.svelte-9yzcwg.svelte-9yzcwg{display:flex;justify-content:space-between;align-items:center;padding:20px;border-bottom:1px solid var(--border-color)}.modal-header.svelte-9yzcwg h2.svelte-9yzcwg{margin:0;color:var(--text-color);font-size:1.5rem}.close-btn.svelte-9yzcwg.svelte-9yzcwg{background:none;border:none;font-size:1.5rem;cursor:pointer;color:var(--text-color);padding:0;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border-radius:50%;transition:background-color 0.2s}.close-btn.svelte-9yzcwg.svelte-9yzcwg:hover{background-color:var(--tab-hover-bg)}.tab-container.svelte-9yzcwg.svelte-9yzcwg{padding:20px}.tabs.svelte-9yzcwg.svelte-9yzcwg{display:flex;border-bottom:1px solid var(--border-color);margin-bottom:20px}.tab-btn.svelte-9yzcwg.svelte-9yzcwg{flex:1;padding:12px 16px;background:none;border:none;cursor:pointer;color:var(--text-color);font-size:1rem;transition:all 0.2s;border-bottom:2px solid transparent}.tab-btn.svelte-9yzcwg.svelte-9yzcwg:hover{background-color:var(--tab-hover-bg)}.tab-btn.active.svelte-9yzcwg.svelte-9yzcwg{border-bottom-color:var(--primary);color:var(--primary)}.tab-content.svelte-9yzcwg.svelte-9yzcwg{min-height:200px}.extension-login.svelte-9yzcwg.svelte-9yzcwg,.nsec-login.svelte-9yzcwg.svelte-9yzcwg{display:flex;flex-direction:column;gap:16px}.extension-login.svelte-9yzcwg p.svelte-9yzcwg,.nsec-login.svelte-9yzcwg p.svelte-9yzcwg{margin:0;color:var(--text-color);line-height:1.5}.login-extension-btn.svelte-9yzcwg.svelte-9yzcwg,.login-nsec-btn.svelte-9yzcwg.svelte-9yzcwg{padding:12px 24px;background:var(--primary);color:white;border:none;border-radius:6px;cursor:pointer;font-size:1rem;transition:background-color 0.2s}.login-extension-btn.svelte-9yzcwg.svelte-9yzcwg:hover:not(:disabled),.login-nsec-btn.svelte-9yzcwg.svelte-9yzcwg:hover:not(:disabled){background:#00ACC1}.login-extension-btn.svelte-9yzcwg.svelte-9yzcwg:disabled,.login-nsec-btn.svelte-9yzcwg.svelte-9yzcwg:disabled{background:#ccc;cursor:not-allowed}.nsec-input.svelte-9yzcwg.svelte-9yzcwg{padding:12px;border:1px solid var(--input-border);border-radius:6px;font-size:1rem;background:var(--bg-color);color:var(--text-color)}.nsec-input.svelte-9yzcwg.svelte-9yzcwg:focus{outline:none;border-color:var(--primary)}.message.svelte-9yzcwg.svelte-9yzcwg{padding:10px;border-radius:4px;margin-top:16px;text-align:center}.error-message.svelte-9yzcwg.svelte-9yzcwg{background:#ffebee;color:#c62828;border:1px solid #ffcdd2}.success-message.svelte-9yzcwg.svelte-9yzcwg{background:#e8f5e8;color:#2e7d32;border:1px solid #c8e6c9}.modal.dark-theme.svelte-9yzcwg .error-message.svelte-9yzcwg{background:#4a2c2a;color:#ffcdd2;border:1px solid #6d4c41}.modal.dark-theme.svelte-9yzcwg .success-message.svelte-9yzcwg{background:#2e4a2e;color:#a5d6a7;border:1px solid #4caf50}
-body{margin:0;padding:0;--bg-color:#ddd;--header-bg:#eee;--border-color:#dee2e6;--text-color:#444444;--input-border:#ccc;--button-bg:#ddd;--button-hover-bg:#eee;--primary:#00BCD4;--warning:#ff3e00;--tab-inactive-bg:#bbb}body.dark-theme{--bg-color:#263238;--header-bg:#1e272c;--border-color:#404040;--text-color:#ffffff;--input-border:#555;--button-bg:#263238;--button-hover-bg:#1e272c;--primary:#00BCD4;--warning:#ff3e00;--tab-inactive-bg:#1a1a1a}.main-header.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{height:3em;background-color:var(--header-bg);position:fixed;top:0;left:0;right:0;z-index:1000;color:var(--text-color)}.header-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{height:100%;display:flex;align-items:center;padding:0;gap:0}.logo.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{height:2.5em;width:2.5em;object-fit:contain;flex-shrink:0}.header-title.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1;height:100%;display:flex;align-items:center;gap:0;padding:0 1rem}.app-title.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:1em;font-weight:600;color:var(--text-color);display:flex;align-items:center;gap:0.5rem}.permission-badge.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.7em;font-weight:500;padding:0.2em 0.5em;border-radius:0.3em;background-color:var(--primary);color:white;text-transform:uppercase;letter-spacing:0.05em}.search-input-container.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1;height:100%;display:flex;align-items:center;padding:0 1rem}.search-input.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:100%;height:2em;padding:0.5rem;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:1em;outline:none}.search-input.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:focus{border-color:var(--primary)}.search-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.search-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background-color:var(--button-bg)}.theme-toggle-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.theme-toggle-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background-color:var(--button-bg)}.login-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.5em 1em;border:none;border-radius:6px;background-color:#4CAF50;color:white;cursor:pointer;font-size:1rem;font-weight:500;transition:background-color 0.2s;display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;margin:0 auto;padding:0.5em 1em}.login-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background-color:#45a049}.app-container.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;margin-top:3em;height:calc(100vh - 3em)}.sidebar.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:fixed;left:0;top:3em;bottom:0;width:200px;background-color:var(--header-bg);color:var(--text-color);z-index:100}.sidebar-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{height:100%;display:flex;flex-direction:column;padding:0}.tabs.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;flex-direction:column}.tab.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{height:3em;display:flex;align-items:center;padding:0 1rem;cursor:pointer;border:none;background:transparent;color:var(--text-color);transition:background-color 0.2s ease;gap:0.75rem;text-align:left;width:100%}.tab.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background-color:var(--bg-color)}.tab.active.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:var(--bg-color)}.tab-icon.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:1.2em;flex-shrink:0;width:1.5em;text-align:center}.tab-label.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.9em;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}.tab-close-icon.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{cursor:pointer;transition:opacity 0.2s;font-size:0.8em;margin-left:auto;padding:0.25rem;border-radius:0.25rem;flex-shrink:0}.tab-close-icon.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{opacity:0.7;background-color:var(--warning);color:white}.main-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:fixed;left:200px;top:3em;right:0;bottom:0;padding:2rem;overflow-y:auto;background-color:var(--bg-color);color:var(--text-color);display:flex;align-items:center;justify-content:center}.welcome-message.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{text-align:center}.welcome-message.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{font-size:1.2rem}.sprocket-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:100%;max-width:1200px;margin:0 auto;padding:1rem}.sprocket-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:var(--card-bg);border-radius:8px;padding:1.5rem;margin-bottom:1.5rem;border:1px solid var(--border-color)}.sprocket-header.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.sprocket-controls.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;gap:0.5rem}.sprocket-upload-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{margin-bottom:1rem;padding:1rem;background-color:var(--bg-color);border-radius:6px;border:1px solid var(--border-color)}.sprocket-upload-section.svelte-4jqeqn h4.svelte-4jqeqn.svelte-4jqeqn{margin:0 0 0.75rem 0;color:var(--text-color);font-size:1rem;font-weight:500}.upload-controls.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;gap:0.5rem;align-items:center}.upload-controls.svelte-4jqeqn input[type="file"].svelte-4jqeqn.svelte-4jqeqn{flex:1;padding:0.5rem;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:0.9rem}.sprocket-btn.upload-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#8b5cf6;color:white}.sprocket-btn.upload-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#7c3aed}.sprocket-status.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;gap:1rem;margin-bottom:1rem;padding:0.75rem;background-color:var(--bg-color);border-radius:6px;border:1px solid var(--border-color)}.status-item.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;flex-direction:column;gap:0.25rem}.status-label.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.8rem;color:var(--text-muted);font-weight:500}.status-value.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.9rem;font-weight:600}.status-value.running.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{color:#22c55e}.script-editor-container.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{margin-bottom:1rem}.script-editor.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:100%;height:300px;padding:1rem;border:1px solid var(--border-color);border-radius:6px;background-color:var(--bg-color);color:var(--text-color);font-family:'Monaco', 'Menlo', 'Ubuntu Mono', monospace;font-size:0.9rem;line-height:1.4;resize:vertical;outline:none}.script-editor.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:focus{border-color:var(--primary-color);box-shadow:0 0 0 2px rgba(59, 130, 246, 0.1)}.script-editor.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:disabled{opacity:0.6;cursor:not-allowed}.script-actions.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;gap:0.5rem;margin-bottom:1rem}.sprocket-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.5rem 1rem;border:none;border-radius:6px;font-size:0.9rem;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;gap:0.5rem}.sprocket-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:disabled{opacity:0.6;cursor:not-allowed}.sprocket-btn.save-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#22c55e;color:white}.sprocket-btn.save-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#16a34a}.sprocket-btn.load-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#3b82f6;color:white}.sprocket-btn.load-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#2563eb}.sprocket-btn.restart-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#f59e0b;color:white}.sprocket-btn.restart-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#d97706}.sprocket-btn.delete-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#ef4444;color:white}.sprocket-btn.delete-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#dc2626}.sprocket-btn.refresh-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#6b7280;color:white}.sprocket-btn.refresh-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#4b5563}.sprocket-message.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.75rem;border-radius:6px;font-size:0.9rem;font-weight:500;background-color:#dbeafe;color:#1e40af;border:1px solid #93c5fd}.sprocket-message.error.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#fee2e2;color:#dc2626;border-color:#fca5a5}.versions-list.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;flex-direction:column;gap:0.75rem;margin-bottom:1rem}.version-item.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;justify-content:space-between;align-items:center;padding:1rem;background-color:var(--bg-color);border:1px solid var(--border-color);border-radius:6px;transition:all 0.2s ease}.version-item.current.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border-color:var(--primary-color);background-color:rgba(59, 130, 246, 0.05)}.version-item.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{border-color:var(--primary-color)}.version-info.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1}.version-name.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-weight:600;font-size:0.9rem;margin-bottom:0.25rem}.version-date.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.8rem;color:var(--text-muted);display:flex;align-items:center;gap:0.5rem}.current-badge.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:var(--primary-color);color:white;padding:0.125rem 0.5rem;border-radius:12px;font-size:0.7rem;font-weight:500}.version-actions.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;gap:0.5rem}.version-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.375rem 0.75rem;border:none;border-radius:4px;font-size:0.8rem;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;gap:0.25rem}.version-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:disabled{opacity:0.6;cursor:not-allowed}.version-btn.load-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#3b82f6;color:white}.version-btn.load-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#2563eb}.version-btn.delete-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background-color:#ef4444;color:white}.version-btn.delete-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover:not(:disabled){background-color:#dc2626}@media(max-width: 640px){.header-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0}.sidebar.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:160px}.main-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{left:160px;padding:1rem}}.user-info.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:flex-start;padding:0;height:3em}.logout-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.5rem 1rem;border:none;border-radius:6px;background-color:var(--warning);color:white;cursor:pointer;font-size:1rem;font-weight:500;transition:background-color 0.2s;display:flex;align-items:center;justify-content:center;gap:0.5rem}.logout-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background-color:#e53935}.logout-btn.floating.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:absolute;top:0.5em;right:0.5em;z-index:10;box-shadow:0 2px 8px rgba(0, 0, 0, 0.3)}.user-profile-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.user-profile-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background-color:var(--button-bg)}.user-avatar.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.user-avatar-placeholder.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:1em;height:1em;object-fit:cover}.user-avatar-placeholder.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:center;justify-content:center;font-size:0.5em;padding:0.5em}.user-name.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.8rem;font-weight:500;max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.drawer-overlay.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.5);z-index:1000;display:flex;justify-content:flex-end}.settings-drawer.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:640px;height:100%;background:var(--bg-color);overflow-y:auto;animation:svelte-4jqeqn-slideIn 0.3s ease}@keyframes svelte-4jqeqn-slideIn{from{transform:translateX(100%)}to{transform:translateX(0)}}.drawer-header.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:center;justify-content:space-between;background:var(--header-bg)}.drawer-header.svelte-4jqeqn h2.svelte-4jqeqn.svelte-4jqeqn{margin:0;color:var(--text-color);font-size:1em;padding:1rem}.close-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:none;border:none;font-size:1em;cursor:pointer;color:var(--text-color);padding:0.5em;transition:background-color 0.2s;align-items:center}.close-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background:var(--button-hover-bg)}.profile-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{margin-bottom:2rem}.profile-hero.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:relative}.profile-banner.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:100%;height:160px;object-fit:cover;border-radius:0;display:block}.profile-avatar.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.profile-avatar-placeholder.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:72px;height:72px;border-radius:50%;object-fit:cover;flex-shrink:0;box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid var(--bg-color)}.overlap.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:absolute;left:12px;bottom:-36px;z-index:2;background:var(--button-hover-bg);display:flex;align-items:center;justify-content:center;font-size:1.5rem}.name-row.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:absolute;left:calc(12px + 72px + 12px);bottom:8px;right:12px;display:flex;align-items:baseline;gap:8px;z-index:1}.profile-username.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{margin:0;font-size:1.1rem;color:#000;text-shadow:0 3px 6px rgba(255,255,255,1)}.profile-nip05-inline.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.85rem;color:#000;font-family:monospace;opacity:0.95;text-shadow:0 3px 6px rgba(255,255,255,1)}.about-card.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:var(--header-bg);padding:12px 12px 12px 96px;position:relative;word-break:auto-phrase}.profile-about.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{margin:0;color:var(--text-color);font-size:0.9rem;line-height:1.4}.profile-loading-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:1rem;text-align:center}.profile-loading-section.svelte-4jqeqn h3.svelte-4jqeqn.svelte-4jqeqn{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.profile-loading-section.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0 0 1rem 0;color:var(--text-color);opacity:0.8}.retry-profile-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.5rem 1rem;background:var(--primary);color:white;border:none;border-radius:4px;cursor:pointer;font-size:0.9rem;margin-bottom:1rem;transition:background-color 0.2s}.retry-profile-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background:#00ACC1}.user-pubkey-display.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.7;background:var(--button-bg);padding:0.5rem;border-radius:4px;word-break:break-all}.export-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.import-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:2rem;max-width:800px;margin:0 auto}.export-view.svelte-4jqeqn h2.svelte-4jqeqn.svelte-4jqeqn,.import-view.svelte-4jqeqn h2.svelte-4jqeqn.svelte-4jqeqn{margin:0 0 2rem 0;color:var(--text-color);font-size:1.5rem;font-weight:600}.export-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.import-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:var(--header-bg);padding:1.5rem;border-radius:8px;margin-bottom:1.5rem}.export-section.svelte-4jqeqn h3.svelte-4jqeqn.svelte-4jqeqn,.import-section.svelte-4jqeqn h3.svelte-4jqeqn.svelte-4jqeqn{margin:0 0 1rem 0;color:var(--text-color);font-size:1.2rem;font-weight:500}.export-section.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn,.import-section.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0 0 1rem 0;color:var(--text-color);opacity:0.8;line-height:1.5}.events-view-buttons.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;gap:0.5rem;align-items:center}.export-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.import-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.refresh-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.reload-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.5rem 1rem;background:var(--primary);color:white;border:none;border-radius:4px;cursor:pointer;font-size:0.875rem;font-weight:500;transition:background-color 0.2s;display:inline-flex;align-items:center;gap:0.25rem;height:2em}.export-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover,.import-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover,.refresh-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover,.reload-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background:#00ACC1}.reload-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{min-width:2em;justify-content:center}.spinner.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:1em;height:1em;border:2px solid transparent;border-top:2px solid currentColor;border-radius:50%;animation:svelte-4jqeqn-spin 1s linear infinite}@keyframes svelte-4jqeqn-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.export-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:disabled,.import-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:disabled{opacity:0.5;cursor:not-allowed}#import-file.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{margin:1rem 0;padding:0.5rem;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:1rem}.login-prompt.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{text-align:center;padding:2rem;background:var(--header-bg);border-radius:8px}.login-prompt.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.permission-denied.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{text-align:center;padding:2rem;background:var(--header-bg);border-radius:8px;border:2px solid var(--warning)}.permission-denied.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0;color:var(--warning);font-size:1.1rem;font-weight:500}.events-view-container.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:fixed;top:3em;left:200px;right:0;bottom:0;background:var(--bg-color);color:var(--text-color);display:flex;flex-direction:column;overflow:hidden}.events-view-header.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:absolute;bottom:0;left:0;right:0;padding:0.5rem 1rem;background:var(--header-bg);border-top:1px solid var(--border-color);display:flex;justify-content:space-between;align-items:center;height:2.5em;z-index:10}.events-view-toggle.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1;display:flex;align-items:center;justify-content:center}.toggle-container.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:center;gap:0.5rem;cursor:pointer;font-size:0.875rem;color:var(--text-color)}.toggle-container.svelte-4jqeqn input[type="checkbox"].svelte-4jqeqn.svelte-4jqeqn{display:none}.toggle-slider.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:relative;width:2.5em;height:1.25em;background:var(--border-color);border-radius:1.25em;transition:background-color 0.3s}.toggle-slider.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn::before{content:'';position:absolute;top:0.125em;left:0.125em;width:1em;height:1em;background:white;border-radius:50%;transition:transform 0.3s}.toggle-container.svelte-4jqeqn input[type="checkbox"].svelte-4jqeqn:checked+.toggle-slider.svelte-4jqeqn{background:var(--primary)}.toggle-container.svelte-4jqeqn input[type="checkbox"].svelte-4jqeqn:checked+.toggle-slider.svelte-4jqeqn::before{transform:translateX(1.25em)}.toggle-label.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.875rem;font-weight:500;user-select:none}.events-view-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1;overflow-y:auto;padding:0}.events-view-item.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.events-view-item.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background:var(--button-hover-bg)}.events-view-item.expanded.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:var(--button-hover-bg)}.events-view-row.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:center;padding:0.4rem 1rem;cursor:pointer;gap:0.75rem;min-height:2rem}.events-view-avatar.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex-shrink:0;width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center}.avatar-placeholder.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:1.5rem;height:1.5rem;border-radius:50%;background:var(--button-bg);display:flex;align-items:center;justify-content:center;font-size:0.7rem}.events-view-info.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.1rem}.events-view-author.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.events-view-kind.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:center;gap:0.5rem}.kind-number.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:var(--primary);color:white;padding:0.125rem 0.375rem;border-radius:0.25rem;font-size:0.7rem;font-weight:500;font-family:monospace}.kind-name.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.75rem;color:var(--text-color);opacity:0.7;font-weight:500}.events-view-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.event-timestamp.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.event-content-single-line.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.delete-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex-shrink:0;background:none;border:none;cursor:pointer;padding:0.2rem;border-radius:0.25rem;transition:background-color 0.2s;font-size:1.6rem;display:flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem}.delete-btn.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background:var(--warning);color:white}.kind-number.delete-event.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:var(--warning)}.delete-event-info.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;flex-direction:column;gap:0.25rem}.delete-event-label.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-weight:500;color:var(--warning)}.delete-targets.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;flex-direction:column;gap:0.125rem}.delete-target.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.75rem;font-family:monospace;color:var(--text-color);opacity:0.7}.events-view-details.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.event-json.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:var(--bg-color);border:1px solid var(--border-color);border-radius:0.25rem;padding:1rem;margin:0;font-family:'Courier New', monospace;font-size:0.8rem;line-height:1.4;color:var(--text-color);white-space:pre-wrap;word-break:break-word;overflow-x:auto}.no-events.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-events.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0;font-size:1rem}.loading-events.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-spinner.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:2rem;height:2rem;border:3px solid var(--border-color);border-top:3px solid var(--primary);border-radius:50%;animation:svelte-4jqeqn-spin 1s linear infinite;margin:0 auto 1rem auto}@keyframes svelte-4jqeqn-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.loading-events.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0;font-size:0.9rem}.end-of-events.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:1rem;text-align:center;color:var(--text-color);opacity:0.5;font-size:0.8rem;border-top:1px solid var(--border-color)}.end-of-events.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0}.search-results-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{position:fixed;top:3em;left:200px;right:0;bottom:0;background:var(--bg-color);color:var(--text-color);display:flex;flex-direction:column;overflow:hidden}.search-results-header.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:0.5rem 1rem;background:var(--header-bg);border-bottom:1px solid var(--border-color);flex-shrink:0;display:flex;justify-content:space-between;align-items:center;height:2.5em}.search-results-header.svelte-4jqeqn h2.svelte-4jqeqn.svelte-4jqeqn{margin:0;font-size:1rem;font-weight:600;color:var(--text-color)}.search-results-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1;overflow-y:auto;padding:0}.search-result-item.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.search-result-item.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn:hover{background:var(--button-hover-bg)}.search-result-item.expanded.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{background:var(--button-hover-bg)}.search-result-row.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:center;padding:0.75rem 1rem;cursor:pointer;gap:0.75rem;min-height:3rem}.search-result-avatar.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex-shrink:0;width:2rem;height:2rem;display:flex;align-items:center;justify-content:center}.search-result-info.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.25rem}.search-result-author.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.search-result-kind.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:flex;align-items:center;gap:0.5rem}.search-result-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.search-result-content.svelte-4jqeqn .event-timestamp.svelte-4jqeqn.svelte-4jqeqn{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.search-result-content.svelte-4jqeqn .event-content-single-line.svelte-4jqeqn.svelte-4jqeqn{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.search-result-details.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.no-search-results.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-search-results.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0;font-size:1rem}.loading-search-results.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-search-results.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0;font-size:0.9rem}.end-of-search-results.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:1rem;text-align:center;color:var(--text-color);opacity:0.5;font-size:0.8rem;border-top:1px solid var(--border-color)}.end-of-search-results.svelte-4jqeqn p.svelte-4jqeqn.svelte-4jqeqn{margin:0}@media(max-width: 1280px){.sidebar.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:60px}.main-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{left:60px}.events-view-container.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{left:60px}.search-results-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{left:60px}.tab-label.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{display:none}.tab.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{justify-content:center;padding:0 0.5rem}.tab-icon.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:2em;height:2em;display:flex;align-items:center;justify-content:center;border-radius:0.25rem;background-color:var(--bg-color)}.tab.active.svelte-4jqeqn .tab-icon.svelte-4jqeqn.svelte-4jqeqn{background-color:var(--primary);color:white}}@media(max-width: 640px){.settings-drawer.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:100%}.name-row.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{left:calc(8px + 56px + 8px);bottom:6px;right:8px;gap:6px}.profile-username.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:1rem}.profile-nip05-inline.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.8rem}.export-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.import-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:1rem}.export-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn,.import-section.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{padding:1rem}.events-view-container.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{left:160px}.events-view-info.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:8rem}.events-view-author.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.7rem}.kind-name.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.7rem}.events-view-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.8rem}.search-results-view.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{left:160px}.search-result-info.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{width:8rem}.search-result-author.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.7rem}.search-result-content.svelte-4jqeqn.svelte-4jqeqn.svelte-4jqeqn{font-size:0.8rem}}
-html,
-body {
- position: relative;
- width: 100%;
- height: 100%;
-}
-
-body {
- color: #333;
- margin: 0;
- padding: 8px;
- box-sizing: border-box;
- font-family:
- -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
- Cantarell, "Helvetica Neue", sans-serif;
-}
-
-a {
- color: rgb(0, 100, 200);
- text-decoration: none;
-}
-
-a:hover {
- text-decoration: underline;
-}
-
-a:visited {
- color: rgb(0, 80, 160);
-}
-
-label {
- display: block;
-}
-
-input,
-button,
-select,
-textarea {
- font-family: inherit;
- font-size: inherit;
- -webkit-padding: 0.4em 0;
- padding: 0.4em;
- margin: 0 0 0.5em 0;
- box-sizing: border-box;
- border: 1px solid #ccc;
- border-radius: 2px;
-}
-
-input:disabled {
- color: #ccc;
-}
-
-button {
- color: #333;
- background-color: #f4f4f4;
- outline: none;
-}
-
-button:disabled {
- color: #999;
-}
-
-button:not(:disabled):active {
- background-color: #ddd;
-}
-
-button:focus {
- border-color: #666;
-}
-
diff --git a/app/web/dist/bundle.js b/app/web/dist/bundle.js
deleted file mode 100644
index c622700..0000000
--- a/app/web/dist/bundle.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var app=function(){"use strict";function noop(){}function run(e){return e()}function blank_object(){return Object.create(null)}function run_all(e){e.forEach(run)}function is_function(e){return"function"==typeof e}function safe_not_equal(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let src_url_equal_anchor;function src_url_equal(e,t){return src_url_equal_anchor||(src_url_equal_anchor=document.createElement("a")),src_url_equal_anchor.href=t,e===src_url_equal_anchor.href}function is_empty(e){return 0===Object.keys(e).length}const globals="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function append(e,t){e.appendChild(t)}function insert(e,t,n){e.insertBefore(t,n||null)}function detach(e){e.parentNode&&e.parentNode.removeChild(e)}function destroy_each(e,t){for(let n=0;ne.removeEventListener(t,n,r)}function stop_propagation(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function attr(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function children(e){return Array.from(e.childNodes)}function set_data(e,t){t=""+t,e.data!==t&&(e.data=t)}function set_input_value(e,t){e.value=null==t?"":t}function toggle_class(e,t,n){e.classList[n?"add":"remove"](t)}function custom_event(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let current_component;function set_current_component(e){current_component=e}function get_current_component(){if(!current_component)throw new Error("Function called outside component initialization");return current_component}function createEventDispatcher(){const e=get_current_component();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const i=custom_event(t,n,{cancelable:r});return s.slice().forEach(t=>{t.call(e,i)}),!i.defaultPrevented}return!0}}function bubble(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const dirty_components=[],binding_callbacks=[];let render_callbacks=[];const flush_callbacks=[],resolved_promise=Promise.resolve();let update_scheduled=!1;function schedule_update(){update_scheduled||(update_scheduled=!0,resolved_promise.then(flush))}function add_render_callback(e){render_callbacks.push(e)}function add_flush_callback(e){flush_callbacks.push(e)}const seen_callbacks=new Set;let flushidx=0;function flush(){if(0!==flushidx)return;const e=current_component;do{try{for(;flushidx-1===e.indexOf(r)?t.push(r):n.push(r)),n.forEach(e=>e()),render_callbacks=t}const outroing=new Set;let outros;function transition_in(e,t){e&&e.i&&(outroing.delete(e),e.i(t))}function transition_out(e,t,n,r){if(e&&e.o){if(outroing.has(e))return;outroing.add(e),outros.c.push(()=>{outroing.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function bind(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}function create_component(e){e&&e.c()}function mount_component(e,t,n,r){const{fragment:s,after_update:i}=e.$$;s&&s.m(t,n),r||add_render_callback(()=>{const t=e.$$.on_mount.map(run).filter(is_function);e.$$.on_destroy?e.$$.on_destroy.push(...t):run_all(t),e.$$.on_mount=[]}),i.forEach(add_render_callback)}function destroy_component(e,t){const n=e.$$;null!==n.fragment&&(flush_render_callbacks(n.after_update),run_all(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function make_dirty(e,t){-1===e.$$.dirty[0]&&(dirty_components.push(e),schedule_update(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const i=r.length?r[0]:n;return l.ctx&&s(l.ctx[t],l.ctx[t]=i)&&(!l.skip_bound&&l.bound[t]&&l.bound[t](i),u&&make_dirty(e,t)),n}):[],l.update(),u=!0,run_all(l.before_update),l.fragment=!!r&&r(l.ctx),t.target){if(t.hydrate){const e=children(t.target);l.fragment&&l.fragment.l(e),e.forEach(detach)}else l.fragment&&l.fragment.c();t.intro&&transition_in(e.$$.fragment),mount_component(e,t.target,t.anchor,t.customElement),flush()}set_current_component(c)}class SvelteComponent{$destroy(){destroy_component(this,1),this.$destroy=noop}$on(e,t){if(!is_function(t))return noop;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!is_empty(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lib$1={},types={};Object.defineProperty(types,"__esModule",{value:!0});var ee={},taskCollection$1={},taskCollection={},utils$1={};function _fast_remove_single(e,t){-1!==t&&(0===t?e.shift():t===e.length-1?e.length=e.length-1:e.splice(t,1))}Object.defineProperty(utils$1,"__esModule",{value:!0}),utils$1._fast_remove_single=void 0,utils$1._fast_remove_single=_fast_remove_single;var bakeCollection={};(function(exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.bakeCollectionVariadic=exports.bakeCollectionAwait=exports.bakeCollection=exports.BAKED_EMPTY_FUNC=void 0,exports.BAKED_EMPTY_FUNC=function(){};var FORLOOP_FALLBACK=1500;function generateArgsDefCode(e){var t="";if(0===e)return t;for(var n=0;n1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var s;if(1===r)(s=Array(1+arguments.length)).push(s),s.push.apply(s,arguments),this._tasks=s;else(s=Array(arguments.length)).push.apply(s,arguments),this._tasks=s;this.length+=arguments.length}else this._tasks=1===r?[this._tasks,e]:e,this.length++}function push_rebuild(e,t){var n,r=this.length;if(r>1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var s;if(1===r)(s=Array(1+arguments.length)).push(s),s.push.apply(s,arguments),this._tasks=s;else(s=Array(arguments.length)).push.apply(s,arguments),this._tasks=s;this.length+=arguments.length}else this._tasks=1===r?[this._tasks,e]:e,this.length++;this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}function removeLast_norebuild(e){0!==this.length&&(1===this.length?this._tasks===e&&(this.length=0):((0,utils_1$1._fast_remove_single)(this._tasks,this._tasks.lastIndexOf(e)),1===this._tasks.length?(this._tasks=this._tasks[0],this.length=1):this.length=this._tasks.length))}function removeLast_rebuild(e){if(0!==this.length){if(1===this.length)return this._tasks===e&&(this.length=0),this.firstEmitBuildStrategy?void(this.call=bake_collection_1.BAKED_EMPTY_FUNC):void this.rebuild();(0,utils_1$1._fast_remove_single)(this._tasks,this._tasks.lastIndexOf(e)),1===this._tasks.length?(this._tasks=this._tasks[0],this.length=1):this.length=this._tasks.length,this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}}function insert_norebuild(e){for(var t,n=[],r=1;r=1.5*n;return Math.round(e/n)+" "+r+(s?"s":"")}return ms=function(a,c){c=c||{};var l=typeof a;if("string"===l&&a.length>0)return function(o){if((o=String(o)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===l&&isFinite(a))return c.long?function(s){var i=Math.abs(s);if(i>=r)return o(s,i,r,"day");if(i>=n)return o(s,i,n,"hour");if(i>=t)return o(s,i,t,"minute");if(i>=e)return o(s,i,e,"second");return s+" ms"}(a):function(s){var i=Math.abs(s);if(i>=r)return Math.round(s/r)+"d";if(i>=n)return Math.round(s/n)+"h";if(i>=t)return Math.round(s/t)+"m";if(i>=e)return Math.round(s/e)+"s";return s+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}function setup(e){function t(e){let r,s,i,o=null;function a(...e){if(!a.enabled)return;const n=a,s=Number(new Date),i=s-(r||s);n.diff=i,n.prev=r,n.curr=s,r=s,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if("%%"===r)return"%";o++;const i=t.formatters[s];if("function"==typeof i){const t=e[o];r=i.call(n,t),e.splice(o,1),o--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(s!==t.namespaces&&(s=t.namespaces,i=t.enabled(e)),i),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e,t){let n=0,r=0,s=-1,i=0;for(;n"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=requireMs(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"%%"!==e&&(r++,"%c"===e&&(s=r))}),t.splice(s,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=common(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(browser,browser.exports);var browserExports=browser.exports,createDebug5=getDefaultExportFromCjs(browserExports);function number$2(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bytes$2(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$1(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$2(e.outputLen),number$2(e.blockLen)}function exists$2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$2(e,t){bytes$2(e);const n=t.outputLen;if(e.lengthe instanceof Uint8Array,createView$3=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$2=(e,t)=>e<<32-t|e>>>t,isLE$2=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];
-/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!isLE$2)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$4(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$3(e){if("string"==typeof e&&(e=utf8ToBytes$4(e)),!u8a$2(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$3(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$2(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}let Hash$2=class{clone(){return this._cloneInto()}};function wrapConstructor$1(e){const t=t=>e().update(toBytes$3(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$2(e=32){if(crypto$2&&"function"==typeof crypto$2.getRandomValues)return crypto$2.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64$3(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}let SHA2$1=class extends Hash$2{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=createView$3(this.buffer)}update(e){exists$2(this);const{view:t,buffer:n,blockLen:r}=this,s=(e=toBytes$3(e)).length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let e=i;el.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,Maj$2=(e,t,n)=>e&t^e&n^t&n,SHA256_K$2=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]),IV$1=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$2=new Uint32Array(64);let SHA256$2=class extends SHA2$1{constructor(){super(64,32,8,!1),this.A=0|IV$1[0],this.B=0|IV$1[1],this.C=0|IV$1[2],this.D=0|IV$1[3],this.E=0|IV$1[4],this.F=0|IV$1[5],this.G=0|IV$1[6],this.H=0|IV$1[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:i,G:o,H:a}=this;return[e,t,n,r,s,i,o,a]}set(e,t,n,r,s,i,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$2[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$2[e-15],n=SHA256_W$2[e-2],r=rotr$2(t,7)^rotr$2(t,18)^t>>>3,s=rotr$2(n,17)^rotr$2(n,19)^n>>>10;SHA256_W$2[e]=s+SHA256_W$2[e-7]+r+SHA256_W$2[e-16]|0}let{A:n,B:r,C:s,D:i,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$2(o,6)^rotr$2(o,11)^rotr$2(o,25))+Chi$2(o,a,c)+SHA256_K$2[e]+SHA256_W$2[e]|0,u=(rotr$2(n,2)^rotr$2(n,13)^rotr$2(n,22))+Maj$2(n,r,s)|0;l=c,c=a,a=o,o=i+t|0,i=s,s=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,s,i,o,a,c,l)}roundClean(){SHA256_W$2.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$3=wrapConstructor$1(()=>new SHA256$2),_0n$9=BigInt(0),_1n$9=BigInt(1),_2n$5=BigInt(2),u8a$1=e=>e instanceof Uint8Array,hexes$2=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bytesToHex$2(e){if(!u8a$1(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$1(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}function equalBytes$1(e,t){if(e.length!==t.length)return!1;for(let n=0;n_0n$9;e>>=_1n$9,t+=1);return t}function bitGet(e,t){return e>>BigInt(t)&_1n$9}const bitSet=(e,t,n)=>e|(n?_1n$9:_0n$9)<(_2n$5<new Uint8Array(e),u8fr=e=>Uint8Array.from(e);function createHmacDrbg$1(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=u8n(e),s=u8n(e),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...e)=>n(s,r,...e),c=(e=u8n())=>{s=a(u8fr([0]),e),r=a(),0!==e.length&&(s=a(u8fr([1]),e),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(o(),c(e);!(n=t(l()));)c();return o(),n}}const validatorFns={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function validateObject(e,t,n={}){const r=(t,n,r)=>{const s=validatorFns[n];if("function"!=typeof s)throw new Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||s(i,e)))throw new Error(`Invalid param ${String(t)}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var ut=Object.freeze({__proto__:null,bitGet:bitGet,bitLen:bitLen$1,bitMask:bitMask$1,bitSet:bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE:bytesToNumberBE$1,bytesToNumberLE:bytesToNumberLE$1,concatBytes:concatBytes$2,createHmacDrbg:createHmacDrbg$1,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber$1,numberToBytesBE:numberToBytesBE$1,numberToBytesLE:numberToBytesLE$1,numberToHexUnpadded:numberToHexUnpadded$1,numberToVarBytesBE:numberToVarBytesBE,utf8ToBytes:utf8ToBytes$3,validateObject:validateObject});
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$8=BigInt(0),_1n$8=BigInt(1),_2n$4=BigInt(2),_3n$3=BigInt(3),_4n$2=BigInt(4),_5n$1=BigInt(5),_8n$1=BigInt(8);function mod$1(e,t){const n=e%t;return n>=_0n$8?n:t+n}function pow(e,t,n){if(n<=_0n$8||t<_0n$8)throw new Error("Expected power/modulo > 0");if(n===_1n$8)return _0n$8;let r=_1n$8;for(;t>_0n$8;)t&_1n$8&&(r=r*e%n),e=e*e%n,t>>=_1n$8;return r}function pow2$1(e,t,n){let r=e;for(;t-- >_0n$8;)r*=r,r%=n;return r}function invert$1(e,t){if(e===_0n$8||t<=_0n$8)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=mod$1(e,t),r=t,s=_0n$8,i=_1n$8;for(;n!==_0n$8;){const e=r%n,t=s-i*(r/n);r=n,n=e,s=i,i=t}if(r!==_1n$8)throw new Error("invert: does not exist");return mod$1(s,t)}function tonelliShanks$1(e){const t=(e-_1n$8)/_2n$4;let n,r,s;for(n=e-_1n$8,r=0;n%_2n$4===_0n$8;n/=_2n$4,r++);for(s=_2n$4;s(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}function FpPow$1(e,t,n){if(n<_0n$8)throw new Error("Expected power > 0");if(n===_0n$8)return e.ONE;if(n===_1n$8)return t;let r=e.ONE,s=t;for(;n>_0n$8;)n&_1n$8&&(r=e.mul(r,s)),s=e.sqr(s),n>>=_1n$8;return r}function FpInvertBatch$1(e,t){const n=new Array(t.length),r=t.reduce((t,r,s)=>e.is0(r)?t:(n[s]=t,e.mul(t,r)),e.ONE),s=e.inv(r);return t.reduceRight((t,r,s)=>e.is0(r)?t:(n[s]=e.mul(t,n[s]),e.mul(t,r)),s),n}function nLength$1(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Field$1(e,t,n=!1,r={}){if(e<=_0n$8)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:i}=nLength$1(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=FpSqrt$1(e),a=Object.freeze({ORDER:e,BITS:s,BYTES:i,MASK:bitMask$1(s),ZERO:_0n$8,ONE:_1n$8,create:t=>mod$1(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return _0n$8<=t&&te===_0n$8,isOdd:e=>(e&_1n$8)===_1n$8,neg:t=>mod$1(-t,e),eql:(e,t)=>e===t,sqr:t=>mod$1(t*t,e),add:(t,n)=>mod$1(t+n,e),sub:(t,n)=>mod$1(t-n,e),mul:(t,n)=>mod$1(t*n,e),pow:(e,t)=>FpPow$1(a,e,t),div:(t,n)=>mod$1(t*invert$1(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert$1(t,e),sqrt:r.sqrt||(e=>o(a,e)),invertBatch:e=>FpInvertBatch$1(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?numberToBytesLE$1(e,i):numberToBytesBE$1(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?bytesToNumberLE$1(e):bytesToNumberBE$1(e)}});return Object.freeze(a)}function getFieldBytesLength$1(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function getMinHashLength$1(e){const t=getFieldBytesLength$1(e);return t+Math.ceil(t/2)}function mapHashToField$1(e,t,n=!1){const r=e.length,s=getFieldBytesLength$1(t),i=getMinHashLength$1(t);if(r<16||r1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=mod$1(n?bytesToNumberBE$1(e):bytesToNumberLE$1(e),t-_1n$8)+_1n$8;return n?numberToBytesLE$1(o,s):numberToBytesBE$1(o,s)}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$7=BigInt(0),_1n$7=BigInt(1);function wNAF$1(e,t){const n=(e,t)=>{const 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,s=t;for(;n>_0n$7;)n&_1n$7&&(r=r.add(s)),s=s.double(),n>>=_1n$7;return r},precomputeWindow(e,t){const{windows:n,windowSize:s}=r(t),i=[];let o=e,a=o;for(let e=0;e>=h,r>a&&(r-=d,i+=_1n$7);const o=t,p=t+Math.abs(r)-1,f=e%2!=0,g=r<0;0===r?l=l.add(n(f,s[o])):c=c.add(n(g,s[p]))}return{p:c,f:l}},wNAFCached(e,t,n,r){const s=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,s),1!==s&&t.set(e,r(i))),this.wNAF(s,i,n)}}}function validateBasic(e){return validateField$1(e.Fp),validateObject(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength$1(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(e){const t=validateBasic(e);validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER$1={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=DER$1;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:b2n(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=DER$1,n="string"==typeof e?h2b(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:i}=DER$1._parseInt(n.subarray(2)),{d:o,l:a}=DER$1._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),s=t(n(e.r)),i=r.length/2,o=s.length/2,a=n(i),c=n(o);return`30${n(o+i+4)}02${c}${s}02${a}${r}`}},_0n$6=BigInt(0),_1n$6=BigInt(1);BigInt(2);const _3n$2=BigInt(3);function weierstrassPoints(e){const t=validatePointOpts(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const s=t.toAffine();return concatBytes$2(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),s=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function i(e){const{a:r,b:s}=t,i=n.sqr(e),o=n.mul(i,e);return n.add(n.add(o,n.mul(e,r)),s)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&&_0n$6n.eql(e,n.ZERO);return s(t)&&s(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(s(ensureBytes$1("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 new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const s=n.sqr(r),o=i(e);if(!n.eql(s,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:r,pz:s}=this,{px:i,py:o,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(i,s)),l=n.eql(n.mul(r,a),n.mul(o,s));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,s=n.mul(r,_3n$2),{px:i,py:o,pz:a}=this;let c=n.ZERO,l=n.ZERO,u=n.ZERO,h=n.mul(i,i),p=n.mul(o,o),f=n.mul(a,a),g=n.mul(i,o);return g=n.add(g,g),u=n.mul(i,a),u=n.add(u,u),c=n.mul(e,u),l=n.mul(s,f),l=n.add(c,l),c=n.sub(p,l),l=n.add(p,l),l=n.mul(c,l),c=n.mul(g,c),u=n.mul(s,u),f=n.mul(e,f),g=n.sub(h,f),g=n.mul(e,g),g=n.add(g,u),u=n.add(h,h),h=n.add(u,h),h=n.add(h,f),h=n.mul(h,g),l=n.add(l,h),f=n.mul(o,a),f=n.add(f,f),h=n.mul(f,g),c=n.sub(c,h),u=n.mul(f,p),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);const{px:r,py:s,pz:i}=this,{px:o,py:a,pz:c}=e;let l=n.ZERO,h=n.ZERO,p=n.ZERO;const f=t.a,g=n.mul(t.b,_3n$2);let y=n.mul(r,o),m=n.mul(s,a),b=n.mul(i,c),v=n.add(r,s),w=n.add(o,a);v=n.mul(v,w),w=n.add(y,m),v=n.sub(v,w),w=n.add(r,i);let _=n.add(o,c);return w=n.mul(w,_),_=n.add(y,b),w=n.sub(w,_),_=n.add(s,i),l=n.add(a,c),_=n.mul(_,l),l=n.add(m,b),_=n.sub(_,l),p=n.mul(f,w),l=n.mul(g,b),p=n.add(l,p),l=n.sub(m,p),p=n.add(m,p),h=n.mul(l,p),m=n.add(y,y),m=n.add(m,y),b=n.mul(f,b),w=n.mul(g,w),m=n.add(m,b),b=n.sub(y,b),b=n.mul(f,b),w=n.add(w,b),y=n.mul(m,w),h=n.add(h,y),y=n.mul(_,w),l=n.mul(v,l),l=n.sub(l,y),y=n.mul(v,m),p=n.mul(_,p),p=n.add(p,y),new d(l,h,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,l,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const r=d.ZERO;if(e===_0n$6)return r;if(a(e),e===_1n$6)return this;const{endo:s}=t;if(!s)return p.unsafeLadder(this,e);let{k1neg:i,k1:o,k2neg:c,k2:l}=s.splitScalar(e),u=r,h=r,f=this;for(;o>_0n$6||l>_0n$6;)o&_1n$6&&(u=u.add(f)),l&_1n$6&&(h=h.add(f)),f=f.double(),o>>=_1n$6,l>>=_1n$6;return i&&(u=u.negate()),c&&(h=h.negate()),h=new d(n.mul(h.px,s.beta),h.py,h.pz),u.add(h)}multiply(e){a(e);let r,s,i=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:a,k2:c}=o.splitScalar(i);let{p:l,f:u}=this.wNAF(t),{p:h,f:f}=this.wNAF(c);l=p.constTimeNegate(e,l),h=p.constTimeNegate(a,h),h=new d(n.mul(h.px,o.beta),h.py,h.pz),r=l.add(h),s=u.add(f)}else{const{p:e,f:t}=this.wNAF(i);r=e,s=t}return d.normalizeZ([r,s])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,s=(e,t)=>t!==_0n$6&&t!==_1n$6&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=s(this,t).add(s(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:s}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(s));const o=n.mul(t,e),a=n.mul(r,e),c=n.mul(s,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===_1n$6)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===_1n$6?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return bytesToHex$2(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const h=t.nBitLength,p=wNAF$1(d,t.endo?Math.ceil(h/2):h);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:o}}function validateOpts(e){const t=validateBasic(e);return validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function weierstrass$1(e){const t=validateOpts(e),{Fp:n,n:r}=t,s=n.BYTES+1,i=2*n.BYTES+1;function o(e){return mod$1(e,r)}function a(e){return invert$1(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:d}=weierstrassPoints({...t,toBytes(e,t,r){const s=t.toAffine(),i=n.toBytes(s.x),o=concatBytes$2;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),i):o(Uint8Array.from([4]),i,n.toBytes(s.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==s||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}{const e=bytesToNumberBE$1(o);if(!function(e){return _0n$6bytesToHex$2(numberToBytesBE$1(e,t.nByteLength));function p(e){return e>r>>_1n$6}const f=(e,t,n)=>bytesToNumberBE$1(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=ensureBytes$1("compactSignature",e,2*n),new g(f(e,0,n),f(e,n,2*n))}static fromDER(e){const{r:t,s:n}=DER$1.toSig(ensureBytes$1("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:s,recovery:i}=this,l=v(ensureBytes$1("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?r+t.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&i?"03":"02",p=c.fromHex(d+h(u)),f=a(u),g=o(-l*f),y=o(s*f),m=c.BASE.multiplyAndAddUnsafe(p,g,y);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER$1.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const y={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=getMinHashLength$1(t.n);return mapHashToField$1(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function m(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===s||r===i:n?r===2*s||r===2*i:e instanceof c}const b=t.bits2int||function(e){const n=bytesToNumberBE$1(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},v=t.bits2int_modN||function(e){return o(b(e))},w=bitMask$1(t.nBitLength);function _(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(_0n$6<=e&&ee in s))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:h,prehash:f,extraEntropy:y}=s;null==h&&(h=!0),e=ensureBytes$1("msgHash",e),f&&(e=ensureBytes$1("prehashed msgHash",i(e)));const m=v(e),w=l(r),E=[_(w),_(m)];if(null!=y){const e=!0===y?u(n.BYTES):y;E.push(ensureBytes$1("extraEntropy",e))}const $=concatBytes$2(...E),x=m;return{seed:$,k2sig:function(e){const t=b(e);if(!d(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),s=o(r.x);if(s===_0n$6)return;const i=o(n*o(x+s*w));if(i===_0n$6)return;let l=(r.x===s?0:2)|Number(r.y&_1n$6),u=i;return h&&p(i)&&(u=function(e){return p(e)?o(-e):e}(i),l^=1),new g(s,u,l)}}}const k={lowS:t.lowS,prehash:!1},$={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(m(e))throw new Error("first arg must be private key");if(!m(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:s,k2sig:i}=E(e,n,r),o=t;return createHmacDrbg$1(o.hash.outputLen,o.nByteLength,o.hmac)(s,i)},verify:function(e,n,r,s=$){const i=e;if(n=ensureBytes$1("msgHash",n),r=ensureBytes$1("publicKey",r),"strict"in s)throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:u}=s;let d,h;try{if("string"==typeof i||i instanceof Uint8Array)try{d=g.fromDER(i)}catch(e){if(!(e instanceof DER$1.Err))throw e;d=g.fromCompact(i)}else{if("object"!=typeof i||"bigint"!=typeof i.r||"bigint"!=typeof i.s)throw new Error("PARSE");{const{r:e,s:t}=i;d=new g(e,t)}}h=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(l&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:p,s:f}=d,y=v(n),m=a(f),b=o(y*m),w=o(p*m),_=c.BASE.multiplyAndAddUnsafe(h,b,w)?.toAffine();return!!_&&o(_.x)===p},ProjectivePoint:c,Signature:g,utils:y}}BigInt(4);let HMAC$2=class extends Hash$2{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,hash$1(e);const n=toBytes$3(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew HMAC$2(e,t).update(n).digest();
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
-function getHash(e){return{hash:e,hmac:(t,...n)=>hmac$2(e,t,concatBytes$3(...n)),randomBytes:randomBytes$2}}function createCurve$1(e,t){const n=t=>weierstrass$1({...e,...getHash(t)});return Object.freeze({...n(t),create:n})}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */hmac$2.create=(e,t)=>new HMAC$2(e,t);const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$5=BigInt(1),_2n$3=BigInt(2),divNearest$1=(e,t)=>(e+t/_2n$3)/t;function sqrtMod$1(e){const t=secp256k1P,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=pow2$1(u,n,t)*u%t,h=pow2$1(d,n,t)*u%t,p=pow2$1(h,_2n$3,t)*l%t,f=pow2$1(p,s,t)*p%t,g=pow2$1(f,i,t)*f%t,y=pow2$1(g,a,t)*g%t,m=pow2$1(y,c,t)*y%t,b=pow2$1(m,a,t)*g%t,v=pow2$1(b,n,t)*u%t,w=pow2$1(v,o,t)*f%t,_=pow2$1(w,r,t)*l%t,E=pow2$1(_,_2n$3,t);if(!Fp.eql(Fp.sqr(E),e))throw new Error("Cannot find square root");return E}const Fp=Field$1(secp256k1P,void 0,void 0,{sqrt:sqrtMod$1}),secp256k1$1=createCurve$1({a:BigInt(0),b:BigInt(7),Fp:Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=secp256k1N,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-_1n$5*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=divNearest$1(i*e,t),c=divNearest$1(-r*e,t);let l=mod$1(e-a*n-c*s,t),u=mod$1(-a*r-c*i,t);const d=l>o,h=u>o;if(d&&(l=t-l),h&&(u=t-u),l>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:l,k2neg:h,k2:u}}}},sha256$3),_0n$5=BigInt(0),fe=e=>"bigint"==typeof e&&_0n$5"bigint"==typeof e&&_0n$5e.charCodeAt(0)));n=concatBytes$2(t,t),TAGGED_HASH_PREFIXES$1[e]=n}return sha256$3(concatBytes$2(n,...t))}const pointToBytes$1=e=>e.toRawBytes(!0).slice(1),numTo32b=e=>numberToBytesBE$1(e,32),modP=e=>mod$1(e,secp256k1P),modN=e=>mod$1(e,secp256k1N),Point=secp256k1$1.ProjectivePoint,GmulAdd=(e,t,n)=>Point.BASE.multiplyAndAddUnsafe(e,t,n);function schnorrGetExtPubKey$1(e){let t=secp256k1$1.utils.normPrivateKeyToScalar(e),n=Point.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:modN(-t),bytes:pointToBytes$1(n)}}function lift_x$1(e){if(!fe(e))throw new Error("bad x: need 0 < x < p");const t=modP(e*e);let n=sqrtMod$1(modP(t*e+BigInt(7)));n%_2n$3!==_0n$5&&(n=modP(-n));const r=new Point(e,n,_1n$5);return r.assertValidity(),r}function challenge$1(...e){return modN(bytesToNumberBE$1(taggedHash$1("BIP0340/challenge",...e)))}function schnorrGetPublicKey$1(e){return schnorrGetExtPubKey$1(e).bytes}function schnorrSign$1(e,t,n=randomBytes$2(32)){const r=ensureBytes$1("message",e),{bytes:s,scalar:i}=schnorrGetExtPubKey$1(t),o=ensureBytes$1("auxRand",n,32),a=numTo32b(i^bytesToNumberBE$1(taggedHash$1("BIP0340/aux",o))),c=taggedHash$1("BIP0340/nonce",a,s,r),l=modN(bytesToNumberBE$1(c));if(l===_0n$5)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=schnorrGetExtPubKey$1(l),h=challenge$1(u,s,r),p=new Uint8Array(64);if(p.set(u,0),p.set(numTo32b(modN(d+h*i)),32),!schnorrVerify$1(p,r,s))throw new Error("sign: Invalid signature produced");return p}function schnorrVerify$1(e,t,n){const r=ensureBytes$1("signature",e,64),s=ensureBytes$1("message",t),i=ensureBytes$1("publicKey",n,32);try{const e=lift_x$1(bytesToNumberBE$1(i)),t=bytesToNumberBE$1(r.subarray(0,32));if(!fe(t))return!1;const n=bytesToNumberBE$1(r.subarray(32,64));if(!ge(n))return!1;const o=challenge$1(numTo32b(t),pointToBytes$1(e),s),a=GmulAdd(e,n,modN(-o));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch(e){return!1}}const schnorr$1=(()=>({getPublicKey:schnorrGetPublicKey$1,sign:schnorrSign$1,verify:schnorrVerify$1,utils:{randomPrivateKey:secp256k1$1.utils.randomPrivateKey,lift_x:lift_x$1,pointToBytes:pointToBytes$1,numberToBytesBE:numberToBytesBE$1,bytesToNumberBE:bytesToNumberBE$1,taggedHash:taggedHash$1,mod:mod$1}}))(),crypto$1="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a=e=>e instanceof Uint8Array,u32$1=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),createView$2=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$1=(e,t)=>e<<32-t|e>>>t,isLE$1=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$1)throw new Error("Non little-endian hardware is not supported");const hexes$1=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex$1(e){if(!u8a(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!u8a(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}let Hash$1=class{clone(){return this._cloneInto()}};const isPlainObject=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function checkOpts$1(e,t){if(void 0!==t&&("object"!=typeof t||!isPlainObject(t)))throw new Error("Options should be object or undefined");return Object.assign(e,t)}function wrapConstructor(e){const t=t=>e().update(toBytes$2(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$1(e=32){if(crypto$1&&"function"==typeof crypto$1.getRandomValues)return crypto$1.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function number$1(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$1(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes$1(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$1(e.outputLen),number$1(e.blockLen)}function exists$1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$1(e,t){bytes$1(e);const n=t.outputLen;if(e.length>s&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}class SHA2 extends Hash$1{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=createView$2(this.buffer)}update(e){assert.exists(this);const{view:t,buffer:n,blockLen:r}=this,s=(e=toBytes$2(e)).length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let e=i;el.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,Maj$1=(e,t,n)=>e&t^e&n^t&n,SHA256_K$1=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]),IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$1=new Uint32Array(64);let SHA256$1=class extends SHA2{constructor(){super(64,32,8,!1),this.A=0|IV[0],this.B=0|IV[1],this.C=0|IV[2],this.D=0|IV[3],this.E=0|IV[4],this.F=0|IV[5],this.G=0|IV[6],this.H=0|IV[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:i,G:o,H:a}=this;return[e,t,n,r,s,i,o,a]}set(e,t,n,r,s,i,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$1[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$1[e-15],n=SHA256_W$1[e-2],r=rotr$1(t,7)^rotr$1(t,18)^t>>>3,s=rotr$1(n,17)^rotr$1(n,19)^n>>>10;SHA256_W$1[e]=s+SHA256_W$1[e-7]+r+SHA256_W$1[e-16]|0}let{A:n,B:r,C:s,D:i,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$1(o,6)^rotr$1(o,11)^rotr$1(o,25))+Chi$1(o,a,c)+SHA256_K$1[e]+SHA256_W$1[e]|0,u=(rotr$1(n,2)^rotr$1(n,13)^rotr$1(n,22))+Maj$1(n,r,s)|0;l=c,c=a,a=o,o=i+t|0,i=s,s=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,s,i,o,a,c,l)}roundClean(){SHA256_W$1.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class SHA224 extends SHA256$1{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const sha256$2=wrapConstructor(()=>new SHA256$1);
-/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
-function assertNumber(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function chain(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function alphabet(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(assertNumber(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function join(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function padding(e,t="="){if(assertNumber(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function normalize$1(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function convertRadix(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],i=Array.from(e);for(i.forEach(e=>{if(assertNumber(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let s=r;snew SHA224);const gcd=(e,t)=>t?gcd(t,e%t):e,radix2carry=(e,t)=>e+(t-gcd(e,t));function convertRadix2(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(radix2carry(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${radix2carry(t,n)}`);let s=0,i=0;const o=2**n-1,a=[];for(const r of e){if(assertNumber(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(s=s<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)a.push((s>>i-n&o)>>>0);s&=2**i-1}if(s=s<=t)throw new Error("Excess padding");if(!r&&s)throw new Error(`Non-zero padding: ${s}`);return r&&i>0&&a.push(s>>>0),a}function radix(e){return assertNumber(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return convertRadix(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(convertRadix(t,e,256))}}}function radix2(e,t=!1){if(assertNumber(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(radix2carry(8,e)>32||radix2carry(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return convertRadix2(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(convertRadix2(n,e,8,t))}}}function unsafeWrapper(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const base16=chain(radix2(4),alphabet("0123456789ABCDEF"),join("")),base32=chain(radix2(5),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),padding(5),join(""));chain(radix2(5),alphabet("0123456789ABCDEFGHIJKLMNOPQRSTUV"),padding(5),join("")),chain(radix2(5),alphabet("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),join(""),normalize$1(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const base64=chain(radix2(6),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding(6),join("")),base64url=chain(radix2(6),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),padding(6),join("")),genBase58=e=>chain(radix(58),alphabet(e),join("")),base58=genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");genBase58("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),genBase58("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const XMR_BLOCK_LEN=[0,2,3,5,6,7,9,10,11],base58xmr={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=POLYMOD_GENERATORS[e]);return n}function bechChecksum(e,t,n=1){const r=e.length;let s=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);s=bech32Polymod(s)^n>>5}s=bech32Polymod(s);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=(e=r).lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,s),o=e.slice(s+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=BECH_ALPHABET.decode(o).slice(0,-6),c=bechChecksum(i,a,t);if(!o.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const s=e.length+7+n.length;if(!1!==r&&s>r)throw new TypeError(`Length ${s} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${BECH_ALPHABET.encode(n)}${bechChecksum(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:unsafeWrapper(o),fromWords:r,fromWordsUnsafe:i,toWords:s}}const bech32=genBech32("bech32");genBech32("bech32m");const utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex=chain(radix2(4),alphabet("0123456789abcdef"),join(""),normalize$1(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),CODERS={utf8:utf8,hex:hex,base16:base16,base32:base32,base64:base64,base64url:base64url,base58:base58,base58xmr:base58xmr};function number(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function bool(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function isBytes$1(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function bytes(e,...t){if(!isBytes$1(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function exists(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output(e,t){bytes(e);const n=t.outputLen;if(e.lengthnew Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),createView$1=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$1(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$1(e){if("string"==typeof e)e=utf8ToBytes$1(e);else{if(!isBytes$1(e))throw new Error("Uint8Array expected, got "+typeof e);e=e.slice()}return e}function checkOpts(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}function equalBytes(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r(Object.assign(t,e),t);function setBigUint64$1(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}const BLOCK_SIZE=16,POLY=283;function mul2(e){return e<<1^POLY&-(e>>7)}function mul(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=mul2(e);return n}const sbox=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=mul2(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return t})(),invSbox=sbox.map((e,t)=>sbox.indexOf(t)),rotr32_8=e=>e<<24|e>>>8,rotl32_8=e=>e<<8|e>>>24;function genTtable(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(rotl32_8),s=r.map(rotl32_8),i=s.map(rotl32_8),o=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){const u=256*t+l;o[u]=n[t]^r[l],a[u]=s[t]^i[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:s,T3:i,T01:o,T23:a}}const tableEncoding=genTtable(sbox,e=>mul(e,3)<<24|e<<16|e<<8|mul(e,2)),tableDecoding=genTtable(invSbox,e=>mul(e,11)<<24|mul(e,13)<<16|mul(e,9)<<8|mul(e,14)),xPowers=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=mul2(n))e[t]=n;return e})();function expandKeyLE(e){bytes(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=tableEncoding,r=u32(e),s=r.length,i=e=>applySbox(n,e,e,e,e),o=new Uint32Array(t+28);o.set(r);for(let e=s;e6&&e%s===4&&(t=i(t)),o[e]=o[e-s]^t}return o}function expandKeyDecLE(e){const t=expandKeyLE(e),n=t.slice(),r=t.length,{sbox2:s}=tableEncoding,{T0:i,T1:o,T2:a,T3:c}=tableDecoding;for(let e=0;e>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}function apply0123(e,t,n,r,s,i){return e[n<<8&65280|r>>>8&255]^t[s>>>8&65280|i>>>24&255]}function applySbox(e,t,n,r,s){return e[255&t|65280&n]|e[r>>>16&255|s>>>16&65280]<<16}function encrypt$3(e,t,n,r,s){const{sbox2:i,T01:o,T23:a}=tableEncoding;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],s^=e[c++];const l=e.length/4-2;for(let i=0;i16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const s=e.subarray(0,-r);for(let t=0;t{const i=expandKeyLE(e),{b:o,o:a,out:c}=validateBlockEncrypt(n,r,s),l=u32(t);let u=l[0],d=l[1],h=l[2],p=l[3],f=0;for(;f+4<=o.length;)u^=o[f+0],d^=o[f+1],h^=o[f+2],p^=o[f+3],({s0:u,s1:d,s2:h,s3:p}=encrypt$3(i,u,d,h,p)),a[f++]=u,a[f++]=d,a[f++]=h,a[f++]=p;if(r){const e=padPCKS(n.subarray(4*f));u^=e[0],d^=e[1],h^=e[2],p^=e[3],({s0:u,s1:d,s2:h,s3:p}=encrypt$3(i,u,d,h,p)),a[f++]=u,a[f++]=d,a[f++]=h,a[f++]=p}return i.fill(0),c},decrypt:(n,s)=>{validateBlockDecrypt(n);const i=expandKeyDecLE(e),o=u32(t),a=getDst(n.length,s),c=u32(n),l=u32(a);let u=o[0],d=o[1],h=o[2],p=o[3];for(let e=0;e+4<=c.length;){const t=u,n=d,r=h,s=p;u=c[e+0],d=c[e+1],h=c[e+2],p=c[e+3];const{s0:o,s1:a,s2:f,s3:g}=decrypt$3(i,u,d,h,p);l[e++]=o^t,l[e++]=a^n,l[e++]=f^r,l[e++]=g^s}return i.fill(0),validatePCKS(a,r)}}}),u8to16=(e,t)=>255&e[t++]|(255&e[t++])<<8;class Poly1305{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,bytes(e=toBytes$1(e),32);const t=u8to16(e,0),n=u8to16(e,2),r=u8to16(e,4),s=u8to16(e,6),i=u8to16(e,8),o=u8to16(e,10),a=u8to16(e,12),c=u8to16(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|s<<9),this.r[4]=255&(s>>>4|i<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=u8to16(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:s,r:i}=this,o=i[0],a=i[1],c=i[2],l=i[3],u=i[4],d=i[5],h=i[6],p=i[7],f=i[8],g=i[9],y=u8to16(e,t+0),m=u8to16(e,t+2),b=u8to16(e,t+4),v=u8to16(e,t+6),w=u8to16(e,t+8),_=u8to16(e,t+10),E=u8to16(e,t+12),k=u8to16(e,t+14);let $=s[0]+(8191&y),x=s[1]+(8191&(y>>>13|m<<3)),S=s[2]+(8191&(m>>>10|b<<6)),T=s[3]+(8191&(b>>>7|v<<9)),R=s[4]+(8191&(v>>>4|w<<12)),A=s[5]+(w>>>1&8191),N=s[6]+(8191&(w>>>14|_<<2)),C=s[7]+(8191&(_>>>11|E<<5)),I=s[8]+(8191&(E>>>8|k<<8)),B=s[9]+(k>>>5|r),D=0,L=D+$*o+x*(5*g)+S*(5*f)+T*(5*p)+R*(5*h);D=L>>>13,L&=8191,L+=A*(5*d)+N*(5*u)+C*(5*l)+I*(5*c)+B*(5*a),D+=L>>>13,L&=8191;let P=D+$*a+x*o+S*(5*g)+T*(5*f)+R*(5*p);D=P>>>13,P&=8191,P+=A*(5*h)+N*(5*d)+C*(5*u)+I*(5*l)+B*(5*c),D+=P>>>13,P&=8191;let F=D+$*c+x*a+S*o+T*(5*g)+R*(5*f);D=F>>>13,F&=8191,F+=A*(5*p)+N*(5*h)+C*(5*d)+I*(5*u)+B*(5*l),D+=F>>>13,F&=8191;let U=D+$*l+x*c+S*a+T*o+R*(5*g);D=U>>>13,U&=8191,U+=A*(5*f)+N*(5*p)+C*(5*h)+I*(5*d)+B*(5*u),D+=U>>>13,U&=8191;let O=D+$*u+x*l+S*c+T*a+R*o;D=O>>>13,O&=8191,O+=A*(5*g)+N*(5*f)+C*(5*p)+I*(5*h)+B*(5*d),D+=O>>>13,O&=8191;let q=D+$*d+x*u+S*l+T*c+R*a;D=q>>>13,q&=8191,q+=A*o+N*(5*g)+C*(5*f)+I*(5*p)+B*(5*h),D+=q>>>13,q&=8191;let M=D+$*h+x*d+S*u+T*l+R*c;D=M>>>13,M&=8191,M+=A*a+N*o+C*(5*g)+I*(5*f)+B*(5*p),D+=M>>>13,M&=8191;let K=D+$*p+x*h+S*d+T*u+R*l;D=K>>>13,K&=8191,K+=A*c+N*a+C*o+I*(5*g)+B*(5*f),D+=K>>>13,K&=8191;let j=D+$*f+x*p+S*h+T*d+R*u;D=j>>>13,j&=8191,j+=A*l+N*c+C*a+I*o+B*(5*g),D+=j>>>13,j&=8191;let H=D+$*g+x*f+S*p+T*h+R*d;D=H>>>13,H&=8191,H+=A*u+N*l+C*c+I*a+B*o,D+=H>>>13,H&=8191,D=(D<<2)+D|0,D=D+L|0,L=8191&D,D>>>=13,P+=D,s[0]=L,s[1]=P,s[2]=F,s[3]=U,s[4]=O,s[5]=q,s[6]=M,s[7]=K,s[8]=j,s[9]=H}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let s=(1^r)-1;for(let e=0;e<10;e++)n[e]&=s;s=~s;for(let t=0;t<10;t++)e[t]=e[t]&s|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let i=e[0]+t[0];e[0]=65535&i;for(let n=1;n<8;n++)i=(e[n]+t[n]|0)+(i>>>16)|0,e[n]=65535&i}update(e){exists(this);const{buffer:t,blockLen:n}=this,r=(e=toBytes$1(e)).length;for(let s=0;s>>0,e[s++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function wrapConstructorWithKey(e){const t=(t,n)=>e(n).update(toBytes$1(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}const poly1305=wrapConstructorWithKey(e=>new Poly1305(e)),_utf8ToBytes=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),sigma16=_utf8ToBytes("expand 16-byte k"),sigma32=_utf8ToBytes("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32);function rotl$1(e,t){return e<>>32-t}function isAligned32(e){return e.byteOffset%4==0}sigma32_32.slice();const BLOCK_LEN=64,BLOCK_LEN32=16,MAX_COUNTER=2**32-1,U32_EMPTY=new Uint32Array;function runCipher(e,t,n,r,s,i,o,a){const c=s.length,l=new Uint8Array(BLOCK_LEN),u=u32(l),d=isAligned32(s)&&isAligned32(i),h=d?u32(s):U32_EMPTY,p=d?u32(i):U32_EMPTY;for(let f=0;f=MAX_COUNTER)throw new Error("arx: counter overflow");const g=Math.min(BLOCK_LEN,c-f);if(d&&g===BLOCK_LEN){const e=f/4;if(f%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n{bytes(t),bytes(a),bytes(c);const d=c.length;if(l||(l=new Uint8Array(d)),bytes(l),number(u),u<0||u>=MAX_COUNTER)throw new Error("arx: counter overflow");if(l.length0;)h.pop().fill(0);return l}}function chachaCore(e,t,n,r,s,i=20){let o=e[0],a=e[1],c=e[2],l=e[3],u=t[0],d=t[1],h=t[2],p=t[3],f=t[4],g=t[5],y=t[6],m=t[7],b=s,v=n[0],w=n[1],_=n[2],E=o,k=a,$=c,x=l,S=u,T=d,R=h,A=p,N=f,C=g,I=y,B=m,D=b,L=v,P=w,F=_;for(let e=0;e{e.update(t);const n=t.length%16;n&&e.update(ZEROS16.subarray(n))},ZEROS32=new Uint8Array(32);function computeTag(e,t,n,r,s){const i=e(t,n,ZEROS32),o=poly1305.create(i);s&&updatePadded(o,s),updatePadded(o,r);const a=new Uint8Array(16),c=createView$1(a);setBigUint64$1(c,0,BigInt(s?s.length:0),!0),setBigUint64$1(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return i.fill(0),l}const _poly1305_aead=e=>(t,n,r)=>{const s=16;return bytes(t,32),bytes(n),{encrypt:(i,o)=>{const a=i.length,c=a+s;o?bytes(o,c):o=new Uint8Array(c),e(t,n,i,o,1);const l=computeTag(e,t,n,o.subarray(0,-16),r);return o.set(l,a),o},decrypt:(i,o)=>{const a=i.length,c=a-s;if(ar?e.create().update(n).digest():n);for(let e=0;enew HMAC$1(e,t).update(n).digest();function extract(e,t,n){return assert.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),hmac$1(e,toBytes$2(n),toBytes$2(t))}hmac$1.create=(e,t)=>new HMAC$1(e,t);const HKDF_COUNTER=new Uint8Array([0]),EMPTY_BUFFER=new Uint8Array;function expand(e,t,n,r=32){if(assert.hash(e),assert.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(r/e.outputLen);void 0===n&&(n=EMPTY_BUFFER);const i=new Uint8Array(s*e.outputLen),o=hmac$1.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t{for(var n in t)__defProp$1(e,n,{get:t[n],enumerable:!0})},verifiedSymbol=Symbol("verified"),isRecord=e=>e instanceof Object;function validateEvent(e){if(!isRecord(e))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;tQueue$1,QueueNode:()=>QueueNode,binarySearch:()=>binarySearch,bytesToHex:()=>bytesToHex$1,hexToBytes:()=>hexToBytes$1,insertEventIntoAscendingList:()=>insertEventIntoAscendingList,insertEventIntoDescendingList:()=>insertEventIntoDescendingList,normalizeURL:()=>normalizeURL,utf8Decoder:()=>utf8Decoder$1,utf8Encoder:()=>utf8Encoder$1});var utf8Decoder$1=new TextDecoder("utf-8"),utf8Encoder$1=new TextEncoder;function normalizeURL(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function insertEventIntoDescendingList(e,t){const[n,r]=binarySearch(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function insertEventIntoAscendingList(e,t){const[n,r]=binarySearch(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return r||e.splice(n,0,t),e}function binarySearch(e,t){let n=0,r=e.length-1;for(;n<=r;){const s=Math.floor((n+r)/2),i=t(e[s]);if(0===i)return[s,!0];i<0?r=s-1:n=s+1}return[n,!1]}var QueueNode=class{value;next=null;prev=null;constructor(e){this.value=e}},Queue$1=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new QueueNode(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}},JS=class{generateSecretKey(){return schnorr$1.utils.randomPrivateKey()}getPublicKey(e){return bytesToHex$1(schnorr$1.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=bytesToHex$1(schnorr$1.getPublicKey(t)),n.id=getEventHash$1(n),n.sig=bytesToHex$1(schnorr$1.sign(getEventHash$1(n),t)),n[verifiedSymbol]=!0,n}verifyEvent(e){if("boolean"==typeof e[verifiedSymbol])return e[verifiedSymbol];const t=getEventHash$1(e);if(t!==e.id)return e[verifiedSymbol]=!1,!1;try{const n=schnorr$1.verify(e.sig,t,e.pubkey);return e[verifiedSymbol]=n,n}catch(t){return e[verifiedSymbol]=!1,!1}}};function serializeEvent(e){if(!validateEvent(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function getEventHash$1(e){return bytesToHex$1(sha256$2(utf8Encoder$1.encode(serializeEvent(e))))}var i=new JS,generateSecretKey=i.generateSecretKey,getPublicKey=i.getPublicKey,finalizeEvent=i.finalizeEvent,verifyEvent=i.verifyEvent,kinds_exports={};function isRegularKind(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function isReplaceableKind(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function isEphemeralKind(e){return 2e4<=e&&e<3e4}function isAddressableKind(e){return 3e4<=e&&e<4e4}function classifyKind(e){return isRegularKind(e)?"regular":isReplaceableKind(e)?"replaceable":isEphemeralKind(e)?"ephemeral":isAddressableKind(e)?"parameterized":"unknown"}function isKind(e,t){const n=t instanceof Array?t:[t];return validateEvent(e)&&n.includes(e.kind)||!1}__export(kinds_exports,{Application:()=>Application,BadgeAward:()=>BadgeAward,BadgeDefinition:()=>BadgeDefinition,BlockedRelaysList:()=>BlockedRelaysList,BookmarkList:()=>BookmarkList,Bookmarksets:()=>Bookmarksets,Calendar:()=>Calendar,CalendarEventRSVP:()=>CalendarEventRSVP,ChannelCreation:()=>ChannelCreation,ChannelHideMessage:()=>ChannelHideMessage,ChannelMessage:()=>ChannelMessage,ChannelMetadata:()=>ChannelMetadata,ChannelMuteUser:()=>ChannelMuteUser,ClassifiedListing:()=>ClassifiedListing,ClientAuth:()=>ClientAuth,CommunitiesList:()=>CommunitiesList,CommunityDefinition:()=>CommunityDefinition,CommunityPostApproval:()=>CommunityPostApproval,Contacts:()=>Contacts,CreateOrUpdateProduct:()=>CreateOrUpdateProduct,CreateOrUpdateStall:()=>CreateOrUpdateStall,Curationsets:()=>Curationsets,Date:()=>Date2,DirectMessageRelaysList:()=>DirectMessageRelaysList,DraftClassifiedListing:()=>DraftClassifiedListing,DraftLong:()=>DraftLong,Emojisets:()=>Emojisets,EncryptedDirectMessage:()=>EncryptedDirectMessage,EventDeletion:()=>EventDeletion,FileMetadata:()=>FileMetadata,FileServerPreference:()=>FileServerPreference,Followsets:()=>Followsets,GenericRepost:()=>GenericRepost,Genericlists:()=>Genericlists,GiftWrap:()=>GiftWrap,HTTPAuth:()=>HTTPAuth,Handlerinformation:()=>Handlerinformation,Handlerrecommendation:()=>Handlerrecommendation,Highlights:()=>Highlights,InterestsList:()=>InterestsList,Interestsets:()=>Interestsets,JobFeedback:()=>JobFeedback,JobRequest:()=>JobRequest,JobResult:()=>JobResult,Label:()=>Label,LightningPubRPC:()=>LightningPubRPC,LiveChatMessage:()=>LiveChatMessage,LiveEvent:()=>LiveEvent,LongFormArticle:()=>LongFormArticle,Metadata:()=>Metadata,Mutelist:()=>Mutelist,NWCWalletInfo:()=>NWCWalletInfo,NWCWalletRequest:()=>NWCWalletRequest,NWCWalletResponse:()=>NWCWalletResponse,NostrConnect:()=>NostrConnect,OpenTimestamps:()=>OpenTimestamps,Pinlist:()=>Pinlist,PrivateDirectMessage:()=>PrivateDirectMessage,ProblemTracker:()=>ProblemTracker,ProfileBadges:()=>ProfileBadges,PublicChatsList:()=>PublicChatsList,Reaction:()=>Reaction,RecommendRelay:()=>RecommendRelay,RelayList:()=>RelayList,Relaysets:()=>Relaysets,Report:()=>Report,Reporting:()=>Reporting,Repost:()=>Repost,Seal:()=>Seal,SearchRelaysList:()=>SearchRelaysList,ShortTextNote:()=>ShortTextNote,Time:()=>Time,UserEmojiList:()=>UserEmojiList,UserStatuses:()=>UserStatuses,Zap:()=>Zap,ZapGoal:()=>ZapGoal,ZapRequest:()=>ZapRequest,classifyKind:()=>classifyKind,isAddressableKind:()=>isAddressableKind,isEphemeralKind:()=>isEphemeralKind,isKind:()=>isKind,isRegularKind:()=>isRegularKind,isReplaceableKind:()=>isReplaceableKind});var Metadata=0,ShortTextNote=1,RecommendRelay=2,Contacts=3,EncryptedDirectMessage=4,EventDeletion=5,Repost=6,Reaction=7,BadgeAward=8,Seal=13,PrivateDirectMessage=14,GenericRepost=16,ChannelCreation=40,ChannelMetadata=41,ChannelMessage=42,ChannelHideMessage=43,ChannelMuteUser=44,OpenTimestamps=1040,GiftWrap=1059,FileMetadata=1063,LiveChatMessage=1311,ProblemTracker=1971,Report=1984,Reporting=1984,Label=1985,CommunityPostApproval=4550,JobRequest=5999,JobResult=6999,JobFeedback=7e3,ZapGoal=9041,ZapRequest=9734,Zap=9735,Highlights=9802,Mutelist=1e4,Pinlist=10001,RelayList=10002,BookmarkList=10003,CommunitiesList=10004,PublicChatsList=10005,BlockedRelaysList=10006,SearchRelaysList=10007,InterestsList=10015,UserEmojiList=10030,DirectMessageRelaysList=10050,FileServerPreference=10096,NWCWalletInfo=13194,LightningPubRPC=21e3,ClientAuth=22242,NWCWalletRequest=23194,NWCWalletResponse=23195,NostrConnect=24133,HTTPAuth=27235,Followsets=3e4,Genericlists=30001,Relaysets=30002,Bookmarksets=30003,Curationsets=30004,ProfileBadges=30008,BadgeDefinition=30009,Interestsets=30015,CreateOrUpdateStall=30017,CreateOrUpdateProduct=30018,LongFormArticle=30023,DraftLong=30024,Emojisets=30030,Application=30078,LiveEvent=30311,UserStatuses=30315,ClassifiedListing=30402,DraftClassifiedListing=30403,Date2=31922,Time=31923,Calendar=31924,CalendarEventRSVP=31925,Handlerrecommendation=31989,Handlerinformation=31990,CommunityDefinition=34550;function matchFilter(e,t){if(e.ids&&-1===e.ids.indexOf(t.id))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey))return!1;for(let n in e)if("#"===n[0]){let r=e[`#${n.slice(1)}`];if(r&&!t.tags.find(([e,t])=>e===n.slice(1)&&-1!==r.indexOf(t)))return!1}return!(e.since&&t.created_ate.until)}function matchFilters(e,t){for(let n=0;ngetHex64,getInt:()=>getInt,getSubscriptionId:()=>getSubscriptionId,matchEventId:()=>matchEventId,matchEventKind:()=>matchEventKind,matchEventPubkey:()=>matchEventPubkey});var nip42_exports={},_WebSocket,_WebSocket2;function makeAuthEvent(e,t){return{kind:ClientAuth,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}__export(nip42_exports,{makeAuthEvent:()=>makeAuthEvent});try{_WebSocket=WebSocket}catch{}try{_WebSocket2=WebSocket}catch{}var nip19_exports$1={};__export(nip19_exports$1,{BECH32_REGEX:()=>BECH32_REGEX$2,Bech32MaxSize:()=>Bech32MaxSize$2,NostrTypeGuard:()=>NostrTypeGuard$1,decode:()=>decode$1,decodeNostrURI:()=>decodeNostrURI$1,encodeBytes:()=>encodeBytes$2,naddrEncode:()=>naddrEncode$1,neventEncode:()=>neventEncode$1,noteEncode:()=>noteEncode$1,nprofileEncode:()=>nprofileEncode$1,npubEncode:()=>npubEncode$1,nsecEncode:()=>nsecEncode$1});var NostrTypeGuard$1={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},Bech32MaxSize$2=5e3,BECH32_REGEX$2=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function integerToUint8Array$1(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}function decodeNostrURI$1(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),decode$1(e)}catch(e){return{type:"invalid",data:null}}}function decode$1(e){let{prefix:t,words:n}=bech32.decode(e,Bech32MaxSize$2),r=new Uint8Array(bech32.fromWords(n));switch(t){case"nprofile":{let e=parseTLV$1(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:bytesToHex$1(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder$1.decode(e)):[]}}}case"nevent":{let e=parseTLV$1(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:bytesToHex$1(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder$1.decode(e)):[],author:e[2]?.[0]?bytesToHex$1(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(bytesToHex$1(e[3][0]),16):void 0}}}case"naddr":{let e=parseTLV$1(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:utf8Decoder$1.decode(e[0][0]),pubkey:bytesToHex$1(e[2][0]),kind:parseInt(bytesToHex$1(e[3][0]),16),relays:e[1]?e[1].map(e=>utf8Decoder$1.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:bytesToHex$1(r)};default:throw new Error(`unknown prefix ${t}`)}}function parseTLV$1(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],s=n.slice(2,2+r);if(n=n.slice(2+r),s.lengthutf8Encoder$1.encode(e))}))}function neventEncode$1(e){let t;return void 0!==e.kind&&(t=integerToUint8Array$1(e.kind)),encodeBech32$2("nevent",encodeTLV$1({0:[hexToBytes$1(e.id)],1:(e.relays||[]).map(e=>utf8Encoder$1.encode(e)),2:e.author?[hexToBytes$1(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function naddrEncode$1(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),encodeBech32$2("naddr",encodeTLV$1({0:[utf8Encoder$1.encode(e.identifier)],1:(e.relays||[]).map(e=>utf8Encoder$1.encode(e)),2:[hexToBytes$1(e.pubkey)],3:[new Uint8Array(t)]}))}function encodeTLV$1(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),concatBytes$1(...t)}var nip04_exports={};function encrypt$2(e,t,n){const r=e instanceof Uint8Array?bytesToHex$1(e):e,s=getNormalizedX(secp256k1$1.getSharedSecret(r,"02"+t));let i=Uint8Array.from(randomBytes$1(16)),o=utf8Encoder$1.encode(n),a=cbc(s,i).encrypt(o);return`${base64.encode(new Uint8Array(a))}?iv=${base64.encode(new Uint8Array(i.buffer))}`}function decrypt$2(e,t,n){const r=e instanceof Uint8Array?bytesToHex$1(e):e;let[s,i]=n.split("?iv="),o=getNormalizedX(secp256k1$1.getSharedSecret(r,"02"+t)),a=base64.decode(i),c=base64.decode(s),l=cbc(o,a).decrypt(c);return utf8Decoder$1.decode(l)}function getNormalizedX(e){return e.slice(1,33)}__export(nip04_exports,{decrypt:()=>decrypt$2,encrypt:()=>encrypt$2});var nip05_exports={};__export(nip05_exports,{NIP05_REGEX:()=>NIP05_REGEX$1,isNip05:()=>isNip05,isValid:()=>isValid,queryProfile:()=>queryProfile,searchDomain:()=>searchDomain,useFetchImplementation:()=>useFetchImplementation});var NIP05_REGEX$1=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,isNip05=e=>NIP05_REGEX$1.test(e||""),_fetch;try{_fetch=fetch}catch(e){}function useFetchImplementation(e){_fetch=e}async function searchDomain(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await _fetch(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function queryProfile(e){const t=e.match(NIP05_REGEX$1);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await _fetch(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const s=await t.json(),i=s.names[n];return i?{pubkey:i,relays:s.relays?.[i]}:null}catch(e){return null}}async function isValid(e,t){const n=await queryProfile(t);return!!n&&n.pubkey===e}var nip10_exports={};function parse(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let s=e.tags.length-1;s>=0;s--){const i=e.tags[s];if("e"===i[0]&&i[1]){const[e,s,o,a,c]=i,l={id:s,relays:o?[o]:[],author:c};if("root"===a){t.root=l;continue}if("reply"===a){t.reply=l;continue}if("mention"===a){t.mentions.push(l);continue}n?r=l:n=l,t.mentions.push(l);continue}if("q"===i[0]&&i[1]){const[e,n,r]=i;t.quotes.push({id:n,relays:r?[r]:[]})}"p"===i[0]&&i[1]&&t.profiles.push({pubkey:i[1],relays:i[2]?[i[2]]:[]})}return t.root||(t.root=r||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}__export(nip10_exports,{parse:()=>parse});var nip11_exports={},_fetch2;__export(nip11_exports,{fetchRelayInformation:()=>fetchRelayInformation$1,useFetchImplementation:()=>useFetchImplementation2});try{_fetch2=fetch}catch{}function useFetchImplementation2(e){_fetch2=e}async function fetchRelayInformation$1(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var nip13_exports={};function getPow(e){let t=0;for(let n=0;n<64;n+=8){const r=parseInt(e.substring(n,n+8),16);if(0!==r){t+=Math.clz32(r);break}t+=32}return t}function minePow(e,t){let n=0;const r=e,s=["nonce",n.toString(),t.toString()];for(r.tags.push(s);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),s[1]=(++n).toString(),r.id=fastEventHash(r),getPow(r.id)>=t)break}return r}function fastEventHash(e){return bytesToHex$1(sha256$2(utf8Encoder$1.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}__export(nip13_exports,{fastEventHash:()=>fastEventHash,getPow:()=>getPow,minePow:()=>minePow});var nip17_exports={};__export(nip17_exports,{unwrapEvent:()=>unwrapEvent2,unwrapManyEvents:()=>unwrapManyEvents2,wrapEvent:()=>wrapEvent2,wrapManyEvents:()=>wrapManyEvents2});var nip59_exports={};__export(nip59_exports,{createRumor:()=>createRumor,createSeal:()=>createSeal,createWrap:()=>createWrap,unwrapEvent:()=>unwrapEvent,unwrapManyEvents:()=>unwrapManyEvents,wrapEvent:()=>wrapEvent$1,wrapManyEvents:()=>wrapManyEvents});var nip44_exports={};__export(nip44_exports,{decrypt:()=>decrypt2,encrypt:()=>encrypt2,getConversationKey:()=>getConversationKey,v2:()=>v2});var minPlaintextSize=1,maxPlaintextSize=65535;function getConversationKey(e,t){const n=secp256k1$1.getSharedSecret(e,"02"+t).subarray(1,33);return extract(sha256$2,n,"nip44-v2")}function getMessageKeys(e,t){const n=expand(sha256$2,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function calcPaddedLen(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<maxPlaintextSize)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}function pad(e){const t=utf8Encoder$1.encode(e),n=t.length;return concatBytes$1(writeU16BE(n),t,new Uint8Array(calcPaddedLen(n)-n))}function unpad(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(tmaxPlaintextSize||n.length!==t||e.length!==2+calcPaddedLen(t))throw new Error("invalid padding");return utf8Decoder$1.decode(n)}function hmacAad(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=concatBytes$1(n,t);return hmac$1(sha256$2,e,r)}function decodePayload(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=base64.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const s=n[0];if(2!==s)throw new Error("unknown encryption version "+s);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function encrypt2(e,t,n=randomBytes$1(32)){const{chacha_key:r,chacha_nonce:s,hmac_key:i}=getMessageKeys(t,n),o=pad(e),a=chacha20(r,s,o),c=hmacAad(i,a,n);return base64.encode(concatBytes$1(new Uint8Array([2]),n,a,c))}function decrypt2(e,t){const{nonce:n,ciphertext:r,mac:s}=decodePayload(e),{chacha_key:i,chacha_nonce:o,hmac_key:a}=getMessageKeys(t,n);if(!equalBytes(hmacAad(a,r,n),s))throw new Error("invalid MAC");return unpad(chacha20(i,o,r))}var v2={utils:{getConversationKey:getConversationKey,calcPaddedLen:calcPaddedLen},encrypt:encrypt2,decrypt:decrypt2},TWO_DAYS=172800,now=()=>Math.round(Date.now()/1e3),randomNow=()=>Math.round(now()-Math.random()*TWO_DAYS),nip44ConversationKey=(e,t)=>getConversationKey(e,t),nip44Encrypt=(e,t,n)=>encrypt2(JSON.stringify(e),nip44ConversationKey(t,n)),nip44Decrypt=(e,t)=>JSON.parse(decrypt2(e.content,nip44ConversationKey(t,e.pubkey)));function createRumor(e,t){const n={created_at:now(),content:"",tags:[],...e,pubkey:getPublicKey(t)};return n.id=getEventHash$1(n),n}function createSeal(e,t,n){return finalizeEvent({kind:Seal,content:nip44Encrypt(e,t,n),created_at:randomNow(),tags:[]},t)}function createWrap(e,t){const n=generateSecretKey();return finalizeEvent({kind:GiftWrap,content:nip44Encrypt(e,n,t),created_at:randomNow(),tags:[["p",t]]},n)}function wrapEvent$1(e,t,n){return createWrap(createSeal(createRumor(e,t),t,n),n)}function wrapManyEvents(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=getPublicKey(t),s=[wrapEvent$1(e,t,r)];return n.forEach(n=>{s.push(wrapEvent$1(e,t,n))}),s}function unwrapEvent(e,t){const n=nip44Decrypt(e,t);return nip44Decrypt(n,t)}function unwrapManyEvents(e,t){let n=[];return e.forEach(e=>{n.push(unwrapEvent(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function createEvent(e,t,n,r){const s={created_at:Math.ceil(Date.now()/1e3),kind:PrivateDirectMessage,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{s.tags.push(t?["p",e,t]:["p",e])}),r&&s.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&s.tags.push(["subject",n]),s}function wrapEvent2(e,t,n,r,s){return wrapEvent$1(createEvent(t,n,r,s),e,t.publicKey)}function wrapManyEvents2(e,t,n,r,s){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:getPublicKey(e)},...t].map(t=>wrapEvent2(e,t,n,r,s))}var unwrapEvent2=unwrapEvent,unwrapManyEvents2=unwrapManyEvents,nip18_exports={};function finishRepostEvent(e,t,n,r){let s;const i=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===ShortTextNote?s=Repost:(s=GenericRepost,i.push(["k",String(t.kind)])),finalizeEvent({kind:s,tags:i,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function getRepostedEventPointer(e){if(![Repost,GenericRepost].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const s=e.tags[r];s.length>=2&&("e"===s[0]&&void 0===t?t=s:"p"===s[0]&&void 0===n&&(n=s))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function getRepostedEvent(e,{skipVerification:t}={}){const n=getRepostedEventPointer(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||verifyEvent(r))?r:void 0}__export(nip18_exports,{finishRepostEvent:()=>finishRepostEvent,getRepostedEvent:()=>getRepostedEvent,getRepostedEventPointer:()=>getRepostedEventPointer});var nip21_exports={};__export(nip21_exports,{NOSTR_URI_REGEX:()=>NOSTR_URI_REGEX,parse:()=>parse2,test:()=>test});var NOSTR_URI_REGEX=new RegExp(`nostr:(${BECH32_REGEX$2.source})`);function test(e){return"string"==typeof e&&new RegExp(`^${NOSTR_URI_REGEX.source}$`).test(e)}function parse2(e){const t=e.match(new RegExp(`^${NOSTR_URI_REGEX.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:decode$1(t[1])}}var nip25_exports={};function finishReactionEvent(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return finalizeEvent({...e,kind:Reaction,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function getReactedEventPointer(e){if(e.kind!==Reaction)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const s=e.tags[r];s.length>=2&&("e"===s[0]&&void 0===t?t=s:"p"===s[0]&&void 0===n&&(n=s))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}__export(nip25_exports,{finishReactionEvent:()=>finishReactionEvent,getReactedEventPointer:()=>getReactedEventPointer});var nip27_exports={};__export(nip27_exports,{parse:()=>parse3});var noCharacter=/\W/m,noURLCharacter=/\W |\W$|$|,| /m;function*parse3(e){const t=e.length;let n=0,r=0;for(;rchannelCreateEvent,channelHideMessageEvent:()=>channelHideMessageEvent,channelMessageEvent:()=>channelMessageEvent,channelMetadataEvent:()=>channelMetadataEvent,channelMuteUserEvent:()=>channelMuteUserEvent});var channelCreateEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelCreation,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},channelMetadataEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelMetadata,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMessageEvent=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),finalizeEvent({kind:ChannelMessage,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},channelHideMessageEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelHideMessage,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMuteUserEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelMuteUser,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)},nip30_exports={};__export(nip30_exports,{EMOJI_SHORTCODE_REGEX:()=>EMOJI_SHORTCODE_REGEX,matchAll:()=>matchAll,regex:()=>regex,replaceAll:()=>replaceAll});var EMOJI_SHORTCODE_REGEX=/:(\w+):/,regex=()=>new RegExp(`\\B${EMOJI_SHORTCODE_REGEX.source}\\B`,"g");function*matchAll(e){const t=e.matchAll(regex());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function replaceAll(e,t){return e.replaceAll(regex(),(e,n)=>t({shortcode:e,name:n}))}var nip39_exports={},_fetch3;__export(nip39_exports,{useFetchImplementation:()=>useFetchImplementation3,validateGithub:()=>validateGithub});try{_fetch3=fetch}catch{}function useFetchImplementation3(e){_fetch3=e}async function validateGithub(e,t,n){try{return await(await _fetch3(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}var nip47_exports={};function parseConnectionString(e){const{host:t,pathname:n,searchParams:r}=new URL(e),s=n||t,i=r.get("relay"),o=r.get("secret");if(!s||!i||!o)throw new Error("invalid connection string");return{pubkey:s,relay:i,secret:o}}async function makeNwcRequestEvent(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},s=encrypt$2(t,e,JSON.stringify(r)),i={kind:NWCWalletRequest,created_at:Math.round(Date.now()/1e3),content:s,tags:[["p",e]]};return finalizeEvent(i,t)}__export(nip47_exports,{makeNwcRequestEvent:()=>makeNwcRequestEvent,parseConnectionString:()=>parseConnectionString});var nip54_exports={};function normalizeIdentifier(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}__export(nip54_exports,{normalizeIdentifier:()=>normalizeIdentifier});var nip57_exports={},_fetch4;__export(nip57_exports,{getSatoshisAmountFromBolt11:()=>getSatoshisAmountFromBolt11,getZapEndpoint:()=>getZapEndpoint,makeZapReceipt:()=>makeZapReceipt,makeZapRequest:()=>makeZapRequest,useFetchImplementation:()=>useFetchImplementation4,validateZapRequest:()=>validateZapRequest});try{_fetch4=fetch}catch{}function useFetchImplementation4(e){_fetch4=e}async function getZapEndpoint(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=bech32.decode(n,1e3),r=bech32.fromWords(e);t=utf8Decoder$1.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let s=await _fetch4(t),i=await s.json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch(e){}return null}function makeZapRequest(e){let t={kind:9734,created_at:Math.round(Date.now()/1e3),content:e.comment||"",tags:[["p","pubkey"in e?e.pubkey:e.event.pubkey],["amount",e.amount.toString()],["relays",...e.relays]]};if("event"in e){if(t.tags.push(["e",e.event.id]),isReplaceableKind(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(isAddressableKind(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(r)}t.tags.push(["k",e.event.kind.toString()])}return t}function validateZapRequest(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!validateEvent(t))return"Zap request is not a valid Nostr event.";if(!verifyEvent(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function makeZapReceipt({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let s=JSON.parse(e),i=s.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),o={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...i,["P",s.pubkey],["bolt11",n],["description",e]]};return t&&o.tags.push(["preimage",t]),o}function getSatoshisAmountFromBolt11(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const s=r[r.length-1],i=s.charCodeAt(0)-"0".charCodeAt(0),o=i>=0&&i<=9;let a=r.length-1;if(o&&a++,a<1)return 0;const c=parseInt(r.substring(0,a));switch(s){case"m":return 1e5*c;case"u":return 100*c;case"n":return c/10;case"p":return c/1e4;default:return 1e8*c}}var nip98_exports={};__export(nip98_exports,{getToken:()=>getToken,hashPayload:()=>hashPayload,unpackEventFromToken:()=>unpackEventFromToken,validateEvent:()=>validateEvent2,validateEventKind:()=>validateEventKind,validateEventMethodTag:()=>validateEventMethodTag,validateEventPayloadTag:()=>validateEventPayloadTag,validateEventTimestamp:()=>validateEventTimestamp,validateEventUrlTag:()=>validateEventUrlTag,validateToken:()=>validateToken});var _authorizationScheme="Nostr ";async function getToken(e,t,n,r=!1,s){const i={kind:HTTPAuth,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};s&&i.tags.push(["payload",hashPayload(s)]);const o=await n(i);return(r?_authorizationScheme:"")+base64.encode(utf8Encoder$1.encode(JSON.stringify(o)))}async function validateToken(e,t,n){const r=await unpackEventFromToken(e).catch(e=>{throw e});return await validateEvent2(r,t,n).catch(e=>{throw e})}async function unpackEventFromToken(e){if(!e)throw new Error("Missing token");e=e.replace(_authorizationScheme,"");const t=utf8Decoder$1.decode(base64.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function validateEventTimestamp(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function validateEventKind(e){return e.kind===HTTPAuth}function validateEventUrlTag(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function validateEventMethodTag(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function hashPayload(e){return bytesToHex$1(sha256$2(utf8Encoder$1.encode(JSON.stringify(e))))}function validateEventPayloadTag(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=hashPayload(t);return n.length>0&&n[1]===r}async function validateEvent2(e,t,n,r){if(!verifyEvent(e))throw new Error("Invalid nostr event, signature invalid");if(!validateEventKind(e))throw new Error("Invalid nostr event, kind invalid");if(!validateEventTimestamp(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!validateEventUrlTag(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!validateEventMethodTag(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!validateEventPayloadTag(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}const crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
-/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function anumber(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function abytes(e,...t){if(!isBytes(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ahash(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");anumber(e.outputLen),anumber(e.blockLen)}function aexists(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function aoutput(e,t){abytes(e);const n=t.outputLen;if(e.length>>t}const hasHexBuiltin=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),hexes=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex(e){if(abytes(e),hasHexBuiltin)return e.toHex();let t="";for(let n=0;n=asciis._0&&e<=asciis._9?e-asciis._0:e>=asciis.A&&e<=asciis.F?e-(asciis.A-10):e>=asciis.a&&e<=asciis.f?e-(asciis.a-10):void 0}function hexToBytes(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(hasHexBuiltin)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,s=0;te().update(toBytes(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes(e=32){if(crypto&&"function"==typeof crypto.getRandomValues)return crypto.getRandomValues(new Uint8Array(e));if(crypto&&"function"==typeof crypto.randomBytes)return Uint8Array.from(crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}function Chi(e,t,n){return e&t^~e&n}function Maj(e,t,n){return e&t^e&n^t&n}class HashMD extends Hash{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){aexists(this),abytes(e=toBytes(e));const{view:t,buffer:n,blockLen:r}=this,s=e.length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let e=i;el.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e>>3,s=rotr(n,17)^rotr(n,19)^n>>>10;SHA256_W[e]=s+SHA256_W[e-7]+r+SHA256_W[e-16]|0}let{A:n,B:r,C:s,D:i,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr(o,6)^rotr(o,11)^rotr(o,25))+Chi(o,a,c)+SHA256_K[e]+SHA256_W[e]|0,u=(rotr(n,2)^rotr(n,13)^rotr(n,22))+Maj(n,r,s)|0;l=c,c=a,a=o,o=i+t|0,i=s,s=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,s,i,o,a,c,l)}roundClean(){clean(SHA256_W)}destroy(){this.set(0,0,0,0,0,0,0,0),clean(this.buffer)}}const sha256$1=createHasher(()=>new SHA256);class HMAC extends Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ahash(e);const n=toBytes(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew HMAC(e,t).update(n).digest();hmac.create=(e,t)=>new HMAC(e,t);
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
-const _0n$4=BigInt(0),_1n$4=BigInt(1);function _abool2(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function _abytes2(e,t,n=""){const r=isBytes(e),s=e?.length,i=void 0!==t;if(!r||i&&s!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(r?`length=${s}`:"type="+typeof e))}return e}function numberToHexUnpadded(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function hexToNumber(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?_0n$4:BigInt("0x"+e)}function bytesToNumberBE(e){return hexToNumber(bytesToHex(e))}function bytesToNumberLE(e){return abytes(e),hexToNumber(bytesToHex(Uint8Array.from(e).reverse()))}function numberToBytesBE(e,t){return hexToBytes(e.toString(16).padStart(2*t,"0"))}function numberToBytesLE(e,t){return numberToBytesBE(e,t).reverse()}function ensureBytes(e,t,n){let r;if("string"==typeof t)try{r=hexToBytes(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!isBytes(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const s=r.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}const isPosBig=e=>"bigint"==typeof e&&_0n$4<=e;function inRange(e,t,n){return isPosBig(e)&&isPosBig(t)&&isPosBig(n)&&t<=e&&e_0n$4;e>>=_1n$4,t+=1);return t}const bitMask=e=>(_1n$4<new Uint8Array(e),s=e=>Uint8Array.of(e);let i=r(e),o=r(e),a=0;const c=()=>{i.fill(1),o.fill(0),a=0},l=(...e)=>n(o,i,...e),u=(e=r(0))=>{o=l(s(0),e),i=l(),0!==e.length&&(o=l(s(1),e),i=l())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(c(),u(e);!(n=t(d()));)u();return c(),n}}function _validateObject(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const s=e[t];if(r&&void 0===s)return;const i=typeof s;if(i!==n||null===s)throw new Error(`param "${t}" is invalid: expected ${n}, got ${i}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}function memoized(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(void 0!==s)return s;const i=e(n,...r);return t.set(n,i),i}}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$3=BigInt(0),_1n$3=BigInt(1),_2n$2=BigInt(2),_3n$1=BigInt(3),_4n$1=BigInt(4),_5n=BigInt(5),_7n=BigInt(7),_8n=BigInt(8),_9n=BigInt(9),_16n=BigInt(16);function mod(e,t){const n=e%t;return n>=_0n$3?n:t+n}function pow2(e,t,n){let r=e;for(;t-- >_0n$3;)r*=r,r%=n;return r}function invert(e,t){if(e===_0n$3)throw new Error("invert: expected non-zero number");if(t<=_0n$3)throw new Error("invert: expected positive modulus, got "+t);let n=mod(e,t),r=t,s=_0n$3,i=_1n$3;for(;n!==_0n$3;){const e=r%n,t=s-i*(r/n);r=n,n=e,s=i,i=t}if(r!==_1n$3)throw new Error("invert: does not exist");return mod(s,t)}function assertIsSquare(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function sqrt3mod4(e,t){const n=(e.ORDER+_1n$3)/_4n$1,r=e.pow(t,n);return assertIsSquare(e,r,t),r}function sqrt5mod8(e,t){const n=(e.ORDER-_5n)/_8n,r=e.mul(t,_2n$2),s=e.pow(r,n),i=e.mul(t,s),o=e.mul(e.mul(i,_2n$2),s),a=e.mul(i,e.sub(o,e.ONE));return assertIsSquare(e,a,t),a}function sqrt9mod16(e){const t=Field(e),n=tonelliShanks(e),r=n(t,t.neg(t.ONE)),s=n(t,r),i=n(t,t.neg(r)),o=(e+_7n)/_16n;return(e,t)=>{let n=e.pow(t,o),a=e.mul(n,r);const c=e.mul(n,s),l=e.mul(n,i),u=e.eql(e.sqr(a),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,a,u),a=e.cmov(l,c,d);const h=e.eql(e.sqr(a),t),p=e.cmov(n,a,h);return assertIsSquare(e,p,t),p}}function tonelliShanks(e){if(e<_3n$1)throw new Error("sqrt is not defined for small field");let t=e-_1n$3,n=0;for(;t%_2n$2===_0n$3;)t/=_2n$2,n++;let r=_2n$2;const s=Field(e);for(;1===FpLegendre(s,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return sqrt3mod4;let i=s.pow(r,t);const o=(t+_1n$3)/_2n$2;return function(e,r){if(e.is0(r))return r;if(1!==FpLegendre(e,r))throw new Error("Cannot find square root");let s=n,a=e.mul(e.ONE,i),c=e.pow(r,t),l=e.pow(r,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===s)throw new Error("Cannot find square root");const r=_1n$3<(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"})),e}function FpPow(e,t,n){if(n<_0n$3)throw new Error("invalid exponent, negatives unsupported");if(n===_0n$3)return e.ONE;if(n===_1n$3)return t;let r=e.ONE,s=t;for(;n>_0n$3;)n&_1n$3&&(r=e.mul(r,s)),s=e.sqr(s),n>>=_1n$3;return r}function FpInvertBatch(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce((t,n,s)=>e.is0(n)?t:(r[s]=t,e.mul(t,n)),e.ONE),i=e.inv(s);return t.reduceRight((t,n,s)=>e.is0(n)?t:(r[s]=e.mul(t,r[s]),e.mul(t,n)),i),r}function FpLegendre(e,t){const n=(e.ORDER-_1n$3)/_2n$2,r=e.pow(t,n),s=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),o=e.eql(r,e.neg(e.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function nLength(e,t){void 0!==t&&anumber(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Field(e,t,n=!1,r={}){if(e<=_0n$3)throw new Error("invalid field: expected ORDER > 0, got "+e);let s,i,o,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(s=e.BITS),e.sqrt&&(i=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),o=e.allowedLengths}else"number"==typeof t&&(s=t),r.sqrt&&(i=r.sqrt);const{nBitLength:c,nByteLength:l}=nLength(e,s);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:bitMask(c),ZERO:_0n$3,ONE:_1n$3,allowedLengths:o,create:t=>mod(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return _0n$3<=t&&te===_0n$3,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&_1n$3)===_1n$3,neg:t=>mod(-t,e),eql:(e,t)=>e===t,sqr:t=>mod(t*t,e),add:(t,n)=>mod(t+n,e),sub:(t,n)=>mod(t-n,e),mul:(t,n)=>mod(t*n,e),pow:(e,t)=>FpPow(d,e,t),div:(t,n)=>mod(t*invert(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert(t,e),sqrt:i||(t=>(u||(u=FpSqrt(e)),u(d,t))),toBytes:e=>n?numberToBytesLE(e,l):numberToBytesBE(e,l),fromBytes:(t,r=!0)=>{if(o){if(!o.includes(t.length)||t.length>l)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+t.length);let s=n?bytesToNumberLE(t):bytesToNumberBE(t);if(a&&(s=mod(s,e)),!r&&!d.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s},invertBatch:e=>FpInvertBatch(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function getFieldBytesLength(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function getMinHashLength(e){const t=getFieldBytesLength(e);return t+Math.ceil(t/2)}function mapHashToField(e,t,n=!1){const r=e.length,s=getFieldBytesLength(t),i=getMinHashLength(t);if(r<16||r1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const o=mod(n?bytesToNumberLE(e):bytesToNumberBE(e),t-_1n$3)+_1n$3;return n?numberToBytesLE(o,s):numberToBytesBE(o,s)}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$2=BigInt(1);function negateCt(e,t){const n=t.negate();return e?n:t}function normalizeZ(e,t){const n=FpInvertBatch(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function validateW(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function calcWOpts(e,t){validateW(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:bitMask(e),maxNumber:n,shiftBy:BigInt(e)}}function calcOffsets(e,t,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:o}=n;let a=Number(e&s),c=e>>o;a>r&&(a-=i,c+=_1n$2);const l=t*r;return{nextN:c,offset:l+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:l}}function validateMSMPoints(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function validateMSMScalars(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}const pointPrecomputes=new WeakMap,pointWindowSizes=new WeakMap;function getW(e){return pointWindowSizes.get(e)||1}function assert0(e){if(e!==_0n$2)throw new Error("invalid wNAF")}class wNAF{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>_0n$2;)t&_1n$2&&(n=n.add(r)),r=r.double(),t>>=_1n$2;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=calcWOpts(t,this.bits),s=[];let i=e,o=i;for(let e=0;e_0n$2||r>_0n$2;)n&_1n$2&&(i=i.add(s)),r&_1n$2&&(o=o.add(s)),s=s.double(),n>>=_1n$2,r>>=_1n$2;return{p1:i,p2:o}}function pippenger(e,t,n,r){validateMSMPoints(n,e),validateMSMScalars(r,t);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,a=bitLen(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=bitMask(c),u=new Array(Number(l)+1).fill(o);let d=o;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){u.fill(o);for(let t=0;t>BigInt(e)&l);u[i]=u[i].add(n[t])}let t=o;for(let e=u.length-1,n=o;e>0;e--)n=n.add(u[e]),t=t.add(n);if(d=d.add(t),0!==e)for(let e=0;e_0n$2))throw new Error(`CURVE.${e} must be positive bigint`)}const s=createField(t.p,n.Fp,r),i=createField(t.n,n.Fn,r),o=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of o)if(!s.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:s,Fn:i}}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const divNearest=(e,t)=>(e+(e>=0?t:-t)/_2n$1)/t;function _splitEndoScalar(e,t,n){const[[r,s],[i,o]]=t,a=divNearest(o*e,n),c=divNearest(-s*e,n);let l=e-a*r-c*i,u=-a*s-c*o;const d=l<_0n$1,h=u<_0n$1;d&&(l=-l),h&&(u=-u);const p=bitMask(Math.ceil(bitLen(n)/2))+_1n$1;if(l<_0n$1||l>=p||u<_0n$1||u>=p)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:h,k2:u}}function validateSigFormat(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function validateSigOpts(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return _abool2(n.lowS,"lowS"),_abool2(n.prehash,"prehash"),void 0!==n.format&&validateSigFormat(n.format),n}class DERErr extends Error{constructor(e=""){super(e)}}const DER={Err:DERErr,_tlv:{encode:(e,t)=>{const{Err:n}=DER;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=numberToHexUnpadded(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?numberToHexUnpadded(s.length/2|128):"";return numberToHexUnpadded(e)+i+s+t},decode(e,t){const{Err:n}=DER;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++];let i=0;if(!!(128&s)){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const o=t.subarray(r,r+e);if(o.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===o[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of o)i=i<<8|e;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const o=t.subarray(r,r+i);if(o.length!==i)throw new n("tlv.decode: wrong value length");return{v:o,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=DER;if(e<_0n$1)throw new t("integer: negative integers are not allowed");let n=numberToHexUnpadded(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=DER;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return bytesToNumberBE(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=DER,s=ensureBytes("signature",e),{v:i,l:o}=r.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,i),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=DER,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},_0n$1=BigInt(0),_1n$1=BigInt(1),_2n$1=BigInt(2),_3n=BigInt(3),_4n=BigInt(4);function _normFnElement(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let s=ensureBytes("private key",t);try{r=e.fromBytes(s)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function weierstrassN(e,t={}){const n=_createCurveFields("weierstrass",e,t),{Fp:r,Fn:s}=n;let i=n.CURVE;const{h:o,n:a}=i;_validateObject(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(i.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=getWLengths(r,s);function u(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const d=t.toBytes||function(e,t,n){const{x:s,y:i}=t.toAffine(),o=r.toBytes(s);if(_abool2(n,"isCompressed"),n){u();return concatBytes(pprefix(!r.isOdd(i)),o)}return concatBytes(Uint8Array.of(4),o,r.toBytes(i))},h=t.fromBytes||function(e){_abytes2(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=l,s=e.length,i=e[0],o=e.subarray(1);if(s!==t||2!==i&&3!==i){if(s===n&&4===i){const e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,2*e));if(!f(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${s}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(o);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=p(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}u();return!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function p(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,i.a)),i.b)}function f(e,t){const n=r.sqr(t),s=p(e);return r.eql(n,s)}if(!f(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(i.a,_3n),_4n),y=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(g,y)))throw new Error("bad curve params: a or b");function m(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof k))throw new Error("ProjectivePoint expected")}function v(e){if(!c||!c.basises)throw new Error("no endo");return _splitEndoScalar(e,c.basises,s.ORDER)}const w=memoized((e,t)=>{const{X:n,Y:s,Z:i}=e;if(r.eql(i,r.ONE))return{x:n,y:s};const o=e.is0();null==t&&(t=o?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(s,t),l=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),_=memoized(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:s}=e.toAffine();if(!r.isValid(n)||!r.isValid(s))throw new Error("bad point: x or y not field elements");if(!f(n,s))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function E(e,t,n,s,i){return n=new k(r.mul(n.X,e),n.Y,n.Z),t=negateCt(s,t),n=negateCt(i,n),t.add(n)}class k{constructor(e,t,n){this.X=m("x",e),this.Y=m("y",t,!0),this.Z=m("z",n),Object.freeze(this)}static CURVE(){return i}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof k)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?k.ZERO:new k(t,n,r.ONE)}static fromBytes(e){const t=k.fromAffine(h(_abytes2(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return k.fromBytes(ensureBytes("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return x.createCache(this,e),t||this.multiply(_3n),this}assertValidity(){_(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){b(e);const{X:t,Y:n,Z:s}=this,{X:i,Y:o,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(i,s)),l=r.eql(r.mul(n,a),r.mul(o,s));return c&&l}negate(){return new k(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=i,n=r.mul(t,_3n),{X:s,Y:o,Z:a}=this;let c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(s,s),h=r.mul(o,o),p=r.mul(a,a),f=r.mul(s,o);return f=r.add(f,f),u=r.mul(s,a),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(h,l),l=r.add(h,l),l=r.mul(c,l),c=r.mul(f,c),u=r.mul(n,u),p=r.mul(e,p),f=r.sub(d,p),f=r.mul(e,f),f=r.add(f,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,f),l=r.add(l,d),p=r.mul(o,a),p=r.add(p,p),d=r.mul(p,f),c=r.sub(c,d),u=r.mul(p,h),u=r.add(u,u),u=r.add(u,u),new k(c,l,u)}add(e){b(e);const{X:t,Y:n,Z:s}=this,{X:o,Y:a,Z:c}=e;let l=r.ZERO,u=r.ZERO,d=r.ZERO;const h=i.a,p=r.mul(i.b,_3n);let f=r.mul(t,o),g=r.mul(n,a),y=r.mul(s,c),m=r.add(t,n),v=r.add(o,a);m=r.mul(m,v),v=r.add(f,g),m=r.sub(m,v),v=r.add(t,s);let w=r.add(o,c);return v=r.mul(v,w),w=r.add(f,y),v=r.sub(v,w),w=r.add(n,s),l=r.add(a,c),w=r.mul(w,l),l=r.add(g,y),w=r.sub(w,l),d=r.mul(h,v),l=r.mul(p,y),d=r.add(l,d),l=r.sub(g,d),d=r.add(g,d),u=r.mul(l,d),g=r.add(f,f),g=r.add(g,f),y=r.mul(h,y),v=r.mul(p,v),g=r.add(g,y),y=r.sub(f,y),y=r.mul(h,y),v=r.add(v,y),f=r.mul(g,v),u=r.add(u,f),f=r.mul(w,v),l=r.mul(m,l),l=r.sub(l,f),f=r.mul(m,g),d=r.mul(w,d),d=r.add(d,f),new k(l,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(k.ZERO)}multiply(e){const{endo:n}=t;if(!s.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,i;const o=e=>x.cached(this,e,e=>normalizeZ(k,e));if(n){const{k1neg:t,k1:s,k2neg:a,k2:c}=v(e),{p:l,f:u}=o(s),{p:d,f:h}=o(c);i=u.add(h),r=E(n.beta,l,d,t,a)}else{const{p:t,f:n}=o(e);r=t,i=n}return normalizeZ(k,[r,i])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!s.isValid(e))throw new Error("invalid scalar: out of range");if(e===_0n$1||r.is0())return k.ZERO;if(e===_1n$1)return r;if(x.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:s,k2neg:i,k2:o}=v(e),{p1:a,p2:c}=mulEndoUnsafe(k,r,s,o);return E(n.beta,a,c,t,i)}return x.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return w(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return o===_1n$1||(e?e(k,this):x.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return o===_1n$1?this:e?e(k,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(e=!0){return _abool2(e,"isCompressed"),this.assertValidity(),d(k,this,e)}toHex(e=!0){return bytesToHex(this.toBytes(e))}toString(){return``}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return normalizeZ(k,e)}static msm(e,t){return pippenger(k,s,e,t)}static fromPrivateKey(e){return k.BASE.multiply(_normFnElement(s,e))}}k.BASE=new k(i.Gx,i.Gy,r.ONE),k.ZERO=new k(r.ZERO,r.ONE,r.ZERO),k.Fp=r,k.Fn=s;const $=s.BITS,x=new wNAF(k,t.endo?Math.ceil($/2):$);return k.BASE.precompute(8),k}function pprefix(e){return Uint8Array.of(e?2:3)}function getWLengths(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ecdh(e,t={}){const{Fn:n}=e,r=t.randomBytes||randomBytes,s=Object.assign(getWLengths(e.Fp,n),{seed:getMinHashLength(n.ORDER)});function i(e){try{return!!_normFnElement(n,e)}catch(e){return!1}}function o(e=r(s.seed)){return mapHashToField(_abytes2(e,s.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(_normFnElement(n,t)).toBytes(r)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:i,publicKeyUncompressed:o}=s;if(n.allowedLengths||r===i)return;const a=ensureBytes("key",t).length;return a===i||a===o}const l={isValidSecretKey:i,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:i}=s;try{const s=t.length;return(!0!==n||s===r)&&((!1!==n||s===i)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:o,isValidPrivateKey:i,randomPrivateKey:o,normPrivateKeyToScalar:e=>_normFnElement(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,s=!0){if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(r))throw new Error("second arg must be public key");const i=_normFnElement(n,t);return e.fromHex(r).multiply(i).toBytes(s)},keygen:function(e){const t=o(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:l,lengths:s})}function ecdsa(e,t,n={}){ahash(t),_validateObject(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||randomBytes,s=n.hmac||((e,...n)=>hmac(t,e,concatBytes(...n))),{Fp:i,Fn:o}=e,{ORDER:a,BITS:c}=o,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:h,lengths:p}=ecdh(e,n),f={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},g="compact";function y(e){return e>a>>_1n$1}function m(e,t){if(!o.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class b{constructor(e,t,n){this.r=m("r",e),this.s=m("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=g){let n;if(function(e,t){validateSigFormat(t);const n=p.signature;_abytes2(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=DER.toSig(_abytes2(e));return new b(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=o.BYTES,s=e.subarray(0,r),i=e.subarray(r,2*r);return new b(o.fromBytes(s),o.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(hexToBytes(e),t)}addRecoveryBit(e){return new b(this.r,this.s,e)}recoverPublicKey(t){const n=i.ORDER,{r:r,s:s,recovery:c}=this;if(null==c||![0,1,2,3].includes(c))throw new Error("recovery id invalid");if(a*_2n$11)throw new Error("recovery id is ambiguous for h>1 curve");const l=2===c||3===c?r+a:r;if(!i.isValid(l))throw new Error("recovery id 2 or 3 invalid");const u=i.toBytes(l),d=e.fromBytes(concatBytes(pprefix(!(1&c)),u)),h=o.inv(l),p=w(ensureBytes("msgHash",t)),f=o.create(-p*h),g=o.create(s*h),y=e.BASE.multiplyUnsafe(f).add(d.multiplyUnsafe(g));if(y.is0())throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return y(this.s)}toBytes(e=g){if(validateSigFormat(e),"der"===e)return hexToBytes(DER.hexFromSig(this));const t=o.toBytes(this.r),n=o.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return concatBytes(Uint8Array.of(this.recovery),t,n)}return concatBytes(t,n)}toHex(e){return bytesToHex(this.toBytes(e))}assertValidity(){}static fromCompact(e){return b.fromBytes(ensureBytes("sig",e),"compact")}static fromDER(e){return b.fromBytes(ensureBytes("sig",e),"der")}normalizeS(){return this.hasHighS()?new b(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bytesToHex(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bytesToHex(this.toBytes("compact"))}}const v=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=bytesToNumberBE(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},w=n.bits2int_modN||function(e){return o.create(v(e))},_=bitMask(c);function E(e){return aInRange("num < 2^"+c,e,_0n$1,_),o.toBytes(e)}function k(e,n){return _abytes2(e,void 0,"message"),n?_abytes2(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:h,lengths:p,Point:e,sign:function(n,i,a={}){n=ensureBytes("message",n);const{seed:c,k2sig:l}=function(t,n,s){if(["recovered","canonical"].some(e=>e in s))throw new Error("sign() legacy options not supported");const{lowS:i,prehash:a,extraEntropy:c}=validateSigOpts(s,f);t=k(t,a);const l=w(t),u=_normFnElement(o,n),d=[E(u),E(l)];if(null!=c&&!1!==c){const e=!0===c?r(p.secretKey):c;d.push(ensureBytes("extraEntropy",e))}const h=concatBytes(...d),g=l;return{seed:h,k2sig:function(t){const n=v(t);if(!o.isValidNot0(n))return;const r=o.inv(n),s=e.BASE.multiply(n).toAffine(),a=o.create(s.x);if(a===_0n$1)return;const c=o.create(r*o.create(g+a*u));if(c===_0n$1)return;let l=(s.x===a?0:2)|Number(s.y&_1n$1),d=c;return i&&y(c)&&(d=o.neg(c),l^=1),new b(a,d,l)}}}(n,i,a);return createHmacDrbg(t.outputLen,o.BYTES,s)(c,l)},verify:function(t,n,r,s={}){const{lowS:i,prehash:a,format:c}=validateSigOpts(s,f);if(r=ensureBytes("publicKey",r),n=k(ensureBytes("message",n),a),"strict"in s)throw new Error("options.strict was renamed to lowS");const l=void 0===c?function(e){let t;const n="string"==typeof e||isBytes(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new b(e.r,e.s);else if(n){try{t=b.fromBytes(ensureBytes("sig",e),"der")}catch(e){if(!(e instanceof DER.Err))throw e}if(!t)try{t=b.fromBytes(ensureBytes("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):b.fromBytes(ensureBytes("sig",t),c);if(!1===l)return!1;try{const t=e.fromBytes(r);if(i&&l.hasHighS())return!1;const{r:s,s:a}=l,c=w(n),u=o.inv(a),d=o.create(c*u),h=o.create(s*u),p=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(h));if(p.is0())return!1;return o.create(p.x)===s}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=validateSigOpts(n,f);return t=k(t,r),b.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:b,hash:t})}function _weierstrass_legacy_opts_to_new(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Field(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function _ecdsa_legacy_opts_to_new(e){const{CURVE:t,curveOpts:n}=_weierstrass_legacy_opts_to_new(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function _ecdsa_new_output_to_legacy(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,nLength(n.Fn.ORDER,n.Fn.BITS))})}function weierstrass(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:s}=_ecdsa_legacy_opts_to_new(e);return _ecdsa_new_output_to_legacy(e,ecdsa(weierstrassN(t,n),r,s))}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function createCurve(e,t){const n=t=>weierstrass({...e,hash:t});return{...n(t),create:n}}
-/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1_CURVE={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},secp256k1_ENDO={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_0n=BigInt(0),_1n=BigInt(1),_2n=BigInt(2);function sqrtMod(e){const t=secp256k1_CURVE.p,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=pow2(u,n,t)*u%t,h=pow2(d,n,t)*u%t,p=pow2(h,_2n,t)*l%t,f=pow2(p,s,t)*p%t,g=pow2(f,i,t)*f%t,y=pow2(g,a,t)*g%t,m=pow2(y,c,t)*y%t,b=pow2(m,a,t)*g%t,v=pow2(b,n,t)*u%t,w=pow2(v,o,t)*f%t,_=pow2(w,r,t)*l%t,E=pow2(_,_2n,t);if(!Fpk1.eql(Fpk1.sqr(E),e))throw new Error("Cannot find square root");return E}const Fpk1=Field(secp256k1_CURVE.p,{sqrt:sqrtMod}),secp256k1=createCurve({...secp256k1_CURVE,Fp:Fpk1,lowS:!0,endo:secp256k1_ENDO},sha256$1),TAGGED_HASH_PREFIXES={};function taggedHash(e,...t){let n=TAGGED_HASH_PREFIXES[e];if(void 0===n){const t=sha256$1(utf8ToBytes(e));n=concatBytes(t,t),TAGGED_HASH_PREFIXES[e]=n}return sha256$1(concatBytes(n,...t))}const pointToBytes=e=>e.toBytes(!0).slice(1),Pointk1=(()=>secp256k1.Point)(),hasEven=e=>e%_2n===_0n;function schnorrGetExtPubKey(e){const{Fn:t,BASE:n}=Pointk1,r=_normFnElement(t,e),s=n.multiply(r);return{scalar:hasEven(s.y)?r:t.neg(r),bytes:pointToBytes(s)}}function lift_x(e){const t=Fpk1;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let s=t.sqrt(r);hasEven(s)||(s=t.neg(s));const i=Pointk1.fromAffine({x:e,y:s});return i.assertValidity(),i}const num=bytesToNumberBE;function challenge(...e){return Pointk1.Fn.create(num(taggedHash("BIP0340/challenge",...e)))}function schnorrGetPublicKey(e){return schnorrGetExtPubKey(e).bytes}function schnorrSign(e,t,n=randomBytes(32)){const{Fn:r}=Pointk1,s=ensureBytes("message",e),{bytes:i,scalar:o}=schnorrGetExtPubKey(t),a=ensureBytes("auxRand",n,32),c=r.toBytes(o^num(taggedHash("BIP0340/aux",a))),l=taggedHash("BIP0340/nonce",c,i,s),{bytes:u,scalar:d}=schnorrGetExtPubKey(l),h=challenge(u,i,s),p=new Uint8Array(64);if(p.set(u,0),p.set(r.toBytes(r.create(d+h*o)),32),!schnorrVerify(p,s,i))throw new Error("sign: Invalid signature produced");return p}function schnorrVerify(e,t,n){const{Fn:r,BASE:s}=Pointk1,i=ensureBytes("signature",e,64),o=ensureBytes("message",t),a=ensureBytes("publicKey",n,32);try{const e=lift_x(num(a)),t=num(i.subarray(0,32));if(!inRange(t,_1n,secp256k1_CURVE.p))return!1;const n=num(i.subarray(32,64));if(!inRange(n,_1n,secp256k1_CURVE.n))return!1;const c=challenge(r.toBytes(t),pointToBytes(e),o),l=s.multiplyUnsafe(n).add(e.multiplyUnsafe(r.neg(c))),{x:u,y:d}=l.toAffine();return!(l.is0()||!hasEven(d)||u!==t)}catch(e){return!1}}const schnorr=(()=>{const e=(e=randomBytes(48))=>mapHashToField(e,secp256k1_CURVE.n);return secp256k1.utils.randomSecretKey,{keygen:function(t){const n=e(t);return{secretKey:n,publicKey:schnorrGetPublicKey(n)}},getPublicKey:schnorrGetPublicKey,sign:schnorrSign,verify:schnorrVerify,Point:Pointk1,utils:{randomSecretKey:e,randomPrivateKey:e,taggedHash:taggedHash,lift_x:lift_x,pointToBytes:pointToBytes,numberToBytesBE:numberToBytesBE,bytesToNumberBE:bytesToNumberBE,mod:mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),sha256=sha256$1;var dist={},LRUCache$1={},LRUCacheNode$1={};Object.defineProperty(LRUCacheNode$1,"__esModule",{value:!0}),LRUCacheNode$1.LRUCacheNode=void 0;class LRUCacheNode{constructor(e,t,n){const{entryExpirationTimeInMS:r=null,next:s=null,prev:i=null,onEntryEvicted:o,onEntryMarkedAsMostRecentlyUsed:a,clone:c,cloneFn:l}=null!=n?n:{};if("number"==typeof r&&(r<=0||Number.isNaN(r)))throw new Error("entryExpirationTimeInMS must either be null (no expiry) or greater than 0");this.clone=null!=c&&c,this.cloneFn=null!=l?l:this.defaultClone,this.key=e,this.internalValue=this.clone?this.cloneFn(t):t,this.created=Date.now(),this.entryExpirationTimeInMS=r,this.next=s,this.prev=i,this.onEntryEvicted=o,this.onEntryMarkedAsMostRecentlyUsed=a}get value(){return this.clone?this.cloneFn(this.internalValue):this.internalValue}get isExpired(){return"number"==typeof this.entryExpirationTimeInMS&&Date.now()-this.created>this.entryExpirationTimeInMS}invokeOnEvicted(){if(this.onEntryEvicted){const{key:e,value:t,isExpired:n}=this;this.onEntryEvicted({key:e,value:t,isExpired:n})}}invokeOnEntryMarkedAsMostRecentlyUsed(){if(this.onEntryMarkedAsMostRecentlyUsed){const{key:e,value:t}=this;this.onEntryMarkedAsMostRecentlyUsed({key:e,value:t})}}defaultClone(e){return"boolean"==typeof e||"string"==typeof e||"number"==typeof e?e:JSON.parse(JSON.stringify(e))}}LRUCacheNode$1.LRUCacheNode=LRUCacheNode,Object.defineProperty(LRUCache$1,"__esModule",{value:!0}),LRUCache$1.LRUCache=void 0;const LRUCacheNode_1=LRUCacheNode$1;class LRUCache{constructor(e){this.lookupTable=new Map,this.head=null,this.tail=null;const{maxSize:t=25,entryExpirationTimeInMS:n=null,onEntryEvicted:r,onEntryMarkedAsMostRecentlyUsed:s,cloneFn:i,clone:o}=null!=e?e:{};if(Number.isNaN(t)||t<=0)throw new Error("maxSize must be greater than 0.");if("number"==typeof n&&(n<=0||Number.isNaN(n)))throw new Error("entryExpirationTimeInMS must either be null (no expiry) or greater than 0");this.maxSizeInternal=t,this.entryExpirationTimeInMS=n,this.onEntryEvicted=r,this.onEntryMarkedAsMostRecentlyUsed=s,this.clone=o,this.cloneFn=i}get size(){return this.cleanCache(),this.lookupTable.size}get remainingSize(){return this.maxSizeInternal-this.size}get newest(){return this.head?this.head.isExpired?(this.removeNodeFromListAndLookupTable(this.head),this.newest):this.mapNodeToEntry(this.head):null}get oldest(){return this.tail?this.tail.isExpired?(this.removeNodeFromListAndLookupTable(this.tail),this.oldest):this.mapNodeToEntry(this.tail):null}get maxSize(){return this.maxSizeInternal}set maxSize(e){if(Number.isNaN(e)||e<=0)throw new Error("maxSize must be greater than 0.");this.maxSizeInternal=e,this.enforceSizeLimit()}set(e,t,n){const r=this.lookupTable.get(e);r&&this.removeNodeFromListAndLookupTable(r);const s=new LRUCacheNode_1.LRUCacheNode(e,t,{entryExpirationTimeInMS:this.entryExpirationTimeInMS,onEntryEvicted:this.onEntryEvicted,onEntryMarkedAsMostRecentlyUsed:this.onEntryMarkedAsMostRecentlyUsed,clone:this.clone,cloneFn:this.cloneFn,...n});return this.setNodeAsHead(s),this.lookupTable.set(e,s),this.enforceSizeLimit(),this}get(e){const t=this.lookupTable.get(e);return t?t.isExpired?(this.removeNodeFromListAndLookupTable(t),null):(this.setNodeAsHead(t),t.value):null}peek(e){const t=this.lookupTable.get(e);return t?t.isExpired?(this.removeNodeFromListAndLookupTable(t),null):t.value:null}delete(e){const t=this.lookupTable.get(e);return!!t&&this.removeNodeFromListAndLookupTable(t)}has(e){const t=this.lookupTable.get(e);return!!t&&(!t.isExpired||(this.removeNodeFromListAndLookupTable(t),!1))}clear(){this.head=null,this.tail=null,this.lookupTable.clear()}find(e){let t=this.head;for(;t;){if(t.isExpired){const e=t.next;this.removeNodeFromListAndLookupTable(t),t=e;continue}const n=this.mapNodeToEntry(t);if(e(n))return this.setNodeAsHead(t),n;t=t.next}return null}forEach(e){let t=this.head,n=0;for(;t;){if(t.isExpired){const e=t.next;this.removeNodeFromListAndLookupTable(t),t=e;continue}e(t.value,t.key,n),t=t.next,n++}}*values(){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield e.value,e=e.next}}*keys(){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield e.key,e=e.next}}*entries(){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield this.mapNodeToEntry(e),e=e.next}}*[Symbol.iterator](){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield this.mapNodeToEntry(e),e=e.next}}enforceSizeLimit(){let e=this.tail;for(;null!==e&&this.size>this.maxSizeInternal;){const t=e.prev;this.removeNodeFromListAndLookupTable(e),e=t}}mapNodeToEntry({key:e,value:t}){return{key:e,value:t}}setNodeAsHead(e){this.removeNodeFromList(e),this.head?(e.next=this.head,this.head.prev=e,this.head=e):(this.head=e,this.tail=e),e.invokeOnEntryMarkedAsMostRecentlyUsed()}removeNodeFromList(e){null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.head===e&&(this.head=e.next),this.tail===e&&(this.tail=e.prev),e.next=null,e.prev=null}removeNodeFromListAndLookupTable(e){return e.invokeOnEvicted(),this.removeNodeFromList(e),this.lookupTable.delete(e.key)}cleanCache(){if(!this.entryExpirationTimeInMS)return;const e=[];for(const t of this.lookupTable.values())t.isExpired&&e.push(t);e.forEach(e=>this.removeNodeFromListAndLookupTable(e))}}function pbkdf2Init(e,t,n,r){assert.hash(e);const s=checkOpts$1({dkLen:32,asyncTick:10},r),{c:i,dkLen:o,asyncTick:a}=s;if(assert.number(i),assert.number(o),assert.number(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=toBytes$2(t),l=toBytes$2(n),u=new Uint8Array(o),d=hmac$1.create(e,c),h=d._cloneInto().update(l);return{c:i,dkLen:o,asyncTick:a,DK:u,PRF:d,PRFSalt:h}}function pbkdf2Output(e,t,n,r,s){return e.destroy(),t.destroy(),r&&r.destroy(),s.fill(0),n}function pbkdf2(e,t,n,r){const{c:s,dkLen:i,DK:o,PRF:a,PRFSalt:c}=pbkdf2Init(e,t,n,r);let l;const u=new Uint8Array(4),d=createView$2(u),h=new Uint8Array(a.outputLen);for(let e=1,t=0;te<>>32-t;function XorAndSalsa(e,t,n,r,s,i){let o=e[t++]^n[r++],a=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],u=e[t++]^n[r++],d=e[t++]^n[r++],h=e[t++]^n[r++],p=e[t++]^n[r++],f=e[t++]^n[r++],g=e[t++]^n[r++],y=e[t++]^n[r++],m=e[t++]^n[r++],b=e[t++]^n[r++],v=e[t++]^n[r++],w=e[t++]^n[r++],_=e[t++]^n[r++],E=o,k=a,$=c,x=l,S=u,T=d,R=h,A=p,N=f,C=g,I=y,B=m,D=b,L=v,P=w,F=_;for(let e=0;e<8;e+=2)S^=rotl(E+D|0,7),N^=rotl(S+E|0,9),D^=rotl(N+S|0,13),E^=rotl(D+N|0,18),C^=rotl(T+k|0,7),L^=rotl(C+T|0,9),k^=rotl(L+C|0,13),T^=rotl(k+L|0,18),P^=rotl(I+R|0,7),$^=rotl(P+I|0,9),R^=rotl($+P|0,13),I^=rotl(R+$|0,18),x^=rotl(F+B|0,7),A^=rotl(x+F|0,9),B^=rotl(A+x|0,13),F^=rotl(B+A|0,18),k^=rotl(E+x|0,7),$^=rotl(k+E|0,9),x^=rotl($+k|0,13),E^=rotl(x+$|0,18),R^=rotl(T+S|0,7),A^=rotl(R+T|0,9),S^=rotl(A+R|0,13),T^=rotl(S+A|0,18),B^=rotl(I+C|0,7),N^=rotl(B+I|0,9),C^=rotl(N+B|0,13),I^=rotl(C+N|0,18),D^=rotl(F+P|0,7),L^=rotl(D+F|0,9),P^=rotl(L+D|0,13),F^=rotl(P+L|0,18);s[i++]=o+E|0,s[i++]=a+k|0,s[i++]=c+$|0,s[i++]=l+x|0,s[i++]=u+S|0,s[i++]=d+T|0,s[i++]=h+R|0,s[i++]=p+A|0,s[i++]=f+N|0,s[i++]=g+C|0,s[i++]=y+I|0,s[i++]=m+B|0,s[i++]=b+D|0,s[i++]=v+L|0,s[i++]=w+P|0,s[i++]=_+F|0}function BlockMix(e,t,n,r,s){let i=r+0,o=r+16*s;for(let r=0;r<16;r++)n[o+r]=e[t+16*(2*s-1)+r];for(let r=0;r0&&(o+=16),XorAndSalsa(n,i,e,t+=16,n,o)}function scryptInit(e,t,n){const r=checkOpts$1({dkLen:32,asyncTick:10,maxmem:1073742848},n),{N:s,r:i,p:o,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=r;if(assert.number(s),assert.number(i),assert.number(o),assert.number(a),assert.number(c),assert.number(l),void 0!==u&&"function"!=typeof u)throw new Error("progressCb should be function");const d=128*i,h=d/4;if(s<=1||s&s-1||s>=2**(d/8)||s>2**32)throw new Error("Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32");if(o<0||o>137438953440/d)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(a<0||a>137438953440)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const p=d*(s+o);if(p>l)throw new Error(`Scrypt: parameters too large, ${p} (128 * r * (N + p)) > ${l} (maxmem)`);const f=pbkdf2(sha256$2,e,t,{c:1,dkLen:d*o}),g=u32$1(f),y=u32$1(new Uint8Array(d*s)),m=u32$1(new Uint8Array(d));let b=()=>{};if(u){const e=2*s*o,t=Math.max(Math.floor(e/1e4),1);let n=0;b=()=>{n++,!u||n%t&&n!==e||u(n/e)}}return{N:s,r:i,p:o,dkLen:a,blockSize32:h,V:y,B32:g,B:f,tmp:m,blockMixCb:b,asyncTick:c}}function scryptOutput(e,t,n,r,s){const i=pbkdf2(sha256$2,e,n,{c:1,dkLen:t});return n.fill(0),r.fill(0),s.fill(0),i}function scrypt(e,t,n){const{N:r,r:s,p:i,dkLen:o,blockSize32:a,V:c,B32:l,B:u,tmp:d,blockMixCb:h}=scryptInit(e,t,n);for(let e=0;e/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},Bech32MaxSize=5e3,BECH32_REGEX$1=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function integerToUint8Array(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}function decodeNostrURI(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),decode(e)}catch(e){return{type:"invalid",data:null}}}function decode(e){let{prefix:t,words:n}=bech32.decode(e,Bech32MaxSize),r=new Uint8Array(bech32.fromWords(n));switch(t){case"nprofile":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:bytesToHex$1(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder.decode(e)):[]}}}case"nevent":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:bytesToHex$1(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder.decode(e)):[],author:e[2]?.[0]?bytesToHex$1(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(bytesToHex$1(e[3][0]),16):void 0}}}case"naddr":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:utf8Decoder.decode(e[0][0]),pubkey:bytesToHex$1(e[2][0]),kind:parseInt(bytesToHex$1(e[3][0]),16),relays:e[1]?e[1].map(e=>utf8Decoder.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:bytesToHex$1(r)};default:throw new Error(`unknown prefix ${t}`)}}function parseTLV(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],s=n.slice(2,2+r);if(n=n.slice(2+r),s.lengthutf8Encoder.encode(e))}))}function neventEncode(e){let t;return void 0!==e.kind&&(t=integerToUint8Array(e.kind)),encodeBech32("nevent",encodeTLV({0:[hexToBytes$1(e.id)],1:(e.relays||[]).map(e=>utf8Encoder.encode(e)),2:e.author?[hexToBytes$1(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function naddrEncode(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),encodeBech32("naddr",encodeTLV({0:[utf8Encoder.encode(e.identifier)],1:(e.relays||[]).map(e=>utf8Encoder.encode(e)),2:[hexToBytes$1(e.pubkey)],3:[new Uint8Array(t)]}))}function encodeTLV(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),concatBytes$1(...t)}var nip19_star=Object.freeze({__proto__:null,BECH32_REGEX:BECH32_REGEX$1,Bech32MaxSize:Bech32MaxSize,NostrTypeGuard:NostrTypeGuard,decode:decode,decodeNostrURI:decodeNostrURI,encodeBytes:encodeBytes,naddrEncode:naddrEncode,neventEncode:neventEncode,noteEncode:noteEncode,nprofileEncode:nprofileEncode,npubEncode:npubEncode,nsecEncode:nsecEncode}),lib={};!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function r(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map(n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function s(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function i(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function o(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let s=0;const i=[],o=Array.from(e);for(o.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let i=s;it?c(t,e%t):e,l=(e,t)=>e+(t-c(e,t));function u(e,n,r,s){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(l(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${l(n,r)}`);let i=0,o=0;const a=2**r-1,c=[];for(const s of e){if(t(s),s>=2**n)throw new Error(`convertRadix2: invalid data word=${s} from=${n}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${n}`);for(o+=n;o>=r;o-=r)c.push((i>>o-r&a)>>>0);i&=2**o-1}if(i=i<=n)throw new Error("Excess padding");if(!s&&i)throw new Error(`Non-zero padding: ${i}`);return s&&o>0&&c.push(i>>>0),c}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(a(t,e,256))}}}function h(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function f(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),s=new Uint8Array(t.length+e);return s.set(t),s.set(r,t.length),s},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),s=n(r).slice(0,e),i=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(h(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),i(6),s("")),e.base64url=n(h(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),i(6),s(""));const g=e=>n(d(58),r(e),s(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const y=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;rn(f(4,e=>t(t(e))),e.base58);const m=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),s("")),b=[996825010,642813549,513874426,1027748829,705979059];function v(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=b[e]);return n}function w(e,t,n=1){const r=e.length;let s=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);s=v(s)^n>>5}s=v(s);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=(e=r).lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,s),o=e.slice(s+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=m.decode(o).slice(0,-6),c=w(i,a,t);if(!o.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const s=e.length+7+n.length;if(!1!==r&&s>r)throw new TypeError(`Length ${s} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${m.encode(n)}${w(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:p(o),fromWords:r,fromWordsUnsafe:i,toWords:s}}e.bech32=_("bech32"),e.bech32m=_("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(h(4),r("0123456789abcdef"),s(""),o(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));const E={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},k=`Invalid encoding type. Available types: ${Object.keys(E).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!E.hasOwnProperty(e))throw new TypeError(k);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return E[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!E.hasOwnProperty(e))throw new TypeError(k);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return E[e].decode(t)},e.bytes=e.stringToBytes}(lib),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const TAGCODES={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(TAGCODES);e{if(t&&"object"==typeof t||"function"==typeof t)for(let s of __getOwnPropNames(t))__hasOwnProp.call(e,s)||s===n||__defProp(e,s,{get:()=>t[s],enumerable:!(r=__getOwnPropDesc(t,s))||r.enumerable});return e},__reExport=(e,t,n)=>(__copyProps(e,t,"default"),n&&__copyProps(n,t,"default"));function getRelaysForSync(e,t,n="write"){if(!e.outboxTracker)return;const r=e.outboxTracker.data.get(t);return r?"write"===n?r.writeRelays:r.readRelays:void 0}async function getWriteRelaysFor(e,t,n="write"){if(e.outboxTracker)return e.outboxTracker.data.has(t)||await e.outboxTracker.trackUsers([t]),getRelaysForSync(e,t,n)}function getTopRelaysForAuthors(e,t){const n=new Map;t.forEach(t=>{const r=getRelaysForSync(e,t);r&&r.forEach(e=>{const t=n.get(e)||0;n.set(e,t+1)})});return Array.from(n.entries()).sort((e,t)=>t[1]-e[1]).map(e=>e[0])}function getAllRelaysForAllPubkeys(e,t,n="read"){const r=new Map,s=new Set;return t.forEach(t=>{const i=getRelaysForSync(e,t,n);i&&i.size>0?(i.forEach(e=>{(r.get(e)||new Set).add(t)}),r.set(t,i)):s.add(t)}),{pubkeysToRelays:r,authorsMissingRelays:s}}function chooseRelayCombinationForPubkeys(e,t,n,{count:r,preferredRelays:s}={}){r??=2,s??=new Set;const i=e.pool,o=i.connectedRelays();o.forEach(e=>{s?.add(e.url)});const a=new Map,{pubkeysToRelays:c,authorsMissingRelays:l}=getAllRelaysForAllPubkeys(e,t,n),u=getTopRelaysForAuthors(e,t),d=(e,t)=>{const n=a.get(t)||[];n.push(e),a.set(t,n)};for(const[e,t]of c.entries()){let n=r;const s=new Set;for(const r of o)t.has(r.url)&&(d(e,r.url),s.add(r.url),n--);for(const r of t)s.has(r)||a.has(r)&&(d(e,r),s.add(r),n--);if(!(n<=0))for(const r of u){if(n<=0)break;s.has(r)||t.has(r)&&(d(e,r),s.add(r),n--)}}for(const e of l)i.permanentAndConnectedRelays().forEach(t=>{const n=a.get(t.url)||[];n.push(e),a.set(t.url,n)});return a}function getRelaysForFilterWithAuthors(e,t,n=2){return chooseRelayCombinationForPubkeys(e,t,"write",{count:n})}function tryNormalizeRelayUrl(e){try{return normalizeRelayUrl(e)}catch{return}}function normalizeRelayUrl(e){let t=normalizeUrl(e,{stripAuthentication:!1,stripWWW:!1,stripHash:!0});return t.endsWith("/")||(t+="/"),t}function normalize(e){const t=new Set;for(const n of e)try{t.add(normalizeRelayUrl(n))}catch{}return Array.from(t)}var DATA_URL_DEFAULT_MIME_TYPE="text/plain",DATA_URL_DEFAULT_CHARSET="us-ascii",testParameter=(e,t)=>t.some(t=>t instanceof RegExp?t.test(e):t===e),supportedProtocols=new Set(["https:","http:","file:"]),hasCustomProtocol=e=>{try{const{protocol:t}=new URL(e);return t.endsWith(":")&&!t.includes(".")&&!supportedProtocols.has(t)}catch{return!1}},normalizeDataURL=(e,{stripHash:t})=>{const n=/^data:(?[^,]*?),(?[^#]*?)(?:#(?.*))?$/.exec(e);if(!n)throw new Error(`Invalid URL: ${e}`);const r=n.groups?.type??"",s=n.groups?.data??"";let i=n.groups?.hash??"";const o=r.split(";");i=t?"":i;let a=!1;"base64"===o[o.length-1]&&(o.pop(),a=!0);const c=o.shift()?.toLowerCase()??"",l=[...o.map(e=>{let[t,n=""]=e.split("=").map(e=>e.trim());return"charset"===t&&(n=n.toLowerCase(),n===DATA_URL_DEFAULT_CHARSET)?"":`${t}${n?`=${n}`:""}`}).filter(Boolean)];return a&&l.push("base64"),(l.length>0||c&&c!==DATA_URL_DEFAULT_MIME_TYPE)&&l.unshift(c),`data:${l.join(";")},${a?s.trim():s}${i?`#${i}`:""}`};function normalizeUrl(e,t={}){if("string"!=typeof(t={defaultProtocol:"http",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,removeExplicitPort:!1,sortQueryParameters:!0,...t}).defaultProtocol||t.defaultProtocol.endsWith(":")||(t.defaultProtocol=`${t.defaultProtocol}:`),e=e.trim(),/^data:/i.test(e))return normalizeDataURL(e,t);if(hasCustomProtocol(e))return e;const n=e.startsWith("//");!n&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));const r=new URL(e);if(r.hostname=r.hostname.toLowerCase(),t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&"https:"===r.protocol&&(r.protocol="http:"),t.forceHttps&&"http:"===r.protocol&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){const e=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let t=0,n="";for(;;){const s=e.exec(r.pathname);if(!s)break;const i=s[0],o=s.index;n+=r.pathname.slice(t,o).replace(/\/{2,}/g,"/"),n+=i,t=o+i.length}n+=r.pathname.slice(t,r.pathname.length).replace(/\/{2,}/g,"/"),r.pathname=n}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(!0===t.removeDirectoryIndex&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let e=r.pathname.split("/");const n=e[e.length-1];testParameter(n,t.removeDirectoryIndex)&&(e=e.slice(0,-1),r.pathname=`${e.slice(1).join("/")}/`)}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(const e of[...r.searchParams.keys()])testParameter(e,t.removeQueryParameters)&&r.searchParams.delete(e);if(Array.isArray(t.keepQueryParameters)||!0!==t.removeQueryParameters||(r.search=""),Array.isArray(t.keepQueryParameters)&&t.keepQueryParameters.length>0)for(const e of[...r.searchParams.keys()])testParameter(e,t.keepQueryParameters)||r.searchParams.delete(e);if(t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,"")),t.removeExplicitPort&&r.port&&(r.port="");const s=e;return e=r.toString(),t.removeSingleSlash||"/"!==r.pathname||s.endsWith("/")||""!==r.hash||(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||"/"===r.pathname)&&""===r.hash&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),n&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var NDKRelayKeepalive=class{constructor(e=3e4,t){this.onSilenceDetected=t,this.timeout=e}lastActivity=Date.now();timer;timeout;isRunning=!1;recordActivity(){this.lastActivity=Date.now(),this.isRunning&&this.resetTimer()}start(){this.isRunning||(this.isRunning=!0,this.lastActivity=Date.now(),this.resetTimer())}stop(){this.isRunning=!1,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}resetTimer(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{const e=Date.now()-this.lastActivity;if(e>=this.timeout)this.onSilenceDetected();else{const t=this.timeout-e;this.timer=setTimeout(()=>{this.onSilenceDetected()},t)}},this.timeout)}};async function probeRelayConnection(e){const t=`probe-${Math.random().toString(36).substring(7)}`;return new Promise(n=>{let r=!1;const s=setTimeout(()=>{r||(r=!0,e.send(["CLOSE",t]),n(!1))},5e3);e.once("message",()=>{r||(r=!0,clearTimeout(s),e.send(["CLOSE",t]),n(!0))}),e.send(["REQ",t,{kinds:[99999],limit:0}])})}var MAX_RECONNECT_ATTEMPTS=5,FLAPPING_THRESHOLD_MS=1e3,NDKRelayConnectivity=class{ndkRelay;ws;_status;timeoutMs;connectedAt;_connectionStats={attempts:0,success:0,durations:[]};debug;netDebug;connectTimeout;reconnectTimeout;ndk;openSubs=new Map;openCountRequests=new Map;openEventPublishes=new Map;serial=0;baseEoseTimeout=4400;keepalive;wsStateMonitor;sleepDetector;lastSleepCheck=Date.now();lastMessageSent=Date.now();wasIdle=!1;constructor(e,t){this.ndkRelay=e,this._status=1;const n=Math.floor(1e3*Math.random());this.debug=this.ndkRelay.debug.extend(`connectivity${n}`),this.ndk=t,this.setupMonitoring()}setupMonitoring(){this.keepalive=new NDKRelayKeepalive(12e4,async()=>{this.debug("Relay silence detected, probing connection");await probeRelayConnection({send:e=>this.send(JSON.stringify(e)),once:(e,t)=>{const n=e=>{try{const r=JSON.parse(e.data);"EOSE"!==r[0]&&"EVENT"!==r[0]&&"NOTICE"!==r[0]||(t(),this.ws?.removeEventListener("message",n))}catch{}};this.ws?.addEventListener("message",n)}})||(this.debug("Probe failed, connection is stale"),this.handleStaleConnection())}),this.wsStateMonitor=setInterval(()=>{5===this._status&&(this.ws&&this.ws.readyState===WebSocket.OPEN||(this.debug("WebSocket died silently, reconnecting"),this.handleStaleConnection()))},5e3),this.sleepDetector=setInterval(()=>{const e=Date.now(),t=e-this.lastSleepCheck;t>15e3&&(this.debug(`Detected possible sleep/wake (${t}ms gap)`),this.handlePossibleWake()),this.lastSleepCheck=e},1e4)}handleStaleConnection(){this._status=1,this.wasIdle=!0,this.onDisconnect()}handlePossibleWake(){this.debug("System wake detected, checking all connections"),this.wasIdle=!0,this._status>=5&&(this.ws&&this.ws.readyState===WebSocket.OPEN?probeRelayConnection({send:e=>this.send(JSON.stringify(e)),once:(e,t)=>{const n=e=>{try{const r=JSON.parse(e.data);"EOSE"!==r[0]&&"EVENT"!==r[0]&&"NOTICE"!==r[0]||(t(),this.ws?.removeEventListener("message",n))}catch{}};this.ws?.addEventListener("message",n)}}).then(e=>{e||this.handleStaleConnection()}):this.handleStaleConnection())}resetReconnectionState(){this.wasIdle=!0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0)}async connect(e,t=!0){if(this.ws&&this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING){this.debug("Cleaning up stale WebSocket connection");try{this.ws.close()}catch(e){}this.ws=void 0,this._status=1}if(2!==this._status&&1!==this._status||this.reconnectTimeout)this.debug("Relay requested to be connected but was in state %s or it had a reconnect timeout",this._status);else{this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),e??=this.timeoutMs,!this.timeoutMs&&e&&(this.timeoutMs=e),this.timeoutMs&&(this.connectTimeout=setTimeout(()=>this.onConnectionError(t),this.timeoutMs));try{this.updateConnectionStats.attempt(),1===this._status?this._status=4:this._status=2,this.ws=new WebSocket(this.ndkRelay.url),this.ws.onopen=this.onConnect.bind(this),this.ws.onclose=this.onDisconnect.bind(this),this.ws.onmessage=this.onMessage.bind(this),this.ws.onerror=this.onError.bind(this)}catch(e){throw this.debug(`Failed to connect to ${this.ndkRelay.url}`,e),this._status=1,t?this.handleReconnection():this.ndkRelay.emit("delayed-connect",1728e5),e}}}disconnect(){this._status=0,this.keepalive?.stop(),this.wsStateMonitor&&(clearInterval(this.wsStateMonitor),this.wsStateMonitor=void 0),this.sleepDetector&&(clearInterval(this.sleepDetector),this.sleepDetector=void 0);try{this.ws?.close()}catch(e){this.debug("Failed to disconnect",e),this._status=1}}onConnectionError(e){this.debug(`Error connecting to ${this.ndkRelay.url}`,this.timeoutMs),e&&!this.reconnectTimeout&&this.handleReconnection()}onConnect(){this.netDebug?.("connected",this.ndkRelay),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),this.updateConnectionStats.connected(),this._status=5,this.keepalive?.start(),this.wasIdle=!1,this.ndkRelay.emit("connect"),this.ndkRelay.emit("ready")}onDisconnect(){this.netDebug?.("disconnected",this.ndkRelay),this.updateConnectionStats.disconnected(),this.keepalive?.stop(),5===this._status&&this.handleReconnection(),this._status=1,this.ndkRelay.emit("disconnect")}onMessage(e){this.netDebug?.(e.data,this.ndkRelay,"recv"),this.keepalive?.recordActivity();try{const t=JSON.parse(e.data),[n,r,...s]=t,i=this.ndkRelay.getProtocolHandler(n);if(i)return void i(this.ndkRelay,t);switch(n){case"EVENT":{const e=this.openSubs.get(r),n=t[2];return e?void e.onevent(n):void this.debug(`Received event for unknown subscription ${r}`)}case"COUNT":{const e=t[2],n=this.openCountRequests.get(r);return void(n&&(n.resolve(e.count),this.openCountRequests.delete(r)))}case"EOSE":{const e=this.openSubs.get(r);if(!e)return;return void e.oneose(r)}case"OK":{const e=t[2],n=t[3],s=this.openEventPublishes.get(r),i=s?.pop();return s&&i?(e?i.resolve(n):i.reject(new Error(n)),void(0===s.length?this.openEventPublishes.delete(r):this.openEventPublishes.set(r,s))):void this.debug("Received OK for unknown event publish",r)}case"CLOSED":{const e=this.openSubs.get(r);if(!e)return;return void e.onclosed(t[2])}case"NOTICE":return void this.onNotice(t[1]);case"AUTH":return void this.onAuthRequested(t[1])}}catch(e){return void this.debug(`Error parsing message from ${this.ndkRelay.url}: ${e.message}`,e?.stack)}}async onAuthRequested(e){const t=this.ndkRelay.authPolicy??this.ndk?.relayAuthDefaultPolicy;if(this.debug("Relay requested authentication",{havePolicy:!!t}),7!==this._status)if(this._status=6,t){if(this._status>=5){let n;this._status=7;try{n=await t(this.ndkRelay,e)}catch(e){this.debug("Authentication policy threw an error",e),n=!1}if(this.debug("Authentication policy returned",!!n),n instanceof NDKEvent||!0===n){n instanceof NDKEvent&&await this.auth(n);const t=async()=>{if(this._status>=5&&this._status<8){const t=new NDKEvent(this.ndk);t.kind=22242,t.tags=[["relay",this.ndkRelay.url],["challenge",e]],await t.sign(),this.auth(t).then(()=>{this._status=8,this.ndkRelay.emit("authed"),this.debug("Authentication successful")}).catch(e=>{this._status=6,this.ndkRelay.emit("auth:failed",e),this.debug("Authentication failed",e)})}else this.debug("Authentication failed, it changed status, status is %d",this._status)};!0===n&&(this.ndk?.signer?t().catch(e=>{console.error("Error authenticating",e)}):(this.debug("No signer available for authentication localhost"),this.ndk?.once("signer:ready",t))),this._status=5,this.ndkRelay.emit("authed")}}}else this.ndkRelay.emit("auth",e);else this.debug("Already authenticating, ignoring")}onError(e){this.debug(`WebSocket error on ${this.ndkRelay.url}:`,e)}get status(){return this._status}isAvailable(){return 5===this._status}isFlapping(){const e=this._connectionStats.durations;if(e.length%3!=0)return!1;const t=e.reduce((e,t)=>e+t,0)/e.length,n=e.map(e=>(e-t)**2).reduce((e,t)=>e+t,0)/e.length;return Math.sqrt(n){this.reconnectTimeout=void 0,this._status=2,this.connect().catch(t=>{e12e4&&(this.wasIdle=!0),this._status>=5&&this.ws?.readyState===WebSocket.OPEN?(this.ws?.send(e),this.netDebug?.(e,this.ndkRelay,"send"),this.lastMessageSent=Date.now()):(this.debug(`Not connected to ${this.ndkRelay.url} (%d), not sending message ${e}`,this._status),this._status>=5&&this.ws?.readyState!==WebSocket.OPEN&&(this.debug(`Stale connection detected, WebSocket state: ${this.ws?.readyState}`),this.handleStaleConnection()))}async auth(e){const t=new Promise((t,n)=>{const r=this.openEventPublishes.get(e.id)??[];r.push({resolve:t,reject:n}),this.openEventPublishes.set(e.id,r)});return this.send(`["AUTH",${JSON.stringify(e.rawEvent())}]`),t}async publish(e){const t=new Promise((t,n)=>{const r=this.openEventPublishes.get(e.id)??[];r.length>0&&console.warn(`Duplicate event publishing detected, you are publishing event ${e.id} twice`),r.push({resolve:t,reject:n}),this.openEventPublishes.set(e.id,r)});return this.send(`["EVENT",${JSON.stringify(e)}]`),t}async count(e,t){this.serial++;const n=t?.id||`count:${this.serial}`,r=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send(`["COUNT","${n}",${JSON.stringify(e).substring(1)}`),r}close(e,t){this.send(`["CLOSE","${e}"]`);const n=this.openSubs.get(e);this.openSubs.delete(e),n&&n.onclose(t)}req(e){this.send(`["REQ","${e.subId}",${JSON.stringify(e.executeFilters).substring(1)}`),this.openSubs.set(e.subId,e)}updateConnectionStats={connected:()=>{this._connectionStats.success++,this._connectionStats.connectedAt=Date.now()},disconnected:()=>{this._connectionStats.connectedAt&&(this._connectionStats.durations.push(Date.now()-this._connectionStats.connectedAt),this._connectionStats.durations.length>100&&this._connectionStats.durations.shift()),this._connectionStats.connectedAt=void 0},attempt:()=>{this._connectionStats.attempts++,this._connectionStats.connectedAt=Date.now()}};get connectionStats(){return this._connectionStats}get url(){return this.ndkRelay.url}get connected(){return this._status>=5&&this.ws?.readyState===WebSocket.OPEN}};async function fetchRelayInformation(e){const t=e.replace(/^wss:\/\//,"https://").replace(/^ws:\/\//,"http://"),n=await fetch(t,{headers:{Accept:"application/nostr+json"}});if(!n.ok)throw new Error(`Failed to fetch relay information: ${n.status} ${n.statusText}`);return await n.json()}var NDKRelayPublisher=class{ndkRelay;debug;constructor(e){this.ndkRelay=e,this.debug=e.debug.extend("publisher")}async publish(e,t=2500){let n;const r=()=>new Promise((t,n)=>{try{this.publishEvent(e).then(n=>{this.ndkRelay.emit("published",e),e.emit("relay:published",this.ndkRelay),t(!0)}).catch(n)}catch(e){n(e)}}),s=new Promise((e,r)=>{n=setTimeout(()=>{n=void 0,r(new Error(`Timeout: ${t}ms`))},t)}),i=()=>{r().then(e=>o(e)).catch(e=>a(e))};let o,a;const c=t=>{throw this.ndkRelay.debug("Publish failed",t,e.id),this.ndkRelay.emit("publish:failed",e,t),e.emit("relay:publish:failed",this.ndkRelay,t),t},l=()=>{n&&clearTimeout(n),this.ndkRelay.removeListener("connect",i)};return this.ndkRelay.status>=5?Promise.race([r(),s]).catch(c).finally(l):(this.ndkRelay.status<=1?(console.warn("Relay is disconnected, trying to connect to publish an event",this.ndkRelay.url),this.ndkRelay.connect()):console.warn("Relay not connected, waiting for connection to publish an event",this.ndkRelay.url),Promise.race([new Promise((e,t)=>{o=e,a=t,this.ndkRelay.on("connect",i)}),s]).catch(c).finally(l))}async publishEvent(e){return this.ndkRelay.connectivity.publish(e.rawEvent())}};function filterFingerprint(e,t){const n=[];for(const t of e){const e=Object.entries(t||{}).map(([e,t])=>["since","until"].includes(e)?`${e}:${t}`:e).sort().join("-");n.push(e)}let r=t?"+":"";return r+=n.join("|"),r}function mergeFilters(e){const t=[],n={};return e.filter(e=>!!e.limit).forEach(e=>t.push(e)),0===(e=e.filter(e=>!e.limit)).length?t:(e.forEach(e=>{Object.entries(e).forEach(([e,t])=>{Array.isArray(t)?void 0===n[e]?n[e]=[...t]:n[e]=Array.from(new Set([...n[e],...t])):n[e]=t})}),[...t,n])}var MAX_ITEMS=3;function formatArray(e,t){const n=(t?e.slice(0,MAX_ITEMS).map(t):e.slice(0,MAX_ITEMS)).join(",");return e.length>MAX_ITEMS?`${n}+${e.length-MAX_ITEMS}`:n}function formatFilters(e){return e.map(e=>{const t=[];e.ids?.length&&t.push(`ids:[${formatArray(e.ids,e=>String(e).slice(0,8))}]`),e.kinds?.length&&t.push(`kinds:[${formatArray(e.kinds)}]`),e.authors?.length&&t.push(`authors:[${formatArray(e.authors,e=>String(e).slice(0,8))}]`),e.since&&t.push(`since:${e.since}`),e.until&&t.push(`until:${e.until}`),e.limit&&t.push(`limit:${e.limit}`),e.search&&t.push(`search:"${String(e.search).slice(0,20)}"`);for(const[n,r]of Object.entries(e))n.startsWith("#")&&Array.isArray(r)&&r.length>0&&t.push(`${n}:[${formatArray(r,e=>String(e).slice(0,8))}]`);return`{${t.join(" ")}}`}).join(", ")}var NDKRelaySubscription=class{fingerprint;items=new Map;topSubManager;debug;status=0;onClose;relay;eosed=!1;executionTimer;fireTime;delayType;executeFilters;id=Math.random().toString(36).substring(7);constructor(e,t,n){this.relay=e,this.topSubManager=n,this.debug=e.debug.extend(`sub[${this.id}]`),this.fingerprint=t||Math.random().toString(36).substring(7)}_subId;get subId(){return this._subId||(this._subId=this.fingerprint.slice(0,15)),this._subId}subIdParts=new Set;addSubIdPart(e){this.subIdParts.add(e)}addItem(e,t){if(this.debug("Adding item",{filters:formatFilters(t),internalId:e.internalId,status:this.status,fingerprint:this.fingerprint,id:this.subId,itemsSize:this.items.size}),!this.items.has(e.internalId))switch(e.on("close",this.removeItem.bind(this,e)),this.items.set(e.internalId,{subscription:e,filters:t}),3!==this.status&&e.subId&&(!this._subId||this._subId.length<48)&&(0!==this.status&&1!==this.status||this.addSubIdPart(e.subId)),this.status){case 0:case 1:this.evaluateExecutionPlan(e);break;case 3:break;case 4:throw this.debug("Subscription is closed, cannot add new items",{filters:formatFilters(t),subId:e.subId,internalId:e.internalId}),new Error("Cannot add new items to a closed subscription")}}removeItem(e){if(this.items.delete(e.internalId),0===this.items.size){if(!this.eosed)return;this.close(),this.cleanup()}}close(){if(4===this.status)return;const e=this.status;if(this.status=4,3===e)try{this.relay.close(this.subId)}catch(e){this.debug("Error closing subscription",e,this)}else this.debug("Subscription wanted to close but it wasn't running, this is probably ok",{subId:this.subId,prevStatus:e,sub:this});this.cleanup()}cleanup(){this.executionTimer&&clearTimeout(this.executionTimer),this.relay.off("ready",this.executeOnRelayReady),this.relay.off("authed",this.reExecuteAfterAuth),this.onClose&&this.onClose(this)}evaluateExecutionPlan(e){if(!e.isGroupable())return this.status=1,void this.execute();if(e.filters.find(e=>!!e.limit)&&(this.executeFilters=this.compileFilters(),this.executeFilters.length>=10))return this.status=1,void this.execute();const t=e.groupableDelay,n=e.groupableDelayType;if(!t)throw new Error("Cannot group a subscription without a delay");if(0===this.status)this.schedule(t,n);else{const e=this.delayType,r=this.fireTime-Date.now();if("at-least"===e&&"at-least"===n)rt&&(this.executionTimer&&clearTimeout(this.executionTimer),this.schedule(t,n));else if("at-most"===e&&"at-most"===n)r>t&&(this.executionTimer&&clearTimeout(this.executionTimer),this.schedule(t,n));else{if("at-most"!==e||"at-least"!==n)throw new Error(`Unknown delay type combination ${e} ${n}`);r>t&&(this.executionTimer&&clearTimeout(this.executionTimer),this.schedule(t,n))}}}schedule(e,t){this.status=1;const n=Date.now();this.fireTime=n+e,this.delayType=t;const r=setTimeout(this.execute.bind(this),e);"at-least"===t&&(this.executionTimer=r)}executeOnRelayReady=()=>{if(2===this.status){if(0===this.items.size)return this.debug("No items to execute; this relay was probably too slow to respond and the caller gave up",{status:this.status,fingerprint:this.fingerprint,id:this.id,subId:this.subId}),void this.cleanup();this.debug("Executing on relay ready",{status:this.status,fingerprint:this.fingerprint,itemsSize:this.items.size,filters:formatFilters(this.compileFilters())}),this.status=1,this.execute()}};finalizeSubId(){this.subIdParts.size>0?this._subId=Array.from(this.subIdParts).join("-"):this._subId=this.fingerprint.slice(0,15),this._subId+=`-${Math.random().toString(36).substring(2,7)}`}reExecuteAfterAuth=(()=>{const e=this.subId;this.debug("Re-executing after auth",this.items.size),this.eosed?this.relay.close(this.subId):this.debug("We are abandoning an opened subscription, once it EOSE's, the handler will close it",{oldSubId:e}),this._subId=void 0,this.status=1,this.execute(),this.debug("Re-executed after auth %s 👉 %s",e,this.subId)}).bind(this);execute(){if(1===this.status){if(!this.relay.connected)return this.status=2,this.debug("Waiting for relay to be ready",{status:this.status,id:this.subId,fingerprint:this.fingerprint,itemsSize:this.items.size}),void this.relay.once("ready",this.executeOnRelayReady);this.relay.status<8&&this.relay.once("authed",this.reExecuteAfterAuth),this.status=3,this.finalizeSubId(),this.executeFilters=this.compileFilters(),this.relay.req(this)}}onstart(){}onevent(e){this.topSubManager.dispatchEvent(e,this.relay)}oneose(e){if(this.eosed=!0,e!==this.subId)return this.debug("Received EOSE for an abandoned subscription",e,this.subId),void this.relay.close(e);0===this.items.size&&this.close();for(const{subscription:e}of this.items.values())e.eoseReceived(this.relay),e.closeOnEose&&(this.debug("Removing item because of EOSE",{filters:formatFilters(e.filters),internalId:e.internalId,status:this.status,fingerprint:this.fingerprint,itemsSize:this.items.size}),this.removeItem(e))}onclose(e){this.status=4}onclosed(e){if(e)for(const{subscription:t}of this.items.values())t.closedReceived(this.relay,e)}compileFilters(){const e=[],t=Array.from(this.items.values()).map(e=>e.filters);if(!t[0])return this.debug("👀 No filters to merge",{itemsSize:this.items.size}),[];const n=t[0].length;for(let r=0;re[r]));e.push(...n)}return e}},NDKRelaySubscriptionManager=class{relay;subscriptions;generalSubManager;constructor(e,t){this.relay=e,this.subscriptions=new Map,this.generalSubManager=t}addSubscription(e,t){let n;if(e.isGroupable()){const r=filterFingerprint(t,e.closeOnEose);if(r){n=(this.subscriptions.get(r)||[]).find(e=>e.status<3)}n??=this.createSubscription(e,t,r)}else n=this.createSubscription(e,t);n.addItem(e,t)}createSubscription(e,t,n){const r=new NDKRelaySubscription(this.relay,n||null,this.generalSubManager);r.onClose=this.onRelaySubscriptionClose.bind(this);const s=this.subscriptions.get(r.fingerprint)??[];return this.subscriptions.set(r.fingerprint,[...s,r]),r}onRelaySubscriptionClose(e){let t=this.subscriptions.get(e.fingerprint)??[];t?1===t.length?this.subscriptions.delete(e.fingerprint):(t=t.filter(t=>t.id!==e.id),this.subscriptions.set(e.fingerprint,t)):console.warn("Unexpectedly did not find a subscription with fingerprint",e.fingerprint)}},NDKRelay=class e extends lib$1.EventEmitter{url;scores;connectivity;subs;publisher;authPolicy;protocolHandlers=new Map;_relayInfo;lowestValidationRatio;targetValidationRatio;validationRatioFn;validatedEventCount=0;nonValidatedEventCount=0;trusted=!1;complaining=!1;debug;static defaultValidationRatioUpdateFn=(e,t,n)=>{if(void 0===e.lowestValidationRatio||void 0===e.targetValidationRatio)return 1;let r=e.validationRatio;if(e.validationRatio>e.targetValidationRatio){const n=t/100;r=Math.max(e.lowestValidationRatio,e.validationRatio-n)}return r0){const e=this.validationRatioFn(this,this.validatedEventCount,this.nonValidatedEventCount);this.targetValidationRatio=e}setTimeout(()=>{this.updateValidationRatio()},3e4)}get status(){return this.connectivity.status}get connectionStats(){return this.connectivity.connectionStats}async connect(e,t=!0){return this.connectivity.connect(e,t)}disconnect(){1!==this.status&&this.connectivity.disconnect()}subscribe(e,t){this.subs.addSubscription(e,t)}async publish(e,t=2500){return this.publisher.publish(e,t)}referenceTags(){return[["r",this.url]]}addValidatedEvent(){this.validatedEventCount++}addNonValidatedEvent(){this.nonValidatedEventCount++}get validationRatio(){return 0===this.nonValidatedEventCount?1:this.validatedEventCount/(this.validatedEventCount+this.nonValidatedEventCount)}shouldValidateEvent(){return!this.trusted&&(void 0===this.targetValidationRatio||(this.targetValidationRatio>=1||Math.random()e.url)}static fromRelayUrls(t,n,r=!0,s){if(!(s=s??n.pool))throw new Error("No pool provided");const i=new Set;for(const e of t){const o=s.relays.get(normalizeRelayUrl(e));if(o)o.status<5&&r&&o.connect(),i.add(o);else{const r=new NDKRelay(normalizeRelayUrl(e),n?.relayAuthDefaultPolicy,n);s.useTemporaryRelay(r,void 0,`requested from fromRelayUrls ${t}`),i.add(r)}}return new e(new Set(i),n,s)}async publish(e,t,n=1){const r=new Set,s=new Map,i=e.isEphemeral();e.publishStatus="pending";const o=e=>{r.add(e)};e.on("relay:published",o);try{const o=Array.from(this.relays).map(n=>new Promise(o=>{const a=t?setTimeout(()=>{r.has(n)||(s.set(n,new Error(`Publish timeout after ${t}ms`)),o(!1))},t):null;n.publish(e,t).then(e=>{a&&clearTimeout(a),e?(r.add(n),o(!0)):o(!1)}).catch(e=>{a&&clearTimeout(a),i||s.set(n,e),o(!1)})}));if(await Promise.all(o),r.size{const n=e.pool?.getRelay(t);n&&r.add(n)});let i=t.tags.filter(e=>["a","e"].includes(e[0])).map(e=>e[2]).filter(e=>e?.startsWith("wss://")).filter(e=>{try{return new URL(e),!0}catch{return!1}}).map(e=>normalizeRelayUrl(e));i=Array.from(new Set(i)).slice(0,5),i.forEach(t=>{const n=e.pool?.getRelay(t,!0,!0);n&&(d("Adding relay hint %s",t),r.add(n))});const o=t.getMatchingTags("p").map(e=>e[1]);if(o.length<5){Array.from(chooseRelayCombinationForPubkeys(e,o,"read",{preferredRelays:new Set(s)}).keys()).forEach(t=>{const n=e.pool?.getRelay(t,!1,!0);n&&(d("Adding p-tagged relay %s",t),r.add(n))})}else d("Too many p-tags to consider %d",o.length);if(e.pool?.permanentAndConnectedRelays().forEach(e=>r.add(e)),n&&r.size!Array.from(r).some(t=>t.url===e)).slice(0,n-r.size);t?.forEach(t=>{const n=e.pool?.getRelay(t,!1,!0);n&&(d("Adding explicit relay %s",t),r.add(n))})}return new NDKRelaySet(r,e)}function calculateRelaySetsFromFilter(e,t,n,r){const s=new Map,i=new Set;if(t.forEach(e=>{e.authors&&e.authors.forEach(e=>i.add(e))}),i.size>0){const n=getRelaysForFilterWithAuthors(e,Array.from(i),r);for(const e of n.keys())s.set(e,[]);for(const e of t)if(e.authors)for(const[t,r]of n.entries()){const n=e.authors.filter(e=>r.includes(e));s.set(t,[...s.get(t),{...e,authors:n}])}else for(const t of n.keys())s.set(t,[...s.get(t),e])}else e.explicitRelayUrls&&e.explicitRelayUrls.forEach(e=>{s.set(e,t)});return 0===s.size&&n.permanentAndConnectedRelays().slice(0,5).forEach(e=>{s.set(e.url,t)}),s}function calculateRelaySetsFromFilters(e,t,n,r){return calculateRelaySetsFromFilter(e,t,n,r)}function checkMissingKind(e,t){void 0!==e.kind&&null!==e.kind||t("event-missing-kind",`Cannot sign event without 'kind'.\n\n📦 Event data:\n • content: ${e.content?`"${e.content.substring(0,50)}${e.content.length>50?"...":""}"`:"(empty)"}\n • tags: ${e.tags.length} tag${1!==e.tags.length?"s":""}\n • kind: ${e.kind} ❌\n\nSet event.kind before signing.`,"Example: event.kind = 1; // for text note",!1)}function checkContentIsObject(e,t){if("object"==typeof e.content){const n=JSON.stringify(e.content,null,2).substring(0,200);t("event-content-is-object",`Event content is an object. Content must be a string.\n\n📦 Your content (${typeof e.content}):\n${n}${JSON.stringify(e.content).length>200?"...":""}\n\n❌ event.content = { ... } // WRONG\n✅ event.content = JSON.stringify({ ... }) // CORRECT`,"Use JSON.stringify() for structured data: event.content = JSON.stringify(data)",!1)}}function checkCreatedAtMilliseconds(e,t){if(e.created_at&&e.created_at>1e10){const n=Math.floor(e.created_at/1e3),r=new Date(e.created_at).toISOString();t("event-created-at-milliseconds",`Event created_at is in milliseconds, not seconds.\n\n📦 Your value:\n • created_at: ${e.created_at} ❌\n • Interpreted as: ${r}\n • Should be: ${n} ✅\n\nNostr timestamps MUST be in seconds since Unix epoch.`,"Use Math.floor(Date.now() / 1000) instead of Date.now()",!1)}}function checkInvalidPTags(e,t){e.getMatchingTags("p").forEach((e,n)=>{if(e[1]&&!/^[0-9a-f]{64}$/i.test(e[1])){const r=JSON.stringify(e);t("tag-invalid-p-tag",`p-tag[${n}] has invalid pubkey.\n\n📦 Your tag:\n ${r}\n\n❌ Invalid value: "${e[1]}"\n • Length: ${e[1].length} (expected 64)\n • Format: ${e[1].startsWith("npub")?"bech32 (npub)":"unknown"}\n\np-tags MUST contain 64-character hex pubkeys.`,e[1].startsWith("npub")?"Use ndkUser.pubkey instead of npub:\n ✅ event.tags.push(['p', ndkUser.pubkey])\n ❌ event.tags.push(['p', 'npub1...'])":"p-tags must contain valid hex pubkeys (64 characters, 0-9a-f)",!1)}})}function checkInvalidETags(e,t){e.getMatchingTags("e").forEach((e,n)=>{if(e[1]&&!/^[0-9a-f]{64}$/i.test(e[1])){const r=JSON.stringify(e),s=e[1].startsWith("note")||e[1].startsWith("nevent");t("tag-invalid-e-tag",`e-tag[${n}] has invalid event ID.\n\n📦 Your tag:\n ${r}\n\n❌ Invalid value: "${e[1]}"\n • Length: ${e[1].length} (expected 64)\n • Format: ${s?"bech32 (note/nevent)":"unknown"}\n\ne-tags MUST contain 64-character hex event IDs.`,s?"Use event.id instead of bech32:\n ✅ event.tags.push(['e', referencedEvent.id])\n ❌ event.tags.push(['e', 'note1...'])":"e-tags must contain valid hex event IDs (64 characters, 0-9a-f)",!1)}})}function checkManualReplyMarkers(e,t,n){if(1!==e.kind)return;if(n.has(e))return;const r=e.tags.filter(e=>"e"===e[0]&&("reply"===e[3]||"root"===e[3]));if(r.length>0){const e=r.map((e,t)=>` ${t+1}. ${JSON.stringify(e)}`).join("\n");t("event-manual-reply-markers",`Event has ${r.length} e-tag(s) with manual reply/root markers.\n\n📦 Your tags with markers:\n${e}\n\n⚠️ Manual reply markers detected! This will cause incorrect threading.`,"Reply events MUST be created using .reply():\n\n ✅ CORRECT:\n const replyEvent = originalEvent.reply();\n replyEvent.content = 'good point!';\n await replyEvent.publish();\n\n ❌ WRONG:\n event.tags.push(['e', eventId, '', 'reply']);\n\nNDK handles all reply threading automatically - never add reply/root markers manually.")}}function signing(e,t,n,r){checkMissingKind(e,t),checkContentIsObject(e,t),checkCreatedAtMilliseconds(e,t),checkInvalidPTags(e,t),checkInvalidETags(e,t),checkManualReplyMarkers(e,n,r)}function isNip33Pattern(e){const t=Array.isArray(e)?e:[e];if(1!==t.length)return!1;const n=t[0];return n.kinds&&Array.isArray(n.kinds)&&1===n.kinds.length&&n.authors&&Array.isArray(n.authors)&&1===n.authors.length&&n["#d"]&&Array.isArray(n["#d"])&&1===n["#d"].length}function isSingleIdLookup(e){const t=Array.isArray(e)?e:[e];if(1!==t.length)return!1;const n=t[0];return n.ids&&Array.isArray(n.ids)&&1===n.ids.length}function isReplaceableEventFilter(e){const t=Array.isArray(e)?e:[e];return 0!==t.length&&t.every(e=>{if(!e.kinds||!Array.isArray(e.kinds)||0===e.kinds.length)return!1;if(!e.authors||!Array.isArray(e.authors)||0===e.authors.length)return!1;return e.kinds.every(e=>0===e||3===e||e>=1e4&&e<=19999)})}function formatFilter(e){return JSON.stringify(e,null,2).split("\n").map((e,t)=>0===t?e:` ${e}`).join("\n")}function fetchingEvents(e,t,n){if("ONLY_CACHE"===t?.cacheUsage)return;const r=Array.isArray(e)?e:[e],s=r.map(formatFilter).join("\n\n ---\n\n ");if(isNip33Pattern(e))r[0],n("fetch-events-usage","For fetching a NIP-33 addressable event, use fetchEvent() with the naddr directly.\n\n📦 Your filter:\n "+s+"\n\n ❌ BAD: const decoded = nip19.decode(naddr);\n const events = await ndk.fetchEvents({\n kinds: [decoded.data.kind],\n authors: [decoded.data.pubkey],\n \"#d\": [decoded.data.identifier]\n });\n const event = Array.from(events)[0];\n\n ✅ GOOD: const event = await ndk.fetchEvent(naddr);\n ✅ GOOD: const event = await ndk.fetchEvent('naddr1...');\n\nfetchEvent() handles naddr decoding automatically and returns the event directly.");else if(isSingleIdLookup(e)){n("fetch-events-usage","For fetching a single event, use fetchEvent() instead.\n\n📦 Your filter:\n "+s+"\n\n💡 Looking for event: "+r[0].ids[0]+"\n\n ❌ BAD: const events = await ndk.fetchEvents({ ids: [eventId] });\n ✅ GOOD: const event = await ndk.fetchEvent(eventId);\n ✅ GOOD: const event = await ndk.fetchEvent('note1...');\n ✅ GOOD: const event = await ndk.fetchEvent('nevent1...');\n\nfetchEvent() is optimized for single event lookups and returns the event directly.")}else{if(isReplaceableEventFilter(e))return;{let e="";const t=r.some(e=>void 0!==e.limit),i=new Set(r.flatMap(e=>e.kinds||[])).size,o=new Set(r.flatMap(e=>e.authors||[])).size;if(t){const t=Math.max(...r.map(e=>e.limit||0));e+=`\n • Limit: ${t} event${1!==t?"s":""}`}i>0&&(e+=`\n • Kinds: ${i} type${1!==i?"s":""}`),o>0&&(e+=`\n • Authors: ${o} author${1!==o?"s":""}`),n("fetch-events-usage","fetchEvents() is a BLOCKING operation that waits for EOSE.\nIn most cases, you should use subscribe() instead.\n\n📦 Your filter"+(r.length>1?"s":"")+":\n "+s+(e?"\n\n📊 Filter analysis:"+e:"")+"\n\n ❌ BAD: const events = await ndk.fetchEvents(filter);\n ✅ GOOD: ndk.subscribe(filter, { onEvent: (e) => ... });\n\nOnly use fetchEvents() when you MUST block until data arrives.","For one-time queries, use fetchEvent() instead of fetchEvents() when expecting a single result.")}}}var GuardrailCheckId={NDK_NO_CACHE:"ndk-no-cache",FILTER_BECH32_IN_ARRAY:"filter-bech32-in-array",FILTER_INVALID_HEX:"filter-invalid-hex",FILTER_ONLY_LIMIT:"filter-only-limit",FILTER_LARGE_LIMIT:"filter-large-limit",FILTER_EMPTY:"filter-empty",FILTER_SINCE_AFTER_UNTIL:"filter-since-after-until",FILTER_INVALID_A_TAG:"filter-invalid-a-tag",FETCH_EVENTS_USAGE:"fetch-events-usage",EVENT_MISSING_KIND:"event-missing-kind",EVENT_PARAM_REPLACEABLE_NO_DTAG:"event-param-replaceable-no-dtag",EVENT_CREATED_AT_MILLISECONDS:"event-created-at-milliseconds",EVENT_NO_NDK_INSTANCE:"event-no-ndk-instance",EVENT_CONTENT_IS_OBJECT:"event-content-is-object",EVENT_MODIFIED_AFTER_SIGNING:"event-modified-after-signing",EVENT_MANUAL_REPLY_MARKERS:"event-manual-reply-markers",TAG_E_FOR_PARAM_REPLACEABLE:"tag-e-for-param-replaceable",TAG_BECH32_VALUE:"tag-bech32-value",TAG_DUPLICATE:"tag-duplicate",TAG_INVALID_P_TAG:"tag-invalid-p-tag",TAG_INVALID_E_TAG:"tag-invalid-e-tag",SUBSCRIBE_NOT_STARTED:"subscribe-not-started",SUBSCRIBE_CLOSE_ON_EOSE_NO_HANDLER:"subscribe-close-on-eose-no-handler",SUBSCRIBE_PASSED_EVENT_NOT_FILTER:"subscribe-passed-event-not-filter",SUBSCRIBE_AWAITED:"subscribe-awaited",RELAY_INVALID_URL:"relay-invalid-url",RELAY_HTTP_INSTEAD_OF_WS:"relay-http-instead-of-ws",RELAY_NO_ERROR_HANDLERS:"relay-no-error-handlers",VALIDATION_PUBKEY_IS_NPUB:"validation-pubkey-is-npub",VALIDATION_PUBKEY_WRONG_LENGTH:"validation-pubkey-wrong-length",VALIDATION_EVENT_ID_IS_BECH32:"validation-event-id-is-bech32",VALIDATION_EVENT_ID_WRONG_LENGTH:"validation-event-id-wrong-length"};function checkCachePresence(e,t){t(GuardrailCheckId.NDK_NO_CACHE)&&setTimeout(()=>{if(!e.cacheAdapter){const e=`\n🤖 AI_GUARDRAILS WARNING: NDK initialized without a cache adapter. Apps perform significantly better with caching.\n\n💡 ${"undefined"!=typeof window?"Consider using @nostr-dev-kit/ndk-cache-dexie or @nostr-dev-kit/ndk-cache-sqlite-wasm":"Consider using @nostr-dev-kit/ndk-cache-redis or @nostr-dev-kit/ndk-cache-sqlite"}\n\n🔇 To disable this check:\n ndk.aiGuardrails.skip('${GuardrailCheckId.NDK_NO_CACHE}')\n or set: ndk.aiGuardrails = { skip: new Set(['${GuardrailCheckId.NDK_NO_CACHE}']) }`;console.warn(e)}},2500)}var AIGuardrails=class{enabled=!1;skipSet=new Set;extensions=new Map;_nextCallDisabled=null;_replyEvents=new WeakSet;constructor(e=!1){this.setMode(e)}register(e,t){this.extensions.has(e)&&console.warn(`AIGuardrails: Extension '${e}' already registered, overwriting`);const n={};for(const[e,r]of Object.entries(t))"function"==typeof r&&(n[e]=(...e)=>{this.enabled&&r(...e,this.shouldCheck.bind(this),this.error.bind(this),this.warn.bind(this))});this.extensions.set(e,n),this[e]=n}setMode(e){"boolean"==typeof e?(this.enabled=e,this.skipSet.clear()):e&&"object"==typeof e&&(this.enabled=!0,this.skipSet=e.skip||new Set)}isEnabled(){return this.enabled}shouldCheck(e){return!!this.enabled&&(!this.skipSet.has(e)&&("all"!==this._nextCallDisabled&&(!this._nextCallDisabled||!this._nextCallDisabled.has(e))))}skip(e){this.skipSet.add(e)}enable(e){this.skipSet.delete(e)}getSkipped(){return Array.from(this.skipSet)}captureAndClearNextCallDisabled(){const e=this._nextCallDisabled;return this._nextCallDisabled=null,e}error(e,t,n,r=!0){if(!this.shouldCheck(e))return;const s=this.formatMessage(e,"ERROR",t,n,r);throw console.error(s),new Error(s)}warn(e,t,n){if(!this.shouldCheck(e))return;const r=this.formatMessage(e,"WARNING",t,n,!0);throw console.error(r),new Error(r)}formatMessage(e,t,n,r,s=!0){let i=`\n🤖 AI_GUARDRAILS ${t}: ${n}`;return r&&(i+=`\n\n💡 ${r}`),s&&(i+=`\n\n🔇 To disable this check:\n ndk.guardrailOff('${e}').yourMethod() // For one call`,i+=`\n ndk.aiGuardrails.skip('${e}') // Permanently`,i+=`\n or set: ndk.aiGuardrails = { skip: new Set(['${e}']) }`),i}ndkInstantiated(e){this.enabled&&checkCachePresence(e,this.shouldCheck.bind(this))}ndk={fetchingEvents:(e,t)=>{this.enabled&&fetchingEvents(e,t,this.warn.bind(this))}};event={signing:e=>{this.enabled&&signing(e,this.error.bind(this),this.warn.bind(this),this._replyEvents)},publishing:e=>{this.enabled},received:(e,t)=>{this.enabled},creatingReply:e=>{this.enabled&&this._replyEvents.add(e)}};subscription={created:(e,t)=>{this.enabled}};relay={connected:e=>{this.enabled}}};function isValidPubkey(e){return"string"==typeof e&&/^[0-9a-f]{64}$/i.test(e)}function processFilters(e,t="validate",n,r){if("ignore"===t)return e;const s=[],i=e.map((e,i)=>{r?.aiGuardrails.isEnabled()&&runAIGuardrailsForFilter(e,i,r);return processFilter(e,t,i,s,n)});if("validate"===t&&s.length>0)throw new Error(`Invalid filter(s) detected:\n${s.join("\n")}`);return i}function processFilter(e,t,n,r,s){const i="validate"===t,o=i?e:{...e};if(e.ids){const t=[];e.ids.forEach((e,o)=>{void 0===e?i?r.push(`Filter[${n}].ids[${o}] is undefined`):s?.(`Fixed: Removed undefined value at ids[${o}]`):"string"!=typeof e?i?r.push(`Filter[${n}].ids[${o}] is not a string (got ${typeof e})`):s?.(`Fixed: Removed non-string value at ids[${o}] (was ${typeof e})`):/^[0-9a-f]{64}$/i.test(e)?t.push(e):i?r.push(`Filter[${n}].ids[${o}] is not a valid 64-char hex string: "${e}"`):s?.(`Fixed: Removed invalid hex string at ids[${o}]`)}),i||(o.ids=t.length>0?t:void 0)}if(e.authors){const t=[];e.authors.forEach((e,o)=>{void 0===e?i?r.push(`Filter[${n}].authors[${o}] is undefined`):s?.(`Fixed: Removed undefined value at authors[${o}]`):"string"!=typeof e?i?r.push(`Filter[${n}].authors[${o}] is not a string (got ${typeof e})`):s?.(`Fixed: Removed non-string value at authors[${o}] (was ${typeof e})`):/^[0-9a-f]{64}$/i.test(e)?t.push(e):i?r.push(`Filter[${n}].authors[${o}] is not a valid 64-char hex pubkey: "${e}"`):s?.(`Fixed: Removed invalid hex pubkey at authors[${o}]`)}),i||(o.authors=t.length>0?t:void 0)}if(e.kinds){const t=[];e.kinds.forEach((e,o)=>{void 0===e?i?r.push(`Filter[${n}].kinds[${o}] is undefined`):s?.(`Fixed: Removed undefined value at kinds[${o}]`):"number"!=typeof e?i?r.push(`Filter[${n}].kinds[${o}] is not a number (got ${typeof e})`):s?.(`Fixed: Removed non-number value at kinds[${o}] (was ${typeof e})`):Number.isInteger(e)?e<0||e>65535?i?r.push(`Filter[${n}].kinds[${o}] is out of valid range (0-65535): ${e}`):s?.(`Fixed: Removed out-of-range kind at kinds[${o}]: ${e}`):t.push(e):i?r.push(`Filter[${n}].kinds[${o}] is not an integer: ${e}`):s?.(`Fixed: Removed non-integer value at kinds[${o}]: ${e}`)}),i||(o.kinds=t.length>0?t:void 0)}for(const t in e)if(t.startsWith("#")&&2===t.length){const a=e[t];if(Array.isArray(a)){const e=[];a.forEach((o,a)=>{void 0===o?i?r.push(`Filter[${n}].${t}[${a}] is undefined`):s?.(`Fixed: Removed undefined value at ${t}[${a}]`):"string"!=typeof o?i?r.push(`Filter[${n}].${t}[${a}] is not a string (got ${typeof o})`):s?.(`Fixed: Removed non-string value at ${t}[${a}] (was ${typeof o})`):"#e"!==t&&"#p"!==t||/^[0-9a-f]{64}$/i.test(o)?e.push(o):i?r.push(`Filter[${n}].${t}[${a}] is not a valid 64-char hex string: "${o}"`):s?.(`Fixed: Removed invalid hex string at ${t}[${a}]`)}),i||(o[t]=e.length>0?e:void 0)}}return i||Object.keys(o).forEach(e=>{void 0===o[e]&&delete o[e]}),o}function runAIGuardrailsForFilter(e,t,n){const r=n.aiGuardrails,s=JSON.stringify(e,null,2);if(1===Object.keys(e).length&&void 0!==e.limit&&r.error(GuardrailCheckId.FILTER_ONLY_LIMIT,`Filter[${t}] contains only 'limit' without any filtering criteria.\n\n📦 Your filter:\n${s}\n\n⚠️ This will fetch random events from relays without any criteria.`,"Add filtering criteria:\n ✅ { kinds: [1], limit: 10 }\n ✅ { authors: [pubkey], limit: 10 }\n ❌ { limit: 10 }"),0===Object.keys(e).length&&r.error(GuardrailCheckId.FILTER_EMPTY,`Filter[${t}] is empty.\n\n📦 Your filter:\n${s}\n\n⚠️ This will request ALL events from relays, which is never what you want.`,"Add filtering criteria like 'kinds', 'authors', or tags.",!1),void 0!==e.since&&void 0!==e.until&&e.since>e.until){const n=new Date(1e3*e.since).toISOString(),i=new Date(1e3*e.until).toISOString();r.error(GuardrailCheckId.FILTER_SINCE_AFTER_UNTIL,`Filter[${t}] has 'since' AFTER 'until'.\n\n📦 Your filter:\n${s}\n\n❌ since: ${e.since} (${n})\n❌ until: ${e.until} (${i})\n\nNo events can match this time range!`,"'since' must be BEFORE 'until'. Both are Unix timestamps in seconds.",!1)}const i=/^n(addr|event|ote|pub|profile)1/,o=/^[0-9a-f]{64}$/i;e.ids&&e.ids.forEach((e,n)=>{"string"==typeof e&&(i.test(e)?r.error(GuardrailCheckId.FILTER_BECH32_IN_ARRAY,`Filter[${t}].ids[${n}] contains bech32: "${e}". IDs must be hex, not bech32.`,'Use filterFromId() to decode bech32 first: import { filterFromId } from "@nostr-dev-kit/ndk"',!1):o.test(e)||r.error(GuardrailCheckId.FILTER_INVALID_HEX,`Filter[${t}].ids[${n}] is not a valid 64-char hex string: "${e}"`,"Event IDs must be 64-character hexadecimal strings. Invalid IDs often come from corrupted data in user-generated lists. Always validate hex strings before using them in filters:\n\n const validIds = ids.filter(id => /^[0-9a-f]{64}$/i.test(id));",!1))}),e.authors&&e.authors.forEach((e,n)=>{"string"==typeof e&&(i.test(e)?r.error(GuardrailCheckId.FILTER_BECH32_IN_ARRAY,`Filter[${t}].authors[${n}] contains bech32: "${e}". Authors must be hex pubkeys, not npub.`,"Use ndkUser.pubkey instead. Example: { authors: [ndkUser.pubkey] }",!1):o.test(e)||r.error(GuardrailCheckId.FILTER_INVALID_HEX,`Filter[${t}].authors[${n}] is not a valid 64-char hex pubkey: "${e}"`,'Kind:3 follow lists can contain invalid entries like labels ("Follow List"), partial strings ("highlig"), or other corrupted data. You MUST validate all pubkeys before using them in filters.\n\n Example:\n const validPubkeys = pubkeys.filter(p => /^[0-9a-f]{64}$/i.test(p));\n ndk.subscribe({ authors: validPubkeys, kinds: [1] });',!1))});for(const n in e)if(n.startsWith("#")&&2===n.length){const s=e[n];Array.isArray(s)&&s.forEach((e,s)=>{"string"==typeof e&&("#e"!==n&&"#p"!==n||(i.test(e)?r.error(GuardrailCheckId.FILTER_BECH32_IN_ARRAY,`Filter[${t}].${n}[${s}] contains bech32: "${e}". Tag values must be decoded.`,"Use filterFromId() or nip19.decode() to get the hex value first.",!1):o.test(e)||r.error(GuardrailCheckId.FILTER_INVALID_HEX,`Filter[${t}].${n}[${s}] is not a valid 64-char hex string: "${e}"`,("#e"===n?"Event IDs":"Public keys")+" in tag filters must be 64-character hexadecimal strings. Kind:3 follow lists and other user-generated content can contain invalid data. Always filter before using:\n\n const validValues = values.filter(v => /^[0-9a-f]{64}$/i.test(v));",!1)))})}if(e["#a"]){const n=e["#a"];n?.forEach((e,n)=>{if("string"==typeof e)if(/^\d+:[0-9a-f]{64}:.*$/.test(e)){const s=Number.parseInt(e.split(":")[0],10);(s<3e4||s>39999)&&r.error(GuardrailCheckId.FILTER_INVALID_A_TAG,`Filter[${t}].#a[${n}] uses non-addressable kind ${s}: "${e}". #a filters are only for addressable events (kinds 30000-39999).`,`Addressable events include:\n • 30000-30039: Parameterized Replaceable Events (profiles, settings, etc.)\n • 30040-39999: Other addressable events\n\nFor regular events (kind ${s}), use:\n • #e filter for specific event IDs\n • kinds + authors filters for event queries`,!1)}else r.error(GuardrailCheckId.FILTER_INVALID_A_TAG,`Filter[${t}].#a[${n}] has invalid format: "${e}". Must be "kind:pubkey:d-tag".`,'Example: "30023:fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52:my-article"',!1)})}}function mergeTags(e,t){const n=new Map,r=(e,t)=>e.every((e,n)=>e===t[n]);return e.concat(t).forEach(e=>{for(const[t,s]of n)if(r(s,e)||r(e,s))return void(e.length>=s.length&&n.set(t,e));n.set((e=>e.join(","))(e),e)}),Array.from(n.values())}var hashtagRegex=/(?<=\s|^)(#[^\s!@#$%^&*()=+./,[{\]};:'"?><]+)/g;function generateHashtags(e){const t=e.match(hashtagRegex),n=new Set,r=new Set;if(t)for(const e of t)n.has(e.slice(1))||(r.add(e.slice(1)),n.add(e.slice(1)));return Array.from(r)}async function generateContentTags(e,t=[],n,r){if(n?.skipContentTagging)return{content:e,tags:t};const s=[],i=e=>{t.find(t=>["q",e[0]].includes(t[0])&&t[1]===e[1])||t.push(e)};if(e=e.replace(/(@|nostr:)(npub|nprofile|note|nevent|naddr)[a-zA-Z0-9]+/g,e=>{try{const t=e.split(/(@|nostr:)/)[2],{type:r,data:o}=nip19_exports$1.decode(t);let a;if(n?.filters){const t=!n.filters.includeTypes||n.filters.includeTypes.includes(r),s=n.filters.excludeTypes?.includes(r);if(!t||s)return e}switch(r){case"npub":!1!==n?.pTags&&(a=["p",o]);break;case"nprofile":!1!==n?.pTags&&(a=["p",o.pubkey]);break;case"note":s.push(new Promise(async e=>{const n=await maybeGetEventRelayUrl(t);i(["q",o,n]),e()}));break;case"nevent":s.push(new Promise(async e=>{const{id:r,author:s}=o;let{relays:a}=o;a&&0!==a.length||(a=[await maybeGetEventRelayUrl(t)]),i(["q",r,a[0]]),s&&!1!==n?.pTags&&!1!==n?.pTagOnQTags&&i(["p",s]),e()}));break;case"naddr":s.push(new Promise(async e=>{const r=[o.kind,o.pubkey,o.identifier].join(":");let s=o.relays??[];0===s.length&&(s=[await maybeGetEventRelayUrl(t)]),i(["q",r,s[0]]),!1!==n?.pTags&&!1!==n?.pTagOnQTags&&!1!==n?.pTagOnATags&&i(["p",o.pubkey]),e()}));break;default:return e}return a&&i(a),`nostr:${t}`}catch(t){return e}}),await Promise.all(s),!n?.filters?.excludeTypes?.includes("hashtag")){const n=generateHashtags(e).map(e=>["t",e]);t=mergeTags(t,n)}if(!1!==n?.pTags&&n?.copyPTagsFromTarget&&r){const e=r.getMatchingTags("p");for(const n of e)n[1]&&isValidPubkey(n[1])&&(t.find(e=>"p"===e[0]&&e[1]===n[1])||t.push(n))}return{content:e,tags:t}}async function maybeGetEventRelayUrl(e){return""}async function encrypt(e,t,n="nip44"){let r;if(!this.ndk)throw new Error("No NDK instance found!");let s=t;if(s||(this.ndk.assertSigner(),s=this.ndk.signer),!s)throw new Error("no NDK signer");const i=e||(()=>{const e=this.getMatchingTags("p");if(1!==e.length)throw new Error("No recipient could be determined and no explicit recipient was provided");return this.ndk.getUser({pubkey:e[0][1]})})();if("nip44"===n&&await isEncryptionEnabled(s,"nip44")&&(r=await s.encrypt(i,this.content,"nip44")),r&&"nip04"!==n||!await isEncryptionEnabled(s,"nip04")||(r=await s.encrypt(i,this.content,"nip04")),!r)throw new Error("Failed to encrypt event.");this.content=r}async function decrypt(e,t,n){if(this.ndk?.cacheAdapter?.getDecryptedEvent){const e=await this.ndk.cacheAdapter.getDecryptedEvent(this.id);if(e)return void(this.content=e.content)}let r;if(!this.ndk)throw new Error("No NDK instance found!");let s=t;if(s||(this.ndk.assertSigner(),s=this.ndk.signer),!s)throw new Error("no NDK signer");const i=e||this.author;if(!i)throw new Error("No sender provided and no author available");const o=n||(this.content.match(/\\?iv=/)?"nip04":"nip44");if(("nip04"===o||4===this.kind)&&await isEncryptionEnabled(s,"nip04")&&this.content.search("\\?iv=")&&(r=await s.decrypt(i,this.content,"nip04")),!r&&"nip44"===o&&await isEncryptionEnabled(s,"nip44")&&(r=await s.decrypt(i,this.content,"nip44")),!r)throw new Error("Failed to decrypt event.");this.content=r,this.ndk?.cacheAdapter?.addDecryptedEvent&&this.ndk.cacheAdapter.addDecryptedEvent(this)}async function isEncryptionEnabled(e,t){return!!e.encryptionEnabled&&(!t||Boolean(await e.encryptionEnabled(t)))}function eventHasETagMarkers(e){for(const t of e.tags)if("e"===t[0]&&(t[3]??"").length>0)return!0;return!1}function getRootTag(e,t){t??=e.tagType();const n=e.tags.find(isTagRootTag);if(!n){if(eventHasETagMarkers(e))return;const n=e.getMatchingTags(t);if(n.length<3)return n[0]}return n}var nip22RootTags=new Set(["A","E","I"]),nip22ReplyTags=new Set(["a","e","i"]);function getReplyTag(e,t){if(1111===e.kind){let t;for(const n of e.tags)if(nip22RootTags.has(n[0]))t=n;else if(nip22ReplyTags.has(n[0])){t=n;break}return t}t??=e.tagType();let n,r=!1;for(const s of e.tags)if(s[0]===t){if((s[3]??"").length>0&&(r=!0),r&&"reply"===s[3])return s;r&&"root"===s[3]&&(n=s),r||(n=s)}return n}function isTagRootTag(e){return"E"===e[0]||"root"===e[3]}async function fetchTaggedEvent(e,t){if(!this.ndk)throw new Error("NDK instance not found");const n=this.getMatchingTags(e,t);if(0===n.length)return;const[r,s,i]=n[0],o=""!==i?this.ndk.pool.getRelay(i):void 0;return await this.ndk.fetchEvent(s,{},o)}async function fetchRootEvent(e){if(!this.ndk)throw new Error("NDK instance not found");const t=getRootTag(this);if(t)return this.ndk.fetchEventFromTag(t,this,e)}async function fetchReplyEvent(e){if(!this.ndk)throw new Error("NDK instance not found");const t=getReplyTag(this);if(t)return this.ndk.fetchEventFromTag(t,this,e)}function isReplaceable(){if(void 0===this.kind)throw new Error("Kind not set");return[0,3].includes(this.kind)||this.kind>=1e4&&this.kind<2e4||this.kind>=3e4&&this.kind<4e4}function isEphemeral(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=2e4&&this.kind<3e4}function isParamReplaceable(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=3e4&&this.kind<4e4}var DEFAULT_RELAY_COUNT=2,worker;function encode(e=DEFAULT_RELAY_COUNT){let t=[];return this.onRelays.length>0?t=this.onRelays.map(e=>e.url):this.relay&&(t=[this.relay.url]),t.length>e&&(t=t.slice(0,e)),this.isParamReplaceable()?nip19_exports$1.naddrEncode({kind:this.kind,pubkey:this.pubkey,identifier:this.replaceableDTag(),relays:t}):t.length>0?nip19_exports$1.neventEncode({id:this.tagId(),relays:t,author:this.pubkey}):nip19_exports$1.noteEncode(this.tagId())}async function repost(e=!0,t){if(!t&&e){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),t=this.ndk.signer}const n=new NDKEvent(this.ndk,{kind:getKind(this)});return this.isProtected||(n.content=JSON.stringify(this.rawEvent())),n.tag(this),1!==this.kind&&n.tags.push(["k",`${this.kind}`]),t&&await n.sign(t),e&&await n.publish(),n}function getKind(e){return 1===e.kind?6:16}function serialize(e=!1,t=!1){const n=[0,this.pubkey,this.created_at,this.kind,this.tags,this.content];return e&&n.push(this.sig),t&&n.push(this.id),JSON.stringify(n)}function deserialize(e){const t=JSON.parse(e),n={pubkey:t[1],created_at:t[2],kind:t[3],tags:t[4],content:t[5]};if(t.length>=7){const e=t[6],r=t[7];e&&128===e.length?(n.sig=e,r&&64===r.length&&(n.id=r)):e&&64===e.length&&(n.id=e,r&&128===r.length&&(n.sig=r))}return n}var processingQueue={};function signatureVerificationInit(e){(worker=e).onmessage=e=>{const[t,n]=e.data,r=processingQueue[t];if(r){delete processingQueue[t];for(const e of r.resolves)e(n)}else console.error("No record found for event",t)}}async function verifySignatureAsync(e,t,n){const r=e.ndk,s=Date.now();let i;return i=r.signatureVerificationFunction?await r.signatureVerificationFunction(e):await new Promise(t=>{const r=e.serialize();let s=!1;processingQueue[e.id]||(processingQueue[e.id]={event:e,resolves:[],relay:n},s=!0),processingQueue[e.id].resolves.push(t),s&&worker?.postMessage({serialized:r,id:e.id,sig:e.sig,pubkey:e.pubkey})}),r.signatureVerificationTimeMs+=Date.now()-s,i}var PUBKEY_REGEX=/^[a-f0-9]{64}$/;function validate(){if("number"!=typeof this.kind)return!1;if("string"!=typeof this.content)return!1;if("number"!=typeof this.created_at)return!1;if("string"!=typeof this.pubkey)return!1;if(!this.pubkey.match(PUBKEY_REGEX))return!1;if(!Array.isArray(this.tags))return!1;for(let e=0;e{e&&(this.signatureVerified=n,n&&verifiedSignatures.set(this.id,this.sig)),n?t&&t.addValidatedEvent():(t?this.ndk?.reportInvalidSignature(this,t):this.ndk?.reportInvalidSignature(this),verifiedSignatures.set(this.id,!1))}).catch(e=>{console.error("signature verification error",this.id,e)})}}catch(e){return this.signatureVerified=!1,!1}}function getEventHash(){return getEventHashFromSerializedEvent(this.serialize())}function getEventHashFromSerializedEvent(e){return bytesToHex(sha256((new TextEncoder).encode(e)))}var skipClientTagOnKinds=new Set([0,4,1059,13,3,9734,5]),NDKEvent=class e extends lib$1.EventEmitter{ndk;created_at;content="";tags=[];kind;id="";sig;pubkey="";signatureVerified;_author=void 0;relay;get onRelays(){let e=[];return this.ndk?e=this.ndk.subManager.seenEvents.get(this.id)||[]:this.relay&&e.push(this.relay),e}publishStatus="success";publishError;constructor(t,n){super(),this.ndk=t,this.created_at=n?.created_at,this.content=n?.content||"",this.tags=n?.tags||[],this.id=n?.id||"",this.sig=n?.sig,this.pubkey=n?.pubkey||"",this.kind=n?.kind,n instanceof e&&(this.relay&&(this.relay=n.relay,this.ndk?.subManager.seenEvent(n.id,this.relay)),this.publishStatus=n.publishStatus,this.publishError=n.publishError)}static deserialize(t,n){return new e(t,deserialize(n))}rawEvent(){return{created_at:this.created_at,content:this.content,tags:this.tags,kind:this.kind,pubkey:this.pubkey,id:this.id,sig:this.sig}}set author(e){this.pubkey=e.pubkey,this._author=e,this._author.ndk??=this.ndk}get author(){if(this._author)return this._author;if(!this.ndk)throw new Error("No NDK instance found");const e=this.ndk.getUser({pubkey:this.pubkey});return this._author=e,e}tagExternal(e,t,n){const r=["i"],s=["k"];switch(t){case"url":{const t=new URL(e);t.hash="",r.push(t.toString()),s.push(`${t.protocol}//${t.host}`);break}case"hashtag":r.push(`#${e.toLowerCase()}`),s.push("#");break;case"geohash":r.push(`geo:${e.toLowerCase()}`),s.push("geo");break;case"isbn":r.push(`isbn:${e.replace(/-/g,"")}`),s.push("isbn");break;case"podcast:guid":r.push(`podcast:guid:${e}`),s.push("podcast:guid");break;case"podcast:item:guid":r.push(`podcast:item:guid:${e}`),s.push("podcast:item:guid");break;case"podcast:publisher:guid":r.push(`podcast:publisher:guid:${e}`),s.push("podcast:publisher:guid");break;case"isan":r.push(`isan:${e.split("-").slice(0,4).join("-")}`),s.push("isan");break;case"doi":r.push(`doi:${e.toLowerCase()}`),s.push("doi");break;default:throw new Error(`Unsupported NIP-73 entity type: ${t}`)}n&&r.push(n),this.tags.push(r),this.tags.push(s)}tag(t,n,r,s,i){let o=[];if(void 0!==t.fetchProfile){if(s??="p","p"===s&&!1===i?.pTags)return;const e=[s,t.pubkey];n&&e.push("",n),o.push(e)}else if(t instanceof e){const e=t;if(r??=e?.pubkey===this.pubkey,o=e.referenceTags(n,r,s,i),!1!==i?.pTags)for(const t of e.getMatchingTags("p"))t[1]&&isValidPubkey(t[1])&&t[1]!==this.pubkey&&(this.tags.find(e=>"p"===e[0]&&e[1]===t[1])||this.tags.push(["p",t[1]]))}else{if(!Array.isArray(t))throw new Error("Invalid argument",t);o=[t]}this.tags=mergeTags(this.tags,o)}async toNostrEvent(e,t){if(!e&&""===this.pubkey){const e=await(this.ndk?.signer?.user());this.pubkey=e?.pubkey||""}this.created_at||(this.created_at=Math.floor(Date.now()/1e3));const{content:n,tags:r}=await this.generateTags(t);this.content=n||"",this.tags=r;try{this.id=this.getEventHash()}catch(e){}return this.rawEvent()}serialize=serialize.bind(this);getEventHash=getEventHash.bind(this);validate=validate.bind(this);verifySignature=verifySignature.bind(this);isReplaceable=isReplaceable.bind(this);isEphemeral=isEphemeral.bind(this);isDvm=()=>this.kind&&this.kind>=5e3&&this.kind<=7e3;isParamReplaceable=isParamReplaceable.bind(this);encode=encode.bind(this);encrypt=encrypt.bind(this);decrypt=decrypt.bind(this);getMatchingTags(e,t){const n=this.tags.filter(t=>t[0]===e);return void 0===t?n:n.filter(e=>e[3]===t)}hasTag(e,t){return this.tags.some(n=>n[0]===e&&(!t||n[3]===t))}tagValue(e,t){const n=this.getMatchingTags(e,t);if(0!==n.length)return n[0][1]}get alt(){return this.tagValue("alt")}set alt(e){this.removeTag("alt"),e&&this.tags.push(["alt",e])}get dTag(){return this.tagValue("d")}set dTag(e){this.removeTag("d"),e&&this.tags.push(["d",e])}removeTag(e,t){const n=Array.isArray(e)?e:[e];this.tags=this.tags.filter(e=>{const r=n.includes(e[0]),s=!t||e[3]===t;return!(r&&s)})}replaceTag(e){this.removeTag(e[0]),this.tags.push(e)}async sign(e,t){this.ndk?.aiGuardrails?.event?.signing(this),e?this.author=await e.user():(this.ndk?.assertSigner(),e=this.ndk?.signer);const n=await this.toNostrEvent(void 0,t);return this.sig=await e.sign(n),this.sig}async publishReplaceable(e,t,n){return this.id="",this.created_at=Math.floor(Date.now()/1e3),this.sig="",this.publish(e,t,n)}async publish(e,t,n,r){if(n||(n=1),this.sig||await this.sign(void 0,r),!this.ndk)throw new Error("NDKEvent must be associated with an NDK instance to publish");if(e&&0!==e.size||(e=this.ndk.devWriteRelaySet||await calculateRelaySetFromEvent(this.ndk,this,n)),5===this.kind&&this.ndk.cacheAdapter?.deleteEventIds){const e=this.getMatchingTags("e").map(e=>e[1]);this.ndk.cacheAdapter.deleteEventIds(e)}const s=this.rawEvent();if(this.ndk.cacheAdapter?.addUnpublishedEvent&&shouldTrackUnpublishedEvent(this))try{this.ndk.cacheAdapter.addUnpublishedEvent(this,e.relayUrls)}catch(e){console.error("Error adding unpublished event to cache",e)}5===this.kind&&this.ndk.cacheAdapter?.deleteEventIds&&this.ndk.cacheAdapter.deleteEventIds(this.getMatchingTags("e").map(e=>e[1])),this.ndk.subManager.dispatchEvent(s,void 0,!0);const i=await e.publish(this,t,n);return i.forEach(e=>this.ndk?.subManager.seenEvent(this.id,e)),i}async generateTags(e){let t=[];const n=await generateContentTags(this.content,this.tags,e,this),r=n.content;if(t=n.tags,this.kind&&this.isParamReplaceable()){if(!this.getMatchingTags("d")[0]){const e=this.tagValue("title");let n=[...Array(e?6:16)].map(()=>Math.random().toString(36)[2]).join("");e&&e.length>0&&(n=`${e.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"")}-${n}`),t.push(["d",n])}}if(this.shouldAddClientTag){const e=["client",this.ndk?.clientName??""];this.ndk?.clientNip89&&e.push(this.ndk?.clientNip89),t.push(e)}else this.shouldStripClientTag&&(t=t.filter(e=>"client"!==e[0]));return{content:r||"",tags:t}}get shouldAddClientTag(){return!(!this.ndk?.clientName&&!this.ndk?.clientNip89)&&(!skipClientTagOnKinds.has(this.kind)&&(!this.isEphemeral()&&(!(this.isReplaceable()&&!this.isParamReplaceable())&&(!this.isDvm()&&!this.hasTag("client")))))}get shouldStripClientTag(){return skipClientTagOnKinds.has(this.kind)}muted(){return this.ndk?.muteFilter&&this.ndk.muteFilter(this)?"muted":null}replaceableDTag(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.getMatchingTags("d")[0];return e?e[1]:""}throw new Error("Event is not a parameterized replaceable event")}deduplicationKey(){return 0===this.kind||3===this.kind||this.kind&&this.kind>=1e4&&this.kind<2e4?`${this.kind}:${this.pubkey}`:this.tagId()}tagId(){return this.isParamReplaceable()?this.tagAddress():this.id}tagAddress(){if(this.isParamReplaceable()){const e=this.dTag??"";return`${this.kind}:${this.pubkey}:${e}`}if(this.isReplaceable())return`${this.kind}:${this.pubkey}:`;throw new Error("Event is not a replaceable event")}tagType(){return this.isParamReplaceable()?"a":"e"}tagReference(e){let t;return t=this.isParamReplaceable()?["a",this.tagAddress()]:["e",this.tagId()],this.relay?t.push(this.relay.url):t.push(""),t.push(e??""),this.isParamReplaceable()||t.push(this.pubkey),t}referenceTags(e,t,n,r){let s=[];return s=this.isParamReplaceable()?[[n??"a",this.tagAddress()],[n??"e",this.id]]:[[n??"e",this.id]],s=s.map(t=>("e"===t[0]||e?t.push(this.relay?.url??""):this.relay?.url&&t.push(this.relay?.url),t)),s.forEach(t=>{"e"===t[0]?(t.push(e??""),t.push(this.pubkey)):e&&t.push(e)}),s=[...s,...this.getMatchingTags("h")],t||!1===r?.pTags||s.push(...this.author.referenceTags()),s}filter(){return this.isParamReplaceable()?{"#a":[this.tagId()]}:{"#e":[this.tagId()]}}nip22Filter(){return this.isParamReplaceable()?{"#A":[this.tagId()]}:{"#E":[this.tagId()]}}async delete(t,n=!0){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const r=new e(this.ndk,{kind:5,content:t||""});return r.tag(this,void 0,!0),r.tags.push(["k",this.kind?.toString()]),n&&(this.emit("deleted"),await r.publish()),r}set isProtected(e){this.removeTag("-"),e&&this.tags.push(["-"])}get isProtected(){return this.hasTag("-")}fetchTaggedEvent=fetchTaggedEvent.bind(this);fetchRootEvent=fetchRootEvent.bind(this);fetchReplyEvent=fetchReplyEvent.bind(this);repost=repost.bind(this);async react(t,n=!0){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const r=new e(this.ndk,{kind:7,content:t});return r.tag(this),1!==this.kind&&r.tags.push(["k",`${this.kind}`]),n&&await r.publish(),r}get isValid(){return this.validate()}get inspect(){return JSON.stringify(this.rawEvent(),null,4)}dump(){console.debug(JSON.stringify(this.rawEvent(),null,4)),console.debug("Event on relays:",this.onRelays.map(e=>e.url).join(", "))}reply(t,n){const r=new e(this.ndk);if(this.ndk?.aiGuardrails?.event?.creatingReply(r),1!==this.kind||t){r.kind=1111;const e=["A","E","I","P"],t=this.tags.filter(t=>e.includes(t[0]));if(t.length>0){const e=this.tagValue("K");let n;if(r.tags.push(...t),e&&r.tags.push(["K",e]),this.isParamReplaceable()){n=["a",this.tagAddress()];const e=this.relay?.url??"";e&&n.push(e)}else{n=["e",this.tagId()];const e=this.relay?.url??"";n.push(e),n.push(this.pubkey)}r.tags.push(n)}else{let e,t;const s=this.relay?.url??"";this.isParamReplaceable()?(e=["a",this.tagAddress(),s],t=["A",this.tagAddress(),s]):(e=["e",this.tagId(),s,this.pubkey],t=["E",this.tagId(),s,this.pubkey]),r.tags.push(e),r.tags.push(t),r.tags.push(["K",this.kind?.toString()]),!1!==n?.pTags&&!1!==n?.pTagOnATags&&r.tags.push(["P",this.pubkey])}r.tags.push(["k",this.kind?.toString()]),!1!==n?.pTags&&(r.tags.push(...this.getMatchingTags("p")),r.tags.push(["p",this.pubkey]))}else{r.kind=1;this.hasTag("e")?r.tags=[...r.tags,...this.getMatchingTags("e"),...this.getMatchingTags("p"),...this.getMatchingTags("a"),...this.referenceTags("reply",!1,void 0,n)]:r.tag(this,"root",!1,void 0,n)}return r}},untrackedUnpublishedEvents=new Set([24133,13194,23194,23195]);function shouldTrackUnpublishedEvent(e){return!untrackedUnpublishedEvents.has(e.kind)}var NDKPool=class extends lib$1.EventEmitter{_relays=new Map;status="idle";autoConnectRelays=new Set;debug;temporaryRelayTimers=new Map;flappingRelays=new Set;backoffTimes=new Map;ndk;disconnectionTimes=new Map;systemEventDetector;constructor(e,t,{debug:n,name:r}={}){super(),this.debug=n??t.debug.extend("pool"),r&&(this._name=r),this.ndk=t,this.relayUrls=e,this.ndk.pools&&this.ndk.pools.push(this)}get relays(){return this._relays}set relayUrls(e){this._relays.clear();for(const t of e){const e=new NDKRelay(t,void 0,this.ndk);e.connectivity.netDebug=this.ndk.netDebug,this.addRelay(e)}}_name="unnamed";get name(){return this._name}set name(e){this._name=e,this.debug=this.debug.extend(e)}useTemporaryRelay(e,t=3e4,n){const r=this.relays.has(e.url);r||(this.addRelay(e),this.debug("Adding temporary relay %s for filters %o",e.url,n));const s=this.temporaryRelayTimers.get(e.url);if(s&&clearTimeout(s),!r||s){const n=setTimeout(()=>{this.ndk.explicitRelayUrls?.includes(e.url)||this.removeRelay(e.url)},t);this.temporaryRelayTimers.set(e.url,n)}}addRelay(e,t=!0){const n=this.relays.has(e.url),r=e.url.includes("/npub1");let s=!0;const i=e.url;if(n)return;if(this.ndk.relayConnectionFilter&&!this.ndk.relayConnectionFilter(i))return void this.debug(`Refusing to add relay ${i}: blocked by relayConnectionFilter`);if(r)return void this.debug(`Refusing to add relay ${i}: is a filter relay`);if(this.ndk.cacheAdapter?.getRelayStatus){const n=this.ndk.cacheAdapter.getRelayStatus(i),r=n instanceof Promise?void 0:n;if(r?.dontConnectBefore){if(r.dontConnectBefore>Date.now()){const n=r.dontConnectBefore-Date.now();return this.debug(`Refusing to add relay ${i}: delayed connect for ${n}ms`),void setTimeout(()=>{this.addRelay(e,t)},n)}s=!1}}const o=t=>this.emit("notice",e,t),a=()=>this.handleRelayConnect(i),c=()=>this.handleRelayReady(e),l=()=>{this.recordDisconnection(e),this.emit("relay:disconnect",e)},u=()=>this.handleFlapping(e),d=t=>this.emit("relay:auth",e,t),h=()=>this.emit("relay:authed",e);e.off("notice",o),e.off("connect",a),e.off("ready",c),e.off("disconnect",l),e.off("flapping",u),e.off("auth",d),e.off("authed",h),e.on("notice",o),e.on("connect",a),e.on("ready",c),e.on("disconnect",l),e.on("flapping",u),e.on("auth",d),e.on("authed",h),e.on("delayed-connect",t=>{this.ndk.cacheAdapter?.updateRelayStatus&&this.ndk.cacheAdapter.updateRelayStatus(e.url,{dontConnectBefore:Date.now()+t})}),this._relays.set(i,e),t&&this.autoConnectRelays.add(i),t&&"active"===this.status&&(this.emit("relay:connecting",e),e.connect(void 0,s).catch(e=>{this.debug(`Failed to connect to relay ${i}`,e)}))}removeRelay(e){const t=this.relays.get(e);if(t)return t.disconnect(),this.relays.delete(e),this.autoConnectRelays.delete(e),this.emit("relay:disconnect",t),!0;const n=this.temporaryRelayTimers.get(e);return n&&(clearTimeout(n),this.temporaryRelayTimers.delete(e)),!1}isRelayConnected(e){const t=normalizeRelayUrl(e),n=this.relays.get(t);return!!n&&5===n.status}getRelay(e,t=!0,n=!1,r){let s=this.relays.get(normalizeRelayUrl(e));return s||(s=new NDKRelay(e,void 0,this.ndk),s.connectivity.netDebug=this.ndk.netDebug,n?this.useTemporaryRelay(s,3e4,r):this.addRelay(s,t)),s}handleRelayConnect(e){const t=this.relays.get(e);t?(this.emit("relay:connect",t),this.stats().connected===this.relays.size&&this.emit("connect")):console.error("NDK BUG: relay not found in pool",{relayUrl:e})}handleRelayReady(e){this.emit("relay:ready",e)}async connect(e){this.status="active",this.debug(`Connecting to ${this.relays.size} relays${e?`, timeout ${e}ms`:""}...`);const t=Array.from(this.autoConnectRelays.keys()).map(e=>this.relays.get(e)).filter(e=>!!e);for(const e of t)5!==e.status&&4!==e.status&&(this.emit("relay:connecting",e),e.connect().catch(t=>{this.debug(`Failed to connect to relay ${e.url}: ${t??"No reason specified"}`)}));const n=()=>t.every(e=>5===e.status),r=new Promise(e=>{if(n())return void e();const r=[];for(const s of t){const i=()=>{if(n()){for(let e=0;esetTimeout(t,e):()=>{});await Promise.race([r,s])}checkOnFlappingRelays(){if(this.flappingRelays.size/this.relays.size>=.8)for(const e of this.flappingRelays)this.backoffTimes.set(e,0)}recordDisconnection(e){const t=Date.now();this.disconnectionTimes.set(e.url,t);for(const[e,n]of this.disconnectionTimes.entries())t-n>1e4&&this.disconnectionTimes.delete(e);this.checkForSystemWideDisconnection()}checkForSystemWideDisconnection(){const e=Date.now(),t=[];for(const n of this.disconnectionTimes.values())e-n<5e3&&t.push(n);t.length>this.relays.size/2&&this.relays.size>1&&(this.debug(`System-wide disconnection detected: ${t.length}/${this.relays.size} relays disconnected`),this.handleSystemWideReconnection())}handleSystemWideReconnection(){if(this.systemEventDetector)this.debug("System-wide reconnection already in progress, skipping");else{this.debug("Initiating system-wide reconnection with reset backoff"),this.systemEventDetector=setTimeout(()=>{this.systemEventDetector=void 0},1e4);for(const e of this.relays.values())e.connectivity&&(e.connectivity.resetReconnectionState(),5!==e.status&&4!==e.status&&e.connect().catch(t=>{this.debug(`Failed to reconnect relay ${e.url} after system event: ${t}`)}));this.disconnectionTimes.clear()}}handleFlapping(e){this.debug(`Relay ${e.url} is flapping`);let t=this.backoffTimes.get(e.url)||5e3;t*=2,this.backoffTimes.set(e.url,t),this.debug(`Backoff time for ${e.url} is ${t}ms`),setTimeout(()=>{this.debug(`Attempting to reconnect to ${e.url}`),this.emit("relay:connecting",e),e.connect(),this.checkOnFlappingRelays()},t),e.disconnect(),this.emit("flapping",e)}size(){return this.relays.size}stats(){const e={total:0,connected:0,disconnected:0,connecting:0};for(const t of this.relays.values())e.total++,5===t.status?e.connected++:1===t.status?e.disconnected++:4===t.status&&e.connecting++;return e}connectedRelays(){return Array.from(this.relays.values()).filter(e=>e.status>=5)}permanentAndConnectedRelays(){return Array.from(this.relays.values()).filter(e=>e.status>=5&&!this.temporaryRelayTimers.has(e.url))}urls(){return Array.from(this.relays.keys())}},NDKDVMJobFeedback=class e extends NDKEvent{static kinds=[7e3];constructor(e,t){super(e,t),this.kind??=7e3}static async from(t){const n=new e(t.ndk,t.rawEvent());return n.encrypted&&await n.dvmDecrypt(),n}get status(){return this.tagValue("status")}set status(e){this.removeTag("status"),void 0!==e&&this.tags.push(["status",e])}get encrypted(){return!!this.getMatchingTags("encrypted")[0]}async dvmDecrypt(){await this.decrypt();const e=JSON.parse(this.content);this.tags.push(...e)}},NDKCashuMintList=class e extends NDKEvent{static kind=10019;static kinds=[10019];_p2pk;constructor(e,t){super(e,t),this.kind??=10019}static from(t){return new e(t.ndk,t)}set relays(e){this.tags=this.tags.filter(e=>"relay"!==e[0]);for(const t of e)this.tags.push(["relay",t])}get relays(){const e=[];for(const t of this.tags)"relay"===t[0]&&e.push(t[1]);return e}set mints(e){this.tags=this.tags.filter(e=>"mint"!==e[0]);for(const t of e)this.tags.push(["mint",t])}get mints(){const e=[];for(const t of this.tags)"mint"===t[0]&&e.push(t[1]);return Array.from(new Set(e))}get p2pk(){return this._p2pk||(this._p2pk=this.tagValue("pubkey")??this.pubkey),this._p2pk}set p2pk(e){this._p2pk=e,this.removeTag("pubkey"),e&&this.tags.push(["pubkey",e])}get relaySet(){return NDKRelaySet.fromRelayUrls(this.relays,this.ndk)}},NDKArticle=class e extends NDKEvent{static kind=30023;static kinds=[30023];constructor(e,t){super(e,t),this.kind??=30023}static from(t){return new e(t.ndk,t)}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get image(){return this.tagValue("image")}set image(e){this.removeTag("image"),e&&this.tags.push(["image",e])}get summary(){return this.tagValue("summary")}set summary(e){this.removeTag("summary"),e&&this.tags.push(["summary",e])}get published_at(){const e=this.tagValue("published_at");if(e){let t=Number.parseInt(e);return t>1e12&&(t=Math.floor(t/1e3)),t}}set published_at(e){this.removeTag("published_at"),void 0!==e&&this.tags.push(["published_at",e.toString()])}async generateTags(){return super.generateTags(),this.published_at||(this.published_at=this.created_at),super.generateTags()}get url(){return this.tagValue("url")}set url(e){e?this.tags.push(["url",e]):this.removeTag("url")}},NDKBlossomList=class e extends NDKEvent{static kinds=[10063];constructor(e,t){super(e,t),this.kind??=10063}static from(t){return new e(t.ndk,t.rawEvent())}get servers(){return this.tags.filter(e=>"server"===e[0]).map(e=>e[1])}set servers(e){this.tags=this.tags.filter(e=>"server"!==e[0]);for(const t of e)this.tags.push(["server",t])}get default(){const e=this.servers;return e.length>0?e[0]:void 0}set default(e){if(!e)return;const t=this.servers.filter(t=>t!==e);this.servers=[e,...t]}addServer(e){if(!e)return;const t=this.servers;t.includes(e)||(this.servers=[...t,e])}removeServer(e){if(!e)return;const t=this.servers;this.servers=t.filter(t=>t!==e)}},NDKFedimintMint=class e extends NDKEvent{static kind=38173;static kinds=[38173];constructor(e,t){super(e,t),this.kind??=38173}static async from(t){return new e(t.ndk,t)}get identifier(){return this.tagValue("d")}set identifier(e){this.removeTag("d"),e&&this.tags.push(["d",e])}get inviteCodes(){return this.getMatchingTags("u").map(e=>e[1])}set inviteCodes(e){this.removeTag("u");for(const t of e)this.tags.push(["u",t])}get modules(){return this.getMatchingTags("modules").map(e=>e[1])}set modules(e){this.removeTag("modules");for(const t of e)this.tags.push(["modules",t])}get network(){return this.tagValue("n")}set network(e){this.removeTag("n"),e&&this.tags.push(["n",e])}get metadata(){if(this.content)try{return JSON.parse(this.content)}catch{return}}set metadata(e){this.content=e?JSON.stringify(e):""}},NDKCashuMintAnnouncement=class e extends NDKEvent{static kind=38172;static kinds=[38172];constructor(e,t){super(e,t),this.kind??=38172}static async from(t){return new e(t.ndk,t)}get identifier(){return this.tagValue("d")}set identifier(e){this.removeTag("d"),e&&this.tags.push(["d",e])}get url(){return this.tagValue("u")}set url(e){this.removeTag("u"),e&&this.tags.push(["u",e])}get nuts(){return this.getMatchingTags("nuts").map(e=>e[1])}set nuts(e){this.removeTag("nuts");for(const t of e)this.tags.push(["nuts",t])}get network(){return this.tagValue("n")}set network(e){this.removeTag("n"),e&&this.tags.push(["n",e])}get metadata(){if(this.content)try{return JSON.parse(this.content)}catch{return}}set metadata(e){this.content=e?JSON.stringify(e):""}},NDKMintRecommendation=class e extends NDKEvent{static kind=38e3;static kinds=[38e3];constructor(e,t){super(e,t),this.kind??=38e3}static async from(t){return new e(t.ndk,t)}get recommendedKind(){const e=this.tagValue("k");return e?Number(e):void 0}set recommendedKind(e){this.removeTag("k"),e&&this.tags.push(["k",e.toString()])}get identifier(){return this.tagValue("d")}set identifier(e){this.removeTag("d"),e&&this.tags.push(["d",e])}get urls(){return this.getMatchingTags("u").map(e=>e[1])}set urls(e){this.removeTag("u");for(const t of e)this.tags.push(["u",t])}get mintEventPointers(){return this.getMatchingTags("a").map(e=>({kind:Number(e[1].split(":")[0]),identifier:e[1].split(":")[2],relay:e[2]}))}addMintEventPointer(e,t,n,r){const s=["a",`${e}:${t}:${n}`];r&&s.push(r),this.tags.push(s)}get review(){return this.content}set review(e){this.content=e}},NDKClassified=class e extends NDKEvent{static kinds=[30402];constructor(e,t){super(e,t),this.kind??=30402}static from(t){return new e(t.ndk,t)}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get summary(){return this.tagValue("summary")}set summary(e){this.removeTag("summary"),e&&this.tags.push(["summary",e])}get published_at(){const e=this.tagValue("published_at");if(e)return Number.parseInt(e)}set published_at(e){this.removeTag("published_at"),void 0!==e&&this.tags.push(["published_at",e.toString()])}get location(){return this.tagValue("location")}set location(e){this.removeTag("location"),e&&this.tags.push(["location",e])}get price(){const e=this.tags.find(e=>"price"===e[0]);if(e)return{amount:Number.parseFloat(e[1]),currency:e[2],frequency:e[3]}}set price(e){if("string"==typeof e&&(e={amount:Number.parseFloat(e)}),e?.amount){const t=["price",e.amount.toString()];e.currency&&t.push(e.currency),e.frequency&&t.push(e.frequency),this.tags.push(t)}else this.removeTag("price")}async generateTags(){return super.generateTags(),this.published_at||(this.published_at=this.created_at),super.generateTags()}},NDKDraft=class e extends NDKEvent{_event;static kind=31234;static kinds=[31234,1234];counterparty;constructor(e,t){super(e,t),this.kind??=31234}static from(t){return new e(t.ndk,t)}set identifier(e){this.removeTag("d"),this.tags.push(["d",e])}get identifier(){return this.dTag}set event(e){this._event=e instanceof NDKEvent?e:new NDKEvent(void 0,e),this.prepareEvent()}set checkpoint(e){e?(this.tags.push(e.tagReference()),this.kind=1234):(this.removeTag("a"),this.kind=31234)}get isCheckpoint(){return 1234===this.kind}get isProposal(){const e=this.tagValue("p");return!!e&&e!==this.pubkey}async getEvent(e){if(this._event)return this._event;if(e??=this.ndk?.signer,!e)throw new Error("No signer available");if(!(this.content&&this.content.length>0))return null;try{const t=e.pubkey,n=[this.tagValue("p"),this.pubkey].filter(Boolean).find(e=>e!==t);let r;r=new NDKUser({pubkey:n??t}),await this.decrypt(r,e);const s=JSON.parse(this.content);return this._event=await wrapEvent(new NDKEvent(this.ndk,s)),this._event}catch(e){return void console.error(e)}}prepareEvent(){if(!this._event)throw new Error("No event has been provided");this.removeTag("k"),this._event.kind&&this.tags.push(["k",this._event.kind.toString()]),this.content=JSON.stringify(this._event.rawEvent())}async save({signer:e,publish:t,relaySet:n}){if(e??=this.ndk?.signer,!e)throw new Error("No signer available");const r=this.counterparty||await e.user();if(await this.encrypt(r,e),this.counterparty){const e=this.counterparty.pubkey;this.removeTag("p"),this.tags.push(["p",e])}if(!1!==t)return this.publishReplaceable(n)}};function mapImetaTag(e){const t={};if(2===e.length){const n=e[1].split(" ");for(let e=0;e"imeta"===e[0]);if(e){const t=mapImetaTag(e);if(t.url)return t.url}return this.tagValue("image")}set image(e){this.tags=this.tags.filter(e=>"imeta"!==e[0]&&"image"!==e[0]),"string"==typeof e?void 0!==e&&this.tags.push(["image",e]):e&&"object"==typeof e&&(this.tags.push(imetaTagToTag(e)),e.url&&this.tags.push(["image",e.url]))}get pubkeys(){return Array.from(new Set(this.tags.filter(e=>"p"===e[0]&&e[1]&&isValidPubkey(e[1])).map(e=>e[1])))}set pubkeys(e){this.tags=this.tags.filter(e=>"p"!==e[0]);for(const t of e)this.tags.push(["p",t])}get description(){return this.tagValue("description")}set description(e){this.removeTag("description"),e&&this.tags.push(["description",e])}},NDKHighlight=class e extends NDKEvent{_article;static kind=9802;static kinds=[9802];constructor(e,t){super(e,t),this.kind??=9802}static from(t){return new e(t.ndk,t)}get url(){return this.tagValue("r")}set context(e){void 0===e?this.tags=this.tags.filter(([e,t])=>"context"!==e):(this.tags=this.tags.filter(([e,t])=>"context"!==e),this.tags.push(["context",e]))}get context(){return this.tags.find(([e,t])=>"context"===e)?.[1]??void 0}get article(){return this._article}set article(e){this._article=e,"string"==typeof e?this.tags.push(["r",e]):this.tag(e)}getArticleTag(){return this.getMatchingTags("a")[0]||this.getMatchingTags("e")[0]||this.getMatchingTags("r")[0]}async getArticle(){if(void 0!==this._article)return this._article;let e;const t=this.getArticleTag();if(t){switch(t[0]){case"a":{const[n,r,s]=t[1].split(":");e=nip19_exports$1.naddrEncode({kind:Number.parseInt(n),pubkey:r,identifier:s});break}case"e":e=nip19_exports$1.noteEncode(t[1]);break;case"r":this._article=t[1]}if(e){let t=await(this.ndk?.fetchEvent(e));t&&(30023===t.kind&&(t=NDKArticle.from(t)),this._article=t)}return this._article}}},NDKImage=class e extends NDKEvent{static kind=20;static kinds=[20];_imetas;constructor(e,t){super(e,t),this.kind??=20}static from(t){return new e(t.ndk,t.rawEvent())}get isValid(){return this.imetas.length>0}get imetas(){return this._imetas||(this._imetas=this.tags.filter(e=>"imeta"===e[0]).map(mapImetaTag).filter(e=>!!e.url)),this._imetas}set imetas(e){this._imetas=e,this.tags=this.tags.filter(e=>"imeta"!==e[0]),this.tags.push(...e.map(imetaTagToTag))}},NDKList=class e extends NDKEvent{_encryptedTags;static kinds=[30001,10004,10050,10030,10015,10001,10002,10007,10006,10003];encryptedTagsLength;constructor(e,t){super(e,t),this.kind??=30001}static from(t){return new e(t.ndk,t)}get title(){const e=this.tagValue("title")||this.tagValue("name");return e||(3===this.kind?"Contacts":1e4===this.kind?"Mute":10001===this.kind?"Pinned Notes":10002===this.kind?"Relay Metadata":10003===this.kind?"Bookmarks":10004===this.kind?"Communities":10005===this.kind?"Public Chats":10006===this.kind?"Blocked Relays":10007===this.kind?"Search Relays":10050===this.kind?"Direct Message Receive Relays":10015===this.kind?"Interests":10030===this.kind?"Emojis":this.tagValue("d"))}set title(e){this.removeTag(["title","name"]),e&&this.tags.push(["title",e])}get name(){return this.title}set name(e){this.title=e}get description(){return this.tagValue("description")}set description(e){this.removeTag("description"),e&&this.tags.push(["description",e])}get image(){return this.tagValue("image")}set image(e){this.removeTag("image"),e&&this.tags.push(["image",e])}isEncryptedTagsCacheValid(){return!(!this._encryptedTags||this.encryptedTagsLength!==this.content.length)}async encryptedTags(e=!0){if(e&&this.isEncryptedTagsCacheValid())return this._encryptedTags;if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");const t=await this.ndk.signer.user();try{if(this.content.length>0)try{const e=await this.ndk.signer.decrypt(t,this.content),n=JSON.parse(e);return n?.[0]?(this.encryptedTagsLength=this.content.length,this._encryptedTags=n):(this.encryptedTagsLength=this.content.length,this._encryptedTags=[])}catch(e){}}catch(e){}return[]}validateTag(e){return!0}getItems(e){return this.tags.filter(t=>t[0]===e)}get items(){return this.tags.filter(e=>!["d","L","l","title","name","description","published_at","summary","image","thumb","alt","expiration","subject","client"].includes(e[0]))}async addItem(e,t=void 0,n=!1,r="bottom"){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");let s;if(e instanceof NDKEvent)s=[e.tagReference(t)];else if(e instanceof NDKUser)s=e.referenceTags();else if(e instanceof NDKRelay)s=e.referenceTags();else{if(!Array.isArray(e))throw new Error("Invalid object type");s=[e]}if(t&&s[0].push(t),n){const e=await this.ndk.signer.user(),t=await this.encryptedTags();"top"===r?t.unshift(...s):t.push(...s),this._encryptedTags=t,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(t),await this.encrypt(e)}else"top"===r?this.tags.unshift(...s):this.tags.push(...s);this.created_at=Math.floor(Date.now()/1e3),this.emit("change")}async removeItemByValue(e,t=!0){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");const n=this.tags.findIndex(t=>t[1]===e);n>=0&&this.tags.splice(n,1);const r=await this.ndk.signer.user(),s=await this.encryptedTags(),i=s.findIndex(t=>t[1]===e);if(i>=0&&(s.splice(i,1),this._encryptedTags=s,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(s),await this.encrypt(r)),t)return this.publishReplaceable();this.created_at=Math.floor(Date.now()/1e3),this.emit("change")}async removeItem(e,t){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");if(t){const t=await this.ndk.signer.user(),n=await this.encryptedTags();n.splice(e,1),this._encryptedTags=n,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(n),await this.encrypt(t)}else this.tags.splice(e,1);return this.created_at=Math.floor(Date.now()/1e3),this.emit("change"),this}has(e){return this.items.some(t=>t[1]===e)}filterForItems(){const e=new Set,t=new Map,n=[];for(const n of this.items)if("e"===n[0]&&n[1])e.add(n[1]);else if("a"===n[0]&&n[1]){const[e,r,s]=n[1].split(":");if(!e||!r)continue;const i=`${e}:${r}`,o=t.get(i)||[];o.push(s||""),t.set(i,o)}if(e.size>0&&n.push({ids:Array.from(e)}),t.size>0)for(const[e,r]of t.entries()){const[t,s]=e.split(":");n.push({kinds:[Number.parseInt(t)],authors:[s],"#d":r})}return n}},NDKAppHandlerEvent=class e extends NDKEvent{profile;static kinds=[31990];constructor(e,t){super(e,t),this.kind??=31990}static from(t){const n=new e(t.ndk,t.rawEvent());return n.isValid?n:null}get isValid(){const e=new Map,t=e=>[e[0],e[2]].join(":").toLowerCase(),n=["web","android","ios"];for(const r of this.tags)if(n.includes(r[0])){const n=t(r);if(e.has(n)&&e.get(n)!==r[1].toLowerCase())return!1;e.set(n,r[1].toLowerCase())}return!0}async fetchProfile(){if(void 0===this.profile&&this.content.length>0)try{const e=JSON.parse(this.content);if(e?.name)return e;this.profile=null}catch(e){this.profile=null}return new Promise((e,t)=>{const n=this.author;n.fetchProfile().then(()=>{e(n.profile)}).catch(t)})}},NDKNutzap=class e extends NDKEvent{debug;_proofs=[];static kind=9321;static kinds=[e.kind];constructor(e,t){super(e,t),this.kind??=9321,this.debug=e?.debug.extend("nutzap")??createDebug5("ndk:nutzap"),this.alt||(this.alt="This is a nutzap");try{const e=this.getMatchingTags("proof");e.length?this._proofs=e.map(e=>JSON.parse(e[1])):this._proofs=JSON.parse(this.content)}catch{return}}static from(t){const n=new e(t.ndk,t);if(n._proofs&&n._proofs.length)return n}set comment(e){this.content=e??""}get comment(){const e=this.tagValue("comment");return e||this.content}set proofs(e){this._proofs=e,this.tags=this.tags.filter(e=>"proof"!==e[0]);for(const t of e)this.tags.push(["proof",JSON.stringify(t)])}get proofs(){return this._proofs}get rawP2pk(){const e=this.proofs[0];try{const t=JSON.parse(e.secret);let n;if("string"==typeof t?(n=JSON.parse(t),this.debug("stringified payload",e.secret)):"object"==typeof t&&(n=t),Array.isArray(n)&&"P2PK"===n[0]&&n.length>1&&"object"==typeof n[1]&&null!==n[1])return n[1].data;if("object"==typeof n&&null!==n&&"string"==typeof n[1]?.data)return n[1].data}catch(e){this.debug("error parsing p2pk pubkey",e,this.proofs[0])}}get p2pk(){const e=this.rawP2pk;if(e)return e.startsWith("02")?e.slice(2):e}get mint(){return this.tagValue("u")}set mint(e){this.replaceTag(["u",e])}get unit(){let e=this.tagValue("unit")??"sat";return e?.startsWith("msat")&&(e="sat"),e}set unit(e){if(this.removeTag("unit"),e?.startsWith("msat"))throw new Error("msat is not allowed, use sat denomination instead");e&&this.tag(["unit",e])}get amount(){return this.proofs.reduce((e,t)=>e+t.amount,0)}sender=this.author;set target(e){this.tags=this.tags.filter(e=>"p"!==e[0]),e instanceof NDKEvent&&this.tags.push(e.tagReference())}set recipientPubkey(e){this.removeTag("p"),this.tag(["p",e])}get recipientPubkey(){return this.tagValue("p")}get recipient(){const e=this.recipientPubkey;return this.ndk?this.ndk.getUser({pubkey:e}):new NDKUser({pubkey:e})}async toNostrEvent(){"msat"===this.unit&&(this.unit="sat"),this.removeTag("amount"),this.tags.push(["amount",this.amount.toString()]);const e=await super.toNostrEvent();return e.content=this.comment,e}get isValid(){let e=0,t=0,n=0;for(const r of this.tags)"e"===r[0]&&e++,"p"===r[0]&&t++,"u"===r[0]&&n++;return 1===t&&1===n&&e<=1&&this.proofs.length>0}},NDKProject=class e extends NDKEvent{static kind=31933;static kinds=[31933];_signer;constructor(e,t){super(e,t),this.kind=31933}static from(t){return new e(t.ndk,t.rawEvent())}set repo(e){this.removeTag("repo"),e&&this.tags.push(["repo",e])}set hashtags(e){this.removeTag("hashtags"),e.filter(e=>e.length>0).length&&this.tags.push(["hashtags",...e])}get hashtags(){const e=this.tags.find(e=>"hashtags"===e[0]);return e?e.slice(1):[]}get repo(){return this.tagValue("repo")}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get picture(){return this.tagValue("picture")}set picture(e){this.removeTag("picture"),e&&this.tags.push(["picture",e])}set description(e){this.content=e}get description(){return this.content}get slug(){return this.dTag??"empty-dtag"}async getSigner(){if(this._signer)return this._signer;const e=this.tagValue("key");if(e){const t=await(this.ndk?.signer?.decrypt(this.ndk.activeUser,e));if(!t)throw new Error("Failed to decrypt project key or missing signer context.");this._signer=new NDKPrivateKeySigner(t)}else this._signer=NDKPrivateKeySigner.generate(),await this.encryptAndSaveNsec();return this._signer}async getNsec(){return(await this.getSigner()).privateKey}async setNsec(e){this._signer=new NDKPrivateKeySigner(e),await this.encryptAndSaveNsec()}async encryptAndSaveNsec(){if(!this._signer)throw new Error("Signer is not set.");const e=this._signer.privateKey,t=await(this.ndk?.signer?.encrypt(this.ndk.activeUser,e));t&&(this.removeTag("key"),this.tags.push(["key",t]))}},NDKProjectTemplate=class e extends NDKEvent{static kind=30717;static kinds=[30717];constructor(e,t){super(e,t),this.kind=30717}static from(t){return new e(t.ndk,t.rawEvent())}get templateId(){return this.dTag??""}set templateId(e){this.dTag=e}get name(){return this.tagValue("title")??""}set name(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get description(){return this.tagValue("description")??""}set description(e){this.removeTag("description"),e&&this.tags.push(["description",e])}get repoUrl(){return this.tagValue("uri")??""}set repoUrl(e){this.removeTag("uri"),e&&this.tags.push(["uri",e])}get image(){return this.tagValue("image")}set image(e){this.removeTag("image"),e&&this.tags.push(["image",e])}get command(){return this.tagValue("command")}set command(e){this.removeTag("command"),e&&this.tags.push(["command",e])}get agentConfig(){const e=this.tagValue("agent");if(e)try{return JSON.parse(e)}catch{return}}set agentConfig(e){this.removeTag("agent"),e&&this.tags.push(["agent",JSON.stringify(e)])}get templateTags(){return this.getMatchingTags("t").map(e=>e[1]).filter(Boolean)}set templateTags(e){this.tags=this.tags.filter(e=>"t"!==e[0]),e.forEach(e=>{e&&this.tags.push(["t",e])})}},READ_MARKER="read",WRITE_MARKER="write",NDKRelayList=class e extends NDKEvent{static kinds=[10002];constructor(e,t){super(e,t),this.kind??=10002}static from(t){return new e(t.ndk,t.rawEvent())}get readRelayUrls(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).filter(e=>!e[2]||e[2]&&e[2]===READ_MARKER).map(e=>tryNormalizeRelayUrl(e[1])).filter(e=>!!e)}set readRelayUrls(e){for(const t of e)this.tags.push(["r",t,READ_MARKER])}get writeRelayUrls(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).filter(e=>!e[2]||e[2]&&e[2]===WRITE_MARKER).map(e=>tryNormalizeRelayUrl(e[1])).filter(e=>!!e)}set writeRelayUrls(e){for(const t of e)this.tags.push(["r",t,WRITE_MARKER])}get bothRelayUrls(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).filter(e=>!e[2]).map(e=>e[1])}set bothRelayUrls(e){for(const t of e)this.tags.push(["r",t])}get relays(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).map(e=>e[1])}get relaySet(){if(!this.ndk)throw new Error("NDKRelayList has no NDK instance");return new NDKRelaySet(new Set(this.relays.map(e=>this.ndk?.pool.getRelay(e)).filter(e=>!!e)),this.ndk)}};function relayListFromKind3(e,t){try{const n=JSON.parse(t.content),r=new NDKRelayList(e),s=new Set,i=new Set;for(let[e,t]of Object.entries(n)){try{e=normalizeRelayUrl(e)}catch{continue}if(t){const n=t;n.write&&i.add(e),n.read&&s.add(e)}else s.add(e),i.add(e)}return r.readRelayUrls=Array.from(s),r.writeRelayUrls=Array.from(i),r}catch{}}var NDKRepost=class e extends NDKEvent{_repostedEvents;static kinds=[6,16];static from(t){return new e(t.ndk,t.rawEvent())}async repostedEvents(e,t){const n=[];if(!this.ndk)throw new Error("NDK instance not set");if(void 0!==this._repostedEvents)return this._repostedEvents;for(const r of this.repostedEventIds()){const s=filterForId(r),i=await this.ndk.fetchEvent(s,t);i&&n.push(e?e.from(i):i)}return n}repostedEventIds(){return this.tags.filter(e=>"e"===e[0]||"a"===e[0]).map(e=>e[1])}};function filterForId(e){if(e.match(/:/)){const[t,n,r]=e.split(":");return{kinds:[Number.parseInt(t)],authors:[n],"#d":[r]}}return{ids:[e]}}var NDKSimpleGroupMemberList=class e extends NDKEvent{relaySet;memberSet=new Set;static kind=39002;static kinds=[39002];constructor(e,t){super(e,t),this.kind??=39002,this.memberSet=new Set(this.members)}static from(t){return new e(t.ndk,t)}get members(){return this.getMatchingTags("p").map(e=>e[1])}hasMember(e){return this.memberSet.has(e)}async publish(e,t,n){return e??=this.relaySet,super.publishReplaceable(e,t,n)}},NDKSimpleGroupMetadata=class e extends NDKEvent{static kind=39e3;static kinds=[39e3];constructor(e,t){super(e,t),this.kind??=39e3}static from(t){return new e(t.ndk,t)}get name(){return this.tagValue("name")}get picture(){return this.tagValue("picture")}get about(){return this.tagValue("about")}get scope(){return this.getMatchingTags("public").length>0?"public":this.getMatchingTags("public").length>0?"private":void 0}set scope(e){this.removeTag("public"),this.removeTag("private"),"public"===e?this.tags.push(["public",""]):"private"===e&&this.tags.push(["private",""])}get access(){return this.getMatchingTags("open").length>0?"open":this.getMatchingTags("closed").length>0?"closed":void 0}set access(e){this.removeTag("open"),this.removeTag("closed"),"open"===e?this.tags.push(["open",""]):"closed"===e&&this.tags.push(["closed",""])}};function strToPosition(e){const[t,n]=e.split(",").map(Number);return{x:t,y:n}}function strToDimension(e){const[t,n]=e.split("x").map(Number);return{width:t,height:n}}var NDKStorySticker=class e{static Text="text";static Pubkey="pubkey";static Event="event";static Prompt="prompt";static Countdown="countdown";type;value;position;dimension;properties;constructor(e){if(Array.isArray(e)){const t=e;if("sticker"!==t[0]||t.length<5)throw new Error("Invalid sticker tag");this.type=t[1],this.value=t[2],this.position=strToPosition(t[3]),this.dimension=strToDimension(t[4]);const n={};for(let e=5;e0&&(this.properties=n)}else this.type=e,this.value=void 0,this.position={x:0,y:0},this.dimension={width:0,height:0}}static fromTag(t){try{return new e(t)}catch{return null}}get style(){return this.properties?.style}set style(e){e?this.properties={...this.properties,style:e}:delete this.properties?.style}get rotation(){return this.properties?.rot?Number.parseFloat(this.properties.rot):void 0}set rotation(e){void 0!==e?this.properties={...this.properties,rot:e.toString()}:delete this.properties?.rot}get isValid(){return this.hasValidDimensions()&&this.hasValidPosition()}hasValidDimensions=()=>"number"==typeof this.dimension.width&&"number"==typeof this.dimension.height&&!Number.isNaN(this.dimension.width)&&!Number.isNaN(this.dimension.height);hasValidPosition=()=>"number"==typeof this.position.x&&"number"==typeof this.position.y&&!Number.isNaN(this.position.x)&&!Number.isNaN(this.position.y);toTag(){if(!this.isValid){const e=[this.hasValidDimensions()?void 0:"dimensions is invalid",this.hasValidPosition()?void 0:"position is invalid"].filter(Boolean);throw new Error(`Invalid sticker: ${e.join(", ")}`)}let e;switch(this.type){case"event":e=this.value.tagId();break;case"pubkey":e=this.value.pubkey;break;default:e=this.value}const t=["sticker",this.type,e,coordinates(this.position),dimension(this.dimension)];if(this.properties)for(const[e,n]of Object.entries(this.properties))t.push(`${e} ${n}`);return t}},NDKStory=class e extends NDKEvent{static kind=23;static kinds=[23];_imeta;_dimensions;constructor(e,t){if(super(e,t),this.kind??=23,t)for(const e of t.tags)switch(e[0]){case"imeta":this._imeta=mapImetaTag(e);break;case"dim":this.dimensions=strToDimension(e[1])}}static from(t){return new e(t.ndk,t)}get isValid(){return!!this.imeta}get imeta(){return this._imeta}set imeta(e){this._imeta=e,this.tags=this.tags.filter(e=>"imeta"!==e[0]),e&&this.tags.push(imetaTagToTag(e))}get dimensions(){const e=this.tagValue("dim");if(e)return strToDimension(e)}set dimensions(e){this.removeTag("dim"),e&&this.tags.push(["dim",`${e.width}x${e.height}`])}get duration(){const e=this.tagValue("dur");if(e)return Number.parseInt(e)}set duration(e){this.removeTag("dur"),void 0!==e&&this.tags.push(["dur",e.toString()])}get stickers(){const e=[];for(const t of this.tags){if("sticker"!==t[0]||t.length<5)continue;const n=NDKStorySticker.fromTag(t);n&&e.push(n)}return e}addSticker(e){let t;if(e instanceof NDKStorySticker)t=e;else{const n=["sticker",e.type,"string"==typeof e.value?e.value:"",coordinates(e.position),dimension(e.dimension)];if(e.properties)for(const[t,r]of Object.entries(e.properties))n.push(`${t} ${r}`);t=new NDKStorySticker(n),t.value=e.value}("pubkey"===t.type||"event"===t.type)&&this.tag(t.value),this.tags.push(t.toTag())}removeSticker(e){const t=this.stickers;if(e<0||e>=t.length)return;let n=0;for(let t=0;t`${e.x},${e.y}`,dimension=e=>`${e.width}x${e.height}`,NDKSubscriptionReceipt=class e extends NDKEvent{debug;static kinds=[7003];constructor(e,t){super(e,t),this.kind??=7003,this.debug=e?.debug.extend("subscription-start")??createDebug5("ndk:subscription-start")}static from(t){return new e(t.ndk,t.rawEvent())}get recipient(){const e=this.getMatchingTags("p")?.[0];if(!e)return;return new NDKUser({pubkey:e[1]})}set recipient(e){this.removeTag("p"),e&&this.tags.push(["p",e.pubkey])}get subscriber(){const e=this.getMatchingTags("P")?.[0];if(!e)return;return new NDKUser({pubkey:e[1]})}set subscriber(e){this.removeTag("P"),e&&this.tags.push(["P",e.pubkey])}set subscriptionStart(e){this.debug(`before setting subscription start: ${this.rawEvent}`),this.removeTag("e"),this.tag(e,"subscription",!0),this.debug(`after setting subscription start: ${this.rawEvent}`)}get tierName(){const e=this.getMatchingTags("tier")?.[0];return e?.[1]}get isValid(){const e=this.validPeriod;if(!e)return!1;if(e.start>e.end)return!1;const t=this.getMatchingTags("p"),n=this.getMatchingTags("P");return 1===t.length&&1===n.length}get validPeriod(){const e=this.getMatchingTags("valid")?.[0];if(e)try{return{start:new Date(1e3*Number.parseInt(e[1])),end:new Date(1e3*Number.parseInt(e[2]))}}catch{return}}set validPeriod(e){this.removeTag("valid"),e&&this.tags.push(["valid",Math.floor(e.start.getTime()/1e3).toString(),Math.floor(e.end.getTime()/1e3).toString()])}get startPeriod(){return this.validPeriod?.start}get endPeriod(){return this.validPeriod?.end}isActive(e){e??=new Date;const t=this.validPeriod;return!!t&&(!(et.end))}},possibleIntervalFrequencies=["daily","weekly","monthly","quarterly","yearly"];function newAmount(e,t,n){return["amount",e.toString(),t,n]}function parseTagToSubscriptionAmount(e){const t=Number.parseInt(e[1]);if(Number.isNaN(t)||null==t||t<=0)return;const n=e[2];if(void 0===n||""===n)return;const r=e[3];return void 0!==r&&possibleIntervalFrequencies.includes(r)?{amount:t,currency:n,term:r}:void 0}var NDKSubscriptionTier=class e extends NDKArticle{static kind=37001;static kinds=[37001];constructor(e,t){const n=t?.kind??37001;super(e,t),this.kind=n}static from(t){return new e(t.ndk,t)}get perks(){return this.getMatchingTags("perk").map(e=>e[1]).filter(e=>void 0!==e)}addPerk(e){this.tags.push(["perk",e])}get amounts(){return this.getMatchingTags("amount").map(e=>parseTagToSubscriptionAmount(e)).filter(e=>void 0!==e)}addAmount(e,t,n){this.tags.push(newAmount(e,t,n))}set relayUrl(e){this.tags.push(["r",e])}get relayUrls(){return this.getMatchingTags("r").map(e=>e[1]).filter(e=>void 0!==e)}get verifierPubkey(){return this.tagValue("p")}set verifierPubkey(e){this.removeTag("p"),e&&this.tags.push(["p",e])}get isValid(){return void 0!==this.title&&this.amounts.length>0}},NDKSubscriptionStart=class e extends NDKEvent{debug;static kinds=[7001];constructor(e,t){super(e,t),this.kind??=7001,this.debug=e?.debug.extend("subscription-start")??createDebug5("ndk:subscription-start")}static from(t){return new e(t.ndk,t.rawEvent())}get recipient(){const e=this.getMatchingTags("p")?.[0];if(!e)return;return new NDKUser({pubkey:e[1]})}set recipient(e){this.removeTag("p"),e&&this.tags.push(["p",e.pubkey])}get amount(){const e=this.getMatchingTags("amount")?.[0];if(e)return parseTagToSubscriptionAmount(e)}set amount(e){this.removeTag("amount"),e&&this.tags.push(newAmount(e.amount,e.currency,e.term))}get tierId(){const e=this.getMatchingTags("e")?.[0],t=this.getMatchingTags("a")?.[0];if(e&&t)return e[1]??t[1]}set tier(e){this.removeTag("e"),this.removeTag("a"),this.removeTag("event"),e&&(this.tag(e),this.removeTag("p"),this.tags.push(["p",e.pubkey]),this.tags.push(["event",JSON.stringify(e.rawEvent())]))}async fetchTier(){const e=this.tagValue("event");if(e)try{const t=JSON.parse(e);return new NDKSubscriptionTier(this.ndk,t)}catch{this.debug("Failed to parse event tag")}const t=this.tierId;if(!t)return;const n=await(this.ndk?.fetchEvent(t));return n?NDKSubscriptionTier.from(n):void 0}get isValid(){return 1!==this.getMatchingTags("amount").length?(this.debug("Invalid # of amount tag"),!1):this.amount?1!==this.getMatchingTags("p").length?(this.debug("Invalid # of p tag"),!1):!!this.recipient||(this.debug("Invalid p tag"),!1):(this.debug("Invalid amount tag"),!1)}},NDKTask=class e extends NDKEvent{static kind=1934;static kinds=[1934];constructor(e,t){super(e,t),this.kind=1934}static from(t){return new e(t.ndk,t.rawEvent())}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get title(){return this.tagValue("title")}set project(e){this.removeTag("a"),this.tags.push(e.tagReference())}get projectSlug(){const e=this.getMatchingTags("a")[0];return e?e[1].split(/:/)?.[2]:void 0}},NDKThread=class e extends NDKEvent{static kind=11;static kinds=[11];constructor(e,t){super(e,t),this.kind??=11}static from(t){return new e(t.ndk,t)}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}},NDKVideo=class e extends NDKEvent{static kind=21;static kinds=[34235,34236,22,21];_imetas;static from(t){return new e(t.ndk,t.rawEvent())}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get thumbnail(){let e;return this.imetas&&this.imetas.length>0&&(e=this.imetas[0].image?.[0]),e??this.tagValue("thumb")}get imetas(){return this._imetas||(this._imetas=this.tags.filter(e=>"imeta"===e[0]).map(mapImetaTag)),this._imetas}set imetas(e){this._imetas=e,this.tags=this.tags.filter(e=>"imeta"!==e[0]),this.tags.push(...e.map(imetaTagToTag))}get url(){return this.imetas&&this.imetas.length>0?this.imetas[0].url:this.tagValue("url")}get published_at(){const e=this.tagValue("published_at");if(e)return Number.parseInt(e)}async generateTags(){if(super.generateTags(),!this.kind&&this.imetas?.[0]?.dim){const[e,t]=this.imetas[0].dim.split("x"),n=e&&t&&Number.parseInt(e)"a"===e[0]||("e"===e[0]&&"source"!==e[3]||void 0)),this.tag(e)}get sourceId(){return this.tagValue("e","source")}set source(e){this.removeTag("e","source"),this.tag(e,"source",!1,"e")}},registeredEventClasses=new Set;function wrapEvent(e){const t=new Map,n=[...[NDKImage,NDKVideo,NDKCashuMintList,NDKArticle,NDKHighlight,NDKDraft,NDKWiki,NDKWikiMergeRequest,NDKNutzap,NDKProject,NDKTask,NDKProjectTemplate,NDKSimpleGroupMemberList,NDKSimpleGroupMetadata,NDKSubscriptionTier,NDKSubscriptionStart,NDKSubscriptionReceipt,NDKList,NDKRelayList,NDKStory,NDKBlossomList,NDKFollowPack,NDKThread,NDKRepost,NDKClassified,NDKAppHandlerEvent,NDKDVMJobFeedback,NDKCashuMintAnnouncement,NDKFedimintMint,NDKMintRecommendation],...registeredEventClasses];for(const e of n)for(const n of e.kinds)t.set(n,e);const r=t.get(e.kind);return r?r.from(e):e}function queryFullyFilled(e){return!(!filterIncludesIds(e.filter)||!resultHasAllRequestedIds(e))}function filterIncludesIds(e){return!!e.ids}function resultHasAllRequestedIds(e){const t=e.filter.ids;return!!t&&t.length===e.eventFirstSeen.size}function filterFromId(e){let t;if(e.match(NIP33_A_REGEX)){const[t,n,r]=e.split(":"),s={authors:[n],kinds:[Number.parseInt(t)]};return r&&(s["#d"]=[r]),s}if(e.match(BECH32_REGEX))try{switch(t=nip19_exports$1.decode(e),t.type){case"nevent":{const e={ids:[t.data.id]};return t.data.author&&(e.authors=[t.data.author]),t.data.kind&&(e.kinds=[t.data.kind]),e}case"note":return{ids:[t.data]};case"naddr":{const e={authors:[t.data.pubkey],kinds:[t.data.kind]};return t.data.identifier&&(e["#d"]=[t.data.identifier]),e}}}catch(t){console.error("Error decoding",e,t)}return{ids:[e]}}function isNip33AValue(e){return null!==e.match(NIP33_A_REGEX)}var NIP33_A_REGEX=/^(\d+):([0-9A-Fa-f]+)(?::(.*))?$/,BECH32_REGEX=/^n(event|ote|profile|pub|addr)1[\d\w]+$/;function relaysFromBech32(e,t){try{const n=nip19_exports$1.decode(e);if(["naddr","nevent"].includes(n?.type)){const e=n.data;if(e?.relays)return e.relays.map(e=>new NDKRelay(e,t.relayAuthDefaultPolicy,t))}}catch(e){}return[]}var defaultOpts={closeOnEose:!1,cacheUsage:"CACHE_FIRST",dontSaveToCache:!1,groupable:!0,groupableDelay:100,groupableDelayType:"at-most",cacheUnconstrainFilter:["limit","since","until"],includeMuted:!1},NDKSubscription=class extends lib$1.EventEmitter{subId;filters;opts;pool;skipVerification=!1;skipValidation=!1;relayFilters;relaySet;ndk;debug;eventFirstSeen=new Map;eosesSeen=new Set;lastEventReceivedAt;mostRecentCacheEventTimestamp;internalId;closeOnEose;poolMonitor;skipOptimisticPublishEvent=!1;cacheUnconstrainFilter;constructor(e,t,n,r){super(),this.ndk=e,this.opts={...defaultOpts,...n||{}},this.pool=this.opts.pool||e.pool;const s=Array.isArray(t)?t:[t],i="validate"===e.filterValidationMode?"validate":"fix"===e.filterValidationMode?"fix":"ignore";if(this.filters=processFilters(s,i,e.debug,e),0===this.filters.length)throw new Error("Subscription must have at least one filter");this.subId=r||this.opts.subId,this.internalId=Math.random().toString(36).substring(7),this.debug=e.debug.extend(`subscription[${this.opts.subId??this.internalId}]`),this.opts.relaySet?this.relaySet=this.opts.relaySet:this.opts.relayUrls&&(this.relaySet=NDKRelaySet.fromRelayUrls(this.opts.relayUrls,this.ndk)),this.skipVerification=this.opts.skipVerification||!1,this.skipValidation=this.opts.skipValidation||!1,this.closeOnEose=this.opts.closeOnEose||!1,this.skipOptimisticPublishEvent=this.opts.skipOptimisticPublishEvent||!1,this.cacheUnconstrainFilter=this.opts.cacheUnconstrainFilter,this.opts.onEvent&&this.on("event",this.opts.onEvent),this.opts.onEose&&this.on("eose",this.opts.onEose),this.opts.onClose&&this.on("close",this.opts.onClose)}relaysMissingEose(){if(!this.relayFilters)return[];return Array.from(this.relayFilters?.keys()).filter(e=>!this.eosesSeen.has(this.pool.getRelay(e,!1,!1)))}get filter(){return this.filters[0]}get groupableDelay(){if(this.isGroupable())return this.opts?.groupableDelay}get groupableDelayType(){return this.opts?.groupableDelayType||"at-most"}isGroupable(){return this.opts?.groupable||!1}shouldQueryCache(){if(this.opts.addSinceFromCache)return!0;if("ONLY_RELAY"===this.opts?.cacheUsage)return!1;this.filters.some(e=>e.kinds?.some(e=>kindIsEphemeral(e)));return!0}shouldQueryRelays(){return"ONLY_CACHE"!==this.opts?.cacheUsage}shouldWaitForCache(){return!!this.opts.addSinceFromCache||!!this.opts.closeOnEose&&!!this.ndk.cacheAdapter?.locking&&"PARALLEL"!==this.opts.cacheUsage}start(e=!0){let t;const n=n=>{for(const e of n)e.created_at&&(!this.mostRecentCacheEventTimestamp||e.created_at>this.mostRecentCacheEventTimestamp)&&(this.mostRecentCacheEventTimestamp=e.created_at),this.eventReceived(e,void 0,!0,!1);e||(t=n)},r=()=>{this.shouldQueryRelays()?(this.startWithRelays(),this.startPoolMonitor()):this.emit("eose",this)};return this.shouldQueryCache()?(t=this.startWithCache(),t instanceof Promise?this.shouldWaitForCache()?(t.then(e=>{n(e),queryFullyFilled(this)?this.emit("eose",this):r()}),null):(t.then(e=>{n(e),this.shouldQueryRelays()||this.emit("eose",this)}),this.shouldQueryRelays()&&r(),null):(n(t),queryFullyFilled(this)?this.emit("eose",this):r(),t)):(r(),null)}startPoolMonitor(){this.debug.extend("pool-monitor"),this.poolMonitor=e=>{if(this.relayFilters?.has(e.url))return;calculateRelaySetsFromFilters(this.ndk,this.filters,this.pool,this.opts.relayGoalPerAuthor).get(e.url)&&(this.relayFilters?.set(e.url,this.filters),e.subscribe(this,this.filters))},this.pool.on("relay:connect",this.poolMonitor)}onStopped;stop(){this.emit("close",this),this.poolMonitor&&this.pool.off("relay:connect",this.poolMonitor),this.onStopped?.()}hasAuthorsFilter(){return this.filters.some(e=>e.authors?.length)}startWithCache(){return this.ndk.cacheAdapter?.query?this.ndk.cacheAdapter.query(this):[]}startWithRelays(){let e=this.filters;if(this.opts.addSinceFromCache&&this.mostRecentCacheEventTimestamp){const t=this.mostRecentCacheEventTimestamp+1;e=e.map(e=>({...e,since:Math.max(e.since||0,t)}))}if(this.relaySet&&0!==this.relaySet.relays.size){this.relayFilters=new Map;for(const t of this.relaySet.relays)this.relayFilters.set(t.url,e)}else this.relayFilters=calculateRelaySetsFromFilters(this.ndk,e,this.pool,this.opts.relayGoalPerAuthor);for(const[e,t]of this.relayFilters){this.pool.getRelay(e,!0,!0,t).subscribe(this,t)}}refreshRelayConnections(){if(this.relaySet&&this.relaySet.relays.size>0)return;const e=calculateRelaySetsFromFilters(this.ndk,this.filters,this.pool,this.opts.relayGoalPerAuthor);for(const[t,n]of e)if(!this.relayFilters?.has(t)){this.relayFilters?.set(t,n);this.pool.getRelay(t,!0,!0,n).subscribe(this,n)}}eventReceived(e,t,n=!1,r=!1){const s=e.id,i=this.eventFirstSeen.has(s);let o;if(e instanceof NDKEvent&&(o=e),i){const i=Date.now()-(this.eventFirstSeen.get(s)||0);if(this.emit("event:dup",e,t,i,this,n,r),this.opts?.onEventDup&&this.opts.onEventDup(e,t,i,this,n,r),n||r||!t||!this.ndk.cacheAdapter?.setEventDup||this.opts.dontSaveToCache||(o??=e instanceof NDKEvent?e:new NDKEvent(this.ndk,e),this.ndk.cacheAdapter.setEventDup(o,t)),t){const n=verifiedSignatures.get(s);if(n&&"string"==typeof n)if(e.sig===n)t.addValidatedEvent();else{const n=e instanceof NDKEvent?e:new NDKEvent(this.ndk,e);this.ndk.reportInvalidSignature(n,t)}}}else{if(o??=new NDKEvent(this.ndk,e),o.ndk=this.ndk,o.relay=t,!n&&!r){if(!this.skipValidation&&!o.isValid)return void this.debug("Event failed validation %s from relay %s",s,t?.url);if(t){if(t.shouldValidateEvent()&&!this.skipVerification)if(o.relay=t,this.ndk.asyncSigVerification)o.verifySignature(!0);else{if(!o.verifySignature(!0))return this.debug("Event failed signature validation",e),void this.ndk.reportInvalidSignature(o,t);t.addValidatedEvent()}else t.addNonValidatedEvent()}this.ndk.cacheAdapter&&!this.opts.dontSaveToCache&&this.ndk.cacheAdapter.setEvent(o,this.filters,t)}if(!this.opts.includeMuted&&this.ndk.muteFilter&&this.ndk.muteFilter(o))return void this.debug("Event muted, skipping");r&&!0===this.skipOptimisticPublishEvent||(this.emitEvent(this.opts?.wrap??!1,o,t,n,r),this.eventFirstSeen.set(s,Date.now()))}this.lastEventReceivedAt=Date.now()}emitEvent(e,t,n,r,s){const i=e?wrapEvent(t):t;i instanceof Promise?i.then(e=>this.emitEvent(!1,e,n,r,s)):i&&this.emit("event",i,n,this,r,s)}closedReceived(e,t){this.emit("closed",e,t)}eoseTimeout;eosed=!1;eoseReceived(e){this.debug("EOSE received from %s",e.url),this.eosesSeen.add(e);let t=this.lastEventReceivedAt?Date.now()-this.lastEventReceivedAt:void 0;const n=this.eosesSeen.size===this.relayFilters?.size,r=queryFullyFilled(this),s=e=>{this.debug("Performing EOSE: %s %d",e,this.eosed),this.eosed||(this.eoseTimeout&&clearTimeout(this.eoseTimeout),this.emit("eose",this),this.eosed=!0,this.opts?.closeOnEose&&this.stop())};if(r||n)s("query filled or seen all");else if(this.relayFilters){let e=1e3;const n=new Set(this.pool.connectedRelays().map(e=>e.url)),r=Array.from(this.relayFilters.keys()).filter(e=>n.has(e));if(0===r.length)return void this.debug("No connected relays, waiting for all relays to connect",Array.from(this.relayFilters.keys()).join(", "));const i=this.eosesSeen.size/r.length;if(this.debug("Percentage of relays that have sent EOSE",{subId:this.subId,percentageOfRelaysThatHaveSentEose:i,seen:this.eosesSeen.size,total:r.length}),this.eosesSeen.size>=2&&i>=.5){if(e*=1-i,0===e)return void s("time to wait was 0");this.eoseTimeout&&clearTimeout(this.eoseTimeout);const n=()=>{t=this.lastEventReceivedAt?Date.now()-this.lastEventReceivedAt:void 0,void 0!==t&&t<20?this.eoseTimeout=setTimeout(n,e):s(`send eose timeout: ${e}`)};this.eoseTimeout=setTimeout(n,e)}}}},kindIsEphemeral=e=>e>=2e4&&e<3e4;async function follows(e,t,n=3){if(!this.ndk)throw new Error("NDK not set");const r=await this.ndk.fetchEvent({kinds:[n],authors:[this.pubkey]},e||{groupable:!1});if(r){const e=new Set;return r.tags.forEach(t=>{"p"===t[0]&&t[1]&&isValidPubkey(t[1])&&e.add(t[1])}),t&&this.ndk?.outboxTracker?.trackUsers(Array.from(e)),[...e].reduce((e,t)=>{const n=new NDKUser({pubkey:t});return n.ndk=this.ndk,e.add(n),e},new Set)}return new Set}var NIP05_REGEX=/^(?:([\w.+-]+)@)?([\w.-]+)$/;async function getNip05For(e,t,n=fetch,r={}){return await e.queuesNip05.add({id:t,func:async()=>{if(e.cacheAdapter?.loadNip05){const n=await e.cacheAdapter.loadNip05(t);if("missing"!==n){if(n){const t=new NDKUser({pubkey:n.pubkey,relayUrls:n.relays,nip46Urls:n.nip46});return t.ndk=e,t}if("no-cache"!==r.cache)return null}}const s=t.match(NIP05_REGEX);if(!s)return null;const[i,o="_",a]=s;try{const s=await n(`https://${a}/.well-known/nostr.json?name=${o}`,r),{names:i,relays:c,nip46:l}=parseNIP05Result(await s.json()),u=i[o.toLowerCase()];let d=null;return u&&(d={pubkey:u,relays:c?.[u],nip46:l?.[u]}),e?.cacheAdapter?.saveNip05&&e.cacheAdapter.saveNip05(t,d),d}catch(n){return e?.cacheAdapter?.saveNip05&&e?.cacheAdapter.saveNip05(t,null),console.error("Failed to fetch NIP05 for",t,n),null}}})}function parseNIP05Result(e){const t={names:{}};for(const[n,r]of Object.entries(e.names))"string"==typeof n&&"string"==typeof r&&(t.names[n.toLowerCase()]=r);if(e.relays){t.relays={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.relays[n]=r.filter(e=>"string"==typeof e))}if(e.nip46){t.nip46={};for(const[n,r]of Object.entries(e.nip46))"string"==typeof n&&Array.isArray(r)&&(t.nip46[n]=r.filter(e=>"string"==typeof e))}return t}function profileFromEvent(e){const t={};let n;try{n=JSON.parse(e.content)}catch(e){throw new Error(`Failed to parse profile event: ${e}`)}t.profileEvent=JSON.stringify(e.rawEvent());for(const e of Object.keys(n))switch(e){case"name":t.name=n.name;break;case"display_name":t.displayName=n.display_name;break;case"image":case"picture":t.picture=n.picture||n.image,t.image=t.picture;break;case"banner":t.banner=n.banner;break;case"bio":t.bio=n.bio;break;case"nip05":t.nip05=n.nip05;break;case"lud06":t.lud06=n.lud06;break;case"lud16":t.lud16=n.lud16;break;case"about":t.about=n.about;break;case"website":t.website=n.website;break;default:t[e]=n[e]}return t.created_at=e.created_at,t}function serializeProfile(e){const t={};for(const[n,r]of Object.entries(e))switch(n){case"username":case"name":t.name=r;break;case"displayName":t.display_name=r;break;case"image":case"picture":t.picture=r;break;case"bio":case"about":t.about=r;break;default:t[n]=r}return JSON.stringify(t)}var NDKUser=class e{ndk;profile;profileEvent;_npub;_pubkey;relayUrls=[];nip46Urls=[];constructor(e){if(e.npub&&(this._npub=e.npub),e.hexpubkey&&(this._pubkey=e.hexpubkey),e.pubkey&&(this._pubkey=e.pubkey),e.relayUrls&&(this.relayUrls=e.relayUrls),e.nip46Urls&&(this.nip46Urls=e.nip46Urls),e.nprofile)try{const t=nip19_exports$1.decode(e.nprofile);"nprofile"===t.type&&(this._pubkey=t.data.pubkey,t.data.relays&&t.data.relays.length>0&&this.relayUrls.push(...t.data.relays))}catch(e){console.error("Failed to decode nprofile",e)}}get npub(){if(!this._npub){if(!this._pubkey)throw new Error("pubkey not set");this._npub=nip19_exports$1.npubEncode(this.pubkey)}return this._npub}get nprofile(){const e=this.profileEvent?.onRelays?.map(e=>e.url);return nip19_exports$1.nprofileEncode({pubkey:this.pubkey,relays:e})}set npub(e){this._npub=e}get pubkey(){if(!this._pubkey){if(!this._npub)throw new Error("npub not set");this._pubkey=nip19_exports$1.decode(this.npub).data}return this._pubkey}set pubkey(e){this._pubkey=e}filter(){return{"#p":[this.pubkey]}}async getZapInfo(e){if(!this.ndk)throw new Error("No NDK instance found");const t=async t=>{if(!e)return t;let n;const r=new Promise((t,r)=>{n=setTimeout(()=>r(new Error("Timeout")),e)});try{const e=await Promise.race([t,r]);return n&&clearTimeout(n),e}catch(e){if(e instanceof Error&&"Timeout"===e.message)try{return await t}catch(e){return}return}},[n,r]=await Promise.all([t(this.fetchProfile()),t(this.ndk.fetchEvent({kinds:[10019],authors:[this.pubkey]}))]),s=new Map;if(r){const e=NDKCashuMintList.from(r);e.mints.length>0&&s.set("nip61",{mints:e.mints,relays:e.relays,p2pk:e.p2pk})}if(n){const{lud06:e,lud16:t}=n;s.set("nip57",{lud06:e,lud16:t})}return s}static async fromNip05(t,n,r=!1){if(!n)throw new Error("No NDK instance found");const s={};r&&(s.cache="no-cache");const i=await getNip05For(n,t,n?.httpFetch,s);if(i){const t=new e({pubkey:i.pubkey,relayUrls:i.relays,nip46Urls:i.nip46});return t.ndk=n,t}}async fetchProfile(e,t=!1){if(!this.ndk)throw new Error("NDK not set");let n=null;if(this.ndk.cacheAdapter&&(this.ndk.cacheAdapter.fetchProfile||this.ndk.cacheAdapter.fetchProfileSync)&&"ONLY_RELAY"!==e?.cacheUsage){let e=null;if(this.ndk.cacheAdapter.fetchProfileSync?e=this.ndk.cacheAdapter.fetchProfileSync(this.pubkey):this.ndk.cacheAdapter.fetchProfile&&(e=await this.ndk.cacheAdapter.fetchProfile(this.pubkey)),e)return this.profile=e,e}return e??={},e.cacheUsage??="ONLY_RELAY",e.closeOnEose??=!0,e.groupable??=!0,e.groupableDelay??=250,n||(n=await this.ndk.fetchEvent({kinds:[0],authors:[this.pubkey]},e)),n?(this.profile=profileFromEvent(n),t&&this.profile&&this.ndk.cacheAdapter&&this.ndk.cacheAdapter.saveProfile&&this.ndk.cacheAdapter.saveProfile(this.pubkey,this.profile),this.profile):null}follows=follows.bind(this);async followSet(e,t,n=3){const r=await this.follows(e,t,n);return new Set(Array.from(r).map(e=>e.pubkey))}tagReference(){return["p",this.pubkey]}referenceTags(e){const t=[["p",this.pubkey]];return e?(t[0].push("",e),t):t}async publish(){if(!this.ndk)throw new Error("No NDK instance found");if(!this.profile)throw new Error("No profile available");this.ndk.assertSigner();const e=new NDKEvent(this.ndk,{kind:0,content:serializeProfile(this.profile)});await e.publish()}async follow(e,t,n=3){if(!this.ndk)throw new Error("No NDK instance found");if(this.ndk.assertSigner(),t||(t=await this.follows(void 0,void 0,n)),t.has(e))return!1;t.add(e);const r=new NDKEvent(this.ndk,{kind:n});for(const e of t)r.tag(e);return await r.publish(),!0}async unfollow(e,t,n=3){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),t||(t=await this.follows(void 0,void 0,n));const r=new Set;let s=!1;for(const n of t)n.pubkey!==e.pubkey?r.add(n):s=!0;if(!s)return!1;const i=new NDKEvent(this.ndk,{kind:n});for(const e of r)i.tag(e);return await i.publish()}async validateNip05(e){if(!this.ndk)throw new Error("No NDK instance found");const t=await getNip05For(this.ndk,e);return null===t?null:t.pubkey===this.pubkey}},signerRegistry=new Map;function registerSigner(e,t){signerRegistry.set(e,t)}var NDKPrivateKeySigner=class e{_user;_privateKey;_pubkey;constructor(e,t){if("string"==typeof e)if(e.startsWith("nsec1")){const{type:t,data:n}=nip19_exports$1.decode(e);if("nsec"!==t)throw new Error("Invalid private key provided.");this._privateKey=n}else{if(64!==e.length)throw new Error("Invalid private key provided.");this._privateKey=hexToBytes(e)}else this._privateKey=e;this._pubkey=getPublicKey(this._privateKey),t&&(this._user=t.getUser({pubkey:this._pubkey})),this._user??=new NDKUser({pubkey:this._pubkey})}get privateKey(){if(!this._privateKey)throw new Error("Not ready");return bytesToHex(this._privateKey)}get pubkey(){if(!this._pubkey)throw new Error("Not ready");return this._pubkey}get nsec(){if(!this._privateKey)throw new Error("Not ready");return nip19_exports$1.nsecEncode(this._privateKey)}get npub(){if(!this._pubkey)throw new Error("Not ready");return nip19_exports$1.npubEncode(this._pubkey)}encryptToNcryptsec(e,t=16,n=2){if(!this._privateKey)throw new Error("Private key not available");return encrypt$1(this._privateKey,e,t,n)}static generate(){const t=generateSecretKey();return new e(t)}static fromNcryptsec(t,n,r){const s=decrypt$1(t,n);return new e(s,r)}async blockUntilReady(){return this._user}async user(){return this._user}get userSync(){return this._user}async sign(e){if(!this._privateKey)throw Error("Attempted to sign without a private key");return finalizeEvent(e,this._privateKey).sig}async encryptionEnabled(e){const t=[];return e&&"nip04"!==e||t.push("nip04"),e&&"nip44"!==e||t.push("nip44"),t}async encrypt(e,t,n){if(!this._privateKey||!this.privateKey)throw Error("Attempted to encrypt without a private key");const r=e.pubkey;if("nip44"===n){const e=nip44_exports.v2.utils.getConversationKey(this._privateKey,r);return await nip44_exports.v2.encrypt(t,e)}return await nip04_exports.encrypt(this._privateKey,r,t)}async decrypt(e,t,n){if(!this._privateKey||!this.privateKey)throw Error("Attempted to decrypt without a private key");const r=e.pubkey;if("nip44"===n){const e=nip44_exports.v2.utils.getConversationKey(this._privateKey,r);return await nip44_exports.v2.decrypt(t,e)}return await nip04_exports.decrypt(this._privateKey,r,t)}toPayload(){if(!this._privateKey)throw new Error("Private key not available");const e={type:"private-key",payload:this.privateKey};return JSON.stringify(e)}static async fromPayload(t,n){const r=JSON.parse(t);if("private-key"!==r.type)throw new Error(`Invalid payload type: expected 'private-key', got ${r.type}`);if(!r.payload||"string"!=typeof r.payload)throw new Error("Invalid payload content for private-key signer");return new e(r.payload,n)}};function dedup(e,t){return e.created_at>t.created_at?e:t}async function getRelayListForUser(e,t){return(await getRelayListForUsers([e],t)).get(e)}async function getRelayListForUsers(e,t,n=!1,r=1e3,s){const i=t.outboxPool||t.pool,o=new Set;for(const e of i.relays.values())o.add(e);if(s)for(const e of s.values())for(const t of e){const e=i.getRelay(t,!0,!0);e&&o.add(e)}const a=new Map,c=new Map,l=new NDKRelaySet(o,t);if(t.cacheAdapter?.locking&&!n){const n=await t.fetchEvents({kinds:[3,10002],authors:Array.from(new Set(e))},{cacheUsage:"ONLY_CACHE",subId:"ndk-relay-list-fetch"});for(const e of n)10002===e.kind&&a.set(e.pubkey,NDKRelayList.from(e));for(const e of n)if(3===e.kind){if(a.has(e.pubkey))continue;const n=relayListFromKind3(t,e);n&&c.set(e.pubkey,n)}e=e.filter(e=>!a.has(e)&&!c.has(e))}if(0===e.length)return a;const u=new Map,d=new Map;return new Promise(n=>{let s=!1;(async()=>{const c={closeOnEose:!0,pool:i,groupable:!0,subId:"ndk-relay-list-fetch",addSinceFromCache:!0,relaySet:l};l&&(c.relaySet=l),t.subscribe({kinds:[3,10002],authors:e},c,{onEvent:e=>{if(10002===e.kind){const t=u.get(e.pubkey);if(t&&t.created_at>e.created_at)return;u.set(e.pubkey,e)}else if(3===e.kind){const t=d.get(e.pubkey);if(t&&t.created_at>e.created_at)return;d.set(e.pubkey,e)}},onEose:()=>{if(!s){s=!0,t.debug(`[getRelayListForUsers] EOSE - relayListEvents: ${u.size}, contactListEvents: ${d.size}`);for(const e of u.values())a.set(e.pubkey,NDKRelayList.from(e));for(const n of e){if(a.has(n))continue;const e=d.get(n);if(!e)continue;const r=relayListFromKind3(t,e);r&&a.set(n,r)}t.debug(`[getRelayListForUsers] Returning ${a.size} relay lists for ${e.length} pubkeys`),n(a)}}});const h=Array.from(o).some(e=>e.status<=2),p=Array.from(o).some(e=>4===e.status);let f=r;(h||p)&&(f=r+3e3),t.debug(`[getRelayListForUsers] Setting fallback timeout to ${f}ms (disconnected: ${h}, connecting: ${p})`,{pubkeys:e}),setTimeout(()=>{s||(s=!0,t.debug(`[getRelayListForUsers] Timeout reached, returning ${a.size} relay lists`),n(a))},f)})()})}registerSigner("private-key",NDKPrivateKeySigner);var OutboxItem=class{type;relayUrlScores;readRelays;writeRelays;constructor(e){this.type=e,this.relayUrlScores=new Map,this.readRelays=new Set,this.writeRelays=new Set}},OutboxTracker=class extends lib$1.EventEmitter{data;ndk;debug;constructor(e){super(),this.ndk=e,this.debug=e.debug.extend("outbox-tracker"),this.data=new dist.LRUCache({maxSize:1e5,entryExpirationTimeInMS:12e4})}async trackUsers(e,t=!1){const n=[];for(let r=0;rgetKeyFromItem(e)).filter(e=>!this.data.has(e));if(0===i.length)continue;for(const e of i)this.data.set(e,new OutboxItem("user"));const o=new Map;for(const e of s)e instanceof NDKUser&&e.relayUrls.length>0&&o.set(e.pubkey,e.relayUrls);n.push(new Promise(e=>{getRelayListForUsers(i,this.ndk,t,1e3,o).then(e=>{this.debug(`Received relay lists for ${e.size} pubkeys out of ${i.length} requested`);for(const[t,n]of e){let e=this.data.get(t);if(e??=new OutboxItem("user"),n){if(e.readRelays=new Set(normalize(n.readRelayUrls)),e.writeRelays=new Set(normalize(n.writeRelayUrls)),this.ndk.relayConnectionFilter){for(const t of e.readRelays)this.ndk.relayConnectionFilter(t)||e.readRelays.delete(t);for(const t of e.writeRelays)this.ndk.relayConnectionFilter(t)||e.writeRelays.delete(t)}this.data.set(t,e),this.emit("user:relay-list-updated",t,e),this.debug(`Adding ${e.readRelays.size} read relays and ${e.writeRelays.size} write relays for ${t}`,n?.rawEvent())}}}).finally(e)}))}return Promise.all(n)}track(e,t,n=!0){const r=getKeyFromItem(e);t??=getTypeFromItem(e);let s=this.data.get(r);return s||(s=new OutboxItem(t),e instanceof NDKUser&&this.trackUsers([e])),s}};function getKeyFromItem(e){return e instanceof NDKUser?e.pubkey:e}function getTypeFromItem(e){return e instanceof NDKUser?"user":"kind"}function correctRelaySet(e,t){const n=t.connectedRelays();if(!Array.from(e.relays).some(e=>n.map(e=>e.url).includes(e.url)))for(const t of n)e.addRelay(t);if(0===n.length)for(const n of t.relays.values())e.addRelay(n);return e}var NDKSubscriptionManager=class{subscriptions;seenEvents=new dist.LRUCache({maxSize:1e4,entryExpirationTimeInMS:3e5});constructor(){this.subscriptions=new Map}add(e){this.subscriptions.set(e.internalId,e),e.onStopped,e.onStopped=()=>{this.subscriptions.delete(e.internalId)},e.on("close",()=>{this.subscriptions.delete(e.internalId)})}seenEvent(e,t){const n=this.seenEvents.get(e)||[];n.some(e=>e.url===t.url)||n.push(t),this.seenEvents.set(e,n)}dispatchEvent(e,t,n=!1){t&&this.seenEvent(e.id,t);const r=this.subscriptions.values(),s=[];for(const t of r)matchFilters(t.filters,e)&&s.push(t);for(const r of s)r.eventReceived(e,t,!1,n)}},debug6=createDebug5("ndk:active-user");async function getUserRelayList(e){if(!this.autoConnectUserRelays)return;const t=await getRelayListForUser(e.pubkey,this);if(t){for(const e of t.relays){let t=this.pool.relays.get(e);t||(t=new NDKRelay(e,this.relayAuthDefaultPolicy,this),this.pool.addRelay(t))}return debug6("Connected to %d user relays",t.relays.length),t}}async function setActiveUser(e){if(!this.autoConnectUserRelays)return;const t=this.outboxPool||this.pool;t.connectedRelays.length>0?await getUserRelayList.call(this,e):t.once("connect",async()=>{await getUserRelayList.call(this,e)})}function getEntity(e){try{const t=nip19_exports$1.decode(e);return"npub"===t.type?npub(this,t.data):"nprofile"===t.type?nprofile(this,t.data):t}catch(e){return null}}function npub(e,t){return e.getUser({pubkey:t})}function nprofile(e,t){const n=e.getUser({pubkey:t.pubkey});return t.relays&&(n.relayUrls=t.relays),n}function isValidHint(e){if(!e||""===e)return!1;try{return new URL(e),!0}catch(e){return!1}}async function fetchEventFromTag(e,t,n,r={type:"timeout"}){const s=this.debug.extend("fetch-event-from-tag"),[i,o,a]=e;s("fetching event from tag",e,n={},r);const c=getRelaysForSync(this,t.pubkey);if(c&&c.size>0){s("fetching event from author relays %o",Array.from(c));const e=NDKRelaySet.fromRelayUrls(Array.from(c),this),t=await this.fetchEvent(o,n,e);if(t)return t}else s("no author relays found for %s",t.pubkey,t);const l=calculateRelaySetsFromFilters(this,[{ids:[o]}],this.pool);s("fetching event without relay hint",l);const u=await this.fetchEvent(o,n);if(u)return u;if(a&&""!==a){const e=await this.fetchEvent(o,n,this.pool.getRelay(a,!0,!0,[{ids:[o]}]));if(e)return e}let d;const h=isValidHint(a)?this.pool.getRelay(a,!1,!0,[{ids:[o]}]):void 0,p=new Promise(e=>{this.fetchEvent(o,n,h).then(e)});if(!isValidHint(a)||"none"===r.type)return p;const f=new Promise(async e=>{const t=r.relaySet,i=r.timeout??1500,a=new Promise(e=>setTimeout(e,i));if("timeout"===r.type&&await a,d)e(d);else{s("fallback fetch triggered");e(await this.fetchEvent(o,n,t))}});switch(r.type){case"timeout":return Promise.race([p,f]);case"eose":return d=await p,d||f}}var Queue=class{queue=[];maxConcurrency;processing=new Set;promises=new Map;constructor(e,t){this.maxConcurrency=t}add(e){if(this.promises.has(e.id))return this.promises.get(e.id);const t=new Promise((t,n)=>{this.queue.push({...e,func:()=>e.func().then(e=>(t(e),e),e=>{throw n(e),e})}),this.process()});return this.promises.set(e.id,t),t.finally(()=>{this.promises.delete(e.id),this.processing.delete(e.id),this.process()}),t}process(){if(this.processing.size>=this.maxConcurrency||0===this.queue.length)return;const e=this.queue.shift();e&&!this.processing.has(e.id)&&(this.processing.add(e.id),e.func())}clear(){this.queue=[]}clearProcessing(){this.processing.clear()}clearAll(){this.clear(),this.clearProcessing()}length(){return this.queue.length}},DEFAULT_OUTBOX_RELAYS=["wss://purplepag.es/","wss://nos.lol/"],NDK=class extends lib$1.EventEmitter{_explicitRelayUrls;pool;outboxPool;_signer;_activeUser;cacheAdapter;debug;devWriteRelaySet;outboxTracker;muteFilter;relayConnectionFilter;clientName;clientNip89;queuesZapConfig;queuesNip05;asyncSigVerification=!1;initialValidationRatio=1;lowestValidationRatio=.1;validationRatioFn;filterValidationMode="validate";subManager;aiGuardrails;_signatureVerificationFunction;_signatureVerificationWorker;signatureVerificationTimeMs=0;publishingFailureHandled=!1;pools=[];relayAuthDefaultPolicy;httpFetch;netDebug;autoConnectUserRelays=!0;walletConfig;constructor(e={}){super(),this.debug=e.debug||createDebug5("ndk"),this.netDebug=e.netDebug,this._explicitRelayUrls=e.explicitRelayUrls||[],this.subManager=new NDKSubscriptionManager,this.pool=new NDKPool(e.explicitRelayUrls||[],this),this.pool.name="Main",this.pool.on("relay:auth",async(e,t)=>{this.relayAuthDefaultPolicy&&await this.relayAuthDefaultPolicy(e,t)}),this.autoConnectUserRelays=e.autoConnectUserRelays??!0,this.clientName=e.clientName,this.clientNip89=e.clientNip89,this.relayAuthDefaultPolicy=e.relayAuthDefaultPolicy,!1!==e.enableOutboxModel&&(this.outboxPool=new NDKPool(e.outboxRelayUrls||DEFAULT_OUTBOX_RELAYS,this,{debug:this.debug.extend("outbox-pool"),name:"Outbox Pool"}),this.outboxTracker=new OutboxTracker(this),this.outboxTracker.on("user:relay-list-updated",(e,t)=>{this.debug(`Outbox relay list updated for ${e}`);for(const t of this.subManager.subscriptions.values()){t.filters.some(t=>t.authors?.includes(e))&&"function"==typeof t.refreshRelayConnections&&(this.debug(`Refreshing relay connections for subscription ${t.internalId}`),t.refreshRelayConnections())}})),this.signer=e.signer,this.cacheAdapter=e.cacheAdapter,this.muteFilter=e.muteFilter,this.relayConnectionFilter=e.relayConnectionFilter,e.devWriteRelayUrls&&(this.devWriteRelaySet=NDKRelaySet.fromRelayUrls(e.devWriteRelayUrls,this)),this.queuesZapConfig=new Queue("zaps",3),this.queuesNip05=new Queue("nip05",10),e.signatureVerificationWorker&&(this.signatureVerificationWorker=e.signatureVerificationWorker),e.signatureVerificationFunction&&(this.signatureVerificationFunction=e.signatureVerificationFunction),this.initialValidationRatio=e.initialValidationRatio||1,this.lowestValidationRatio=e.lowestValidationRatio||.1,this.validationRatioFn=e.validationRatioFn||this.defaultValidationRatioFn,this.filterValidationMode=e.filterValidationMode||"validate",this.aiGuardrails=new AIGuardrails(e.aiGuardrails||!1),this.aiGuardrails.ndkInstantiated(this);try{this.httpFetch=fetch}catch{}}set explicitRelayUrls(e){this._explicitRelayUrls=e.map(normalizeRelayUrl),this.pool.relayUrls=e}get explicitRelayUrls(){return this._explicitRelayUrls||[]}set signatureVerificationWorker(e){this._signatureVerificationWorker=e,e?(signatureVerificationInit(e),this.asyncSigVerification=!0):this.asyncSigVerification=!1}set signatureVerificationFunction(e){this._signatureVerificationFunction=e,this.asyncSigVerification=!!e}get signatureVerificationFunction(){return this._signatureVerificationFunction}addExplicitRelay(e,t,n=!0){let r;return r="string"==typeof e?new NDKRelay(e,t,this):e,this.pool.addRelay(r,n),this.explicitRelayUrls?.push(r.url),r}toJSON(){return{relayCount:this.pool.relays.size}.toString()}get activeUser(){return this._activeUser}set activeUser(e){const t=this._activeUser?.pubkey!==e?.pubkey;this._activeUser=e,t&&this.emit("activeUser:change",e),e&&t&&setActiveUser.call(this,e)}get signer(){return this._signer}set signer(e){this._signer=e,e&&this.emit("signer:ready",e),e?.user().then(e=>{e.ndk=this,this.activeUser=e})}async connect(e){if(this._signer&&this.autoConnectUserRelays&&(this.debug("Attempting to connect to user relays specified by signer %o",await(this._signer.relays?.(this))),this._signer.relays)){(await this._signer.relays(this)).forEach(e=>this.pool.addRelay(e))}const t=[this.pool.connect(e)];return this.outboxPool&&t.push(this.outboxPool.connect(e)),Promise.allSettled(t).then(()=>{})}reportInvalidSignature(e,t){this.debug(`Invalid signature detected for event ${e.id}${t?` from relay ${t.url}`:""}`),this.emit("event:invalid-sig",e,t)}defaultValidationRatioFn(e,t,n){if(t<10)return this.initialValidationRatio;const r=Math.min(t/100,1),s=this.initialValidationRatio*(1-r)+this.lowestValidationRatio*r;return Math.max(s,this.lowestValidationRatio)}getUser(e){if("string"==typeof e){if(e.startsWith("npub1")){const{type:t,data:n}=nip19_exports$1.decode(e);if("npub"!==t)throw new Error(`Invalid npub: ${e}`);return this.getUser({pubkey:n})}if(e.startsWith("nprofile1")){const{type:t,data:n}=nip19_exports$1.decode(e);if("nprofile"!==t)throw new Error(`Invalid nprofile: ${e}`);return this.getUser({pubkey:n.pubkey,relayUrls:n.relays})}return this.getUser({pubkey:e})}const t=new NDKUser(e);return t.ndk=this,t}async getUserFromNip05(e,t=!1){return NDKUser.fromNip05(e,this,t)}async fetchUser(e,t=!1){if(e.includes("@")||e.includes(".")&&!e.startsWith("n"))return NDKUser.fromNip05(e,this,t);if(e.startsWith("npub1")){const{type:t,data:n}=nip19_exports$1.decode(e);if("npub"!==t)throw new Error(`Invalid npub: ${e}`);const r=new NDKUser({pubkey:n});return r.ndk=this,r}if(e.startsWith("nprofile1")){const{type:t,data:n}=nip19_exports$1.decode(e);if("nprofile"!==t)throw new Error(`Invalid nprofile: ${e}`);const r=new NDKUser({pubkey:n.pubkey,relayUrls:n.relays});return r.ndk=this,r}{const t=new NDKUser({pubkey:e});return t.ndk=this,t}}subscribe(e,t,n=!0,r=!0){let s,i=t?.relaySet,o=r;n instanceof NDKRelaySet?(console.warn("relaySet is deprecated, use opts.relaySet instead. This will be removed in version v2.14.0"),i=n,o=r):"boolean"!=typeof n&&"object"!=typeof n||(o=n);const a={relaySet:i,...t};o&&"object"==typeof o&&(o.onEvent&&(a.onEvent=o.onEvent),o.onEose&&(a.onEose=o.onEose),o.onClose&&(a.onClose=o.onClose),o.onEvents&&(s=o.onEvents));const c=new NDKSubscription(this,e,a);this.subManager.add(c);const l=c.pool;if(c.relaySet)for(const e of c.relaySet.relays)l.useTemporaryRelay(e,void 0,c.filters);if(this.outboxPool&&c.hasAuthorsFilter()){const e=c.filters.filter(e=>e.authors&&e.authors?.length>0).flatMap(e=>e.authors);this.outboxTracker?.trackUsers(e)}return o&&setTimeout(()=>{const e=c.start(!s);e&&e.length>0&&s&&s(e)},0),c}fetchEventFromTag=fetchEventFromTag.bind(this);fetchEventSync(e){if(!this.cacheAdapter)throw new Error("Cache adapter not set");let t;t="string"==typeof e?[filterFromId(e)]:e;const n=new NDKSubscription(this,t),r=this.cacheAdapter.query(n);if(r instanceof Promise)throw new Error("Cache adapter is async");return r.map(e=>(e.ndk=this,e))}async fetchEvent(e,t,n){let r,s;if(n instanceof NDKRelay?s=new NDKRelaySet(new Set([n]),this):n instanceof NDKRelaySet&&(s=n),!n&&"string"==typeof e&&!isNip33AValue(e)){const t=relaysFromBech32(e,this);t.length>0&&(s=new NDKRelaySet(new Set(t),this),s=correctRelaySet(s,this.pool))}if(r="string"==typeof e?[filterFromId(e)]:Array.isArray(e)?e:[e],"string"!=typeof e&&this.aiGuardrails?.ndk?.fetchingEvents(r),0===r.length)throw new Error(`Invalid filter: ${JSON.stringify(e)}`);return new Promise((e,n)=>{let i=null;const o={...t||{},closeOnEose:!0};s&&(o.relaySet=s);const a=setTimeout(()=>{c.stop(),this.aiGuardrails._nextCallDisabled=null,e(i)},1e4),c=this.subscribe(r,o,{onEvent:t=>{t.ndk=this,t.isReplaceable()?(!i||i.created_at{clearTimeout(a),this.aiGuardrails._nextCallDisabled=null,e(i)}})})}async fetchEvents(e,t,n){return this.aiGuardrails?.ndk?.fetchingEvents(e,t),new Promise(r=>{const s=new Map,i={...t||{},closeOnEose:!0};n&&(i.relaySet=n);this.subscribe(e,{...i,onEvent:e=>{let t;t=e instanceof NDKEvent?e:new NDKEvent(void 0,e);const n=t.deduplicationKey(),r=s.get(n);r&&(t=dedup(r,t)),t.ndk=this,s.set(n,t)},onEose:()=>{this.aiGuardrails._nextCallDisabled=null,r(new Set(s.values()))}})})}assertSigner(){if(!this.signer)throw this.emit("signer:required"),new Error("Signer required")}getEntity=getEntity.bind(this);guardrailOff(e){return this.aiGuardrails._nextCallDisabled=e?"string"==typeof e?new Set([e]):new Set(e):"all",this}set wallet(e){e?(this.walletConfig??={},this.walletConfig.lnPay=e?.lnPay?.bind(e),this.walletConfig.cashuPay=e?.cashuPay?.bind(e)):this.walletConfig=void 0}},nip19_exports={};__reExport(nip19_exports,nip19_star);var nip49_exports={};function disconnect(e,t){return t??=createDebug5("ndk:relay:auth-policies:disconnect"),async n=>{t?.(`Relay ${n.url} requested authentication, disconnecting`),e.removeRelay(n.url)}}async function signAndAuth(e,t,n,r,s,i){try{await e.sign(n),s(e)}catch(n){r?.(`Failed to publish auth event to relay ${t.url}`,n),i(e)}}function signIn({ndk:e,signer:t,debug:n}={}){return n??=createDebug5("ndk:auth-policies:signIn"),async(r,s)=>{n?.(`Relay ${r.url} requested authentication, signing in`);const i=new NDKEvent(e);return i.kind=22242,i.tags=[["relay",r.url],["challenge",s]],t??=e?.signer,new Promise(async(s,o)=>{t?await signAndAuth(i,r,t,n,s,o):e?.once("signer:ready",async e=>{await signAndAuth(i,r,e,n,s,o)})})}}__reExport(nip49_exports,nip49_star);var NDKRelayAuthPolicies={disconnect:disconnect,signIn:signIn};async function ndkSignerFromPayload(e,t){let n;try{n=JSON.parse(e)}catch(t){return void console.error("Failed to parse signer payload string",e,t)}if(!n||"string"!=typeof n.type)return void console.error("Failed to parse signer payload string",e,new Error("Missing type field"));const r=signerRegistry.get(n.type);if(!r)throw new Error(`Unknown signer type: ${n.type}`);try{return await r.fromPayload(e,t)}catch(e){const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to deserialize signer type ${n.type}: ${t}`)}}var NDKNip07Signer=class e{_userPromise;encryptionQueue=[];encryptionProcessing=!1;debug;waitTimeout;_pubkey;ndk;_user;constructor(e=1e3,t){this.debug=createDebug5("ndk:nip07"),this.waitTimeout=e,this.ndk=t}get pubkey(){if(!this._pubkey)throw new Error("Not ready");return this._pubkey}async blockUntilReady(){await this.waitForExtension();const e=await(window.nostr?.getPublicKey());if(!e)throw new Error("User rejected access");let t;return this._pubkey=e,t=this.ndk?this.ndk.getUser({pubkey:e}):new NDKUser({pubkey:e}),this._user=t,t}async user(){return this._userPromise||(this._userPromise=this.blockUntilReady()),this._userPromise}get userSync(){if(!this._user)throw new Error("User not ready");return this._user}async sign(e){await this.waitForExtension();const t=await(window.nostr?.signEvent(e));if(!t)throw new Error("Failed to sign event");return t.sig}async relays(e){await this.waitForExtension();const t=await(window.nostr?.getRelays?.())||{},n=[];for(const e of Object.keys(t))t[e].read&&t[e].write&&n.push(e);return n.map(t=>new NDKRelay(t,e?.relayAuthDefaultPolicy,e))}async encryptionEnabled(e){const t=[];return e&&"nip04"!==e||!Boolean(window.nostr?.nip04)||t.push("nip04"),e&&"nip44"!==e||!Boolean(window.nostr?.nip44)||t.push("nip44"),t}async encrypt(e,t,n="nip04"){if(!await this.encryptionEnabled(n))throw new Error(`${n}encryption is not available from your browser extension`);await this.waitForExtension();const r=e.pubkey;return this.queueEncryption(n,"encrypt",r,t)}async decrypt(e,t,n="nip04"){if(!await this.encryptionEnabled(n))throw new Error(`${n}encryption is not available from your browser extension`);await this.waitForExtension();const r=e.pubkey;return this.queueEncryption(n,"decrypt",r,t)}async queueEncryption(e,t,n,r){return new Promise((s,i)=>{this.encryptionQueue.push({scheme:e,method:t,counterpartyHexpubkey:n,value:r,resolve:s,reject:i}),this.encryptionProcessing||this.processEncryptionQueue()})}async processEncryptionQueue(e,t=0){if(!e&&0===this.encryptionQueue.length)return void(this.encryptionProcessing=!1);this.encryptionProcessing=!0;const n=e||this.encryptionQueue.shift();if(!n)return void(this.encryptionProcessing=!1);const{scheme:r,method:s,counterpartyHexpubkey:i,value:o,resolve:a,reject:c}=n;this.debug("Processing encryption queue item",{method:s,counterpartyHexpubkey:i,value:o});try{const e=await(window.nostr?.[r]?.[s](i,o));if(!e)throw new Error("Failed to encrypt/decrypt");a(e)}catch(e){const r=e instanceof Error?e.message:String(e);if(r.includes("call already executing")&&t<5)return this.debug("Retrying encryption queue item",{method:s,counterpartyHexpubkey:i,value:o,retries:t}),void setTimeout(()=>{this.processEncryptionQueue(n,t+1)},50*t);c(e instanceof Error?e:new Error(r))}this.processEncryptionQueue()}waitForExtension(){return new Promise((e,t)=>{if(window.nostr)return void e();let n;const r=setInterval(()=>{window.nostr&&(clearTimeout(n),clearInterval(r),e())},100);n=setTimeout(()=>{clearInterval(r),t(new Error("NIP-07 extension not available"))},this.waitTimeout)})}toPayload(){return JSON.stringify({type:"nip07",payload:""})}static async fromPayload(t,n){const r=JSON.parse(t);if("nip07"!==r.type)throw new Error(`Invalid payload type: expected 'nip07', got ${r.type}`);return new e(void 0,n)}};registerSigner("nip07",NDKNip07Signer);var NDKNostrRpc=class extends lib$1.EventEmitter{ndk;signer;relaySet;debug;encryptionType="nip04";pool;constructor(e,t,n,r){if(super(),this.ndk=e,this.signer=t,r){this.pool=new NDKPool(r,e,{debug:n.extend("rpc-pool"),name:"Nostr RPC"}),this.relaySet=new NDKRelaySet(new Set,e,this.pool);for(const s of r){const r=this.pool.getRelay(s,!1,!1);r.authPolicy=NDKRelayAuthPolicies.signIn({ndk:e,signer:t,debug:n}),this.relaySet.addRelay(r),r.connect()}}this.debug=n.extend("rpc")}subscribe(e){return new Promise(t=>{const n=this.ndk.subscribe(e,{closeOnEose:!1,groupable:!1,cacheUsage:"ONLY_RELAY",pool:this.pool,relaySet:this.relaySet,onEvent:async e=>{try{const t=await this.parseEvent(e);t.method?this.emit("request",t):(this.emit(`response-${t.id}`,t),this.emit("response",t))}catch(t){this.debug("error parsing event",t,e.rawEvent())}},onEose:()=>{this.debug("eosed"),t(n)}})})}async parseEvent(e){"nip44"===this.encryptionType&&e.content.includes("?iv=")?this.encryptionType="nip04":"nip04"!==this.encryptionType||e.content.includes("?iv=")||(this.encryptionType="nip44");const t=this.ndk.getUser({pubkey:e.pubkey});let n;t.ndk=this.ndk;try{n=await this.signer.decrypt(t,e.content,this.encryptionType)}catch(r){const s="nip04"===this.encryptionType?"nip44":"nip04";n=await this.signer.decrypt(t,e.content,s),this.encryptionType=s}const r=JSON.parse(n),{id:s,method:i,params:o,result:a,error:c}=r;return i?{id:s,pubkey:e.pubkey,method:i,params:o,event:e}:{id:s,result:a,error:c,event:e}}async sendResponse(e,t,n,r=24133,s){const i={id:e,result:n};s&&(i.error=s);const o=await this.signer.user(),a=this.ndk.getUser({pubkey:t}),c=new NDKEvent(this.ndk,{kind:r,content:JSON.stringify(i),tags:[["p",t]],pubkey:o.pubkey});c.content=await this.signer.encrypt(a,c.content,this.encryptionType),await c.sign(this.signer),await c.publish(this.relaySet)}async sendRequest(e,t,n=[],r=24133,s){const i=Math.random().toString(36).substring(7),o=await this.signer.user(),a=this.ndk.getUser({pubkey:e}),c={id:i,method:t,params:n},l=new Promise(()=>{const e=t=>{"auth_url"===t.result?(this.once(`response-${i}`,e),this.emit("authUrl",t.error)):s&&s(t)};this.once(`response-${i}`,e)}),u=new NDKEvent(this.ndk,{kind:r,content:JSON.stringify(c),tags:[["p",e]],pubkey:o.pubkey});return u.content=await this.signer.encrypt(a,u.content,this.encryptionType),await u.sign(this.signer),await u.publish(this.relaySet),l}};function nostrConnectGenerateSecret(){return Math.random().toString(36).substring(2,15)}function generateNostrConnectUri(e,t,n,r){const s=r?.name?encodeURIComponent(r.name):"",i=r?.url?encodeURIComponent(r.url):"";let o=`nostrconnect://${e}?image=${r?.image?encodeURIComponent(r.image):""}&url=${i}&name=${s}&perms=${r?.perms?encodeURIComponent(r.perms):""}&secret=${encodeURIComponent(t)}`;return n&&(o+=`&relay=${encodeURIComponent(n)}`),o}var NDKNip46Signer=class e extends lib$1.EventEmitter{ndk;_user;bunkerPubkey;userPubkey;get pubkey(){if(!this.userPubkey)throw new Error("Not ready");return this.userPubkey}secret;localSigner;nip05;rpc;debug;relayUrls;subscription;nostrConnectUri;nostrConnectSecret;constructor(e,t,n,r,s){super(),this.ndk=e,this.debug=e.debug.extend("nip46:signer"),this.relayUrls=r,this.localSigner=n?"string"==typeof n?new NDKPrivateKeySigner(n):n:NDKPrivateKeySigner.generate(),!1===t||(t?t.startsWith("bunker://")?this.bunkerFlowInit(t):this.nip05Init(t):this.nostrconnectFlowInit(s)),this.rpc=new NDKNostrRpc(this.ndk,this.localSigner,this.debug,this.relayUrls)}static bunker(t,n,r){return new e(t,n,r)}static nostrconnect(t,n,r,s){return new e(t,void 0,r,[n],s)}nostrconnectFlowInit(e){this.nostrConnectSecret=nostrConnectGenerateSecret();const t=this.localSigner.pubkey;this.nostrConnectUri=generateNostrConnectUri(t,this.nostrConnectSecret,this.relayUrls?.[0],e)}bunkerFlowInit(e){const t=new URL(e),n=t.hostname||t.pathname.replace(/^\/\//,""),r=t.searchParams.get("pubkey"),s=t.searchParams.getAll("relay"),i=t.searchParams.get("secret");this.bunkerPubkey=n,this.userPubkey=r,this.relayUrls=s,this.secret=i}nip05Init(e){this.nip05=e}async startListening(){if(this.subscription)return;const e=await this.localSigner.user();if(!e)throw new Error("Local signer not ready");this.subscription=await this.rpc.subscribe({kinds:[24133],"#p":[e.pubkey]})}async user(){return this._user?this._user:this.blockUntilReady()}get userSync(){if(!this._user)throw new Error("Remote user not ready synchronously");return this._user}async blockUntilReadyNostrConnect(){return new Promise((e,t)=>{const n=t=>{t.result===this.nostrConnectSecret&&(this._user=t.event.author,this.userPubkey=t.event.pubkey,this.bunkerPubkey=t.event.pubkey,this.rpc.off("response",n),e(this._user))};this.startListening(),this.rpc.on("response",n)})}async blockUntilReady(){if(!this.bunkerPubkey&&!this.nostrConnectSecret&&!this.nip05)throw new Error("Bunker pubkey not set");if(this.nostrConnectSecret)return this.blockUntilReadyNostrConnect();if(this.nip05&&!this.userPubkey){const e=await NDKUser.fromNip05(this.nip05,this.ndk);e&&(this._user=e,this.userPubkey=e.pubkey,this.relayUrls=e.nip46Urls,this.rpc=new NDKNostrRpc(this.ndk,this.localSigner,this.debug,this.relayUrls))}if(!this.bunkerPubkey&&this.userPubkey)this.bunkerPubkey=this.userPubkey;else if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");return await this.startListening(),this.rpc.on("authUrl",(...e)=>{this.emit("authUrl",...e)}),new Promise((e,t)=>{const n=[this.userPubkey??""];if(this.secret&&n.push(this.secret),!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"connect",n,24133,n=>{"ack"===n.result?this.getPublicKey().then(t=>{this.userPubkey=t,this._user=this.ndk.getUser({pubkey:t}),e(this._user)}):t(n.error)})})}stop(){this.subscription?.stop(),this.subscription=void 0}async getPublicKey(){return this.userPubkey?this.userPubkey:new Promise((e,t)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"get_public_key",[],24133,t=>{e(t.result)})})}async encryptionEnabled(e){return e?[e]:Promise.resolve(["nip04","nip44"])}async encrypt(e,t,n="nip04"){return this.encryption(e,t,n,"encrypt")}async decrypt(e,t,n="nip04"){return this.encryption(e,t,n,"decrypt")}async encryption(e,t,n,r){return new Promise((s,i)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,`${n}_${r}`,[e.pubkey,t],24133,e=>{e.error?i(e.error):s(e.result)})})}async sign(e){return new Promise((t,n)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"sign_event",[JSON.stringify(e)],24133,e=>{if(e.error)n(e.error);else{const n=JSON.parse(e.result);t(n.sig)}})})}async createAccount(e,t,n){await this.startListening();const r=[];return e&&r.push(e),t&&r.push(t),n&&r.push(n),new Promise((e,t)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"create_account",r,24133,n=>{if(n.error)t(n.error);else{const t=n.result;e(t)}})})}toPayload(){if(!this.bunkerPubkey||!this.userPubkey)throw new Error("NIP-46 signer is not fully initialized for serialization");const e={type:"nip46",payload:{bunkerPubkey:this.bunkerPubkey,userPubkey:this.userPubkey,relayUrls:this.relayUrls,secret:this.secret,localSignerPayload:this.localSigner.toPayload(),nip05:this.nip05||null}};return JSON.stringify(e)}static async fromPayload(t,n){if(!n)throw new Error("NDK instance is required to deserialize NIP-46 signer");const r=JSON.parse(t);if("nip46"!==r.type)throw new Error(`Invalid payload type: expected 'nip46', got ${r.type}`);const s=r.payload;if(!s||"object"!=typeof s||!s.localSignerPayload)throw new Error("Invalid payload content for nip46 signer");const i=await ndkSignerFromPayload(s.localSignerPayload,n);if(!i)throw new Error("Failed to deserialize local signer for NIP-46");if(!(i instanceof NDKPrivateKeySigner))throw new Error("Local signer must be an instance of NDKPrivateKeySigner");let o;return o=new e(n,!1,i,s.relayUrls),o.userPubkey=s.userPubkey,o.bunkerPubkey=s.bunkerPubkey,o.relayUrls=s.relayUrls,o.secret=s.secret,s.userPubkey&&(o._user=new NDKUser({pubkey:s.userPubkey}),o._user&&(o._user.ndk=n)),o}};registerSigner("nip46",NDKNip46Signer),createDebug5("ndk:zapper:ln"),createDebug5("ndk:zapper");const{window:window_1}=globals;function create_if_block$1(e){let t,n,r,s,i,o,a,c,l,u,d,h,p,f,g,y,m,b;function v(e,t){return"extension"===e[2]?create_if_block_3$1:create_else_block$1}let w=v(e),_=w(e),E=e[5]&&create_if_block_2$1(e),k=e[6]&&create_if_block_1$1(e);return{c(){t=element("div"),n=element("div"),r=element("div"),s=element("h2"),s.textContent="Login to Nostr",i=space(),o=element("button"),o.textContent="×",a=space(),c=element("div"),l=element("div"),u=element("button"),u.textContent="Extension",d=space(),h=element("button"),h.textContent="Nsec",p=space(),f=element("div"),_.c(),g=space(),E&&E.c(),y=space(),k&&k.c(),attr(s,"class","svelte-9yzcwg"),attr(o,"class","close-btn svelte-9yzcwg"),attr(r,"class","modal-header svelte-9yzcwg"),attr(u,"class","tab-btn svelte-9yzcwg"),toggle_class(u,"active","extension"===e[2]),attr(h,"class","tab-btn svelte-9yzcwg"),toggle_class(h,"active","nsec"===e[2]),attr(l,"class","tabs svelte-9yzcwg"),attr(f,"class","tab-content svelte-9yzcwg"),attr(c,"class","tab-container svelte-9yzcwg"),attr(n,"class","modal svelte-9yzcwg"),toggle_class(n,"dark-theme",e[1]),attr(t,"class","modal-overlay svelte-9yzcwg"),attr(t,"role","button"),attr(t,"tabindex","0")},m(v,w){insert(v,t,w),append(t,n),append(n,r),append(r,s),append(r,i),append(r,o),append(n,a),append(n,c),append(c,l),append(l,u),append(l,d),append(l,h),append(c,p),append(c,f),_.m(f,null),append(f,g),E&&E.m(f,null),append(f,y),k&&k.m(f,null),m||(b=[listen(o,"click",e[7]),listen(u,"click",e[14]),listen(h,"click",e[15]),listen(n,"click",stop_propagation(e[12])),listen(n,"keydown",stop_propagation(e[13])),listen(t,"click",e[7]),listen(t,"keydown",e[17])],m=!0)},p(e,t){4&t&&toggle_class(u,"active","extension"===e[2]),4&t&&toggle_class(h,"active","nsec"===e[2]),w===(w=v(e))&&_?_.p(e,t):(_.d(1),_=w(e),_&&(_.c(),_.m(f,g))),e[5]?E?E.p(e,t):(E=create_if_block_2$1(e),E.c(),E.m(f,y)):E&&(E.d(1),E=null),e[6]?k?k.p(e,t):(k=create_if_block_1$1(e),k.c(),k.m(f,null)):k&&(k.d(1),k=null),2&t&&toggle_class(n,"dark-theme",e[1])},d(e){e&&detach(t),_.d(),E&&E.d(),k&&k.d(),m=!1,run_all(b)}}}function create_else_block$1(e){let t,n,r,s,i,o,a,c,l,u,d=e[4]?"Logging in...":"Log in with nsec";return{c(){t=element("div"),n=element("p"),n.textContent="Enter your nsec (private key) to login. This will be stored securely in your browser.",r=space(),s=element("input"),i=space(),o=element("button"),a=text(d),attr(n,"class","svelte-9yzcwg"),attr(s,"type","password"),attr(s,"placeholder","nsec1..."),s.disabled=e[4],attr(s,"class","nsec-input svelte-9yzcwg"),attr(o,"class","login-nsec-btn svelte-9yzcwg"),o.disabled=c=e[4]||!e[3].trim(),attr(t,"class","nsec-login svelte-9yzcwg")},m(c,d){insert(c,t,d),append(t,n),append(t,r),append(t,s),set_input_value(s,e[3]),append(t,i),append(t,o),append(o,a),l||(u=[listen(s,"input",e[16]),listen(o,"click",e[10])],l=!0)},p(e,t){16&t&&(s.disabled=e[4]),8&t&&s.value!==e[3]&&set_input_value(s,e[3]),16&t&&d!==(d=e[4]?"Logging in...":"Log in with nsec")&&set_data(a,d),24&t&&c!==(c=e[4]||!e[3].trim())&&(o.disabled=c)},d(e){e&&detach(t),l=!1,run_all(u)}}}function create_if_block_3$1(e){let t,n,r,s,i,o,a,c=e[4]?"Connecting...":"Log in using extension";return{c(){t=element("div"),n=element("p"),n.textContent="Login using a NIP-07 compatible browser extension like nos2x or Alby.",r=space(),s=element("button"),i=text(c),attr(n,"class","svelte-9yzcwg"),attr(s,"class","login-extension-btn svelte-9yzcwg"),s.disabled=e[4],attr(t,"class","extension-login svelte-9yzcwg")},m(c,l){insert(c,t,l),append(t,n),append(t,r),append(t,s),append(s,i),o||(a=listen(s,"click",e[9]),o=!0)},p(e,t){16&t&&c!==(c=e[4]?"Connecting...":"Log in using extension")&&set_data(i,c),16&t&&(s.disabled=e[4])},d(e){e&&detach(t),o=!1,a()}}}function create_if_block_2$1(e){let t,n;return{c(){t=element("div"),n=text(e[5]),attr(t,"class","message error-message svelte-9yzcwg")},m(e,r){insert(e,t,r),append(t,n)},p(e,t){32&t&&set_data(n,e[5])},d(e){e&&detach(t)}}}function create_if_block_1$1(e){let t,n;return{c(){t=element("div"),n=text(e[6]),attr(t,"class","message success-message svelte-9yzcwg")},m(e,r){insert(e,t,r),append(t,n)},p(e,t){64&t&&set_data(n,e[6])},d(e){e&&detach(t)}}}function create_fragment$1(e){let t,n,r,s=e[0]&&create_if_block$1(e);return{c(){s&&s.c(),t=empty()},m(i,o){s&&s.m(i,o),insert(i,t,o),n||(r=listen(window_1,"keydown",e[11]),n=!0)},p(e,[n]){e[0]?s?s.p(e,n):(s=create_if_block$1(e),s.c(),s.m(t.parentNode,t)):s&&(s.d(1),s=null)},i:noop,o:noop,d(e){s&&s.d(e),e&&detach(t),n=!1,r()}}}function validateNsec(e){return!!e.startsWith("nsec1")&&!(e.length<60||e.length>70)}function instance$1(e,t,n){const r=createEventDispatcher();let{showModal:s=!1}=t,{isDarkTheme:i=!1}=t,o="extension",a="",c=!1,l="",u="";function d(){n(0,s=!1),n(3,a=""),n(5,l=""),n(6,u=""),r("close")}function h(e){n(2,o=e),n(5,l=""),n(6,u="")}async function p(){n(4,c=!0),n(5,l=""),n(6,u="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!validateNsec(a.trim()))throw new Error('Invalid nsec format. Must start with "nsec1"');const e=new NDKPrivateKeySigner(a.trim()),t=await e.user().then(e=>e.pubkey);localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),localStorage.setItem("nostr_privkey",a.trim()),n(6,u="Successfully logged in with nsec!"),r("login",{method:"nsec",pubkey:t,privateKey:a.trim(),signer:e}),setTimeout(()=>{d()},1500)}catch(e){n(5,l=e.message)}finally{n(4,c=!1)}}return e.$$set=e=>{"showModal"in e&&n(0,s=e.showModal),"isDarkTheme"in e&&n(1,i=e.isDarkTheme)},[s,i,o,a,c,l,u,d,h,async function(){n(4,c=!0),n(5,l=""),n(6,u="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(6,u="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{d()},1500))}catch(e){n(5,l=e.message)}finally{n(4,c=!1)}},p,function(e){"Escape"===e.key&&d(),"Enter"===e.key&&"nsec"===o&&p()},function(t){bubble.call(this,e,t)},function(t){bubble.call(this,e,t)},()=>h("extension"),()=>h("nsec"),function(){a=this.value,n(3,a)},e=>"Escape"===e.key&&d()]}class LoginModal extends SvelteComponent{constructor(e){super(),init(this,e,instance$1,create_fragment$1,safe_not_equal,{showModal:0,isDarkTheme:1})}}const DEFAULT_RELAYS=[`wss://${window.location.host}/`];class NostrClient{constructor(){this.ndk=new NDK({explicitRelayUrls:DEFAULT_RELAYS}),this.isConnected=!1}async connect(){console.log("Starting NDK connection to",DEFAULT_RELAYS.length,"relays...");try{await this.ndk.connect(),this.isConnected=!0,console.log("✓ NDK successfully connected to relays"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ NDK connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay to NDK: ${e}`);try{return DEFAULT_RELAYS.push(e),await this.connect(),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating NDK subscription with filters:",e);const n=this.ndk.subscribe(e,{closeOnEose:!0});return n.on("event",e=>{console.log("Event received via NDK:",e),t(e.rawEvent())}),n.on("eose",()=>{console.log("EOSE received via NDK"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}),n.id}unsubscribe(e){console.log(`Closing NDK subscription: ${e}`)}disconnect(){console.log("Disconnecting NDK"),this.ndk&&"function"==typeof this.ndk.disconnect&&this.ndk.disconnect(),this.isConnected=!1}async publish(e){console.log("Publishing event via NDK:",e);try{const t=new NDKEvent(this.ndk,e);return await t.publish(),console.log("✓ Event published successfully via NDK"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event via NDK:",e),e}}getNDK(){return this.ndk}getSigner(){return this.ndk.signer}setSigner(e){this.ndk.signer=e}}const nostrClient=new NostrClient,DB_NAME="nostrCache",DB_VERSION=1,STORE_EVENTS="events";function openDB(){return new Promise((e,t)=>{try{const n=indexedDB.open(DB_NAME,DB_VERSION);n.onupgradeneeded=()=>{const e=n.result;if(!e.objectStoreNames.contains(STORE_EVENTS)){const t=e.createObjectStore(STORE_EVENTS,{keyPath:"id"});t.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),t.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1})}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){t(e)}})}async function getLatestProfileEvent(e){try{const t=await openDB();return await new Promise((n,r)=>{const s=t.transaction(STORE_EVENTS,"readonly").objectStore(STORE_EVENTS).index("byKindAuthorCreated"),i=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),o=s.openCursor(i,"prev");o.onsuccess=()=>{const e=o.result;n(e?e.value:null)},o.onerror=()=>r(o.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}async function putEvent(e){try{const t=await openDB();await new Promise((n,r)=>{const s=t.transaction(STORE_EVENTS,"readwrite");s.oncomplete=()=>n(),s.onerror=()=>r(s.error),s.objectStore(STORE_EVENTS).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}function parseProfileFromEvent(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function fetchUserProfile(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await getLatestProfileEvent(e);if(t){console.log("Using cached profile event");return parseProfileFromEvent(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=nostrClient.getNDK().getUser({hexpubkey:e}),n=await t.fetchProfile();if(n){console.log("Profile fetched via NDK:",n),await putEvent(n.rawEvent());const t=parseProfileFromEvent(n.rawEvent());try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:t,event:n.rawEvent()}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return t}throw new Error("No profile found")}catch(e){throw console.error("Failed to fetch profile via NDK:",e),e}}async function fetchEvents(e,t={}){console.log("Starting event fetch with filters:",e);const{timeout:n=3e4,limit:r=null}=t;try{const t=nostrClient.getNDK(),s={...e};r&&(s.limit=r),console.log("Fetching events via NDK with filters:",s);const i=await t.fetchEvents(s,{timeout:n});console.log(`Fetched ${i.size} events via NDK`);return Array.from(i).map(e=>e.rawEvent())}catch(e){throw console.error("Failed to fetch events via NDK:",e),e}}async function fetchAllEvents(e={}){const{limit:t=100,since:n=null,until:r=null,authors:s=null}=e,i={};n&&(i.since=n),r&&(i.until=r),s&&(i.authors=s);return await fetchEvents(i,{limit:t,timeout:3e4})}async function searchEvents(e,t={}){const{limit:n=100,since:r=null,until:s=null,kinds:i=null}=t,o={search:e};r&&(o.since=r),s&&(o.until=s),i&&(o.kinds=i);return await fetchEvents(o,{limit:n,timeout:3e4})}async function fetchEventById(e,t={}){const{timeout:n=1e4,relays:r=null}=t;console.log(`Fetching event by ID: ${e}`);try{const t=nostrClient.getNDK(),r={ids:[e]};console.log("Fetching event via NDK with filters:",r);const s=await t.fetchEvents(r,{timeout:n});console.log(`Fetched ${s.size} events via NDK`);const i=Array.from(s).map(e=>e.rawEvent());return i.length>0?i[0]:null}catch(e){throw console.error("Failed to fetch event by ID via NDK:",e),e}}async function fetchDeleteEventsByTarget(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=nostrClient.getNDK(),r={kinds:[5],"#e":[e]};console.log("Fetching delete events via NDK with filters:",r);const s=await t.fetchEvents(r,{timeout:n});console.log(`Fetched ${s.size} delete events via NDK`);return Array.from(s).map(e=>e.rawEvent())}catch(e){throw console.error("Failed to fetch delete events via NDK:",e),e}}async function initializeNostrClient(){await nostrClient.connect()}function get_each_context_3(e,t,n){const r=e.slice();return r[129]=t[n],r}function get_each_context_4(e,t,n){const r=e.slice();return r[120]=t[n],r}function get_each_context_2(e,t,n){const r=e.slice();return r[126]=t[n],r}function get_each_context(e,t,n){const r=e.slice();return r[120]=t[n],r}function get_each_context_1(e,t,n){const r=e.slice();return r[123]=t[n],r}function get_each_context_5(e,t,n){const r=e.slice();return r[134]=t[n],r}function create_else_block_11(e){let t,n,r,s=e[1]&&e[4]&&create_if_block_45(e);return{c(){t=element("div"),n=element("span"),r=text("ORLY? dashboard\n "),s&&s.c(),attr(n,"class","app-title svelte-4jqeqn"),attr(t,"class","header-title svelte-4jqeqn")},m(e,i){insert(e,t,i),append(t,n),append(n,r),s&&s.m(n,null)},p(e,t){e[1]&&e[4]?s?s.p(e,t):(s=create_if_block_45(e),s.c(),s.m(n,null)):s&&(s.d(1),s=null)},d(e){e&&detach(t),s&&s.d()}}}function create_if_block_44(e){let t,n,r,s;return{c(){t=element("div"),n=element("input"),attr(n,"type","text"),attr(n,"class","search-input svelte-4jqeqn"),attr(n,"placeholder","Search..."),attr(t,"class","search-input-container svelte-4jqeqn")},m(i,o){insert(i,t,o),append(t,n),set_input_value(n,e[12]),r||(s=[listen(n,"input",e[66]),listen(n,"keydown",e[50])],r=!0)},p(e,t){4096&t[0]&&n.value!==e[12]&&set_input_value(n,e[12])},d(e){e&&detach(t),r=!1,run_all(s)}}}function create_if_block_45(e){let t,n;return{c(){t=element("span"),n=text(e[4]),attr(t,"class","permission-badge svelte-4jqeqn")},m(e,r){insert(e,t,r),append(t,n)},p(e,t){16&t[0]&&set_data(n,e[4])},d(e){e&&detach(t)}}}function create_else_block_10(e){let t,n,r;return{c(){t=element("button"),t.textContent="Log in",attr(t,"class","login-btn svelte-4jqeqn")},m(s,i){insert(s,t,i),n||(r=listen(t,"click",e[43]),n=!0)},p:noop,d(e){e&&detach(t),n=!1,r()}}}function create_if_block_42(e){let t,n,r,s,i,o,a,c=(e[3]?.name||e[2].slice(0,8)+"...")+"";function l(e,t){return e[3]?.picture?create_if_block_43:create_else_block_9}let u=l(e),d=u(e);return{c(){t=element("div"),n=element("button"),d.c(),r=space(),s=element("span"),i=text(c),attr(s,"class","user-name svelte-4jqeqn"),attr(n,"class","user-profile-btn svelte-4jqeqn"),attr(t,"class","user-info svelte-4jqeqn")},m(c,l){insert(c,t,l),append(t,n),d.m(n,null),append(n,r),append(n,s),append(s,i),o||(a=listen(n,"click",e[47]),o=!0)},p(e,t){u===(u=l(e))&&d?d.p(e,t):(d.d(1),d=u(e),d&&(d.c(),d.m(n,r))),12&t[0]&&c!==(c=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&set_data(i,c)},d(e){e&&detach(t),d.d(),o=!1,a()}}}function create_else_block_9(e){let t;return{c(){t=element("div"),t.textContent="👤",attr(t,"class","user-avatar-placeholder svelte-4jqeqn")},m(e,n){insert(e,t,n)},p:noop,d(e){e&&detach(t)}}}function create_if_block_43(e){let t,n;return{c(){t=element("img"),src_url_equal(t.src,n=e[3].picture)||attr(t,"src",n),attr(t,"alt","User avatar"),attr(t,"class","user-avatar svelte-4jqeqn")},m(e,n){insert(e,t,n)},p(e,r){8&r[0]&&!src_url_equal(t.src,n=e[3].picture)&&attr(t,"src",n)},d(e){e&&detach(t)}}}function create_if_block_41(e){let t,n,r;function s(){return e[67](e[134])}function i(...t){return e[68](e[134],...t)}return{c(){t=element("span"),t.textContent="✕",attr(t,"class","tab-close-icon svelte-4jqeqn"),attr(t,"role","button"),attr(t,"tabindex","0")},m(e,o){insert(e,t,o),n||(r=[listen(t,"click",stop_propagation(s)),listen(t,"keydown",i)],n=!0)},p(t,n){e=t},d(e){e&&detach(t),n=!1,run_all(r)}}}function create_each_block_5(e){let t,n,r,s,i,o,a,c,l,u,d=e[134].icon+"",h=e[134].label+"",p=e[134].isSearchTab&&create_if_block_41(e);function f(){return e[69](e[134])}return{c(){t=element("button"),n=element("span"),r=text(d),s=space(),i=element("span"),o=text(h),a=space(),p&&p.c(),c=space(),attr(n,"class","tab-icon svelte-4jqeqn"),attr(i,"class","tab-label svelte-4jqeqn"),attr(t,"class","tab svelte-4jqeqn"),toggle_class(t,"active",e[5]===e[134].id)},m(e,d){insert(e,t,d),append(t,n),append(n,r),append(t,s),append(t,i),append(i,o),append(t,a),p&&p.m(t,null),append(t,c),l||(u=listen(t,"click",f),l=!0)},p(n,s){e=n,16777216&s[0]&&d!==(d=e[134].icon+"")&&set_data(r,d),16777216&s[0]&&h!==(h=e[134].label+"")&&set_data(o,h),e[134].isSearchTab?p?p.p(e,s):(p=create_if_block_41(e),p.c(),p.m(t,c)):p&&(p.d(1),p=null),16777248&s[0]&&toggle_class(t,"active",e[5]===e[134].id)},d(e){e&&detach(t),p&&p.d(),l=!1,u()}}}function create_else_block_7(e){let t;function n(e,t){return e[1]?create_if_block_40:create_else_block_8}let r=n(e),s=r(e);return{c(){t=element("div"),s.c(),attr(t,"class","welcome-message svelte-4jqeqn")},m(e,n){insert(e,t,n),s.m(t,null)},p(e,i){r===(r=n(e))&&s?s.p(e,i):(s.d(1),s=r(e),s&&(s.c(),s.m(t,null)))},d(e){e&&detach(t),s.d()}}}function create_if_block_32(e){let t,n=e[6],r=[];for(let t=0;t0;function k(){return e[80](e[129])}function $(e,t){return 64&t[0]&&(p=null),64&t[0]&&(f=null),null==p&&(p=!!(e[27].get(e[129].id)?.events?.length>0)),p?create_if_block_36:(null==f&&(f=!e[27].get(e[129].id)?.isLoading),f?create_if_block_39:void 0)}let x=$(e,[-1,-1,-1,-1,-1]),S=x&&x(e),T=_&&create_if_block_35(),R=E&&create_if_block_34();function A(...t){return e[84](e[129],...t)}return{c(){t=element("div"),n=element("div"),r=element("h2"),s=text('🔍 Search Results: "'),i=text(w),o=text('"'),a=space(),c=element("button"),l=text("🔄 Refresh"),d=space(),h=element("div"),S&&S.c(),g=space(),T&&T.c(),y=space(),R&&R.c(),m=space(),attr(r,"class","svelte-4jqeqn"),attr(c,"class","refresh-btn svelte-4jqeqn"),c.disabled=u=e[27].get(e[129].id)?.isLoading,attr(n,"class","search-results-header svelte-4jqeqn"),attr(h,"class","search-results-content svelte-4jqeqn"),attr(t,"class","search-results-view svelte-4jqeqn")},m(e,u){insert(e,t,u),append(t,n),append(n,r),append(r,s),append(r,i),append(r,o),append(n,a),append(n,c),append(c,l),append(t,d),append(t,h),S&&S.m(h,null),append(h,g),T&&T.m(h,null),append(h,y),R&&R.m(h,null),append(t,m),b||(v=[listen(c,"click",k),listen(h,"scroll",A)],b=!0)},p(t,n){e=t,64&n[0]&&w!==(w=e[129].query+"")&&set_data(i,w),64&n[0]&&u!==(u=e[27].get(e[129].id)?.isLoading)&&(c.disabled=u),x===(x=$(e,n))&&S?S.p(e,n):(S&&S.d(1),S=x&&x(e),S&&(S.c(),S.m(h,g))),64&n[0]&&(_=e[27].get(e[129].id)?.isLoading),_?T||(T=create_if_block_35(),T.c(),T.m(h,y)):T&&(T.d(1),T=null),64&n[0]&&(E=!e[27].get(e[129].id)?.hasMore&&e[27].get(e[129].id)?.events?.length>0),E?R||(R=create_if_block_34(),R.c(),R.m(h,null)):R&&(R.d(1),R=null)},d(e){e&&detach(t),S&&S.d(),T&&T.d(),R&&R.d(),b=!1,run_all(v)}}}function create_if_block_39(e){let t,n,r,s,i,o=e[129].query+"";return{c(){t=element("div"),n=element("p"),r=text('No search results found for "'),s=text(o),i=text('".'),attr(n,"class","svelte-4jqeqn"),attr(t,"class","no-search-results svelte-4jqeqn")},m(e,o){insert(e,t,o),append(t,n),append(n,r),append(n,s),append(n,i)},p(e,t){64&t[0]&&o!==(o=e[129].query+"")&&set_data(s,o)},d(e){e&&detach(t)}}}function create_if_block_36(e){let t,n=e[27].get(e[129].id).events,r=[];for(let t=0;t👤',s=space(),i=element("div"),o=element("div"),a=text(T),c=space(),l=element("div"),u=element("span"),d=text(R),h=space(),p=element("span"),f=text(A),g=space(),y=element("div"),m=element("div"),b=text(N),v=space(),w=element("div"),_=text(C),E=space(),B&&B.c(),k=space(),P&&P.c(),$=space(),attr(r,"class","search-result-avatar svelte-4jqeqn"),attr(o,"class","search-result-author svelte-4jqeqn"),attr(u,"class","kind-number svelte-4jqeqn"),attr(p,"class","kind-name svelte-4jqeqn"),attr(l,"class","search-result-kind svelte-4jqeqn"),attr(i,"class","search-result-info svelte-4jqeqn"),attr(m,"class","event-timestamp svelte-4jqeqn"),attr(w,"class","event-content-single-line svelte-4jqeqn"),attr(y,"class","search-result-content svelte-4jqeqn"),attr(n,"class","search-result-row svelte-4jqeqn"),attr(n,"role","button"),attr(n,"tabindex","0"),attr(t,"class","search-result-item svelte-4jqeqn"),toggle_class(t,"expanded",e[14].has(e[120].id))},m(e,T){insert(e,t,T),append(t,n),append(n,r),append(n,s),append(n,i),append(i,o),append(o,a),append(i,c),append(i,l),append(l,u),append(u,d),append(l,h),append(l,p),append(p,f),append(n,g),append(n,y),append(y,m),append(m,b),append(y,v),append(y,w),append(w,_),append(n,E),B&&B.m(n,null),append(t,k),P&&P.m(t,null),append(t,$),x||(S=[listen(n,"click",D),listen(n,"keydown",L)],x=!0)},p(r,s){e=r,64&s[0]&&T!==(T=truncatePubkey(e[120].pubkey)+"")&&set_data(a,T),64&s[0]&&R!==(R=e[120].kind+"")&&set_data(d,R),64&s[0]&&A!==(A=e[28](e[120].kind)+"")&&set_data(f,A),64&s[0]&&N!==(N=formatTimestamp(e[120].created_at)+"")&&set_data(b,N),64&s[0]&&C!==(C=truncateContent(e[120].content)+"")&&set_data(_,C),5!==e[120].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[120].pubkey&&e[120].pubkey===e[2])?B?B.p(e,s):(B=create_if_block_38(e),B.c(),B.m(n,null)):B&&(B.d(1),B=null),16448&s[0]&&(I=e[14].has(e[120].id)),I?P?P.p(e,s):(P=create_if_block_37(e),P.c(),P.m(t,$)):P&&(P.d(1),P=null),134234176&s[0]&&toggle_class(t,"expanded",e[14].has(e[120].id))},d(e){e&&detach(t),B&&B.d(),P&&P.d(),x=!1,run_all(S)}}}function create_if_block_35(e){let t;return{c(){t=element("div"),t.innerHTML=' \n Searching...
',attr(t,"class","loading-search-results svelte-4jqeqn")},m(e,n){insert(e,t,n)},d(e){e&&detach(t)}}}function create_if_block_34(e){let t;return{c(){t=element("div"),t.innerHTML='No more search results to load.
',attr(t,"class","end-of-search-results svelte-4jqeqn")},m(e,n){insert(e,t,n)},d(e){e&&detach(t)}}}function create_each_block_3(e){let t,n=e[129].id===e[5]&&create_if_block_33(e);return{c(){n&&n.c(),t=empty()},m(e,r){n&&n.m(e,r),insert(e,t,r)},p(e,r){e[129].id===e[5]?n?n.p(e,r):(n=create_if_block_33(e),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(e){n&&n.d(e),e&&detach(t)}}}function create_else_block_6(e){let t,n,r,s,i,o;return{c(){t=element("div"),n=element("p"),n.textContent="Please log in to access sprocket management.",r=space(),s=element("button"),s.textContent="Log In",attr(n,"class","svelte-4jqeqn"),attr(s,"class","login-btn svelte-4jqeqn"),attr(t,"class","login-prompt svelte-4jqeqn")},m(a,c){insert(a,t,c),append(t,n),append(t,r),append(t,s),i||(o=listen(s,"click",e[43]),i=!0)},p:noop,d(e){e&&detach(t),i=!1,o()}}}function create_if_block_31(e){let t,n,r,s,i,o,a,c,l,u=(e[4]||"none")+"";return{c(){t=element("div"),n=element("p"),n.textContent="❌ Owner permission required for sprocket management.",r=space(),s=element("p"),s.innerHTML="To enable sprocket functionality, set the ORLY_OWNERS environment variable with your npub when starting the relay.",i=space(),o=element("p"),a=text("Current user role: "),c=element("strong"),l=text(u),attr(n,"class","svelte-4jqeqn"),attr(s,"class","svelte-4jqeqn"),attr(o,"class","svelte-4jqeqn"),attr(t,"class","permission-denied svelte-4jqeqn")},m(e,u){insert(e,t,u),append(t,n),append(t,r),append(t,s),append(t,i),append(t,o),append(o,a),append(o,c),append(c,l)},p(e,t){16&t[0]&&u!==(u=(e[4]||"none")+"")&&set_data(l,u)},d(e){e&&detach(t)}}}function create_if_block_26(e){let t,n,r,s,i,o,a,c,l,u,d,h,p,f,g,y,m,b,v,w,_,E,k,$,x,S,T,R,A,N,C,I,B,D,L,P,F,U,O,q,M,K,j,H,V,z,G,W,J,Z,Y,X,Q,ee,te,ne,re=e[18]?.is_running?"🟢 Running":"🔴 Stopped",se=e[18]?.script_exists?"✅ Exists":"❌ Not found",ie=e[18]?.pid&&create_if_block_30(e),oe=e[21]&&create_if_block_29(e),ae=e[19],ce=[];for(let t=0;t❌ Write, admin, or owner permission required to view all events.
',attr(t,"class","permission-denied svelte-4jqeqn")},m(e,n){insert(e,t,n)},p:noop,d(e){e&&detach(t)}}}function create_if_block_16(e){let t,n,r,s,i;function o(e,t){return e[26].length>0?create_if_block_19:e[15]?void 0:create_if_block_24}let a=o(e),c=a&&a(e),l=e[15]&&create_if_block_18(),u=!e[16]&&e[7].length>0&&create_if_block_17();return{c(){t=element("div"),c&&c.c(),n=space(),l&&l.c(),r=space(),u&&u.c(),attr(t,"class","events-view-content svelte-4jqeqn")},m(o,a){insert(o,t,a),c&&c.m(t,null),append(t,n),l&&l.m(t,null),append(t,r),u&&u.m(t,null),s||(i=listen(t,"scroll",e[60]),s=!0)},p(e,s){a===(a=o(e))&&c?c.p(e,s):(c&&c.d(1),c=a&&a(e),c&&(c.c(),c.m(t,n))),e[15]?l||(l=create_if_block_18(),l.c(),l.m(t,r)):l&&(l.d(1),l=null),!e[16]&&e[7].length>0?u||(u=create_if_block_17(),u.c(),u.m(t,null)):u&&(u.d(1),u=null)},d(e){e&&detach(t),c&&c.d(),l&&l.d(),u&&u.d(),s=!1,i()}}}function create_if_block_24(e){let t;return{c(){t=element("div"),t.innerHTML='No events found.
',attr(t,"class","no-events svelte-4jqeqn")},m(e,n){insert(e,t,n)},p:noop,d(e){e&&detach(t)}}}function create_if_block_19(e){let t,n=e[26],r=[];for(let t=0;t0&&create_if_block_23(e);return{c(){t=element("div"),n=element("span"),n.textContent="🗑️ Delete Event",r=space(),s&&s.c(),attr(n,"class","delete-event-label svelte-4jqeqn"),attr(t,"class","delete-event-info svelte-4jqeqn")},m(e,i){insert(e,t,i),append(t,n),append(t,r),s&&s.m(t,null)},p(e,n){e[120].tags&&e[120].tags.length>0?s?s.p(e,n):(s=create_if_block_23(e),s.c(),s.m(t,null)):s&&(s.d(1),s=null)},d(e){e&&detach(t),s&&s.d()}}}function create_if_block_23(e){let t,n=e[120].tags.filter(func_1),r=[];for(let t=0;t👤',s=space(),i=element("div"),o=element("div"),a=text(x),c=space(),l=element("div"),u=element("span"),d=text(S),h=space(),p=element("span"),f=text(T),g=space(),y=element("div"),m=element("div"),b=text(R),v=space(),I.c(),w=space(),B&&B.c(),_=space(),P&&P.c(),E=space(),attr(r,"class","events-view-avatar svelte-4jqeqn"),attr(o,"class","events-view-author svelte-4jqeqn"),attr(u,"class","kind-number svelte-4jqeqn"),toggle_class(u,"delete-event",5===e[120].kind),attr(p,"class","kind-name svelte-4jqeqn"),attr(l,"class","events-view-kind svelte-4jqeqn"),attr(i,"class","events-view-info svelte-4jqeqn"),attr(m,"class","event-timestamp svelte-4jqeqn"),attr(y,"class","events-view-content svelte-4jqeqn"),attr(n,"class","events-view-row svelte-4jqeqn"),attr(n,"role","button"),attr(n,"tabindex","0"),attr(t,"class","events-view-item svelte-4jqeqn"),toggle_class(t,"expanded",e[14].has(e[120].id))},m(e,x){insert(e,t,x),append(t,n),append(n,r),append(n,s),append(n,i),append(i,o),append(o,a),append(i,c),append(i,l),append(l,u),append(u,d),append(l,h),append(l,p),append(p,f),append(n,g),append(n,y),append(y,m),append(m,b),append(y,v),I.m(y,null),append(n,w),B&&B.m(n,null),append(t,_),P&&P.m(t,null),append(t,E),k||($=[listen(n,"click",D),listen(n,"keydown",L)],k=!0)},p(r,s){e=r,67108864&s[0]&&x!==(x=truncatePubkey(e[120].pubkey)+"")&&set_data(a,x),67108864&s[0]&&S!==(S=e[120].kind+"")&&set_data(d,S),67108864&s[0]&&toggle_class(u,"delete-event",5===e[120].kind),67108864&s[0]&&T!==(T=e[28](e[120].kind)+"")&&set_data(f,T),67108864&s[0]&&R!==(R=formatTimestamp(e[120].created_at)+"")&&set_data(b,R),C===(C=N(e))&&I?I.p(e,s):(I.d(1),I=C(e),I&&(I.c(),I.m(y,null))),5!==e[120].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[120].pubkey&&e[120].pubkey===e[2])?B?B.p(e,s):(B=create_if_block_21(e),B.c(),B.m(n,null)):B&&(B.d(1),B=null),67125248&s[0]&&(A=e[14].has(e[120].id)),A?P?P.p(e,s):(P=create_if_block_20(e),P.c(),P.m(t,E)):P&&(P.d(1),P=null),67125248&s[0]&&toggle_class(t,"expanded",e[14].has(e[120].id))},d(e){e&&detach(t),I.d(),B&&B.d(),P&&P.d(),k=!1,run_all($)}}}function create_if_block_18(e){let t;return{c(){t=element("div"),t.innerHTML=' \n Loading events...
',attr(t,"class","loading-events svelte-4jqeqn")},m(e,n){insert(e,t,n)},d(e){e&&detach(t)}}}function create_if_block_17(e){let t;return{c(){t=element("div"),t.innerHTML='No more events to load.
',attr(t,"class","end-of-events svelte-4jqeqn")},m(e,n){insert(e,t,n)},d(e){e&&detach(t)}}}function create_if_block_14(e){let t,n,r,s,i,o,a,c,l,u,d,h,p,f,g,y;function m(e,t){return e[15]?create_if_block_15:create_else_block_3}let b=m(e),v=b(e);return{c(){t=element("div"),n=element("div"),r=element("label"),s=element("input"),i=space(),o=element("span"),a=space(),c=element("span"),c.textContent="Only show my events",l=space(),u=element("div"),d=element("button"),h=text("🔄 Load More"),p=space(),f=element("button"),v.c(),attr(s,"type","checkbox"),attr(s,"class","svelte-4jqeqn"),attr(o,"class","toggle-slider svelte-4jqeqn"),attr(c,"class","toggle-label svelte-4jqeqn"),attr(r,"class","toggle-container svelte-4jqeqn"),attr(n,"class","events-view-toggle svelte-4jqeqn"),attr(d,"class","refresh-btn svelte-4jqeqn"),d.disabled=e[15],attr(f,"class","reload-btn svelte-4jqeqn"),f.disabled=e[15],attr(u,"class","events-view-buttons svelte-4jqeqn"),attr(t,"class","events-view-header svelte-4jqeqn")},m(m,b){insert(m,t,b),append(t,n),append(n,r),append(r,s),s.checked=e[8],append(r,i),append(r,o),append(r,a),append(r,c),append(t,l),append(t,u),append(u,d),append(d,h),append(u,p),append(u,f),v.m(f,null),g||(y=[listen(s,"change",e[73]),listen(s,"change",e[74]),listen(d,"click",e[75]),listen(f,"click",e[76])],g=!0)},p(e,t){256&t[0]&&(s.checked=e[8]),32768&t[0]&&(d.disabled=e[15]),b!==(b=m(e))&&(v.d(1),v=b(e),v&&(v.c(),v.m(f,null))),32768&t[0]&&(f.disabled=e[15])},d(e){e&&detach(t),v.d(),g=!1,run_all(y)}}}function create_else_block_3(e){let t;return{c(){t=text("🔄")},m(e,n){insert(e,t,n)},d(e){e&&detach(t)}}}function create_if_block_15(e){let t;return{c(){t=element("div"),attr(t,"class","spinner svelte-4jqeqn")},m(e,n){insert(e,t,n)},d(e){e&&detach(t)}}}function create_else_block_2(e){let t,n,r,s,i,o;return{c(){t=element("div"),n=element("p"),n.textContent="Please log in to access import functionality.",r=space(),s=element("button"),s.textContent="Log In",attr(n,"class","svelte-4jqeqn"),attr(s,"class","login-btn svelte-4jqeqn"),attr(t,"class","login-prompt svelte-4jqeqn")},m(a,c){insert(a,t,c),append(t,n),append(t,r),append(t,s),i||(o=listen(s,"click",e[43]),i=!0)},p:noop,d(e){e&&detach(t),i=!1,o()}}}function create_if_block_12(e){let t;return{c(){t=element("div"),t.innerHTML='❌ Admin or owner permission required for import functionality.
',attr(t,"class","permission-denied svelte-4jqeqn")},m(e,n){insert(e,t,n)},p:noop,d(e){e&&detach(t)}}}function create_if_block_11(e){let t,n,r,s,i,o,a,c,l,u,d,h;return{c(){t=element("div"),n=element("h3"),n.textContent="Import Events",r=space(),s=element("p"),s.textContent="Upload a JSONL file to import events into the database.",i=space(),o=element("input"),a=space(),c=element("button"),l=text("📥 Import Events"),attr(n,"class","svelte-4jqeqn"),attr(s,"class","svelte-4jqeqn"),attr(o,"type","file"),attr(o,"id","import-file"),attr(o,"accept",".jsonl,.txt"),attr(o,"class","svelte-4jqeqn"),attr(c,"class","import-btn svelte-4jqeqn"),c.disabled=u=!e[13],attr(t,"class","import-section svelte-4jqeqn")},m(u,p){insert(u,t,p),append(t,n),append(t,r),append(t,s),append(t,i),append(t,o),append(t,a),append(t,c),append(c,l),d||(h=[listen(o,"change",e[57]),listen(c,"click",e[58])],d=!0)},p(e,t){8192&t[0]&&u!==(u=!e[13])&&(c.disabled=u)},d(e){e&&detach(t),d=!1,run_all(h)}}}function create_else_block_1(e){let t,n,r,s,i,o;return{c(){t=element("div"),n=element("p"),n.textContent="Please log in to access export functionality.",r=space(),s=element("button"),s.textContent="Log In",attr(n,"class","svelte-4jqeqn"),attr(s,"class","login-btn svelte-4jqeqn"),attr(t,"class","login-prompt svelte-4jqeqn")},m(a,c){insert(a,t,c),append(t,n),append(t,r),append(t,s),i||(o=listen(s,"click",e[43]),i=!0)},p:noop,d(e){e&&detach(t),i=!1,o()}}}function create_if_block_8(e){let t,n,r,s,i,o,a,c,l,u,d=("admin"===e[4]||"owner"===e[4])&&create_if_block_9(e);return{c(){t=element("div"),n=element("h3"),n.textContent="Export My Events",r=space(),s=element("p"),s.textContent="Download your personal events as a JSONL file.",i=space(),o=element("button"),o.textContent="📤 Export My Events",a=space(),d&&d.c(),c=empty(),attr(n,"class","svelte-4jqeqn"),attr(s,"class","svelte-4jqeqn"),attr(o,"class","export-btn svelte-4jqeqn"),attr(t,"class","export-section svelte-4jqeqn")},m(h,p){insert(h,t,p),append(t,n),append(t,r),append(t,s),append(t,i),append(t,o),insert(h,a,p),d&&d.m(h,p),insert(h,c,p),l||(u=listen(o,"click",e[56]),l=!0)},p(e,t){"admin"===e[4]||"owner"===e[4]?d?d.p(e,t):(d=create_if_block_9(e),d.c(),d.m(c.parentNode,c)):d&&(d.d(1),d=null)},d(e){e&&detach(t),e&&detach(a),d&&d.d(e),e&&detach(c),l=!1,u()}}}function create_if_block_9(e){let t,n,r,s,i,o,a,c;return{c(){t=element("div"),n=element("h3"),n.textContent="Export All Events",r=space(),s=element("p"),s.textContent="Download the complete database as a JSONL file. This includes all events from all users.",i=space(),o=element("button"),o.textContent="📤 Export All Events",attr(n,"class","svelte-4jqeqn"),attr(s,"class","svelte-4jqeqn"),attr(o,"class","export-btn svelte-4jqeqn"),attr(t,"class","export-section svelte-4jqeqn")},m(l,u){insert(l,t,u),append(t,n),append(t,r),append(t,s),append(t,i),append(t,o),a||(c=listen(o,"click",e[55]),a=!0)},p:noop,d(e){e&&detach(t),a=!1,c()}}}function create_if_block(e){let t,n,r,s,i,o,a,c,l,u;function d(e,t){return e[3]?create_if_block_1:e[1]&&e[2]?create_if_block_6:void 0}let h=d(e),p=h&&h(e);return{c(){t=element("div"),n=element("div"),r=element("div"),s=element("h2"),s.textContent="Settings",i=space(),o=element("button"),o.textContent="✕",a=space(),c=element("div"),p&&p.c(),attr(s,"class","svelte-4jqeqn"),attr(o,"class","close-btn svelte-4jqeqn"),attr(r,"class","drawer-header svelte-4jqeqn"),attr(c,"class","drawer-content"),attr(n,"class","settings-drawer svelte-4jqeqn"),toggle_class(n,"dark-theme",e[0]),attr(t,"class","drawer-overlay svelte-4jqeqn"),attr(t,"role","button"),attr(t,"tabindex","0")},m(d,h){insert(d,t,h),append(t,n),append(n,r),append(r,s),append(r,i),append(r,o),append(n,a),append(n,c),p&&p.m(c,null),l||(u=[listen(o,"click",e[48]),listen(n,"click",stop_propagation(e[63])),listen(n,"keydown",stop_propagation(e[64])),listen(t,"click",e[48]),listen(t,"keydown",e[85])],l=!0)},p(e,t){h===(h=d(e))&&p?p.p(e,t):(p&&p.d(1),p=h&&h(e),p&&(p.c(),p.m(c,null))),1&t[0]&&toggle_class(n,"dark-theme",e[0])},d(e){e&&detach(t),p&&p.d(),l=!1,run_all(u)}}}function create_if_block_6(e){let t,n,r,s,i,o,a,c,l,u,d,h,p,f,g,y=e[2].slice(0,16)+"",m=e[2].slice(-8)+"";return{c(){t=element("div"),n=element("h3"),n.textContent="Profile Loading",r=space(),s=element("p"),s.textContent="Your profile metadata is being loaded...",i=space(),o=element("button"),o.textContent="Retry Loading Profile",a=space(),c=element("div"),l=element("strong"),l.textContent="Public Key:",u=space(),d=text(y),h=text("..."),p=text(m),attr(n,"class","svelte-4jqeqn"),attr(s,"class","svelte-4jqeqn"),attr(o,"class","retry-profile-btn svelte-4jqeqn"),attr(c,"class","user-pubkey-display svelte-4jqeqn"),attr(t,"class","profile-loading-section svelte-4jqeqn")},m(y,m){insert(y,t,m),append(t,n),append(t,r),append(t,s),append(t,i),append(t,o),append(t,a),append(t,c),append(c,l),append(c,u),append(c,d),append(c,h),append(c,p),f||(g=listen(o,"click",e[54]),f=!0)},p(e,t){4&t[0]&&y!==(y=e[2].slice(0,16)+"")&&set_data(d,y),4&t[0]&&m!==(m=e[2].slice(-8)+"")&&set_data(p,m)},d(e){e&&detach(t),f=!1,g()}}}function create_if_block_1(e){let t,n,r,s,i,o,a,c,l,u,d,h,p,f=(e[3].name||"Unknown User")+"",g=e[3].banner&&create_if_block_5(e);function y(e,t){return e[3].picture?create_if_block_4:create_else_block}let m=y(e),b=m(e),v=e[3].nip05&&create_if_block_3(e),w=e[3].about&&create_if_block_2(e);return{c(){t=element("div"),n=element("div"),g&&g.c(),r=space(),s=element("button"),s.textContent="Log out",i=space(),b.c(),o=space(),a=element("div"),c=element("h3"),l=text(f),u=space(),v&&v.c(),d=space(),w&&w.c(),attr(s,"class","logout-btn floating svelte-4jqeqn"),attr(c,"class","profile-username svelte-4jqeqn"),attr(a,"class","name-row svelte-4jqeqn"),attr(n,"class","profile-hero svelte-4jqeqn"),attr(t,"class","profile-section svelte-4jqeqn")},m(f,y){insert(f,t,y),append(t,n),g&&g.m(n,null),append(n,r),append(n,s),append(n,i),b.m(n,null),append(n,o),append(n,a),append(a,c),append(c,l),append(a,u),v&&v.m(a,null),append(t,d),w&&w.m(t,null),h||(p=listen(s,"click",e[45]),h=!0)},p(e,s){e[3].banner?g?g.p(e,s):(g=create_if_block_5(e),g.c(),g.m(n,r)):g&&(g.d(1),g=null),m===(m=y(e))&&b?b.p(e,s):(b.d(1),b=m(e),b&&(b.c(),b.m(n,o))),8&s[0]&&f!==(f=(e[3].name||"Unknown User")+"")&&set_data(l,f),e[3].nip05?v?v.p(e,s):(v=create_if_block_3(e),v.c(),v.m(a,null)):v&&(v.d(1),v=null),e[3].about?w?w.p(e,s):(w=create_if_block_2(e),w.c(),w.m(t,null)):w&&(w.d(1),w=null)},d(e){e&&detach(t),g&&g.d(),b.d(),v&&v.d(),w&&w.d(),h=!1,p()}}}function create_if_block_5(e){let t,n;return{c(){t=element("img"),src_url_equal(t.src,n=e[3].banner)||attr(t,"src",n),attr(t,"alt","Profile banner"),attr(t,"class","profile-banner svelte-4jqeqn")},m(e,n){insert(e,t,n)},p(e,r){8&r[0]&&!src_url_equal(t.src,n=e[3].banner)&&attr(t,"src",n)},d(e){e&&detach(t)}}}function create_else_block(e){let t;return{c(){t=element("div"),t.textContent="👤",attr(t,"class","profile-avatar-placeholder overlap svelte-4jqeqn")},m(e,n){insert(e,t,n)},p:noop,d(e){e&&detach(t)}}}function create_if_block_4(e){let t,n;return{c(){t=element("img"),src_url_equal(t.src,n=e[3].picture)||attr(t,"src",n),attr(t,"alt","User avatar"),attr(t,"class","profile-avatar overlap svelte-4jqeqn")},m(e,n){insert(e,t,n)},p(e,r){8&r[0]&&!src_url_equal(t.src,n=e[3].picture)&&attr(t,"src",n)},d(e){e&&detach(t)}}}function create_if_block_3(e){let t,n,r=e[3].nip05+"";return{c(){t=element("span"),n=text(r),attr(t,"class","profile-nip05-inline svelte-4jqeqn")},m(e,r){insert(e,t,r),append(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&set_data(n,r)},d(e){e&&detach(t)}}}function create_if_block_2(e){let t,n;return{c(){t=element("div"),n=element("p"),attr(n,"class","profile-about svelte-4jqeqn"),attr(t,"class","about-card svelte-4jqeqn")},m(r,s){insert(r,t,s),append(t,n),n.innerHTML=e[25]},p(e,t){33554432&t[0]&&(n.innerHTML=e[25])},d(e){e&&detach(t)}}}function create_fragment(e){let t,n,r,s,i,o,a,c,l,u,d,h,p,f,g,y,m,b,v,w,_,E,k,$,x,S,T=e[0]?"☀️":"🌙";function R(e,t){return e[11]?create_if_block_44:create_else_block_11}let A=R(e),N=A(e);function C(e,t){return e[1]?create_if_block_42:create_else_block_10}let I=C(e),B=I(e),D=e[24],L=[];for(let t=0;tbind(E,"showModal",q)),E.$on("login",e[44]),E.$on("close",e[46]),{c(){t=element("header"),n=element("div"),r=element("img"),i=space(),N.c(),o=space(),a=element("button"),a.textContent="🔍",c=space(),l=element("button"),u=text(T),d=space(),B.c(),h=space(),p=element("div"),f=element("aside"),g=element("div"),y=element("div");for(let e=0;ek=!1)),E.$set(s)},i(e){$||(transition_in(E.$$.fragment,e),$=!0)},o(e){transition_out(E.$$.fragment,e),$=!1},d(e){e&&detach(t),N.d(),B.d(),e&&detach(h),e&&detach(p),destroy_each(L,e),U.d(),e&&detach(w),O&&O.d(e),e&&detach(_),destroy_component(E,e),x=!1,run_all(S)}}}function truncatePubkey(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function truncateContent(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function formatTimestamp(e){return e?new Date(1e3*e).toLocaleString():""}function escapeHtml(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}const func_1=e=>"e"===e[0];function instance(e,t,n){let r,s,i,o,a=!1,c=!1,l=!1,u="",d="",h=null,p="",f=null,g=!1,y="export",m=!1,b="",v=[],w=[],_=null,E=new Set,k=!1,$=!0,x=null,S=new Map,T=[],R=0;const A=3e5;let N=!1,C=[],I=!0,B=null,D="",L=null,P=[],F=!1,U="",O="info",q=!1,M=null;const K={0:"ProfileMetadata",1:"TextNote",2:"RecommendRelay",3:"FollowList",4:"EncryptedDirectMessage",5:"EventDeletion",6:"Repost",7:"Reaction",8:"BadgeAward",13:"Seal",14:"PrivateDirectMessage",15:"ReadReceipt",16:"GenericRepost",40:"ChannelCreation",41:"ChannelMetadata",42:"ChannelMessage",43:"ChannelHideMessage",44:"ChannelMuteUser",1021:"Bid",1022:"BidConfirmation",1040:"OpenTimestamps",1059:"GiftWrap",1060:"GiftWrapWithKind4",1063:"FileMetadata",1311:"LiveChatMessage",1517:"BitcoinBlock",1808:"LiveStream",1971:"ProblemTracker",1984:"Reporting",1985:"Label",4550:"CommunityPostApproval",5e3:"JobRequestStart",5999:"JobRequestEnd",6e3:"JobResultStart",6999:"JobResultEnd",7e3:"JobFeedback",9041:"ZapGoal",9734:"ZapRequest",9735:"Zap",9882:"Highlights",1e4:"BlockList",10001:"PinList",10002:"RelayListMetadata",10003:"BookmarkList",10004:"CommunitiesList",10005:"PublicChatsList",10006:"BlockedRelaysList",10007:"SearchRelaysList",10015:"InterestsList",10030:"UserEmojiList",10050:"DMRelaysList",10096:"FileStorageServerList",13004:"JWTBinding",13194:"NWCWalletServiceInfo",19999:"ReplaceableEnd",2e4:"EphemeralStart",21e3:"LightningPubRPC",22242:"ClientAuthentication",23194:"WalletRequest",23195:"WalletResponse",23196:"WalletNotificationNip4",23197:"WalletNotification",24133:"NostrConnect",27235:"HTTPAuth",29999:"EphemeralEnd",3e4:"FollowSets",30001:"GenericLists",30002:"RelaySets",30003:"BookmarkSets",30004:"CurationSets",30008:"ProfileBadges",30009:"BadgeDefinition",30015:"InterestSets",30017:"StallDefinition",30018:"ProductDefinition",30019:"MarketplaceUIUX",30020:"ProductSoldAsAuction",30023:"LongFormContent",30024:"DraftLongFormContent",30030:"EmojiSets"};function j(e){E.has(e)?E.delete(e):E.add(e),n(14,E)}async function H(){console.log("Toggle changed, showOnlyMyEvents:",N);const e=N&&l&&u?[u]:null;await ce(!0,e)}async function V(e){if(!l)return void alert("Please log in first");const t=w.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===p||"owner"===p||"write"===p&&t.pubkey&&t.pubkey===u){if(confirm("Are you sure you want to delete this event?"))try{if(!f)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",u),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const s=await f.signEvent(r);console.log("Signed delete event:",s),console.log("Signed delete event pubkey:",s.pubkey),console.log("Delete event tags:",s.tags);const i=t.pubkey&&t.pubkey===u;if(i){const t=await nostrClient.publish(s);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await fetchEventById(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await fetchDeleteEventsByTarget(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===u);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(7,w=w.filter(t=>t.id!==e)),C=C.filter(t=>t.id!==e),T=T.filter(t=>t.id!==e);for(const[t,n]of S)n.events&&(n.events=n.events.filter(t=>t.id!==e),S.set(t,n));z(),console.log("Reloading events to show delete event...");const r=N&&l&&u?[u]:null;await ce(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`wss://${window.location.host}/`,r=new NostrClient;await r.connectToRelay(t);const i=await r.publish(s);if(console.log("Delete event published to local relay only:",i),!(i.success&&i.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await fetchEventById(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${i.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await fetchDeleteEventsByTarget(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===u);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(7,w=w.filter(t=>t.id!==e)),C=C.filter(t=>t.id!==e),T=T.filter(t=>t.id!==e);for(const[t,n]of S)n.events&&(n.events=n.events.filter(t=>t.id!==e),S.set(t,n));z(),console.log("Reloading events to show delete event...");const t=N&&l&&u?[u]:null;await ce(!0,t),alert("Event deleted successfully (local relay only - admin/owner deleting other user's event)")}}}catch(e){console.error("Failed to delete event:",e),alert("Failed to delete event: "+e.message)}}else alert("You do not have permission to delete this event")}if("undefined"!=typeof localStorage){const e=localStorage.getItem("isDarkTheme");null!==e&&(a=JSON.parse(e));const t=localStorage.getItem("nostr_auth_method"),r=localStorage.getItem("nostr_pubkey");t&&r&&(l=!0,u=r,d=t,"extension"===t&&window.nostr&&(f=window.nostr),oe()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&Q.some(e=>e.id===r.selectedTab)&&n(5,y=r.selectedTab),r.expandedEvents&&n(14,E=new Set(r.expandedEvents)),r.globalEventsCache&&(T=r.globalEventsCache),r.globalCacheTimestamp&&(R=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&n(16,$=r.hasMoreEvents),r.oldestEventTimestamp&&(x=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(I=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(B=r.oldestMyEventTimestamp),T.length>0&&((e=R)&&Date.now()-et.created_at-e.created_at),R=Date.now(),z()}async function W(){if(l&&"owner"===p&&q)try{n(20,F=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await de("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(18,L=await e.json()):X("Failed to load sprocket status","error")}catch(e){X(`Error loading sprocket status: ${e.message}`,"error")}finally{n(20,F=!1)}}async function J(){if(l&&"owner"===p)try{n(20,F=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await de("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(19,P=await e.json()):X("Failed to load versions","error")}catch(e){X(`Error loading versions: ${e.message}`,"error")}finally{n(20,F=!1)}}async function Z(e){l&&"owner"===p&&(n(17,D=e.content),X(`Loaded version: ${e.name}`,"success"))}async function Y(e){if(l&&"owner"===p&&confirm(`Are you sure you want to delete version ${e}?`))try{n(20,F=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await de("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)X(`Version ${e} deleted successfully`,"success"),await J();else{X(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){X(`Error deleting version: ${e.message}`,"error")}finally{n(20,F=!1)}}function X(e,t="info"){n(21,U=e),n(22,O=t),setTimeout(()=>{n(21,U="")},5e3)}const Q=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0}];function ee(e){n(5,y=e),"sprocket"===e&&l&&"owner"===p&&q&&(W(),J()),z()}function te(){n(10,g=!1)}function ne(e){n(6,v=v.filter(t=>t.id!==e)),S.delete(e),y===e&&n(5,y="export")}async function re(e,t,n=!0){const r=S.get(e);if(r&&!r.isLoading){r.isLoading=!0,S.set(e,r);try{const s={limit:n?100:200,until:n?Math.floor(Date.now()/1e3):r.oldestTimestamp};console.log("Loading search results for query:",t,"with options:",s);const i=await searchEvents(t,s);if(console.log("Received search results:",i.length,"events"),r.events=n?i.sort((e,t)=>t.created_at-e.created_at):[...r.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!r.oldestTimestamp||et.id===e);t&&await re(e,t.query,!1)}(t)}}async function ie(){if(l&&u&&!h)try{console.log("Auto-fetching profile for:",u),await initializeNostrClient(),n(3,h=await fetchUserProfile(u)),console.log("Profile auto-loaded:",h)}catch(e){console.error("Failed to auto-load profile:",e)}}async function oe(){if(l&&u)try{const e=await fetch(`/api/permissions/${u}`);if(e.ok){const t=await e.json();n(4,p=t.permission||""),console.log("User role loaded:",p)}else console.error("Failed to fetch user role:",e.status),n(4,p="")}catch(e){console.error("Error fetching user role:",e),n(4,p="")}else n(4,p="")}async function ae(e=[]){if(l)if(0!==e.length||"admin"===p||"owner"===p)try{const t=await ue("/api/export","POST"),n=await fetch("/api/export",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const r=await n.blob(),s=window.URL.createObjectURL(r),i=document.createElement("a");i.href=s;const o=n.headers.get("Content-Disposition");let a="events.jsonl";if(o){const e=o.match(/filename="([^"]+)"/);e&&(a=e[1])}i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(s)}catch(e){console.error("Export failed:",e),alert("Export failed: "+e.message)}else alert("Admin or owner permission required to export all events");else alert("Please log in first")}async function ce(e=!1,t=null){if(!l||"write"!==p&&"admin"!==p&&"owner"!==p)alert("Write, admin, or owner permission required");else if(!k){n(15,k=!0),e&&(x=null);try{console.log("Loading events with authors filter:",t,"including delete events");const r=await fetchAllEvents({limit:e?100:200,until:e?Math.floor(Date.now()/1e3):x,authors:t});if(console.log("Received events:",r.length,"events"),t&&r.length>0){const e=r.filter(e=>e.pubkey&&e.pubkey!==u);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",r.length)}if(e?(n(7,w=r.sort((e,t)=>t.created_at-e.created_at)),G(r)):(n(7,w=[...w,...r].sort((e,t)=>t.created_at-e.created_at)),G(w)),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!x||e{if("events"===y){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&le()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(15,k=!1)}}}async function le(){await ce(!1)}async function ue(e,t){if(!l||!u)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+e],["method",t.toUpperCase()]],content:"",pubkey:u};let r;if(f&&"extension"===d)try{r=await f.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==d)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const s=JSON.stringify(r);return`Nostr ${btoa(s)}`}async function de(e,t){if(!l||!u)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+t],["method",e.toUpperCase()]],content:"",pubkey:u};let r;if(f&&"extension"===d)try{r=await f.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==d)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const s=JSON.stringify(r);return btoa(s)}return e.$$.update=()=>{if(390&e.$$.dirty[0]&&n(26,r=(N&&l&&u?w.filter(e=>e.pubkey&&e.pubkey===u):w).sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(25,s=h?.about?escapeHtml(h.about).replace(/\n{2,}/g,"
"):""),18&e.$$.dirty[0]|1073741824&e.$$.dirty[1]&&n(62,i=Q.filter(e=>!(e.requiresAdmin&&(!l||"admin"!==p&&"owner"!==p))&&(!(e.requiresOwner&&(!l||"owner"!==p))&&!("sprocket"===e.id&&!q)))),64&e.$$.dirty[0]|1&e.$$.dirty[2]&&n(24,o=[...i,...v]),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(a?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&l&&u&&!h&&ie(),438&e.$$.dirty[0]&&"events"===y&&l&&("write"===p||"admin"===p||"owner"===p)&&0===w.length){ce(!0,N&&u?[u]:null)}},[a,l,u,h,p,y,v,w,N,c,g,m,b,_,E,k,$,D,L,P,F,U,O,M,o,s,r,S,function(e){return K[e]||`Kind ${e}`},j,H,V,async function(){if(l&&"owner"===p)try{n(20,F=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await de("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(17,D=t.script_content||""),n(18,L=t),X("Script loaded successfully","success")}else X("Failed to load script","error")}catch(e){X(`Error loading script: ${e.message}`,"error")}finally{n(20,F=!1)}},async function(){if(l&&"owner"===p)try{n(20,F=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await de("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:D});if(e.ok)X("Script saved and updated successfully","success"),await W(),await J();else{X(`Failed to save script: ${await e.text()}`,"error")}}catch(e){X(`Error saving script: ${e.message}`,"error")}finally{n(20,F=!1)}},async function(){if(l&&"owner"===p)try{n(20,F=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await de("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)X("Sprocket restarted successfully","success"),await W();else{X(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){X(`Error restarting sprocket: ${e.message}`,"error")}finally{n(20,F=!1)}},async function(){if(l&&"owner"===p&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(20,F=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await de("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(17,D=""),X("Sprocket script deleted successfully","success"),await W(),await J();else{X(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){X(`Error deleting script: ${e.message}`,"error")}finally{n(20,F=!1)}},J,Z,Y,function(e){n(23,M=e.target.files[0])},async function(){if(l&&"owner"===p&&M)try{n(20,F=!0);const e=await M.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await de("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(17,D=e),X("Script uploaded and updated successfully","success"),await W(),await J();else{X(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){X(`Error uploading script: ${e.message}`,"error")}finally{n(20,F=!1),n(23,M=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},ee,function(){n(0,a=!a),"undefined"!=typeof localStorage&&localStorage.setItem("isDarkTheme",JSON.stringify(a))},function(){l||n(9,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:s,signer:i}=e.detail;n(1,l=!0),n(2,u=r),d=t,f=i,n(9,c=!1);try{if(await initializeNostrClient(),"extension"===t&&i)nostrClient.setSigner(i);else if("nsec"===t&&s){const e=new NDKPrivateKeySigner(s);nostrClient.setSigner(e)}n(3,h=await fetchUserProfile(r)),console.log("Profile loaded:",h)}catch(e){console.error("Failed to load profile:",e)}await oe()},function(){n(1,l=!1),n(2,u=""),d="",n(3,h=null),n(4,p=""),f=null,n(10,g=!1),C=[],n(7,w=[]),T=[],R=0,z(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(9,c=!1)},function(){n(10,g=!0)},te,function(){n(11,m=!m),m||n(12,b="")},function(e){"Enter"===e.key&&b.trim()?(!function(e){const t=`search-${Date.now()}`,r={id:t,icon:"🔍",label:e,isSearchTab:!0,query:e};n(6,v=[...v,r]),n(5,y=t),S.set(t,{events:[],isLoading:!1,hasMore:!0,oldestTimestamp:null}),re(t,e)}(b.trim()),n(12,b=""),n(11,m=!1)):"Escape"===e.key&&(n(11,m=!1),n(12,b=""))},ne,re,se,ie,async function(){await ae([])},async function(){await ae([u])},function(e){n(13,_=e.target.files[0])},async function(){if(!l||"admin"!==p&&"owner"!==p)alert("Admin or owner permission required");else if(_)try{const e=await ue("/api/import","POST"),t=new FormData;t.append("file",_);const r=await fetch("/api/import",{method:"POST",headers:{Authorization:e},body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();alert("Import started successfully"),n(13,_=null),document.getElementById("import-file").value=""}catch(e){console.error("Import failed:",e),alert("Import failed: "+e.message)}else alert("Please select a file")},ce,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&le()},q,i,function(t){bubble.call(this,e,t)},function(t){bubble.call(this,e,t)},e=>e.id===y,function(){b=this.value,n(12,b)},e=>ne(e.id),(e,t)=>"Enter"===t.key&&ne(e.id),e=>ee(e.id),e=>V(e.id),e=>j(e.id),(e,t)=>"Enter"===t.key&&j(e.id),function(){N=this.checked,n(8,N)},()=>H(),()=>{ce(!1,N&&u?[u]:null)},()=>{ce(!0,N&&u?[u]:null)},function(){D=this.value,n(17,D)},e=>Z(e),e=>Y(e.name),e=>re(e.id,e.query,!0),e=>V(e.id),e=>j(e.id),(e,t)=>"Enter"===t.key&&j(e.id),(e,t)=>se(t,e.id),e=>"Escape"===e.key&&te(),function(e){c=e,n(9,c)}]}class App extends SvelteComponent{constructor(e){super(),init(this,e,instance,create_fragment,safe_not_equal,{},null,[-1,-1,-1,-1,-1])}}const app=new App({target:document.body,props:{name:"world"}});return app}();
-//# sourceMappingURL=bundle.js.map
diff --git a/app/web/dist/favicon.png b/app/web/dist/favicon.png
deleted file mode 100644
index 9dac94c7dc3865b036fc4d6f02e6acbbf453b99c..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 526586
zcmeFYcT|&I_coY72)#*{7C=Smy_WzYMNv9PhY*VNj#3hefPjD%1f_@|(ouR19Vt>2
zLnjmgsR0B+37P2gK5tp`tu^a6GvE9%>t!v%o%@_~oxQKU_c{9%9vR-&p{2S=1pokO
z^>nWr0{|f6BM3kNCjLQi3-ubUrY(3^aBOf%y9SxVU@5A%XXO;ShMJy9)piI^|_(
zMAr$Sz^^hZlaL7U^p@Lx4$H(+FVr1OEl^F&8
z`b-Jmi;jKpbwQ@@Qf!7v##FW^vSFYa3MYR7
zZRk-|rA!%`v6ghlP+cNnV^B>ivaMk1@X(W=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