nostr-components 0.3.0 → 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.
Files changed (131) hide show
  1. package/README.md +58 -46
  2. package/dist/assets/{base-styles-DC0ilu4S.js → base-styles-Dmuzg8I4.js} +3 -3
  3. package/dist/assets/{base-styles-DC0ilu4S.js.map → base-styles-Dmuzg8I4.js.map} +1 -1
  4. package/dist/assets/{copy-delegation-CcagQMIW.js → copy-delegation-xzt-t_do.js} +5 -5
  5. package/dist/assets/{copy-delegation-CcagQMIW.js.map → copy-delegation-xzt-t_do.js.map} +1 -1
  6. package/dist/assets/dark-nostrich-running.gif +0 -0
  7. package/dist/assets/default_dp-NQ3TGrtT.png +0 -0
  8. package/dist/assets/default_dp.png +0 -0
  9. package/dist/assets/default_dp_32.png +0 -0
  10. package/dist/assets/{dialog-component-Dqg0QU9I.js → dialog-component-Da1ZIYh9.js} +7 -2
  11. package/dist/assets/dialog-component-Da1ZIYh9.js.map +1 -0
  12. package/dist/assets/{dialog-likers-D3c7WIMp.js → dialog-likers-Bq6kUbS0.js} +4 -4
  13. package/dist/assets/{dialog-likers-D3c7WIMp.js.map → dialog-likers-Bq6kUbS0.js.map} +1 -1
  14. package/dist/assets/light-nostrich-running.gif +0 -0
  15. package/dist/assets/{nostr-service-m3Hgc5Xx.js → nostr-service-CA0Qx4nJ.js} +3 -3
  16. package/dist/assets/{nostr-service-m3Hgc5Xx.js.map → nostr-service-CA0Qx4nJ.js.map} +1 -1
  17. package/dist/assets/nostr-user-component-r-MUbTL6.js +2 -0
  18. package/dist/assets/nostr-user-component-r-MUbTL6.js.map +1 -0
  19. package/dist/assets/{pure-laCRX9eG.js → pure-DOoUcNQv.js} +2 -2
  20. package/dist/assets/{pure-laCRX9eG.js.map → pure-DOoUcNQv.js.map} +1 -1
  21. package/dist/assets/{theme-C1r1Zw8r.js → theme-BN1Bvweb.js} +2 -2
  22. package/dist/assets/{theme-C1r1Zw8r.js.map → theme-BN1Bvweb.js.map} +1 -1
  23. package/dist/assets/{user-resolver-DqI5KGh6.js → user-resolver-ArI0680e.js} +2 -2
  24. package/dist/assets/{user-resolver-DqI5KGh6.js.map → user-resolver-ArI0680e.js.map} +1 -1
  25. package/dist/assets/zap-utils-BiKkJPt6.js +2 -0
  26. package/dist/assets/zap-utils-BiKkJPt6.js.map +1 -0
  27. package/dist/components/nostr-comment.es.js +6 -6
  28. package/dist/components/nostr-comment.es.js.map +1 -1
  29. package/dist/components/nostr-dm.es.js +2 -2
  30. package/dist/components/nostr-dm.es.js.map +1 -1
  31. package/dist/components/nostr-follow-button.es.js +3 -3
  32. package/dist/components/nostr-follow-button.es.js.map +1 -1
  33. package/dist/components/nostr-like.es.js +6 -6
  34. package/dist/components/nostr-like.es.js.map +1 -1
  35. package/dist/components/nostr-live-chat.es.js +3 -3
  36. package/dist/components/nostr-live-chat.es.js.map +1 -1
  37. package/dist/components/nostr-post.es.js +2 -2
  38. package/dist/components/nostr-post.es.js.map +1 -1
  39. package/dist/components/nostr-profile-badge.es.js +3 -3
  40. package/dist/components/nostr-profile-badge.es.js.map +1 -1
  41. package/dist/components/nostr-profile.es.js +5 -5
  42. package/dist/components/nostr-profile.es.js.map +1 -1
  43. package/dist/components/nostr-zap.es.js +5 -5
  44. package/dist/components/nostr-zap.es.js.map +1 -1
  45. package/dist/index.d.ts +6 -0
  46. package/dist/nostr-comment.d.ts +4 -0
  47. package/dist/nostr-components.es.js +1 -1
  48. package/dist/nostr-components.es.js.map +1 -1
  49. package/dist/nostr-components.umd.js +69 -40
  50. package/dist/nostr-components.umd.js.map +1 -1
  51. package/dist/nostr-dm.d.ts +4 -0
  52. package/dist/nostr-follow-button.d.ts +4 -0
  53. package/dist/nostr-like.d.ts +4 -0
  54. package/dist/nostr-live-chat.d.ts +4 -0
  55. package/dist/nostr-post.d.ts +4 -0
  56. package/dist/nostr-profile-badge.d.ts +4 -0
  57. package/dist/nostr-profile.d.ts +4 -0
  58. package/dist/nostr-zap.d.ts +4 -0
  59. package/dist/src/base/base-component/nostr-base-component.d.ts +116 -0
  60. package/dist/src/base/copy-delegation.d.ts +5 -0
  61. package/dist/src/base/dialog-component/dialog-component.d.ts +67 -0
  62. package/dist/src/base/dialog-component/style.d.ts +5 -0
  63. package/dist/src/base/event-component/nostr-event-component.d.ts +53 -0
  64. package/dist/src/base/render-options.d.ts +5 -0
  65. package/dist/src/base/resolvers/event-resolver.d.ts +20 -0
  66. package/dist/src/base/resolvers/user-resolver.d.ts +19 -0
  67. package/dist/src/base/text-row/render-name.d.ts +7 -0
  68. package/dist/src/base/text-row/render-nip05.d.ts +1 -0
  69. package/dist/src/base/text-row/render-npub.d.ts +1 -0
  70. package/dist/src/base/text-row/render-text-row.d.ts +9 -0
  71. package/dist/src/base/user-component/nostr-user-component.d.ts +43 -0
  72. package/dist/src/common/base-styles.d.ts +44 -0
  73. package/dist/src/common/constants.d.ts +4 -0
  74. package/dist/src/common/date-utils.d.ts +9 -0
  75. package/dist/src/common/icons.d.ts +7 -0
  76. package/dist/src/common/nip05-utils.d.ts +13 -0
  77. package/dist/src/common/nostr-login-service.d.ts +26 -0
  78. package/dist/src/common/nostr-service.d.ts +40 -0
  79. package/dist/src/common/theme.d.ts +4 -0
  80. package/dist/src/common/types.d.ts +1 -0
  81. package/dist/src/common/utils.d.ts +34 -0
  82. package/dist/src/index.d.ts +32 -0
  83. package/dist/src/nostr-comment/nostr-comment.d.ts +60 -0
  84. package/dist/src/nostr-comment/render.d.ts +15 -0
  85. package/dist/src/nostr-comment/utils.d.ts +81 -0
  86. package/dist/src/nostr-dm/nostr-dm.d.ts +34 -0
  87. package/dist/src/nostr-dm/render.d.ts +15 -0
  88. package/dist/src/nostr-follow-button/nostr-follow-button.d.ts +24 -0
  89. package/dist/src/nostr-follow-button/render.d.ts +11 -0
  90. package/dist/src/nostr-follow-button/style.d.ts +1 -0
  91. package/dist/src/nostr-like/dialog-help-style.d.ts +1 -0
  92. package/dist/src/nostr-like/dialog-help.d.ts +2 -0
  93. package/dist/src/nostr-like/dialog-likers-style.d.ts +1 -0
  94. package/dist/src/nostr-like/dialog-likers.d.ts +24 -0
  95. package/dist/src/nostr-like/like-utils.d.ts +48 -0
  96. package/dist/src/nostr-like/nostr-like.d.ts +49 -0
  97. package/dist/src/nostr-like/render.d.ts +10 -0
  98. package/dist/src/nostr-like/style.d.ts +1 -0
  99. package/dist/src/nostr-live-chat/nostr-live-chat.d.ts +65 -0
  100. package/dist/src/nostr-live-chat/render.d.ts +31 -0
  101. package/dist/src/nostr-post/nostr-post.d.ts +25 -0
  102. package/dist/src/nostr-post/parse-text.d.ts +8 -0
  103. package/dist/src/nostr-post/render-content.d.ts +5 -0
  104. package/dist/src/nostr-post/render.d.ts +19 -0
  105. package/dist/src/nostr-post/style.d.ts +1 -0
  106. package/dist/src/nostr-profile/nostr-profile.d.ts +24 -0
  107. package/dist/src/nostr-profile/render-stats.d.ts +1 -0
  108. package/dist/src/nostr-profile/render.d.ts +22 -0
  109. package/dist/src/nostr-profile/style.d.ts +1 -0
  110. package/dist/src/nostr-profile-badge/nostr-profile-badge.d.ts +34 -0
  111. package/dist/src/nostr-profile-badge/render.d.ts +11 -0
  112. package/dist/src/nostr-profile-badge/style.d.ts +1 -0
  113. package/dist/src/nostr-zap/dialog-help-style.d.ts +5 -0
  114. package/dist/src/nostr-zap/dialog-help.d.ts +2 -0
  115. package/dist/src/nostr-zap/dialog-zap-style.d.ts +6 -0
  116. package/dist/src/nostr-zap/dialog-zap.d.ts +31 -0
  117. package/dist/src/nostr-zap/dialog-zappers-style.d.ts +1 -0
  118. package/dist/src/nostr-zap/dialog-zappers.d.ts +25 -0
  119. package/dist/src/nostr-zap/nostr-zap.d.ts +45 -0
  120. package/dist/src/nostr-zap/render.d.ts +9 -0
  121. package/dist/src/nostr-zap/style.d.ts +1 -0
  122. package/dist/src/nostr-zap/zap-utils.d.ts +57 -0
  123. package/dist/vite.config.d.ts +2 -0
  124. package/dist/vite.config.esm.d.ts +2 -0
  125. package/dist/vite.config.umd.d.ts +2 -0
  126. package/package.json +1 -1
  127. package/dist/assets/dialog-component-Dqg0QU9I.js.map +0 -1
  128. package/dist/assets/nostr-user-component-XEnanH-d.js +0 -2
  129. package/dist/assets/nostr-user-component-XEnanH-d.js.map +0 -1
  130. package/dist/assets/zap-utils-BZcaCsT_.js +0 -2
  131. package/dist/assets/zap-utils-BZcaCsT_.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"mappings":";m2BAMO,MAAMA,GAAkB,CAACC,EAA0B,UAAoB,CAC5E,MAAMC,EAASD,IAAU,OAEzB,MAAO;AAAA;AAAA;AAAA;AAAA,eAIMC,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAoBnBA,EAAS,UAAY,SAAS;AAAA;AAAA,oBAEpCA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA,eAGnCA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAsCnBA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBA4BpCA,EAAS,UAAY,SAAS;AAAA,0BACxBA,EAAS,UAAY,SAAS;AAAA,eACzCA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOz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AoB,CACvC,OAAQ,KAAK,KAAK,OAClB,OAAQ,KAAK,YACb,IAAK,KAAK,aAAa,KAAK,GAAK,OAClC,EACD,KAAK,eAAiB5X,EAAO,YAC7B,KAAK,iBAAmBA,EAAO,WAC/B,KAAK,cAAc,IAAI4W,EAAS,KAAK,CACvC,OAAS1I,EAAG,CACV,QAAQ,MAAM,0DAA2DA,CAAC,EAC1E,KAAK,eAAiB,KACtB,KAAK,cAAc,IAAI0I,EAAS,KAAK,CACvC,SACE,KAAK,QACP,CACF,CAEU,eAAgB,CACxB,MAAMiB,EAAgB,KAAK,WAAW,OAASjB,EAAS,QAClDhB,EAAkB,KAAK,cAAc,OAASgB,EAAS,QACvDrB,EAAU,KAAK,mBAAqBqB,EAAS,MAC7CnB,EAAe,KAAK,aACpBC,EAAa,KAAK,aAAa,MAAM,GAAK,MAE1CoC,EAAwC,CAC5C,UAAWD,EACX,gBAAAjC,EACA,QAAAL,EACA,UAAW,GACX,aAAAE,EACA,WAAAC,EACA,eAAgB,KAAK,eACrB,QAAS,KAAK,iBAAiB,OAAS,GAG1C,KAAK,WAAY,UAAY;AAAA,QACzBc,IAAoB;AAAA,QACpBnB,GAAgByC,CAAa,CAAC;AAAA,KAEpC,CACF,CAEA,eAAe,OAAO,YAAarB,EAAQ","names":["getDialogStyles","theme","isDark","canPromise","toSJISFunction","CODEWORDS_COUNT","utils","version","data","digit","f","kanji","exports","fromString","string","level","value","defaultValue","BitBuffer","index","bufIndex","num","length","i","bit","bitBuffer","BitMatrix","size","row","col","reserved","bitMatrix","getSymbolSize","require$$0","posCount","intervals","positions","coords","pos","posLength","j","FINDER_PATTERN_SIZE","finderPattern","PenaltyScores","mask","points","sameCountCol","sameCountRow","lastCol","lastRow","module","last","bitsCol","bitsRow","darkCount","modulesCount","getMaskAt","maskPattern","pattern","setupFormatFunc","numPatterns","bestPattern","lowerPenalty","p","penalty","ECLevel","EC_BLOCKS_TABLE","EC_CODEWORDS_TABLE","errorCorrectionCode","errorCorrectionLevel","EXP_TABLE","LOG_TABLE","x","galoisField","n","y","GF","p1","p2","coeff","divident","divisor","result","offset","degree","poly","Polynomial","ReedSolomonEncoder","paddedData","remainder","start","buff","reedSolomonEncoder","versionCheck","numeric","alphanumeric","byte","regex","TEST_KANJI","TEST_NUMERIC","TEST_ALPHANUMERIC","str","VersionCheck","Regex","require$$1","mode","dataStr","Utils","ECCode","require$$2","Mode","require$$3","require$$4","G18","G18_BCH","getBestVersionForDataLength","currentVersion","getReservedBitsCount","getTotalBitsFromDataArray","segments","totalBits","reservedBits","getBestVersionForMixedData","totalCodewords","ecTotalCodewords","dataTotalCodewordsBits","usableBits","seg","ecl","d","G15","G15_MASK","G15_BCH","formatInfo","NumericData","group","remainingNum","numericData","ALPHA_NUM_CHARS","AlphanumericData","alphanumericData","ByteData","l","byteData","KanjiData","kanjiData","dijkstra","graph","s","predecessors","costs","open","closest","u","v","cost_of_s_to_u","adjacent_nodes","cost_of_e","cost_of_s_to_u_plus_cost_of_e","cost_of_s_to_v","first_visit","msg","nodes","opts","T","t","key","a","b","cost","item","require$$5","require$$6","require$$7","getStringByteLength","getSegments","getSegmentsFromString","numSegs","alphaNumSegs","byteSegs","kanjiSegs","s1","s2","obj","getSegmentBitsLength","mergeSegments","segs","acc","curr","prevSeg","buildNodes","buildGraph","table","prevNodeIds","nodeGroup","currentNodeIds","node","prevNodeId","buildSingleSegment","modesHint","bestMode","array","path","optimizedSegs","AlignmentPattern","FinderPattern","MaskPattern","require$$8","Version","require$$9","FormatInfo","require$$10","require$$11","Segments","require$$12","setupFinderPattern","matrix","r","setupTimingPattern","setupAlignmentPattern","c","setupVersionInfo","bits","mod","setupFormatInfo","setupData","inc","bitIndex","byteIndex","dark","createData","buffer","remainingByte","createCodewords","dataTotalCodewords","ecTotalBlocks","blocksInGroup2","blocksInGroup1","totalCodewordsInGroup1","dataCodewordsInGroup1","dataCodewordsInGroup2","ecCount","rs","dcData","ecData","maxDataSize","dataSize","createSymbol","estimatedVersion","rawSegments","bestVersion","dataBits","moduleCount","modules","qrcode","options","hex2rgba","hex","hexCode","hexValue","margin","width","scale","qrSize","imgData","qr","symbolSize","scaledMargin","palette","posDst","pxColor","iSrc","jSrc","clearCanvas","ctx","canvas","getCanvasElement","qrData","canvasEl","image","type","rendererOpts","getColorAttrib","color","attrib","alpha","svgCmd","cmd","qrToPath","moveBy","newRow","lineLength","svgTag","cb","qrcodesize","bg","viewBox","QRCode","CanvasRenderer","SvgRenderer","renderCanvas","renderFunc","text","args","argsNum","isLastArgCb","resolve","reject","e","toDataURL","_","injectCSS","style","init","params","npub","relays","cachedDialogComponent","buttonColor","fixedAmount","defaultAmount","initialAmount","url","npubHex","decodeNpub","cachedDialog","el","updateZapBtn","successOverlay","refreshUI","presets","selectedAmount","customComment","currentInvoice","cleanupReceipt","loadInvoice","amountSats","comment","authorId","meta","getProfileMetadata","endpoint","getZapEndpoint","invoice","fetchInvoice","relaysArr","listenForZapReceipt","markSuccess","qrImgSrc","QRCode.toDataURL","error","setActiveAmountButtons","container","amt","btn","dialog","qrImg","src","payBtn","dialogComponent","amountButtonsHtml","hideAmountUI","dialogElement","_a","amountContainer","target","val","customAmountInput","commentInput","copyInvoice","addCommentBtn","overlay","btnColor","getContrastingTextColor","input","ch","g","getHelpDialogStyles","YOUTUBE_URL","injectHelpDialogStyles","showHelpDialog","getZappersDialogStyles","getComponentStyles","injectZappersDialogStyles","renderZapEntry","zap","authorNameSafe","escapeHtml","njumpUrl","isValidPublicKey","profilePictureSafe","isValidUrl","profilePicture","commentHtml","formatRelativeTime","renderSkeletonZapEntry","openZappersDialog","zapDetails","initialContent","renderInitialContent","enhanceZapDetailsProgressively","npubs","hexToNpub","zappersList","uniqueAuthorIds","profileResults","getBatchedProfileMetadata","profileMap","npubMap","pubkey","profile","enhanced","profileContent","extractProfileMetadataContent","skeletonEntry","enhancedEntry","enhanceZapDetailsIndividually","profileCache","profilePromises","cachedProfile","__vitePreload","profileMetadata","promise","renderZapButton","isLoading","isError","isSuccess","errorMessage","buttonText","totalZapAmount","isAmountLoading","hasZaps","renderError","renderLoading","iconContent","getLightningIcon","textContent","renderContainer","renderErrorContainer","leftContent","rightContent","zapAmountHtml","getZapButtonStyles","NostrZap","NostrUserComponent","__publicField","NCStatus","name","oldValue","newValue","_status","_user","_profile","textAttr","amtAttr","defaultAmtAttr","urlAttr","tagName","ensureInitialized","openZapModal","defAttr","_b","fetchTotalZapAmount","isUserLoading","renderOptions"],"ignoreList":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],"sources":["../../src/nostr-zap/dialog-zap-style.ts","../../node_modules/qrcode/lib/can-promise.js","../../node_modules/qrcode/lib/core/utils.js","../../node_modules/qrcode/lib/core/error-correction-level.js","../../node_modules/qrcode/lib/core/bit-buffer.js","../../node_modules/qrcode/lib/core/bit-matrix.js","../../node_modules/qrcode/lib/core/alignment-pattern.js","../../node_modules/qrcode/lib/core/finder-pattern.js","../../node_modules/qrcode/lib/core/mask-pattern.js","../../node_modules/qrcode/lib/core/error-correction-code.js","../../node_modules/qrcode/lib/core/galois-field.js","../../node_modules/qrcode/lib/core/polynomial.js","../../node_modules/qrcode/lib/core/reed-solomon-encoder.js","../../node_modules/qrcode/lib/core/version-check.js","../../node_modules/qrcode/lib/core/regex.js","../../node_modules/qrcode/lib/core/mode.js","../../node_modules/qrcode/lib/core/version.js","../../node_modules/qrcode/lib/core/format-info.js","../../node_modules/qrcode/lib/core/numeric-data.js","../../node_modules/qrcode/lib/core/alphanumeric-data.js","../../node_modules/qrcode/lib/core/byte-data.js","../../node_modules/qrcode/lib/core/kanji-data.js","../../node_modules/dijkstrajs/dijkstra.js","../../node_modules/qrcode/lib/core/segments.js","../../node_modules/qrcode/lib/core/qrcode.js","../../node_modules/qrcode/lib/renderer/utils.js","../../node_modules/qrcode/lib/renderer/canvas.js","../../node_modules/qrcode/lib/renderer/svg-tag.js","../../node_modules/qrcode/lib/browser.js","../../src/nostr-zap/dialog-zap.ts","../../src/nostr-zap/dialog-help-style.ts","../../src/nostr-zap/dialog-help.ts","../../src/nostr-zap/dialog-zappers-style.ts","../../src/nostr-zap/dialog-zappers.ts","../../src/nostr-zap/render.ts","../../src/nostr-zap/style.ts","../../src/nostr-zap/nostr-zap.ts"],"sourcesContent":["/**\n * Dialog styles for nostr-zap component\n * Extracted from dialog.ts for better organization\n * Uses CSS variables from nostr-zap component for consistency\n */\n\nexport const getDialogStyles = (theme: 'light' | 'dark' = 'light'): string => {\n const isDark = theme === 'dark';\n \n return `\n /* === ZAP DIALOG CONTENT STYLES === */\n .zap-dialog-content {\n text-align: center;\n color: ${isDark ? '#ffffff' : '#000000'};\n }\n\n .zap-dialog-content p {\n margin: 4px 0;\n word-break: break-word;\n }\n\n /* === AMOUNT BUTTONS === */\n .zap-dialog-content .amount-buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin: 16px 0 8px;\n }\n\n .zap-dialog-content .amount-buttons button {\n flex: 1 1 30%;\n min-width: 72px;\n padding: 8px 0;\n border: 1px solid ${isDark ? '#3a3a3a' : '#e2e8f0'};\n border-radius: 6px;\n background: ${isDark ? '#262626' : '#f7fafc'};\n cursor: pointer;\n font-size: 14px;\n color: ${isDark ? '#ffffff' : '#000000'};\n }\n\n .zap-dialog-content .amount-buttons button.active {\n background: #7f00ff;\n color: #ffffff;\n }\n\n /* === ACTION BUTTONS === */\n .zap-dialog-content .cta-btn {\n width: 100%;\n padding: 12px 0;\n border: none;\n border-radius: 6px;\n font-size: 16px;\n margin-top: 16px;\n cursor: pointer;\n background: #7f00ff;\n color: #ffffff;\n }\n\n .zap-dialog-content .copy-btn {\n margin-top: 12px;\n cursor: pointer;\n font-size: 14px;\n background: none;\n border: none;\n color: #7f00ff;\n }\n\n .zap-dialog-content .update-zap-btn {\n background: #7f00ff;\n color: #ffffff;\n }\n\n /* === QR CODE === */\n .zap-dialog-content img.qr {\n margin-top: 16px;\n border: 1px solid ${isDark ? '#3a3a3a' : '#e2e8f0'};\n border-radius: 8px;\n }\n\n /* === INPUT CONTAINERS === */\n .zap-dialog-content .update-zap-container {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-top: 8px;\n }\n\n .zap-dialog-content .update-zap-container .custom-amount {\n flex-grow: 1;\n }\n\n .zap-dialog-content .comment-container {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-top: 8px;\n }\n\n .zap-dialog-content .comment-container .comment-input {\n flex-grow: 1;\n }\n\n .zap-dialog-content input {\n background: ${isDark ? '#262626' : '#ffffff'};\n border: 1px solid ${isDark ? '#3a3a3a' : '#e2e8f0'};\n color: ${isDark ? '#ffffff' : '#000000'};\n }\n\n /* === LOADING OVERLAY === */\n .nostr-base-dialog .loading-overlay {\n position: absolute;\n inset: 0;\n background: ${isDark ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)'};\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 10px;\n opacity: 0;\n transition: opacity 0.2s ease;\n pointer-events: none;\n }\n\n .nostr-base-dialog.loading .loading-overlay {\n opacity: 1;\n pointer-events: auto;\n }\n\n .nostr-base-dialog .loading-overlay .loader {\n width: 40px;\n height: 40px;\n border: 4px solid ${isDark ? '#3a3a3a' : '#ccc'};\n border-top-color: #7f00ff;\n border-radius: 50%;\n animation: nstrc-spin 1s linear infinite;\n }\n\n /* === SUCCESS OVERLAY === */\n .nostr-base-dialog .success-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.65);\n display: flex;\n justify-content: center;\n align-items: center;\n color: #ffffff;\n font-size: 24px;\n border-radius: 10px;\n opacity: 0;\n transition: opacity 0.3s ease;\n pointer-events: none;\n }\n\n .nostr-base-dialog.success .success-overlay {\n opacity: 1;\n pointer-events: auto;\n }\n\n /* === ANIMATIONS === */\n @keyframes nstrc-spin {\n to {\n transform: rotate(360deg);\n }\n }\n `;\n};","// can-promise has a crash in some versions of react native that dont have\n// standard global objects\n// https://github.com/soldair/node-qrcode/issues/157\n\nmodule.exports = function () {\n return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then\n}\n","let toSJISFunction\nconst CODEWORDS_COUNT = [\n 0, // Not used\n 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,\n 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,\n 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,\n 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706\n]\n\n/**\n * Returns the QR Code size for the specified version\n *\n * @param {Number} version QR Code version\n * @return {Number} size of QR code\n */\nexports.getSymbolSize = function getSymbolSize (version) {\n if (!version) throw new Error('\"version\" cannot be null or undefined')\n if (version < 1 || version > 40) throw new Error('\"version\" should be in range from 1 to 40')\n return version * 4 + 17\n}\n\n/**\n * Returns the total number of codewords used to store data and EC information.\n *\n * @param {Number} version QR Code version\n * @return {Number} Data length in bits\n */\nexports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {\n return CODEWORDS_COUNT[version]\n}\n\n/**\n * Encode data with Bose-Chaudhuri-Hocquenghem\n *\n * @param {Number} data Value to encode\n * @return {Number} Encoded value\n */\nexports.getBCHDigit = function (data) {\n let digit = 0\n\n while (data !== 0) {\n digit++\n data >>>= 1\n }\n\n return digit\n}\n\nexports.setToSJISFunction = function setToSJISFunction (f) {\n if (typeof f !== 'function') {\n throw new Error('\"toSJISFunc\" is not a valid function.')\n }\n\n toSJISFunction = f\n}\n\nexports.isKanjiModeEnabled = function () {\n return typeof toSJISFunction !== 'undefined'\n}\n\nexports.toSJIS = function toSJIS (kanji) {\n return toSJISFunction(kanji)\n}\n","exports.L = { bit: 1 }\nexports.M = { bit: 0 }\nexports.Q = { bit: 3 }\nexports.H = { bit: 2 }\n\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'l':\n case 'low':\n return exports.L\n\n case 'm':\n case 'medium':\n return exports.M\n\n case 'q':\n case 'quartile':\n return exports.Q\n\n case 'h':\n case 'high':\n return exports.H\n\n default:\n throw new Error('Unknown EC Level: ' + string)\n }\n}\n\nexports.isValid = function isValid (level) {\n return level && typeof level.bit !== 'undefined' &&\n level.bit >= 0 && level.bit < 4\n}\n\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n","function BitBuffer () {\n this.buffer = []\n this.length = 0\n}\n\nBitBuffer.prototype = {\n\n get: function (index) {\n const bufIndex = Math.floor(index / 8)\n return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1\n },\n\n put: function (num, length) {\n for (let i = 0; i < length; i++) {\n this.putBit(((num >>> (length - i - 1)) & 1) === 1)\n }\n },\n\n getLengthInBits: function () {\n return this.length\n },\n\n putBit: function (bit) {\n const bufIndex = Math.floor(this.length / 8)\n if (this.buffer.length <= bufIndex) {\n this.buffer.push(0)\n }\n\n if (bit) {\n this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))\n }\n\n this.length++\n }\n}\n\nmodule.exports = BitBuffer\n","/**\n * Helper class to handle QR Code symbol modules\n *\n * @param {Number} size Symbol size\n */\nfunction BitMatrix (size) {\n if (!size || size < 1) {\n throw new Error('BitMatrix size must be defined and greater than 0')\n }\n\n this.size = size\n this.data = new Uint8Array(size * size)\n this.reservedBit = new Uint8Array(size * size)\n}\n\n/**\n * Set bit value at specified location\n * If reserved flag is set, this bit will be ignored during masking process\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n * @param {Boolean} reserved\n */\nBitMatrix.prototype.set = function (row, col, value, reserved) {\n const index = row * this.size + col\n this.data[index] = value\n if (reserved) this.reservedBit[index] = true\n}\n\n/**\n * Returns bit value at specified location\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.get = function (row, col) {\n return this.data[row * this.size + col]\n}\n\n/**\n * Applies xor operator at specified location\n * (used during masking process)\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n */\nBitMatrix.prototype.xor = function (row, col, value) {\n this.data[row * this.size + col] ^= value\n}\n\n/**\n * Check if bit at specified location is reserved\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.isReserved = function (row, col) {\n return this.reservedBit[row * this.size + col]\n}\n\nmodule.exports = BitMatrix\n","/**\n * Alignment pattern are fixed reference pattern in defined positions\n * in a matrix symbology, which enables the decode software to re-synchronise\n * the coordinate mapping of the image modules in the event of moderate amounts\n * of distortion of the image.\n *\n * Alignment patterns are present only in QR Code symbols of version 2 or larger\n * and their number depends on the symbol version.\n */\n\nconst getSymbolSize = require('./utils').getSymbolSize\n\n/**\n * Calculate the row/column coordinates of the center module of each alignment pattern\n * for the specified QR Code version.\n *\n * The alignment patterns are positioned symmetrically on either side of the diagonal\n * running from the top left corner of the symbol to the bottom right corner.\n *\n * Since positions are simmetrical only half of the coordinates are returned.\n * Each item of the array will represent in turn the x and y coordinate.\n * @see {@link getPositions}\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinate\n */\nexports.getRowColCoords = function getRowColCoords (version) {\n if (version === 1) return []\n\n const posCount = Math.floor(version / 7) + 2\n const size = getSymbolSize(version)\n const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2\n const positions = [size - 7] // Last coord is always (size - 7)\n\n for (let i = 1; i < posCount - 1; i++) {\n positions[i] = positions[i - 1] - intervals\n }\n\n positions.push(6) // First coord is always 6\n\n return positions.reverse()\n}\n\n/**\n * Returns an array containing the positions of each alignment pattern.\n * Each array's element represent the center point of the pattern as (x, y) coordinates\n *\n * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}\n * and filtering out the items that overlaps with finder pattern\n *\n * @example\n * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.\n * The alignment patterns, therefore, are to be centered on (row, column)\n * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).\n * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns\n * and are not therefore used for alignment patterns.\n *\n * let pos = getPositions(7)\n * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinates\n */\nexports.getPositions = function getPositions (version) {\n const coords = []\n const pos = exports.getRowColCoords(version)\n const posLength = pos.length\n\n for (let i = 0; i < posLength; i++) {\n for (let j = 0; j < posLength; j++) {\n // Skip if position is occupied by finder patterns\n if ((i === 0 && j === 0) || // top-left\n (i === 0 && j === posLength - 1) || // bottom-left\n (i === posLength - 1 && j === 0)) { // top-right\n continue\n }\n\n coords.push([pos[i], pos[j]])\n }\n }\n\n return coords\n}\n","const getSymbolSize = require('./utils').getSymbolSize\nconst FINDER_PATTERN_SIZE = 7\n\n/**\n * Returns an array containing the positions of each finder pattern.\n * Each array's element represent the top-left point of the pattern as (x, y) coordinates\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinates\n */\nexports.getPositions = function getPositions (version) {\n const size = getSymbolSize(version)\n\n return [\n // top-left\n [0, 0],\n // top-right\n [size - FINDER_PATTERN_SIZE, 0],\n // bottom-left\n [0, size - FINDER_PATTERN_SIZE]\n ]\n}\n","/**\n * Data mask pattern reference\n * @type {Object}\n */\nexports.Patterns = {\n PATTERN000: 0,\n PATTERN001: 1,\n PATTERN010: 2,\n PATTERN011: 3,\n PATTERN100: 4,\n PATTERN101: 5,\n PATTERN110: 6,\n PATTERN111: 7\n}\n\n/**\n * Weighted penalty scores for the undesirable features\n * @type {Object}\n */\nconst PenaltyScores = {\n N1: 3,\n N2: 3,\n N3: 40,\n N4: 10\n}\n\n/**\n * Check if mask pattern value is valid\n *\n * @param {Number} mask Mask pattern\n * @return {Boolean} true if valid, false otherwise\n */\nexports.isValid = function isValid (mask) {\n return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7\n}\n\n/**\n * Returns mask pattern from a value.\n * If value is not valid, returns undefined\n *\n * @param {Number|String} value Mask pattern value\n * @return {Number} Valid mask pattern or undefined\n */\nexports.from = function from (value) {\n return exports.isValid(value) ? parseInt(value, 10) : undefined\n}\n\n/**\n* Find adjacent modules in row/column with the same color\n* and assign a penalty value.\n*\n* Points: N1 + i\n* i is the amount by which the number of adjacent modules of the same color exceeds 5\n*/\nexports.getPenaltyN1 = function getPenaltyN1 (data) {\n const size = data.size\n let points = 0\n let sameCountCol = 0\n let sameCountRow = 0\n let lastCol = null\n let lastRow = null\n\n for (let row = 0; row < size; row++) {\n sameCountCol = sameCountRow = 0\n lastCol = lastRow = null\n\n for (let col = 0; col < size; col++) {\n let module = data.get(row, col)\n if (module === lastCol) {\n sameCountCol++\n } else {\n if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)\n lastCol = module\n sameCountCol = 1\n }\n\n module = data.get(col, row)\n if (module === lastRow) {\n sameCountRow++\n } else {\n if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)\n lastRow = module\n sameCountRow = 1\n }\n }\n\n if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)\n if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)\n }\n\n return points\n}\n\n/**\n * Find 2x2 blocks with the same color and assign a penalty value\n *\n * Points: N2 * (m - 1) * (n - 1)\n */\nexports.getPenaltyN2 = function getPenaltyN2 (data) {\n const size = data.size\n let points = 0\n\n for (let row = 0; row < size - 1; row++) {\n for (let col = 0; col < size - 1; col++) {\n const last = data.get(row, col) +\n data.get(row, col + 1) +\n data.get(row + 1, col) +\n data.get(row + 1, col + 1)\n\n if (last === 4 || last === 0) points++\n }\n }\n\n return points * PenaltyScores.N2\n}\n\n/**\n * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,\n * preceded or followed by light area 4 modules wide\n *\n * Points: N3 * number of pattern found\n */\nexports.getPenaltyN3 = function getPenaltyN3 (data) {\n const size = data.size\n let points = 0\n let bitsCol = 0\n let bitsRow = 0\n\n for (let row = 0; row < size; row++) {\n bitsCol = bitsRow = 0\n for (let col = 0; col < size; col++) {\n bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)\n if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++\n\n bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)\n if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++\n }\n }\n\n return points * PenaltyScores.N3\n}\n\n/**\n * Calculate proportion of dark modules in entire symbol\n *\n * Points: N4 * k\n *\n * k is the rating of the deviation of the proportion of dark modules\n * in the symbol from 50% in steps of 5%\n */\nexports.getPenaltyN4 = function getPenaltyN4 (data) {\n let darkCount = 0\n const modulesCount = data.data.length\n\n for (let i = 0; i < modulesCount; i++) darkCount += data.data[i]\n\n const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)\n\n return k * PenaltyScores.N4\n}\n\n/**\n * Return mask value at given position\n *\n * @param {Number} maskPattern Pattern reference value\n * @param {Number} i Row\n * @param {Number} j Column\n * @return {Boolean} Mask value\n */\nfunction getMaskAt (maskPattern, i, j) {\n switch (maskPattern) {\n case exports.Patterns.PATTERN000: return (i + j) % 2 === 0\n case exports.Patterns.PATTERN001: return i % 2 === 0\n case exports.Patterns.PATTERN010: return j % 3 === 0\n case exports.Patterns.PATTERN011: return (i + j) % 3 === 0\n case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0\n case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0\n case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0\n case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0\n\n default: throw new Error('bad maskPattern:' + maskPattern)\n }\n}\n\n/**\n * Apply a mask pattern to a BitMatrix\n *\n * @param {Number} pattern Pattern reference number\n * @param {BitMatrix} data BitMatrix data\n */\nexports.applyMask = function applyMask (pattern, data) {\n const size = data.size\n\n for (let col = 0; col < size; col++) {\n for (let row = 0; row < size; row++) {\n if (data.isReserved(row, col)) continue\n data.xor(row, col, getMaskAt(pattern, row, col))\n }\n }\n}\n\n/**\n * Returns the best mask pattern for data\n *\n * @param {BitMatrix} data\n * @return {Number} Mask pattern reference number\n */\nexports.getBestMask = function getBestMask (data, setupFormatFunc) {\n const numPatterns = Object.keys(exports.Patterns).length\n let bestPattern = 0\n let lowerPenalty = Infinity\n\n for (let p = 0; p < numPatterns; p++) {\n setupFormatFunc(p)\n exports.applyMask(p, data)\n\n // Calculate penalty\n const penalty =\n exports.getPenaltyN1(data) +\n exports.getPenaltyN2(data) +\n exports.getPenaltyN3(data) +\n exports.getPenaltyN4(data)\n\n // Undo previously applied mask\n exports.applyMask(p, data)\n\n if (penalty < lowerPenalty) {\n lowerPenalty = penalty\n bestPattern = p\n }\n }\n\n return bestPattern\n}\n","const ECLevel = require('./error-correction-level')\r\n\r\nconst EC_BLOCKS_TABLE = [\r\n// L M Q H\r\n 1, 1, 1, 1,\r\n 1, 1, 1, 1,\r\n 1, 1, 2, 2,\r\n 1, 2, 2, 4,\r\n 1, 2, 4, 4,\r\n 2, 4, 4, 4,\r\n 2, 4, 6, 5,\r\n 2, 4, 6, 6,\r\n 2, 5, 8, 8,\r\n 4, 5, 8, 8,\r\n 4, 5, 8, 11,\r\n 4, 8, 10, 11,\r\n 4, 9, 12, 16,\r\n 4, 9, 16, 16,\r\n 6, 10, 12, 18,\r\n 6, 10, 17, 16,\r\n 6, 11, 16, 19,\r\n 6, 13, 18, 21,\r\n 7, 14, 21, 25,\r\n 8, 16, 20, 25,\r\n 8, 17, 23, 25,\r\n 9, 17, 23, 34,\r\n 9, 18, 25, 30,\r\n 10, 20, 27, 32,\r\n 12, 21, 29, 35,\r\n 12, 23, 34, 37,\r\n 12, 25, 34, 40,\r\n 13, 26, 35, 42,\r\n 14, 28, 38, 45,\r\n 15, 29, 40, 48,\r\n 16, 31, 43, 51,\r\n 17, 33, 45, 54,\r\n 18, 35, 48, 57,\r\n 19, 37, 51, 60,\r\n 19, 38, 53, 63,\r\n 20, 40, 56, 66,\r\n 21, 43, 59, 70,\r\n 22, 45, 62, 74,\r\n 24, 47, 65, 77,\r\n 25, 49, 68, 81\r\n]\r\n\r\nconst EC_CODEWORDS_TABLE = [\r\n// L M Q H\r\n 7, 10, 13, 17,\r\n 10, 16, 22, 28,\r\n 15, 26, 36, 44,\r\n 20, 36, 52, 64,\r\n 26, 48, 72, 88,\r\n 36, 64, 96, 112,\r\n 40, 72, 108, 130,\r\n 48, 88, 132, 156,\r\n 60, 110, 160, 192,\r\n 72, 130, 192, 224,\r\n 80, 150, 224, 264,\r\n 96, 176, 260, 308,\r\n 104, 198, 288, 352,\r\n 120, 216, 320, 384,\r\n 132, 240, 360, 432,\r\n 144, 280, 408, 480,\r\n 168, 308, 448, 532,\r\n 180, 338, 504, 588,\r\n 196, 364, 546, 650,\r\n 224, 416, 600, 700,\r\n 224, 442, 644, 750,\r\n 252, 476, 690, 816,\r\n 270, 504, 750, 900,\r\n 300, 560, 810, 960,\r\n 312, 588, 870, 1050,\r\n 336, 644, 952, 1110,\r\n 360, 700, 1020, 1200,\r\n 390, 728, 1050, 1260,\r\n 420, 784, 1140, 1350,\r\n 450, 812, 1200, 1440,\r\n 480, 868, 1290, 1530,\r\n 510, 924, 1350, 1620,\r\n 540, 980, 1440, 1710,\r\n 570, 1036, 1530, 1800,\r\n 570, 1064, 1590, 1890,\r\n 600, 1120, 1680, 1980,\r\n 630, 1204, 1770, 2100,\r\n 660, 1260, 1860, 2220,\r\n 720, 1316, 1950, 2310,\r\n 750, 1372, 2040, 2430\r\n]\r\n\r\n/**\r\n * Returns the number of error correction block that the QR Code should contain\r\n * for the specified version and error correction level.\r\n *\r\n * @param {Number} version QR Code version\r\n * @param {Number} errorCorrectionLevel Error correction level\r\n * @return {Number} Number of error correction blocks\r\n */\r\nexports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {\r\n switch (errorCorrectionLevel) {\r\n case ECLevel.L:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]\r\n case ECLevel.M:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]\r\n case ECLevel.Q:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]\r\n case ECLevel.H:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]\r\n default:\r\n return undefined\r\n }\r\n}\r\n\r\n/**\r\n * Returns the number of error correction codewords to use for the specified\r\n * version and error correction level.\r\n *\r\n * @param {Number} version QR Code version\r\n * @param {Number} errorCorrectionLevel Error correction level\r\n * @return {Number} Number of error correction codewords\r\n */\r\nexports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {\r\n switch (errorCorrectionLevel) {\r\n case ECLevel.L:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]\r\n case ECLevel.M:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]\r\n case ECLevel.Q:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]\r\n case ECLevel.H:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]\r\n default:\r\n return undefined\r\n }\r\n}\r\n","const EXP_TABLE = new Uint8Array(512)\nconst LOG_TABLE = new Uint8Array(256)\n/**\n * Precompute the log and anti-log tables for faster computation later\n *\n * For each possible value in the galois field 2^8, we will pre-compute\n * the logarithm and anti-logarithm (exponential) of this value\n *\n * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}\n */\n;(function initTables () {\n let x = 1\n for (let i = 0; i < 255; i++) {\n EXP_TABLE[i] = x\n LOG_TABLE[x] = i\n\n x <<= 1 // multiply by 2\n\n // The QR code specification says to use byte-wise modulo 100011101 arithmetic.\n // This means that when a number is 256 or larger, it should be XORed with 0x11D.\n if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)\n x ^= 0x11D\n }\n }\n\n // Optimization: double the size of the anti-log table so that we don't need to mod 255 to\n // stay inside the bounds (because we will mainly use this table for the multiplication of\n // two GF numbers, no more).\n // @see {@link mul}\n for (let i = 255; i < 512; i++) {\n EXP_TABLE[i] = EXP_TABLE[i - 255]\n }\n}())\n\n/**\n * Returns log value of n inside Galois Field\n *\n * @param {Number} n\n * @return {Number}\n */\nexports.log = function log (n) {\n if (n < 1) throw new Error('log(' + n + ')')\n return LOG_TABLE[n]\n}\n\n/**\n * Returns anti-log value of n inside Galois Field\n *\n * @param {Number} n\n * @return {Number}\n */\nexports.exp = function exp (n) {\n return EXP_TABLE[n]\n}\n\n/**\n * Multiplies two number inside Galois Field\n *\n * @param {Number} x\n * @param {Number} y\n * @return {Number}\n */\nexports.mul = function mul (x, y) {\n if (x === 0 || y === 0) return 0\n\n // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized\n // @see {@link initTables}\n return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]\n}\n","const GF = require('./galois-field')\n\n/**\n * Multiplies two polynomials inside Galois Field\n *\n * @param {Uint8Array} p1 Polynomial\n * @param {Uint8Array} p2 Polynomial\n * @return {Uint8Array} Product of p1 and p2\n */\nexports.mul = function mul (p1, p2) {\n const coeff = new Uint8Array(p1.length + p2.length - 1)\n\n for (let i = 0; i < p1.length; i++) {\n for (let j = 0; j < p2.length; j++) {\n coeff[i + j] ^= GF.mul(p1[i], p2[j])\n }\n }\n\n return coeff\n}\n\n/**\n * Calculate the remainder of polynomials division\n *\n * @param {Uint8Array} divident Polynomial\n * @param {Uint8Array} divisor Polynomial\n * @return {Uint8Array} Remainder\n */\nexports.mod = function mod (divident, divisor) {\n let result = new Uint8Array(divident)\n\n while ((result.length - divisor.length) >= 0) {\n const coeff = result[0]\n\n for (let i = 0; i < divisor.length; i++) {\n result[i] ^= GF.mul(divisor[i], coeff)\n }\n\n // remove all zeros from buffer head\n let offset = 0\n while (offset < result.length && result[offset] === 0) offset++\n result = result.slice(offset)\n }\n\n return result\n}\n\n/**\n * Generate an irreducible generator polynomial of specified degree\n * (used by Reed-Solomon encoder)\n *\n * @param {Number} degree Degree of the generator polynomial\n * @return {Uint8Array} Buffer containing polynomial coefficients\n */\nexports.generateECPolynomial = function generateECPolynomial (degree) {\n let poly = new Uint8Array([1])\n for (let i = 0; i < degree; i++) {\n poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]))\n }\n\n return poly\n}\n","const Polynomial = require('./polynomial')\n\nfunction ReedSolomonEncoder (degree) {\n this.genPoly = undefined\n this.degree = degree\n\n if (this.degree) this.initialize(this.degree)\n}\n\n/**\n * Initialize the encoder.\n * The input param should correspond to the number of error correction codewords.\n *\n * @param {Number} degree\n */\nReedSolomonEncoder.prototype.initialize = function initialize (degree) {\n // create an irreducible generator polynomial\n this.degree = degree\n this.genPoly = Polynomial.generateECPolynomial(this.degree)\n}\n\n/**\n * Encodes a chunk of data\n *\n * @param {Uint8Array} data Buffer containing input data\n * @return {Uint8Array} Buffer containing encoded data\n */\nReedSolomonEncoder.prototype.encode = function encode (data) {\n if (!this.genPoly) {\n throw new Error('Encoder not initialized')\n }\n\n // Calculate EC for this data block\n // extends data size to data+genPoly size\n const paddedData = new Uint8Array(data.length + this.degree)\n paddedData.set(data)\n\n // The error correction codewords are the remainder after dividing the data codewords\n // by a generator polynomial\n const remainder = Polynomial.mod(paddedData, this.genPoly)\n\n // return EC data blocks (last n byte, where n is the degree of genPoly)\n // If coefficients number in remainder are less than genPoly degree,\n // pad with 0s to the left to reach the needed number of coefficients\n const start = this.degree - remainder.length\n if (start > 0) {\n const buff = new Uint8Array(this.degree)\n buff.set(remainder, start)\n\n return buff\n }\n\n return remainder\n}\n\nmodule.exports = ReedSolomonEncoder\n","/**\n * Check if QR Code version is valid\n *\n * @param {Number} version QR Code version\n * @return {Boolean} true if valid version, false otherwise\n */\nexports.isValid = function isValid (version) {\n return !isNaN(version) && version >= 1 && version <= 40\n}\n","const numeric = '[0-9]+'\nconst alphanumeric = '[A-Z $%*+\\\\-./:]+'\nlet kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +\n '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +\n '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +\n '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+'\nkanji = kanji.replace(/u/g, '\\\\u')\n\nconst byte = '(?:(?![A-Z0-9 $%*+\\\\-./:]|' + kanji + ')(?:.|[\\r\\n]))+'\n\nexports.KANJI = new RegExp(kanji, 'g')\nexports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\\\-./:]+', 'g')\nexports.BYTE = new RegExp(byte, 'g')\nexports.NUMERIC = new RegExp(numeric, 'g')\nexports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')\n\nconst TEST_KANJI = new RegExp('^' + kanji + '$')\nconst TEST_NUMERIC = new RegExp('^' + numeric + '$')\nconst TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\\\-./:]+$')\n\nexports.testKanji = function testKanji (str) {\n return TEST_KANJI.test(str)\n}\n\nexports.testNumeric = function testNumeric (str) {\n return TEST_NUMERIC.test(str)\n}\n\nexports.testAlphanumeric = function testAlphanumeric (str) {\n return TEST_ALPHANUMERIC.test(str)\n}\n","const VersionCheck = require('./version-check')\nconst Regex = require('./regex')\n\n/**\n * Numeric mode encodes data from the decimal digit set (0 - 9)\n * (byte values 30HEX to 39HEX).\n * Normally, 3 data characters are represented by 10 bits.\n *\n * @type {Object}\n */\nexports.NUMERIC = {\n id: 'Numeric',\n bit: 1 << 0,\n ccBits: [10, 12, 14]\n}\n\n/**\n * Alphanumeric mode encodes data from a set of 45 characters,\n * i.e. 10 numeric digits (0 - 9),\n * 26 alphabetic characters (A - Z),\n * and 9 symbols (SP, $, %, *, +, -, ., /, :).\n * Normally, two input characters are represented by 11 bits.\n *\n * @type {Object}\n */\nexports.ALPHANUMERIC = {\n id: 'Alphanumeric',\n bit: 1 << 1,\n ccBits: [9, 11, 13]\n}\n\n/**\n * In byte mode, data is encoded at 8 bits per character.\n *\n * @type {Object}\n */\nexports.BYTE = {\n id: 'Byte',\n bit: 1 << 2,\n ccBits: [8, 16, 16]\n}\n\n/**\n * The Kanji mode efficiently encodes Kanji characters in accordance with\n * the Shift JIS system based on JIS X 0208.\n * The Shift JIS values are shifted from the JIS X 0208 values.\n * JIS X 0208 gives details of the shift coded representation.\n * Each two-byte character value is compacted to a 13-bit binary codeword.\n *\n * @type {Object}\n */\nexports.KANJI = {\n id: 'Kanji',\n bit: 1 << 3,\n ccBits: [8, 10, 12]\n}\n\n/**\n * Mixed mode will contain a sequences of data in a combination of any of\n * the modes described above\n *\n * @type {Object}\n */\nexports.MIXED = {\n bit: -1\n}\n\n/**\n * Returns the number of bits needed to store the data length\n * according to QR Code specifications.\n *\n * @param {Mode} mode Data mode\n * @param {Number} version QR Code version\n * @return {Number} Number of bits\n */\nexports.getCharCountIndicator = function getCharCountIndicator (mode, version) {\n if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)\n\n if (!VersionCheck.isValid(version)) {\n throw new Error('Invalid version: ' + version)\n }\n\n if (version >= 1 && version < 10) return mode.ccBits[0]\n else if (version < 27) return mode.ccBits[1]\n return mode.ccBits[2]\n}\n\n/**\n * Returns the most efficient mode to store the specified data\n *\n * @param {String} dataStr Input data string\n * @return {Mode} Best mode\n */\nexports.getBestModeForData = function getBestModeForData (dataStr) {\n if (Regex.testNumeric(dataStr)) return exports.NUMERIC\n else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC\n else if (Regex.testKanji(dataStr)) return exports.KANJI\n else return exports.BYTE\n}\n\n/**\n * Return mode name as string\n *\n * @param {Mode} mode Mode object\n * @returns {String} Mode name\n */\nexports.toString = function toString (mode) {\n if (mode && mode.id) return mode.id\n throw new Error('Invalid mode')\n}\n\n/**\n * Check if input param is a valid mode object\n *\n * @param {Mode} mode Mode object\n * @returns {Boolean} True if valid mode, false otherwise\n */\nexports.isValid = function isValid (mode) {\n return mode && mode.bit && mode.ccBits\n}\n\n/**\n * Get mode object from its name\n *\n * @param {String} string Mode name\n * @returns {Mode} Mode object\n */\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'numeric':\n return exports.NUMERIC\n case 'alphanumeric':\n return exports.ALPHANUMERIC\n case 'kanji':\n return exports.KANJI\n case 'byte':\n return exports.BYTE\n default:\n throw new Error('Unknown mode: ' + string)\n }\n}\n\n/**\n * Returns mode from a value.\n * If value is not a valid mode, returns defaultValue\n *\n * @param {Mode|String} value Encoding mode\n * @param {Mode} defaultValue Fallback value\n * @return {Mode} Encoding mode\n */\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n","const Utils = require('./utils')\nconst ECCode = require('./error-correction-code')\nconst ECLevel = require('./error-correction-level')\nconst Mode = require('./mode')\nconst VersionCheck = require('./version-check')\n\n// Generator polynomial used to encode version information\nconst G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)\nconst G18_BCH = Utils.getBCHDigit(G18)\n\nfunction getBestVersionForDataLength (mode, length, errorCorrectionLevel) {\n for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {\n if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {\n return currentVersion\n }\n }\n\n return undefined\n}\n\nfunction getReservedBitsCount (mode, version) {\n // Character count indicator + mode indicator bits\n return Mode.getCharCountIndicator(mode, version) + 4\n}\n\nfunction getTotalBitsFromDataArray (segments, version) {\n let totalBits = 0\n\n segments.forEach(function (data) {\n const reservedBits = getReservedBitsCount(data.mode, version)\n totalBits += reservedBits + data.getBitsLength()\n })\n\n return totalBits\n}\n\nfunction getBestVersionForMixedData (segments, errorCorrectionLevel) {\n for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {\n const length = getTotalBitsFromDataArray(segments, currentVersion)\n if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {\n return currentVersion\n }\n }\n\n return undefined\n}\n\n/**\n * Returns version number from a value.\n * If value is not a valid version, returns defaultValue\n *\n * @param {Number|String} value QR Code version\n * @param {Number} defaultValue Fallback value\n * @return {Number} QR Code version number\n */\nexports.from = function from (value, defaultValue) {\n if (VersionCheck.isValid(value)) {\n return parseInt(value, 10)\n }\n\n return defaultValue\n}\n\n/**\n * Returns how much data can be stored with the specified QR code version\n * and error correction level\n *\n * @param {Number} version QR Code version (1-40)\n * @param {Number} errorCorrectionLevel Error correction level\n * @param {Mode} mode Data mode\n * @return {Number} Quantity of storable data\n */\nexports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {\n if (!VersionCheck.isValid(version)) {\n throw new Error('Invalid QR Code version')\n }\n\n // Use Byte mode as default\n if (typeof mode === 'undefined') mode = Mode.BYTE\n\n // Total codewords for this QR code version (Data + Error correction)\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n\n // Total number of error correction codewords\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n\n // Total number of data codewords\n const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8\n\n if (mode === Mode.MIXED) return dataTotalCodewordsBits\n\n const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)\n\n // Return max number of storable codewords\n switch (mode) {\n case Mode.NUMERIC:\n return Math.floor((usableBits / 10) * 3)\n\n case Mode.ALPHANUMERIC:\n return Math.floor((usableBits / 11) * 2)\n\n case Mode.KANJI:\n return Math.floor(usableBits / 13)\n\n case Mode.BYTE:\n default:\n return Math.floor(usableBits / 8)\n }\n}\n\n/**\n * Returns the minimum version needed to contain the amount of data\n *\n * @param {Segment} data Segment of data\n * @param {Number} [errorCorrectionLevel=H] Error correction level\n * @param {Mode} mode Data mode\n * @return {Number} QR Code version\n */\nexports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {\n let seg\n\n const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)\n\n if (Array.isArray(data)) {\n if (data.length > 1) {\n return getBestVersionForMixedData(data, ecl)\n }\n\n if (data.length === 0) {\n return 1\n }\n\n seg = data[0]\n } else {\n seg = data\n }\n\n return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)\n}\n\n/**\n * Returns version information with relative error correction bits\n *\n * The version information is included in QR Code symbols of version 7 or larger.\n * It consists of an 18-bit sequence containing 6 data bits,\n * with 12 error correction bits calculated using the (18, 6) Golay code.\n *\n * @param {Number} version QR Code version\n * @return {Number} Encoded version info bits\n */\nexports.getEncodedBits = function getEncodedBits (version) {\n if (!VersionCheck.isValid(version) || version < 7) {\n throw new Error('Invalid QR Code version')\n }\n\n let d = version << 12\n\n while (Utils.getBCHDigit(d) - G18_BCH >= 0) {\n d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))\n }\n\n return (version << 12) | d\n}\n","const Utils = require('./utils')\n\nconst G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)\nconst G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)\nconst G15_BCH = Utils.getBCHDigit(G15)\n\n/**\n * Returns format information with relative error correction bits\n *\n * The format information is a 15-bit sequence containing 5 data bits,\n * with 10 error correction bits calculated using the (15, 5) BCH code.\n *\n * @param {Number} errorCorrectionLevel Error correction level\n * @param {Number} mask Mask pattern\n * @return {Number} Encoded format information bits\n */\nexports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {\n const data = ((errorCorrectionLevel.bit << 3) | mask)\n let d = data << 10\n\n while (Utils.getBCHDigit(d) - G15_BCH >= 0) {\n d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))\n }\n\n // xor final data with mask pattern in order to ensure that\n // no combination of Error Correction Level and data mask pattern\n // will result in an all-zero data string\n return ((data << 10) | d) ^ G15_MASK\n}\n","const Mode = require('./mode')\n\nfunction NumericData (data) {\n this.mode = Mode.NUMERIC\n this.data = data.toString()\n}\n\nNumericData.getBitsLength = function getBitsLength (length) {\n return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)\n}\n\nNumericData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nNumericData.prototype.getBitsLength = function getBitsLength () {\n return NumericData.getBitsLength(this.data.length)\n}\n\nNumericData.prototype.write = function write (bitBuffer) {\n let i, group, value\n\n // The input data string is divided into groups of three digits,\n // and each group is converted to its 10-bit binary equivalent.\n for (i = 0; i + 3 <= this.data.length; i += 3) {\n group = this.data.substr(i, 3)\n value = parseInt(group, 10)\n\n bitBuffer.put(value, 10)\n }\n\n // If the number of input digits is not an exact multiple of three,\n // the final one or two digits are converted to 4 or 7 bits respectively.\n const remainingNum = this.data.length - i\n if (remainingNum > 0) {\n group = this.data.substr(i)\n value = parseInt(group, 10)\n\n bitBuffer.put(value, remainingNum * 3 + 1)\n }\n}\n\nmodule.exports = NumericData\n","const Mode = require('./mode')\n\n/**\n * Array of characters available in alphanumeric mode\n *\n * As per QR Code specification, to each character\n * is assigned a value from 0 to 44 which in this case coincides\n * with the array index\n *\n * @type {Array}\n */\nconst ALPHA_NUM_CHARS = [\n '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',\n 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\n ' ', '$', '%', '*', '+', '-', '.', '/', ':'\n]\n\nfunction AlphanumericData (data) {\n this.mode = Mode.ALPHANUMERIC\n this.data = data\n}\n\nAlphanumericData.getBitsLength = function getBitsLength (length) {\n return 11 * Math.floor(length / 2) + 6 * (length % 2)\n}\n\nAlphanumericData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nAlphanumericData.prototype.getBitsLength = function getBitsLength () {\n return AlphanumericData.getBitsLength(this.data.length)\n}\n\nAlphanumericData.prototype.write = function write (bitBuffer) {\n let i\n\n // Input data characters are divided into groups of two characters\n // and encoded as 11-bit binary codes.\n for (i = 0; i + 2 <= this.data.length; i += 2) {\n // The character value of the first character is multiplied by 45\n let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45\n\n // The character value of the second digit is added to the product\n value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])\n\n // The sum is then stored as 11-bit binary number\n bitBuffer.put(value, 11)\n }\n\n // If the number of input data characters is not a multiple of two,\n // the character value of the final character is encoded as a 6-bit binary number.\n if (this.data.length % 2) {\n bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)\n }\n}\n\nmodule.exports = AlphanumericData\n","const Mode = require('./mode')\n\nfunction ByteData (data) {\n this.mode = Mode.BYTE\n if (typeof (data) === 'string') {\n this.data = new TextEncoder().encode(data)\n } else {\n this.data = new Uint8Array(data)\n }\n}\n\nByteData.getBitsLength = function getBitsLength (length) {\n return length * 8\n}\n\nByteData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nByteData.prototype.getBitsLength = function getBitsLength () {\n return ByteData.getBitsLength(this.data.length)\n}\n\nByteData.prototype.write = function (bitBuffer) {\n for (let i = 0, l = this.data.length; i < l; i++) {\n bitBuffer.put(this.data[i], 8)\n }\n}\n\nmodule.exports = ByteData\n","const Mode = require('./mode')\nconst Utils = require('./utils')\n\nfunction KanjiData (data) {\n this.mode = Mode.KANJI\n this.data = data\n}\n\nKanjiData.getBitsLength = function getBitsLength (length) {\n return length * 13\n}\n\nKanjiData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nKanjiData.prototype.getBitsLength = function getBitsLength () {\n return KanjiData.getBitsLength(this.data.length)\n}\n\nKanjiData.prototype.write = function (bitBuffer) {\n let i\n\n // In the Shift JIS system, Kanji characters are represented by a two byte combination.\n // These byte values are shifted from the JIS X 0208 values.\n // JIS X 0208 gives details of the shift coded representation.\n for (i = 0; i < this.data.length; i++) {\n let value = Utils.toSJIS(this.data[i])\n\n // For characters with Shift JIS values from 0x8140 to 0x9FFC:\n if (value >= 0x8140 && value <= 0x9FFC) {\n // Subtract 0x8140 from Shift JIS value\n value -= 0x8140\n\n // For characters with Shift JIS values from 0xE040 to 0xEBBF\n } else if (value >= 0xE040 && value <= 0xEBBF) {\n // Subtract 0xC140 from Shift JIS value\n value -= 0xC140\n } else {\n throw new Error(\n 'Invalid SJIS character: ' + this.data[i] + '\\n' +\n 'Make sure your charset is UTF-8')\n }\n\n // Multiply most significant byte of result by 0xC0\n // and add least significant byte to product\n value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)\n\n // Convert result to a 13-bit binary string\n bitBuffer.put(value, 13)\n }\n}\n\nmodule.exports = KanjiData\n","'use strict';\n\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin <self@wyattbaldwin.com>\n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nvar dijkstra = {\n single_source_shortest_paths: function(graph, s, d) {\n // Predecessor map for each node that has been encountered.\n // node ID => predecessor node ID\n var predecessors = {};\n\n // Costs of shortest paths from s to all nodes encountered.\n // node ID => cost\n var costs = {};\n costs[s] = 0;\n\n // Costs of shortest paths from s to all nodes encountered; differs from\n // `costs` in that it provides easy access to the node that currently has\n // the known shortest path from s.\n // XXX: Do we actually need both `costs` and `open`?\n var open = dijkstra.PriorityQueue.make();\n open.push(s, 0);\n\n var closest,\n u, v,\n cost_of_s_to_u,\n adjacent_nodes,\n cost_of_e,\n cost_of_s_to_u_plus_cost_of_e,\n cost_of_s_to_v,\n first_visit;\n while (!open.empty()) {\n // In the nodes remaining in graph that have a known cost from s,\n // find the node, u, that currently has the shortest path from s.\n closest = open.pop();\n u = closest.value;\n cost_of_s_to_u = closest.cost;\n\n // Get nodes adjacent to u...\n adjacent_nodes = graph[u] || {};\n\n // ...and explore the edges that connect u to those nodes, updating\n // the cost of the shortest paths to any or all of those nodes as\n // necessary. v is the node across the current edge from u.\n for (v in adjacent_nodes) {\n if (adjacent_nodes.hasOwnProperty(v)) {\n // Get the cost of the edge running from u to v.\n cost_of_e = adjacent_nodes[v];\n\n // Cost of s to u plus the cost of u to v across e--this is *a*\n // cost from s to v that may or may not be less than the current\n // known cost to v.\n cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n // If we haven't visited v yet OR if the current known cost from s to\n // v is greater than the new cost we just found (cost of s to u plus\n // cost of u to v across e), update v's cost in the cost list and\n // update v's predecessor in the predecessor list (it's now u).\n cost_of_s_to_v = costs[v];\n first_visit = (typeof costs[v] === 'undefined');\n if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n costs[v] = cost_of_s_to_u_plus_cost_of_e;\n open.push(v, cost_of_s_to_u_plus_cost_of_e);\n predecessors[v] = u;\n }\n }\n }\n }\n\n if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {\n var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');\n throw new Error(msg);\n }\n\n return predecessors;\n },\n\n extract_shortest_path_from_predecessor_list: function(predecessors, d) {\n var nodes = [];\n var u = d;\n var predecessor;\n while (u) {\n nodes.push(u);\n predecessor = predecessors[u];\n u = predecessors[u];\n }\n nodes.reverse();\n return nodes;\n },\n\n find_path: function(graph, s, d) {\n var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);\n return dijkstra.extract_shortest_path_from_predecessor_list(\n predecessors, d);\n },\n\n /**\n * A very naive priority queue implementation.\n */\n PriorityQueue: {\n make: function (opts) {\n var T = dijkstra.PriorityQueue,\n t = {},\n key;\n opts = opts || {};\n for (key in T) {\n if (T.hasOwnProperty(key)) {\n t[key] = T[key];\n }\n }\n t.queue = [];\n t.sorter = opts.sorter || T.default_sorter;\n return t;\n },\n\n default_sorter: function (a, b) {\n return a.cost - b.cost;\n },\n\n /**\n * Add a new item to the queue and ensure the highest priority element\n * is at the front of the queue.\n */\n push: function (value, cost) {\n var item = {value: value, cost: cost};\n this.queue.push(item);\n this.queue.sort(this.sorter);\n },\n\n /**\n * Return the highest priority element in the queue.\n */\n pop: function () {\n return this.queue.shift();\n },\n\n empty: function () {\n return this.queue.length === 0;\n }\n }\n};\n\n\n// node.js module exports\nif (typeof module !== 'undefined') {\n module.exports = dijkstra;\n}\n","const Mode = require('./mode')\nconst NumericData = require('./numeric-data')\nconst AlphanumericData = require('./alphanumeric-data')\nconst ByteData = require('./byte-data')\nconst KanjiData = require('./kanji-data')\nconst Regex = require('./regex')\nconst Utils = require('./utils')\nconst dijkstra = require('dijkstrajs')\n\n/**\n * Returns UTF8 byte length\n *\n * @param {String} str Input string\n * @return {Number} Number of byte\n */\nfunction getStringByteLength (str) {\n return unescape(encodeURIComponent(str)).length\n}\n\n/**\n * Get a list of segments of the specified mode\n * from a string\n *\n * @param {Mode} mode Segment mode\n * @param {String} str String to process\n * @return {Array} Array of object with segments data\n */\nfunction getSegments (regex, mode, str) {\n const segments = []\n let result\n\n while ((result = regex.exec(str)) !== null) {\n segments.push({\n data: result[0],\n index: result.index,\n mode: mode,\n length: result[0].length\n })\n }\n\n return segments\n}\n\n/**\n * Extracts a series of segments with the appropriate\n * modes from a string\n *\n * @param {String} dataStr Input string\n * @return {Array} Array of object with segments data\n */\nfunction getSegmentsFromString (dataStr) {\n const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)\n const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)\n let byteSegs\n let kanjiSegs\n\n if (Utils.isKanjiModeEnabled()) {\n byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)\n kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)\n } else {\n byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)\n kanjiSegs = []\n }\n\n const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)\n\n return segs\n .sort(function (s1, s2) {\n return s1.index - s2.index\n })\n .map(function (obj) {\n return {\n data: obj.data,\n mode: obj.mode,\n length: obj.length\n }\n })\n}\n\n/**\n * Returns how many bits are needed to encode a string of\n * specified length with the specified mode\n *\n * @param {Number} length String length\n * @param {Mode} mode Segment mode\n * @return {Number} Bit length\n */\nfunction getSegmentBitsLength (length, mode) {\n switch (mode) {\n case Mode.NUMERIC:\n return NumericData.getBitsLength(length)\n case Mode.ALPHANUMERIC:\n return AlphanumericData.getBitsLength(length)\n case Mode.KANJI:\n return KanjiData.getBitsLength(length)\n case Mode.BYTE:\n return ByteData.getBitsLength(length)\n }\n}\n\n/**\n * Merges adjacent segments which have the same mode\n *\n * @param {Array} segs Array of object with segments data\n * @return {Array} Array of object with segments data\n */\nfunction mergeSegments (segs) {\n return segs.reduce(function (acc, curr) {\n const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null\n if (prevSeg && prevSeg.mode === curr.mode) {\n acc[acc.length - 1].data += curr.data\n return acc\n }\n\n acc.push(curr)\n return acc\n }, [])\n}\n\n/**\n * Generates a list of all possible nodes combination which\n * will be used to build a segments graph.\n *\n * Nodes are divided by groups. Each group will contain a list of all the modes\n * in which is possible to encode the given text.\n *\n * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.\n * The group for '12345' will contain then 3 objects, one for each\n * possible encoding mode.\n *\n * Each node represents a possible segment.\n *\n * @param {Array} segs Array of object with segments data\n * @return {Array} Array of object with segments data\n */\nfunction buildNodes (segs) {\n const nodes = []\n for (let i = 0; i < segs.length; i++) {\n const seg = segs[i]\n\n switch (seg.mode) {\n case Mode.NUMERIC:\n nodes.push([seg,\n { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },\n { data: seg.data, mode: Mode.BYTE, length: seg.length }\n ])\n break\n case Mode.ALPHANUMERIC:\n nodes.push([seg,\n { data: seg.data, mode: Mode.BYTE, length: seg.length }\n ])\n break\n case Mode.KANJI:\n nodes.push([seg,\n { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }\n ])\n break\n case Mode.BYTE:\n nodes.push([\n { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }\n ])\n }\n }\n\n return nodes\n}\n\n/**\n * Builds a graph from a list of nodes.\n * All segments in each node group will be connected with all the segments of\n * the next group and so on.\n *\n * At each connection will be assigned a weight depending on the\n * segment's byte length.\n *\n * @param {Array} nodes Array of object with segments data\n * @param {Number} version QR Code version\n * @return {Object} Graph of all possible segments\n */\nfunction buildGraph (nodes, version) {\n const table = {}\n const graph = { start: {} }\n let prevNodeIds = ['start']\n\n for (let i = 0; i < nodes.length; i++) {\n const nodeGroup = nodes[i]\n const currentNodeIds = []\n\n for (let j = 0; j < nodeGroup.length; j++) {\n const node = nodeGroup[j]\n const key = '' + i + j\n\n currentNodeIds.push(key)\n table[key] = { node: node, lastCount: 0 }\n graph[key] = {}\n\n for (let n = 0; n < prevNodeIds.length; n++) {\n const prevNodeId = prevNodeIds[n]\n\n if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {\n graph[prevNodeId][key] =\n getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -\n getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)\n\n table[prevNodeId].lastCount += node.length\n } else {\n if (table[prevNodeId]) table[prevNodeId].lastCount = node.length\n\n graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +\n 4 + Mode.getCharCountIndicator(node.mode, version) // switch cost\n }\n }\n }\n\n prevNodeIds = currentNodeIds\n }\n\n for (let n = 0; n < prevNodeIds.length; n++) {\n graph[prevNodeIds[n]].end = 0\n }\n\n return { map: graph, table: table }\n}\n\n/**\n * Builds a segment from a specified data and mode.\n * If a mode is not specified, the more suitable will be used.\n *\n * @param {String} data Input data\n * @param {Mode | String} modesHint Data mode\n * @return {Segment} Segment\n */\nfunction buildSingleSegment (data, modesHint) {\n let mode\n const bestMode = Mode.getBestModeForData(data)\n\n mode = Mode.from(modesHint, bestMode)\n\n // Make sure data can be encoded\n if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {\n throw new Error('\"' + data + '\"' +\n ' cannot be encoded with mode ' + Mode.toString(mode) +\n '.\\n Suggested mode is: ' + Mode.toString(bestMode))\n }\n\n // Use Mode.BYTE if Kanji support is disabled\n if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {\n mode = Mode.BYTE\n }\n\n switch (mode) {\n case Mode.NUMERIC:\n return new NumericData(data)\n\n case Mode.ALPHANUMERIC:\n return new AlphanumericData(data)\n\n case Mode.KANJI:\n return new KanjiData(data)\n\n case Mode.BYTE:\n return new ByteData(data)\n }\n}\n\n/**\n * Builds a list of segments from an array.\n * Array can contain Strings or Objects with segment's info.\n *\n * For each item which is a string, will be generated a segment with the given\n * string and the more appropriate encoding mode.\n *\n * For each item which is an object, will be generated a segment with the given\n * data and mode.\n * Objects must contain at least the property \"data\".\n * If property \"mode\" is not present, the more suitable mode will be used.\n *\n * @param {Array} array Array of objects with segments data\n * @return {Array} Array of Segments\n */\nexports.fromArray = function fromArray (array) {\n return array.reduce(function (acc, seg) {\n if (typeof seg === 'string') {\n acc.push(buildSingleSegment(seg, null))\n } else if (seg.data) {\n acc.push(buildSingleSegment(seg.data, seg.mode))\n }\n\n return acc\n }, [])\n}\n\n/**\n * Builds an optimized sequence of segments from a string,\n * which will produce the shortest possible bitstream.\n *\n * @param {String} data Input string\n * @param {Number} version QR Code version\n * @return {Array} Array of segments\n */\nexports.fromString = function fromString (data, version) {\n const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())\n\n const nodes = buildNodes(segs)\n const graph = buildGraph(nodes, version)\n const path = dijkstra.find_path(graph.map, 'start', 'end')\n\n const optimizedSegs = []\n for (let i = 1; i < path.length - 1; i++) {\n optimizedSegs.push(graph.table[path[i]].node)\n }\n\n return exports.fromArray(mergeSegments(optimizedSegs))\n}\n\n/**\n * Splits a string in various segments with the modes which\n * best represent their content.\n * The produced segments are far from being optimized.\n * The output of this function is only used to estimate a QR Code version\n * which may contain the data.\n *\n * @param {string} data Input string\n * @return {Array} Array of segments\n */\nexports.rawSplit = function rawSplit (data) {\n return exports.fromArray(\n getSegmentsFromString(data, Utils.isKanjiModeEnabled())\n )\n}\n","const Utils = require('./utils')\nconst ECLevel = require('./error-correction-level')\nconst BitBuffer = require('./bit-buffer')\nconst BitMatrix = require('./bit-matrix')\nconst AlignmentPattern = require('./alignment-pattern')\nconst FinderPattern = require('./finder-pattern')\nconst MaskPattern = require('./mask-pattern')\nconst ECCode = require('./error-correction-code')\nconst ReedSolomonEncoder = require('./reed-solomon-encoder')\nconst Version = require('./version')\nconst FormatInfo = require('./format-info')\nconst Mode = require('./mode')\nconst Segments = require('./segments')\n\n/**\n * QRCode for JavaScript\n *\n * modified by Ryan Day for nodejs support\n * Copyright (c) 2011 Ryan Day\n *\n * Licensed under the MIT license:\n * http://www.opensource.org/licenses/mit-license.php\n *\n//---------------------------------------------------------------------\n// QRCode for JavaScript\n//\n// Copyright (c) 2009 Kazuhiko Arase\n//\n// URL: http://www.d-project.com/\n//\n// Licensed under the MIT license:\n// http://www.opensource.org/licenses/mit-license.php\n//\n// The word \"QR Code\" is registered trademark of\n// DENSO WAVE INCORPORATED\n// http://www.denso-wave.com/qrcode/faqpatent-e.html\n//\n//---------------------------------------------------------------------\n*/\n\n/**\n * Add finder patterns bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupFinderPattern (matrix, version) {\n const size = matrix.size\n const pos = FinderPattern.getPositions(version)\n\n for (let i = 0; i < pos.length; i++) {\n const row = pos[i][0]\n const col = pos[i][1]\n\n for (let r = -1; r <= 7; r++) {\n if (row + r <= -1 || size <= row + r) continue\n\n for (let c = -1; c <= 7; c++) {\n if (col + c <= -1 || size <= col + c) continue\n\n if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||\n (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||\n (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {\n matrix.set(row + r, col + c, true, true)\n } else {\n matrix.set(row + r, col + c, false, true)\n }\n }\n }\n }\n}\n\n/**\n * Add timing pattern bits to matrix\n *\n * Note: this function must be called before {@link setupAlignmentPattern}\n *\n * @param {BitMatrix} matrix Modules matrix\n */\nfunction setupTimingPattern (matrix) {\n const size = matrix.size\n\n for (let r = 8; r < size - 8; r++) {\n const value = r % 2 === 0\n matrix.set(r, 6, value, true)\n matrix.set(6, r, value, true)\n }\n}\n\n/**\n * Add alignment patterns bits to matrix\n *\n * Note: this function must be called after {@link setupTimingPattern}\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupAlignmentPattern (matrix, version) {\n const pos = AlignmentPattern.getPositions(version)\n\n for (let i = 0; i < pos.length; i++) {\n const row = pos[i][0]\n const col = pos[i][1]\n\n for (let r = -2; r <= 2; r++) {\n for (let c = -2; c <= 2; c++) {\n if (r === -2 || r === 2 || c === -2 || c === 2 ||\n (r === 0 && c === 0)) {\n matrix.set(row + r, col + c, true, true)\n } else {\n matrix.set(row + r, col + c, false, true)\n }\n }\n }\n }\n}\n\n/**\n * Add version info bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupVersionInfo (matrix, version) {\n const size = matrix.size\n const bits = Version.getEncodedBits(version)\n let row, col, mod\n\n for (let i = 0; i < 18; i++) {\n row = Math.floor(i / 3)\n col = i % 3 + size - 8 - 3\n mod = ((bits >> i) & 1) === 1\n\n matrix.set(row, col, mod, true)\n matrix.set(col, row, mod, true)\n }\n}\n\n/**\n * Add format info bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @param {Number} maskPattern Mask pattern reference value\n */\nfunction setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {\n const size = matrix.size\n const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)\n let i, mod\n\n for (i = 0; i < 15; i++) {\n mod = ((bits >> i) & 1) === 1\n\n // vertical\n if (i < 6) {\n matrix.set(i, 8, mod, true)\n } else if (i < 8) {\n matrix.set(i + 1, 8, mod, true)\n } else {\n matrix.set(size - 15 + i, 8, mod, true)\n }\n\n // horizontal\n if (i < 8) {\n matrix.set(8, size - i - 1, mod, true)\n } else if (i < 9) {\n matrix.set(8, 15 - i - 1 + 1, mod, true)\n } else {\n matrix.set(8, 15 - i - 1, mod, true)\n }\n }\n\n // fixed module\n matrix.set(size - 8, 8, 1, true)\n}\n\n/**\n * Add encoded data bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Uint8Array} data Data codewords\n */\nfunction setupData (matrix, data) {\n const size = matrix.size\n let inc = -1\n let row = size - 1\n let bitIndex = 7\n let byteIndex = 0\n\n for (let col = size - 1; col > 0; col -= 2) {\n if (col === 6) col--\n\n while (true) {\n for (let c = 0; c < 2; c++) {\n if (!matrix.isReserved(row, col - c)) {\n let dark = false\n\n if (byteIndex < data.length) {\n dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)\n }\n\n matrix.set(row, col - c, dark)\n bitIndex--\n\n if (bitIndex === -1) {\n byteIndex++\n bitIndex = 7\n }\n }\n }\n\n row += inc\n\n if (row < 0 || size <= row) {\n row -= inc\n inc = -inc\n break\n }\n }\n }\n}\n\n/**\n * Create encoded codewords from data input\n *\n * @param {Number} version QR Code version\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @param {ByteData} data Data input\n * @return {Uint8Array} Buffer containing encoded codewords\n */\nfunction createData (version, errorCorrectionLevel, segments) {\n // Prepare data buffer\n const buffer = new BitBuffer()\n\n segments.forEach(function (data) {\n // prefix data with mode indicator (4 bits)\n buffer.put(data.mode.bit, 4)\n\n // Prefix data with character count indicator.\n // The character count indicator is a string of bits that represents the\n // number of characters that are being encoded.\n // The character count indicator must be placed after the mode indicator\n // and must be a certain number of bits long, depending on the QR version\n // and data mode\n // @see {@link Mode.getCharCountIndicator}.\n buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))\n\n // add binary data sequence to buffer\n data.write(buffer)\n })\n\n // Calculate required number of bits\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8\n\n // Add a terminator.\n // If the bit string is shorter than the total number of required bits,\n // a terminator of up to four 0s must be added to the right side of the string.\n // If the bit string is more than four bits shorter than the required number of bits,\n // add four 0s to the end.\n if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {\n buffer.put(0, 4)\n }\n\n // If the bit string is fewer than four bits shorter, add only the number of 0s that\n // are needed to reach the required number of bits.\n\n // After adding the terminator, if the number of bits in the string is not a multiple of 8,\n // pad the string on the right with 0s to make the string's length a multiple of 8.\n while (buffer.getLengthInBits() % 8 !== 0) {\n buffer.putBit(0)\n }\n\n // Add pad bytes if the string is still shorter than the total number of required bits.\n // Extend the buffer to fill the data capacity of the symbol corresponding to\n // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)\n // and 00010001 (0x11) alternately.\n const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8\n for (let i = 0; i < remainingByte; i++) {\n buffer.put(i % 2 ? 0x11 : 0xEC, 8)\n }\n\n return createCodewords(buffer, version, errorCorrectionLevel)\n}\n\n/**\n * Encode input data with Reed-Solomon and return codewords with\n * relative error correction bits\n *\n * @param {BitBuffer} bitBuffer Data to encode\n * @param {Number} version QR Code version\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @return {Uint8Array} Buffer containing encoded codewords\n */\nfunction createCodewords (bitBuffer, version, errorCorrectionLevel) {\n // Total codewords for this QR code version (Data + Error correction)\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n\n // Total number of error correction codewords\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n\n // Total number of data codewords\n const dataTotalCodewords = totalCodewords - ecTotalCodewords\n\n // Total number of blocks\n const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)\n\n // Calculate how many blocks each group should contain\n const blocksInGroup2 = totalCodewords % ecTotalBlocks\n const blocksInGroup1 = ecTotalBlocks - blocksInGroup2\n\n const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)\n\n const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)\n const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1\n\n // Number of EC codewords is the same for both groups\n const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1\n\n // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount\n const rs = new ReedSolomonEncoder(ecCount)\n\n let offset = 0\n const dcData = new Array(ecTotalBlocks)\n const ecData = new Array(ecTotalBlocks)\n let maxDataSize = 0\n const buffer = new Uint8Array(bitBuffer.buffer)\n\n // Divide the buffer into the required number of blocks\n for (let b = 0; b < ecTotalBlocks; b++) {\n const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2\n\n // extract a block of data from buffer\n dcData[b] = buffer.slice(offset, offset + dataSize)\n\n // Calculate EC codewords for this data block\n ecData[b] = rs.encode(dcData[b])\n\n offset += dataSize\n maxDataSize = Math.max(maxDataSize, dataSize)\n }\n\n // Create final data\n // Interleave the data and error correction codewords from each block\n const data = new Uint8Array(totalCodewords)\n let index = 0\n let i, r\n\n // Add data codewords\n for (i = 0; i < maxDataSize; i++) {\n for (r = 0; r < ecTotalBlocks; r++) {\n if (i < dcData[r].length) {\n data[index++] = dcData[r][i]\n }\n }\n }\n\n // Apped EC codewords\n for (i = 0; i < ecCount; i++) {\n for (r = 0; r < ecTotalBlocks; r++) {\n data[index++] = ecData[r][i]\n }\n }\n\n return data\n}\n\n/**\n * Build QR Code symbol\n *\n * @param {String} data Input string\n * @param {Number} version QR Code version\n * @param {ErrorCorretionLevel} errorCorrectionLevel Error level\n * @param {MaskPattern} maskPattern Mask pattern\n * @return {Object} Object containing symbol data\n */\nfunction createSymbol (data, version, errorCorrectionLevel, maskPattern) {\n let segments\n\n if (Array.isArray(data)) {\n segments = Segments.fromArray(data)\n } else if (typeof data === 'string') {\n let estimatedVersion = version\n\n if (!estimatedVersion) {\n const rawSegments = Segments.rawSplit(data)\n\n // Estimate best version that can contain raw splitted segments\n estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel)\n }\n\n // Build optimized segments\n // If estimated version is undefined, try with the highest version\n segments = Segments.fromString(data, estimatedVersion || 40)\n } else {\n throw new Error('Invalid data')\n }\n\n // Get the min version that can contain data\n const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel)\n\n // If no version is found, data cannot be stored\n if (!bestVersion) {\n throw new Error('The amount of data is too big to be stored in a QR Code')\n }\n\n // If not specified, use min version as default\n if (!version) {\n version = bestVersion\n\n // Check if the specified version can contain the data\n } else if (version < bestVersion) {\n throw new Error('\\n' +\n 'The chosen QR Code version cannot contain this amount of data.\\n' +\n 'Minimum version required to store current data is: ' + bestVersion + '.\\n'\n )\n }\n\n const dataBits = createData(version, errorCorrectionLevel, segments)\n\n // Allocate matrix buffer\n const moduleCount = Utils.getSymbolSize(version)\n const modules = new BitMatrix(moduleCount)\n\n // Add function modules\n setupFinderPattern(modules, version)\n setupTimingPattern(modules)\n setupAlignmentPattern(modules, version)\n\n // Add temporary dummy bits for format info just to set them as reserved.\n // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}\n // since the masking operation must be performed only on the encoding region.\n // These blocks will be replaced with correct values later in code.\n setupFormatInfo(modules, errorCorrectionLevel, 0)\n\n if (version >= 7) {\n setupVersionInfo(modules, version)\n }\n\n // Add data codewords\n setupData(modules, dataBits)\n\n if (isNaN(maskPattern)) {\n // Find best mask pattern\n maskPattern = MaskPattern.getBestMask(modules,\n setupFormatInfo.bind(null, modules, errorCorrectionLevel))\n }\n\n // Apply mask pattern\n MaskPattern.applyMask(maskPattern, modules)\n\n // Replace format info bits with correct values\n setupFormatInfo(modules, errorCorrectionLevel, maskPattern)\n\n return {\n modules: modules,\n version: version,\n errorCorrectionLevel: errorCorrectionLevel,\n maskPattern: maskPattern,\n segments: segments\n }\n}\n\n/**\n * QR Code\n *\n * @param {String | Array} data Input data\n * @param {Object} options Optional configurations\n * @param {Number} options.version QR Code version\n * @param {String} options.errorCorrectionLevel Error correction level\n * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis\n */\nexports.create = function create (data, options) {\n if (typeof data === 'undefined' || data === '') {\n throw new Error('No input text')\n }\n\n let errorCorrectionLevel = ECLevel.M\n let version\n let mask\n\n if (typeof options !== 'undefined') {\n // Use higher error correction level as default\n errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)\n version = Version.from(options.version)\n mask = MaskPattern.from(options.maskPattern)\n\n if (options.toSJISFunc) {\n Utils.setToSJISFunction(options.toSJISFunc)\n }\n }\n\n return createSymbol(data, version, errorCorrectionLevel, mask)\n}\n","function hex2rgba (hex) {\n if (typeof hex === 'number') {\n hex = hex.toString()\n }\n\n if (typeof hex !== 'string') {\n throw new Error('Color should be defined as hex string')\n }\n\n let hexCode = hex.slice().replace('#', '').split('')\n if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {\n throw new Error('Invalid hex color: ' + hex)\n }\n\n // Convert from short to long form (fff -> ffffff)\n if (hexCode.length === 3 || hexCode.length === 4) {\n hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {\n return [c, c]\n }))\n }\n\n // Add default alpha value\n if (hexCode.length === 6) hexCode.push('F', 'F')\n\n const hexValue = parseInt(hexCode.join(''), 16)\n\n return {\n r: (hexValue >> 24) & 255,\n g: (hexValue >> 16) & 255,\n b: (hexValue >> 8) & 255,\n a: hexValue & 255,\n hex: '#' + hexCode.slice(0, 6).join('')\n }\n}\n\nexports.getOptions = function getOptions (options) {\n if (!options) options = {}\n if (!options.color) options.color = {}\n\n const margin = typeof options.margin === 'undefined' ||\n options.margin === null ||\n options.margin < 0\n ? 4\n : options.margin\n\n const width = options.width && options.width >= 21 ? options.width : undefined\n const scale = options.scale || 4\n\n return {\n width: width,\n scale: width ? 4 : scale,\n margin: margin,\n color: {\n dark: hex2rgba(options.color.dark || '#000000ff'),\n light: hex2rgba(options.color.light || '#ffffffff')\n },\n type: options.type,\n rendererOpts: options.rendererOpts || {}\n }\n}\n\nexports.getScale = function getScale (qrSize, opts) {\n return opts.width && opts.width >= qrSize + opts.margin * 2\n ? opts.width / (qrSize + opts.margin * 2)\n : opts.scale\n}\n\nexports.getImageWidth = function getImageWidth (qrSize, opts) {\n const scale = exports.getScale(qrSize, opts)\n return Math.floor((qrSize + opts.margin * 2) * scale)\n}\n\nexports.qrToImageData = function qrToImageData (imgData, qr, opts) {\n const size = qr.modules.size\n const data = qr.modules.data\n const scale = exports.getScale(size, opts)\n const symbolSize = Math.floor((size + opts.margin * 2) * scale)\n const scaledMargin = opts.margin * scale\n const palette = [opts.color.light, opts.color.dark]\n\n for (let i = 0; i < symbolSize; i++) {\n for (let j = 0; j < symbolSize; j++) {\n let posDst = (i * symbolSize + j) * 4\n let pxColor = opts.color.light\n\n if (i >= scaledMargin && j >= scaledMargin &&\n i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {\n const iSrc = Math.floor((i - scaledMargin) / scale)\n const jSrc = Math.floor((j - scaledMargin) / scale)\n pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0]\n }\n\n imgData[posDst++] = pxColor.r\n imgData[posDst++] = pxColor.g\n imgData[posDst++] = pxColor.b\n imgData[posDst] = pxColor.a\n }\n }\n}\n","const Utils = require('./utils')\n\nfunction clearCanvas (ctx, canvas, size) {\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n\n if (!canvas.style) canvas.style = {}\n canvas.height = size\n canvas.width = size\n canvas.style.height = size + 'px'\n canvas.style.width = size + 'px'\n}\n\nfunction getCanvasElement () {\n try {\n return document.createElement('canvas')\n } catch (e) {\n throw new Error('You need to specify a canvas element')\n }\n}\n\nexports.render = function render (qrData, canvas, options) {\n let opts = options\n let canvasEl = canvas\n\n if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {\n opts = canvas\n canvas = undefined\n }\n\n if (!canvas) {\n canvasEl = getCanvasElement()\n }\n\n opts = Utils.getOptions(opts)\n const size = Utils.getImageWidth(qrData.modules.size, opts)\n\n const ctx = canvasEl.getContext('2d')\n const image = ctx.createImageData(size, size)\n Utils.qrToImageData(image.data, qrData, opts)\n\n clearCanvas(ctx, canvasEl, size)\n ctx.putImageData(image, 0, 0)\n\n return canvasEl\n}\n\nexports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {\n let opts = options\n\n if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {\n opts = canvas\n canvas = undefined\n }\n\n if (!opts) opts = {}\n\n const canvasEl = exports.render(qrData, canvas, opts)\n\n const type = opts.type || 'image/png'\n const rendererOpts = opts.rendererOpts || {}\n\n return canvasEl.toDataURL(type, rendererOpts.quality)\n}\n","const Utils = require('./utils')\n\nfunction getColorAttrib (color, attrib) {\n const alpha = color.a / 255\n const str = attrib + '=\"' + color.hex + '\"'\n\n return alpha < 1\n ? str + ' ' + attrib + '-opacity=\"' + alpha.toFixed(2).slice(1) + '\"'\n : str\n}\n\nfunction svgCmd (cmd, x, y) {\n let str = cmd + x\n if (typeof y !== 'undefined') str += ' ' + y\n\n return str\n}\n\nfunction qrToPath (data, size, margin) {\n let path = ''\n let moveBy = 0\n let newRow = false\n let lineLength = 0\n\n for (let i = 0; i < data.length; i++) {\n const col = Math.floor(i % size)\n const row = Math.floor(i / size)\n\n if (!col && !newRow) newRow = true\n\n if (data[i]) {\n lineLength++\n\n if (!(i > 0 && col > 0 && data[i - 1])) {\n path += newRow\n ? svgCmd('M', col + margin, 0.5 + row + margin)\n : svgCmd('m', moveBy, 0)\n\n moveBy = 0\n newRow = false\n }\n\n if (!(col + 1 < size && data[i + 1])) {\n path += svgCmd('h', lineLength)\n lineLength = 0\n }\n } else {\n moveBy++\n }\n }\n\n return path\n}\n\nexports.render = function render (qrData, options, cb) {\n const opts = Utils.getOptions(options)\n const size = qrData.modules.size\n const data = qrData.modules.data\n const qrcodesize = size + opts.margin * 2\n\n const bg = !opts.color.light.a\n ? ''\n : '<path ' + getColorAttrib(opts.color.light, 'fill') +\n ' d=\"M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z\"/>'\n\n const path =\n '<path ' + getColorAttrib(opts.color.dark, 'stroke') +\n ' d=\"' + qrToPath(data, size, opts.margin) + '\"/>'\n\n const viewBox = 'viewBox=\"' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '\"'\n\n const width = !opts.width ? '' : 'width=\"' + opts.width + '\" height=\"' + opts.width + '\" '\n\n const svgTag = '<svg xmlns=\"http://www.w3.org/2000/svg\" ' + width + viewBox + ' shape-rendering=\"crispEdges\">' + bg + path + '</svg>\\n'\n\n if (typeof cb === 'function') {\n cb(null, svgTag)\n }\n\n return svgTag\n}\n","\nconst canPromise = require('./can-promise')\n\nconst QRCode = require('./core/qrcode')\nconst CanvasRenderer = require('./renderer/canvas')\nconst SvgRenderer = require('./renderer/svg-tag.js')\n\nfunction renderCanvas (renderFunc, canvas, text, opts, cb) {\n const args = [].slice.call(arguments, 1)\n const argsNum = args.length\n const isLastArgCb = typeof args[argsNum - 1] === 'function'\n\n if (!isLastArgCb && !canPromise()) {\n throw new Error('Callback required as last argument')\n }\n\n if (isLastArgCb) {\n if (argsNum < 2) {\n throw new Error('Too few arguments provided')\n }\n\n if (argsNum === 2) {\n cb = text\n text = canvas\n canvas = opts = undefined\n } else if (argsNum === 3) {\n if (canvas.getContext && typeof cb === 'undefined') {\n cb = opts\n opts = undefined\n } else {\n cb = opts\n opts = text\n text = canvas\n canvas = undefined\n }\n }\n } else {\n if (argsNum < 1) {\n throw new Error('Too few arguments provided')\n }\n\n if (argsNum === 1) {\n text = canvas\n canvas = opts = undefined\n } else if (argsNum === 2 && !canvas.getContext) {\n opts = text\n text = canvas\n canvas = undefined\n }\n\n return new Promise(function (resolve, reject) {\n try {\n const data = QRCode.create(text, opts)\n resolve(renderFunc(data, canvas, opts))\n } catch (e) {\n reject(e)\n }\n })\n }\n\n try {\n const data = QRCode.create(text, opts)\n cb(null, renderFunc(data, canvas, opts))\n } catch (e) {\n cb(e)\n }\n}\n\nexports.create = QRCode.create\nexports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render)\nexports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)\n\n// only svg for now.\nexports.toString = renderCanvas.bind(null, function (data, _, opts) {\n return SvgRenderer.render(data, opts)\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 { getDialogStyles } from './dialog-zap-style';\nimport { decodeNpub } from '../common/utils';\n\n/**\n * Modal dialog helper for <nostr-zap> component.\n *\n * Adapted (simplified) from the original `nostr-zap` repository `view.js` file.\n * The goal is to give users a full-page modal with amount presets, QR-invoice,\n * wallet URI link, copy-to-clipboard, and success feedback – while keeping code\n * size reasonable for the component bundle.\n * \n * NOTE: This dialog now receives pre-resolved npub from the component, eliminating\n * the need for redundant validation and resolution logic.\n */\n\nimport { \n fetchInvoice, \n getProfileMetadata, \n getZapEndpoint, \n listenForZapReceipt \n} from './zap-utils';\nimport * as QRCode from 'qrcode';\n\ninterface WebLN {\n enable: () => Promise<void>;\n sendPayment: (invoice: string) => Promise<{ preimage: string }>;\n}\n\ndeclare global {\n interface Window {\n webln?: WebLN;\n }\n}\n\nexport interface OpenZapModalParams {\n npub: string;\n relays: string;\n cachedDialogComponent?: DialogComponent | null;\n buttonColor?: string;\n theme?: 'light' | 'dark';\n fixedAmount?: number; // if supplied, hide amount UI\n defaultAmount?: number; // preselect but allow change\n initialAmount?: number; // legacy support\n anon?: boolean;\n url?: string; // URL to send zap to (enables URL-based zaps)\n}\n\nexport const injectCSS = (theme: 'light' | 'dark' = 'light') => {\n // Remove existing dialog styles\n const existingStyles = document.querySelectorAll('style[data-zap-dialog-styles]');\n existingStyles.forEach(style => style.remove());\n \n const style = document.createElement('style');\n style.setAttribute('data-zap-dialog-styles', 'true');\n style.textContent = getDialogStyles(theme);\n document.head.appendChild(style);\n};\n\n/**\n * Opens (or re-opens) the zap modal. Returns the DialogComponent so the caller\n * can cache it between clicks.\n */\nexport async function init(params: OpenZapModalParams): Promise<DialogComponent> {\n const { npub, relays, cachedDialogComponent, buttonColor, fixedAmount, defaultAmount, initialAmount, url } = params;\n const npubHex = decodeNpub(npub);\n \n // Ensure custom element is defined\n if (!customElements.get('dialog-component')) {\n await customElements.whenDefined('dialog-component');\n }\n \n if (cachedDialogComponent) {\n // Find the actual dialog element\n const cachedDialog = document.querySelector('.nostr-base-dialog') as HTMLDialogElement | null;\n if (cachedDialog) {\n // remove success class if it exists\n cachedDialog.classList.remove('success');\n // show all controls that might have been hidden\n const controls = cachedDialog.querySelectorAll('.amount-buttons, .update-zap-container, .comment-container, .cta-btn, .copy-btn');\n controls.forEach(el => {\n if (el instanceof HTMLElement) el.style.display = '';\n });\n // reset the update button\n const updateZapBtn = cachedDialog.querySelector('.update-zap-btn') as HTMLButtonElement | null;\n if (updateZapBtn) updateZapBtn.style.display = '';\n // reset success overlay opacity if it was previously shown\n const successOverlay = cachedDialog.querySelector('.success-overlay') as HTMLElement | null;\n if (successOverlay) {\n successOverlay.style.opacity = '0';\n successOverlay.style.pointerEvents = 'none';\n }\n\n void refreshUI(cachedDialog);\n cachedDialogComponent.showModal();\n return cachedDialogComponent;\n }\n }\n\n // Minimal amount presets – feel free to tweak / add more later.\n const presets = [21, 100, 1000];\n let selectedAmount: number;\n if (typeof fixedAmount === 'number' && fixedAmount > 0) {\n selectedAmount = fixedAmount;\n } else if (typeof defaultAmount === 'number' && defaultAmount > 0) {\n selectedAmount = defaultAmount;\n } else if (typeof initialAmount === 'number' && initialAmount > 0) {\n selectedAmount = initialAmount;\n } else {\n selectedAmount = presets[0];\n }\n let customComment = '';\n let currentInvoice = '';\n let cleanupReceipt: (() => void) | null = null;\n\n // -----------------------------------------------------------------------------\n // Internal helpers\n // ---------------------------------------------------------------------------\n\n async function loadInvoice(amountSats: number, comment: string) {\n const authorId = npubHex;\n const meta = await getProfileMetadata(authorId);\n const endpoint = await getZapEndpoint(meta);\n const invoice = await fetchInvoice({\n zapEndpoint: endpoint,\n amount: amountSats * 1000, // -> msats\n comment,\n authorId,\n nip19Target: undefined,\n normalizedRelays: relays.split(','),\n anon: params.anon ?? false,\n url: url,\n });\n currentInvoice = invoice;\n\n // Zap receipt listener\n const relaysArr = relays.split(',');\n // Dispose previous listener before creating a new one\n if (cleanupReceipt) cleanupReceipt();\n cleanupReceipt = listenForZapReceipt({\n relays: relaysArr,\n receiversPubKey: npubHex,\n invoice,\n onSuccess: markSuccess\n });\n }\n\n async function qrImgSrc(invoice: string): Promise<string> {\n try {\n // Generate QR code as a data URL (base64 encoded image)\n return await QRCode.toDataURL(invoice, {\n width: 240,\n margin: 1,\n color: {\n dark: '#000000',\n light: '#ffffff'\n }\n });\n } catch (error) {\n console.error('Failed to generate QR code:', error);\n // Fallback to text representation if QR generation fails\n return `data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"240\" height=\"240\" viewBox=\"0 0 100 100\">\n <rect width=\"100%\" height=\"100%\" fill=\"white\"/>\n <text x=\"50%\" y=\"50%\" font-family=\"monospace\" font-size=\"10\" text-anchor=\"middle\" dominant-baseline=\"middle\" fill=\"black\">\n Invoice: ${invoice.substring(0, 10)}...\n </text>\n </svg>`;\n }\n }\n\n function setActiveAmountButtons(container: HTMLElement, amt: number) {\n container.querySelectorAll('button').forEach(btn => {\n if ((btn as HTMLButtonElement).dataset['val'] === String(amt)) {\n btn.classList.add('active');\n } else {\n btn.classList.remove('active');\n }\n });\n }\n\n async function refreshUI(dialog: HTMLDialogElement) {\n dialog.classList.add('loading');\n try {\n await loadInvoice(selectedAmount, customComment);\n const qrImg = dialog.querySelector('img.qr') as HTMLImageElement;\n qrImgSrc(currentInvoice).then(src => {\n qrImg.src = src;\n });\n\n const payBtn = dialog.querySelector('.cta-btn') as HTMLButtonElement;\n payBtn.disabled = false;\n } finally {\n dialog.classList.remove('loading');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Build dialog DOM\n // ---------------------------------------------------------------------------\n\n injectCSS(params.theme || 'light');\n\n // Create dialog component (not added to DOM)\n const dialogComponent = document.createElement('dialog-component') as DialogComponent;\n dialogComponent.setAttribute('header', 'Send a Zap');\n if (params.theme) {\n dialogComponent.setAttribute('data-theme', params.theme);\n }\n \n const amountButtonsHtml = presets\n .map(a => `<button type=\"button\" data-val=\"${a}\">${a} ⚡</button>`) // show sat symbol\n .join('');\n\n const hideAmountUI = typeof fixedAmount === 'number' && fixedAmount > 0;\n\n dialogComponent.innerHTML = `\n <div class=\"zap-dialog-content\">\n ${hideAmountUI ? '' : `<div class=\"amount-buttons\">${amountButtonsHtml}</div>`}\n ${hideAmountUI ? `<p class=\"zapping-amount\">Zapping ${fixedAmount} sats</p>` : ''}\n ${hideAmountUI ? '' : `<div class=\"update-zap-container\">\n <input type=\"number\" min=\"1\" placeholder=\"Custom sats\" class=\"custom-amount\" style=\"width:100%;padding:8px;border:1px solid #e2e8f0;border-radius:6px\" />\n <button type=\"button\" class=\"update-zap-btn\" style=\"padding:8px 12px;border:none;border-radius:6px;background:#7f00ff;color:#fff\">Update Zap</button>\n </div>`}\n ${hideAmountUI ? '' : `<div class=\"comment-container\">\n <input type=\"text\" placeholder=\"Comment (optional)\" class=\"comment-input\" style=\"width:100%;padding:8px;border:1px solid #e2e8f0;border-radius:6px\" />\n <button type=\"button\" class=\"add-comment-btn\" style=\"padding:8px 12px;border:none;border-radius:6px;background:#7f00ff;color:#fff\">Add</button>\n </div>`}\n <img class=\"qr\" width=\"240\" height=\"240\" alt=\"QR\" style=\"cursor:pointer\" />\n <br />\n <button type=\"button\" class=\"copy-btn\">Copy invoice</button>\n <button type=\"button\" class=\"cta-btn\" disabled>Open in wallet</button>\n <div class=\"loading-overlay\"><div class=\"loader\"></div></div>\n <div class=\"success-overlay\">⚡ Thank you!</div>\n </div>\n `;\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 event listeners\n // The dialog is created synchronously by showModal() and appended to document.body\n // Try both shadow root and light DOM, then fall back to document.body\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('[showZapDialog] 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 // Event wiring - moved listener setup to after initial invoice load\n const amountContainer = dialog.querySelector('.amount-buttons') as HTMLElement | null;\n if (amountContainer)\n amountContainer.addEventListener('click', async e => {\n const target = e.target as HTMLElement;\n if (target.tagName === 'BUTTON') {\n const val = Number(target.dataset['val']);\n if (!isNaN(val)) {\n selectedAmount = val;\n setActiveAmountButtons(amountContainer, val);\n const payBtn = dialog.querySelector('.cta-btn') as HTMLButtonElement;\n payBtn.disabled = true; // disable until new invoice fetched\n await refreshUI(dialog);\n }\n }\n });\n\n // custom amount change\n const customAmountInput = dialog.querySelector('.custom-amount') as HTMLInputElement | null;\n if (customAmountInput) customAmountInput.addEventListener('input', async e => {\n const val = Number((e.target as HTMLInputElement).value);\n if (val > 0) {\n selectedAmount = val;\n if (amountContainer) setActiveAmountButtons(amountContainer, -1); // clear presets highlight\n const payBtn = dialog.querySelector('.cta-btn') as HTMLButtonElement;\n payBtn.disabled = true; // will be enabled after Update Zap\n }\n });\n\n const commentInput = dialog.querySelector('.comment-input') as HTMLInputElement | null;\n if (commentInput) commentInput.addEventListener('input', e => {\n customComment = (e.target as HTMLInputElement).value.slice(0, 200);\n });\n\n const copyInvoice = async () => {\n if (!currentInvoice) return;\n await navigator.clipboard.writeText(currentInvoice);\n (dialog.querySelector('.copy-btn') as HTMLButtonElement).textContent = 'Copied!';\n setTimeout(() => {\n (dialog.querySelector('.copy-btn') as HTMLButtonElement).textContent = 'Copy invoice';\n }, 1500);\n };\n (dialog.querySelector('.copy-btn') as HTMLButtonElement).onclick = copyInvoice;\n (dialog.querySelector('img.qr') as HTMLImageElement).onclick = copyInvoice;\n\n // Update zap button\n const updateZapBtn = dialog.querySelector('.update-zap-btn') as HTMLButtonElement | null;\n if (updateZapBtn) updateZapBtn.addEventListener('click', async () => {\n const val = Number(customAmountInput?.value);\n if (!isNaN(val) && val > 0) {\n selectedAmount = val;\n updateZapBtn.disabled = true;\n await refreshUI(dialog);\n updateZapBtn.disabled = false;\n }\n });\n\n const addCommentBtn = dialog.querySelector('.add-comment-btn') as HTMLButtonElement | null;\n if (addCommentBtn) addCommentBtn.addEventListener('click', async () => {\n addCommentBtn.disabled = true;\n await refreshUI(dialog);\n addCommentBtn.disabled = false;\n });\n\n (dialog.querySelector('.cta-btn') as HTMLButtonElement).onclick = async () => {\n if (!currentInvoice) return;\n // try WebLN first\n if (window.webln) {\n try {\n await window.webln.enable();\n await window.webln.sendPayment(currentInvoice);\n markSuccess();\n return;\n } catch (e) {\n console.error('Nostr-Components: Zap button: webln payment failed', e);\n dialog.close();\n }\n }\n window.location.href = `lightning:${currentInvoice}`;\n };\n\n function markSuccess() {\n dialog.classList.add('success');\n const overlay = dialog.querySelector('.success-overlay') as HTMLElement;\n overlay.style.opacity = '1';\n // Ensure overlay does not block interactions (close button)\n overlay.style.pointerEvents = 'none';\n // hide other controls for clarity\n const controls = dialog.querySelectorAll('.amount-buttons, .update-zap-container, .comment-container, .cta-btn, .copy-btn');\n controls.forEach(el => {\n if (el instanceof HTMLElement) el.style.display = 'none';\n });\n // DialogComponent close button is always clickable\n }\n\n dialog.addEventListener('close', () => {\n if (cleanupReceipt) cleanupReceipt();\n });\n\n // Color customisation (buttonColor background)\n if (buttonColor) {\n const btnColor = buttonColor;\n (dialog.querySelector('.cta-btn') as HTMLButtonElement).style.background = btnColor;\n (dialog.querySelector('.cta-btn') as HTMLButtonElement).style.color = getContrastingTextColor(btnColor);\n }\n\n // Load first invoice & show\n await refreshUI(dialog);\n \n if (amountContainer && presets.includes(selectedAmount)) {\n setActiveAmountButtons(amountContainer, selectedAmount);\n } else if (!hideAmountUI) {\n const input = dialog.querySelector('.custom-amount') as HTMLInputElement | null;\n if (input) input.value = String(selectedAmount);\n if (amountContainer) setActiveAmountButtons(amountContainer, -1);\n }\n\n return dialogComponent;\n}\n\n// -----------------------------------------------------------------------------\n// Helper – compute readable text colour for custom bg\n// -----------------------------------------------------------------------------\nfunction getContrastingTextColor(hex: string): string {\n hex = hex.replace('#', '');\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map(ch => ch + ch)\n .join('');\n }\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n return brightness > 125 ? '#000' : '#fff';\n}\n","// SPDX-License-Identifier: MIT\n\n/**\n * Help dialog content styles for nostr-zap component\n * Contains only content-specific styles (base dialog styles in DialogComponent)\n */\nexport const getHelpDialogStyles = (): string => {\n return `\n /* Help Dialog Content Styles */\n .help-content {\n padding: var(--nostrc-spacing-md, 12px);\n }\n\n .help-content p {\n margin: 0 0 var(--nostrc-spacing-md, 12px) 0;\n color: var(--nostrc-theme-text-primary, #333333);\n line-height: 1.5;\n }\n\n .help-content p:last-child {\n margin-bottom: 0;\n }\n\n .help-content ul {\n margin: 0 0 var(--nostrc-spacing-md, 12px) 0;\n padding-left: var(--nostrc-spacing-lg, 16px);\n color: var(--nostrc-theme-text-primary, #333333);\n }\n\n .help-content li {\n margin-bottom: var(--nostrc-spacing-xs, 4px);\n line-height: 1.5;\n }\n\n .help-content li:last-child {\n margin-bottom: 0;\n }\n\n .help-content strong {\n font-weight: 600;\n color: var(--nostrc-theme-text-primary, #333333);\n }\n\n .help-content a:not(.youtube-link) {\n color: var(--nostrc-theme-primary, #0066cc);\n text-decoration: underline;\n }\n\n .help-content a:not(.youtube-link):hover {\n color: var(--nostrc-theme-primary-hover, #0052a3);\n }\n\n .youtube-link {\n display: inline-block;\n background: var(--nostrc-color-primary, #7f00ff);\n color: var(--nostrc-color-text-on-primary, #ffffff);\n padding: var(--nostrc-spacing-sm, 8px) var(--nostrc-spacing-md, 12px);\n border-radius: var(--nostrc-border-radius-md, 6px);\n text-decoration: none;\n font-weight: var(--nostrc-font-weight-medium, 500);\n margin-top: var(--nostrc-spacing-md, 12px);\n transition: background-color 0.2s ease;\n }\n\n .youtube-link:hover {\n background: var(--nostrc-color-primary-hover, #6b00d9);\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 { getHelpDialogStyles } from './dialog-help-style';\n\nconst YOUTUBE_URL = \"https://www.youtube.com/shorts/PDnrh8pkF3g\";\n\nexport const injectHelpDialogStyles = (): void => {\n // Check if styles are already injected\n if (document.querySelector('style[data-help-dialog-styles]')) return;\n \n const style = document.createElement('style');\n style.setAttribute('data-help-dialog-styles', 'true');\n style.textContent = getHelpDialogStyles();\n document.head.appendChild(style);\n};\n\nexport const showHelpDialog = async (theme?: 'light' | 'dark'): Promise<void> => {\n injectHelpDialogStyles();\n \n if (!customElements.get('dialog-component')) {\n await customElements.whenDefined('dialog-component');\n }\n \n const dialogComponent = document.createElement('dialog-component') as DialogComponent;\n dialogComponent.setAttribute('header', 'What is a Zap?');\n if (theme) {\n dialogComponent.setAttribute('data-theme', theme);\n }\n \n // Set dialog content\n dialogComponent.innerHTML = `\n <div class=\"help-content\">\n <p>Send instant tips to support content creators! Zaps are small Bitcoin Lightning payments that go directly to creators—no middleman.</p>\n <ul>\n <li>Send any amount instantly</li>\n <li>Money goes straight to the creator</li>\n <li>Powered by Bitcoin Lightning Network</li>\n </ul>\n <p><strong>How it works:</strong> Click zap, choose amount, scan QR code with a Lightning wallet, done!</p>\n <a href=\"${YOUTUBE_URL}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"youtube-link\">\n Watch Tutorial\n </a>\n </div>\n `;\n \n dialogComponent.showModal();\n};\n","// SPDX-License-Identifier: MIT\n\nimport { getComponentStyles } from \"../common/base-styles\";\n\nexport function getZappersDialogStyles(theme: 'light' | 'dark' = 'light'): string {\n const isDark = theme === 'dark';\n \n const customStyles = `\n /* === ZAPPERS DIALOG CONTENT STYLES === */\n .zappers-dialog-content {\n overflow: hidden;\n }\n\n .zappers-list {\n max-height: 60vh;\n overflow-y: auto;\n }\n\n /* Individual zap entry */\n .zap-entry {\n padding: var(--nostrc-spacing-md, 16px);\n border-bottom: 1px solid ${isDark ? '#333333' : '#f3f4f6'};\n transition: background-color 0.2s ease;\n }\n\n .zap-entry:last-child {\n border-bottom: none;\n }\n\n .zap-entry:hover {\n background: ${isDark ? '#2a2a2a' : '#f9fafb'};\n }\n\n .zap-author-info {\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-md, 16px);\n }\n\n .zap-author-picture {\n width: 40px;\n height: 40px;\n border-radius: var(--nostrc-border-radius-full, 50%);\n object-fit: cover;\n border: 2px solid ${isDark ? '#374151' : '#e5e7eb'};\n }\n\n .zap-author-picture-default {\n width: 40px;\n height: 40px;\n border-radius: var(--nostrc-border-radius-full, 50%);\n background: ${isDark ? '#374151' : '#f3f4f6'};\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: var(--nostrc-font-size-lg, 18px);\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n border: 2px solid ${isDark ? '#4b5563' : '#d1d5db'};\n }\n\n .zap-author-details {\n flex: 1;\n min-width: 0;\n }\n\n .zap-author-link {\n display: block;\n font-weight: 500;\n color: ${isDark ? '#ffffff' : '#1a1a1a'};\n text-decoration: none;\n font-size: var(--nostrc-font-size-base, 16px);\n margin-bottom: var(--nostrc-spacing-xs, 4px);\n transition: color 0.2s ease;\n }\n\n .zap-author-link:hover {\n color: var(--nostrc-color-primary, #7f00ff);\n }\n\n .zap-comment {\n font-size: var(--nostrc-font-size-sm, 14px);\n color: ${isDark ? '#d1d5db' : '#4b5563'};\n margin: var(--nostrc-spacing-xs, 4px) 0;\n line-height: 1.4;\n word-wrap: break-word;\n white-space: pre-wrap;\n }\n\n .zap-amount-date {\n font-size: var(--nostrc-font-size-sm, 14px);\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-xs, 4px);\n }\n\n /* Loading skeleton with npub */\n .skeleton-entry {\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-md, 16px);\n padding: var(--nostrc-spacing-md, 16px);\n border-bottom: 1px solid ${isDark ? '#333333' : '#f3f4f6'};\n }\n\n .skeleton-entry:last-child {\n border-bottom: none;\n }\n\n .skeleton-picture {\n width: 40px;\n height: 40px;\n border-radius: var(--nostrc-border-radius-full, 50%);\n background: linear-gradient(90deg, \n ${isDark ? '#374151' : '#f0f0f0'} 25%, \n ${isDark ? '#4b5563' : '#e0e0e0'} 50%, \n ${isDark ? '#374151' : '#f0f0f0'} 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n }\n\n .skeleton-name {\n font-size: var(--nostrc-font-size-base, 16px);\n font-weight: 500;\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;\n word-break: break-all;\n line-height: 1.2;\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 /* Empty state */\n .no-zaps {\n text-align: center;\n padding: var(--nostrc-spacing-xl, 32px);\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n font-size: var(--nostrc-font-size-base, 16px);\n }\n\n /* Responsive design */\n @media (max-width: 640px) {\n .zap-author-picture,\n .zap-author-picture-default,\n .skeleton-picture {\n width: 36px;\n height: 36px;\n }\n \n .zap-author-link {\n font-size: var(--nostrc-font-size-sm, 14px);\n }\n \n .zap-amount-date {\n font-size: var(--nostrc-font-size-xs, 12px);\n }\n }\n\n /* Scrollbar styling */\n .zappers-list::-webkit-scrollbar {\n width: 6px;\n }\n\n .zappers-list::-webkit-scrollbar-track {\n background: ${isDark ? '#2a2a2a' : '#f1f5f9'};\n border-radius: 3px;\n }\n\n .zappers-list::-webkit-scrollbar-thumb {\n background: ${isDark ? '#4b5563' : '#cbd5e1'};\n border-radius: 3px;\n }\n\n .zappers-list::-webkit-scrollbar-thumb:hover {\n background: ${isDark ? '#6b7280' : '#94a3b8'};\n }\n `;\n \n return getComponentStyles(customStyles);\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 { getZappersDialogStyles } from './dialog-zappers-style';\nimport { getBatchedProfileMetadata, extractProfileMetadataContent, ZapDetails } from './zap-utils';\nimport { escapeHtml, formatRelativeTime, hexToNpub, isValidUrl } from '../common/utils';\nimport { isValidPublicKey } from '../nostr-comment/utils';\n\n/**\n * Modal dialog for displaying individual zap details (zappers).\n * \n * Shows a list of all zaps received by a user with:\n * - Zap amount\n * - Zap date (relative time)\n * - Zap author's name\n * - Zap author's profile picture\n * - Clickable links to author profiles via njump.me\n */\n\nexport interface OpenZappersModalParams {\n zapDetails: ZapDetails[];\n theme?: 'light' | 'dark';\n}\n\n/**\n * Inject zappers dialog content styles into document head\n * Prevents duplicate injection by checking for existing styles\n */\nexport const injectZappersDialogStyles = (theme: 'light' | 'dark' = 'light') => {\n // Remove existing zappers dialog styles\n const existingStyles = document.querySelectorAll('style[data-zappers-dialog-styles]');\n existingStyles.forEach(style => style.remove());\n \n const style = document.createElement('style');\n style.setAttribute('data-zappers-dialog-styles', 'true');\n style.textContent = getZappersDialogStyles(theme);\n document.head.appendChild(style);\n}\n\ninterface EnhancedZapDetails extends ZapDetails {\n authorName?: string;\n authorPicture?: string;\n authorNpub?: string;\n}\n\n/**\n * Render individual zap entry HTML (with profile data)\n */\nfunction renderZapEntry(zap: EnhancedZapDetails, index: number): string {\n const authorNameSafe = escapeHtml(zap.authorName || 'Unknown zapper');\n const npubSafe = isValidPublicKey(zap.authorNpub || '') ? zap.authorNpub : '';\n const njumpUrl = `https://njump.me/${npubSafe}`;\n const profilePictureSafe = isValidUrl(zap.authorPicture || '') ? zap.authorPicture || '' : '';\n \n\n const profilePicture = zap.authorPicture \n ? `<img src=\"${profilePictureSafe}\" alt=\"${authorNameSafe}\" class=\"zap-author-picture\" />`\n : `<div class=\"zap-author-picture-default\">👤</div>`;\n \n const commentHtml = zap.comment \n ? `<div class=\"zap-comment\">${zap.comment}</div>`\n : '';\n \n return `\n <div class=\"zap-entry\" data-zap-index=\"${index}\" data-author-pubkey=\"${zap.authorPubkey}\">\n <div class=\"zap-author-info\">\n ${profilePicture}\n <div class=\"zap-author-details\">\n <a href=\"${njumpUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"zap-author-link\">\n ${authorNameSafe}\n </a>\n ${commentHtml}\n <div class=\"zap-amount-date\">\n ${zap.amount.toLocaleString()} ⚡ • ${formatRelativeTime(Math.floor(zap.date.getTime() / 1000))}\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Render skeleton zap entry HTML (with npub)\n */\nfunction renderSkeletonZapEntry(zap: ZapDetails, npub: string, index: number): string {\n return `\n <div class=\"zap-entry skeleton-entry\" data-zap-index=\"${index}\" data-author-pubkey=\"${zap.authorPubkey}\">\n <div class=\"zap-author-info\">\n <div class=\"skeleton-picture\"></div>\n <div class=\"zap-author-details\">\n <div class=\"zap-author-link skeleton-name\">\n ${escapeHtml(npub)}\n </div>\n <div class=\"zap-amount-date\">\n ${zap.amount.toLocaleString()} ⚡ • ${formatRelativeTime(Math.floor(zap.date.getTime() / 1000))}\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Opens the zappers dialog showing individual zap details\n */\nexport async function openZappersDialog(params: OpenZappersModalParams): Promise<DialogComponent> {\n const { zapDetails, theme = 'light' } = params;\n \n // Inject styles\n injectZappersDialogStyles(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', 'Zappers');\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(zapDetails);\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 // The dialog is created synchronously by showModal() and appended to document.body\n // Try both shadow root and light DOM, then fall back to document.body\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('[showZappersDialog] 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 && zapDetails.length > 0) {\n enhanceZapDetailsProgressively(dialog, zapDetails);\n }\n\n return dialogComponent;\n}\n\n/**\n * Render initial dialog content with skeleton loaders showing npubs\n */\nasync function renderInitialContent(zapDetails: ZapDetails[]): Promise<string> {\n if (zapDetails.length === 0) {\n return `\n <div class=\"zappers-dialog-content\">\n <div class=\"zappers-list\">\n <div class=\"no-zaps\">No zaps received yet</div>\n </div>\n </div>\n `;\n }\n\n // Convert all pubkeys to npubs for immediate display\n const npubs = zapDetails.map(zap => hexToNpub(zap.authorPubkey));\n\n const skeletonEntries = zapDetails.map((zap, index) => \n renderSkeletonZapEntry(zap, npubs[index], index)\n ).join('');\n\n return `\n <div class=\"zappers-dialog-content\">\n <div class=\"zappers-list\">\n ${skeletonEntries}\n </div>\n </div>\n `;\n}\n\n/**\n * Progressively enhance zap details with profile information (batched approach)\n */\nasync function enhanceZapDetailsProgressively(dialog: HTMLDialogElement, zapDetails: ZapDetails[]): Promise<void> {\n const zappersList = dialog.querySelector('.zappers-list') as HTMLElement;\n if (!zappersList) return;\n\n // Get unique author IDs\n const uniqueAuthorIds = [...new Set(zapDetails.map(zap => zap.authorPubkey))];\n console.log(\"Nostr-Components: Zappers 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 zap entry\n for (let index = 0; index < zapDetails.length; index++) {\n const zap = zapDetails[index];\n const profile = profileMap.get(zap.authorPubkey);\n const npub = npubMap.get(zap.authorPubkey) || zap.authorPubkey;\n \n let enhanced: EnhancedZapDetails;\n \n if (profile) {\n const profileContent = extractProfileMetadataContent(profile);\n enhanced = {\n ...zap,\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 ...zap,\n authorName: npub,\n authorNpub: npub,\n };\n }\n\n // Find the corresponding skeleton entry by index and replace it\n const skeletonEntry = zappersList.querySelector(`[data-zap-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderZapEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n }\n\n console.log(\"Nostr-Components: Zappers dialog: Progressive enhancement completed for\", zapDetails.length, \"zap entries\");\n } catch (error) {\n console.error(\"Nostr-Components: Zappers dialog: Error in batched profile enhancement\", error);\n \n // Fallback to individual processing if batched approach fails\n console.log(\"Nostr-Components: Zappers dialog: Falling back to individual profile fetching\");\n await enhanceZapDetailsIndividually(dialog, zapDetails);\n }\n}\n\n/**\n * Fallback: Enhance zap details individually (original approach)\n */\nasync function enhanceZapDetailsIndividually(dialog: HTMLDialogElement, zapDetails: ZapDetails[]): Promise<void> {\n const zappersList = dialog.querySelector('.zappers-list') as HTMLElement;\n if (!zappersList) return;\n\n // Create a map to track which profiles we've already fetched\n const profileCache = new Map<string, EnhancedZapDetails>();\n \n // Fetch all profile metadata in parallel\n const profilePromises = zapDetails.map(async (zap, index) => {\n // Check if we already have this profile cached\n if (profileCache.has(zap.authorPubkey)) {\n const cachedProfile = profileCache.get(zap.authorPubkey)!;\n return {\n index,\n enhanced: {\n ...zap,\n authorName: cachedProfile.authorName,\n authorPicture: cachedProfile.authorPicture,\n authorNpub: cachedProfile.authorNpub,\n }\n };\n }\n\n try {\n const { getProfileMetadata } = await import('./zap-utils');\n const profileMetadata = await getProfileMetadata(zap.authorPubkey);\n const profileContent = extractProfileMetadataContent(profileMetadata);\n const npub = hexToNpub(zap.authorPubkey);\n \n const enhanced = {\n ...zap,\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(zap.authorPubkey, enhanced);\n \n return {\n index,\n enhanced\n };\n } catch (error) {\n console.error(\"Nostr-Components: Zappers dialog: Error fetching profile for\", zap.authorPubkey, error);\n // Fallback with just pubkey converted to npub\n const npub = hexToNpub(zap.authorPubkey);\n const enhanced = {\n ...zap,\n authorName: npub,\n authorNpub: npub,\n };\n \n // Cache the fallback profile\n profileCache.set(zap.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 = zappersList.querySelector(`[data-zap-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderZapEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n } catch (error) {\n console.error(\"Nostr-Components: Zappers dialog: Error processing profile enhancement\", error);\n }\n }\n}\n\n","// SPDX-License-Identifier: MIT\n\nimport { getSuccessAnimation } from '../common/theme';\nimport { escapeHtml } from '../common/utils';\nimport { IRenderOptions } from '../base/render-options';\n\nexport interface RenderZapButtonOptions extends IRenderOptions {\n isAmountLoading: boolean;\n isSuccess: boolean;\n buttonText: string;\n totalZapAmount: number | null;\n hasZaps?: boolean;\n}\n\nexport function renderZapButton({\n isLoading,\n isError,\n isSuccess,\n errorMessage,\n buttonText,\n totalZapAmount,\n isAmountLoading,\n hasZaps = false,\n}: RenderZapButtonOptions): string {\n\n if (isError) {\n return renderError(errorMessage || '');\n }\n\n if (isLoading) {\n return renderLoading(isAmountLoading);\n }\n\n const iconContent = isSuccess\n ? getSuccessAnimation('light')\n : getLightningIcon();\n const textContent = isSuccess\n ? `<span>Zapped</span>`\n : `<span>${escapeHtml(buttonText)}</span>`;\n\n return renderContainer(iconContent, textContent, totalZapAmount, isAmountLoading, hasZaps);\n}\n\nfunction renderLoading(isAmountLoading: boolean): string {\n return renderContainer(\n getLightningIcon(),\n '<span class=\"button-text-skeleton\"></span>',\n null,\n isAmountLoading\n );\n}\n\nfunction renderError(errorMessage: string): string {\n return renderErrorContainer(\n '<div class=\"error-icon\">&#9888;</div>',\n escapeHtml(errorMessage)\n );\n}\n\nfunction renderErrorContainer(leftContent: string, rightContent: string): string {\n return `\n <div class=\"nostr-zap-button-container\">\n <div class=\"nostr-zap-button-left-container\">\n ${leftContent}\n </div>\n <div class=\"nostr-zap-button-right-container\">\n ${rightContent}\n </div>\n </div>\n `;\n}\n\nfunction renderContainer(iconContent: string, textContent: string, totalZapAmount: number | null, isAmountLoading: boolean, hasZaps: boolean = false): string {\n const zapAmountHtml = isAmountLoading \n ? `<span class=\"total-zap-amount skeleton\"></span>` \n : (totalZapAmount !== null ? `<span class=\"total-zap-amount${hasZaps ? ' clickable' : ''}\">${totalZapAmount.toLocaleString()} ⚡ sats received</span>` : '');\n \n const helpIconHtml = `<button class=\"help-icon\" title=\"What is a zap?\">?</button>`;\n \n return `\n <div class=\"nostr-zap-button-container\">\n <button class=\"nostr-zap-button\">\n ${iconContent}\n ${textContent}\n </button>\n ${zapAmountHtml} ${helpIconHtml}\n </div>\n `;\n}\n\nfunction getLightningIcon(): string {\n // Yellow lightning regardless of text color\n return `<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 2L3 14h7v8l10-12h-7z\" fill=\"#FFC800\"/></svg>`;\n}\n","// SPDX-License-Identifier: MIT\n\nimport { getComponentStyles } from \"../common/base-styles\";\n\nexport function getZapButtonStyles(): string {\n const customStyles = `\n /* === ZAP BUTTON CONTAINER PATTERN === */\n :host {\n /* Icon sizing (overridable via CSS variables) */\n --nostrc-icon-height: 25px;\n --nostrc-icon-width: 25px;\n\n /* Zap button CSS variables (overridable by parent components) */\n --nostrc-zap-btn-padding: var(--nostrc-spacing-sm) var(--nostrc-spacing-md);\n --nostrc-zap-btn-border-radius: var(--nostrc-border-radius-md);\n --nostrc-zap-btn-border: var(--nostrc-border-width) solid var(--nostrc-color-border);\n --nostrc-zap-btn-min-height: 47px;\n --nostrc-zap-btn-width: auto;\n --nostrc-zap-btn-horizontal-alignment: left;\n --nostrc-zap-btn-bg: var(--nostrc-theme-bg, #ffffff);\n --nostrc-zap-btn-color: var(--nostrc-theme-text-primary, #333333);\n --nostrc-zap-btn-font-family: var(--nostrc-font-family-primary);\n --nostrc-zap-btn-font-size: var(--nostrc-font-size-base);\n \n /* Hover state variables */\n --nostrc-zap-btn-hover-bg: var(--nostrc-theme-hover-bg, rgba(0, 0, 0, 0.05));\n --nostrc-zap-btn-hover-color: var(--nostrc-theme-text-primary, #333333);\n --nostrc-zap-btn-hover-border: var(--nostrc-border-width) solid var(--nostrc-theme-border, var(--nostrc-color-border));\n\n /* Make the host a flex container for button + amount */\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n gap: var(--nostrc-spacing-md);\n font-family: var(--nostrc-zap-btn-font-family);\n font-size: var(--nostrc-zap-btn-font-size);\n }\n\n /* Focus state for accessibility */\n :host(:focus-visible) {\n outline: 2px solid var(--nostrc-color-primary, #007bff);\n outline-offset: 2px;\n }\n\n :host(.is-error) .nostr-zap-button-container {\n border: var(--nostrc-border-width) solid var(--nostrc-color-error-text);\n border-radius: var(--nostrc-border-radius-md);\n padding: var(--nostrc-spacing-sm);\n color: var(--nostrc-color-error-text);\n }\n\n .nostr-zap-button-container {\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-md);\n width: fit-content;\n }\n\n .nostr-zap-button-left-container {\n display: flex;\n align-items: center;\n }\n\n .nostr-zap-button-right-container {\n display: flex;\n align-items: center;\n }\n\n .nostr-zap-button {\n display: flex;\n align-items: center;\n justify-content: var(--nostrc-zap-btn-horizontal-alignment);\n gap: var(--nostrc-spacing-sm);\n background: var(--nostrc-zap-btn-bg);\n color: var(--nostrc-zap-btn-color);\n border: var(--nostrc-zap-btn-border);\n border-radius: var(--nostrc-zap-btn-border-radius);\n padding: var(--nostrc-zap-btn-padding);\n min-height: var(--nostrc-zap-btn-min-height);\n width: var(--nostrc-zap-btn-width);\n cursor: pointer;\n transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;\n font-family: inherit;\n font-size: inherit;\n }\n\n /* Hover state on the button */\n .nostr-zap-button:hover {\n background: var(--nostrc-zap-btn-hover-bg);\n color: var(--nostrc-zap-btn-hover-color);\n border: var(--nostrc-zap-btn-hover-border);\n }\n\n .nostr-zap-button:disabled {\n pointer-events: none;\n user-select: none;\n opacity: 0.6;\n }\n\n :host:not([user-status=\"ready\"]) .nostr-zap-button {\n cursor: not-allowed;\n }\n\n /* SVG Icon Styles */\n .nostr-zap-button svg {\n display: inline-block;\n vertical-align: middle;\n width: var(--nostrc-icon-width);\n height: var(--nostrc-icon-height);\n }\n\n /* Total zap amount display */\n .total-zap-amount {\n font-size: var(--nostrc-font-size-sm);\n color: var(--nostrc-theme-text-secondary, #666666);\n white-space: nowrap;\n }\n\n /* Clickable zap amount */\n .total-zap-amount.clickable {\n cursor: pointer;\n transition: color 0.2s ease;\n }\n\n .total-zap-amount.clickable:hover {\n color: var(--nostrc-color-primary, #7f00ff);\n }\n\n /* Help icon */\n .help-icon {\n background: none;\n border: 1px solid var(--nostrc-color-border, #e0e0e0);\n border-radius: var(--nostrc-border-radius-full, 50%);\n width: var(--nostrc-help-icon-size, 16px);\n height: var(--nostrc-help-icon-size, 16px);\n font-size: calc(var(--nostrc-help-icon-size, 16px) * 0.7);\n font-weight: bold;\n color: var(--nostrc-theme-text-secondary, #666666);\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: var(--nostrc-spacing-xs, 4px);\n transition: all 0.2s ease;\n }\n\n .help-icon:hover {\n background: var(--nostrc-color-hover-background, rgba(0, 0, 0, 0.05));\n border-color: var(--nostrc-color-primary, #7f00ff);\n color: var(--nostrc-color-primary, #7f00ff);\n }\n\n /* Skeleton loader for zap amount */\n .total-zap-amount.skeleton {\n background: linear-gradient(90deg, \n var(--nostrc-color-skeleton, #f0f0f0) 25%, \n var(--nostrc-color-skeleton-highlight, #e0e0e0) 50%, \n var(--nostrc-color-skeleton, #f0f0f0) 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n border-radius: var(--nostrc-border-radius-sm);\n width: 80px;\n height: 1.2em;\n display: inline-block;\n }\n\n /* Skeleton loader for button text */\n .button-text-skeleton {\n background: linear-gradient(90deg, \n var(--nostrc-color-skeleton, #f0f0f0) 25%, \n var(--nostrc-color-skeleton-highlight, #e0e0e0) 50%, \n var(--nostrc-color-skeleton, #f0f0f0) 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n border-radius: var(--nostrc-border-radius-sm);\n width: 60px;\n height: 1em;\n display: inline-block;\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 /* Error message styling */\n .nostr-zap-button-error small {\n color: var(--nostrc-color-error-text);\n font-size: var(--nostrc-font-size-sm);\n line-height: 1em;\n max-width: 250px;\n white-space: pre-line;\n }\n `;\n \n return getComponentStyles(customStyles);\n}\n\n","// SPDX-License-Identifier: MIT\n\nimport { NostrUserComponent } from '../base/user-component/nostr-user-component';\nimport { NCStatus } from '../base/base-component/nostr-base-component';\nimport { init as openZapModal } from './dialog-zap';\nimport { showHelpDialog } from './dialog-help';\nimport { openZappersDialog } from './dialog-zappers';\nimport { renderZapButton, RenderZapButtonOptions } from './render';\nimport { getZapButtonStyles } from './style';\nimport { fetchTotalZapAmount, ZapDetails } from './zap-utils';\nimport { isValidUrl } from '../common/utils';\nimport type { DialogComponent } from '../base/dialog-component/dialog-component';\nimport { ensureInitialized } from '../common/nostr-login-service';\n\n/**\n * <nostr-zap>\n * Attributes:\n * - npub | pubkey | nip05 (required) : Nostr user to zap\n * - relays (optional) : comma-separated relay URLs\n * - theme (optional) : \"light\" | \"dark\" (default light)\n * - text (optional) : custom text (default \"Zap\")\n * - amount (optional) : pre-defined zap amount in sats\n * - default-amount (optional) : default zap amount in sats (default 21)\n * - url (optional) : URL to send zap to (enables URL-based zaps)\n * \n * TODO: Doesn't yet support dynamic updates of attributes.\n */\nexport default class NostrZap extends NostrUserComponent {\n protected zapActionStatus= this.channel('zapAction');\n protected zapListStatus = this.channel('zapList');\n \n private totalZapAmount: number | null = null;\n private cachedZapDetails: ZapDetails[] = [];\n private cachedAmountDialog: DialogComponent | null = null;\n\n constructor() {\n super();\n this.zapListStatus.set(NCStatus.Loading);\n }\n\n connectedCallback() {\n super.connectedCallback?.();\n this.attachDelegatedListeners();\n this.render();\n }\n\n static get observedAttributes() {\n return [\n ...super.observedAttributes,\n 'text',\n 'amount',\n 'default-amount',\n 'url'\n ];\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue === newValue) return;\n super.attributeChangedCallback(name, oldValue, newValue);\n // TODO: To handle text, amount, and default-amount changes?\n this.render();\n }\n\n disconnectedCallback() {\n if (\n this.cachedAmountDialog &&\n typeof this.cachedAmountDialog.close === \"function\"\n ) {\n this.cachedAmountDialog.close();\n }\n }\n\n /** Base class functions */\n protected onStatusChange(_status: NCStatus) {\n this.render();\n }\n\n protected onUserReady(_user: any, _profile: any) {\n this.render();\n this.updateZapCount();\n }\n\n /** Protected methods */\n protected validateInputs(): boolean {\n if (!super.validateInputs()) {\n this.zapActionStatus.set(NCStatus.Idle);\n this.zapListStatus.set(NCStatus.Idle);\n return false;\n }\n\n const textAttr = this.getAttribute(\"text\");\n const amtAttr = this.getAttribute(\"amount\");\n const defaultAmtAttr= this.getAttribute(\"default-amount\");\n const urlAttr = this.getAttribute(\"url\");\n const tagName = this.tagName.toLowerCase();\n\n let errorMessage: string | null = null;\n\n if (textAttr && textAttr.length > 128) {\n errorMessage = \"Max text length: 128 characters\";\n } else if (amtAttr) {\n const num = Number(amtAttr);\n if (isNaN(num) || num <= 0) {\n errorMessage = \"Invalid amount\";\n } else if (num > 210000) {\n errorMessage = \"Amount too high (max 210,000 sats)\";\n }\n } else if (defaultAmtAttr) {\n const num = Number(defaultAmtAttr);\n if (isNaN(num) || num <= 0) {\n errorMessage = \"Invalid default-amount\";\n } else if (num > 210000) {\n errorMessage = \"Default-amount too high (max 210,000 sats)\";\n }\n } else if (urlAttr) {\n if (!isValidUrl(urlAttr)) {\n errorMessage = \"Invalid URL format\";\n }\n }\n\n if (errorMessage) {\n this.zapActionStatus.set(NCStatus.Error, errorMessage);\n this.zapListStatus.set(NCStatus.Error, errorMessage);\n this.userStatus.set(NCStatus.Idle);\n console.error(`Nostr-Components: ${tagName}: ${errorMessage}`);\n return false;\n }\n\n return true;\n }\n\n /** Private functions */\n private async handleZapClick() {\n if (this.userStatus.get() !== NCStatus.Ready) return;\n\n this.zapActionStatus.set(NCStatus.Loading);\n this.render();\n\n try {\n // Ensure NostrLogin is initialized (sets up window.nostr)\n await ensureInitialized();\n\n if (!this.user) {\n this.zapActionStatus.set(NCStatus.Error, \"Could not resolve user to zap.\");\n this.render();\n return;\n }\n\n const relays = this.getRelays().join(\",\");\n const npub = this.user.npub;\n\n this.cachedAmountDialog = await openZapModal({\n npub,\n relays,\n cachedDialogComponent: this.cachedAmountDialog,\n theme: this.theme === 'dark' ? 'dark' : 'light',\n fixedAmount: (() => {\n const amtAttr = this.getAttribute(\"amount\");\n if (!amtAttr) return undefined;\n const num = Number(amtAttr);\n if (isNaN(num) || num <= 0 || num > 210000) {\n console.error(\"Nostr-Components: Zap button: Max zap amount: 210,000 sats\");\n return undefined;\n }\n return num;\n })(),\n defaultAmount: (() => {\n const defAttr = this.getAttribute(\"default-amount\");\n if (!defAttr) return 21;\n const num = Number(defAttr);\n if (isNaN(num) || num <= 0 || num > 210000) {\n console.error(\"Nostr-Components: Zap button: Max zap amount: 210,000 sats\");\n return 21;\n }\n return num;\n })(),\n url: this.getAttribute(\"url\") || undefined,\n anon: false,\n });\n this.zapActionStatus.set(NCStatus.Ready);\n } catch (e: any) {\n this.zapActionStatus.set(NCStatus.Error, e?.message || \"Unable to zap\");\n } finally {\n this.render();\n }\n }\n\n private async handleHelpClick() {\n try {\n await showHelpDialog(this.theme === 'dark' ? 'dark' : 'light');\n } catch (error) {\n console.error('Error showing help dialog:', error);\n }\n }\n\n private async handleZappersClick() {\n if (this.cachedZapDetails.length === 0) {\n return; // No zaps to show\n }\n\n try {\n await openZappersDialog({\n zapDetails: this.cachedZapDetails,\n theme: this.theme === 'dark' ? 'dark' : 'light',\n });\n } catch (error) {\n console.error(\"Nostr-Components: Zap button: Error opening zappers dialog\", error);\n }\n }\n\n private attachDelegatedListeners() {\n this.delegateEvent('click', '.nostr-zap-button', (e) => {\n e.preventDefault?.();\n e.stopPropagation?.();\n void this.handleZapClick();\n });\n\n this.delegateEvent('click', '.help-icon', (e) => {\n e.preventDefault?.();\n e.stopPropagation?.();\n this.handleHelpClick();\n });\n\n this.delegateEvent('click', '.total-zap-amount', (e) => {\n e.preventDefault?.();\n e.stopPropagation?.();\n void this.handleZappersClick();\n });\n }\n\n private async updateZapCount() {\n if (!this.user) return;\n\n try {\n this.zapListStatus.set(NCStatus.Loading);\n this.render();\n \n await this.ensureNostrConnected();\n const result = await fetchTotalZapAmount({ \n pubkey: this.user.pubkey, \n relays: this.getRelays(),\n url: this.getAttribute(\"url\") || undefined\n });\n this.totalZapAmount = result.totalAmount;\n this.cachedZapDetails = result.zapDetails;\n this.zapListStatus.set(NCStatus.Ready);\n } catch (e) {\n console.error(\"Nostr-Components: Zap button: Failed to fetch zap count\", e);\n this.totalZapAmount = null;\n this.zapListStatus.set(NCStatus.Error);\n } finally {\n this.render();\n }\n }\n\n protected renderContent() {\n const isUserLoading = this.userStatus.get() == NCStatus.Loading;\n const isAmountLoading = this.zapListStatus.get() == NCStatus.Loading;\n const isError = this.computeOverall() === NCStatus.Error;\n const errorMessage = this.errorMessage;\n const buttonText = this.getAttribute('text') || 'Zap';\n\n const renderOptions: RenderZapButtonOptions = {\n isLoading: isUserLoading,\n isAmountLoading: isAmountLoading,\n isError: isError,\n isSuccess: false, // TODO: Add success state handling\n errorMessage: errorMessage,\n buttonText: buttonText,\n totalZapAmount: this.totalZapAmount,\n hasZaps: this.cachedZapDetails.length > 0,\n };\n\n this.shadowRoot!.innerHTML = `\n ${getZapButtonStyles()}\n ${renderZapButton(renderOptions)}\n `;\n }\n}\n\ncustomElements.define(\"nostr-zap\", NostrZap);\n"],"file":"components/nostr-zap.es.js"}
