nostr-components 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  **Embed Nostr anywhere on the internet, a Zap Button for every webpage.**
4
4
 
5
- ## 🚀 About the Project
5
+ ## About the Project
6
6
 
7
- Nostr Components makes it easy to embed Zap button, Nostr profiles, posts, and follow buttons in any website. Inspired by <a href="https://unpkg.com/nostr-web-components@0.0.15/demo.html">fiatjaf's Nostr Web Components</a>, this project adds a beautiful UI, a Storybook component generator (for webmasters), and allows embedding Nostr content anywhere on the Internet.
7
+ Nostr Components makes it easy to embed Zap button, Nostr profiles, posts, and follow buttons in any website. Inspired by <a href="https://unpkg.com/nostr-web-components@latest/demo.html">fiatjaf's Nostr Web Components</a>, this project adds a beautiful UI, a Storybook component generator (for webmasters), and allows embedding Nostr content anywhere on the Internet.
8
8
 
9
9
  * **[Zap button](#1-nostr-zap)**
10
10
  * **[Follow button](#2-nostr-follow)**
@@ -14,7 +14,7 @@ Nostr Components makes it easy to embed Zap button, Nostr profiles, posts, and f
14
14
  * **[Post](#6-nostr-post)**
15
15
  * **[WordPress Integration](#7-wordpress-integration)**
16
16
 
17
- ## 🛠️ Usage
17
+ ## Usage
18
18
 
19
19
  ### Quick Start
20
20
 
@@ -25,23 +25,25 @@ Add the component script to your HTML's `<head>`. Each component can be loaded i
25
25
  ```html
26
26
  <head>
27
27
  <!-- Load individual component (recommended for smaller bundles) -->
28
- <script type="module" src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-follow-button.es.js"></script>
28
+ <script type="module" src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-profile.es.js"></script>
29
29
 
30
- <!-- Or load the full bundle -->
30
+ <!-- Or load the full bundle: ES -->
31
+ <script type="module" src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/nostr-components.es.js"></script>
32
+
33
+ <!-- Or load the full bundle: UMD -->
31
34
  <script src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/nostr-components.umd.js"></script>
32
- <!-- Components auto-register when the script loads, no init() needed -->
33
- <!-- Optional: Call init() for explicit initialization (for backward compatibility) -->
34
- <script>
35
- // Components are already registered automatically
36
- // You can optionally call init() for explicit initialization
37
- if (window.NostrComponents && window.NostrComponents.default) {
38
- window.NostrComponents.default.init();
39
- } else if (window.NostrComponents && window.NostrComponents.init) {
40
- // Fallback: use named export
41
- window.NostrComponents.init();
42
- }
43
- </script>
35
+
36
+ <!-- Optional: Dark theme -->
37
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nostr-components@0.3.2/dist/themes/dark.css">
44
38
  </head>
39
+ <body>
40
+ <h1> Welcome to My home page </h1>
41
+ <nostr-zap nip05="saiy2k@iris.to" url="https://nostr-components.web.app/"></nostr-zap>
42
+ <nostr-profile npub="npub1qsvv5ttv6mrlh38q8ydmw3gzwq360mdu8re2vr7rk68sqmhmsh4svhsft3"></nostr-profile>
43
+ <nostr-like></nostr-like>
44
+
45
+ <!-- For more components, see blow -->
46
+ </body>
45
47
  ```
46
48
 
47
49
  #### Option 2: NPM Package
@@ -56,27 +58,12 @@ Then import components in your JavaScript/TypeScript:
56
58
 
57
59
  ```javascript
58
60
  // Import individual components
59
- import 'nostr-components/dist/components/nostr-follow-button.es.js';
60
- import 'nostr-components/dist/components/nostr-zap.es.js';
61
- import 'nostr-components/dist/components/nostr-like.es.js';
61
+ // [Will update here soon]
62
62
 
63
63
  // Or import the full bundle
64
- import 'nostr-components/dist/nostr-components.es.js';
65
- ```
66
-
67
- For bundlers (Vite, Webpack, etc.), you can also import the source:
68
-
69
- ```javascript
70
- // Import from source (requires bundler)
71
- import { NostrFollowButton } from 'nostr-components';
72
- import { NostrZap } from 'nostr-components';
73
- import { NostrLike } from 'nostr-components';
64
+ import 'nostr-components';
74
65
  ```
75
66
 
76
- **Note:** When using npm packages, make sure your bundler is configured to handle Web Components properly.
77
-
78
- **Use the Components:** Place the component tags anywhere in your `<body>`.
79
-
80
67
  ### Authentication
81
68
 
82
69
  All interactive components (Follow, Like, Zap) require user authentication. Components use [NostrLogin](https://github.com/nostrband/nostr-login) which supports:
@@ -89,18 +76,23 @@ The authentication flow is handled automatically when users interact with compon
89
76
 
90
77
  ## 1. Nostr Zap
91
78
 
92
- A Lightning Network zap button that allows users to send sats to any Nostr user with a lightning address or LNURL.
79
+ A Zap button that allows users to send sats to any Nostr user or a URL associated with a User.
80
+ What is ~[https://www.youtube.com/shorts/PDnrh8pkF3g](Zap)?
93
81
 
94
82
  **Usage:**
95
83
 
96
84
  ```html
97
85
  <head>
98
- <script type="module" src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-zap.es.js"></script>
86
+ <script
87
+ type="module"
88
+ src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-zap.es.js">
89
+ </script>
99
90
  </head>
100
91
  <body>
101
92
  <nostr-zap
102
93
  npub="npub1qsvv5ttv6mrlh38q8ydmw3gzwq360mdu8re2vr7rk68sqmhmsh4svhsft3"
103
94
  theme="dark"
95
+ url="https://nostr-components.web.app/"
104
96
  text="⚡ Zap Me"
105
97
  ></nostr-zap>
106
98
  </body>
@@ -147,14 +139,20 @@ When URL is not specified, current URL is taken.
147
139
 
148
140
  ```html
149
141
  <head>
150
- <script type="module" src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-like.es.js"></script>
142
+ <script
143
+ type="module"
144
+ src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-like.es.js">
145
+ </script>
151
146
  </head>
152
147
  <body>
153
148
  <!-- Like the current page URL -->
154
149
  <nostr-like></nostr-like>
155
150
 
156
151
  <!-- Like a specific URL with custom text -->
157
- <nostr-like url="https://github.com/saiy2k/nostr-components" text="❤️"></nostr-like>
152
+ <nostr-like
153
+ url="https://github.com/saiy2k/nostr-components"
154
+ text="❤️">
155
+ </nostr-like>
158
156
  </body>
159
157
  ```
160
158
 
@@ -198,7 +196,10 @@ A detailed profile card showing avatar, name, bio, notes count, followers, etc.
198
196
 
199
197
  ```html
200
198
  <head>
201
- <script type="module" src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-profile.es.js"></script>
199
+ <script
200
+ type="module"
201
+ src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-profile.es.js">
202
+ </script>
202
203
  </head>
203
204
  <body>
204
205
  <nostr-profile
@@ -221,7 +222,9 @@ Embed any Nostr post by providing the event ID.
221
222
 
222
223
  ```html
223
224
  <head>
224
- <script type="module" src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-post.es.js"></script>
225
+ <script
226
+ type="module"
227
+ src="https://cdn.jsdelivr.net/npm/nostr-components@latest/dist/components/nostr-post.es.js"></script>
225
228
  </head>
226
229
  <body>
227
230
  <nostr-post
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/zap-utils-QRxLBOst.js","assets/nostr-service-CA0Qx4nJ.js","assets/nostr-login-service-D2FmscPI.js","assets/preload-helper-D7HrI6pR.js","assets/utils--bxLbhGF.js"])))=>i.map(i=>d[i]);
2
- import{_ as y}from"./preload-helper-D7HrI6pR.js";import"./dialog-component-Da1ZIYh9.js";import{getBatchedProfileMetadata as x,extractProfileMetadataContent as k}from"./zap-utils-QRxLBOst.js";import{j as p,e as g,k as b,i as v}from"./base-styles-Dmuzg8I4.js";import"./nostr-service-CA0Qx4nJ.js";import"./nostr-login-service-D2FmscPI.js";import"./utils--bxLbhGF.js";function $(t="light"){const e=t==="dark";return`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/zap-utils-BiKkJPt6.js","assets/nostr-service-CA0Qx4nJ.js","assets/nostr-login-service-D2FmscPI.js","assets/preload-helper-D7HrI6pR.js","assets/utils--bxLbhGF.js"])))=>i.map(i=>d[i]);
2
+ import{_ as y}from"./preload-helper-D7HrI6pR.js";import"./dialog-component-Da1ZIYh9.js";import{getBatchedProfileMetadata as x,extractProfileMetadataContent as k}from"./zap-utils-BiKkJPt6.js";import{j as p,e as g,k as b,i as v}from"./base-styles-Dmuzg8I4.js";import"./nostr-service-CA0Qx4nJ.js";import"./nostr-login-service-D2FmscPI.js";import"./utils--bxLbhGF.js";function $(t="light"){const e=t==="dark";return`
3
3
  .likers-dialog-content {
4
4
  padding: 0;
5
5
  max-height: 60vh;
@@ -234,5 +234,5 @@ import{_ as y}from"./preload-helper-D7HrI6pR.js";import"./dialog-component-Da1ZI
234
234
  ${t.map((a,n)=>P(a,e[n],n)).join("")}
235
235
  </div>
236
236
  </div>
237
- `}async function N(t,e){const r=t.querySelector(".likers-list");if(!r)return;const a=[...new Set(e.map(n=>n.authorPubkey))];console.log("Nostr-Components: Likers dialog: Fetching profiles for",a.length,"unique authors");try{const n=await x(a),i=new Map;n.forEach(o=>{i.set(o.id,o.profile)});const s=new Map;a.forEach(o=>{s.set(o,p(o))});for(let o=0;o<e.length;o++){const l=e[o],c=i.get(l.authorPubkey),d=s.get(l.authorPubkey)||l.authorPubkey;let u;if(c){const h=k(c);u={...l,authorName:h.display_name||h.name||d,authorPicture:h.picture,authorNpub:d}}else u={...l,authorName:d,authorNpub:d};const f=r.querySelector(`[data-like-index="${o}"]`);if(f){const h=m(u,o);f.outerHTML=h}}console.log("Nostr-Components: Likers dialog: Progressive enhancement completed for",e.length,"like entries")}catch(n){console.error("Nostr-Components: Likers dialog: Error in batched profile enhancement",n),console.log("Nostr-Components: Likers dialog: Falling back to individual profile fetching"),await E(t,e)}}async function E(t,e){const r=t.querySelector(".likers-list");if(!r)return;const a=new Map,n=e.map(async(i,s)=>{if(a.has(i.authorPubkey)){const o=a.get(i.authorPubkey);return{index:s,enhanced:{...i,authorName:o.authorName,authorPicture:o.authorPicture,authorNpub:o.authorNpub}}}try{const{getProfileMetadata:o}=await y(async()=>{const{getProfileMetadata:f}=await import("./zap-utils-QRxLBOst.js");return{getProfileMetadata:f}},__vite__mapDeps([0,1,2,3,4])),l=await o(i.authorPubkey),c=k(l),d=p(i.authorPubkey),u={...i,authorName:c.display_name||c.name||d,authorPicture:c.picture,authorNpub:d};return a.set(i.authorPubkey,u),{index:s,enhanced:u}}catch(o){console.error("Nostr-Components: Likers dialog: Error fetching profile for",i.authorPubkey,o);const l=p(i.authorPubkey),c={...i,authorName:l,authorNpub:l};return a.set(i.authorPubkey,c),{index:s,enhanced:c}}});for(const i of n)try{const{index:s,enhanced:o}=await i,l=r.querySelector(`[data-like-index="${s}"]`);if(l){const c=m(o,s);l.outerHTML=c}}catch(s){console.error("Nostr-Components: Likers dialog: Error processing profile enhancement",s)}}export{w as injectLikersDialogStyles,D as openLikersDialog};
238
- //# sourceMappingURL=dialog-likers-B15m_NxI.js.map
237
+ `}async function N(t,e){const r=t.querySelector(".likers-list");if(!r)return;const a=[...new Set(e.map(n=>n.authorPubkey))];console.log("Nostr-Components: Likers dialog: Fetching profiles for",a.length,"unique authors");try{const n=await x(a),i=new Map;n.forEach(o=>{i.set(o.id,o.profile)});const s=new Map;a.forEach(o=>{s.set(o,p(o))});for(let o=0;o<e.length;o++){const l=e[o],c=i.get(l.authorPubkey),d=s.get(l.authorPubkey)||l.authorPubkey;let u;if(c){const h=k(c);u={...l,authorName:h.display_name||h.name||d,authorPicture:h.picture,authorNpub:d}}else u={...l,authorName:d,authorNpub:d};const f=r.querySelector(`[data-like-index="${o}"]`);if(f){const h=m(u,o);f.outerHTML=h}}console.log("Nostr-Components: Likers dialog: Progressive enhancement completed for",e.length,"like entries")}catch(n){console.error("Nostr-Components: Likers dialog: Error in batched profile enhancement",n),console.log("Nostr-Components: Likers dialog: Falling back to individual profile fetching"),await E(t,e)}}async function E(t,e){const r=t.querySelector(".likers-list");if(!r)return;const a=new Map,n=e.map(async(i,s)=>{if(a.has(i.authorPubkey)){const o=a.get(i.authorPubkey);return{index:s,enhanced:{...i,authorName:o.authorName,authorPicture:o.authorPicture,authorNpub:o.authorNpub}}}try{const{getProfileMetadata:o}=await y(async()=>{const{getProfileMetadata:f}=await import("./zap-utils-BiKkJPt6.js");return{getProfileMetadata:f}},__vite__mapDeps([0,1,2,3,4])),l=await o(i.authorPubkey),c=k(l),d=p(i.authorPubkey),u={...i,authorName:c.display_name||c.name||d,authorPicture:c.picture,authorNpub:d};return a.set(i.authorPubkey,u),{index:s,enhanced:u}}catch(o){console.error("Nostr-Components: Likers dialog: Error fetching profile for",i.authorPubkey,o);const l=p(i.authorPubkey),c={...i,authorName:l,authorNpub:l};return a.set(i.authorPubkey,c),{index:s,enhanced:c}}});for(const i of n)try{const{index:s,enhanced:o}=await i,l=r.querySelector(`[data-like-index="${s}"]`);if(l){const c=m(o,s);l.outerHTML=c}}catch(s){console.error("Nostr-Components: Likers dialog: Error processing profile enhancement",s)}}export{w as injectLikersDialogStyles,D as openLikersDialog};
238
+ //# sourceMappingURL=dialog-likers-Bq6kUbS0.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";4WAEO,SAASA,EAAsBC,EAA0B,QAAiB,CAC/E,MAAMC,EAASD,IAAU,OAEzB,MAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAkBWC,EAAS,UAAY,SAAS;AAAA,0BACxBA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKpCA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAsB9BA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAiBnCA,EAAS,UAAY,SAAS;AAAA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yles","theme","isDark","injectLikersDialogStyles","style","renderLikeEntry","like","index","authorNameSafe","escapeHtml","njumpUrl","hexToNpub","profilePictureSafe","isValidUrl","profilePicture","isDislike","statusText","statusClass","formatRelativeTime","renderSkeletonLikeEntry","npub","openLikersDialog","params","likeDetails","dialogComponent","initialContent","renderInitialContent","dialogElement","_a","dialog","enhanceLikeDetailsProgressively","npubs","likersList","uniqueAuthorIds","profileResults","getBatchedProfileMetadata","profileMap","result","npubMap","pubkey","profile","enhanced","profileContent","extractProfileMetadataContent","skeletonEntry","enhancedEntry","error","enhanceLikeDetailsIndividually","profileCache","profilePromises","cachedProfile","getProfileMetadata","__vitePreload","profileMetadata","promise"],"ignoreList":[],"sources":["../../src/nostr-like/dialog-likers-style.ts","../../src/nostr-like/dialog-likers.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n\nexport function getLikersDialogStyles(theme: 'light' | 'dark' = 'light'): string {\n const isDark = theme === 'dark';\n \n return `\n .likers-dialog-content {\n padding: 0;\n max-height: 60vh;\n overflow-y: auto;\n }\n\n .likers-list {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .like-entry {\n display: flex;\n align-items: center;\n padding: 12px;\n border-radius: 8px;\n background: ${isDark ? '#2a2a2a' : '#f8f9fa'};\n border: 1px solid ${isDark ? '#3a3a3a' : '#e9ecef'};\n transition: background-color 0.2s ease;\n }\n\n .like-entry:hover {\n background: ${isDark ? '#3a3a3a' : '#e9ecef'};\n }\n\n .like-author-info {\n display: flex;\n align-items: center;\n gap: 12px;\n width: 100%;\n }\n\n .like-author-picture {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n }\n\n .like-author-picture-default {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: ${isDark ? '#3a3a3a' : '#e9ecef'};\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n flex-shrink: 0;\n }\n\n .like-author-details {\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 1;\n min-width: 0;\n }\n\n .like-author-link {\n color: ${isDark ? '#ffffff' : '#000000'};\n text-decoration: none;\n font-weight: 500;\n font-size: 14px;\n transition: color 0.2s ease;\n }\n\n .like-author-link:hover {\n color: ${isDark ? '#4a9eff' : '#1877f2'};\n text-decoration: underline;\n }\n\n .like-date {\n color: ${isDark ? '#b0b0b0' : '#65676b'};\n font-size: 12px;\n font-weight: 400;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .like-status {\n font-weight: 500;\n font-size: 11px;\n padding: 2px 6px;\n border-radius: 4px;\n }\n\n .like-status.liked {\n color: ${isDark ? '#4a9eff' : '#1877f2'};\n background: ${isDark ? 'rgba(74, 158, 255, 0.1)' : 'rgba(24, 119, 242, 0.1)'};\n }\n\n .like-status.disliked {\n color: #d32f2f;\n background: rgba(211, 47, 47, 0.1);\n }\n\n .no-likes {\n text-align: center;\n color: ${isDark ? '#b0b0b0' : '#65676b'};\n font-size: 14px;\n padding: 40px 20px;\n }\n\n /* Skeleton loading states */\n .skeleton-entry {\n opacity: 0.7;\n }\n\n .skeleton-picture {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: linear-gradient(90deg, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 25%, \n ${isDark ? '#4a4a4a' : '#e0e0e0'} 50%, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n flex-shrink: 0;\n }\n\n .skeleton-name {\n width: 120px;\n height: 14px;\n background: linear-gradient(90deg, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 25%, \n ${isDark ? '#4a4a4a' : '#e0e0e0'} 50%, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n border-radius: 2px;\n }\n\n @keyframes skeleton-loading {\n 0% {\n background-position: -200% 0;\n }\n 100% {\n background-position: 200% 0;\n }\n }\n\n /* Responsive */\n @media (max-width: 480px) {\n .likers-dialog-content {\n max-height: 70vh;\n }\n\n .like-entry {\n padding: 10px;\n }\n\n .like-author-picture,\n .like-author-picture-default,\n .skeleton-picture {\n width: 36px;\n height: 36px;\n }\n\n .like-author-link {\n font-size: 13px;\n }\n\n .like-date {\n font-size: 11px;\n }\n }\n\n /* Scrollbar styling */\n .likers-dialog-content::-webkit-scrollbar {\n width: 6px;\n }\n\n .likers-dialog-content::-webkit-scrollbar-track {\n background: ${isDark ? '#2a2a2a' : '#f1f1f1'};\n border-radius: 3px;\n }\n\n .likers-dialog-content::-webkit-scrollbar-thumb {\n background: ${isDark ? '#555' : '#c1c1c1'};\n border-radius: 3px;\n }\n\n .likers-dialog-content::-webkit-scrollbar-thumb:hover {\n background: ${isDark ? '#777' : '#a8a8a8'};\n }\n `;\n}\n","// SPDX-License-Identifier: MIT\n\n// Import for side effects to register the custom element\nimport '../base/dialog-component/dialog-component';\nimport type { DialogComponent } from '../base/dialog-component/dialog-component';\nimport { getLikersDialogStyles } from './dialog-likers-style';\nimport { getBatchedProfileMetadata, extractProfileMetadataContent } from '../nostr-zap/zap-utils';\nimport { escapeHtml, formatRelativeTime, hexToNpub, isValidUrl } from '../common/utils';\nimport { LikeDetails } from './like-utils';\n\n/**\n * Modal dialog for displaying individual like details (likers).\n * \n * Shows a list of all users who liked a URL with:\n * - User's name\n * - User's profile picture\n * - Time of like (relative time)\n * - Clickable links to user profiles via njump.me\n */\n\nexport interface OpenLikersModalParams {\n likeDetails: LikeDetails[];\n theme?: 'light' | 'dark';\n}\n\n/**\n * Inject likers dialog content styles into document head\n * Prevents duplicate injection by checking for existing styles\n */\nexport const injectLikersDialogStyles = (theme: 'light' | 'dark' = 'light') => {\n // Remove existing likers dialog styles\n const existingStyles = document.querySelectorAll('style[data-likers-dialog-styles]');\n existingStyles.forEach(style => style.remove());\n \n const style = document.createElement('style');\n style.setAttribute('data-likers-dialog-styles', 'true');\n style.textContent = getLikersDialogStyles(theme);\n document.head.appendChild(style);\n}\n\ninterface EnhancedLikeDetails extends LikeDetails {\n authorName?: string;\n authorPicture?: string;\n authorNpub?: string;\n}\n\n/**\n * Render individual like entry HTML (with profile data)\n */\nfunction renderLikeEntry(like: EnhancedLikeDetails, index: number): string {\n const authorNameSafe = escapeHtml(like.authorName || 'Unknown liker');\n const npubSafe = like.authorNpub || hexToNpub(like.authorPubkey);\n const njumpUrl = `https://njump.me/${npubSafe}`;\n const profilePictureSafe = isValidUrl(like.authorPicture || '') ? like.authorPicture || '' : '';\n \n const profilePicture = profilePictureSafe \n ? `<img src=\"${profilePictureSafe}\" alt=\"${authorNameSafe}\" class=\"like-author-picture\" />`\n : `<div class=\"like-author-picture-default\">👤</div>`;\n \n const isDislike = like.content === '-';\n const statusText = isDislike ? 'Disliked' : 'Liked';\n const statusClass = isDislike ? 'disliked' : 'liked';\n \n return `\n <div class=\"like-entry\" data-like-index=\"${index}\" data-author-pubkey=\"${like.authorPubkey}\">\n <div class=\"like-author-info\">\n ${profilePicture}\n <div class=\"like-author-details\">\n <a href=\"${njumpUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"like-author-link\">\n ${authorNameSafe}\n </a>\n <div class=\"like-date\">\n ${formatRelativeTime(Math.floor(like.date.getTime() / 1000))}\n <span class=\"like-status ${statusClass}\">${statusText}</span>\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Render skeleton like entry HTML (with npub)\n */\nfunction renderSkeletonLikeEntry(like: LikeDetails, npub: string, index: number): string {\n const isDislike = like.content === '-';\n const statusText = isDislike ? 'Disliked' : 'Liked';\n const statusClass = isDislike ? 'disliked' : 'liked';\n \n return `\n <div class=\"like-entry skeleton-entry\" data-like-index=\"${index}\" data-author-pubkey=\"${like.authorPubkey}\">\n <div class=\"like-author-info\">\n <div class=\"skeleton-picture\"></div>\n <div class=\"like-author-details\">\n <div class=\"like-author-link skeleton-name\">\n ${escapeHtml(npub)}\n </div>\n <div class=\"like-date\">\n ${formatRelativeTime(Math.floor(like.date.getTime() / 1000))}\n <span class=\"like-status ${statusClass}\">${statusText}</span>\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Opens the likers dialog showing individual like details\n */\nexport async function openLikersDialog(params: OpenLikersModalParams): Promise<DialogComponent> {\n const { likeDetails, theme = 'light' } = params;\n \n // Inject styles\n injectLikersDialogStyles(theme);\n \n // Ensure custom element is defined\n if (!customElements.get('dialog-component')) {\n await customElements.whenDefined('dialog-component');\n }\n \n // Create dialog component (not added to DOM)\n const dialogComponent = document.createElement('dialog-component') as DialogComponent;\n dialogComponent.setAttribute('header', 'Likers');\n if (params.theme) {\n dialogComponent.setAttribute('data-theme', params.theme);\n }\n \n // Initial content with skeleton loaders showing npubs\n const initialContent = await renderInitialContent(likeDetails);\n dialogComponent.innerHTML = initialContent;\n \n // Show the dialog (this will create and append the actual dialog element)\n dialogComponent.showModal();\n \n // Get the actual dialog element for progressive enhancement\n const dialogElement: HTMLDialogElement | null = \n dialogComponent.querySelector('.nostr-base-dialog') ||\n dialogComponent.shadowRoot?.querySelector('.nostr-base-dialog') ||\n document.body.querySelector('.nostr-base-dialog');\n \n if (!dialogElement) {\n console.error('[openLikersDialog] Failed to find dialog element after showModal()');\n throw new Error('Dialog element not found. The dialog may not have been created properly.');\n }\n \n // Type assertion: dialog is guaranteed to be non-null after the check above\n const dialog = dialogElement as HTMLDialogElement;\n \n // Start progressive enhancement\n if (dialog && likeDetails.length > 0) {\n enhanceLikeDetailsProgressively(dialog, likeDetails);\n }\n\n return dialogComponent;\n}\n\n/**\n * Render initial dialog content with skeleton loaders showing npubs\n */\nasync function renderInitialContent(likeDetails: LikeDetails[]): Promise<string> {\n if (likeDetails.length === 0) {\n return `\n <div class=\"likers-dialog-content\">\n <div class=\"likers-list\">\n <div class=\"no-likes\">No likes yet</div>\n </div>\n </div>\n `;\n }\n\n // Convert all pubkeys to npubs for immediate display\n const npubs = likeDetails.map(like => hexToNpub(like.authorPubkey));\n\n const skeletonEntries = likeDetails.map((like, index) => \n renderSkeletonLikeEntry(like, npubs[index], index)\n ).join('');\n\n return `\n <div class=\"likers-dialog-content\">\n <div class=\"likers-list\">\n ${skeletonEntries}\n </div>\n </div>\n `;\n}\n\n/**\n * Progressively enhance like details with profile information (batched approach)\n */\nasync function enhanceLikeDetailsProgressively(dialog: HTMLDialogElement, likeDetails: LikeDetails[]): Promise<void> {\n const likersList = dialog.querySelector('.likers-list') as HTMLElement;\n if (!likersList) return;\n\n // Get unique author IDs\n const uniqueAuthorIds = [...new Set(likeDetails.map(like => like.authorPubkey))];\n console.log(\"Nostr-Components: Likers dialog: Fetching profiles for\", uniqueAuthorIds.length, \"unique authors\");\n\n try {\n // Fetch all profiles in a single batched call\n const profileResults = await getBatchedProfileMetadata(uniqueAuthorIds);\n \n // Create a map for quick lookup\n const profileMap = new Map<string, any>();\n profileResults.forEach(result => {\n profileMap.set(result.id, result.profile);\n });\n\n // Convert all pubkeys to npubs for display\n const npubMap = new Map<string, string>();\n uniqueAuthorIds.forEach(pubkey => {\n npubMap.set(pubkey, hexToNpub(pubkey));\n });\n\n // Process each like entry\n for (let index = 0; index < likeDetails.length; index++) {\n const like = likeDetails[index];\n const profile = profileMap.get(like.authorPubkey);\n const npub = npubMap.get(like.authorPubkey) || like.authorPubkey;\n \n let enhanced: EnhancedLikeDetails;\n \n if (profile) {\n const profileContent = extractProfileMetadataContent(profile);\n enhanced = {\n ...like,\n authorName: profileContent.display_name || profileContent.name || npub,\n authorPicture: profileContent.picture,\n authorNpub: npub,\n };\n } else {\n // Fallback if profile not found\n enhanced = {\n ...like,\n authorName: npub,\n authorNpub: npub,\n };\n }\n\n // Find the corresponding skeleton entry by index and replace it\n const skeletonEntry = likersList.querySelector(`[data-like-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderLikeEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n }\n\n console.log(\"Nostr-Components: Likers dialog: Progressive enhancement completed for\", likeDetails.length, \"like entries\");\n } catch (error) {\n console.error(\"Nostr-Components: Likers dialog: Error in batched profile enhancement\", error);\n \n // Fallback to individual processing if batched approach fails\n console.log(\"Nostr-Components: Likers dialog: Falling back to individual profile fetching\");\n await enhanceLikeDetailsIndividually(dialog, likeDetails);\n }\n}\n\n/**\n * Fallback: Enhance like details individually (original approach)\n */\nasync function enhanceLikeDetailsIndividually(dialog: HTMLDialogElement, likeDetails: LikeDetails[]): Promise<void> {\n const likersList = dialog.querySelector('.likers-list') as HTMLElement;\n if (!likersList) return;\n\n // Create a map to track which profiles we've already fetched\n const profileCache = new Map<string, EnhancedLikeDetails>();\n \n // Fetch all profile metadata in parallel\n const profilePromises = likeDetails.map(async (like, index) => {\n // Check if we already have this profile cached\n if (profileCache.has(like.authorPubkey)) {\n const cachedProfile = profileCache.get(like.authorPubkey)!;\n return {\n index,\n enhanced: {\n ...like,\n authorName: cachedProfile.authorName,\n authorPicture: cachedProfile.authorPicture,\n authorNpub: cachedProfile.authorNpub,\n }\n };\n }\n\n try {\n const { getProfileMetadata } = await import('../nostr-zap/zap-utils');\n const profileMetadata = await getProfileMetadata(like.authorPubkey);\n const profileContent = extractProfileMetadataContent(profileMetadata);\n const npub = hexToNpub(like.authorPubkey);\n \n const enhanced = {\n ...like,\n authorName: profileContent.display_name || profileContent.name || npub,\n authorPicture: profileContent.picture,\n authorNpub: npub,\n };\n\n // Cache the profile for other entries from the same author\n profileCache.set(like.authorPubkey, enhanced);\n \n return {\n index,\n enhanced\n };\n } catch (error) {\n console.error(\"Nostr-Components: Likers dialog: Error fetching profile for\", like.authorPubkey, error);\n // Fallback with just pubkey converted to npub\n const npub = hexToNpub(like.authorPubkey);\n const enhanced = {\n ...like,\n authorName: npub,\n authorNpub: npub,\n };\n \n // Cache the fallback profile\n profileCache.set(like.authorPubkey, enhanced);\n \n return {\n index,\n enhanced\n };\n }\n });\n\n // Process each profile as it becomes available\n for (const promise of profilePromises) {\n try {\n const { index, enhanced } = await promise;\n \n // Find the corresponding skeleton entry by index and replace it\n const skeletonEntry = likersList.querySelector(`[data-like-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderLikeEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n } catch (error) {\n console.error(\"Nostr-Components: Likers dialog: Error processing profile enhancement\", error);\n }\n }\n}\n"],"file":"assets/dialog-likers-B15m_NxI.js"}
1
+ {"version":3,"mappings":";4WAEO,SAASA,EAAsBC,EAA0B,QAAiB,CAC/E,MAAMC,EAASD,IAAU,OAEzB,MAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAkBWC,EAAS,UAAY,SAAS;AAAA,0BACxBA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKpCA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAsB9BA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAiBnCA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAQ9BA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,eAK9BA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAgB9BA,EAAS,UAAY,SAAS;AAAA,oBACzBA,EAAS,0BAA4B,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAUnEA,EAAS,UAAY,SAAS;AAAA;AAAA;A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EAA8BU,CAAe,EAC9DjC,EAAOT,EAAUL,EAAK,YAAY,EAElCmC,EAAW,CACf,GAAGnC,EACH,WAAYoC,EAAe,cAAgBA,EAAe,MAAQtB,EAClE,cAAesB,EAAe,QAC9B,WAAYtB,CAAA,EAId,OAAA4B,EAAa,IAAI1C,EAAK,aAAcmC,CAAQ,EAErC,CACL,MAAAlC,EACA,SAAAkC,CAAA,CAEJ,OAASK,EAAO,CACd,QAAQ,MAAM,8DAA+DxC,EAAK,aAAcwC,CAAK,EAErG,MAAM1B,EAAOT,EAAUL,EAAK,YAAY,EAClCmC,EAAW,CACf,GAAGnC,EACH,WAAYc,EACZ,WAAYA,CAAA,EAId,OAAA4B,EAAa,IAAI1C,EAAK,aAAcmC,CAAQ,EAErC,CACL,MAAAlC,EACA,SAAAkC,CAAA,CAEJ,CACF,CAAC,EAGD,UAAWa,KAAWL,EACpB,GAAI,CACF,KAAM,CAAE,MAAA1C,EAAO,SAAAkC,CAAA,EAAa,MAAMa,EAG5BV,EAAgBZ,EAAW,cAAc,qBAAqBzB,CAAK,IAAI,EAC7E,GAAIqC,EAAe,CACjB,MAAMC,EAAgBxC,EAAgBoC,EAAUlC,CAAK,EACrDqC,EAAc,UAAYC,CAC5B,CACF,OAASC,EAAO,CACd,QAAQ,MAAM,wEAAyEA,CAAK,CAC9F,CAEJ","names":["getLikersDialogStyles","theme","isDark","injectLikersDialogStyles","style","renderLikeEntry","like","index","authorNameSafe","escapeHtml","njumpUrl","hexToNpub","profilePictureSafe","isValidUrl","profilePicture","isDislike","statusText","statusClass","formatRelativeTime","renderSkeletonLikeEntry","npub","openLikersDialog","params","likeDetails","dialogComponent","initialContent","renderInitialContent","dialogElement","_a","dialog","enhanceLikeDetailsProgressively","npubs","likersList","uniqueAuthorIds","profileResults","getBatchedProfileMetadata","profileMap","result","npubMap","pubkey","profile","enhanced","profileContent","extractProfileMetadataContent","skeletonEntry","enhancedEntry","error","enhanceLikeDetailsIndividually","profileCache","profilePromises","cachedProfile","getProfileMetadata","__vitePreload","profileMetadata","promise"],"ignoreList":[],"sources":["../../src/nostr-like/dialog-likers-style.ts","../../src/nostr-like/dialog-likers.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n\nexport function getLikersDialogStyles(theme: 'light' | 'dark' = 'light'): string {\n const isDark = theme === 'dark';\n \n return `\n .likers-dialog-content {\n padding: 0;\n max-height: 60vh;\n overflow-y: auto;\n }\n\n .likers-list {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .like-entry {\n display: flex;\n align-items: center;\n padding: 12px;\n border-radius: 8px;\n background: ${isDark ? '#2a2a2a' : '#f8f9fa'};\n border: 1px solid ${isDark ? '#3a3a3a' : '#e9ecef'};\n transition: background-color 0.2s ease;\n }\n\n .like-entry:hover {\n background: ${isDark ? '#3a3a3a' : '#e9ecef'};\n }\n\n .like-author-info {\n display: flex;\n align-items: center;\n gap: 12px;\n width: 100%;\n }\n\n .like-author-picture {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n }\n\n .like-author-picture-default {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: ${isDark ? '#3a3a3a' : '#e9ecef'};\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n flex-shrink: 0;\n }\n\n .like-author-details {\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 1;\n min-width: 0;\n }\n\n .like-author-link {\n color: ${isDark ? '#ffffff' : '#000000'};\n text-decoration: none;\n font-weight: 500;\n font-size: 14px;\n transition: color 0.2s ease;\n }\n\n .like-author-link:hover {\n color: ${isDark ? '#4a9eff' : '#1877f2'};\n text-decoration: underline;\n }\n\n .like-date {\n color: ${isDark ? '#b0b0b0' : '#65676b'};\n font-size: 12px;\n font-weight: 400;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .like-status {\n font-weight: 500;\n font-size: 11px;\n padding: 2px 6px;\n border-radius: 4px;\n }\n\n .like-status.liked {\n color: ${isDark ? '#4a9eff' : '#1877f2'};\n background: ${isDark ? 'rgba(74, 158, 255, 0.1)' : 'rgba(24, 119, 242, 0.1)'};\n }\n\n .like-status.disliked {\n color: #d32f2f;\n background: rgba(211, 47, 47, 0.1);\n }\n\n .no-likes {\n text-align: center;\n color: ${isDark ? '#b0b0b0' : '#65676b'};\n font-size: 14px;\n padding: 40px 20px;\n }\n\n /* Skeleton loading states */\n .skeleton-entry {\n opacity: 0.7;\n }\n\n .skeleton-picture {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: linear-gradient(90deg, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 25%, \n ${isDark ? '#4a4a4a' : '#e0e0e0'} 50%, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n flex-shrink: 0;\n }\n\n .skeleton-name {\n width: 120px;\n height: 14px;\n background: linear-gradient(90deg, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 25%, \n ${isDark ? '#4a4a4a' : '#e0e0e0'} 50%, \n ${isDark ? '#3a3a3a' : '#f0f0f0'} 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n border-radius: 2px;\n }\n\n @keyframes skeleton-loading {\n 0% {\n background-position: -200% 0;\n }\n 100% {\n background-position: 200% 0;\n }\n }\n\n /* Responsive */\n @media (max-width: 480px) {\n .likers-dialog-content {\n max-height: 70vh;\n }\n\n .like-entry {\n padding: 10px;\n }\n\n .like-author-picture,\n .like-author-picture-default,\n .skeleton-picture {\n width: 36px;\n height: 36px;\n }\n\n .like-author-link {\n font-size: 13px;\n }\n\n .like-date {\n font-size: 11px;\n }\n }\n\n /* Scrollbar styling */\n .likers-dialog-content::-webkit-scrollbar {\n width: 6px;\n }\n\n .likers-dialog-content::-webkit-scrollbar-track {\n background: ${isDark ? '#2a2a2a' : '#f1f1f1'};\n border-radius: 3px;\n }\n\n .likers-dialog-content::-webkit-scrollbar-thumb {\n background: ${isDark ? '#555' : '#c1c1c1'};\n border-radius: 3px;\n }\n\n .likers-dialog-content::-webkit-scrollbar-thumb:hover {\n background: ${isDark ? '#777' : '#a8a8a8'};\n }\n `;\n}\n","// SPDX-License-Identifier: MIT\n\n// Import for side effects to register the custom element\nimport '../base/dialog-component/dialog-component';\nimport type { DialogComponent } from '../base/dialog-component/dialog-component';\nimport { getLikersDialogStyles } from './dialog-likers-style';\nimport { getBatchedProfileMetadata, extractProfileMetadataContent } from '../nostr-zap/zap-utils';\nimport { escapeHtml, formatRelativeTime, hexToNpub, isValidUrl } from '../common/utils';\nimport { LikeDetails } from './like-utils';\n\n/**\n * Modal dialog for displaying individual like details (likers).\n * \n * Shows a list of all users who liked a URL with:\n * - User's name\n * - User's profile picture\n * - Time of like (relative time)\n * - Clickable links to user profiles via njump.me\n */\n\nexport interface OpenLikersModalParams {\n likeDetails: LikeDetails[];\n theme?: 'light' | 'dark';\n}\n\n/**\n * Inject likers dialog content styles into document head\n * Prevents duplicate injection by checking for existing styles\n */\nexport const injectLikersDialogStyles = (theme: 'light' | 'dark' = 'light') => {\n // Remove existing likers dialog styles\n const existingStyles = document.querySelectorAll('style[data-likers-dialog-styles]');\n existingStyles.forEach(style => style.remove());\n \n const style = document.createElement('style');\n style.setAttribute('data-likers-dialog-styles', 'true');\n style.textContent = getLikersDialogStyles(theme);\n document.head.appendChild(style);\n}\n\ninterface EnhancedLikeDetails extends LikeDetails {\n authorName?: string;\n authorPicture?: string;\n authorNpub?: string;\n}\n\n/**\n * Render individual like entry HTML (with profile data)\n */\nfunction renderLikeEntry(like: EnhancedLikeDetails, index: number): string {\n const authorNameSafe = escapeHtml(like.authorName || 'Unknown liker');\n const npubSafe = like.authorNpub || hexToNpub(like.authorPubkey);\n const njumpUrl = `https://njump.me/${npubSafe}`;\n const profilePictureSafe = isValidUrl(like.authorPicture || '') ? like.authorPicture || '' : '';\n \n const profilePicture = profilePictureSafe \n ? `<img src=\"${profilePictureSafe}\" alt=\"${authorNameSafe}\" class=\"like-author-picture\" />`\n : `<div class=\"like-author-picture-default\">👤</div>`;\n \n const isDislike = like.content === '-';\n const statusText = isDislike ? 'Disliked' : 'Liked';\n const statusClass = isDislike ? 'disliked' : 'liked';\n \n return `\n <div class=\"like-entry\" data-like-index=\"${index}\" data-author-pubkey=\"${like.authorPubkey}\">\n <div class=\"like-author-info\">\n ${profilePicture}\n <div class=\"like-author-details\">\n <a href=\"${njumpUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"like-author-link\">\n ${authorNameSafe}\n </a>\n <div class=\"like-date\">\n ${formatRelativeTime(Math.floor(like.date.getTime() / 1000))}\n <span class=\"like-status ${statusClass}\">${statusText}</span>\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Render skeleton like entry HTML (with npub)\n */\nfunction renderSkeletonLikeEntry(like: LikeDetails, npub: string, index: number): string {\n const isDislike = like.content === '-';\n const statusText = isDislike ? 'Disliked' : 'Liked';\n const statusClass = isDislike ? 'disliked' : 'liked';\n \n return `\n <div class=\"like-entry skeleton-entry\" data-like-index=\"${index}\" data-author-pubkey=\"${like.authorPubkey}\">\n <div class=\"like-author-info\">\n <div class=\"skeleton-picture\"></div>\n <div class=\"like-author-details\">\n <div class=\"like-author-link skeleton-name\">\n ${escapeHtml(npub)}\n </div>\n <div class=\"like-date\">\n ${formatRelativeTime(Math.floor(like.date.getTime() / 1000))}\n <span class=\"like-status ${statusClass}\">${statusText}</span>\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Opens the likers dialog showing individual like details\n */\nexport async function openLikersDialog(params: OpenLikersModalParams): Promise<DialogComponent> {\n const { likeDetails, theme = 'light' } = params;\n \n // Inject styles\n injectLikersDialogStyles(theme);\n \n // Ensure custom element is defined\n if (!customElements.get('dialog-component')) {\n await customElements.whenDefined('dialog-component');\n }\n \n // Create dialog component (not added to DOM)\n const dialogComponent = document.createElement('dialog-component') as DialogComponent;\n dialogComponent.setAttribute('header', 'Likers');\n if (params.theme) {\n dialogComponent.setAttribute('data-theme', params.theme);\n }\n \n // Initial content with skeleton loaders showing npubs\n const initialContent = await renderInitialContent(likeDetails);\n dialogComponent.innerHTML = initialContent;\n \n // Show the dialog (this will create and append the actual dialog element)\n dialogComponent.showModal();\n \n // Get the actual dialog element for progressive enhancement\n const dialogElement: HTMLDialogElement | null = \n dialogComponent.querySelector('.nostr-base-dialog') ||\n dialogComponent.shadowRoot?.querySelector('.nostr-base-dialog') ||\n document.body.querySelector('.nostr-base-dialog');\n \n if (!dialogElement) {\n console.error('[openLikersDialog] Failed to find dialog element after showModal()');\n throw new Error('Dialog element not found. The dialog may not have been created properly.');\n }\n \n // Type assertion: dialog is guaranteed to be non-null after the check above\n const dialog = dialogElement as HTMLDialogElement;\n \n // Start progressive enhancement\n if (dialog && likeDetails.length > 0) {\n enhanceLikeDetailsProgressively(dialog, likeDetails);\n }\n\n return dialogComponent;\n}\n\n/**\n * Render initial dialog content with skeleton loaders showing npubs\n */\nasync function renderInitialContent(likeDetails: LikeDetails[]): Promise<string> {\n if (likeDetails.length === 0) {\n return `\n <div class=\"likers-dialog-content\">\n <div class=\"likers-list\">\n <div class=\"no-likes\">No likes yet</div>\n </div>\n </div>\n `;\n }\n\n // Convert all pubkeys to npubs for immediate display\n const npubs = likeDetails.map(like => hexToNpub(like.authorPubkey));\n\n const skeletonEntries = likeDetails.map((like, index) => \n renderSkeletonLikeEntry(like, npubs[index], index)\n ).join('');\n\n return `\n <div class=\"likers-dialog-content\">\n <div class=\"likers-list\">\n ${skeletonEntries}\n </div>\n </div>\n `;\n}\n\n/**\n * Progressively enhance like details with profile information (batched approach)\n */\nasync function enhanceLikeDetailsProgressively(dialog: HTMLDialogElement, likeDetails: LikeDetails[]): Promise<void> {\n const likersList = dialog.querySelector('.likers-list') as HTMLElement;\n if (!likersList) return;\n\n // Get unique author IDs\n const uniqueAuthorIds = [...new Set(likeDetails.map(like => like.authorPubkey))];\n console.log(\"Nostr-Components: Likers dialog: Fetching profiles for\", uniqueAuthorIds.length, \"unique authors\");\n\n try {\n // Fetch all profiles in a single batched call\n const profileResults = await getBatchedProfileMetadata(uniqueAuthorIds);\n \n // Create a map for quick lookup\n const profileMap = new Map<string, any>();\n profileResults.forEach(result => {\n profileMap.set(result.id, result.profile);\n });\n\n // Convert all pubkeys to npubs for display\n const npubMap = new Map<string, string>();\n uniqueAuthorIds.forEach(pubkey => {\n npubMap.set(pubkey, hexToNpub(pubkey));\n });\n\n // Process each like entry\n for (let index = 0; index < likeDetails.length; index++) {\n const like = likeDetails[index];\n const profile = profileMap.get(like.authorPubkey);\n const npub = npubMap.get(like.authorPubkey) || like.authorPubkey;\n \n let enhanced: EnhancedLikeDetails;\n \n if (profile) {\n const profileContent = extractProfileMetadataContent(profile);\n enhanced = {\n ...like,\n authorName: profileContent.display_name || profileContent.name || npub,\n authorPicture: profileContent.picture,\n authorNpub: npub,\n };\n } else {\n // Fallback if profile not found\n enhanced = {\n ...like,\n authorName: npub,\n authorNpub: npub,\n };\n }\n\n // Find the corresponding skeleton entry by index and replace it\n const skeletonEntry = likersList.querySelector(`[data-like-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderLikeEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n }\n\n console.log(\"Nostr-Components: Likers dialog: Progressive enhancement completed for\", likeDetails.length, \"like entries\");\n } catch (error) {\n console.error(\"Nostr-Components: Likers dialog: Error in batched profile enhancement\", error);\n \n // Fallback to individual processing if batched approach fails\n console.log(\"Nostr-Components: Likers dialog: Falling back to individual profile fetching\");\n await enhanceLikeDetailsIndividually(dialog, likeDetails);\n }\n}\n\n/**\n * Fallback: Enhance like details individually (original approach)\n */\nasync function enhanceLikeDetailsIndividually(dialog: HTMLDialogElement, likeDetails: LikeDetails[]): Promise<void> {\n const likersList = dialog.querySelector('.likers-list') as HTMLElement;\n if (!likersList) return;\n\n // Create a map to track which profiles we've already fetched\n const profileCache = new Map<string, EnhancedLikeDetails>();\n \n // Fetch all profile metadata in parallel\n const profilePromises = likeDetails.map(async (like, index) => {\n // Check if we already have this profile cached\n if (profileCache.has(like.authorPubkey)) {\n const cachedProfile = profileCache.get(like.authorPubkey)!;\n return {\n index,\n enhanced: {\n ...like,\n authorName: cachedProfile.authorName,\n authorPicture: cachedProfile.authorPicture,\n authorNpub: cachedProfile.authorNpub,\n }\n };\n }\n\n try {\n const { getProfileMetadata } = await import('../nostr-zap/zap-utils');\n const profileMetadata = await getProfileMetadata(like.authorPubkey);\n const profileContent = extractProfileMetadataContent(profileMetadata);\n const npub = hexToNpub(like.authorPubkey);\n \n const enhanced = {\n ...like,\n authorName: profileContent.display_name || profileContent.name || npub,\n authorPicture: profileContent.picture,\n authorNpub: npub,\n };\n\n // Cache the profile for other entries from the same author\n profileCache.set(like.authorPubkey, enhanced);\n \n return {\n index,\n enhanced\n };\n } catch (error) {\n console.error(\"Nostr-Components: Likers dialog: Error fetching profile for\", like.authorPubkey, error);\n // Fallback with just pubkey converted to npub\n const npub = hexToNpub(like.authorPubkey);\n const enhanced = {\n ...like,\n authorName: npub,\n authorNpub: npub,\n };\n \n // Cache the fallback profile\n profileCache.set(like.authorPubkey, enhanced);\n \n return {\n index,\n enhanced\n };\n }\n });\n\n // Process each profile as it becomes available\n for (const promise of profilePromises) {\n try {\n const { index, enhanced } = await promise;\n \n // Find the corresponding skeleton entry by index and replace it\n const skeletonEntry = likersList.querySelector(`[data-like-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderLikeEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n } catch (error) {\n console.error(\"Nostr-Components: Likers dialog: Error processing profile enhancement\", error);\n }\n }\n}\n"],"file":"assets/dialog-likers-Bq6kUbS0.js"}
@@ -0,0 +1,2 @@
1
+ import{S as k,h as N,i as P}from"./nostr-service-CA0Qx4nJ.js";import{e as R,s as S}from"./nostr-login-service-D2FmscPI.js";import{n as E}from"./utils--bxLbhGF.js";import"./preload-helper-D7HrI6pR.js";const d={},x=async t=>{if(d[t])return d[t];const e=new k,s=["wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{const a=await e.get(s,{authors:[t],kinds:[0]});return d[t]=a,a}finally{e.close(s)}},D=async t=>{const e=t.filter(r=>!d[r]);if(e.length===0)return t.map(r=>({id:r,profile:d[r]}));const s=new k,a=["wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{return(await s.querySync(a,{authors:e,kinds:[0]})).forEach(n=>{d[n.pubkey]=n}),t.map(n=>({id:n,profile:d[n]||null}))}finally{s.close(a)}},J=t=>{try{return JSON.parse((t==null?void 0:t.content)||"{}")}catch{return{}}},I=async t=>{const e=await N.getZapEndpoint(t);if(!e)throw new Error("Failed to retrieve zap LNURL");return e},L=async(t,e)=>{try{return await R(),await S(t)}catch{}return P(t,C())},Z=async({profile:t,nip19Target:e,amount:s,relays:a,comment:r,anon:i,url:n})=>{const f={pubkey:t,amount:s,relays:a,comment:r||""};debugger;const c=N.makeZapRequest(f);n&&(c.tags.push(["k","web"]),c.tags.push(["i",E(n)]));let l=!1;try{await R(),l=typeof window<"u"&&!!window.nostr}catch{l=!1}return(!l||i)&&c.tags.push(["anon"]),L(c)},M=async({zapEndpoint:t,amount:e,comment:s,authorId:a,nip19Target:r,normalizedRelays:i,anon:n,url:f})=>{const c=await Z({profile:a,nip19Target:r,amount:e,relays:i,comment:s??"",anon:n,url:f});let l=`${t}?amount=${e}&nostr=${encodeURIComponent(JSON.stringify(c))}`;s&&(l+=`&comment=${encodeURIComponent(s??"")}`);const p=await fetch(l,{method:"GET"});if(!p.ok)throw new Error(`LNURL request failed: ${p.status} ${p.statusText}`);let m;try{m=await p.json()}catch{throw new Error("Invalid JSON from LNURL endpoint")}const{pr:h,reason:v,status:g}=m||{};if(h)return h;throw g==="ERROR"?new Error(v??"Unable to fetch invoice"):new Error("Unable to fetch invoice")},C=()=>{const t=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else{console.warn("crypto.getRandomValues not available, using Math.random as fallback");for(let e=0;e<32;e++)t[e]=Math.floor(Math.random()*256)}return t},V=async({pubkey:t,relays:e,url:s})=>{var f,c,l,p;const a=s?E(s):void 0,r=new k;let i=0;const n=[];try{const m={kinds:[9735],"#p":[t],limit:1e3},h=await r.querySync(e,m);for(const v of h){const g=(f=v.tags)==null?void 0:f.find(o=>o[0]==="description");if(g!=null&&g[1])try{const o=JSON.parse(g[1]),y=(c=o==null?void 0:o.tags)==null?void 0:c.find(u=>u[0]==="amount");if(a){const u=(l=o==null?void 0:o.tags)==null?void 0:l.find(w=>w[0]==="k"),b=(p=o==null?void 0:o.tags)==null?void 0:p.find(w=>w[0]==="i"),U=b!=null&&b[1]?E(b[1]):"";if((u==null?void 0:u[1])==="web"&&U===a&&(y!=null&&y[1])){const w=parseInt(y[1],10);w>0&&(i+=w,n.push({amount:w/1e3,date:new Date(v.created_at*1e3),authorPubkey:o.pubkey,comment:o.content}))}}else if(y!=null&&y[1]){const u=parseInt(y[1],10);u>0&&(i+=u,n.push({amount:u/1e3,date:new Date(v.created_at*1e3),authorPubkey:o.pubkey,comment:o.content}))}}catch(o){console.error("Nostr-Components: Zap button: Could not parse zap request from description tag",o)}}}catch(m){console.error("Nostr-Components: Zap button: Error fetching zap receipts",m)}finally{r.close(e)}return n.sort((m,h)=>h.date.getTime()-m.date.getTime()),{totalAmount:i/1e3,zapDetails:n}},_=({relays:t,receiversPubKey:e,invoice:s,onSuccess:a})=>{const r=new k,i=Array.from(new Set(t)),n=Math.floor((Date.now()-24*60*60*1e3)/1e3);r.subscribe(i,{kinds:[9735],"#p":[e],since:n},{onevent(c){c.tags.some(p=>p[0]==="bolt11"&&p[1]===s)&&(a(),f())}});const f=()=>{r.close(i)};return f};export{J as extractProfileMetadataContent,M as fetchInvoice,V as fetchTotalZapAmount,D as getBatchedProfileMetadata,x as getProfileMetadata,I as getZapEndpoint,_ as listenForZapReceipt};
2
+ //# sourceMappingURL=zap-utils-BiKkJPt6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zap-utils-BiKkJPt6.js","sources":["../../src/nostr-zap/zap-utils.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n\nimport {\n nip57,\n nip05,\n finalizeEvent,\n SimplePool,\n} from 'nostr-tools';\nimport { decodeNip19Entity } from '../common/utils';\nimport { ensureInitialized, signEvent as signEventWithNostrLogin } from '../common/nostr-login-service';\n\n/**\n * Helper utilities for Nostr zap operations (adapted from the original `nostr-zap` repo).\n * These are deliberately kept self-contained so `nostr-zap` Web Component can import\n * everything from a single module without polluting the rest of the codebase.\n */\n\n// Basic in-memory cache – sufficient for component lifetime.\nconst profileCache: Record<string, any> = {};\n\nexport const getProfileMetadata = async (authorId: string) => {\n if (profileCache[authorId]) return profileCache[authorId];\n\n const pool = new SimplePool();\n const relays = [\n // 'wss://relay.nostr.band',\n 'wss://purplepag.es',\n 'wss://relay.damus.io',\n 'wss://nostr.wine',\n ];\n\n try {\n const event = await pool.get(relays, {\n authors: [authorId],\n kinds: [0],\n });\n profileCache[authorId] = event;\n return event;\n } finally {\n pool.close(relays);\n }\n};\n\nexport const getBatchedProfileMetadata = async (authorIds: string[]) => {\n // Filter out already cached profiles\n const uncachedIds = authorIds.filter(id => !profileCache[id]);\n\n // If all profiles are cached, return them\n if (uncachedIds.length === 0) {\n return authorIds.map(id => ({ id, profile: profileCache[id] }));\n }\n\n const pool = new SimplePool();\n const relays = [\n // 'wss://relay.nostr.band',\n 'wss://purplepag.es',\n 'wss://relay.damus.io',\n 'wss://nostr.wine',\n ];\n\n try {\n // Fetch all uncached profiles in a single query\n const events = await pool.querySync(relays, {\n authors: uncachedIds,\n kinds: [0],\n });\n\n // Cache the fetched profiles\n events.forEach(event => {\n profileCache[event.pubkey] = event;\n });\n\n // Combine cached and newly fetched profiles\n const allProfiles = authorIds.map(id => ({\n id,\n profile: profileCache[id] || null\n }));\n\n return allProfiles;\n } finally {\n pool.close(relays);\n }\n};\n\nexport const extractProfileMetadataContent = (profileMetadata: any) => {\n try {\n return JSON.parse(profileMetadata?.content || '{}');\n } catch {\n return {};\n }\n};\n\nexport const getZapEndpoint = async (profileMetadata: any) => {\n const endpoint = await nip57.getZapEndpoint(profileMetadata);\n if (!endpoint) throw new Error('Failed to retrieve zap LNURL');\n return endpoint;\n};\n\ninterface NostrExtension {\n signEvent(event: any): Promise<{\n id: string;\n sig: string;\n kind: number;\n tags: string[][];\n pubkey: string;\n content: string;\n created_at: number;\n }>;\n}\n\nconst signEvent = async (zapEvent: any, anon?: boolean) => {\n if (!anon) {\n try {\n await ensureInitialized();\n return await signEventWithNostrLogin(zapEvent);\n } catch {\n /* fall-through -> anonymous */\n }\n }\n return finalizeEvent(zapEvent, generateRandomPrivKey());\n};\n\nconst makeZapEvent = async ({\n profile,\n nip19Target,\n amount,\n relays,\n comment,\n anon,\n url,\n}: {\n profile: string;\n nip19Target?: string;\n amount: number;\n relays: string[];\n comment?: string;\n anon?: boolean;\n url?: string;\n}) => {\n const req: any = {\n pubkey: profile,\n amount,\n relays,\n comment: comment || '',\n };\n if (nip19Target?.startsWith('note')) {\n req.event = decodeNip19Entity(nip19Target);\n }\n debugger;\n const event = nip57.makeZapRequest(req);\n\n if (nip19Target?.startsWith('naddr')) {\n const naddrData: any = decodeNip19Entity(nip19Target);\n const relayTag = naddrData?.relays?.join(',') ?? '';\n event.tags.push(['a', `${naddrData.kind}:${naddrData.pubkey}:${naddrData.identifier}`, relayTag]);\n }\n\n // Add URL-based zap tags if URL is provided\n if (url) {\n event.tags.push(['k', 'web']);\n event.tags.push(['i', normalizeURL(url)]);\n }\n\n // Check if NostrLogin is available (will initialize if needed)\n // Note: We check availability here to decide if we should add 'anon' tag\n // The actual signing happens in signEvent() which will ensure initialization\n let isNostrLoginAvailable = false;\n if (!anon) {\n try {\n await ensureInitialized();\n isNostrLoginAvailable = typeof window !== 'undefined' && !!(window as any).nostr;\n } catch {\n // If initialization fails, fall back to anonymous\n isNostrLoginAvailable = false;\n }\n }\n \n if (!isNostrLoginAvailable || anon) {\n event.tags.push(['anon']);\n }\n\n return signEvent(event, anon);\n};\n\nexport const fetchInvoice = async ({\n zapEndpoint,\n amount,\n comment,\n authorId,\n nip19Target,\n normalizedRelays,\n anon,\n url,\n}: {\n zapEndpoint: string;\n amount: number;\n comment?: string;\n authorId: string;\n nip19Target?: string;\n normalizedRelays: string[];\n anon?: boolean;\n url?: string;\n}): Promise<string> => {\n const zapEvent = await makeZapEvent({\n profile: authorId,\n nip19Target,\n amount,\n relays: normalizedRelays,\n comment: comment ?? '',\n anon,\n url,\n });\n\n\n let invoiceUrl = `${zapEndpoint}?amount=${amount}&nostr=${encodeURIComponent(\n JSON.stringify(zapEvent)\n )}`;\n if (comment) invoiceUrl += `&comment=${encodeURIComponent(comment ?? '')}`;\n\n const res = await fetch(invoiceUrl, { method: 'GET' });\n if (!res.ok) {\n throw new Error(`LNURL request failed: ${res.status} ${res.statusText}`);\n }\n let json: any;\n try {\n json = await res.json();\n } catch {\n throw new Error('Invalid JSON from LNURL endpoint');\n }\n const { pr: invoice, reason, status } = json || {};\n if (invoice) return invoice;\n if (status === 'ERROR') throw new Error(reason ?? 'Unable to fetch invoice');\n throw new Error('Unable to fetch invoice');\n};\n\nconst generateRandomPrivKey = (): Uint8Array => {\n const bytes = new Uint8Array(32);\n if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {\n crypto.getRandomValues(bytes);\n } else {\n // Node.js fallback during build – use Math.random (not cryptographically strong but acceptable for anon zaps)\n console.warn('crypto.getRandomValues not available, using Math.random as fallback');\n for (let i = 0; i < 32; i++) bytes[i] = Math.floor(Math.random() * 256);\n }\n return bytes;\n};\n\n/**\n * Check if NostrLogin is available\n * @deprecated Use ensureInitialized() instead - it will initialize NostrLogin if needed\n */\nexport const isNip07ExtAvailable = (): boolean => {\n // This function is kept for backward compatibility but will always return false\n // until ensureInitialized() is called. Components should use ensureInitialized() instead.\n return typeof window !== 'undefined' && !!(window as any).nostr;\n};\n\n// ---------------------------------------------------------------------------\n// nip05 resolution helper – very lightweight fetch to /.well-known/nostr.json\n// ---------------------------------------------------------------------------\n\n\n\nexport async function resolveNip05(nip05Identifier: string): Promise<string | null> {\n try {\n const profile = await nip05.queryProfile(nip05Identifier);\n return profile?.pubkey || null;\n } catch (error) {\n console.error(`Failed to resolve NIP-05 ${nip05Identifier}:`, error);\n return null;\n }\n}\n\n// Import necessary types from nostr-tools\nimport type { Filter, Event } from 'nostr-tools';\nimport { normalizeURL } from '../nostr-comment/utils';\n\n// Augment the SimplePool type to include our usage\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ndeclare module 'nostr-tools' {\n interface SimplePool {\n subscribe(\n relays: string[],\n filter: Filter,\n params: {\n onevent: (event: Event) => void;\n onclose?: () => void;\n id?: string;\n maxWait?: number;\n }\n ): {\n close: () => void;\n };\n }\n}\n\nexport interface ZapDetails {\n amount: number;\n date: Date;\n authorPubkey: string;\n comment?: string;\n}\n\nexport interface ZapAmountResult {\n totalAmount: number;\n zapDetails: ZapDetails[];\n}\n\nexport const fetchTotalZapAmount = async ({\n pubkey,\n relays,\n url,\n}: {\n pubkey: string;\n relays: string[];\n url?: string;\n}): Promise<ZapAmountResult> => {\n // Normalize URL at the beginning for consistent comparison with tags\n const normalizedUrl = url ? normalizeURL(url) : undefined;\n \n const pool = new SimplePool();\n let totalAmount = 0;\n const zapDetails: ZapDetails[] = [];\n\n try {\n // Build filter for zap receipt events\n const filter: any = {\n kinds: [9735], // Zap receipt\n '#p': [pubkey],\n limit: 1000,\n };\n\n // Add URL-based filtering if URL is provided\n // TODO: These tags doesn't appear in zap receipt event.\n // They goes into the description tag, which has the zap request JSON.\n /*\n if (normalizedUrl) {\n filter['#k'] = ['web'];\n filter['#i'] = [normalizedUrl];\n }\n */\n\n // Use pool.querySync to fetch multiple zap receipt events\n const events = await pool.querySync(relays, filter);\n\n for (const event of events) {\n const descriptionTag = event.tags?.find((tag: string[]) => tag[0] === 'description');\n if (descriptionTag?.[1]) {\n try {\n const zapRequest = JSON.parse(descriptionTag[1]);\n const amountTag = zapRequest?.tags?.find((tag: string[]) => tag[0] === 'amount');\n \n // If URL is provided, check for URL-based zap tags\n // TODO: Too much work, since #k and #i tags doesn't appear in zap receipt event.\n // This is not a practical solution, but it's working for now!\n if (normalizedUrl) {\n const kTag = zapRequest?.tags?.find((tag: string[]) => tag[0] === 'k');\n const iTag = zapRequest?.tags?.find((tag: string[]) => tag[0] === 'i');\n \n const iTagNormalized = iTag?.[1] ? normalizeURL(iTag[1]) : '';\n if (kTag?.[1] === 'web' && iTagNormalized === normalizedUrl && amountTag?.[1]) {\n const amount = parseInt(amountTag[1], 10);\n if (amount > 0) {\n totalAmount += amount;\n zapDetails.push({\n amount: amount / 1000, // convert from msats to sats\n date: new Date(event.created_at * 1000),\n authorPubkey: zapRequest.pubkey,\n comment: zapRequest.content,\n });\n }\n }\n } else {\n // No URL filtering - count all zaps\n if (amountTag?.[1]) {\n const amount = parseInt(amountTag[1], 10);\n if (amount > 0) {\n totalAmount += amount;\n zapDetails.push({\n amount: amount / 1000, // convert from msats to sats\n date: new Date(event.created_at * 1000),\n authorPubkey: zapRequest.pubkey,\n comment: zapRequest.content,\n });\n }\n }\n }\n } catch (e) {\n console.error(\"Nostr-Components: Zap button: Could not parse zap request from description tag\", e);\n }\n }\n }\n } catch (error) {\n console.error(\"Nostr-Components: Zap button: Error fetching zap receipts\", error);\n } finally {\n pool.close(relays);\n }\n\n // Sort zap details by date (newest first)\n zapDetails.sort((a, b) => b.date.getTime() - a.date.getTime());\n\n return {\n totalAmount: totalAmount / 1000, // convert from msats to sats\n zapDetails,\n };\n};\n\nexport const listenForZapReceipt = ({\n relays,\n receiversPubKey,\n invoice,\n onSuccess,\n}: {\n relays: string[];\n receiversPubKey: string,\n invoice: string;\n onSuccess: () => void;\n}) => {\n const pool = new SimplePool();\n const normalizedRelays = Array.from(new Set(relays));\n const since = Math.floor((Date.now() - 24 * 60 * 60 * 1000) / 1000); // current time - 24 hours\n\n pool.subscribe(\n normalizedRelays,\n {\n kinds: [9735],\n '#p': [receiversPubKey],\n since,\n },\n {\n onevent(event: Event) {\n const tags = event.tags as [string, string][];\n if (tags.some(t => t[0] === 'bolt11' && t[1] === invoice)) {\n onSuccess();\n cleanup();\n }\n }\n }\n );\n\n const cleanup = () => {\n pool.close(normalizedRelays);\n };\n\n return cleanup;\n};\n"],"names":["profileCache","getProfileMetadata","authorId","pool","SimplePool","relays","event","getBatchedProfileMetadata","authorIds","uncachedIds","id","extractProfileMetadataContent","profileMetadata","getZapEndpoint","endpoint","nip57","signEvent","zapEvent","anon","ensureInitialized","signEventWithNostrLogin","finalizeEvent","generateRandomPrivKey","makeZapEvent","profile","nip19Target","amount","comment","url","req","normalizeURL","isNostrLoginAvailable","fetchInvoice","zapEndpoint","normalizedRelays","invoiceUrl","res","json","invoice","reason","status","bytes","i","fetchTotalZapAmount","pubkey","normalizedUrl","totalAmount","zapDetails","filter","events","descriptionTag","_a","tag","zapRequest","amountTag","_b","kTag","_c","iTag","_d","iTagNormalized","e","error","a","b","listenForZapReceipt","receiversPubKey","onSuccess","since","t","cleanup"],"mappings":"wMAkBA,MAAMA,EAAoC,CAAA,EAE7BC,EAAqB,MAAOC,GAAqB,CAC5D,GAAIF,EAAaE,CAAQ,EAAG,OAAOF,EAAaE,CAAQ,EAExD,MAAMC,EAAO,IAAIC,EACXC,EAAS,CAEb,qBACA,uBACA,kBAAA,EAGF,GAAI,CACF,MAAMC,EAAQ,MAAMH,EAAK,IAAIE,EAAQ,CACnC,QAAS,CAACH,CAAQ,EAClB,MAAO,CAAC,CAAC,CAAA,CACV,EACD,OAAAF,EAAaE,CAAQ,EAAII,EAClBA,CACT,QAAA,CACEH,EAAK,MAAME,CAAM,CACnB,CACF,EAEaE,EAA4B,MAAOC,GAAwB,CAEtE,MAAMC,EAAcD,EAAU,UAAa,CAACR,EAAaU,CAAE,CAAC,EAG5D,GAAID,EAAY,SAAW,EACzB,OAAOD,EAAU,IAAIE,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CAAA,CACF,EAGF,MAAMA,EAAU,IAAM,CACpBnE,EAAK,MAAM+B,CAAgB,CAC7B,EAEA,OAAOoC,CACT"}
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-likers-B15m_NxI.js","assets/preload-helper-D7HrI6pR.js","assets/dialog-component-Da1ZIYh9.js","assets/zap-utils-QRxLBOst.js","assets/nostr-service-CA0Qx4nJ.js","assets/nostr-login-service-D2FmscPI.js","assets/utils--bxLbhGF.js","assets/base-styles-Dmuzg8I4.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-likers-Bq6kUbS0.js","assets/preload-helper-D7HrI6pR.js","assets/dialog-component-Da1ZIYh9.js","assets/zap-utils-BiKkJPt6.js","assets/nostr-service-CA0Qx4nJ.js","assets/nostr-login-service-D2FmscPI.js","assets/utils--bxLbhGF.js","assets/base-styles-Dmuzg8I4.js"])))=>i.map(i=>d[i]);
2
2
  var y=Object.defineProperty;var w=(o,e,t)=>e in o?y(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var d=(o,e,t)=>w(o,typeof e!="symbol"?e+"":e,t);import{_ as L}from"../assets/preload-helper-D7HrI6pR.js";import{e as f,g as C,c as x,N as i,i as S}from"../assets/base-styles-Dmuzg8I4.js";import{S as v,d as g}from"../assets/nostr-service-CA0Qx4nJ.js";import"../assets/dialog-component-Da1ZIYh9.js";import{e as p,g as E,s as A}from"../assets/nostr-login-service-D2FmscPI.js";function U({isLoading:o,isError:e,errorMessage:t,buttonText:r,isLiked:n,likeCount:s,hasLikes:a=!1,isCountLoading:l=!1,theme:u="light"}){if(e)return z(t||"");const c=$(n,u),h=n?"<span>Liked</span>":`<span>${f(r)}</span>`;return N(c,h,s,a,n,o,l)}function z(o){return D('<div class="error-icon">&#9888;</div>',f(o))}function D(o,e){return`
3
3
  <div class="nostr-like-button-container">
4
4
  <div class="nostr-like-button-left-container">
@@ -289,7 +289,7 @@ var y=Object.defineProperty;var w=(o,e,t)=>e in o?y(o,e,{enumerable:!0,configura
289
289
  <li>Works with a browser extension like <a href="https://getalby.com" target="_blank" rel="noopener noreferrer">Alby</a> or nos2x</li>
290
290
  </ul>
291
291
  </div>
292
- `,e.showModal()};new TextDecoder("utf-8");new TextEncoder;function k(o){try{o.indexOf("://")===-1&&(o="wss://"+o);let e=new URL(o);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${o}`)}}async function T(o,e){const t=k(o),r=new v;try{const n=await r.querySync(e,{kinds:[17],"#k":["web"],"#i":[t],limit:1e3}),s=[];let a=0,l=0;for(const c of n)s.push({authorPubkey:c.pubkey,date:new Date(c.created_at*1e3),content:c.content}),c.content==="-"?l++:a++;return s.sort((c,h)=>h.date.getTime()-c.date.getTime()),{totalCount:a-l,likeDetails:s,likedCount:a,dislikedCount:l}}catch(n){throw n instanceof Error?n:new Error(String(n))}finally{r.close(e)}}function m(o,e){return{kind:17,content:e,tags:[["k","web"],["i",o]],created_at:Math.floor(Date.now()/1e3)}}function P(o){return m(o,"+")}function _(o){return m(o,"-")}async function F(o,e,t){const r=new v,n=o;try{const s=await r.querySync(t,{kinds:[17],authors:[e],"#k":["web"],"#i":[n],limit:1});if(s.length===0)return!1;const a=s[0];return a.content==="+"||a.content===""}catch(s){return console.error("Nostr-Components: Like button: Error checking user like status",s),!1}finally{r.close(t)}}async function q(){try{return await p(),await E()}catch(o){return console.error("Nostr-Components: Like button: Error getting user pubkey",o),null}}async function b(o){try{return await p(),await A(o)}catch(e){throw console.error("Nostr-Components: Like button: Error signing event",e),e}}class O extends x{constructor(){super();d(this,"likeActionStatus",this.channel("likeAction"));d(this,"likeListStatus",this.channel("likeList"));d(this,"currentUrl","");d(this,"isLiked",!1);d(this,"likeCount",0);d(this,"cachedLikeDetails",null);d(this,"loadSeq",0)}connectedCallback(){var t;(t=super.connectedCallback)==null||t.call(this),this.likeListStatus.get()===i.Idle&&this.initChannelStatus("likeList",i.Loading,{reflectOverall:!1}),this.attachDelegatedListeners(),this.render()}static get observedAttributes(){return[...super.observedAttributes,"url","text"]}attributeChangedCallback(t,r,n){r!==n&&(super.attributeChangedCallback(t,r,n),(t==="url"||t==="text")&&(this.likeActionStatus.set(i.Ready),this.likeListStatus.set(i.Loading),this.isLiked=!1,this.errorMessage="",this.updateLikeCount(),this.render()))}validateInputs(){if(!super.validateInputs())return this.likeActionStatus.set(i.Idle),this.likeListStatus.set(i.Idle),!1;const t=this.getAttribute("url"),r=this.getAttribute("text"),n=this.tagName.toLowerCase();let s=null;return t&&(S(t)||(s="Invalid URL format")),r&&r.length>32&&(s="Max text length: 32 characters"),s?(this.likeActionStatus.set(i.Error,s),this.likeListStatus.set(i.Error,s),console.error(`Nostr-Components: ${n}: ${s}`),!1):!0}onStatusChange(t){this.render()}onNostrRelaysConnected(){this.updateLikeCount(),this.render()}ensureCurrentUrl(){this.currentUrl||(this.currentUrl=k(this.getAttribute("url")||window.location.href))}async updateLikeCount(){const t=++this.loadSeq;try{await this.ensureNostrConnected(),this.currentUrl=k(this.getAttribute("url")||window.location.href),this.likeListStatus.set(i.Loading),this.render();const r=await T(this.currentUrl,this.getRelays());if(t!==this.loadSeq)return;this.likeCount=r.totalCount,this.cachedLikeDetails=r,this.likeListStatus.set(i.Ready)}catch(r){console.error("[NostrLike] Failed to fetch like count:",r),this.likeListStatus.set(i.Error,"Failed to load likes")}finally{this.render()}}async handleLikeClick(){if(this.ensureCurrentUrl(),!this.currentUrl){this.likeActionStatus.set(i.Error,"Invalid URL"),this.render();return}this.likeActionStatus.set(i.Loading),this.render();try{await p();const t=await q();if(t&&(this.isLiked=await F(this.currentUrl,t,this.getRelays())),this.isLiked){if(!window.confirm("You have already liked this. Do you want to unlike it?")){this.likeActionStatus.set(i.Ready),this.render();return}await this.handleUnlike()}else await this.handleLike()}catch(t){console.error("[NostrLike] Failed to check user like status:",t);const r=t instanceof Error?t.message:"Failed to check user like status";this.likeActionStatus.set(i.Error,r),this.render()}}async handleLike(){if(this.ensureCurrentUrl(),!this.currentUrl){this.likeActionStatus.set(i.Error,"Invalid URL"),this.render();return}this.likeActionStatus.set(i.Loading),this.render();try{const t=P(this.currentUrl),r=await b(t);await new g(this.nostrService.getNDK(),r).publish(),this.isLiked=!0,this.likeCount++,this.likeActionStatus.set(i.Ready),await this.updateLikeCount()}catch(t){console.error("[NostrLike] Failed to like:",t),this.isLiked=!1,this.likeCount--;const r=t instanceof Error?t.message:"Failed to like";this.likeActionStatus.set(i.Error,r)}finally{this.render()}}async handleUnlike(){if(this.ensureCurrentUrl(),!this.currentUrl){this.likeActionStatus.set(i.Error,"Invalid URL"),this.render();return}this.likeActionStatus.set(i.Loading),this.render();try{const t=_(this.currentUrl),r=await b(t);await new g(this.nostrService.getNDK(),r).publish(),this.isLiked=!1,this.likeCount>0&&this.likeCount--,this.likeActionStatus.set(i.Ready),await this.updateLikeCount()}catch(t){console.error("[NostrLike] Failed to unlike:",t),this.isLiked=!0,this.likeCount++;const r=t instanceof Error?t.message:"Failed to unlike";this.likeActionStatus.set(i.Error,r)}finally{this.render()}}async handleCountClick(){if(!(this.likeCount===0||!this.cachedLikeDetails))try{const{openLikersDialog:t}=await L(async()=>{const{openLikersDialog:r}=await import("../assets/dialog-likers-B15m_NxI.js");return{openLikersDialog:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]));await t({likeDetails:this.cachedLikeDetails.likeDetails,theme:this.theme==="dark"?"dark":"light"})}catch(t){console.error("[NostrLike] Error opening likers dialog:",t)}}async handleHelpClick(){try{await H(this.theme==="dark"?"dark":"light")}catch(t){console.error("[NostrLike] Error showing help dialog:",t)}}attachDelegatedListeners(){this.delegateEvent("click",".nostr-like-button",t=>{var r,n;(r=t.preventDefault)==null||r.call(t),(n=t.stopPropagation)==null||n.call(t),this.handleLikeClick()}),this.delegateEvent("click",".like-count",t=>{var r,n;(r=t.preventDefault)==null||r.call(t),(n=t.stopPropagation)==null||n.call(t),this.handleCountClick()}),this.delegateEvent("click",".help-icon",t=>{var r,n;(r=t.preventDefault)==null||r.call(t),(n=t.stopPropagation)==null||n.call(t),this.handleHelpClick()})}renderContent(){const t=this.likeActionStatus.get()===i.Loading||this.conn.get()===i.Loading,r=this.likeListStatus.get()===i.Loading,n=this.computeOverall()===i.Error,s=this.errorMessage,a=this.getAttribute("text")||"Like",l={isLoading:t,isError:n,errorMessage:s,buttonText:a,isLiked:this.isLiked,likeCount:this.likeCount,hasLikes:this.likeCount>0,isCountLoading:r,theme:this.theme};this.shadowRoot.innerHTML=`
292
+ `,e.showModal()};new TextDecoder("utf-8");new TextEncoder;function k(o){try{o.indexOf("://")===-1&&(o="wss://"+o);let e=new URL(o);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${o}`)}}async function T(o,e){const t=k(o),r=new v;try{const n=await r.querySync(e,{kinds:[17],"#k":["web"],"#i":[t],limit:1e3}),s=[];let a=0,l=0;for(const c of n)s.push({authorPubkey:c.pubkey,date:new Date(c.created_at*1e3),content:c.content}),c.content==="-"?l++:a++;return s.sort((c,h)=>h.date.getTime()-c.date.getTime()),{totalCount:a-l,likeDetails:s,likedCount:a,dislikedCount:l}}catch(n){throw n instanceof Error?n:new Error(String(n))}finally{r.close(e)}}function m(o,e){return{kind:17,content:e,tags:[["k","web"],["i",o]],created_at:Math.floor(Date.now()/1e3)}}function P(o){return m(o,"+")}function _(o){return m(o,"-")}async function F(o,e,t){const r=new v,n=o;try{const s=await r.querySync(t,{kinds:[17],authors:[e],"#k":["web"],"#i":[n],limit:1});if(s.length===0)return!1;const a=s[0];return a.content==="+"||a.content===""}catch(s){return console.error("Nostr-Components: Like button: Error checking user like status",s),!1}finally{r.close(t)}}async function q(){try{return await p(),await E()}catch(o){return console.error("Nostr-Components: Like button: Error getting user pubkey",o),null}}async function b(o){try{return await p(),await A(o)}catch(e){throw console.error("Nostr-Components: Like button: Error signing event",e),e}}class O extends x{constructor(){super();d(this,"likeActionStatus",this.channel("likeAction"));d(this,"likeListStatus",this.channel("likeList"));d(this,"currentUrl","");d(this,"isLiked",!1);d(this,"likeCount",0);d(this,"cachedLikeDetails",null);d(this,"loadSeq",0)}connectedCallback(){var t;(t=super.connectedCallback)==null||t.call(this),this.likeListStatus.get()===i.Idle&&this.initChannelStatus("likeList",i.Loading,{reflectOverall:!1}),this.attachDelegatedListeners(),this.render()}static get observedAttributes(){return[...super.observedAttributes,"url","text"]}attributeChangedCallback(t,r,n){r!==n&&(super.attributeChangedCallback(t,r,n),(t==="url"||t==="text")&&(this.likeActionStatus.set(i.Ready),this.likeListStatus.set(i.Loading),this.isLiked=!1,this.errorMessage="",this.updateLikeCount(),this.render()))}validateInputs(){if(!super.validateInputs())return this.likeActionStatus.set(i.Idle),this.likeListStatus.set(i.Idle),!1;const t=this.getAttribute("url"),r=this.getAttribute("text"),n=this.tagName.toLowerCase();let s=null;return t&&(S(t)||(s="Invalid URL format")),r&&r.length>32&&(s="Max text length: 32 characters"),s?(this.likeActionStatus.set(i.Error,s),this.likeListStatus.set(i.Error,s),console.error(`Nostr-Components: ${n}: ${s}`),!1):!0}onStatusChange(t){this.render()}onNostrRelaysConnected(){this.updateLikeCount(),this.render()}ensureCurrentUrl(){this.currentUrl||(this.currentUrl=k(this.getAttribute("url")||window.location.href))}async updateLikeCount(){const t=++this.loadSeq;try{await this.ensureNostrConnected(),this.currentUrl=k(this.getAttribute("url")||window.location.href),this.likeListStatus.set(i.Loading),this.render();const r=await T(this.currentUrl,this.getRelays());if(t!==this.loadSeq)return;this.likeCount=r.totalCount,this.cachedLikeDetails=r,this.likeListStatus.set(i.Ready)}catch(r){console.error("[NostrLike] Failed to fetch like count:",r),this.likeListStatus.set(i.Error,"Failed to load likes")}finally{this.render()}}async handleLikeClick(){if(this.ensureCurrentUrl(),!this.currentUrl){this.likeActionStatus.set(i.Error,"Invalid URL"),this.render();return}this.likeActionStatus.set(i.Loading),this.render();try{await p();const t=await q();if(t&&(this.isLiked=await F(this.currentUrl,t,this.getRelays())),this.isLiked){if(!window.confirm("You have already liked this. Do you want to unlike it?")){this.likeActionStatus.set(i.Ready),this.render();return}await this.handleUnlike()}else await this.handleLike()}catch(t){console.error("[NostrLike] Failed to check user like status:",t);const r=t instanceof Error?t.message:"Failed to check user like status";this.likeActionStatus.set(i.Error,r),this.render()}}async handleLike(){if(this.ensureCurrentUrl(),!this.currentUrl){this.likeActionStatus.set(i.Error,"Invalid URL"),this.render();return}this.likeActionStatus.set(i.Loading),this.render();try{const t=P(this.currentUrl),r=await b(t);await new g(this.nostrService.getNDK(),r).publish(),this.isLiked=!0,this.likeCount++,this.likeActionStatus.set(i.Ready),await this.updateLikeCount()}catch(t){console.error("[NostrLike] Failed to like:",t),this.isLiked=!1,this.likeCount--;const r=t instanceof Error?t.message:"Failed to like";this.likeActionStatus.set(i.Error,r)}finally{this.render()}}async handleUnlike(){if(this.ensureCurrentUrl(),!this.currentUrl){this.likeActionStatus.set(i.Error,"Invalid URL"),this.render();return}this.likeActionStatus.set(i.Loading),this.render();try{const t=_(this.currentUrl),r=await b(t);await new g(this.nostrService.getNDK(),r).publish(),this.isLiked=!1,this.likeCount>0&&this.likeCount--,this.likeActionStatus.set(i.Ready),await this.updateLikeCount()}catch(t){console.error("[NostrLike] Failed to unlike:",t),this.isLiked=!0,this.likeCount++;const r=t instanceof Error?t.message:"Failed to unlike";this.likeActionStatus.set(i.Error,r)}finally{this.render()}}async handleCountClick(){if(!(this.likeCount===0||!this.cachedLikeDetails))try{const{openLikersDialog:t}=await L(async()=>{const{openLikersDialog:r}=await import("../assets/dialog-likers-Bq6kUbS0.js");return{openLikersDialog:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]));await t({likeDetails:this.cachedLikeDetails.likeDetails,theme:this.theme==="dark"?"dark":"light"})}catch(t){console.error("[NostrLike] Error opening likers dialog:",t)}}async handleHelpClick(){try{await H(this.theme==="dark"?"dark":"light")}catch(t){console.error("[NostrLike] Error showing help dialog:",t)}}attachDelegatedListeners(){this.delegateEvent("click",".nostr-like-button",t=>{var r,n;(r=t.preventDefault)==null||r.call(t),(n=t.stopPropagation)==null||n.call(t),this.handleLikeClick()}),this.delegateEvent("click",".like-count",t=>{var r,n;(r=t.preventDefault)==null||r.call(t),(n=t.stopPropagation)==null||n.call(t),this.handleCountClick()}),this.delegateEvent("click",".help-icon",t=>{var r,n;(r=t.preventDefault)==null||r.call(t),(n=t.stopPropagation)==null||n.call(t),this.handleHelpClick()})}renderContent(){const t=this.likeActionStatus.get()===i.Loading||this.conn.get()===i.Loading,r=this.likeListStatus.get()===i.Loading,n=this.computeOverall()===i.Error,s=this.errorMessage,a=this.getAttribute("text")||"Like",l={isLoading:t,isError:n,errorMessage:s,buttonText:a,isLiked:this.isLiked,likeCount:this.likeCount,hasLikes:this.likeCount>0,isCountLoading:r,theme:this.theme};this.shadowRoot.innerHTML=`
293
293
  ${R()}
294
294
  ${U(l)}
295
295
  `}}customElements.get("nostr-like")||customElements.define("nostr-like",O);export{O as default};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/zap-utils-QRxLBOst.js","assets/nostr-service-CA0Qx4nJ.js","assets/nostr-login-service-D2FmscPI.js","assets/preload-helper-D7HrI6pR.js","assets/utils--bxLbhGF.js"])))=>i.map(i=>d[i]);
2
- var Jt=Object.defineProperty;var $t=(e,t,n)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Z=(e,t,n)=>$t(e,typeof t!="symbol"?t+"":t,n);import{N as Gt}from"../assets/nostr-user-component-r-MUbTL6.js";import{h as Qt,g as St,j as G,e as X,k as kt,i as At,N}from"../assets/base-styles-Dmuzg8I4.js";import"../assets/dialog-component-Da1ZIYh9.js";import{getProfileMetadata as Wt,getZapEndpoint as Xt,fetchInvoice as te,listenForZapReceipt as ee,getBatchedProfileMetadata as ne,extractProfileMetadataContent as Nt,fetchTotalZapAmount as oe}from"../assets/zap-utils-QRxLBOst.js";import{_ as re}from"../assets/preload-helper-D7HrI6pR.js";import{i as ae}from"../assets/utils--bxLbhGF.js";import{e as ie}from"../assets/nostr-login-service-D2FmscPI.js";import"../assets/user-resolver-ArI0680e.js";import"../assets/nostr-service-CA0Qx4nJ.js";const se=(e="light")=>{const t=e==="dark";return`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/zap-utils-BiKkJPt6.js","assets/nostr-service-CA0Qx4nJ.js","assets/nostr-login-service-D2FmscPI.js","assets/preload-helper-D7HrI6pR.js","assets/utils--bxLbhGF.js"])))=>i.map(i=>d[i]);
2
+ var Jt=Object.defineProperty;var $t=(e,t,n)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Z=(e,t,n)=>$t(e,typeof t!="symbol"?t+"":t,n);import{N as Gt}from"../assets/nostr-user-component-r-MUbTL6.js";import{h as Qt,g as St,j as G,e as X,k as kt,i as At,N}from"../assets/base-styles-Dmuzg8I4.js";import"../assets/dialog-component-Da1ZIYh9.js";import{getProfileMetadata as Wt,getZapEndpoint as Xt,fetchInvoice as te,listenForZapReceipt as ee,getBatchedProfileMetadata as ne,extractProfileMetadataContent as Nt,fetchTotalZapAmount as oe}from"../assets/zap-utils-BiKkJPt6.js";import{_ as re}from"../assets/preload-helper-D7HrI6pR.js";import{i as ae}from"../assets/utils--bxLbhGF.js";import{e as ie}from"../assets/nostr-login-service-D2FmscPI.js";import"../assets/user-resolver-ArI0680e.js";import"../assets/nostr-service-CA0Qx4nJ.js";const se=(e="light")=>{const t=e==="dark";return`
3
3
  /* === ZAP DIALOG CONTENT STYLES === */
4
4
  .zap-dialog-content {
5
5
  text-align: center;
@@ -476,7 +476,7 @@ Minimum version required to store current data is: `+a+`.
476
476
  ${e.map((o,r)=>an(o,t[r],r)).join("")}
477
477
  </div>
478
478
  </div>
479
- `}async function ln(e,t){const n=e.querySelector(".zappers-list");if(!n)return;const o=[...new Set(t.map(r=>r.authorPubkey))];console.log("Nostr-Components: Zappers dialog: Fetching profiles for",o.length,"unique authors");try{const r=await ne(o),a=new Map;r.forEach(i=>{a.set(i.id,i.profile)});const s=new Map;o.forEach(i=>{s.set(i,G(i))});for(let i=0;i<t.length;i++){const c=t[i],l=a.get(c.authorPubkey),u=s.get(c.authorPubkey)||c.authorPubkey;let y;if(l){const d=Nt(l);y={...c,authorName:d.display_name||d.name||u,authorPicture:d.picture,authorNpub:u}}else y={...c,authorName:u,authorNpub:u};const p=n.querySelector(`[data-zap-index="${i}"]`);if(p){const d=Vt(y,i);p.outerHTML=d}}console.log("Nostr-Components: Zappers dialog: Progressive enhancement completed for",t.length,"zap entries")}catch(r){console.error("Nostr-Components: Zappers dialog: Error in batched profile enhancement",r),console.log("Nostr-Components: Zappers dialog: Falling back to individual profile fetching"),await un(e,t)}}async function un(e,t){const n=e.querySelector(".zappers-list");if(!n)return;const o=new Map,r=t.map(async(a,s)=>{if(o.has(a.authorPubkey)){const i=o.get(a.authorPubkey);return{index:s,enhanced:{...a,authorName:i.authorName,authorPicture:i.authorPicture,authorNpub:i.authorNpub}}}try{const{getProfileMetadata:i}=await re(async()=>{const{getProfileMetadata:p}=await import("../assets/zap-utils-QRxLBOst.js");return{getProfileMetadata:p}},__vite__mapDeps([0,1,2,3,4])),c=await i(a.authorPubkey),l=Nt(c),u=G(a.authorPubkey),y={...a,authorName:l.display_name||l.name||u,authorPicture:l.picture,authorNpub:u};return o.set(a.authorPubkey,y),{index:s,enhanced:y}}catch(i){console.error("Nostr-Components: Zappers dialog: Error fetching profile for",a.authorPubkey,i);const c=G(a.authorPubkey),l={...a,authorName:c,authorNpub:c};return o.set(a.authorPubkey,l),{index:s,enhanced:l}}});for(const a of r)try{const{index:s,enhanced:i}=await a,c=n.querySelector(`[data-zap-index="${s}"]`);if(c){const l=Vt(i,s);c.outerHTML=l}}catch(s){console.error("Nostr-Components: Zappers dialog: Error processing profile enhancement",s)}}function dn({isLoading:e,isError:t,isSuccess:n,errorMessage:o,buttonText:r,totalZapAmount:a,isAmountLoading:s,hasZaps:i=!1}){if(t)return pn(o||"");if(e)return fn(s);const c=Kt(),l=`<span>${X(r)}</span>`;return jt(c,l,a,s,i)}function fn(e){return jt(Kt(),'<span class="button-text-skeleton"></span>',null,e)}function pn(e){return gn('<div class="error-icon">&#9888;</div>',X(e))}function gn(e,t){return`
479
+ `}async function ln(e,t){const n=e.querySelector(".zappers-list");if(!n)return;const o=[...new Set(t.map(r=>r.authorPubkey))];console.log("Nostr-Components: Zappers dialog: Fetching profiles for",o.length,"unique authors");try{const r=await ne(o),a=new Map;r.forEach(i=>{a.set(i.id,i.profile)});const s=new Map;o.forEach(i=>{s.set(i,G(i))});for(let i=0;i<t.length;i++){const c=t[i],l=a.get(c.authorPubkey),u=s.get(c.authorPubkey)||c.authorPubkey;let y;if(l){const d=Nt(l);y={...c,authorName:d.display_name||d.name||u,authorPicture:d.picture,authorNpub:u}}else y={...c,authorName:u,authorNpub:u};const p=n.querySelector(`[data-zap-index="${i}"]`);if(p){const d=Vt(y,i);p.outerHTML=d}}console.log("Nostr-Components: Zappers dialog: Progressive enhancement completed for",t.length,"zap entries")}catch(r){console.error("Nostr-Components: Zappers dialog: Error in batched profile enhancement",r),console.log("Nostr-Components: Zappers dialog: Falling back to individual profile fetching"),await un(e,t)}}async function un(e,t){const n=e.querySelector(".zappers-list");if(!n)return;const o=new Map,r=t.map(async(a,s)=>{if(o.has(a.authorPubkey)){const i=o.get(a.authorPubkey);return{index:s,enhanced:{...a,authorName:i.authorName,authorPicture:i.authorPicture,authorNpub:i.authorNpub}}}try{const{getProfileMetadata:i}=await re(async()=>{const{getProfileMetadata:p}=await import("../assets/zap-utils-BiKkJPt6.js");return{getProfileMetadata:p}},__vite__mapDeps([0,1,2,3,4])),c=await i(a.authorPubkey),l=Nt(c),u=G(a.authorPubkey),y={...a,authorName:l.display_name||l.name||u,authorPicture:l.picture,authorNpub:u};return o.set(a.authorPubkey,y),{index:s,enhanced:y}}catch(i){console.error("Nostr-Components: Zappers dialog: Error fetching profile for",a.authorPubkey,i);const c=G(a.authorPubkey),l={...a,authorName:c,authorNpub:c};return o.set(a.authorPubkey,l),{index:s,enhanced:l}}});for(const a of r)try{const{index:s,enhanced:i}=await a,c=n.querySelector(`[data-zap-index="${s}"]`);if(c){const l=Vt(i,s);c.outerHTML=l}}catch(s){console.error("Nostr-Components: Zappers dialog: Error processing profile enhancement",s)}}function dn({isLoading:e,isError:t,isSuccess:n,errorMessage:o,buttonText:r,totalZapAmount:a,isAmountLoading:s,hasZaps:i=!1}){if(t)return pn(o||"");if(e)return fn(s);const c=Kt(),l=`<span>${X(r)}</span>`;return jt(c,l,a,s,i)}function fn(e){return jt(Kt(),'<span class="button-text-skeleton"></span>',null,e)}function pn(e){return gn('<div class="error-icon">&#9888;</div>',X(e))}function gn(e,t){return`
480
480
  <div class="nostr-zap-button-container">
481
481
  <div class="nostr-zap-button-left-container">
482
482
  ${e}
@@ -1,2 +1,2 @@
1
- import o from"./components/nostr-profile-badge.es.js";import t from"./components/nostr-post.es.js";import r from"./components/nostr-profile.es.js";import i from"./components/nostr-follow-button.es.js";import m from"./components/nostr-zap.es.js";import p from"./components/nostr-comment.es.js";import f from"./components/nostr-dm.es.js";import e from"./components/nostr-live-chat.es.js";import s from"./components/nostr-like.es.js";import"./assets/base-styles-Dmuzg8I4.js";import"./assets/nostr-service-CA0Qx4nJ.js";import"./assets/nostr-user-component-r-MUbTL6.js";import"./assets/user-resolver-ArI0680e.js";import"./assets/copy-delegation-xzt-t_do.js";import"./assets/icons-Dr_d9MII.js";import"./assets/theme-BN1Bvweb.js";import"./assets/nostr-login-service-D2FmscPI.js";import"./assets/preload-helper-D7HrI6pR.js";import"./assets/dialog-component-Da1ZIYh9.js";import"./assets/zap-utils-QRxLBOst.js";import"./assets/utils--bxLbhGF.js";import"./assets/nip05-utils-BNBHUmkr.js";function n(){typeof window<"u"&&console.log("Nostr Components initialized")}const j={init:n,NostrProfileBadge:o,NostrPost:t,NostrProfile:r,NostrFollowButton:i,NostrZap:m,NostrComment:p,NostrDm:f,NostrLiveChat:e,NostrLike:s};export{p as NostrComment,f as NostrDm,i as NostrFollowButton,s as NostrLike,e as NostrLiveChat,t as NostrPost,r as NostrProfile,o as NostrProfileBadge,m as NostrZap,j as default,n as init};
1
+ import o from"./components/nostr-profile-badge.es.js";import t from"./components/nostr-post.es.js";import r from"./components/nostr-profile.es.js";import i from"./components/nostr-follow-button.es.js";import m from"./components/nostr-zap.es.js";import p from"./components/nostr-comment.es.js";import f from"./components/nostr-dm.es.js";import e from"./components/nostr-live-chat.es.js";import s from"./components/nostr-like.es.js";import"./assets/base-styles-Dmuzg8I4.js";import"./assets/nostr-service-CA0Qx4nJ.js";import"./assets/nostr-user-component-r-MUbTL6.js";import"./assets/user-resolver-ArI0680e.js";import"./assets/copy-delegation-xzt-t_do.js";import"./assets/icons-Dr_d9MII.js";import"./assets/theme-BN1Bvweb.js";import"./assets/nostr-login-service-D2FmscPI.js";import"./assets/preload-helper-D7HrI6pR.js";import"./assets/dialog-component-Da1ZIYh9.js";import"./assets/zap-utils-BiKkJPt6.js";import"./assets/utils--bxLbhGF.js";import"./assets/nip05-utils-BNBHUmkr.js";function n(){typeof window<"u"&&console.log("Nostr Components initialized")}const j={init:n,NostrProfileBadge:o,NostrPost:t,NostrProfile:r,NostrFollowButton:i,NostrZap:m,NostrComment:p,NostrDm:f,NostrLiveChat:e,NostrLike:s};export{p as NostrComment,f as NostrDm,i as NostrFollowButton,s as NostrLike,e as NostrLiveChat,t as NostrPost,r as NostrProfile,o as NostrProfileBadge,m as NostrZap,j as default,n as init};
2
2
  //# sourceMappingURL=nostr-components.es.js.map
@@ -1667,7 +1667,7 @@ ${c}`)}return n}async fetchFollows(t){try{return(await t.followSet()).size}catch
1667
1667
  transform: rotate(360deg);
1668
1668
  }
1669
1669
  }
1670
- `};function normalizeURL$2(e){try{const t=new URL(e);return t.origin.replace("://m.","://").replace("://mobile.","://").replace("http://","https://").replace(/:\d+/,n=>n===":443"||n===":80"?"":n)+t.pathname.replace(/\/+/g,"/").replace(/\/*$/,"")}catch{return console.error("Invalid URL:",e),e}}function isValidPublicKey(e){return/^[a-f0-9]{64}$/.test(e)}const profileCache={},getProfileMetadata=async e=>{if(profileCache[e])return profileCache[e];const t=new SimplePool,n=["wss://relay.nostr.band","wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{const r=await t.get(n,{authors:[e],kinds:[0]});return profileCache[e]=r,r}finally{t.close(n)}},getBatchedProfileMetadata=async e=>{const t=e.filter(s=>!profileCache[s]);if(t.length===0)return e.map(s=>({id:s,profile:profileCache[s]}));const n=new SimplePool,r=["wss://relay.nostr.band","wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{return(await n.querySync(r,{authors:t,kinds:[0]})).forEach(a=>{profileCache[a.pubkey]=a}),e.map(a=>({id:a,profile:profileCache[a]||null}))}finally{n.close(r)}},extractProfileMetadataContent=e=>{try{return JSON.parse((e==null?void 0:e.content)||"{}")}catch{return{}}},getZapEndpoint$1=async e=>{const t=await nip57_exports$1.getZapEndpoint(e);if(!t)throw new Error("Failed to retrieve zap LNURL");return t},signEvent$1=async(e,t)=>{try{return await ensureInitialized(),await signEvent$2(e)}catch{}return finalizeEvent$1(e,generateRandomPrivKey())},makeZapEvent=async({profile:e,nip19Target:t,amount:n,relays:r,comment:s,anon:o,url:a})=>{const c={profile:e,amount:n,relays:r,comment:s||""},l=nip57_exports$1.makeZapRequest(c);a&&(l.tags.push(["k","web"]),l.tags.push(["i",normalizeURL$2(a)]));let p=!1;try{await ensureInitialized(),p=typeof window<"u"&&!!window.nostr}catch{p=!1}return(!p||o)&&l.tags.push(["anon"]),signEvent$1(l)},fetchInvoice=async({zapEndpoint:e,amount:t,comment:n,authorId:r,nip19Target:s,normalizedRelays:o,anon:a,url:c})=>{const l=await makeZapEvent({profile:r,nip19Target:s,amount:t,relays:o,comment:n??"",anon:a,url:c});let p=`${e}?amount=${t}&nostr=${encodeURIComponent(JSON.stringify(l))}`;n&&(p+=`&comment=${encodeURIComponent(n??"")}`);const g=await fetch(p,{method:"GET"});if(!g.ok)throw new Error(`LNURL request failed: ${g.status} ${g.statusText}`);let m;try{m=await g.json()}catch{throw new Error("Invalid JSON from LNURL endpoint")}const{pr:b,reason:w,status:E}=m||{};if(b)return b;throw E==="ERROR"?new Error(w??"Unable to fetch invoice"):new Error("Unable to fetch invoice")},generateRandomPrivKey=()=>{const e=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else{console.warn("crypto.getRandomValues not available, using Math.random as fallback");for(let t=0;t<32;t++)e[t]=Math.floor(Math.random()*256)}return e},fetchTotalZapAmount=async({pubkey:e,relays:t,url:n})=>{var c,l,p,g;const r=n?normalizeURL$2(n):void 0,s=new SimplePool;let o=0;const a=[];try{const m={kinds:[9735],"#p":[e],limit:1e3},b=await s.querySync(t,m);for(const w of b){const E=(c=w.tags)==null?void 0:c.find(v=>v[0]==="description");if(E!=null&&E[1])try{const v=JSON.parse(E[1]),x=(l=v==null?void 0:v.tags)==null?void 0:l.find(k=>k[0]==="amount");if(r){const k=(p=v==null?void 0:v.tags)==null?void 0:p.find(R=>R[0]==="k"),$=(g=v==null?void 0:v.tags)==null?void 0:g.find(R=>R[0]==="i"),A=$!=null&&$[1]?normalizeURL$2($[1]):"";if((k==null?void 0:k[1])==="web"&&A===r&&(x!=null&&x[1])){const R=parseInt(x[1],10);R>0&&(o+=R,a.push({amount:R/1e3,date:new Date(w.created_at*1e3),authorPubkey:v.pubkey,comment:v.content}))}}else if(x!=null&&x[1]){const k=parseInt(x[1],10);k>0&&(o+=k,a.push({amount:k/1e3,date:new Date(w.created_at*1e3),authorPubkey:v.pubkey,comment:v.content}))}}catch(v){console.error("Nostr-Components: Zap button: Could not parse zap request from description tag",v)}}}catch(m){console.error("Nostr-Components: Zap button: Error fetching zap receipts",m)}finally{s.close(t)}return a.sort((m,b)=>b.date.getTime()-m.date.getTime()),{totalAmount:o/1e3,zapDetails:a}},listenForZapReceipt=({relays:e,receiversPubKey:t,invoice:n,onSuccess:r})=>{const s=new SimplePool,o=Array.from(new Set([...e,"wss://relay.nostr.band"])),a=Math.floor((Date.now()-24*60*60*1e3)/1e3);s.subscribe(o,{kinds:[9735],"#p":[t],since:a},{onevent(l){l.tags.some(g=>g[0]==="bolt11"&&g[1]===n)&&(r(),c())}});const c=()=>{s.close(o)};return c},zapUtils=Object.freeze(Object.defineProperty({__proto__:null,extractProfileMetadataContent,fetchInvoice,fetchTotalZapAmount,getBatchedProfileMetadata,getProfileMetadata,getZapEndpoint:getZapEndpoint$1,listenForZapReceipt},Symbol.toStringTag,{value:"Module"}));var canPromise$3=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode$1={},utils$5={};let toSJISFunction$1;const CODEWORDS_COUNT$1=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$5.getSymbolSize=function e(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},utils$5.getSymbolTotalCodewords=function e(t){return CODEWORDS_COUNT$1[t]},utils$5.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},utils$5.setToSJISFunction=function e(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction$1=t},utils$5.isKanjiModeEnabled=function(){return typeof toSJISFunction$1<"u"},utils$5.toSJIS=function e(t){return toSJISFunction$1(t)};var errorCorrectionLevel$1={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,s){if(e.isValid(r))return r;try{return t(r)}catch{return s}}})(errorCorrectionLevel$1);function BitBuffer$3(){this.buffer=[],this.length=0}BitBuffer$3.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var bitBuffer$1=BitBuffer$3;function BitMatrix$3(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}BitMatrix$3.prototype.set=function(e,t,n,r){const s=e*this.size+t;this.data[s]=n,r&&(this.reservedBit[s]=!0)},BitMatrix$3.prototype.get=function(e,t){return this.data[e*this.size+t]},BitMatrix$3.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},BitMatrix$3.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var bitMatrix$1=BitMatrix$3,alignmentPattern$1={};(function(e){const t=utils$5.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const s=Math.floor(r/7)+2,o=t(r),a=o===145?26:Math.ceil((o-13)/(2*s-2))*2,c=[o-7];for(let l=1;l<s-1;l++)c[l]=c[l-1]-a;return c.push(6),c.reverse()},e.getPositions=function(r){const s=[],o=e.getRowColCoords(r),a=o.length;for(let c=0;c<a;c++)for(let l=0;l<a;l++)c===0&&l===0||c===0&&l===a-1||c===a-1&&l===0||s.push([o[c],o[l]]);return s}})(alignmentPattern$1);var finderPattern$1={};const getSymbolSize$1=utils$5.getSymbolSize,FINDER_PATTERN_SIZE$1=7;finderPattern$1.getPositions=function e(t){const n=getSymbolSize$1(t);return[[0,0],[n-FINDER_PATTERN_SIZE$1,0],[0,n-FINDER_PATTERN_SIZE$1]]};var maskPattern$1={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(s){return s!=null&&s!==""&&!isNaN(s)&&s>=0&&s<=7},e.from=function(s){return e.isValid(s)?parseInt(s,10):void 0},e.getPenaltyN1=function(s){const o=s.size;let a=0,c=0,l=0,p=null,g=null;for(let m=0;m<o;m++){c=l=0,p=g=null;for(let b=0;b<o;b++){let w=s.get(m,b);w===p?c++:(c>=5&&(a+=t.N1+(c-5)),p=w,c=1),w=s.get(b,m),w===g?l++:(l>=5&&(a+=t.N1+(l-5)),g=w,l=1)}c>=5&&(a+=t.N1+(c-5)),l>=5&&(a+=t.N1+(l-5))}return a},e.getPenaltyN2=function(s){const o=s.size;let a=0;for(let c=0;c<o-1;c++)for(let l=0;l<o-1;l++){const p=s.get(c,l)+s.get(c,l+1)+s.get(c+1,l)+s.get(c+1,l+1);(p===4||p===0)&&a++}return a*t.N2},e.getPenaltyN3=function(s){const o=s.size;let a=0,c=0,l=0;for(let p=0;p<o;p++){c=l=0;for(let g=0;g<o;g++)c=c<<1&2047|s.get(p,g),g>=10&&(c===1488||c===93)&&a++,l=l<<1&2047|s.get(g,p),g>=10&&(l===1488||l===93)&&a++}return a*t.N3},e.getPenaltyN4=function(s){let o=0;const a=s.data.length;for(let l=0;l<a;l++)o+=s.data[l];return Math.abs(Math.ceil(o*100/a/5)-10)*t.N4};function n(r,s,o){switch(r){case e.Patterns.PATTERN000:return(s+o)%2===0;case e.Patterns.PATTERN001:return s%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(s+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(s/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return s*o%2+s*o%3===0;case e.Patterns.PATTERN110:return(s*o%2+s*o%3)%2===0;case e.Patterns.PATTERN111:return(s*o%3+(s+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(s,o){const a=o.size;for(let c=0;c<a;c++)for(let l=0;l<a;l++)o.isReserved(l,c)||o.xor(l,c,n(s,l,c))},e.getBestMask=function(s,o){const a=Object.keys(e.Patterns).length;let c=0,l=1/0;for(let p=0;p<a;p++){o(p),e.applyMask(p,s);const g=e.getPenaltyN1(s)+e.getPenaltyN2(s)+e.getPenaltyN3(s)+e.getPenaltyN4(s);e.applyMask(p,s),g<l&&(l=g,c=p)}return c}})(maskPattern$1);var errorCorrectionCode$1={};const ECLevel$3=errorCorrectionLevel$1,EC_BLOCKS_TABLE$1=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],EC_CODEWORDS_TABLE$1=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];errorCorrectionCode$1.getBlocksCount=function e(t,n){switch(n){case ECLevel$3.L:return EC_BLOCKS_TABLE$1[(t-1)*4+0];case ECLevel$3.M:return EC_BLOCKS_TABLE$1[(t-1)*4+1];case ECLevel$3.Q:return EC_BLOCKS_TABLE$1[(t-1)*4+2];case ECLevel$3.H:return EC_BLOCKS_TABLE$1[(t-1)*4+3];default:return}},errorCorrectionCode$1.getTotalCodewordsCount=function e(t,n){switch(n){case ECLevel$3.L:return EC_CODEWORDS_TABLE$1[(t-1)*4+0];case ECLevel$3.M:return EC_CODEWORDS_TABLE$1[(t-1)*4+1];case ECLevel$3.Q:return EC_CODEWORDS_TABLE$1[(t-1)*4+2];case ECLevel$3.H:return EC_CODEWORDS_TABLE$1[(t-1)*4+3];default:return}};var polynomial$1={},galoisField$1={};const EXP_TABLE$1=new Uint8Array(512),LOG_TABLE$1=new Uint8Array(256);(function e(){let t=1;for(let n=0;n<255;n++)EXP_TABLE$1[n]=t,LOG_TABLE$1[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)EXP_TABLE$1[n]=EXP_TABLE$1[n-255]})(),galoisField$1.log=function e(t){if(t<1)throw new Error("log("+t+")");return LOG_TABLE$1[t]},galoisField$1.exp=function e(t){return EXP_TABLE$1[t]},galoisField$1.mul=function e(t,n){return t===0||n===0?0:EXP_TABLE$1[LOG_TABLE$1[t]+LOG_TABLE$1[n]]},function(e){const t=galoisField$1;e.mul=function(r,s){const o=new Uint8Array(r.length+s.length-1);for(let a=0;a<r.length;a++)for(let c=0;c<s.length;c++)o[a+c]^=t.mul(r[a],s[c]);return o},e.mod=function(r,s){let o=new Uint8Array(r);for(;o.length-s.length>=0;){const a=o[0];for(let l=0;l<s.length;l++)o[l]^=t.mul(s[l],a);let c=0;for(;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},e.generateECPolynomial=function(r){let s=new Uint8Array([1]);for(let o=0;o<r;o++)s=e.mul(s,new Uint8Array([1,t.exp(o)]));return s}}(polynomial$1);const Polynomial$1=polynomial$1;function ReedSolomonEncoder$3(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}ReedSolomonEncoder$3.prototype.initialize=function e(t){this.degree=t,this.genPoly=Polynomial$1.generateECPolynomial(this.degree)},ReedSolomonEncoder$3.prototype.encode=function e(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=Polynomial$1.mod(n,this.genPoly),s=this.degree-r.length;if(s>0){const o=new Uint8Array(this.degree);return o.set(r,s),o}return r};var reedSolomonEncoder$1=ReedSolomonEncoder$3,version$1={},mode$1={},versionCheck$1={};versionCheck$1.isValid=function e(t){return!isNaN(t)&&t>=1&&t<=40};var regex$2={};const numeric$1="[0-9]+",alphanumeric$1="[A-Z $%*+\\-./:]+";let kanji$1="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji$1=kanji$1.replace(/u/g,"\\u");const byte$1="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji$1+`)(?:.|[\r
1670
+ `};function normalizeURL$2(e){try{const t=new URL(e);return t.origin.replace("://m.","://").replace("://mobile.","://").replace("http://","https://").replace(/:\d+/,n=>n===":443"||n===":80"?"":n)+t.pathname.replace(/\/+/g,"/").replace(/\/*$/,"")}catch{return console.error("Invalid URL:",e),e}}function isValidPublicKey(e){return/^[a-f0-9]{64}$/.test(e)}const profileCache={},getProfileMetadata=async e=>{if(profileCache[e])return profileCache[e];const t=new SimplePool,n=["wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{const r=await t.get(n,{authors:[e],kinds:[0]});return profileCache[e]=r,r}finally{t.close(n)}},getBatchedProfileMetadata=async e=>{const t=e.filter(s=>!profileCache[s]);if(t.length===0)return e.map(s=>({id:s,profile:profileCache[s]}));const n=new SimplePool,r=["wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{return(await n.querySync(r,{authors:t,kinds:[0]})).forEach(a=>{profileCache[a.pubkey]=a}),e.map(a=>({id:a,profile:profileCache[a]||null}))}finally{n.close(r)}},extractProfileMetadataContent=e=>{try{return JSON.parse((e==null?void 0:e.content)||"{}")}catch{return{}}},getZapEndpoint$1=async e=>{const t=await nip57_exports$1.getZapEndpoint(e);if(!t)throw new Error("Failed to retrieve zap LNURL");return t},signEvent$1=async(e,t)=>{try{return await ensureInitialized(),await signEvent$2(e)}catch{}return finalizeEvent$1(e,generateRandomPrivKey())},makeZapEvent=async({profile:e,nip19Target:t,amount:n,relays:r,comment:s,anon:o,url:a})=>{const c={pubkey:e,amount:n,relays:r,comment:s||""};debugger;const l=nip57_exports$1.makeZapRequest(c);a&&(l.tags.push(["k","web"]),l.tags.push(["i",normalizeURL$2(a)]));let p=!1;try{await ensureInitialized(),p=typeof window<"u"&&!!window.nostr}catch{p=!1}return(!p||o)&&l.tags.push(["anon"]),signEvent$1(l)},fetchInvoice=async({zapEndpoint:e,amount:t,comment:n,authorId:r,nip19Target:s,normalizedRelays:o,anon:a,url:c})=>{const l=await makeZapEvent({profile:r,nip19Target:s,amount:t,relays:o,comment:n??"",anon:a,url:c});let p=`${e}?amount=${t}&nostr=${encodeURIComponent(JSON.stringify(l))}`;n&&(p+=`&comment=${encodeURIComponent(n??"")}`);const g=await fetch(p,{method:"GET"});if(!g.ok)throw new Error(`LNURL request failed: ${g.status} ${g.statusText}`);let m;try{m=await g.json()}catch{throw new Error("Invalid JSON from LNURL endpoint")}const{pr:b,reason:w,status:E}=m||{};if(b)return b;throw E==="ERROR"?new Error(w??"Unable to fetch invoice"):new Error("Unable to fetch invoice")},generateRandomPrivKey=()=>{const e=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else{console.warn("crypto.getRandomValues not available, using Math.random as fallback");for(let t=0;t<32;t++)e[t]=Math.floor(Math.random()*256)}return e},fetchTotalZapAmount=async({pubkey:e,relays:t,url:n})=>{var c,l,p,g;const r=n?normalizeURL$2(n):void 0,s=new SimplePool;let o=0;const a=[];try{const m={kinds:[9735],"#p":[e],limit:1e3},b=await s.querySync(t,m);for(const w of b){const E=(c=w.tags)==null?void 0:c.find(v=>v[0]==="description");if(E!=null&&E[1])try{const v=JSON.parse(E[1]),x=(l=v==null?void 0:v.tags)==null?void 0:l.find(k=>k[0]==="amount");if(r){const k=(p=v==null?void 0:v.tags)==null?void 0:p.find(R=>R[0]==="k"),$=(g=v==null?void 0:v.tags)==null?void 0:g.find(R=>R[0]==="i"),A=$!=null&&$[1]?normalizeURL$2($[1]):"";if((k==null?void 0:k[1])==="web"&&A===r&&(x!=null&&x[1])){const R=parseInt(x[1],10);R>0&&(o+=R,a.push({amount:R/1e3,date:new Date(w.created_at*1e3),authorPubkey:v.pubkey,comment:v.content}))}}else if(x!=null&&x[1]){const k=parseInt(x[1],10);k>0&&(o+=k,a.push({amount:k/1e3,date:new Date(w.created_at*1e3),authorPubkey:v.pubkey,comment:v.content}))}}catch(v){console.error("Nostr-Components: Zap button: Could not parse zap request from description tag",v)}}}catch(m){console.error("Nostr-Components: Zap button: Error fetching zap receipts",m)}finally{s.close(t)}return a.sort((m,b)=>b.date.getTime()-m.date.getTime()),{totalAmount:o/1e3,zapDetails:a}},listenForZapReceipt=({relays:e,receiversPubKey:t,invoice:n,onSuccess:r})=>{const s=new SimplePool,o=Array.from(new Set(e)),a=Math.floor((Date.now()-24*60*60*1e3)/1e3);s.subscribe(o,{kinds:[9735],"#p":[t],since:a},{onevent(l){l.tags.some(g=>g[0]==="bolt11"&&g[1]===n)&&(r(),c())}});const c=()=>{s.close(o)};return c},zapUtils=Object.freeze(Object.defineProperty({__proto__:null,extractProfileMetadataContent,fetchInvoice,fetchTotalZapAmount,getBatchedProfileMetadata,getProfileMetadata,getZapEndpoint:getZapEndpoint$1,listenForZapReceipt},Symbol.toStringTag,{value:"Module"}));var canPromise$3=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode$1={},utils$5={};let toSJISFunction$1;const CODEWORDS_COUNT$1=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$5.getSymbolSize=function e(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},utils$5.getSymbolTotalCodewords=function e(t){return CODEWORDS_COUNT$1[t]},utils$5.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},utils$5.setToSJISFunction=function e(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction$1=t},utils$5.isKanjiModeEnabled=function(){return typeof toSJISFunction$1<"u"},utils$5.toSJIS=function e(t){return toSJISFunction$1(t)};var errorCorrectionLevel$1={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,s){if(e.isValid(r))return r;try{return t(r)}catch{return s}}})(errorCorrectionLevel$1);function BitBuffer$3(){this.buffer=[],this.length=0}BitBuffer$3.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var bitBuffer$1=BitBuffer$3;function BitMatrix$3(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}BitMatrix$3.prototype.set=function(e,t,n,r){const s=e*this.size+t;this.data[s]=n,r&&(this.reservedBit[s]=!0)},BitMatrix$3.prototype.get=function(e,t){return this.data[e*this.size+t]},BitMatrix$3.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},BitMatrix$3.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var bitMatrix$1=BitMatrix$3,alignmentPattern$1={};(function(e){const t=utils$5.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const s=Math.floor(r/7)+2,o=t(r),a=o===145?26:Math.ceil((o-13)/(2*s-2))*2,c=[o-7];for(let l=1;l<s-1;l++)c[l]=c[l-1]-a;return c.push(6),c.reverse()},e.getPositions=function(r){const s=[],o=e.getRowColCoords(r),a=o.length;for(let c=0;c<a;c++)for(let l=0;l<a;l++)c===0&&l===0||c===0&&l===a-1||c===a-1&&l===0||s.push([o[c],o[l]]);return s}})(alignmentPattern$1);var finderPattern$1={};const getSymbolSize$1=utils$5.getSymbolSize,FINDER_PATTERN_SIZE$1=7;finderPattern$1.getPositions=function e(t){const n=getSymbolSize$1(t);return[[0,0],[n-FINDER_PATTERN_SIZE$1,0],[0,n-FINDER_PATTERN_SIZE$1]]};var maskPattern$1={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(s){return s!=null&&s!==""&&!isNaN(s)&&s>=0&&s<=7},e.from=function(s){return e.isValid(s)?parseInt(s,10):void 0},e.getPenaltyN1=function(s){const o=s.size;let a=0,c=0,l=0,p=null,g=null;for(let m=0;m<o;m++){c=l=0,p=g=null;for(let b=0;b<o;b++){let w=s.get(m,b);w===p?c++:(c>=5&&(a+=t.N1+(c-5)),p=w,c=1),w=s.get(b,m),w===g?l++:(l>=5&&(a+=t.N1+(l-5)),g=w,l=1)}c>=5&&(a+=t.N1+(c-5)),l>=5&&(a+=t.N1+(l-5))}return a},e.getPenaltyN2=function(s){const o=s.size;let a=0;for(let c=0;c<o-1;c++)for(let l=0;l<o-1;l++){const p=s.get(c,l)+s.get(c,l+1)+s.get(c+1,l)+s.get(c+1,l+1);(p===4||p===0)&&a++}return a*t.N2},e.getPenaltyN3=function(s){const o=s.size;let a=0,c=0,l=0;for(let p=0;p<o;p++){c=l=0;for(let g=0;g<o;g++)c=c<<1&2047|s.get(p,g),g>=10&&(c===1488||c===93)&&a++,l=l<<1&2047|s.get(g,p),g>=10&&(l===1488||l===93)&&a++}return a*t.N3},e.getPenaltyN4=function(s){let o=0;const a=s.data.length;for(let l=0;l<a;l++)o+=s.data[l];return Math.abs(Math.ceil(o*100/a/5)-10)*t.N4};function n(r,s,o){switch(r){case e.Patterns.PATTERN000:return(s+o)%2===0;case e.Patterns.PATTERN001:return s%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(s+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(s/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return s*o%2+s*o%3===0;case e.Patterns.PATTERN110:return(s*o%2+s*o%3)%2===0;case e.Patterns.PATTERN111:return(s*o%3+(s+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(s,o){const a=o.size;for(let c=0;c<a;c++)for(let l=0;l<a;l++)o.isReserved(l,c)||o.xor(l,c,n(s,l,c))},e.getBestMask=function(s,o){const a=Object.keys(e.Patterns).length;let c=0,l=1/0;for(let p=0;p<a;p++){o(p),e.applyMask(p,s);const g=e.getPenaltyN1(s)+e.getPenaltyN2(s)+e.getPenaltyN3(s)+e.getPenaltyN4(s);e.applyMask(p,s),g<l&&(l=g,c=p)}return c}})(maskPattern$1);var errorCorrectionCode$1={};const ECLevel$3=errorCorrectionLevel$1,EC_BLOCKS_TABLE$1=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],EC_CODEWORDS_TABLE$1=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];errorCorrectionCode$1.getBlocksCount=function e(t,n){switch(n){case ECLevel$3.L:return EC_BLOCKS_TABLE$1[(t-1)*4+0];case ECLevel$3.M:return EC_BLOCKS_TABLE$1[(t-1)*4+1];case ECLevel$3.Q:return EC_BLOCKS_TABLE$1[(t-1)*4+2];case ECLevel$3.H:return EC_BLOCKS_TABLE$1[(t-1)*4+3];default:return}},errorCorrectionCode$1.getTotalCodewordsCount=function e(t,n){switch(n){case ECLevel$3.L:return EC_CODEWORDS_TABLE$1[(t-1)*4+0];case ECLevel$3.M:return EC_CODEWORDS_TABLE$1[(t-1)*4+1];case ECLevel$3.Q:return EC_CODEWORDS_TABLE$1[(t-1)*4+2];case ECLevel$3.H:return EC_CODEWORDS_TABLE$1[(t-1)*4+3];default:return}};var polynomial$1={},galoisField$1={};const EXP_TABLE$1=new Uint8Array(512),LOG_TABLE$1=new Uint8Array(256);(function e(){let t=1;for(let n=0;n<255;n++)EXP_TABLE$1[n]=t,LOG_TABLE$1[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)EXP_TABLE$1[n]=EXP_TABLE$1[n-255]})(),galoisField$1.log=function e(t){if(t<1)throw new Error("log("+t+")");return LOG_TABLE$1[t]},galoisField$1.exp=function e(t){return EXP_TABLE$1[t]},galoisField$1.mul=function e(t,n){return t===0||n===0?0:EXP_TABLE$1[LOG_TABLE$1[t]+LOG_TABLE$1[n]]},function(e){const t=galoisField$1;e.mul=function(r,s){const o=new Uint8Array(r.length+s.length-1);for(let a=0;a<r.length;a++)for(let c=0;c<s.length;c++)o[a+c]^=t.mul(r[a],s[c]);return o},e.mod=function(r,s){let o=new Uint8Array(r);for(;o.length-s.length>=0;){const a=o[0];for(let l=0;l<s.length;l++)o[l]^=t.mul(s[l],a);let c=0;for(;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},e.generateECPolynomial=function(r){let s=new Uint8Array([1]);for(let o=0;o<r;o++)s=e.mul(s,new Uint8Array([1,t.exp(o)]));return s}}(polynomial$1);const Polynomial$1=polynomial$1;function ReedSolomonEncoder$3(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}ReedSolomonEncoder$3.prototype.initialize=function e(t){this.degree=t,this.genPoly=Polynomial$1.generateECPolynomial(this.degree)},ReedSolomonEncoder$3.prototype.encode=function e(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=Polynomial$1.mod(n,this.genPoly),s=this.degree-r.length;if(s>0){const o=new Uint8Array(this.degree);return o.set(r,s),o}return r};var reedSolomonEncoder$1=ReedSolomonEncoder$3,version$1={},mode$1={},versionCheck$1={};versionCheck$1.isValid=function e(t){return!isNaN(t)&&t>=1&&t<=40};var regex$2={};const numeric$1="[0-9]+",alphanumeric$1="[A-Z $%*+\\-./:]+";let kanji$1="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji$1=kanji$1.replace(/u/g,"\\u");const byte$1="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji$1+`)(?:.|[\r
1671
1671
  ]))+`;regex$2.KANJI=new RegExp(kanji$1,"g"),regex$2.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),regex$2.BYTE=new RegExp(byte$1,"g"),regex$2.NUMERIC=new RegExp(numeric$1,"g"),regex$2.ALPHANUMERIC=new RegExp(alphanumeric$1,"g");const TEST_KANJI$1=new RegExp("^"+kanji$1+"$"),TEST_NUMERIC$1=new RegExp("^"+numeric$1+"$"),TEST_ALPHANUMERIC$1=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");regex$2.testKanji=function e(t){return TEST_KANJI$1.test(t)},regex$2.testNumeric=function e(t){return TEST_NUMERIC$1.test(t)},regex$2.testAlphanumeric=function e(t){return TEST_ALPHANUMERIC$1.test(t)},function(e){const t=versionCheck$1,n=regex$2;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(o,a){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?o.ccBits[0]:a<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return n.testNumeric(o)?e.NUMERIC:n.testAlphanumeric(o)?e.ALPHANUMERIC:n.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.ccBits};function r(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+s)}}e.from=function(o,a){if(e.isValid(o))return o;try{return r(o)}catch{return a}}}(mode$1),function(e){const t=utils$5,n=errorCorrectionCode$1,r=errorCorrectionLevel$1,s=mode$1,o=versionCheck$1,a=7973,c=t.getBCHDigit(a);function l(b,w,E){for(let v=1;v<=40;v++)if(w<=e.getCapacity(v,E,b))return v}function p(b,w){return s.getCharCountIndicator(b,w)+4}function g(b,w){let E=0;return b.forEach(function(v){const x=p(v.mode,w);E+=x+v.getBitsLength()}),E}function m(b,w){for(let E=1;E<=40;E++)if(g(b,E)<=e.getCapacity(E,w,s.MIXED))return E}e.from=function(w,E){return o.isValid(w)?parseInt(w,10):E},e.getCapacity=function(w,E,v){if(!o.isValid(w))throw new Error("Invalid QR Code version");typeof v>"u"&&(v=s.BYTE);const x=t.getSymbolTotalCodewords(w),k=n.getTotalCodewordsCount(w,E),$=(x-k)*8;if(v===s.MIXED)return $;const A=$-p(v,w);switch(v){case s.NUMERIC:return Math.floor(A/10*3);case s.ALPHANUMERIC:return Math.floor(A/11*2);case s.KANJI:return Math.floor(A/13);case s.BYTE:default:return Math.floor(A/8)}},e.getBestVersionForData=function(w,E){let v;const x=r.from(E,r.M);if(Array.isArray(w)){if(w.length>1)return m(w,x);if(w.length===0)return 1;v=w[0]}else v=w;return l(v.mode,v.getLength(),x)},e.getEncodedBits=function(w){if(!o.isValid(w)||w<7)throw new Error("Invalid QR Code version");let E=w<<12;for(;t.getBCHDigit(E)-c>=0;)E^=a<<t.getBCHDigit(E)-c;return w<<12|E}}(version$1);var formatInfo$1={};const Utils$7=utils$5,G15$1=1335,G15_MASK$1=21522,G15_BCH$1=Utils$7.getBCHDigit(G15$1);formatInfo$1.getEncodedBits=function e(t,n){const r=t.bit<<3|n;let s=r<<10;for(;Utils$7.getBCHDigit(s)-G15_BCH$1>=0;)s^=G15$1<<Utils$7.getBCHDigit(s)-G15_BCH$1;return(r<<10|s)^G15_MASK$1};var segments$1={};const Mode$9=mode$1;function NumericData$1(e){this.mode=Mode$9.NUMERIC,this.data=e.toString()}NumericData$1.getBitsLength=function e(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},NumericData$1.prototype.getLength=function e(){return this.data.length},NumericData$1.prototype.getBitsLength=function e(){return NumericData$1.getBitsLength(this.data.length)},NumericData$1.prototype.write=function e(t){let n,r,s;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),s=parseInt(r,10),t.put(s,10);const o=this.data.length-n;o>0&&(r=this.data.substr(n),s=parseInt(r,10),t.put(s,o*3+1))};var numericData$1=NumericData$1;const Mode$8=mode$1,ALPHA_NUM_CHARS$1=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function AlphanumericData$1(e){this.mode=Mode$8.ALPHANUMERIC,this.data=e}AlphanumericData$1.getBitsLength=function e(t){return 11*Math.floor(t/2)+6*(t%2)},AlphanumericData$1.prototype.getLength=function e(){return this.data.length},AlphanumericData$1.prototype.getBitsLength=function e(){return AlphanumericData$1.getBitsLength(this.data.length)},AlphanumericData$1.prototype.write=function e(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=ALPHA_NUM_CHARS$1.indexOf(this.data[n])*45;r+=ALPHA_NUM_CHARS$1.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(ALPHA_NUM_CHARS$1.indexOf(this.data[n]),6)};var alphanumericData$1=AlphanumericData$1;const Mode$7=mode$1;function ByteData$1(e){this.mode=Mode$7.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}ByteData$1.getBitsLength=function e(t){return t*8},ByteData$1.prototype.getLength=function e(){return this.data.length},ByteData$1.prototype.getBitsLength=function e(){return ByteData$1.getBitsLength(this.data.length)},ByteData$1.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var byteData$1=ByteData$1;const Mode$6=mode$1,Utils$6=utils$5;function KanjiData$1(e){this.mode=Mode$6.KANJI,this.data=e}KanjiData$1.getBitsLength=function e(t){return t*13},KanjiData$1.prototype.getLength=function e(){return this.data.length},KanjiData$1.prototype.getBitsLength=function e(){return KanjiData$1.getBitsLength(this.data.length)},KanjiData$1.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=Utils$6.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
1672
1672
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var kanjiData$1=KanjiData$1,dijkstra$1={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,s){var o={},a={};a[r]=0;var c=t.PriorityQueue.make();c.push(r,0);for(var l,p,g,m,b,w,E,v,x;!c.empty();){l=c.pop(),p=l.value,m=l.cost,b=n[p]||{};for(g in b)b.hasOwnProperty(g)&&(w=b[g],E=m+w,v=a[g],x=typeof a[g]>"u",(x||v>E)&&(a[g]=E,c.push(g,E),o[g]=p))}if(typeof s<"u"&&typeof a[s]>"u"){var k=["Could not find a path from ",r," to ",s,"."].join("");throw new Error(k)}return o},extract_shortest_path_from_predecessor_list:function(n,r){for(var s=[],o=r;o;)s.push(o),n[o],o=n[o];return s.reverse(),s},find_path:function(n,r,s){var o=t.single_source_shortest_paths(n,r,s);return t.extract_shortest_path_from_predecessor_list(o,s)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,s={},o;n=n||{};for(o in r)r.hasOwnProperty(o)&&(s[o]=r[o]);return s.queue=[],s.sorter=n.sorter||r.default_sorter,s},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var s={value:n,cost:r};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(dijkstra$1);var dijkstraExports=dijkstra$1.exports;(function(e){const t=mode$1,n=numericData$1,r=alphanumericData$1,s=byteData$1,o=kanjiData$1,a=regex$2,c=utils$5,l=dijkstraExports;function p(k){return unescape(encodeURIComponent(k)).length}function g(k,$,A){const R=[];let M;for(;(M=k.exec(A))!==null;)R.push({data:M[0],index:M.index,mode:$,length:M[0].length});return R}function m(k){const $=g(a.NUMERIC,t.NUMERIC,k),A=g(a.ALPHANUMERIC,t.ALPHANUMERIC,k);let R,M;return c.isKanjiModeEnabled()?(R=g(a.BYTE,t.BYTE,k),M=g(a.KANJI,t.KANJI,k)):(R=g(a.BYTE_KANJI,t.BYTE,k),M=[]),$.concat(A,R,M).sort(function(D,B){return D.index-B.index}).map(function(D){return{data:D.data,mode:D.mode,length:D.length}})}function b(k,$){switch($){case t.NUMERIC:return n.getBitsLength(k);case t.ALPHANUMERIC:return r.getBitsLength(k);case t.KANJI:return o.getBitsLength(k);case t.BYTE:return s.getBitsLength(k)}}function w(k){return k.reduce(function($,A){const R=$.length-1>=0?$[$.length-1]:null;return R&&R.mode===A.mode?($[$.length-1].data+=A.data,$):($.push(A),$)},[])}function E(k){const $=[];for(let A=0;A<k.length;A++){const R=k[A];switch(R.mode){case t.NUMERIC:$.push([R,{data:R.data,mode:t.ALPHANUMERIC,length:R.length},{data:R.data,mode:t.BYTE,length:R.length}]);break;case t.ALPHANUMERIC:$.push([R,{data:R.data,mode:t.BYTE,length:R.length}]);break;case t.KANJI:$.push([R,{data:R.data,mode:t.BYTE,length:p(R.data)}]);break;case t.BYTE:$.push([{data:R.data,mode:t.BYTE,length:p(R.data)}])}}return $}function v(k,$){const A={},R={start:{}};let M=["start"];for(let U=0;U<k.length;U++){const D=k[U],B=[];for(let N=0;N<D.length;N++){const P=D[N],T=""+U+N;B.push(T),A[T]={node:P,lastCount:0},R[T]={};for(let L=0;L<M.length;L++){const S=M[L];A[S]&&A[S].node.mode===P.mode?(R[S][T]=b(A[S].lastCount+P.length,P.mode)-b(A[S].lastCount,P.mode),A[S].lastCount+=P.length):(A[S]&&(A[S].lastCount=P.length),R[S][T]=b(P.length,P.mode)+4+t.getCharCountIndicator(P.mode,$))}}M=B}for(let U=0;U<M.length;U++)R[M[U]].end=0;return{map:R,table:A}}function x(k,$){let A;const R=t.getBestModeForData(k);if(A=t.from($,R),A!==t.BYTE&&A.bit<R.bit)throw new Error('"'+k+'" cannot be encoded with mode '+t.toString(A)+`.
1673
1673
  Suggested mode is: `+t.toString(R));switch(A===t.KANJI&&!c.isKanjiModeEnabled()&&(A=t.BYTE),A){case t.NUMERIC:return new n(k);case t.ALPHANUMERIC:return new r(k);case t.KANJI:return new o(k);case t.BYTE:return new s(k)}}e.fromArray=function($){return $.reduce(function(A,R){return typeof R=="string"?A.push(x(R,null)):R.data&&A.push(x(R.data,R.mode)),A},[])},e.fromString=function($,A){const R=m($,c.isKanjiModeEnabled()),M=E(R),U=v(M,A),D=l.find_path(U.map,"start","end"),B=[];for(let N=1;N<D.length-1;N++)B.push(U.table[D[N]].node);return e.fromArray(w(B))},e.rawSplit=function($){return e.fromArray(m($,c.isKanjiModeEnabled()))}})(segments$1);const Utils$5=utils$5,ECLevel$2=errorCorrectionLevel$1,BitBuffer$2=bitBuffer$1,BitMatrix$2=bitMatrix$1,AlignmentPattern$1=alignmentPattern$1,FinderPattern$1=finderPattern$1,MaskPattern$1=maskPattern$1,ECCode$1=errorCorrectionCode$1,ReedSolomonEncoder$2=reedSolomonEncoder$1,Version$1=version$1,FormatInfo$1=formatInfo$1,Mode$5=mode$1,Segments$1=segments$1;function setupFinderPattern$1(e,t){const n=e.size,r=FinderPattern$1.getPositions(t);for(let s=0;s<r.length;s++){const o=r[s][0],a=r[s][1];for(let c=-1;c<=7;c++)if(!(o+c<=-1||n<=o+c))for(let l=-1;l<=7;l++)a+l<=-1||n<=a+l||(c>=0&&c<=6&&(l===0||l===6)||l>=0&&l<=6&&(c===0||c===6)||c>=2&&c<=4&&l>=2&&l<=4?e.set(o+c,a+l,!0,!0):e.set(o+c,a+l,!1,!0))}}function setupTimingPattern$1(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function setupAlignmentPattern$1(e,t){const n=AlignmentPattern$1.getPositions(t);for(let r=0;r<n.length;r++){const s=n[r][0],o=n[r][1];for(let a=-2;a<=2;a++)for(let c=-2;c<=2;c++)a===-2||a===2||c===-2||c===2||a===0&&c===0?e.set(s+a,o+c,!0,!0):e.set(s+a,o+c,!1,!0)}}function setupVersionInfo$1(e,t){const n=e.size,r=Version$1.getEncodedBits(t);let s,o,a;for(let c=0;c<18;c++)s=Math.floor(c/3),o=c%3+n-8-3,a=(r>>c&1)===1,e.set(s,o,a,!0),e.set(o,s,a,!0)}function setupFormatInfo$1(e,t,n){const r=e.size,s=FormatInfo$1.getEncodedBits(t,n);let o,a;for(o=0;o<15;o++)a=(s>>o&1)===1,o<6?e.set(o,8,a,!0):o<8?e.set(o+1,8,a,!0):e.set(r-15+o,8,a,!0),o<8?e.set(8,r-o-1,a,!0):o<9?e.set(8,15-o-1+1,a,!0):e.set(8,15-o-1,a,!0);e.set(r-8,8,1,!0)}function setupData$1(e,t){const n=e.size;let r=-1,s=n-1,o=7,a=0;for(let c=n-1;c>0;c-=2)for(c===6&&c--;;){for(let l=0;l<2;l++)if(!e.isReserved(s,c-l)){let p=!1;a<t.length&&(p=(t[a]>>>o&1)===1),e.set(s,c-l,p),o--,o===-1&&(a++,o=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function createData$1(e,t,n){const r=new BitBuffer$2;n.forEach(function(l){r.put(l.mode.bit,4),r.put(l.getLength(),Mode$5.getCharCountIndicator(l.mode,e)),l.write(r)});const s=Utils$5.getSymbolTotalCodewords(e),o=ECCode$1.getTotalCodewordsCount(e,t),a=(s-o)*8;for(r.getLengthInBits()+4<=a&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const c=(a-r.getLengthInBits())/8;for(let l=0;l<c;l++)r.put(l%2?17:236,8);return createCodewords$1(r,e,t)}function createCodewords$1(e,t,n){const r=Utils$5.getSymbolTotalCodewords(t),s=ECCode$1.getTotalCodewordsCount(t,n),o=r-s,a=ECCode$1.getBlocksCount(t,n),c=r%a,l=a-c,p=Math.floor(r/a),g=Math.floor(o/a),m=g+1,b=p-g,w=new ReedSolomonEncoder$2(b);let E=0;const v=new Array(a),x=new Array(a);let k=0;const $=new Uint8Array(e.buffer);for(let D=0;D<a;D++){const B=D<l?g:m;v[D]=$.slice(E,E+B),x[D]=w.encode(v[D]),E+=B,k=Math.max(k,B)}const A=new Uint8Array(r);let R=0,M,U;for(M=0;M<k;M++)for(U=0;U<a;U++)M<v[U].length&&(A[R++]=v[U][M]);for(M=0;M<b;M++)for(U=0;U<a;U++)A[R++]=x[U][M];return A}function createSymbol$1(e,t,n,r){let s;if(Array.isArray(e))s=Segments$1.fromArray(e);else if(typeof e=="string"){let p=t;if(!p){const g=Segments$1.rawSplit(e);p=Version$1.getBestVersionForData(g,n)}s=Segments$1.fromString(e,p||40)}else throw new Error("Invalid data");const o=Version$1.getBestVersionForData(s,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`