1
+ {"version":3,"mappings":";81BAMO,MAAMA,GAAkB,CAACC,EAA0B,UAAoB,CAC5E,MAAMC,EAASD,IAAU,OAEzB,MAAO;AAAA;AAAA;AAAA;AAAA,eAIMC,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAoBnBA,EAAS,UAAY,SAAS;AAAA;AAAA,oBAEpCA,EAAS,UAAY,SAAS;AAAA;AAAA;AAAA,eAGnCA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAsCnBA,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;AAAA;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AAzJ,EAAE,kBAAF,MAAAyJ,EAAA,KAAAzJ,GACK,KAAK,oBACZ,CAAC,CACH,CAEA,MAAc,gBAAiB,CAC7B,GAAK,KAAK,KAEV,GAAI,CACF,KAAK,cAAc,IAAI0I,EAAS,OAAO,EACvC,KAAK,SAEL,MAAM,KAAK,uBACX,MAAM5W,EAAS,MAAM4X,GAAoB,CACvC,OAAQ,KAAK,KAAK,OAClB,OAAQ,KAAK,YACb,IAAK,KAAK,aAAa,KAAK,GAAK,OAClC,EACD,KAAK,eAAiB5X,EAAO,YAC7B,KAAK,iBAAmBA,EAAO,WAC/B,KAAK,cAAc,IAAI4W,EAAS,KAAK,CACvC,OAAS1I,EAAG,CACV,QAAQ,MAAM,0DAA2DA,CAAC,EAC1E,KAAK,eAAiB,KACtB,KAAK,cAAc,IAAI0I,EAAS,KAAK,CACvC,SACE,KAAK,QACP,CACF,CAEU,eAAgB,CACxB,MAAMiB,EAAgB,KAAK,WAAW,OAASjB,EAAS,QAClDhB,EAAkB,KAAK,cAAc,OAASgB,EAAS,QACvDrB,EAAU,KAAK,mBAAqBqB,EAAS,MAC7CnB,EAAe,KAAK,aACpBC,EAAa,KAAK,aAAa,MAAM,GAAK,MAE1CoC,EAAwC,CAC5C,UAAWD,EACX,gBAAAjC,EACA,QAAAL,EACA,UAAW,GACX,aAAAE,EACA,WAAAC,EACA,eAAgB,KAAK,eACrB,QAAS,KAAK,iBAAiB,OAAS,GAG1C,KAAK,WAAY,UAAY;AAAA,QACzBc,IAAoB;AAAA,QACpBnB,GAAgByC,CAAa,CAAC;AAAA,KAEpC,CACF,CAEK,eAAe,IAAI,WAAW,GACjC,eAAe,OAAO,YAAarB,EAAQ","names":["getDialogStyles","theme","isDark","canPromise","toSJISFunction","CODEWORDS_COUNT","utils","version","data","digit","f","kanji","exports","fromString","string","level","value","defaultValue","BitBuffer","index","bufIndex","num","length","i","bit","bitBuffer","BitMatrix","size","row","col","reserved","bitMatrix","getSymbolSize","require$$0","posCount","intervals","positions","coords","pos","posLength","j","FINDER_PATTERN_SIZE","finderPattern","PenaltyScores","mask","points","sameCountCol","sameCountRow","lastCol","lastRow","module","last","bitsCol","bitsRow","darkCount","modulesCount","getMaskAt","maskPattern","pattern","setupFormatFunc","numPatterns","bestPattern","lowerPenalty","p","penalty","ECLevel","EC_BLOCKS_TABLE","EC_CODEWORDS_TABLE","errorCorrectionCode","errorCorrectionLevel","EXP_TABLE","LOG_TABLE","x","galoisField","n","y","GF","p1","p2","coeff","divident","divisor","result","offset","degree","poly","Polynomial","ReedSolomonEncoder","paddedData","remainder","start","buff","reedSolomonEncoder","versionCheck","numeric","alphanumeric","byte","regex","TEST_KANJI","TEST_NUMERIC","TEST_ALPHANUMERIC","str","VersionCheck","Regex","require$$1","mode","dataStr","Utils","ECCode","require$$2","Mode","require$$3","require$$4","G18","G18_BCH","getBestVersionForDataLength","currentVersion","getReservedBitsCount","getTotalBitsFromDataArray","segments","totalBits","reservedBits","getBestVersionForMixedData","totalCodewords","ecTotalCodewords","dataTotalCodewordsBits","usableBits","seg","ecl","d","G15","G15_MASK","G15_BCH","formatInfo","NumericData","group","remainingNum","numericData","ALPHA_NUM_CHARS","AlphanumericData","alphanumericData","ByteData","l","byteData","KanjiData","kanjiData","dijkstra","graph","s","predecessors","costs","open","closest","u","v","cost_of_s_to_u","adjacent_nodes","cost_of_e","cost_of_s_to_u_plus_cost_of_e","cost_of_s_to_v","first_visit","msg","nodes","opts","T","t","key","a","b","cost","item","require$$5","require$$6","require$$7","getStringByteLength","getSegments","getSegmentsFromString","numSegs","alphaNumSegs","byteSegs","kanjiSegs","s1","s2","obj","getSegmentBitsLength","mergeSegments","segs","acc","curr","prevSeg","buildNodes","buildGraph","table","prevNodeIds","nodeGroup","currentNodeIds","node","prevNodeId","buildSingleSegment","modesHint","bestMode","array","path","optimizedSegs","AlignmentPattern","FinderPattern","MaskPattern","require$$8","Version","require$$9","FormatInfo","require$$10","require$$11","Segments","require$$12","setupFinderPattern","matrix","r","setupTimingPattern","setupAlignmentPattern","c","setupVersionInfo","bits","mod","setupFormatInfo","setupData","inc","bitIndex","byteIndex","dark","createData","buffer","remainingByte","createCodewords","dataTotalCodewords","ecTotalBlocks","blocksInGroup2","blocksInGroup1","totalCodewordsInGroup1","dataCodewordsInGroup1","dataCodewordsInGroup2","ecCount","rs","dcData","ecData","maxDataSize","dataSize","createSymbol","estimatedVersion","rawSegments","bestVersion","dataBits","moduleCount","modules","qrcode","options","hex2rgba","hex","hexCode","hexValue","margin","width","scale","qrSize","imgData","qr","symbolSize","scaledMargin","palette","posDst","pxColor","iSrc","jSrc","clearCanvas","ctx","canvas","getCanvasElement","qrData","canvasEl","image","type","rendererOpts","getColorAttrib","color","attrib","alpha","svgCmd","cmd","qrToPath","moveBy","newRow","lineLength","svgTag","cb","qrcodesize","bg","viewBox","QRCode","CanvasRenderer","SvgRenderer","renderCanvas","renderFunc","text","args","argsNum","isLastArgCb","resolve","reject","e","toDataURL","_","injectCSS","style","init","params","npub","relays","cachedDialogComponent","buttonColor","fixedAmount","defaultAmount","initialAmount","url","npubHex","decodeNpub","cachedDialog","el","updateZapBtn","successOverlay","refreshUI","presets","selectedAmount","customComment","currentInvoice","cleanupReceipt","loadInvoice","amountSats","comment","authorId","meta","getProfileMetadata","endpoint","getZapEndpoint","invoice","fetchInvoice","relaysArr","listenForZapReceipt","markSuccess","qrImgSrc","QRCode.toDataURL","error","setActiveAmountButtons","container","amt","btn","dialog","qrImg","src","payBtn","dialogComponent","amountButtonsHtml","hideAmountUI","dialogElement","_a","amountContainer","target","val","customAmountInput","commentInput","copyInvoice","addCommentBtn","overlay","btnColor","getContrastingTextColor","input","ch","g","getHelpDialogStyles","YOUTUBE_URL","injectHelpDialogStyles","showHelpDialog","getZappersDialogStyles","getComponentStyles","injectZappersDialogStyles","renderZapEntry","zap","authorNameSafe","escapeHtml","njumpUrl","isValidPublicKey","profilePictureSafe","isValidUrl","profilePicture","commentHtml","formatRelativeTime","renderSkeletonZapEntry","openZappersDialog","zapDetails","initialContent","renderInitialContent","enhanceZapDetailsProgressively","npubs","hexToNpub","zappersList","uniqueAuthorIds","profileResults","getBatchedProfileMetadata","profileMap","npubMap","pubkey","profile","enhanced","profileContent","extractProfileMetadataContent","skeletonEntry","enhancedEntry","enhanceZapDetailsIndividually","profileCache","profilePromises","cachedProfile","__vitePreload","profileMetadata","promise","renderZapButton","isLoading","isError","isSuccess","errorMessage","buttonText","totalZapAmount","isAmountLoading","hasZaps","renderError","renderLoading","iconContent","getLightningIcon","textContent","renderContainer","renderErrorContainer","leftContent","rightContent","zapAmountHtml","getZapButtonStyles","NostrZap","NostrUserComponent","__publicField","NCStatus","name","oldValue","newValue","_status","_user","_profile","textAttr","amtAttr","defaultAmtAttr","urlAttr","tagName","ensureInitialized","openZapModal","defAttr","_b","fetchTotalZapAmount","isUserLoading","renderOptions"],"ignoreList":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],"sources":["../../src/nostr-zap/dialog-zap-style.ts","../../node_modules/qrcode/lib/can-promise.js","../../node_modules/qrcode/lib/core/utils.js","../../node_modules/qrcode/lib/core/error-correction-level.js","../../node_modules/qrcode/lib/core/bit-buffer.js","../../node_modules/qrcode/lib/core/bit-matrix.js","../../node_modules/qrcode/lib/core/alignment-pattern.js","../../node_modules/qrcode/lib/core/finder-pattern.js","../../node_modules/qrcode/lib/core/mask-pattern.js","../../node_modules/qrcode/lib/core/error-correction-code.js","../../node_modules/qrcode/lib/core/galois-field.js","../../node_modules/qrcode/lib/core/polynomial.js","../../node_modules/qrcode/lib/core/reed-solomon-encoder.js","../../node_modules/qrcode/lib/core/version-check.js","../../node_modules/qrcode/lib/core/regex.js","../../node_modules/qrcode/lib/core/mode.js","../../node_modules/qrcode/lib/core/version.js","../../node_modules/qrcode/lib/core/format-info.js","../../node_modules/qrcode/lib/core/numeric-data.js","../../node_modules/qrcode/lib/core/alphanumeric-data.js","../../node_modules/qrcode/lib/core/byte-data.js","../../node_modules/qrcode/lib/core/kanji-data.js","../../node_modules/dijkstrajs/dijkstra.js","../../node_modules/qrcode/lib/core/segments.js","../../node_modules/qrcode/lib/core/qrcode.js","../../node_modules/qrcode/lib/renderer/utils.js","../../node_modules/qrcode/lib/renderer/canvas.js","../../node_modules/qrcode/lib/renderer/svg-tag.js","../../node_modules/qrcode/lib/browser.js","../../src/nostr-zap/dialog-zap.ts","../../src/nostr-zap/dialog-help-style.ts","../../src/nostr-zap/dialog-help.ts","../../src/nostr-zap/dialog-zappers-style.ts","../../src/nostr-zap/dialog-zappers.ts","../../src/nostr-zap/render.ts","../../src/nostr-zap/style.ts","../../src/nostr-zap/nostr-zap.ts"],"sourcesContent":["/**\n * Dialog styles for nostr-zap component\n * Extracted from dialog.ts for better organization\n * Uses CSS variables from nostr-zap component for consistency\n */\n\nexport const getDialogStyles = (theme: 'light' | 'dark' = 'light'): string => {\n const isDark = theme === 'dark';\n \n return `\n /* === ZAP DIALOG CONTENT STYLES === */\n .zap-dialog-content {\n text-align: center;\n color: ${isDark ? '#ffffff' : '#000000'};\n }\n\n .zap-dialog-content p {\n margin: 4px 0;\n word-break: break-word;\n }\n\n /* === AMOUNT BUTTONS === */\n .zap-dialog-content .amount-buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin: 16px 0 8px;\n }\n\n .zap-dialog-content .amount-buttons button {\n flex: 1 1 30%;\n min-width: 72px;\n padding: 8px 0;\n border: 1px solid ${isDark ? '#3a3a3a' : '#e2e8f0'};\n border-radius: 6px;\n background: ${isDark ? '#262626' : '#f7fafc'};\n cursor: pointer;\n font-size: 14px;\n color: ${isDark ? '#ffffff' : '#000000'};\n }\n\n .zap-dialog-content .amount-buttons button.active {\n background: #7f00ff;\n color: #ffffff;\n }\n\n /* === ACTION BUTTONS === */\n .zap-dialog-content .cta-btn {\n width: 100%;\n padding: 12px 0;\n border: none;\n border-radius: 6px;\n font-size: 16px;\n margin-top: 16px;\n cursor: pointer;\n background: #7f00ff;\n color: #ffffff;\n }\n\n .zap-dialog-content .copy-btn {\n margin-top: 12px;\n cursor: pointer;\n font-size: 14px;\n background: none;\n border: none;\n color: #7f00ff;\n }\n\n .zap-dialog-content .update-zap-btn {\n background: #7f00ff;\n color: #ffffff;\n }\n\n /* === QR CODE === */\n .zap-dialog-content img.qr {\n margin-top: 16px;\n border: 1px solid ${isDark ? '#3a3a3a' : '#e2e8f0'};\n border-radius: 8px;\n }\n\n /* === INPUT CONTAINERS === */\n .zap-dialog-content .update-zap-container {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-top: 8px;\n }\n\n .zap-dialog-content .update-zap-container .custom-amount {\n flex-grow: 1;\n }\n\n .zap-dialog-content .comment-container {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-top: 8px;\n }\n\n .zap-dialog-content .comment-container .comment-input {\n flex-grow: 1;\n }\n\n .zap-dialog-content input {\n background: ${isDark ? '#262626' : '#ffffff'};\n border: 1px solid ${isDark ? '#3a3a3a' : '#e2e8f0'};\n color: ${isDark ? '#ffffff' : '#000000'};\n }\n\n /* === LOADING OVERLAY === */\n .nostr-base-dialog .loading-overlay {\n position: absolute;\n inset: 0;\n background: ${isDark ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)'};\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 10px;\n opacity: 0;\n transition: opacity 0.2s ease;\n pointer-events: none;\n }\n\n .nostr-base-dialog.loading .loading-overlay {\n opacity: 1;\n pointer-events: auto;\n }\n\n .nostr-base-dialog .loading-overlay .loader {\n width: 40px;\n height: 40px;\n border: 4px solid ${isDark ? '#3a3a3a' : '#ccc'};\n border-top-color: #7f00ff;\n border-radius: 50%;\n animation: nstrc-spin 1s linear infinite;\n }\n\n /* === SUCCESS OVERLAY === */\n .nostr-base-dialog .success-overlay {\n position: absolute;\n inset: 0;\n background: rgba(0, 0, 0, 0.65);\n display: flex;\n justify-content: center;\n align-items: center;\n color: #ffffff;\n font-size: 24px;\n border-radius: 10px;\n opacity: 0;\n transition: opacity 0.3s ease;\n pointer-events: none;\n }\n\n .nostr-base-dialog.success .success-overlay {\n opacity: 1;\n pointer-events: auto;\n }\n\n /* === ANIMATIONS === */\n @keyframes nstrc-spin {\n to {\n transform: rotate(360deg);\n }\n }\n `;\n};","// can-promise has a crash in some versions of react native that dont have\n// standard global objects\n// https://github.com/soldair/node-qrcode/issues/157\n\nmodule.exports = function () {\n return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then\n}\n","let toSJISFunction\nconst CODEWORDS_COUNT = [\n 0, // Not used\n 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,\n 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,\n 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,\n 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706\n]\n\n/**\n * Returns the QR Code size for the specified version\n *\n * @param {Number} version QR Code version\n * @return {Number} size of QR code\n */\nexports.getSymbolSize = function getSymbolSize (version) {\n if (!version) throw new Error('\"version\" cannot be null or undefined')\n if (version < 1 || version > 40) throw new Error('\"version\" should be in range from 1 to 40')\n return version * 4 + 17\n}\n\n/**\n * Returns the total number of codewords used to store data and EC information.\n *\n * @param {Number} version QR Code version\n * @return {Number} Data length in bits\n */\nexports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {\n return CODEWORDS_COUNT[version]\n}\n\n/**\n * Encode data with Bose-Chaudhuri-Hocquenghem\n *\n * @param {Number} data Value to encode\n * @return {Number} Encoded value\n */\nexports.getBCHDigit = function (data) {\n let digit = 0\n\n while (data !== 0) {\n digit++\n data >>>= 1\n }\n\n return digit\n}\n\nexports.setToSJISFunction = function setToSJISFunction (f) {\n if (typeof f !== 'function') {\n throw new Error('\"toSJISFunc\" is not a valid function.')\n }\n\n toSJISFunction = f\n}\n\nexports.isKanjiModeEnabled = function () {\n return typeof toSJISFunction !== 'undefined'\n}\n\nexports.toSJIS = function toSJIS (kanji) {\n return toSJISFunction(kanji)\n}\n","exports.L = { bit: 1 }\nexports.M = { bit: 0 }\nexports.Q = { bit: 3 }\nexports.H = { bit: 2 }\n\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'l':\n case 'low':\n return exports.L\n\n case 'm':\n case 'medium':\n return exports.M\n\n case 'q':\n case 'quartile':\n return exports.Q\n\n case 'h':\n case 'high':\n return exports.H\n\n default:\n throw new Error('Unknown EC Level: ' + string)\n }\n}\n\nexports.isValid = function isValid (level) {\n return level && typeof level.bit !== 'undefined' &&\n level.bit >= 0 && level.bit < 4\n}\n\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n","function BitBuffer () {\n this.buffer = []\n this.length = 0\n}\n\nBitBuffer.prototype = {\n\n get: function (index) {\n const bufIndex = Math.floor(index / 8)\n return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1\n },\n\n put: function (num, length) {\n for (let i = 0; i < length; i++) {\n this.putBit(((num >>> (length - i - 1)) & 1) === 1)\n }\n },\n\n getLengthInBits: function () {\n return this.length\n },\n\n putBit: function (bit) {\n const bufIndex = Math.floor(this.length / 8)\n if (this.buffer.length <= bufIndex) {\n this.buffer.push(0)\n }\n\n if (bit) {\n this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))\n }\n\n this.length++\n }\n}\n\nmodule.exports = BitBuffer\n","/**\n * Helper class to handle QR Code symbol modules\n *\n * @param {Number} size Symbol size\n */\nfunction BitMatrix (size) {\n if (!size || size < 1) {\n throw new Error('BitMatrix size must be defined and greater than 0')\n }\n\n this.size = size\n this.data = new Uint8Array(size * size)\n this.reservedBit = new Uint8Array(size * size)\n}\n\n/**\n * Set bit value at specified location\n * If reserved flag is set, this bit will be ignored during masking process\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n * @param {Boolean} reserved\n */\nBitMatrix.prototype.set = function (row, col, value, reserved) {\n const index = row * this.size + col\n this.data[index] = value\n if (reserved) this.reservedBit[index] = true\n}\n\n/**\n * Returns bit value at specified location\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.get = function (row, col) {\n return this.data[row * this.size + col]\n}\n\n/**\n * Applies xor operator at specified location\n * (used during masking process)\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n */\nBitMatrix.prototype.xor = function (row, col, value) {\n this.data[row * this.size + col] ^= value\n}\n\n/**\n * Check if bit at specified location is reserved\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.isReserved = function (row, col) {\n return this.reservedBit[row * this.size + col]\n}\n\nmodule.exports = BitMatrix\n","/**\n * Alignment pattern are fixed reference pattern in defined positions\n * in a matrix symbology, which enables the decode software to re-synchronise\n * the coordinate mapping of the image modules in the event of moderate amounts\n * of distortion of the image.\n *\n * Alignment patterns are present only in QR Code symbols of version 2 or larger\n * and their number depends on the symbol version.\n */\n\nconst getSymbolSize = require('./utils').getSymbolSize\n\n/**\n * Calculate the row/column coordinates of the center module of each alignment pattern\n * for the specified QR Code version.\n *\n * The alignment patterns are positioned symmetrically on either side of the diagonal\n * running from the top left corner of the symbol to the bottom right corner.\n *\n * Since positions are simmetrical only half of the coordinates are returned.\n * Each item of the array will represent in turn the x and y coordinate.\n * @see {@link getPositions}\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinate\n */\nexports.getRowColCoords = function getRowColCoords (version) {\n if (version === 1) return []\n\n const posCount = Math.floor(version / 7) + 2\n const size = getSymbolSize(version)\n const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2\n const positions = [size - 7] // Last coord is always (size - 7)\n\n for (let i = 1; i < posCount - 1; i++) {\n positions[i] = positions[i - 1] - intervals\n }\n\n positions.push(6) // First coord is always 6\n\n return positions.reverse()\n}\n\n/**\n * Returns an array containing the positions of each alignment pattern.\n * Each array's element represent the center point of the pattern as (x, y) coordinates\n *\n * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}\n * and filtering out the items that overlaps with finder pattern\n *\n * @example\n * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.\n * The alignment patterns, therefore, are to be centered on (row, column)\n * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).\n * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns\n * and are not therefore used for alignment patterns.\n *\n * let pos = getPositions(7)\n * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinates\n */\nexports.getPositions = function getPositions (version) {\n const coords = []\n const pos = exports.getRowColCoords(version)\n const posLength = pos.length\n\n for (let i = 0; i < posLength; i++) {\n for (let j = 0; j < posLength; j++) {\n // Skip if position is occupied by finder patterns\n if ((i === 0 && j === 0) || // top-left\n (i === 0 && j === posLength - 1) || // bottom-left\n (i === posLength - 1 && j === 0)) { // top-right\n continue\n }\n\n coords.push([pos[i], pos[j]])\n }\n }\n\n return coords\n}\n","const getSymbolSize = require('./utils').getSymbolSize\nconst FINDER_PATTERN_SIZE = 7\n\n/**\n * Returns an array containing the positions of each finder pattern.\n * Each array's element represent the top-left point of the pattern as (x, y) coordinates\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinates\n */\nexports.getPositions = function getPositions (version) {\n const size = getSymbolSize(version)\n\n return [\n // top-left\n [0, 0],\n // top-right\n [size - FINDER_PATTERN_SIZE, 0],\n // bottom-left\n [0, size - FINDER_PATTERN_SIZE]\n ]\n}\n","/**\n * Data mask pattern reference\n * @type {Object}\n */\nexports.Patterns = {\n PATTERN000: 0,\n PATTERN001: 1,\n PATTERN010: 2,\n PATTERN011: 3,\n PATTERN100: 4,\n PATTERN101: 5,\n PATTERN110: 6,\n PATTERN111: 7\n}\n\n/**\n * Weighted penalty scores for the undesirable features\n * @type {Object}\n */\nconst PenaltyScores = {\n N1: 3,\n N2: 3,\n N3: 40,\n N4: 10\n}\n\n/**\n * Check if mask pattern value is valid\n *\n * @param {Number} mask Mask pattern\n * @return {Boolean} true if valid, false otherwise\n */\nexports.isValid = function isValid (mask) {\n return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7\n}\n\n/**\n * Returns mask pattern from a value.\n * If value is not valid, returns undefined\n *\n * @param {Number|String} value Mask pattern value\n * @return {Number} Valid mask pattern or undefined\n */\nexports.from = function from (value) {\n return exports.isValid(value) ? parseInt(value, 10) : undefined\n}\n\n/**\n* Find adjacent modules in row/column with the same color\n* and assign a penalty value.\n*\n* Points: N1 + i\n* i is the amount by which the number of adjacent modules of the same color exceeds 5\n*/\nexports.getPenaltyN1 = function getPenaltyN1 (data) {\n const size = data.size\n let points = 0\n let sameCountCol = 0\n let sameCountRow = 0\n let lastCol = null\n let lastRow = null\n\n for (let row = 0; row < size; row++) {\n sameCountCol = sameCountRow = 0\n lastCol = lastRow = null\n\n for (let col = 0; col < size; col++) {\n let module = data.get(row, col)\n if (module === lastCol) {\n sameCountCol++\n } else {\n if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)\n lastCol = module\n sameCountCol = 1\n }\n\n module = data.get(col, row)\n if (module === lastRow) {\n sameCountRow++\n } else {\n if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)\n lastRow = module\n sameCountRow = 1\n }\n }\n\n if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)\n if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)\n }\n\n return points\n}\n\n/**\n * Find 2x2 blocks with the same color and assign a penalty value\n *\n * Points: N2 * (m - 1) * (n - 1)\n */\nexports.getPenaltyN2 = function getPenaltyN2 (data) {\n const size = data.size\n let points = 0\n\n for (let row = 0; row < size - 1; row++) {\n for (let col = 0; col < size - 1; col++) {\n const last = data.get(row, col) +\n data.get(row, col + 1) +\n data.get(row + 1, col) +\n data.get(row + 1, col + 1)\n\n if (last === 4 || last === 0) points++\n }\n }\n\n return points * PenaltyScores.N2\n}\n\n/**\n * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,\n * preceded or followed by light area 4 modules wide\n *\n * Points: N3 * number of pattern found\n */\nexports.getPenaltyN3 = function getPenaltyN3 (data) {\n const size = data.size\n let points = 0\n let bitsCol = 0\n let bitsRow = 0\n\n for (let row = 0; row < size; row++) {\n bitsCol = bitsRow = 0\n for (let col = 0; col < size; col++) {\n bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)\n if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++\n\n bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)\n if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++\n }\n }\n\n return points * PenaltyScores.N3\n}\n\n/**\n * Calculate proportion of dark modules in entire symbol\n *\n * Points: N4 * k\n *\n * k is the rating of the deviation of the proportion of dark modules\n * in the symbol from 50% in steps of 5%\n */\nexports.getPenaltyN4 = function getPenaltyN4 (data) {\n let darkCount = 0\n const modulesCount = data.data.length\n\n for (let i = 0; i < modulesCount; i++) darkCount += data.data[i]\n\n const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)\n\n return k * PenaltyScores.N4\n}\n\n/**\n * Return mask value at given position\n *\n * @param {Number} maskPattern Pattern reference value\n * @param {Number} i Row\n * @param {Number} j Column\n * @return {Boolean} Mask value\n */\nfunction getMaskAt (maskPattern, i, j) {\n switch (maskPattern) {\n case exports.Patterns.PATTERN000: return (i + j) % 2 === 0\n case exports.Patterns.PATTERN001: return i % 2 === 0\n case exports.Patterns.PATTERN010: return j % 3 === 0\n case exports.Patterns.PATTERN011: return (i + j) % 3 === 0\n case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0\n case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0\n case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0\n case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0\n\n default: throw new Error('bad maskPattern:' + maskPattern)\n }\n}\n\n/**\n * Apply a mask pattern to a BitMatrix\n *\n * @param {Number} pattern Pattern reference number\n * @param {BitMatrix} data BitMatrix data\n */\nexports.applyMask = function applyMask (pattern, data) {\n const size = data.size\n\n for (let col = 0; col < size; col++) {\n for (let row = 0; row < size; row++) {\n if (data.isReserved(row, col)) continue\n data.xor(row, col, getMaskAt(pattern, row, col))\n }\n }\n}\n\n/**\n * Returns the best mask pattern for data\n *\n * @param {BitMatrix} data\n * @return {Number} Mask pattern reference number\n */\nexports.getBestMask = function getBestMask (data, setupFormatFunc) {\n const numPatterns = Object.keys(exports.Patterns).length\n let bestPattern = 0\n let lowerPenalty = Infinity\n\n for (let p = 0; p < numPatterns; p++) {\n setupFormatFunc(p)\n exports.applyMask(p, data)\n\n // Calculate penalty\n const penalty =\n exports.getPenaltyN1(data) +\n exports.getPenaltyN2(data) +\n exports.getPenaltyN3(data) +\n exports.getPenaltyN4(data)\n\n // Undo previously applied mask\n exports.applyMask(p, data)\n\n if (penalty < lowerPenalty) {\n lowerPenalty = penalty\n bestPattern = p\n }\n }\n\n return bestPattern\n}\n","const ECLevel = require('./error-correction-level')\r\n\r\nconst EC_BLOCKS_TABLE = [\r\n// L M Q H\r\n 1, 1, 1, 1,\r\n 1, 1, 1, 1,\r\n 1, 1, 2, 2,\r\n 1, 2, 2, 4,\r\n 1, 2, 4, 4,\r\n 2, 4, 4, 4,\r\n 2, 4, 6, 5,\r\n 2, 4, 6, 6,\r\n 2, 5, 8, 8,\r\n 4, 5, 8, 8,\r\n 4, 5, 8, 11,\r\n 4, 8, 10, 11,\r\n 4, 9, 12, 16,\r\n 4, 9, 16, 16,\r\n 6, 10, 12, 18,\r\n 6, 10, 17, 16,\r\n 6, 11, 16, 19,\r\n 6, 13, 18, 21,\r\n 7, 14, 21, 25,\r\n 8, 16, 20, 25,\r\n 8, 17, 23, 25,\r\n 9, 17, 23, 34,\r\n 9, 18, 25, 30,\r\n 10, 20, 27, 32,\r\n 12, 21, 29, 35,\r\n 12, 23, 34, 37,\r\n 12, 25, 34, 40,\r\n 13, 26, 35, 42,\r\n 14, 28, 38, 45,\r\n 15, 29, 40, 48,\r\n 16, 31, 43, 51,\r\n 17, 33, 45, 54,\r\n 18, 35, 48, 57,\r\n 19, 37, 51, 60,\r\n 19, 38, 53, 63,\r\n 20, 40, 56, 66,\r\n 21, 43, 59, 70,\r\n 22, 45, 62, 74,\r\n 24, 47, 65, 77,\r\n 25, 49, 68, 81\r\n]\r\n\r\nconst EC_CODEWORDS_TABLE = [\r\n// L M Q H\r\n 7, 10, 13, 17,\r\n 10, 16, 22, 28,\r\n 15, 26, 36, 44,\r\n 20, 36, 52, 64,\r\n 26, 48, 72, 88,\r\n 36, 64, 96, 112,\r\n 40, 72, 108, 130,\r\n 48, 88, 132, 156,\r\n 60, 110, 160, 192,\r\n 72, 130, 192, 224,\r\n 80, 150, 224, 264,\r\n 96, 176, 260, 308,\r\n 104, 198, 288, 352,\r\n 120, 216, 320, 384,\r\n 132, 240, 360, 432,\r\n 144, 280, 408, 480,\r\n 168, 308, 448, 532,\r\n 180, 338, 504, 588,\r\n 196, 364, 546, 650,\r\n 224, 416, 600, 700,\r\n 224, 442, 644, 750,\r\n 252, 476, 690, 816,\r\n 270, 504, 750, 900,\r\n 300, 560, 810, 960,\r\n 312, 588, 870, 1050,\r\n 336, 644, 952, 1110,\r\n 360, 700, 1020, 1200,\r\n 390, 728, 1050, 1260,\r\n 420, 784, 1140, 1350,\r\n 450, 812, 1200, 1440,\r\n 480, 868, 1290, 1530,\r\n 510, 924, 1350, 1620,\r\n 540, 980, 1440, 1710,\r\n 570, 1036, 1530, 1800,\r\n 570, 1064, 1590, 1890,\r\n 600, 1120, 1680, 1980,\r\n 630, 1204, 1770, 2100,\r\n 660, 1260, 1860, 2220,\r\n 720, 1316, 1950, 2310,\r\n 750, 1372, 2040, 2430\r\n]\r\n\r\n/**\r\n * Returns the number of error correction block that the QR Code should contain\r\n * for the specified version and error correction level.\r\n *\r\n * @param {Number} version QR Code version\r\n * @param {Number} errorCorrectionLevel Error correction level\r\n * @return {Number} Number of error correction blocks\r\n */\r\nexports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {\r\n switch (errorCorrectionLevel) {\r\n case ECLevel.L:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]\r\n case ECLevel.M:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]\r\n case ECLevel.Q:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]\r\n case ECLevel.H:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]\r\n default:\r\n return undefined\r\n }\r\n}\r\n\r\n/**\r\n * Returns the number of error correction codewords to use for the specified\r\n * version and error correction level.\r\n *\r\n * @param {Number} version QR Code version\r\n * @param {Number} errorCorrectionLevel Error correction level\r\n * @return {Number} Number of error correction codewords\r\n */\r\nexports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {\r\n switch (errorCorrectionLevel) {\r\n case ECLevel.L:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]\r\n case ECLevel.M:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]\r\n case ECLevel.Q:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]\r\n case ECLevel.H:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]\r\n default:\r\n return undefined\r\n }\r\n}\r\n","const EXP_TABLE = new Uint8Array(512)\nconst LOG_TABLE = new Uint8Array(256)\n/**\n * Precompute the log and anti-log tables for faster computation later\n *\n * For each possible value in the galois field 2^8, we will pre-compute\n * the logarithm and anti-logarithm (exponential) of this value\n *\n * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}\n */\n;(function initTables () {\n let x = 1\n for (let i = 0; i < 255; i++) {\n EXP_TABLE[i] = x\n LOG_TABLE[x] = i\n\n x <<= 1 // multiply by 2\n\n // The QR code specification says to use byte-wise modulo 100011101 arithmetic.\n // This means that when a number is 256 or larger, it should be XORed with 0x11D.\n if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)\n x ^= 0x11D\n }\n }\n\n // Optimization: double the size of the anti-log table so that we don't need to mod 255 to\n // stay inside the bounds (because we will mainly use this table for the multiplication of\n // two GF numbers, no more).\n // @see {@link mul}\n for (let i = 255; i < 512; i++) {\n EXP_TABLE[i] = EXP_TABLE[i - 255]\n }\n}())\n\n/**\n * Returns log value of n inside Galois Field\n *\n * @param {Number} n\n * @return {Number}\n */\nexports.log = function log (n) {\n if (n < 1) throw new Error('log(' + n + ')')\n return LOG_TABLE[n]\n}\n\n/**\n * Returns anti-log value of n inside Galois Field\n *\n * @param {Number} n\n * @return {Number}\n */\nexports.exp = function exp (n) {\n return EXP_TABLE[n]\n}\n\n/**\n * Multiplies two number inside Galois Field\n *\n * @param {Number} x\n * @param {Number} y\n * @return {Number}\n */\nexports.mul = function mul (x, y) {\n if (x === 0 || y === 0) return 0\n\n // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized\n // @see {@link initTables}\n return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]\n}\n","const GF = require('./galois-field')\n\n/**\n * Multiplies two polynomials inside Galois Field\n *\n * @param {Uint8Array} p1 Polynomial\n * @param {Uint8Array} p2 Polynomial\n * @return {Uint8Array} Product of p1 and p2\n */\nexports.mul = function mul (p1, p2) {\n const coeff = new Uint8Array(p1.length + p2.length - 1)\n\n for (let i = 0; i < p1.length; i++) {\n for (let j = 0; j < p2.length; j++) {\n coeff[i + j] ^= GF.mul(p1[i], p2[j])\n }\n }\n\n return coeff\n}\n\n/**\n * Calculate the remainder of polynomials division\n *\n * @param {Uint8Array} divident Polynomial\n * @param {Uint8Array} divisor Polynomial\n * @return {Uint8Array} Remainder\n */\nexports.mod = function mod (divident, divisor) {\n let result = new Uint8Array(divident)\n\n while ((result.length - divisor.length) >= 0) {\n const coeff = result[0]\n\n for (let i = 0; i < divisor.length; i++) {\n result[i] ^= GF.mul(divisor[i], coeff)\n }\n\n // remove all zeros from buffer head\n let offset = 0\n while (offset < result.length && result[offset] === 0) offset++\n result = result.slice(offset)\n }\n\n return result\n}\n\n/**\n * Generate an irreducible generator polynomial of specified degree\n * (used by Reed-Solomon encoder)\n *\n * @param {Number} degree Degree of the generator polynomial\n * @return {Uint8Array} Buffer containing polynomial coefficients\n */\nexports.generateECPolynomial = function generateECPolynomial (degree) {\n let poly = new Uint8Array([1])\n for (let i = 0; i < degree; i++) {\n poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]))\n }\n\n return poly\n}\n","const Polynomial = require('./polynomial')\n\nfunction ReedSolomonEncoder (degree) {\n this.genPoly = undefined\n this.degree = degree\n\n if (this.degree) this.initialize(this.degree)\n}\n\n/**\n * Initialize the encoder.\n * The input param should correspond to the number of error correction codewords.\n *\n * @param {Number} degree\n */\nReedSolomonEncoder.prototype.initialize = function initialize (degree) {\n // create an irreducible generator polynomial\n this.degree = degree\n this.genPoly = Polynomial.generateECPolynomial(this.degree)\n}\n\n/**\n * Encodes a chunk of data\n *\n * @param {Uint8Array} data Buffer containing input data\n * @return {Uint8Array} Buffer containing encoded data\n */\nReedSolomonEncoder.prototype.encode = function encode (data) {\n if (!this.genPoly) {\n throw new Error('Encoder not initialized')\n }\n\n // Calculate EC for this data block\n // extends data size to data+genPoly size\n const paddedData = new Uint8Array(data.length + this.degree)\n paddedData.set(data)\n\n // The error correction codewords are the remainder after dividing the data codewords\n // by a generator polynomial\n const remainder = Polynomial.mod(paddedData, this.genPoly)\n\n // return EC data blocks (last n byte, where n is the degree of genPoly)\n // If coefficients number in remainder are less than genPoly degree,\n // pad with 0s to the left to reach the needed number of coefficients\n const start = this.degree - remainder.length\n if (start > 0) {\n const buff = new Uint8Array(this.degree)\n buff.set(remainder, start)\n\n return buff\n }\n\n return remainder\n}\n\nmodule.exports = ReedSolomonEncoder\n","/**\n * Check if QR Code version is valid\n *\n * @param {Number} version QR Code version\n * @return {Boolean} true if valid version, false otherwise\n */\nexports.isValid = function isValid (version) {\n return !isNaN(version) && version >= 1 && version <= 40\n}\n","const numeric = '[0-9]+'\nconst alphanumeric = '[A-Z $%*+\\\\-./:]+'\nlet kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +\n '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +\n '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +\n '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+'\nkanji = kanji.replace(/u/g, '\\\\u')\n\nconst byte = '(?:(?![A-Z0-9 $%*+\\\\-./:]|' + kanji + ')(?:.|[\\r\\n]))+'\n\nexports.KANJI = new RegExp(kanji, 'g')\nexports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\\\-./:]+', 'g')\nexports.BYTE = new RegExp(byte, 'g')\nexports.NUMERIC = new RegExp(numeric, 'g')\nexports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')\n\nconst TEST_KANJI = new RegExp('^' + kanji + '$')\nconst TEST_NUMERIC = new RegExp('^' + numeric + '$')\nconst TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\\\-./:]+$')\n\nexports.testKanji = function testKanji (str) {\n return TEST_KANJI.test(str)\n}\n\nexports.testNumeric = function testNumeric (str) {\n return TEST_NUMERIC.test(str)\n}\n\nexports.testAlphanumeric = function testAlphanumeric (str) {\n return TEST_ALPHANUMERIC.test(str)\n}\n","const VersionCheck = require('./version-check')\nconst Regex = require('./regex')\n\n/**\n * Numeric mode encodes data from the decimal digit set (0 - 9)\n * (byte values 30HEX to 39HEX).\n * Normally, 3 data characters are represented by 10 bits.\n *\n * @type {Object}\n */\nexports.NUMERIC = {\n id: 'Numeric',\n bit: 1 << 0,\n ccBits: [10, 12, 14]\n}\n\n/**\n * Alphanumeric mode encodes data from a set of 45 characters,\n * i.e. 10 numeric digits (0 - 9),\n * 26 alphabetic characters (A - Z),\n * and 9 symbols (SP, $, %, *, +, -, ., /, :).\n * Normally, two input characters are represented by 11 bits.\n *\n * @type {Object}\n */\nexports.ALPHANUMERIC = {\n id: 'Alphanumeric',\n bit: 1 << 1,\n ccBits: [9, 11, 13]\n}\n\n/**\n * In byte mode, data is encoded at 8 bits per character.\n *\n * @type {Object}\n */\nexports.BYTE = {\n id: 'Byte',\n bit: 1 << 2,\n ccBits: [8, 16, 16]\n}\n\n/**\n * The Kanji mode efficiently encodes Kanji characters in accordance with\n * the Shift JIS system based on JIS X 0208.\n * The Shift JIS values are shifted from the JIS X 0208 values.\n * JIS X 0208 gives details of the shift coded representation.\n * Each two-byte character value is compacted to a 13-bit binary codeword.\n *\n * @type {Object}\n */\nexports.KANJI = {\n id: 'Kanji',\n bit: 1 << 3,\n ccBits: [8, 10, 12]\n}\n\n/**\n * Mixed mode will contain a sequences of data in a combination of any of\n * the modes described above\n *\n * @type {Object}\n */\nexports.MIXED = {\n bit: -1\n}\n\n/**\n * Returns the number of bits needed to store the data length\n * according to QR Code specifications.\n *\n * @param {Mode} mode Data mode\n * @param {Number} version QR Code version\n * @return {Number} Number of bits\n */\nexports.getCharCountIndicator = function getCharCountIndicator (mode, version) {\n if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)\n\n if (!VersionCheck.isValid(version)) {\n throw new Error('Invalid version: ' + version)\n }\n\n if (version >= 1 && version < 10) return mode.ccBits[0]\n else if (version < 27) return mode.ccBits[1]\n return mode.ccBits[2]\n}\n\n/**\n * Returns the most efficient mode to store the specified data\n *\n * @param {String} dataStr Input data string\n * @return {Mode} Best mode\n */\nexports.getBestModeForData = function getBestModeForData (dataStr) {\n if (Regex.testNumeric(dataStr)) return exports.NUMERIC\n else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC\n else if (Regex.testKanji(dataStr)) return exports.KANJI\n else return exports.BYTE\n}\n\n/**\n * Return mode name as string\n *\n * @param {Mode} mode Mode object\n * @returns {String} Mode name\n */\nexports.toString = function toString (mode) {\n if (mode && mode.id) return mode.id\n throw new Error('Invalid mode')\n}\n\n/**\n * Check if input param is a valid mode object\n *\n * @param {Mode} mode Mode object\n * @returns {Boolean} True if valid mode, false otherwise\n */\nexports.isValid = function isValid (mode) {\n return mode && mode.bit && mode.ccBits\n}\n\n/**\n * Get mode object from its name\n *\n * @param {String} string Mode name\n * @returns {Mode} Mode object\n */\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'numeric':\n return exports.NUMERIC\n case 'alphanumeric':\n return exports.ALPHANUMERIC\n case 'kanji':\n return exports.KANJI\n case 'byte':\n return exports.BYTE\n default:\n throw new Error('Unknown mode: ' + string)\n }\n}\n\n/**\n * Returns mode from a value.\n * If value is not a valid mode, returns defaultValue\n *\n * @param {Mode|String} value Encoding mode\n * @param {Mode} defaultValue Fallback value\n * @return {Mode} Encoding mode\n */\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n","const Utils = require('./utils')\nconst ECCode = require('./error-correction-code')\nconst ECLevel = require('./error-correction-level')\nconst Mode = require('./mode')\nconst VersionCheck = require('./version-check')\n\n// Generator polynomial used to encode version information\nconst G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)\nconst G18_BCH = Utils.getBCHDigit(G18)\n\nfunction getBestVersionForDataLength (mode, length, errorCorrectionLevel) {\n for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {\n if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {\n return currentVersion\n }\n }\n\n return undefined\n}\n\nfunction getReservedBitsCount (mode, version) {\n // Character count indicator + mode indicator bits\n return Mode.getCharCountIndicator(mode, version) + 4\n}\n\nfunction getTotalBitsFromDataArray (segments, version) {\n let totalBits = 0\n\n segments.forEach(function (data) {\n const reservedBits = getReservedBitsCount(data.mode, version)\n totalBits += reservedBits + data.getBitsLength()\n })\n\n return totalBits\n}\n\nfunction getBestVersionForMixedData (segments, errorCorrectionLevel) {\n for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {\n const length = getTotalBitsFromDataArray(segments, currentVersion)\n if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {\n return currentVersion\n }\n }\n\n return undefined\n}\n\n/**\n * Returns version number from a value.\n * If value is not a valid version, returns defaultValue\n *\n * @param {Number|String} value QR Code version\n * @param {Number} defaultValue Fallback value\n * @return {Number} QR Code version number\n */\nexports.from = function from (value, defaultValue) {\n if (VersionCheck.isValid(value)) {\n return parseInt(value, 10)\n }\n\n return defaultValue\n}\n\n/**\n * Returns how much data can be stored with the specified QR code version\n * and error correction level\n *\n * @param {Number} version QR Code version (1-40)\n * @param {Number} errorCorrectionLevel Error correction level\n * @param {Mode} mode Data mode\n * @return {Number} Quantity of storable data\n */\nexports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {\n if (!VersionCheck.isValid(version)) {\n throw new Error('Invalid QR Code version')\n }\n\n // Use Byte mode as default\n if (typeof mode === 'undefined') mode = Mode.BYTE\n\n // Total codewords for this QR code version (Data + Error correction)\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n\n // Total number of error correction codewords\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n\n // Total number of data codewords\n const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8\n\n if (mode === Mode.MIXED) return dataTotalCodewordsBits\n\n const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)\n\n // Return max number of storable codewords\n switch (mode) {\n case Mode.NUMERIC:\n return Math.floor((usableBits / 10) * 3)\n\n case Mode.ALPHANUMERIC:\n return Math.floor((usableBits / 11) * 2)\n\n case Mode.KANJI:\n return Math.floor(usableBits / 13)\n\n case Mode.BYTE:\n default:\n return Math.floor(usableBits / 8)\n }\n}\n\n/**\n * Returns the minimum version needed to contain the amount of data\n *\n * @param {Segment} data Segment of data\n * @param {Number} [errorCorrectionLevel=H] Error correction level\n * @param {Mode} mode Data mode\n * @return {Number} QR Code version\n */\nexports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {\n let seg\n\n const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)\n\n if (Array.isArray(data)) {\n if (data.length > 1) {\n return getBestVersionForMixedData(data, ecl)\n }\n\n if (data.length === 0) {\n return 1\n }\n\n seg = data[0]\n } else {\n seg = data\n }\n\n return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)\n}\n\n/**\n * Returns version information with relative error correction bits\n *\n * The version information is included in QR Code symbols of version 7 or larger.\n * It consists of an 18-bit sequence containing 6 data bits,\n * with 12 error correction bits calculated using the (18, 6) Golay code.\n *\n * @param {Number} version QR Code version\n * @return {Number} Encoded version info bits\n */\nexports.getEncodedBits = function getEncodedBits (version) {\n if (!VersionCheck.isValid(version) || version < 7) {\n throw new Error('Invalid QR Code version')\n }\n\n let d = version << 12\n\n while (Utils.getBCHDigit(d) - G18_BCH >= 0) {\n d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))\n }\n\n return (version << 12) | d\n}\n","const Utils = require('./utils')\n\nconst G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)\nconst G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)\nconst G15_BCH = Utils.getBCHDigit(G15)\n\n/**\n * Returns format information with relative error correction bits\n *\n * The format information is a 15-bit sequence containing 5 data bits,\n * with 10 error correction bits calculated using the (15, 5) BCH code.\n *\n * @param {Number} errorCorrectionLevel Error correction level\n * @param {Number} mask Mask pattern\n * @return {Number} Encoded format information bits\n */\nexports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {\n const data = ((errorCorrectionLevel.bit << 3) | mask)\n let d = data << 10\n\n while (Utils.getBCHDigit(d) - G15_BCH >= 0) {\n d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))\n }\n\n // xor final data with mask pattern in order to ensure that\n // no combination of Error Correction Level and data mask pattern\n // will result in an all-zero data string\n return ((data << 10) | d) ^ G15_MASK\n}\n","const Mode = require('./mode')\n\nfunction NumericData (data) {\n this.mode = Mode.NUMERIC\n this.data = data.toString()\n}\n\nNumericData.getBitsLength = function getBitsLength (length) {\n return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)\n}\n\nNumericData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nNumericData.prototype.getBitsLength = function getBitsLength () {\n return NumericData.getBitsLength(this.data.length)\n}\n\nNumericData.prototype.write = function write (bitBuffer) {\n let i, group, value\n\n // The input data string is divided into groups of three digits,\n // and each group is converted to its 10-bit binary equivalent.\n for (i = 0; i + 3 <= this.data.length; i += 3) {\n group = this.data.substr(i, 3)\n value = parseInt(group, 10)\n\n bitBuffer.put(value, 10)\n }\n\n // If the number of input digits is not an exact multiple of three,\n // the final one or two digits are converted to 4 or 7 bits respectively.\n const remainingNum = this.data.length - i\n if (remainingNum > 0) {\n group = this.data.substr(i)\n value = parseInt(group, 10)\n\n bitBuffer.put(value, remainingNum * 3 + 1)\n }\n}\n\nmodule.exports = NumericData\n","const Mode = require('./mode')\n\n/**\n * Array of characters available in alphanumeric mode\n *\n * As per QR Code specification, to each character\n * is assigned a value from 0 to 44 which in this case coincides\n * with the array index\n *\n * @type {Array}\n */\nconst ALPHA_NUM_CHARS = [\n '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',\n 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\n ' ', '$', '%', '*', '+', '-', '.', '/', ':'\n]\n\nfunction AlphanumericData (data) {\n this.mode = Mode.ALPHANUMERIC\n this.data = data\n}\n\nAlphanumericData.getBitsLength = function getBitsLength (length) {\n return 11 * Math.floor(length / 2) + 6 * (length % 2)\n}\n\nAlphanumericData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nAlphanumericData.prototype.getBitsLength = function getBitsLength () {\n return AlphanumericData.getBitsLength(this.data.length)\n}\n\nAlphanumericData.prototype.write = function write (bitBuffer) {\n let i\n\n // Input data characters are divided into groups of two characters\n // and encoded as 11-bit binary codes.\n for (i = 0; i + 2 <= this.data.length; i += 2) {\n // The character value of the first character is multiplied by 45\n let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45\n\n // The character value of the second digit is added to the product\n value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])\n\n // The sum is then stored as 11-bit binary number\n bitBuffer.put(value, 11)\n }\n\n // If the number of input data characters is not a multiple of two,\n // the character value of the final character is encoded as a 6-bit binary number.\n if (this.data.length % 2) {\n bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)\n }\n}\n\nmodule.exports = AlphanumericData\n","const Mode = require('./mode')\n\nfunction ByteData (data) {\n this.mode = Mode.BYTE\n if (typeof (data) === 'string') {\n this.data = new TextEncoder().encode(data)\n } else {\n this.data = new Uint8Array(data)\n }\n}\n\nByteData.getBitsLength = function getBitsLength (length) {\n return length * 8\n}\n\nByteData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nByteData.prototype.getBitsLength = function getBitsLength () {\n return ByteData.getBitsLength(this.data.length)\n}\n\nByteData.prototype.write = function (bitBuffer) {\n for (let i = 0, l = this.data.length; i < l; i++) {\n bitBuffer.put(this.data[i], 8)\n }\n}\n\nmodule.exports = ByteData\n","const Mode = require('./mode')\nconst Utils = require('./utils')\n\nfunction KanjiData (data) {\n this.mode = Mode.KANJI\n this.data = data\n}\n\nKanjiData.getBitsLength = function getBitsLength (length) {\n return length * 13\n}\n\nKanjiData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nKanjiData.prototype.getBitsLength = function getBitsLength () {\n return KanjiData.getBitsLength(this.data.length)\n}\n\nKanjiData.prototype.write = function (bitBuffer) {\n let i\n\n // In the Shift JIS system, Kanji characters are represented by a two byte combination.\n // These byte values are shifted from the JIS X 0208 values.\n // JIS X 0208 gives details of the shift coded representation.\n for (i = 0; i < this.data.length; i++) {\n let value = Utils.toSJIS(this.data[i])\n\n // For characters with Shift JIS values from 0x8140 to 0x9FFC:\n if (value >= 0x8140 && value <= 0x9FFC) {\n // Subtract 0x8140 from Shift JIS value\n value -= 0x8140\n\n // For characters with Shift JIS values from 0xE040 to 0xEBBF\n } else if (value >= 0xE040 && value <= 0xEBBF) {\n // Subtract 0xC140 from Shift JIS value\n value -= 0xC140\n } else {\n throw new Error(\n 'Invalid SJIS character: ' + this.data[i] + '\\n' +\n 'Make sure your charset is UTF-8')\n }\n\n // Multiply most significant byte of result by 0xC0\n // and add least significant byte to product\n value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)\n\n // Convert result to a 13-bit binary string\n bitBuffer.put(value, 13)\n }\n}\n\nmodule.exports = KanjiData\n","'use strict';\n\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin <self@wyattbaldwin.com>\n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nvar dijkstra = {\n single_source_shortest_paths: function(graph, s, d) {\n // Predecessor map for each node that has been encountered.\n // node ID => predecessor node ID\n var predecessors = {};\n\n // Costs of shortest paths from s to all nodes encountered.\n // node ID => cost\n var costs = {};\n costs[s] = 0;\n\n // Costs of shortest paths from s to all nodes encountered; differs from\n // `costs` in that it provides easy access to the node that currently has\n // the known shortest path from s.\n // XXX: Do we actually need both `costs` and `open`?\n var open = dijkstra.PriorityQueue.make();\n open.push(s, 0);\n\n var closest,\n u, v,\n cost_of_s_to_u,\n adjacent_nodes,\n cost_of_e,\n cost_of_s_to_u_plus_cost_of_e,\n cost_of_s_to_v,\n first_visit;\n while (!open.empty()) {\n // In the nodes remaining in graph that have a known cost from s,\n // find the node, u, that currently has the shortest path from s.\n closest = open.pop();\n u = closest.value;\n cost_of_s_to_u = closest.cost;\n\n // Get nodes adjacent to u...\n adjacent_nodes = graph[u] || {};\n\n // ...and explore the edges that connect u to those nodes, updating\n // the cost of the shortest paths to any or all of those nodes as\n // necessary. v is the node across the current edge from u.\n for (v in adjacent_nodes) {\n if (adjacent_nodes.hasOwnProperty(v)) {\n // Get the cost of the edge running from u to v.\n cost_of_e = adjacent_nodes[v];\n\n // Cost of s to u plus the cost of u to v across e--this is *a*\n // cost from s to v that may or may not be less than the current\n // known cost to v.\n cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n // If we haven't visited v yet OR if the current known cost from s to\n // v is greater than the new cost we just found (cost of s to u plus\n // cost of u to v across e), update v's cost in the cost list and\n // update v's predecessor in the predecessor list (it's now u).\n cost_of_s_to_v = costs[v];\n first_visit = (typeof costs[v] === 'undefined');\n if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n costs[v] = cost_of_s_to_u_plus_cost_of_e;\n open.push(v, cost_of_s_to_u_plus_cost_of_e);\n predecessors[v] = u;\n }\n }\n }\n }\n\n if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {\n var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');\n throw new Error(msg);\n }\n\n return predecessors;\n },\n\n extract_shortest_path_from_predecessor_list: function(predecessors, d) {\n var nodes = [];\n var u = d;\n var predecessor;\n while (u) {\n nodes.push(u);\n predecessor = predecessors[u];\n u = predecessors[u];\n }\n nodes.reverse();\n return nodes;\n },\n\n find_path: function(graph, s, d) {\n var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);\n return dijkstra.extract_shortest_path_from_predecessor_list(\n predecessors, d);\n },\n\n /**\n * A very naive priority queue implementation.\n */\n PriorityQueue: {\n make: function (opts) {\n var T = dijkstra.PriorityQueue,\n t = {},\n key;\n opts = opts || {};\n for (key in T) {\n if (T.hasOwnProperty(key)) {\n t[key] = T[key];\n }\n }\n t.queue = [];\n t.sorter = opts.sorter || T.default_sorter;\n return t;\n },\n\n default_sorter: function (a, b) {\n return a.cost - b.cost;\n },\n\n /**\n * Add a new item to the queue and ensure the highest priority element\n * is at the front of the queue.\n */\n push: function (value, cost) {\n var item = {value: value, cost: cost};\n this.queue.push(item);\n this.queue.sort(this.sorter);\n },\n\n /**\n * Return the highest priority element in the queue.\n */\n pop: function () {\n return this.queue.shift();\n },\n\n empty: function () {\n return this.queue.length === 0;\n }\n }\n};\n\n\n// node.js module exports\nif (typeof module !== 'undefined') {\n module.exports = dijkstra;\n}\n","const Mode = require('./mode')\nconst NumericData = require('./numeric-data')\nconst AlphanumericData = require('./alphanumeric-data')\nconst ByteData = require('./byte-data')\nconst KanjiData = require('./kanji-data')\nconst Regex = require('./regex')\nconst Utils = require('./utils')\nconst dijkstra = require('dijkstrajs')\n\n/**\n * Returns UTF8 byte length\n *\n * @param {String} str Input string\n * @return {Number} Number of byte\n */\nfunction getStringByteLength (str) {\n return unescape(encodeURIComponent(str)).length\n}\n\n/**\n * Get a list of segments of the specified mode\n * from a string\n *\n * @param {Mode} mode Segment mode\n * @param {String} str String to process\n * @return {Array} Array of object with segments data\n */\nfunction getSegments (regex, mode, str) {\n const segments = []\n let result\n\n while ((result = regex.exec(str)) !== null) {\n segments.push({\n data: result[0],\n index: result.index,\n mode: mode,\n length: result[0].length\n })\n }\n\n return segments\n}\n\n/**\n * Extracts a series of segments with the appropriate\n * modes from a string\n *\n * @param {String} dataStr Input string\n * @return {Array} Array of object with segments data\n */\nfunction getSegmentsFromString (dataStr) {\n const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)\n const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)\n let byteSegs\n let kanjiSegs\n\n if (Utils.isKanjiModeEnabled()) {\n byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)\n kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)\n } else {\n byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)\n kanjiSegs = []\n }\n\n const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)\n\n return segs\n .sort(function (s1, s2) {\n return s1.index - s2.index\n })\n .map(function (obj) {\n return {\n data: obj.data,\n mode: obj.mode,\n length: obj.length\n }\n })\n}\n\n/**\n * Returns how many bits are needed to encode a string of\n * specified length with the specified mode\n *\n * @param {Number} length String length\n * @param {Mode} mode Segment mode\n * @return {Number} Bit length\n */\nfunction getSegmentBitsLength (length, mode) {\n switch (mode) {\n case Mode.NUMERIC:\n return NumericData.getBitsLength(length)\n case Mode.ALPHANUMERIC:\n return AlphanumericData.getBitsLength(length)\n case Mode.KANJI:\n return KanjiData.getBitsLength(length)\n case Mode.BYTE:\n return ByteData.getBitsLength(length)\n }\n}\n\n/**\n * Merges adjacent segments which have the same mode\n *\n * @param {Array} segs Array of object with segments data\n * @return {Array} Array of object with segments data\n */\nfunction mergeSegments (segs) {\n return segs.reduce(function (acc, curr) {\n const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null\n if (prevSeg && prevSeg.mode === curr.mode) {\n acc[acc.length - 1].data += curr.data\n return acc\n }\n\n acc.push(curr)\n return acc\n }, [])\n}\n\n/**\n * Generates a list of all possible nodes combination which\n * will be used to build a segments graph.\n *\n * Nodes are divided by groups. Each group will contain a list of all the modes\n * in which is possible to encode the given text.\n *\n * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.\n * The group for '12345' will contain then 3 objects, one for each\n * possible encoding mode.\n *\n * Each node represents a possible segment.\n *\n * @param {Array} segs Array of object with segments data\n * @return {Array} Array of object with segments data\n */\nfunction buildNodes (segs) {\n const nodes = []\n for (let i = 0; i < segs.length; i++) {\n const seg = segs[i]\n\n switch (seg.mode) {\n case Mode.NUMERIC:\n nodes.push([seg,\n { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },\n { data: seg.data, mode: Mode.BYTE, length: seg.length }\n ])\n break\n case Mode.ALPHANUMERIC:\n nodes.push([seg,\n { data: seg.data, mode: Mode.BYTE, length: seg.length }\n ])\n break\n case Mode.KANJI:\n nodes.push([seg,\n { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }\n ])\n break\n case Mode.BYTE:\n nodes.push([\n { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }\n ])\n }\n }\n\n return nodes\n}\n\n/**\n * Builds a graph from a list of nodes.\n * All segments in each node group will be connected with all the segments of\n * the next group and so on.\n *\n * At each connection will be assigned a weight depending on the\n * segment's byte length.\n *\n * @param {Array} nodes Array of object with segments data\n * @param {Number} version QR Code version\n * @return {Object} Graph of all possible segments\n */\nfunction buildGraph (nodes, version) {\n const table = {}\n const graph = { start: {} }\n let prevNodeIds = ['start']\n\n for (let i = 0; i < nodes.length; i++) {\n const nodeGroup = nodes[i]\n const currentNodeIds = []\n\n for (let j = 0; j < nodeGroup.length; j++) {\n const node = nodeGroup[j]\n const key = '' + i + j\n\n currentNodeIds.push(key)\n table[key] = { node: node, lastCount: 0 }\n graph[key] = {}\n\n for (let n = 0; n < prevNodeIds.length; n++) {\n const prevNodeId = prevNodeIds[n]\n\n if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {\n graph[prevNodeId][key] =\n getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -\n getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)\n\n table[prevNodeId].lastCount += node.length\n } else {\n if (table[prevNodeId]) table[prevNodeId].lastCount = node.length\n\n graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +\n 4 + Mode.getCharCountIndicator(node.mode, version) // switch cost\n }\n }\n }\n\n prevNodeIds = currentNodeIds\n }\n\n for (let n = 0; n < prevNodeIds.length; n++) {\n graph[prevNodeIds[n]].end = 0\n }\n\n return { map: graph, table: table }\n}\n\n/**\n * Builds a segment from a specified data and mode.\n * If a mode is not specified, the more suitable will be used.\n *\n * @param {String} data Input data\n * @param {Mode | String} modesHint Data mode\n * @return {Segment} Segment\n */\nfunction buildSingleSegment (data, modesHint) {\n let mode\n const bestMode = Mode.getBestModeForData(data)\n\n mode = Mode.from(modesHint, bestMode)\n\n // Make sure data can be encoded\n if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {\n throw new Error('\"' + data + '\"' +\n ' cannot be encoded with mode ' + Mode.toString(mode) +\n '.\\n Suggested mode is: ' + Mode.toString(bestMode))\n }\n\n // Use Mode.BYTE if Kanji support is disabled\n if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {\n mode = Mode.BYTE\n }\n\n switch (mode) {\n case Mode.NUMERIC:\n return new NumericData(data)\n\n case Mode.ALPHANUMERIC:\n return new AlphanumericData(data)\n\n case Mode.KANJI:\n return new KanjiData(data)\n\n case Mode.BYTE:\n return new ByteData(data)\n }\n}\n\n/**\n * Builds a list of segments from an array.\n * Array can contain Strings or Objects with segment's info.\n *\n * For each item which is a string, will be generated a segment with the given\n * string and the more appropriate encoding mode.\n *\n * For each item which is an object, will be generated a segment with the given\n * data and mode.\n * Objects must contain at least the property \"data\".\n * If property \"mode\" is not present, the more suitable mode will be used.\n *\n * @param {Array} array Array of objects with segments data\n * @return {Array} Array of Segments\n */\nexports.fromArray = function fromArray (array) {\n return array.reduce(function (acc, seg) {\n if (typeof seg === 'string') {\n acc.push(buildSingleSegment(seg, null))\n } else if (seg.data) {\n acc.push(buildSingleSegment(seg.data, seg.mode))\n }\n\n return acc\n }, [])\n}\n\n/**\n * Builds an optimized sequence of segments from a string,\n * which will produce the shortest possible bitstream.\n *\n * @param {String} data Input string\n * @param {Number} version QR Code version\n * @return {Array} Array of segments\n */\nexports.fromString = function fromString (data, version) {\n const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())\n\n const nodes = buildNodes(segs)\n const graph = buildGraph(nodes, version)\n const path = dijkstra.find_path(graph.map, 'start', 'end')\n\n const optimizedSegs = []\n for (let i = 1; i < path.length - 1; i++) {\n optimizedSegs.push(graph.table[path[i]].node)\n }\n\n return exports.fromArray(mergeSegments(optimizedSegs))\n}\n\n/**\n * Splits a string in various segments with the modes which\n * best represent their content.\n * The produced segments are far from being optimized.\n * The output of this function is only used to estimate a QR Code version\n * which may contain the data.\n *\n * @param {string} data Input string\n * @return {Array} Array of segments\n */\nexports.rawSplit = function rawSplit (data) {\n return exports.fromArray(\n getSegmentsFromString(data, Utils.isKanjiModeEnabled())\n )\n}\n","const Utils = require('./utils')\nconst ECLevel = require('./error-correction-level')\nconst BitBuffer = require('./bit-buffer')\nconst BitMatrix = require('./bit-matrix')\nconst AlignmentPattern = require('./alignment-pattern')\nconst FinderPattern = require('./finder-pattern')\nconst MaskPattern = require('./mask-pattern')\nconst ECCode = require('./error-correction-code')\nconst ReedSolomonEncoder = require('./reed-solomon-encoder')\nconst Version = require('./version')\nconst FormatInfo = require('./format-info')\nconst Mode = require('./mode')\nconst Segments = require('./segments')\n\n/**\n * QRCode for JavaScript\n *\n * modified by Ryan Day for nodejs support\n * Copyright (c) 2011 Ryan Day\n *\n * Licensed under the MIT license:\n * http://www.opensource.org/licenses/mit-license.php\n *\n//---------------------------------------------------------------------\n// QRCode for JavaScript\n//\n// Copyright (c) 2009 Kazuhiko Arase\n//\n// URL: http://www.d-project.com/\n//\n// Licensed under the MIT license:\n// http://www.opensource.org/licenses/mit-license.php\n//\n// The word \"QR Code\" is registered trademark of\n// DENSO WAVE INCORPORATED\n// http://www.denso-wave.com/qrcode/faqpatent-e.html\n//\n//---------------------------------------------------------------------\n*/\n\n/**\n * Add finder patterns bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupFinderPattern (matrix, version) {\n const size = matrix.size\n const pos = FinderPattern.getPositions(version)\n\n for (let i = 0; i < pos.length; i++) {\n const row = pos[i][0]\n const col = pos[i][1]\n\n for (let r = -1; r <= 7; r++) {\n if (row + r <= -1 || size <= row + r) continue\n\n for (let c = -1; c <= 7; c++) {\n if (col + c <= -1 || size <= col + c) continue\n\n if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||\n (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||\n (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {\n matrix.set(row + r, col + c, true, true)\n } else {\n matrix.set(row + r, col + c, false, true)\n }\n }\n }\n }\n}\n\n/**\n * Add timing pattern bits to matrix\n *\n * Note: this function must be called before {@link setupAlignmentPattern}\n *\n * @param {BitMatrix} matrix Modules matrix\n */\nfunction setupTimingPattern (matrix) {\n const size = matrix.size\n\n for (let r = 8; r < size - 8; r++) {\n const value = r % 2 === 0\n matrix.set(r, 6, value, true)\n matrix.set(6, r, value, true)\n }\n}\n\n/**\n * Add alignment patterns bits to matrix\n *\n * Note: this function must be called after {@link setupTimingPattern}\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupAlignmentPattern (matrix, version) {\n const pos = AlignmentPattern.getPositions(version)\n\n for (let i = 0; i < pos.length; i++) {\n const row = pos[i][0]\n const col = pos[i][1]\n\n for (let r = -2; r <= 2; r++) {\n for (let c = -2; c <= 2; c++) {\n if (r === -2 || r === 2 || c === -2 || c === 2 ||\n (r === 0 && c === 0)) {\n matrix.set(row + r, col + c, true, true)\n } else {\n matrix.set(row + r, col + c, false, true)\n }\n }\n }\n }\n}\n\n/**\n * Add version info bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupVersionInfo (matrix, version) {\n const size = matrix.size\n const bits = Version.getEncodedBits(version)\n let row, col, mod\n\n for (let i = 0; i < 18; i++) {\n row = Math.floor(i / 3)\n col = i % 3 + size - 8 - 3\n mod = ((bits >> i) & 1) === 1\n\n matrix.set(row, col, mod, true)\n matrix.set(col, row, mod, true)\n }\n}\n\n/**\n * Add format info bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @param {Number} maskPattern Mask pattern reference value\n */\nfunction setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {\n const size = matrix.size\n const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)\n let i, mod\n\n for (i = 0; i < 15; i++) {\n mod = ((bits >> i) & 1) === 1\n\n // vertical\n if (i < 6) {\n matrix.set(i, 8, mod, true)\n } else if (i < 8) {\n matrix.set(i + 1, 8, mod, true)\n } else {\n matrix.set(size - 15 + i, 8, mod, true)\n }\n\n // horizontal\n if (i < 8) {\n matrix.set(8, size - i - 1, mod, true)\n } else if (i < 9) {\n matrix.set(8, 15 - i - 1 + 1, mod, true)\n } else {\n matrix.set(8, 15 - i - 1, mod, true)\n }\n }\n\n // fixed module\n matrix.set(size - 8, 8, 1, true)\n}\n\n/**\n * Add encoded data bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Uint8Array} data Data codewords\n */\nfunction setupData (matrix, data) {\n const size = matrix.size\n let inc = -1\n let row = size - 1\n let bitIndex = 7\n let byteIndex = 0\n\n for (let col = size - 1; col > 0; col -= 2) {\n if (col === 6) col--\n\n while (true) {\n for (let c = 0; c < 2; c++) {\n if (!matrix.isReserved(row, col - c)) {\n let dark = false\n\n if (byteIndex < data.length) {\n dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)\n }\n\n matrix.set(row, col - c, dark)\n bitIndex--\n\n if (bitIndex === -1) {\n byteIndex++\n bitIndex = 7\n }\n }\n }\n\n row += inc\n\n if (row < 0 || size <= row) {\n row -= inc\n inc = -inc\n break\n }\n }\n }\n}\n\n/**\n * Create encoded codewords from data input\n *\n * @param {Number} version QR Code version\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @param {ByteData} data Data input\n * @return {Uint8Array} Buffer containing encoded codewords\n */\nfunction createData (version, errorCorrectionLevel, segments) {\n // Prepare data buffer\n const buffer = new BitBuffer()\n\n segments.forEach(function (data) {\n // prefix data with mode indicator (4 bits)\n buffer.put(data.mode.bit, 4)\n\n // Prefix data with character count indicator.\n // The character count indicator is a string of bits that represents the\n // number of characters that are being encoded.\n // The character count indicator must be placed after the mode indicator\n // and must be a certain number of bits long, depending on the QR version\n // and data mode\n // @see {@link Mode.getCharCountIndicator}.\n buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))\n\n // add binary data sequence to buffer\n data.write(buffer)\n })\n\n // Calculate required number of bits\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8\n\n // Add a terminator.\n // If the bit string is shorter than the total number of required bits,\n // a terminator of up to four 0s must be added to the right side of the string.\n // If the bit string is more than four bits shorter than the required number of bits,\n // add four 0s to the end.\n if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {\n buffer.put(0, 4)\n }\n\n // If the bit string is fewer than four bits shorter, add only the number of 0s that\n // are needed to reach the required number of bits.\n\n // After adding the terminator, if the number of bits in the string is not a multiple of 8,\n // pad the string on the right with 0s to make the string's length a multiple of 8.\n while (buffer.getLengthInBits() % 8 !== 0) {\n buffer.putBit(0)\n }\n\n // Add pad bytes if the string is still shorter than the total number of required bits.\n // Extend the buffer to fill the data capacity of the symbol corresponding to\n // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)\n // and 00010001 (0x11) alternately.\n const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8\n for (let i = 0; i < remainingByte; i++) {\n buffer.put(i % 2 ? 0x11 : 0xEC, 8)\n }\n\n return createCodewords(buffer, version, errorCorrectionLevel)\n}\n\n/**\n * Encode input data with Reed-Solomon and return codewords with\n * relative error correction bits\n *\n * @param {BitBuffer} bitBuffer Data to encode\n * @param {Number} version QR Code version\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @return {Uint8Array} Buffer containing encoded codewords\n */\nfunction createCodewords (bitBuffer, version, errorCorrectionLevel) {\n // Total codewords for this QR code version (Data + Error correction)\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n\n // Total number of error correction codewords\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n\n // Total number of data codewords\n const dataTotalCodewords = totalCodewords - ecTotalCodewords\n\n // Total number of blocks\n const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)\n\n // Calculate how many blocks each group should contain\n const blocksInGroup2 = totalCodewords % ecTotalBlocks\n const blocksInGroup1 = ecTotalBlocks - blocksInGroup2\n\n const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)\n\n const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)\n const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1\n\n // Number of EC codewords is the same for both groups\n const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1\n\n // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount\n const rs = new ReedSolomonEncoder(ecCount)\n\n let offset = 0\n const dcData = new Array(ecTotalBlocks)\n const ecData = new Array(ecTotalBlocks)\n let maxDataSize = 0\n const buffer = new Uint8Array(bitBuffer.buffer)\n\n // Divide the buffer into the required number of blocks\n for (let b = 0; b < ecTotalBlocks; b++) {\n const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2\n\n // extract a block of data from buffer\n dcData[b] = buffer.slice(offset, offset + dataSize)\n\n // Calculate EC codewords for this data block\n ecData[b] = rs.encode(dcData[b])\n\n offset += dataSize\n maxDataSize = Math.max(maxDataSize, dataSize)\n }\n\n // Create final data\n // Interleave the data and error correction codewords from each block\n const data = new Uint8Array(totalCodewords)\n let index = 0\n let i, r\n\n // Add data codewords\n for (i = 0; i < maxDataSize; i++) {\n for (r = 0; r < ecTotalBlocks; r++) {\n if (i < dcData[r].length) {\n data[index++] = dcData[r][i]\n }\n }\n }\n\n // Apped EC codewords\n for (i = 0; i < ecCount; i++) {\n for (r = 0; r < ecTotalBlocks; r++) {\n data[index++] = ecData[r][i]\n }\n }\n\n return data\n}\n\n/**\n * Build QR Code symbol\n *\n * @param {String} data Input string\n * @param {Number} version QR Code version\n * @param {ErrorCorretionLevel} errorCorrectionLevel Error level\n * @param {MaskPattern} maskPattern Mask pattern\n * @return {Object} Object containing symbol data\n */\nfunction createSymbol (data, version, errorCorrectionLevel, maskPattern) {\n let segments\n\n if (Array.isArray(data)) {\n segments = Segments.fromArray(data)\n } else if (typeof data === 'string') {\n let estimatedVersion = version\n\n if (!estimatedVersion) {\n const rawSegments = Segments.rawSplit(data)\n\n // Estimate best version that can contain raw splitted segments\n estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel)\n }\n\n // Build optimized segments\n // If estimated version is undefined, try with the highest version\n segments = Segments.fromString(data, estimatedVersion || 40)\n } else {\n throw new Error('Invalid data')\n }\n\n // Get the min version that can contain data\n const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel)\n\n // If no version is found, data cannot be stored\n if (!bestVersion) {\n throw new Error('The amount of data is too big to be stored in a QR Code')\n }\n\n // If not specified, use min version as default\n if (!version) {\n version = bestVersion\n\n // Check if the specified version can contain the data\n } else if (version < bestVersion) {\n throw new Error('\\n' +\n 'The chosen QR Code version cannot contain this amount of data.\\n' +\n 'Minimum version required to store current data is: ' + bestVersion + '.\\n'\n )\n }\n\n const dataBits = createData(version, errorCorrectionLevel, segments)\n\n // Allocate matrix buffer\n const moduleCount = Utils.getSymbolSize(version)\n const modules = new BitMatrix(moduleCount)\n\n // Add function modules\n setupFinderPattern(modules, version)\n setupTimingPattern(modules)\n setupAlignmentPattern(modules, version)\n\n // Add temporary dummy bits for format info just to set them as reserved.\n // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}\n // since the masking operation must be performed only on the encoding region.\n // These blocks will be replaced with correct values later in code.\n setupFormatInfo(modules, errorCorrectionLevel, 0)\n\n if (version >= 7) {\n setupVersionInfo(modules, version)\n }\n\n // Add data codewords\n setupData(modules, dataBits)\n\n if (isNaN(maskPattern)) {\n // Find best mask pattern\n maskPattern = MaskPattern.getBestMask(modules,\n setupFormatInfo.bind(null, modules, errorCorrectionLevel))\n }\n\n // Apply mask pattern\n MaskPattern.applyMask(maskPattern, modules)\n\n // Replace format info bits with correct values\n setupFormatInfo(modules, errorCorrectionLevel, maskPattern)\n\n return {\n modules: modules,\n version: version,\n errorCorrectionLevel: errorCorrectionLevel,\n maskPattern: maskPattern,\n segments: segments\n }\n}\n\n/**\n * QR Code\n *\n * @param {String | Array} data Input data\n * @param {Object} options Optional configurations\n * @param {Number} options.version QR Code version\n * @param {String} options.errorCorrectionLevel Error correction level\n * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis\n */\nexports.create = function create (data, options) {\n if (typeof data === 'undefined' || data === '') {\n throw new Error('No input text')\n }\n\n let errorCorrectionLevel = ECLevel.M\n let version\n let mask\n\n if (typeof options !== 'undefined') {\n // Use higher error correction level as default\n errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)\n version = Version.from(options.version)\n mask = MaskPattern.from(options.maskPattern)\n\n if (options.toSJISFunc) {\n Utils.setToSJISFunction(options.toSJISFunc)\n }\n }\n\n return createSymbol(data, version, errorCorrectionLevel, mask)\n}\n","function hex2rgba (hex) {\n if (typeof hex === 'number') {\n hex = hex.toString()\n }\n\n if (typeof hex !== 'string') {\n throw new Error('Color should be defined as hex string')\n }\n\n let hexCode = hex.slice().replace('#', '').split('')\n if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {\n throw new Error('Invalid hex color: ' + hex)\n }\n\n // Convert from short to long form (fff -> ffffff)\n if (hexCode.length === 3 || hexCode.length === 4) {\n hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {\n return [c, c]\n }))\n }\n\n // Add default alpha value\n if (hexCode.length === 6) hexCode.push('F', 'F')\n\n const hexValue = parseInt(hexCode.join(''), 16)\n\n return {\n r: (hexValue >> 24) & 255,\n g: (hexValue >> 16) & 255,\n b: (hexValue >> 8) & 255,\n a: hexValue & 255,\n hex: '#' + hexCode.slice(0, 6).join('')\n }\n}\n\nexports.getOptions = function getOptions (options) {\n if (!options) options = {}\n if (!options.color) options.color = {}\n\n const margin = typeof options.margin === 'undefined' ||\n options.margin === null ||\n options.margin < 0\n ? 4\n : options.margin\n\n const width = options.width && options.width >= 21 ? options.width : undefined\n const scale = options.scale || 4\n\n return {\n width: width,\n scale: width ? 4 : scale,\n margin: margin,\n color: {\n dark: hex2rgba(options.color.dark || '#000000ff'),\n light: hex2rgba(options.color.light || '#ffffffff')\n },\n type: options.type,\n rendererOpts: options.rendererOpts || {}\n }\n}\n\nexports.getScale = function getScale (qrSize, opts) {\n return opts.width && opts.width >= qrSize + opts.margin * 2\n ? opts.width / (qrSize + opts.margin * 2)\n : opts.scale\n}\n\nexports.getImageWidth = function getImageWidth (qrSize, opts) {\n const scale = exports.getScale(qrSize, opts)\n return Math.floor((qrSize + opts.margin * 2) * scale)\n}\n\nexports.qrToImageData = function qrToImageData (imgData, qr, opts) {\n const size = qr.modules.size\n const data = qr.modules.data\n const scale = exports.getScale(size, opts)\n const symbolSize = Math.floor((size + opts.margin * 2) * scale)\n const scaledMargin = opts.margin * scale\n const palette = [opts.color.light, opts.color.dark]\n\n for (let i = 0; i < symbolSize; i++) {\n for (let j = 0; j < symbolSize; j++) {\n let posDst = (i * symbolSize + j) * 4\n let pxColor = opts.color.light\n\n if (i >= scaledMargin && j >= scaledMargin &&\n i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {\n const iSrc = Math.floor((i - scaledMargin) / scale)\n const jSrc = Math.floor((j - scaledMargin) / scale)\n pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0]\n }\n\n imgData[posDst++] = pxColor.r\n imgData[posDst++] = pxColor.g\n imgData[posDst++] = pxColor.b\n imgData[posDst] = pxColor.a\n }\n }\n}\n","const Utils = require('./utils')\n\nfunction clearCanvas (ctx, canvas, size) {\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n\n if (!canvas.style) canvas.style = {}\n canvas.height = size\n canvas.width = size\n canvas.style.height = size + 'px'\n canvas.style.width = size + 'px'\n}\n\nfunction getCanvasElement () {\n try {\n return document.createElement('canvas')\n } catch (e) {\n throw new Error('You need to specify a canvas element')\n }\n}\n\nexports.render = function render (qrData, canvas, options) {\n let opts = options\n let canvasEl = canvas\n\n if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {\n opts = canvas\n canvas = undefined\n }\n\n if (!canvas) {\n canvasEl = getCanvasElement()\n }\n\n opts = Utils.getOptions(opts)\n const size = Utils.getImageWidth(qrData.modules.size, opts)\n\n const ctx = canvasEl.getContext('2d')\n const image = ctx.createImageData(size, size)\n Utils.qrToImageData(image.data, qrData, opts)\n\n clearCanvas(ctx, canvasEl, size)\n ctx.putImageData(image, 0, 0)\n\n return canvasEl\n}\n\nexports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {\n let opts = options\n\n if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {\n opts = canvas\n canvas = undefined\n }\n\n if (!opts) opts = {}\n\n const canvasEl = exports.render(qrData, canvas, opts)\n\n const type = opts.type || 'image/png'\n const rendererOpts = opts.rendererOpts || {}\n\n return canvasEl.toDataURL(type, rendererOpts.quality)\n}\n","const Utils = require('./utils')\n\nfunction getColorAttrib (color, attrib) {\n const alpha = color.a / 255\n const str = attrib + '=\"' + color.hex + '\"'\n\n return alpha < 1\n ? str + ' ' + attrib + '-opacity=\"' + alpha.toFixed(2).slice(1) + '\"'\n : str\n}\n\nfunction svgCmd (cmd, x, y) {\n let str = cmd + x\n if (typeof y !== 'undefined') str += ' ' + y\n\n return str\n}\n\nfunction qrToPath (data, size, margin) {\n let path = ''\n let moveBy = 0\n let newRow = false\n let lineLength = 0\n\n for (let i = 0; i < data.length; i++) {\n const col = Math.floor(i % size)\n const row = Math.floor(i / size)\n\n if (!col && !newRow) newRow = true\n\n if (data[i]) {\n lineLength++\n\n if (!(i > 0 && col > 0 && data[i - 1])) {\n path += newRow\n ? svgCmd('M', col + margin, 0.5 + row + margin)\n : svgCmd('m', moveBy, 0)\n\n moveBy = 0\n newRow = false\n }\n\n if (!(col + 1 < size && data[i + 1])) {\n path += svgCmd('h', lineLength)\n lineLength = 0\n }\n } else {\n moveBy++\n }\n }\n\n return path\n}\n\nexports.render = function render (qrData, options, cb) {\n const opts = Utils.getOptions(options)\n const size = qrData.modules.size\n const data = qrData.modules.data\n const qrcodesize = size + opts.margin * 2\n\n const bg = !opts.color.light.a\n ? ''\n : '<path ' + getColorAttrib(opts.color.light, 'fill') +\n ' d=\"M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z\"/>'\n\n const path =\n '<path ' + getColorAttrib(opts.color.dark, 'stroke') +\n ' d=\"' + qrToPath(data, size, opts.margin) + '\"/>'\n\n const viewBox = 'viewBox=\"' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '\"'\n\n const width = !opts.width ? '' : 'width=\"' + opts.width + '\" height=\"' + opts.width + '\" '\n\n const svgTag = '<svg xmlns=\"http://www.w3.org/2000/svg\" ' + width + viewBox + ' shape-rendering=\"crispEdges\">' + bg + path + '</svg>\\n'\n\n if (typeof cb === 'function') {\n cb(null, svgTag)\n }\n\n return svgTag\n}\n","\nconst canPromise = require('./can-promise')\n\nconst QRCode = require('./core/qrcode')\nconst CanvasRenderer = require('./renderer/canvas')\nconst SvgRenderer = require('./renderer/svg-tag.js')\n\nfunction renderCanvas (renderFunc, canvas, text, opts, cb) {\n const args = [].slice.call(arguments, 1)\n const argsNum = args.length\n const isLastArgCb = typeof args[argsNum - 1] === 'function'\n\n if (!isLastArgCb && !canPromise()) {\n throw new Error('Callback required as last argument')\n }\n\n if (isLastArgCb) {\n if (argsNum < 2) {\n throw new Error('Too few arguments provided')\n }\n\n if (argsNum === 2) {\n cb = text\n text = canvas\n canvas = opts = undefined\n } else if (argsNum === 3) {\n if (canvas.getContext && typeof cb === 'undefined') {\n cb = opts\n opts = undefined\n } else {\n cb = opts\n opts = text\n text = canvas\n canvas = undefined\n }\n }\n } else {\n if (argsNum < 1) {\n throw new Error('Too few arguments provided')\n }\n\n if (argsNum === 1) {\n text = canvas\n canvas = opts = undefined\n } else if (argsNum === 2 && !canvas.getContext) {\n opts = text\n text = canvas\n canvas = undefined\n }\n\n return new Promise(function (resolve, reject) {\n try {\n const data = QRCode.create(text, opts)\n resolve(renderFunc(data, canvas, opts))\n } catch (e) {\n reject(e)\n }\n })\n }\n\n try {\n const data = QRCode.create(text, opts)\n cb(null, renderFunc(data, canvas, opts))\n } catch (e) {\n cb(e)\n }\n}\n\nexports.create = QRCode.create\nexports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render)\nexports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)\n\n// only svg for now.\nexports.toString = renderCanvas.bind(null, function (data, _, opts) {\n return SvgRenderer.render(data, opts)\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 { getDialogStyles } from './dialog-zap-style';\nimport { decodeNpub } from '../common/utils';\n\n/**\n * Modal dialog helper for <nostr-zap> component.\n *\n * Adapted (simplified) from the original `nostr-zap` repository `view.js` file.\n * The goal is to give users a full-page modal with amount presets, QR-invoice,\n * wallet URI link, copy-to-clipboard, and success feedback – while keeping code\n * size reasonable for the component bundle.\n * \n * NOTE: This dialog now receives pre-resolved npub from the component, eliminating\n * the need for redundant validation and resolution logic.\n */\n\nimport { \n fetchInvoice, \n getProfileMetadata, \n getZapEndpoint, \n listenForZapReceipt \n} from './zap-utils';\nimport * as QRCode from 'qrcode';\n\ninterface WebLN {\n enable: () => Promise<void>;\n sendPayment: (invoice: string) => Promise<{ preimage: string }>;\n}\n\ndeclare global {\n interface Window {\n webln?: WebLN;\n }\n}\n\nexport interface OpenZapModalParams {\n npub: string;\n relays: string;\n cachedDialogComponent?: DialogComponent | null;\n buttonColor?: string;\n theme?: 'light' | 'dark';\n fixedAmount?: number; // if supplied, hide amount UI\n defaultAmount?: number; // preselect but allow change\n initialAmount?: number; // legacy support\n anon?: boolean;\n url?: string; // URL to send zap to (enables URL-based zaps)\n}\n\nexport const injectCSS = (theme: 'light' | 'dark' = 'light') => {\n // Remove existing dialog styles\n const existingStyles = document.querySelectorAll('style[data-zap-dialog-styles]');\n existingStyles.forEach(style => style.remove());\n \n const style = document.createElement('style');\n style.setAttribute('data-zap-dialog-styles', 'true');\n style.textContent = getDialogStyles(theme);\n document.head.appendChild(style);\n};\n\n/**\n * Opens (or re-opens) the zap modal. Returns the DialogComponent so the caller\n * can cache it between clicks.\n */\nexport async function init(params: OpenZapModalParams): Promise<DialogComponent> {\n const { npub, relays, cachedDialogComponent, buttonColor, fixedAmount, defaultAmount, initialAmount, url } = params;\n const npubHex = decodeNpub(npub);\n \n // Ensure custom element is defined\n if (!customElements.get('dialog-component')) {\n await customElements.whenDefined('dialog-component');\n }\n \n if (cachedDialogComponent) {\n // Find the actual dialog element\n const cachedDialog = document.querySelector('.nostr-base-dialog') as HTMLDialogElement | null;\n if (cachedDialog) {\n // remove success class if it exists\n cachedDialog.classList.remove('success');\n // show all controls that might have been hidden\n const controls = cachedDialog.querySelectorAll('.amount-buttons, .update-zap-container, .comment-container, .cta-btn, .copy-btn');\n controls.forEach(el => {\n if (el instanceof HTMLElement) el.style.display = '';\n });\n // reset the update button\n const updateZapBtn = cachedDialog.querySelector('.update-zap-btn') as HTMLButtonElement | null;\n if (updateZapBtn) updateZapBtn.style.display = '';\n // reset success overlay opacity if it was previously shown\n const successOverlay = cachedDialog.querySelector('.success-overlay') as HTMLElement | null;\n if (successOverlay) {\n successOverlay.style.opacity = '0';\n successOverlay.style.pointerEvents = 'none';\n }\n\n void refreshUI(cachedDialog);\n cachedDialogComponent.showModal();\n return cachedDialogComponent;\n }\n }\n\n // Minimal amount presets – feel free to tweak / add more later.\n const presets = [21, 100, 1000];\n let selectedAmount: number;\n if (typeof fixedAmount === 'number' && fixedAmount > 0) {\n selectedAmount = fixedAmount;\n } else if (typeof defaultAmount === 'number' && defaultAmount > 0) {\n selectedAmount = defaultAmount;\n } else if (typeof initialAmount === 'number' && initialAmount > 0) {\n selectedAmount = initialAmount;\n } else {\n selectedAmount = presets[0];\n }\n let customComment = '';\n let currentInvoice = '';\n let cleanupReceipt: (() => void) | null = null;\n\n // -----------------------------------------------------------------------------\n // Internal helpers\n // ---------------------------------------------------------------------------\n\n async function loadInvoice(amountSats: number, comment: string) {\n const authorId = npubHex;\n const meta = await getProfileMetadata(authorId);\n const endpoint = await getZapEndpoint(meta);\n const invoice = await fetchInvoice({\n zapEndpoint: endpoint,\n amount: amountSats * 1000, // -> msats\n comment,\n authorId,\n nip19Target: undefined,\n normalizedRelays: relays.split(','),\n anon: params.anon ?? false,\n url: url,\n });\n currentInvoice = invoice;\n\n // Zap receipt listener\n const relaysArr = relays.split(',');\n // Dispose previous listener before creating a new one\n if (cleanupReceipt) cleanupReceipt();\n cleanupReceipt = listenForZapReceipt({\n relays: relaysArr,\n receiversPubKey: npubHex,\n invoice,\n onSuccess: markSuccess\n });\n }\n\n async function qrImgSrc(invoice: string): Promise<string> {\n try {\n // Generate QR code as a data URL (base64 encoded image)\n return await QRCode.toDataURL(invoice, {\n width: 240,\n margin: 1,\n color: {\n dark: '#000000',\n light: '#ffffff'\n }\n });\n } catch (error) {\n console.error('Failed to generate QR code:', error);\n // Fallback to text representation if QR generation fails\n return `data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"240\" height=\"240\" viewBox=\"0 0 100 100\">\n <rect width=\"100%\" height=\"100%\" fill=\"white\"/>\n <text x=\"50%\" y=\"50%\" font-family=\"monospace\" font-size=\"10\" text-anchor=\"middle\" dominant-baseline=\"middle\" fill=\"black\">\n Invoice: ${invoice.substring(0, 10)}...\n </text>\n </svg>`;\n }\n }\n\n function setActiveAmountButtons(container: HTMLElement, amt: number) {\n container.querySelectorAll('button').forEach(btn => {\n if ((btn as HTMLButtonElement).dataset['val'] === String(amt)) {\n btn.classList.add('active');\n } else {\n btn.classList.remove('active');\n }\n });\n }\n\n async function refreshUI(dialog: HTMLDialogElement) {\n dialog.classList.add('loading');\n try {\n await loadInvoice(selectedAmount, customComment);\n const qrImg = dialog.querySelector('img.qr') as HTMLImageElement;\n qrImgSrc(currentInvoice).then(src => {\n qrImg.src = src;\n });\n\n const payBtn = dialog.querySelector('.cta-btn') as HTMLButtonElement;\n payBtn.disabled = false;\n } finally {\n dialog.classList.remove('loading');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Build dialog DOM\n // ---------------------------------------------------------------------------\n\n injectCSS(params.theme || 'light');\n\n // Create dialog component (not added to DOM)\n const dialogComponent = document.createElement('dialog-component') as DialogComponent;\n dialogComponent.setAttribute('header', 'Send a Zap');\n if (params.theme) {\n dialogComponent.setAttribute('data-theme', params.theme);\n }\n \n const amountButtonsHtml = presets\n .map(a => `<button type=\"button\" data-val=\"${a}\">${a} ⚡</button>`) // show sat symbol\n .join('');\n\n const hideAmountUI = typeof fixedAmount === 'number' && fixedAmount > 0;\n\n dialogComponent.innerHTML = `\n <div class=\"zap-dialog-content\">\n ${hideAmountUI ? '' : `<div class=\"amount-buttons\">${amountButtonsHtml}</div>`}\n ${hideAmountUI ? `<p class=\"zapping-amount\">Zapping ${fixedAmount} sats</p>` : ''}\n ${hideAmountUI ? '' : `<div class=\"update-zap-container\">\n <input type=\"number\" min=\"1\" placeholder=\"Custom sats\" class=\"custom-amount\" style=\"width:100%;padding:8px;border:1px solid #e2e8f0;border-radius:6px\" />\n <button type=\"button\" class=\"update-zap-btn\" style=\"padding:8px 12px;border:none;border-radius:6px;background:#7f00ff;color:#fff\">Update Zap</button>\n </div>`}\n ${hideAmountUI ? '' : `<div class=\"comment-container\">\n <input type=\"text\" placeholder=\"Comment (optional)\" class=\"comment-input\" style=\"width:100%;padding:8px;border:1px solid #e2e8f0;border-radius:6px\" />\n <button type=\"button\" class=\"add-comment-btn\" style=\"padding:8px 12px;border:none;border-radius:6px;background:#7f00ff;color:#fff\">Add</button>\n </div>`}\n <img class=\"qr\" width=\"240\" height=\"240\" alt=\"QR\" style=\"cursor:pointer\" />\n <br />\n <button type=\"button\" class=\"copy-btn\">Copy invoice</button>\n <button type=\"button\" class=\"cta-btn\" disabled>Open in wallet</button>\n <div class=\"loading-overlay\"><div class=\"loader\"></div></div>\n <div class=\"success-overlay\">⚡ Thank you!</div>\n </div>\n `;\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 event listeners\n // The dialog is created synchronously by showModal() and appended to document.body\n // Try both shadow root and light DOM, then fall back to document.body\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('[showZapDialog] 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 // Event wiring - moved listener setup to after initial invoice load\n const amountContainer = dialog.querySelector('.amount-buttons') as HTMLElement | null;\n if (amountContainer)\n amountContainer.addEventListener('click', async e => {\n const target = e.target as HTMLElement;\n if (target.tagName === 'BUTTON') {\n const val = Number(target.dataset['val']);\n if (!isNaN(val)) {\n selectedAmount = val;\n setActiveAmountButtons(amountContainer, val);\n const payBtn = dialog.querySelector('.cta-btn') as HTMLButtonElement;\n payBtn.disabled = true; // disable until new invoice fetched\n await refreshUI(dialog);\n }\n }\n });\n\n // custom amount change\n const customAmountInput = dialog.querySelector('.custom-amount') as HTMLInputElement | null;\n if (customAmountInput) customAmountInput.addEventListener('input', async e => {\n const val = Number((e.target as HTMLInputElement).value);\n if (val > 0) {\n selectedAmount = val;\n if (amountContainer) setActiveAmountButtons(amountContainer, -1); // clear presets highlight\n const payBtn = dialog.querySelector('.cta-btn') as HTMLButtonElement;\n payBtn.disabled = true; // will be enabled after Update Zap\n }\n });\n\n const commentInput = dialog.querySelector('.comment-input') as HTMLInputElement | null;\n if (commentInput) commentInput.addEventListener('input', e => {\n customComment = (e.target as HTMLInputElement).value.slice(0, 200);\n });\n\n const copyInvoice = async () => {\n if (!currentInvoice) return;\n await navigator.clipboard.writeText(currentInvoice);\n (dialog.querySelector('.copy-btn') as HTMLButtonElement).textContent = 'Copied!';\n setTimeout(() => {\n (dialog.querySelector('.copy-btn') as HTMLButtonElement).textContent = 'Copy invoice';\n }, 1500);\n };\n (dialog.querySelector('.copy-btn') as HTMLButtonElement).onclick = copyInvoice;\n (dialog.querySelector('img.qr') as HTMLImageElement).onclick = copyInvoice;\n\n // Update zap button\n const updateZapBtn = dialog.querySelector('.update-zap-btn') as HTMLButtonElement | null;\n if (updateZapBtn) updateZapBtn.addEventListener('click', async () => {\n const val = Number(customAmountInput?.value);\n if (!isNaN(val) && val > 0) {\n selectedAmount = val;\n updateZapBtn.disabled = true;\n await refreshUI(dialog);\n updateZapBtn.disabled = false;\n }\n });\n\n const addCommentBtn = dialog.querySelector('.add-comment-btn') as HTMLButtonElement | null;\n if (addCommentBtn) addCommentBtn.addEventListener('click', async () => {\n addCommentBtn.disabled = true;\n await refreshUI(dialog);\n addCommentBtn.disabled = false;\n });\n\n (dialog.querySelector('.cta-btn') as HTMLButtonElement).onclick = async () => {\n if (!currentInvoice) return;\n // try WebLN first\n if (window.webln) {\n try {\n await window.webln.enable();\n await window.webln.sendPayment(currentInvoice);\n markSuccess();\n return;\n } catch (e) {\n console.error('Nostr-Components: Zap button: webln payment failed', e);\n dialog.close();\n }\n }\n window.location.href = `lightning:${currentInvoice}`;\n };\n\n function markSuccess() {\n dialog.classList.add('success');\n const overlay = dialog.querySelector('.success-overlay') as HTMLElement;\n overlay.style.opacity = '1';\n // Ensure overlay does not block interactions (close button)\n overlay.style.pointerEvents = 'none';\n // hide other controls for clarity\n const controls = dialog.querySelectorAll('.amount-buttons, .update-zap-container, .comment-container, .cta-btn, .copy-btn');\n controls.forEach(el => {\n if (el instanceof HTMLElement) el.style.display = 'none';\n });\n // DialogComponent close button is always clickable\n }\n\n dialog.addEventListener('close', () => {\n if (cleanupReceipt) cleanupReceipt();\n });\n\n // Color customisation (buttonColor background)\n if (buttonColor) {\n const btnColor = buttonColor;\n (dialog.querySelector('.cta-btn') as HTMLButtonElement).style.background = btnColor;\n (dialog.querySelector('.cta-btn') as HTMLButtonElement).style.color = getContrastingTextColor(btnColor);\n }\n\n // Load first invoice & show\n await refreshUI(dialog);\n \n if (amountContainer && presets.includes(selectedAmount)) {\n setActiveAmountButtons(amountContainer, selectedAmount);\n } else if (!hideAmountUI) {\n const input = dialog.querySelector('.custom-amount') as HTMLInputElement | null;\n if (input) input.value = String(selectedAmount);\n if (amountContainer) setActiveAmountButtons(amountContainer, -1);\n }\n\n return dialogComponent;\n}\n\n// -----------------------------------------------------------------------------\n// Helper – compute readable text colour for custom bg\n// -----------------------------------------------------------------------------\nfunction getContrastingTextColor(hex: string): string {\n hex = hex.replace('#', '');\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map(ch => ch + ch)\n .join('');\n }\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n return brightness > 125 ? '#000' : '#fff';\n}\n","// SPDX-License-Identifier: MIT\n\n/**\n * Help dialog content styles for nostr-zap component\n * Contains only content-specific styles (base dialog styles in DialogComponent)\n */\nexport const getHelpDialogStyles = (): string => {\n return `\n /* Help Dialog Content Styles */\n .help-content {\n padding: var(--nostrc-spacing-md, 12px);\n }\n\n .help-content p {\n margin: 0 0 var(--nostrc-spacing-md, 12px) 0;\n color: var(--nostrc-theme-text-primary, #333333);\n line-height: 1.5;\n }\n\n .help-content p:last-child {\n margin-bottom: 0;\n }\n\n .help-content ul {\n margin: 0 0 var(--nostrc-spacing-md, 12px) 0;\n padding-left: var(--nostrc-spacing-lg, 16px);\n color: var(--nostrc-theme-text-primary, #333333);\n }\n\n .help-content li {\n margin-bottom: var(--nostrc-spacing-xs, 4px);\n line-height: 1.5;\n }\n\n .help-content li:last-child {\n margin-bottom: 0;\n }\n\n .help-content strong {\n font-weight: 600;\n color: var(--nostrc-theme-text-primary, #333333);\n }\n\n .help-content a:not(.youtube-link) {\n color: var(--nostrc-theme-primary, #0066cc);\n text-decoration: underline;\n }\n\n .help-content a:not(.youtube-link):hover {\n color: var(--nostrc-theme-primary-hover, #0052a3);\n }\n\n .youtube-link {\n display: inline-block;\n background: var(--nostrc-color-primary, #7f00ff);\n color: var(--nostrc-color-text-on-primary, #ffffff);\n padding: var(--nostrc-spacing-sm, 8px) var(--nostrc-spacing-md, 12px);\n border-radius: var(--nostrc-border-radius-md, 6px);\n text-decoration: none;\n font-weight: var(--nostrc-font-weight-medium, 500);\n margin-top: var(--nostrc-spacing-md, 12px);\n transition: background-color 0.2s ease;\n }\n\n .youtube-link:hover {\n background: var(--nostrc-color-primary-hover, #6b00d9);\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 { getHelpDialogStyles } from './dialog-help-style';\n\nconst YOUTUBE_URL = \"https://www.youtube.com/shorts/PDnrh8pkF3g\";\n\nexport const injectHelpDialogStyles = (): void => {\n // Check if styles are already injected\n if (document.querySelector('style[data-help-dialog-styles]')) return;\n \n const style = document.createElement('style');\n style.setAttribute('data-help-dialog-styles', 'true');\n style.textContent = getHelpDialogStyles();\n document.head.appendChild(style);\n};\n\nexport const showHelpDialog = async (theme?: 'light' | 'dark'): Promise<void> => {\n injectHelpDialogStyles();\n \n if (!customElements.get('dialog-component')) {\n await customElements.whenDefined('dialog-component');\n }\n \n const dialogComponent = document.createElement('dialog-component') as DialogComponent;\n dialogComponent.setAttribute('header', 'What is a Zap?');\n if (theme) {\n dialogComponent.setAttribute('data-theme', theme);\n }\n \n // Set dialog content\n dialogComponent.innerHTML = `\n <div class=\"help-content\">\n <p>Send instant tips to support content creators! Zaps are small Bitcoin Lightning payments that go directly to creators—no middleman.</p>\n <ul>\n <li>Send any amount instantly</li>\n <li>Money goes straight to the creator</li>\n <li>Powered by Bitcoin Lightning Network</li>\n </ul>\n <p><strong>How it works:</strong> Click zap, choose amount, scan QR code with a Lightning wallet, done!</p>\n <a href=\"${YOUTUBE_URL}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"youtube-link\">\n Watch Tutorial\n </a>\n </div>\n `;\n \n dialogComponent.showModal();\n};\n","// SPDX-License-Identifier: MIT\n\nimport { getComponentStyles } from \"../common/base-styles\";\n\nexport function getZappersDialogStyles(theme: 'light' | 'dark' = 'light'): string {\n const isDark = theme === 'dark';\n \n const customStyles = `\n /* === ZAPPERS DIALOG CONTENT STYLES === */\n .zappers-dialog-content {\n overflow: hidden;\n }\n\n .zappers-list {\n max-height: 60vh;\n overflow-y: auto;\n }\n\n /* Individual zap entry */\n .zap-entry {\n padding: var(--nostrc-spacing-md, 16px);\n border-bottom: 1px solid ${isDark ? '#333333' : '#f3f4f6'};\n transition: background-color 0.2s ease;\n }\n\n .zap-entry:last-child {\n border-bottom: none;\n }\n\n .zap-entry:hover {\n background: ${isDark ? '#2a2a2a' : '#f9fafb'};\n }\n\n .zap-author-info {\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-md, 16px);\n }\n\n .zap-author-picture {\n width: 40px;\n height: 40px;\n border-radius: var(--nostrc-border-radius-full, 50%);\n object-fit: cover;\n border: 2px solid ${isDark ? '#374151' : '#e5e7eb'};\n }\n\n .zap-author-picture-default {\n width: 40px;\n height: 40px;\n border-radius: var(--nostrc-border-radius-full, 50%);\n background: ${isDark ? '#374151' : '#f3f4f6'};\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: var(--nostrc-font-size-lg, 18px);\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n border: 2px solid ${isDark ? '#4b5563' : '#d1d5db'};\n }\n\n .zap-author-details {\n flex: 1;\n min-width: 0;\n }\n\n .zap-author-link {\n display: block;\n font-weight: 500;\n color: ${isDark ? '#ffffff' : '#1a1a1a'};\n text-decoration: none;\n font-size: var(--nostrc-font-size-base, 16px);\n margin-bottom: var(--nostrc-spacing-xs, 4px);\n transition: color 0.2s ease;\n }\n\n .zap-author-link:hover {\n color: var(--nostrc-color-primary, #7f00ff);\n }\n\n .zap-comment {\n font-size: var(--nostrc-font-size-sm, 14px);\n color: ${isDark ? '#d1d5db' : '#4b5563'};\n margin: var(--nostrc-spacing-xs, 4px) 0;\n line-height: 1.4;\n word-wrap: break-word;\n white-space: pre-wrap;\n }\n\n .zap-amount-date {\n font-size: var(--nostrc-font-size-sm, 14px);\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-xs, 4px);\n }\n\n /* Loading skeleton with npub */\n .skeleton-entry {\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-md, 16px);\n padding: var(--nostrc-spacing-md, 16px);\n border-bottom: 1px solid ${isDark ? '#333333' : '#f3f4f6'};\n }\n\n .skeleton-entry:last-child {\n border-bottom: none;\n }\n\n .skeleton-picture {\n width: 40px;\n height: 40px;\n border-radius: var(--nostrc-border-radius-full, 50%);\n background: linear-gradient(90deg, \n ${isDark ? '#374151' : '#f0f0f0'} 25%, \n ${isDark ? '#4b5563' : '#e0e0e0'} 50%, \n ${isDark ? '#374151' : '#f0f0f0'} 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n }\n\n .skeleton-name {\n font-size: var(--nostrc-font-size-base, 16px);\n font-weight: 500;\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;\n word-break: break-all;\n line-height: 1.2;\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 /* Empty state */\n .no-zaps {\n text-align: center;\n padding: var(--nostrc-spacing-xl, 32px);\n color: ${isDark ? '#9ca3af' : '#6b7280'};\n font-size: var(--nostrc-font-size-base, 16px);\n }\n\n /* Responsive design */\n @media (max-width: 640px) {\n .zap-author-picture,\n .zap-author-picture-default,\n .skeleton-picture {\n width: 36px;\n height: 36px;\n }\n \n .zap-author-link {\n font-size: var(--nostrc-font-size-sm, 14px);\n }\n \n .zap-amount-date {\n font-size: var(--nostrc-font-size-xs, 12px);\n }\n }\n\n /* Scrollbar styling */\n .zappers-list::-webkit-scrollbar {\n width: 6px;\n }\n\n .zappers-list::-webkit-scrollbar-track {\n background: ${isDark ? '#2a2a2a' : '#f1f5f9'};\n border-radius: 3px;\n }\n\n .zappers-list::-webkit-scrollbar-thumb {\n background: ${isDark ? '#4b5563' : '#cbd5e1'};\n border-radius: 3px;\n }\n\n .zappers-list::-webkit-scrollbar-thumb:hover {\n background: ${isDark ? '#6b7280' : '#94a3b8'};\n }\n `;\n \n return getComponentStyles(customStyles);\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 { getZappersDialogStyles } from './dialog-zappers-style';\nimport { getBatchedProfileMetadata, extractProfileMetadataContent, ZapDetails } from './zap-utils';\nimport { escapeHtml, formatRelativeTime, hexToNpub, isValidUrl } from '../common/utils';\nimport { isValidPublicKey } from '../nostr-comment/utils';\n\n/**\n * Modal dialog for displaying individual zap details (zappers).\n * \n * Shows a list of all zaps received by a user with:\n * - Zap amount\n * - Zap date (relative time)\n * - Zap author's name\n * - Zap author's profile picture\n * - Clickable links to author profiles via njump.me\n */\n\nexport interface OpenZappersModalParams {\n zapDetails: ZapDetails[];\n theme?: 'light' | 'dark';\n}\n\n/**\n * Inject zappers dialog content styles into document head\n * Prevents duplicate injection by checking for existing styles\n */\nexport const injectZappersDialogStyles = (theme: 'light' | 'dark' = 'light') => {\n // Remove existing zappers dialog styles\n const existingStyles = document.querySelectorAll('style[data-zappers-dialog-styles]');\n existingStyles.forEach(style => style.remove());\n \n const style = document.createElement('style');\n style.setAttribute('data-zappers-dialog-styles', 'true');\n style.textContent = getZappersDialogStyles(theme);\n document.head.appendChild(style);\n}\n\ninterface EnhancedZapDetails extends ZapDetails {\n authorName?: string;\n authorPicture?: string;\n authorNpub?: string;\n}\n\n/**\n * Render individual zap entry HTML (with profile data)\n */\nfunction renderZapEntry(zap: EnhancedZapDetails, index: number): string {\n const authorNameSafe = escapeHtml(zap.authorName || 'Unknown zapper');\n const npubSafe = isValidPublicKey(zap.authorNpub || '') ? zap.authorNpub : '';\n const njumpUrl = `https://njump.me/${npubSafe}`;\n const profilePictureSafe = isValidUrl(zap.authorPicture || '') ? zap.authorPicture || '' : '';\n \n\n const profilePicture = zap.authorPicture \n ? `<img src=\"${profilePictureSafe}\" alt=\"${authorNameSafe}\" class=\"zap-author-picture\" />`\n : `<div class=\"zap-author-picture-default\">👤</div>`;\n \n const commentHtml = zap.comment \n ? `<div class=\"zap-comment\">${zap.comment}</div>`\n : '';\n \n return `\n <div class=\"zap-entry\" data-zap-index=\"${index}\" data-author-pubkey=\"${zap.authorPubkey}\">\n <div class=\"zap-author-info\">\n ${profilePicture}\n <div class=\"zap-author-details\">\n <a href=\"${njumpUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"zap-author-link\">\n ${authorNameSafe}\n </a>\n ${commentHtml}\n <div class=\"zap-amount-date\">\n ${zap.amount.toLocaleString()} ⚡ • ${formatRelativeTime(Math.floor(zap.date.getTime() / 1000))}\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Render skeleton zap entry HTML (with npub)\n */\nfunction renderSkeletonZapEntry(zap: ZapDetails, npub: string, index: number): string {\n return `\n <div class=\"zap-entry skeleton-entry\" data-zap-index=\"${index}\" data-author-pubkey=\"${zap.authorPubkey}\">\n <div class=\"zap-author-info\">\n <div class=\"skeleton-picture\"></div>\n <div class=\"zap-author-details\">\n <div class=\"zap-author-link skeleton-name\">\n ${escapeHtml(npub)}\n </div>\n <div class=\"zap-amount-date\">\n ${zap.amount.toLocaleString()} ⚡ • ${formatRelativeTime(Math.floor(zap.date.getTime() / 1000))}\n </div>\n </div>\n </div>\n </div>\n `;\n}\n\n/**\n * Opens the zappers dialog showing individual zap details\n */\nexport async function openZappersDialog(params: OpenZappersModalParams): Promise<DialogComponent> {\n const { zapDetails, theme = 'light' } = params;\n \n // Inject styles\n injectZappersDialogStyles(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', 'Zappers');\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(zapDetails);\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 // The dialog is created synchronously by showModal() and appended to document.body\n // Try both shadow root and light DOM, then fall back to document.body\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('[showZappersDialog] 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 && zapDetails.length > 0) {\n enhanceZapDetailsProgressively(dialog, zapDetails);\n }\n\n return dialogComponent;\n}\n\n/**\n * Render initial dialog content with skeleton loaders showing npubs\n */\nasync function renderInitialContent(zapDetails: ZapDetails[]): Promise<string> {\n if (zapDetails.length === 0) {\n return `\n <div class=\"zappers-dialog-content\">\n <div class=\"zappers-list\">\n <div class=\"no-zaps\">No zaps received yet</div>\n </div>\n </div>\n `;\n }\n\n // Convert all pubkeys to npubs for immediate display\n const npubs = zapDetails.map(zap => hexToNpub(zap.authorPubkey));\n\n const skeletonEntries = zapDetails.map((zap, index) => \n renderSkeletonZapEntry(zap, npubs[index], index)\n ).join('');\n\n return `\n <div class=\"zappers-dialog-content\">\n <div class=\"zappers-list\">\n ${skeletonEntries}\n </div>\n </div>\n `;\n}\n\n/**\n * Progressively enhance zap details with profile information (batched approach)\n */\nasync function enhanceZapDetailsProgressively(dialog: HTMLDialogElement, zapDetails: ZapDetails[]): Promise<void> {\n const zappersList = dialog.querySelector('.zappers-list') as HTMLElement;\n if (!zappersList) return;\n\n // Get unique author IDs\n const uniqueAuthorIds = [...new Set(zapDetails.map(zap => zap.authorPubkey))];\n console.log(\"Nostr-Components: Zappers 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 zap entry\n for (let index = 0; index < zapDetails.length; index++) {\n const zap = zapDetails[index];\n const profile = profileMap.get(zap.authorPubkey);\n const npub = npubMap.get(zap.authorPubkey) || zap.authorPubkey;\n \n let enhanced: EnhancedZapDetails;\n \n if (profile) {\n const profileContent = extractProfileMetadataContent(profile);\n enhanced = {\n ...zap,\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 ...zap,\n authorName: npub,\n authorNpub: npub,\n };\n }\n\n // Find the corresponding skeleton entry by index and replace it\n const skeletonEntry = zappersList.querySelector(`[data-zap-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderZapEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n }\n\n console.log(\"Nostr-Components: Zappers dialog: Progressive enhancement completed for\", zapDetails.length, \"zap entries\");\n } catch (error) {\n console.error(\"Nostr-Components: Zappers dialog: Error in batched profile enhancement\", error);\n \n // Fallback to individual processing if batched approach fails\n console.log(\"Nostr-Components: Zappers dialog: Falling back to individual profile fetching\");\n await enhanceZapDetailsIndividually(dialog, zapDetails);\n }\n}\n\n/**\n * Fallback: Enhance zap details individually (original approach)\n */\nasync function enhanceZapDetailsIndividually(dialog: HTMLDialogElement, zapDetails: ZapDetails[]): Promise<void> {\n const zappersList = dialog.querySelector('.zappers-list') as HTMLElement;\n if (!zappersList) return;\n\n // Create a map to track which profiles we've already fetched\n const profileCache = new Map<string, EnhancedZapDetails>();\n \n // Fetch all profile metadata in parallel\n const profilePromises = zapDetails.map(async (zap, index) => {\n // Check if we already have this profile cached\n if (profileCache.has(zap.authorPubkey)) {\n const cachedProfile = profileCache.get(zap.authorPubkey)!;\n return {\n index,\n enhanced: {\n ...zap,\n authorName: cachedProfile.authorName,\n authorPicture: cachedProfile.authorPicture,\n authorNpub: cachedProfile.authorNpub,\n }\n };\n }\n\n try {\n const { getProfileMetadata } = await import('./zap-utils');\n const profileMetadata = await getProfileMetadata(zap.authorPubkey);\n const profileContent = extractProfileMetadataContent(profileMetadata);\n const npub = hexToNpub(zap.authorPubkey);\n \n const enhanced = {\n ...zap,\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(zap.authorPubkey, enhanced);\n \n return {\n index,\n enhanced\n };\n } catch (error) {\n console.error(\"Nostr-Components: Zappers dialog: Error fetching profile for\", zap.authorPubkey, error);\n // Fallback with just pubkey converted to npub\n const npub = hexToNpub(zap.authorPubkey);\n const enhanced = {\n ...zap,\n authorName: npub,\n authorNpub: npub,\n };\n \n // Cache the fallback profile\n profileCache.set(zap.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 = zappersList.querySelector(`[data-zap-index=\"${index}\"]`);\n if (skeletonEntry) {\n const enhancedEntry = renderZapEntry(enhanced, index);\n skeletonEntry.outerHTML = enhancedEntry;\n }\n } catch (error) {\n console.error(\"Nostr-Components: Zappers dialog: Error processing profile enhancement\", error);\n }\n }\n}\n\n","// SPDX-License-Identifier: MIT\n\nimport { getSuccessAnimation } from '../common/theme';\nimport { escapeHtml } from '../common/utils';\nimport { IRenderOptions } from '../base/render-options';\n\nexport interface RenderZapButtonOptions extends IRenderOptions {\n isAmountLoading: boolean;\n isSuccess: boolean;\n buttonText: string;\n totalZapAmount: number | null;\n hasZaps?: boolean;\n}\n\nexport function renderZapButton({\n isLoading,\n isError,\n isSuccess,\n errorMessage,\n buttonText,\n totalZapAmount,\n isAmountLoading,\n hasZaps = false,\n}: RenderZapButtonOptions): string {\n\n if (isError) {\n return renderError(errorMessage || '');\n }\n\n if (isLoading) {\n return renderLoading(isAmountLoading);\n }\n\n const iconContent = isSuccess\n ? getSuccessAnimation('light')\n : getLightningIcon();\n const textContent = isSuccess\n ? `<span>Zapped</span>`\n : `<span>${escapeHtml(buttonText)}</span>`;\n\n return renderContainer(iconContent, textContent, totalZapAmount, isAmountLoading, hasZaps);\n}\n\nfunction renderLoading(isAmountLoading: boolean): string {\n return renderContainer(\n getLightningIcon(),\n '<span class=\"button-text-skeleton\"></span>',\n null,\n isAmountLoading\n );\n}\n\nfunction renderError(errorMessage: string): string {\n return renderErrorContainer(\n '<div class=\"error-icon\">&#9888;</div>',\n escapeHtml(errorMessage)\n );\n}\n\nfunction renderErrorContainer(leftContent: string, rightContent: string): string {\n return `\n <div class=\"nostr-zap-button-container\">\n <div class=\"nostr-zap-button-left-container\">\n ${leftContent}\n </div>\n <div class=\"nostr-zap-button-right-container\">\n ${rightContent}\n </div>\n </div>\n `;\n}\n\nfunction renderContainer(iconContent: string, textContent: string, totalZapAmount: number | null, isAmountLoading: boolean, hasZaps: boolean = false): string {\n const zapAmountHtml = isAmountLoading \n ? `<span class=\"total-zap-amount skeleton\"></span>` \n : (totalZapAmount !== null ? `<span class=\"total-zap-amount${hasZaps ? ' clickable' : ''}\">${totalZapAmount.toLocaleString()} ⚡ sats received</span>` : '');\n \n const helpIconHtml = `<button class=\"help-icon\" title=\"What is a zap?\">?</button>`;\n \n return `\n <div class=\"nostr-zap-button-container\">\n <button class=\"nostr-zap-button\">\n ${iconContent}\n ${textContent}\n </button>\n ${zapAmountHtml} ${helpIconHtml}\n </div>\n `;\n}\n\nfunction getLightningIcon(): string {\n // Yellow lightning regardless of text color\n return `<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 2L3 14h7v8l10-12h-7z\" fill=\"#FFC800\"/></svg>`;\n}\n","// SPDX-License-Identifier: MIT\n\nimport { getComponentStyles } from \"../common/base-styles\";\n\nexport function getZapButtonStyles(): string {\n const customStyles = `\n /* === ZAP BUTTON CONTAINER PATTERN === */\n :host {\n /* Icon sizing (overridable via CSS variables) */\n --nostrc-icon-height: 25px;\n --nostrc-icon-width: 25px;\n\n /* Zap button CSS variables (overridable by parent components) */\n --nostrc-zap-btn-padding: var(--nostrc-spacing-sm) var(--nostrc-spacing-md);\n --nostrc-zap-btn-border-radius: var(--nostrc-border-radius-md);\n --nostrc-zap-btn-border: var(--nostrc-border-width) solid var(--nostrc-color-border);\n --nostrc-zap-btn-min-height: 47px;\n --nostrc-zap-btn-width: auto;\n --nostrc-zap-btn-horizontal-alignment: left;\n --nostrc-zap-btn-bg: var(--nostrc-theme-bg, #ffffff);\n --nostrc-zap-btn-color: var(--nostrc-theme-text-primary, #333333);\n --nostrc-zap-btn-font-family: var(--nostrc-font-family-primary);\n --nostrc-zap-btn-font-size: var(--nostrc-font-size-base);\n \n /* Hover state variables */\n --nostrc-zap-btn-hover-bg: var(--nostrc-theme-hover-bg, rgba(0, 0, 0, 0.05));\n --nostrc-zap-btn-hover-color: var(--nostrc-theme-text-primary, #333333);\n --nostrc-zap-btn-hover-border: var(--nostrc-border-width) solid var(--nostrc-theme-border, var(--nostrc-color-border));\n\n /* Make the host a flex container for button + amount */\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n gap: var(--nostrc-spacing-md);\n font-family: var(--nostrc-zap-btn-font-family);\n font-size: var(--nostrc-zap-btn-font-size);\n }\n\n /* Focus state for accessibility */\n :host(:focus-visible) {\n outline: 2px solid var(--nostrc-color-primary, #007bff);\n outline-offset: 2px;\n }\n\n :host(.is-error) .nostr-zap-button-container {\n border: var(--nostrc-border-width) solid var(--nostrc-color-error-text);\n border-radius: var(--nostrc-border-radius-md);\n padding: var(--nostrc-spacing-sm);\n color: var(--nostrc-color-error-text);\n }\n\n .nostr-zap-button-container {\n display: flex;\n align-items: center;\n gap: var(--nostrc-spacing-md);\n width: fit-content;\n }\n\n .nostr-zap-button-left-container {\n display: flex;\n align-items: center;\n }\n\n .nostr-zap-button-right-container {\n display: flex;\n align-items: center;\n }\n\n .nostr-zap-button {\n display: flex;\n align-items: center;\n justify-content: var(--nostrc-zap-btn-horizontal-alignment);\n gap: var(--nostrc-spacing-sm);\n background: var(--nostrc-zap-btn-bg);\n color: var(--nostrc-zap-btn-color);\n border: var(--nostrc-zap-btn-border);\n border-radius: var(--nostrc-zap-btn-border-radius);\n padding: var(--nostrc-zap-btn-padding);\n min-height: var(--nostrc-zap-btn-min-height);\n width: var(--nostrc-zap-btn-width);\n cursor: pointer;\n transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;\n font-family: inherit;\n font-size: inherit;\n }\n\n /* Hover state on the button */\n .nostr-zap-button:hover {\n background: var(--nostrc-zap-btn-hover-bg);\n color: var(--nostrc-zap-btn-hover-color);\n border: var(--nostrc-zap-btn-hover-border);\n }\n\n .nostr-zap-button:disabled {\n pointer-events: none;\n user-select: none;\n opacity: 0.6;\n }\n\n :host:not([user-status=\"ready\"]) .nostr-zap-button {\n cursor: not-allowed;\n }\n\n /* SVG Icon Styles */\n .nostr-zap-button svg {\n display: inline-block;\n vertical-align: middle;\n width: var(--nostrc-icon-width);\n height: var(--nostrc-icon-height);\n }\n\n /* Total zap amount display */\n .total-zap-amount {\n font-size: var(--nostrc-font-size-sm);\n color: var(--nostrc-theme-text-secondary, #666666);\n white-space: nowrap;\n }\n\n /* Clickable zap amount */\n .total-zap-amount.clickable {\n cursor: pointer;\n transition: color 0.2s ease;\n }\n\n .total-zap-amount.clickable:hover {\n color: var(--nostrc-color-primary, #7f00ff);\n }\n\n /* Help icon */\n .help-icon {\n background: none;\n border: 1px solid var(--nostrc-color-border, #e0e0e0);\n border-radius: var(--nostrc-border-radius-full, 50%);\n width: var(--nostrc-help-icon-size, 16px);\n height: var(--nostrc-help-icon-size, 16px);\n font-size: calc(var(--nostrc-help-icon-size, 16px) * 0.7);\n font-weight: bold;\n color: var(--nostrc-theme-text-secondary, #666666);\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: var(--nostrc-spacing-xs, 4px);\n transition: all 0.2s ease;\n }\n\n .help-icon:hover {\n background: var(--nostrc-color-hover-background, rgba(0, 0, 0, 0.05));\n border-color: var(--nostrc-color-primary, #7f00ff);\n color: var(--nostrc-color-primary, #7f00ff);\n }\n\n /* Skeleton loader for zap amount */\n .total-zap-amount.skeleton {\n background: linear-gradient(90deg, \n var(--nostrc-color-skeleton, #f0f0f0) 25%, \n var(--nostrc-color-skeleton-highlight, #e0e0e0) 50%, \n var(--nostrc-color-skeleton, #f0f0f0) 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n border-radius: var(--nostrc-border-radius-sm);\n width: 80px;\n height: 1.2em;\n display: inline-block;\n }\n\n /* Skeleton loader for button text */\n .button-text-skeleton {\n background: linear-gradient(90deg, \n var(--nostrc-color-skeleton, #f0f0f0) 25%, \n var(--nostrc-color-skeleton-highlight, #e0e0e0) 50%, \n var(--nostrc-color-skeleton, #f0f0f0) 75%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n border-radius: var(--nostrc-border-radius-sm);\n width: 60px;\n height: 1em;\n display: inline-block;\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 /* Error message styling */\n .nostr-zap-button-error small {\n color: var(--nostrc-color-error-text);\n font-size: var(--nostrc-font-size-sm);\n line-height: 1em;\n max-width: 250px;\n white-space: pre-line;\n }\n `;\n \n return getComponentStyles(customStyles);\n}\n\n","// SPDX-License-Identifier: MIT\n\nimport { NostrUserComponent } from '../base/user-component/nostr-user-component';\nimport { NCStatus } from '../base/base-component/nostr-base-component';\nimport { init as openZapModal } from './dialog-zap';\nimport { showHelpDialog } from './dialog-help';\nimport { openZappersDialog } from './dialog-zappers';\nimport { renderZapButton, RenderZapButtonOptions } from './render';\nimport { getZapButtonStyles } from './style';\nimport { fetchTotalZapAmount, ZapDetails } from './zap-utils';\nimport { isValidUrl } from '../common/utils';\nimport type { DialogComponent } from '../base/dialog-component/dialog-component';\nimport { ensureInitialized } from '../common/nostr-login-service';\n\n/**\n * <nostr-zap>\n * Attributes:\n * - npub | pubkey | nip05 (required) : Nostr user to zap\n * - relays (optional) : comma-separated relay URLs\n * - theme (optional) : \"light\" | \"dark\" (default light)\n * - text (optional) : custom text (default \"Zap\")\n * - amount (optional) : pre-defined zap amount in sats\n * - default-amount (optional) : default zap amount in sats (default 21)\n * - url (optional) : URL to send zap to (enables URL-based zaps)\n * \n * TODO: Doesn't yet support dynamic updates of attributes.\n */\nexport default class NostrZap extends NostrUserComponent {\n protected zapActionStatus= this.channel('zapAction');\n protected zapListStatus = this.channel('zapList');\n \n private totalZapAmount: number | null = null;\n private cachedZapDetails: ZapDetails[] = [];\n private cachedAmountDialog: DialogComponent | null = null;\n\n constructor() {\n super();\n }\n\n connectedCallback() {\n super.connectedCallback?.();\n if (this.zapListStatus.get() == NCStatus.Idle) {\n this.initChannelStatus('zapList', NCStatus.Loading, { reflectOverall: false });\n }\n this.attachDelegatedListeners();\n this.render();\n }\n\n static get observedAttributes() {\n return [\n ...super.observedAttributes,\n 'text',\n 'amount',\n 'default-amount',\n 'url'\n ];\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue === newValue) return;\n super.attributeChangedCallback(name, oldValue, newValue);\n // TODO: To handle text, amount, and default-amount changes?\n this.render();\n }\n\n disconnectedCallback() {\n if (\n this.cachedAmountDialog &&\n typeof this.cachedAmountDialog.close === \"function\"\n ) {\n this.cachedAmountDialog.close();\n }\n }\n\n /** Base class functions */\n protected onStatusChange(_status: NCStatus) {\n this.render();\n }\n\n protected onUserReady(_user: any, _profile: any) {\n this.render();\n this.updateZapCount();\n }\n\n /** Protected methods */\n protected validateInputs(): boolean {\n if (!super.validateInputs()) {\n this.zapActionStatus.set(NCStatus.Idle);\n this.zapListStatus.set(NCStatus.Idle);\n return false;\n }\n\n const textAttr = this.getAttribute(\"text\");\n const amtAttr = this.getAttribute(\"amount\");\n const defaultAmtAttr= this.getAttribute(\"default-amount\");\n const urlAttr = this.getAttribute(\"url\");\n const tagName = this.tagName.toLowerCase();\n\n let errorMessage: string | null = null;\n\n if (textAttr && textAttr.length > 128) {\n errorMessage = \"Max text length: 128 characters\";\n } else if (amtAttr) {\n const num = Number(amtAttr);\n if (isNaN(num) || num <= 0) {\n errorMessage = \"Invalid amount\";\n } else if (num > 210000) {\n errorMessage = \"Amount too high (max 210,000 sats)\";\n }\n } else if (defaultAmtAttr) {\n const num = Number(defaultAmtAttr);\n if (isNaN(num) || num <= 0) {\n errorMessage = \"Invalid default-amount\";\n } else if (num > 210000) {\n errorMessage = \"Default-amount too high (max 210,000 sats)\";\n }\n } else if (urlAttr) {\n if (!isValidUrl(urlAttr)) {\n errorMessage = \"Invalid URL format\";\n }\n }\n\n if (errorMessage) {\n this.zapActionStatus.set(NCStatus.Error, errorMessage);\n this.zapListStatus.set(NCStatus.Error, errorMessage);\n this.userStatus.set(NCStatus.Idle);\n console.error(`Nostr-Components: ${tagName}: ${errorMessage}`);\n return false;\n }\n\n return true;\n }\n\n /** Private functions */\n private async handleZapClick() {\n if (this.userStatus.get() !== NCStatus.Ready) return;\n\n this.zapActionStatus.set(NCStatus.Loading);\n this.render();\n\n try {\n // Ensure NostrLogin is initialized (sets up window.nostr)\n await ensureInitialized();\n\n if (!this.user) {\n this.zapActionStatus.set(NCStatus.Error, \"Could not resolve user to zap.\");\n this.render();\n return;\n }\n\n const relays = this.getRelays().join(\",\");\n const npub = this.user.npub;\n\n this.cachedAmountDialog = await openZapModal({\n npub,\n relays,\n cachedDialogComponent: this.cachedAmountDialog,\n theme: this.theme === 'dark' ? 'dark' : 'light',\n fixedAmount: (() => {\n const amtAttr = this.getAttribute(\"amount\");\n if (!amtAttr) return undefined;\n const num = Number(amtAttr);\n if (isNaN(num) || num <= 0 || num > 210000) {\n console.error(\"Nostr-Components: Zap button: Max zap amount: 210,000 sats\");\n return undefined;\n }\n return num;\n })(),\n defaultAmount: (() => {\n const defAttr = this.getAttribute(\"default-amount\");\n if (!defAttr) return 21;\n const num = Number(defAttr);\n if (isNaN(num) || num <= 0 || num > 210000) {\n console.error(\"Nostr-Components: Zap button: Max zap amount: 210,000 sats\");\n return 21;\n }\n return num;\n })(),\n url: this.getAttribute(\"url\") || undefined,\n anon: false,\n });\n this.zapActionStatus.set(NCStatus.Ready);\n } catch (e: any) {\n this.zapActionStatus.set(NCStatus.Error, e?.message || \"Unable to zap\");\n } finally {\n this.render();\n }\n }\n\n private async handleHelpClick() {\n try {\n await showHelpDialog(this.theme === 'dark' ? 'dark' : 'light');\n } catch (error) {\n console.error('Error showing help dialog:', error);\n }\n }\n\n private async handleZappersClick() {\n if (this.cachedZapDetails.length === 0) {\n return; // No zaps to show\n }\n\n try {\n await openZappersDialog({\n zapDetails: this.cachedZapDetails,\n theme: this.theme === 'dark' ? 'dark' : 'light',\n });\n } catch (error) {\n console.error(\"Nostr-Components: Zap button: Error opening zappers dialog\", error);\n }\n }\n\n private attachDelegatedListeners() {\n this.delegateEvent('click', '.nostr-zap-button', (e) => {\n e.preventDefault?.();\n e.stopPropagation?.();\n void this.handleZapClick();\n });\n\n this.delegateEvent('click', '.help-icon', (e) => {\n e.preventDefault?.();\n e.stopPropagation?.();\n this.handleHelpClick();\n });\n\n this.delegateEvent('click', '.total-zap-amount', (e) => {\n e.preventDefault?.();\n e.stopPropagation?.();\n void this.handleZappersClick();\n });\n }\n\n private async updateZapCount() {\n if (!this.user) return;\n\n try {\n this.zapListStatus.set(NCStatus.Loading);\n this.render();\n \n await this.ensureNostrConnected();\n const result = await fetchTotalZapAmount({ \n pubkey: this.user.pubkey, \n relays: this.getRelays(),\n url: this.getAttribute(\"url\") || undefined\n });\n this.totalZapAmount = result.totalAmount;\n this.cachedZapDetails = result.zapDetails;\n this.zapListStatus.set(NCStatus.Ready);\n } catch (e) {\n console.error(\"Nostr-Components: Zap button: Failed to fetch zap count\", e);\n this.totalZapAmount = null;\n this.zapListStatus.set(NCStatus.Error);\n } finally {\n this.render();\n }\n }\n\n protected renderContent() {\n const isUserLoading = this.userStatus.get() == NCStatus.Loading;\n const isAmountLoading = this.zapListStatus.get() == NCStatus.Loading;\n const isError = this.computeOverall() === NCStatus.Error;\n const errorMessage = this.errorMessage;\n const buttonText = this.getAttribute('text') || 'Zap';\n\n const renderOptions: RenderZapButtonOptions = {\n isLoading: isUserLoading,\n isAmountLoading: isAmountLoading,\n isError: isError,\n isSuccess: false, // TODO: Add success state handling\n errorMessage: errorMessage,\n buttonText: buttonText,\n totalZapAmount: this.totalZapAmount,\n hasZaps: this.cachedZapDetails.length > 0,\n };\n\n this.shadowRoot!.innerHTML = `\n ${getZapButtonStyles()}\n ${renderZapButton(renderOptions)}\n `;\n }\n}\n\nif (!customElements.get('nostr-zap')) {\n customElements.define('nostr-zap', NostrZap);\n}\n"],"file":"components/nostr-zap.es.js"}